~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/drivers/media/video/cpia_pp.c

Version: ~ [ 2.2.5 ] ~ [ 2.4.1 ] ~ [ 2.4.9 ] ~ [ 2.6.17.10 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * cpia_pp CPiA Parallel Port driver
  3  *
  4  * Supports CPiA based parallel port Video Camera's.
  5  *
  6  * (C) Copyright 1999 Bas Huisman <bhuism@cs.utwente.nl>
  7  * (C) Copyright 1999-2000 Scott J. Bertin <sbertin@mindspring.com>,
  8  * (C) Copyright 1999-2000 Peter Pregler <Peter_Pregler@email.com>
  9  *
 10  * This program is free software; you can redistribute it and/or modify
 11  * it under the terms of the GNU General Public License as published by
 12  * the Free Software Foundation; either version 2 of the License, or
 13  * (at your option) any later version.
 14  *
 15  * This program is distributed in the hope that it will be useful,
 16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 18  * GNU General Public License for more details.
 19  *
 20  * You should have received a copy of the GNU General Public License
 21  * along with this program; if not, write to the Free Software
 22  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 23  */
 24 
 25 #include <linux/config.h>
 26 #include <linux/version.h>
 27 
 28 #include <linux/module.h>
 29 #include <linux/init.h>
 30 
 31 #include <linux/kernel.h>
 32 #include <linux/parport.h>
 33 #include <linux/interrupt.h>
 34 #include <linux/delay.h>
 35 #include <linux/smp_lock.h>
 36 
 37 #ifdef CONFIG_KMOD
 38 #include <linux/kmod.h>
 39 #endif
 40 
 41 /* #define _CPIA_DEBUG_         define for verbose debug output */
 42 #include "cpia.h"
 43 
 44 static int cpia_pp_open(void *privdata);
 45 static int cpia_pp_registerCallback(void *privdata, void (*cb) (void *cbdata),
 46                                     void *cbdata);
 47 static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data);
 48 static int cpia_pp_streamStart(void *privdata);
 49 static int cpia_pp_streamStop(void *privdata);
 50 static int cpia_pp_streamRead(void *privdata, u8 *buffer, int noblock);
 51 static int cpia_pp_close(void *privdata);
 52 
 53 #define ABOUT "Parallel port driver for Vision CPiA based cameras"
 54 
 55 /* IEEE 1284 Compatiblity Mode signal names     */
 56 #define nStrobe         PARPORT_CONTROL_STROBE    /* inverted */
 57 #define nAutoFd         PARPORT_CONTROL_AUTOFD    /* inverted */
 58 #define nInit           PARPORT_CONTROL_INIT
 59 #define nSelectIn       PARPORT_CONTROL_SELECT
 60 #define IntrEnable      PARPORT_CONTROL_INTEN     /* normally zero for no IRQ */
 61 #define DirBit          PARPORT_CONTROL_DIRECTION /* 0 = Forward, 1 = Reverse   */
 62 
 63 #define nFault          PARPORT_STATUS_ERROR
 64 #define Select          PARPORT_STATUS_SELECT
 65 #define PError          PARPORT_STATUS_PAPEROUT
 66 #define nAck            PARPORT_STATUS_ACK
 67 #define Busy            PARPORT_STATUS_BUSY       /* inverted */        
 68 
 69 /* some more */
 70 #define HostClk         nStrobe
 71 #define HostAck         nAutoFd
 72 #define nReverseRequest nInit
 73 #define Active_1284     nSelectIn
 74 #define nPeriphRequest  nFault
 75 #define XFlag           Select
 76 #define nAckReverse     PError
 77 #define PeriphClk       nAck
 78 #define PeriphAck       Busy
 79 
 80 /* these can be used to correct for the inversion on some bits */
 81 #define STATUS_INVERSION_MASK   (Busy)
 82 #define CONTROL_INVERSION_MASK  (nStrobe|nAutoFd|nSelectIn)
 83 
 84 #define ECR_empty       0x01
 85 #define ECR_full        0x02
 86 #define ECR_serviceIntr 0x04
 87 #define ECR_dmaEn       0x08
 88 #define ECR_nErrIntrEn  0x10
 89 
 90 #define ECR_mode_mask   0xE0
 91 #define ECR_SPP_mode    0x00
 92 #define ECR_PS2_mode    0x20
 93 #define ECR_FIFO_mode   0x40
 94 #define ECR_ECP_mode    0x60
 95 
 96 #define ECP_FIFO_SIZE   16
 97 #define DMA_BUFFER_SIZE               PAGE_SIZE
 98         /* for 16bit DMA make sure DMA_BUFFER_SIZE is 16 bit aligned */
 99 #define PARPORT_CHUNK_SIZE      PAGE_SIZE/* >=2.3.x */
100                                 /* we read this many bytes at once */
101 
102 #define GetECRMasked(port,mask) (parport_read_econtrol(port) & (mask))
103 #define GetStatus(port)         ((parport_read_status(port)^STATUS_INVERSION_MASK)&(0xf8))
104 #define SetStatus(port,val)     parport_write_status(port,(val)^STATUS_INVERSION_MASK)
105 #define GetControl(port)        ((parport_read_control(port)^CONTROL_INVERSION_MASK)&(0x3f))
106 #define SetControl(port,val)    parport_write_control(port,(val)^CONTROL_INVERSION_MASK)
107 
108 #define GetStatusMasked(port,mask)      (GetStatus(port) & (mask))
109 #define GetControlMasked(port,mask)     (GetControl(port) & (mask))
110 #define SetControlMasked(port,mask)     SetControl(port,GetControl(port) | (mask));
111 #define ClearControlMasked(port,mask)   SetControl(port,GetControl(port)&~(mask));
112 #define FrobControlBit(port,mask,value) SetControl(port,(GetControl(port)&~(mask))|((value)&(mask)));
113 
114 #define PACKET_LENGTH   8
115 
116 /* Magic numbers for defining port-device mappings */
117 #define PPCPIA_PARPORT_UNSPEC -4
118 #define PPCPIA_PARPORT_AUTO -3
119 #define PPCPIA_PARPORT_OFF -2
120 #define PPCPIA_PARPORT_NONE -1
121 
122 #ifdef MODULE
123 static int parport_nr[PARPORT_MAX] = {[0 ... PARPORT_MAX - 1] = PPCPIA_PARPORT_UNSPEC};
124 static char *parport[PARPORT_MAX] = {NULL,};
125 
126 MODULE_AUTHOR("B. Huisman <bhuism@cs.utwente.nl> & Peter Pregler <Peter_Pregler@email.com>");
127 MODULE_DESCRIPTION("Parallel port driver for Vision CPiA based cameras");
128 MODULE_PARM(parport, "1-" __MODULE_STRING(PARPORT_MAX) "s");
129 MODULE_PARM_DESC(parport, "'auto' or a list of parallel port numbers. Just like lp.");
130 #else
131 static int parport_nr[PARPORT_MAX] __initdata =
132         {[0 ... PARPORT_MAX - 1] = PPCPIA_PARPORT_UNSPEC};
133 static int parport_ptr = 0;
134 #endif
135 
136 struct pp_cam_entry {
137         struct pardevice *pdev;
138         struct parport *port;
139         struct tq_struct cb_task;
140         int open_count;
141         wait_queue_head_t wq_stream;
142         /* image state flags */
143         int image_ready;        /* we got an interrupt */
144         int image_complete;     /* we have seen 4 EOI */
145 
146         int streaming; /* we are in streaming mode */
147         int stream_irq;
148 };
149 
150 static struct cpia_camera_ops cpia_pp_ops = 
151 {
152         cpia_pp_open,
153         cpia_pp_registerCallback,
154         cpia_pp_transferCmd,
155         cpia_pp_streamStart,
156         cpia_pp_streamStop,
157         cpia_pp_streamRead,
158         cpia_pp_close,
159         1
160 };
161 
162 static struct cam_data *cam_list;
163 
164 #ifdef _CPIA_DEBUG_
165 #define DEB_PORT(port) { \
166 u8 controll = GetControl(port); \
167 u8 statusss = GetStatus(port); \
168 DBG("nsel %c per %c naut %c nstrob %c nak %c busy %c nfaul %c sel %c init %c dir %c\n",\
169 ((controll & nSelectIn) ? 'U' : 'D'), \
170 ((statusss & PError)    ? 'U' : 'D'), \
171 ((controll & nAutoFd)   ? 'U' : 'D'), \
172 ((controll & nStrobe)   ? 'U' : 'D'), \
173 ((statusss & nAck)      ? 'U' : 'D'), \
174 ((statusss & Busy)      ? 'U' : 'D'), \
175 ((statusss & nFault)    ? 'U' : 'D'), \
176 ((statusss & Select)    ? 'U' : 'D'), \
177 ((controll & nInit)     ? 'U' : 'D'), \
178 ((controll & DirBit)    ? 'R' : 'F')  \
179 ); }
180 #else
181 #define DEB_PORT(port) {}
182 #endif
183 
184 #define WHILE_OUT_TIMEOUT (HZ/10)
185 #define DMA_TIMEOUT 10*HZ
186 
187 /* FIXME */
188 static void cpia_parport_enable_irq( struct parport *port ) {
189         parport_enable_irq(port);
190         mdelay(10);
191         return;
192 }
193 
194 static void cpia_parport_disable_irq( struct parport *port ) {
195         parport_disable_irq(port);
196         mdelay(10);
197         return;
198 }
199 
200 /****************************************************************************
201  *
202  *  EndTransferMode
203  *
204  ***************************************************************************/
205 static void EndTransferMode(struct pp_cam_entry *cam)
206 {
207         parport_negotiate(cam->port, IEEE1284_MODE_COMPAT);
208 }
209 
210 /****************************************************************************
211  *
212  *  ForwardSetup
213  *
214  ***************************************************************************/
215 static int ForwardSetup(struct pp_cam_entry *cam)
216 {
217         int retry;
218         
219         /* After some commands the camera needs extra time before
220          * it will respond again, so we try up to 3 times */
221         for(retry=0; retry<3; ++retry) {
222                 if(!parport_negotiate(cam->port, IEEE1284_MODE_ECP)) {
223                         break;
224                 }
225         }
226         if(retry == 3) {
227                 DBG("Unable to negotiate ECP mode\n");
228                 return -1;
229         }
230         return 0;
231 }
232 
233 /****************************************************************************
234  *
235  *  ReverseSetup
236  *
237  ***************************************************************************/
238 static int ReverseSetup(struct pp_cam_entry *cam, int extensibility)
239 {
240         int retry;
241         int mode = IEEE1284_MODE_ECP;
242         if(extensibility) mode = 8|3|IEEE1284_EXT_LINK;
243 
244         /* After some commands the camera needs extra time before
245          * it will respond again, so we try up to 3 times */
246         for(retry=0; retry<3; ++retry) {
247                 if(!parport_negotiate(cam->port, mode)) {
248                         break;
249                 }
250         }
251         if(retry == 3) {
252                 if(extensibility)
253                         DBG("Unable to negotiate extensibility mode\n");
254                 else
255                         DBG("Unable to negotiate ECP mode\n");
256                 return -1;
257         }
258         if(extensibility) cam->port->ieee1284.mode = IEEE1284_MODE_ECP;
259         return 0;
260 }
261 
262 /****************************************************************************
263  *
264  *  WritePacket
265  *
266  ***************************************************************************/
267 static int WritePacket(struct pp_cam_entry *cam, const u8 *packet, size_t size)
268 {
269         int retval=0;
270         int size_written;
271 
272         if (packet == NULL) {
273                 return -EINVAL;
274         }
275         if (ForwardSetup(cam)) {
276                 DBG("Write failed in setup\n");
277                 return -EIO;
278         }
279         size_written = parport_write(cam->port, packet, size);
280         if(size_written != size) {
281                 DBG("Write failed, wrote %d/%d\n", size_written, size);
282                 retval = -EIO;
283         }
284         EndTransferMode(cam);
285         return retval;
286 }
287 
288 /****************************************************************************
289  *
290  *  ReadPacket
291  *
292  ***************************************************************************/
293 static int ReadPacket(struct pp_cam_entry *cam, u8 *packet, size_t size)
294 {
295         int retval=0;
296         if (packet == NULL) {
297                 return -EINVAL;
298         }
299         if (ReverseSetup(cam, 0)) {
300                 return -EIO;
301         }
302         if(parport_read(cam->port, packet, size) != size) {
303                 retval = -EIO;
304         }
305         EndTransferMode(cam);
306         return retval;
307 }
308 
309 /****************************************************************************
310  *
311  *  cpia_pp_streamStart
312  *
313  ***************************************************************************/
314 static int cpia_pp_streamStart(void *privdata)
315 {
316         struct pp_cam_entry *cam = privdata;
317         DBG("\n");
318         cam->streaming=1;
319         cam->image_ready=0;
320         //if (ReverseSetup(cam,1)) return -EIO;
321         if(cam->stream_irq) cpia_parport_enable_irq(cam->port);
322         return 0;
323 }
324 
325 /****************************************************************************
326  *
327  *  cpia_pp_streamStop
328  *
329  ***************************************************************************/
330 static int cpia_pp_streamStop(void *privdata)
331 {
332         struct pp_cam_entry *cam = privdata;
333 
334         DBG("\n");
335         cam->streaming=0;
336         cpia_parport_disable_irq(cam->port);
337         //EndTransferMode(cam);
338 
339         return 0;
340 }
341 
342 static int cpia_pp_read(struct parport *port, u8 *buffer, int len)
343 {
344         int bytes_read, new_bytes;
345         for(bytes_read=0; bytes_read<len; bytes_read += new_bytes) {
346                 new_bytes = parport_read(port, buffer+bytes_read,
347                                          len-bytes_read);
348                 if(new_bytes < 0) break;
349         }
350         return bytes_read;
351 }
352 
353 /****************************************************************************
354  *
355  *  cpia_pp_streamRead
356  *
357  ***************************************************************************/
358 static int cpia_pp_streamRead(void *privdata, u8 *buffer, int noblock)
359 {
360         struct pp_cam_entry *cam = privdata;
361         int read_bytes = 0;
362         int i, endseen, block_size, new_bytes;
363 
364         if(cam == NULL) {
365                 DBG("Internal driver error: cam is NULL\n");
366                 return -EINVAL;
367         }
368         if(buffer == NULL) {
369                 DBG("Internal driver error: buffer is NULL\n");
370                 return -EINVAL;
371         }
372         //if(cam->streaming) DBG("%d / %d\n", cam->image_ready, noblock);
373         if( cam->stream_irq ) {
374                 DBG("%d\n", cam->image_ready);
375                 cam->image_ready--;
376         }
377         cam->image_complete=0;
378         if (0/*cam->streaming*/) {
379                 if(!cam->image_ready) {
380                         if(noblock) return -EWOULDBLOCK;
381                         interruptible_sleep_on(&cam->wq_stream);
382                         if( signal_pending(current) ) return -EINTR;
383                         DBG("%d\n", cam->image_ready);
384                 }
385         } else {
386                 if (ReverseSetup(cam, 1)) {
387                         DBG("unable to ReverseSetup\n");
388                         return -EIO;
389                 }
390         }
391         endseen = 0;
392         block_size = PARPORT_CHUNK_SIZE;
393         while( !cam->image_complete ) {
394                 if(current->need_resched)  schedule();
395                 
396                 new_bytes = cpia_pp_read(cam->port, buffer, block_size );
397                 if( new_bytes <= 0 ) {
398                         break;
399                 }
400                 i=-1;
401                 while(++i<new_bytes && endseen<4) {
402                         if(*buffer==EOI) {
403                                 endseen++;
404                         } else {
405                                 endseen=0;
406                         }
407                         buffer++;
408                 }
409                 read_bytes += i;
410                 if( endseen==4 ) {
411                         cam->image_complete=1;
412                         break;
413                 }
414                 if( CPIA_MAX_IMAGE_SIZE-read_bytes <= PARPORT_CHUNK_SIZE ) {
415                         block_size=CPIA_MAX_IMAGE_SIZE-read_bytes;
416                 }
417         }
418         EndTransferMode(cam);
419         return cam->image_complete ? read_bytes : -EIO;
420 }
421 
422 /****************************************************************************
423  *
424  *  cpia_pp_transferCmd
425  *
426  ***************************************************************************/
427 static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data)
428 {
429         int err;
430         int retval=0;
431         int databytes;
432         struct pp_cam_entry *cam = privdata;
433 
434         if(cam == NULL) {
435                 DBG("Internal driver error: cam is NULL\n");
436                 return -EINVAL;
437         }
438         if(command == NULL) {
439                 DBG("Internal driver error: command is NULL\n");
440                 return -EINVAL;
441         }
442         databytes = (((int)command[7])<<8) | command[6];
443         if ((err = WritePacket(cam, command, PACKET_LENGTH)) < 0) {
444                 DBG("Error writing command\n");
445                 return err;
446         }
447         if(command[0] == DATA_IN) {
448                 u8 buffer[8];
449                 if(data == NULL) {
450                         DBG("Internal driver error: data is NULL\n");
451                         return -EINVAL;
452                 }
453                 if((err = ReadPacket(cam, buffer, 8)) < 0) {
454                         return err;
455                         DBG("Error reading command result\n");
456                 }
457                 memcpy(data, buffer, databytes);
458         } else if(command[0] == DATA_OUT) {
459                 if(databytes > 0) {
460                         if(data == NULL) {
461                                 DBG("Internal driver error: data is NULL\n");
462                                 retval = -EINVAL;
463                         } else {
464                                 if((err=WritePacket(cam, data, databytes)) < 0){
465                                         DBG("Error writing command data\n");
466                                         return err;
467                                 }
468                         }
469                 }
470         } else {
471                 DBG("Unexpected first byte of command: %x\n", command[0]);
472                 retval = -EINVAL;
473         }
474         return retval;
475 }
476 
477 /****************************************************************************
478  *
479  *  cpia_pp_open
480  *
481  ***************************************************************************/
482 static int cpia_pp_open(void *privdata)
483 {
484         struct pp_cam_entry *cam = (struct pp_cam_entry *)privdata;
485         
486         if (cam == NULL)
487                 return -EINVAL;
488         
489         if(cam->open_count == 0) {
490                 if (parport_claim(cam->pdev)) {
491                         DBG("failed to claim the port\n");
492                         return -EBUSY;
493                 }
494                 parport_negotiate(cam->port, IEEE1284_MODE_COMPAT);
495                 parport_data_forward(cam->port);
496                 parport_write_control(cam->port, PARPORT_CONTROL_SELECT);
497                 udelay(50);
498                 parport_write_control(cam->port,
499                                       PARPORT_CONTROL_SELECT
500                                       | PARPORT_CONTROL_INIT);
501         }
502         
503         ++cam->open_count;
504         
505 #ifdef MODULE
506         MOD_INC_USE_COUNT;
507 #endif
508         return 0;
509 }
510 
511 /****************************************************************************
512  *
513  *  cpia_pp_registerCallback
514  *
515  ***************************************************************************/
516 static int cpia_pp_registerCallback(void *privdata, void (*cb)(void *cbdata), void *cbdata)
517 {
518         struct pp_cam_entry *cam = privdata;
519         int retval = 0;
520         
521         if(cam->port->irq != PARPORT_IRQ_NONE) {
522                 cam->cb_task.routine = cb;
523                 cam->cb_task.data = cbdata;
524         } else {
525                 retval = -1;
526         }
527         return retval;
528 }
529 
530 /****************************************************************************
531  *
532  *  cpia_pp_close
533  *
534  ***************************************************************************/
535 static int cpia_pp_close(void *privdata)
536 {
537         struct pp_cam_entry *cam = privdata;
538 #ifdef MODULE
539         MOD_DEC_USE_COUNT;
540 #endif
541         if (--cam->open_count == 0) {
542                 parport_release(cam->pdev);
543         }
544         return 0;
545 }
546 
547 /****************************************************************************
548  *
549  *  cpia_pp_register
550  *
551  ***************************************************************************/
552 static int cpia_pp_register(struct parport *port)
553 {
554         struct pardevice *pdev = NULL;
555         struct pp_cam_entry *cam;
556         struct cam_data *cpia;
557 
558         if (!(port->modes & PARPORT_MODE_ECP) &&
559             !(port->modes & PARPORT_MODE_TRISTATE)) {
560                 LOG("port is not ECP capable\n");
561                 return -ENXIO;
562         }
563 
564         cam = kmalloc(sizeof(struct pp_cam_entry), GFP_KERNEL);
565         if (cam == NULL) {
566                 LOG("failed to allocate camera structure\n");
567                 return -ENOMEM;
568         }
569         memset(cam,0,sizeof(struct pp_cam_entry));
570         
571         pdev = parport_register_device(port, "cpia_pp", NULL, NULL,
572                                        NULL, 0, cam);
573 
574         if (!pdev) {
575                 LOG("failed to parport_register_device\n");
576                 kfree(cam);
577                 return -ENXIO;
578         }
579 
580         cam->pdev = pdev;
581         cam->port = port;
582         init_waitqueue_head(&cam->wq_stream);
583 
584         cam->streaming = 0;
585         cam->stream_irq = 0;
586 
587         if((cpia = cpia_register_camera(&cpia_pp_ops, cam)) == NULL) {
588                 LOG("failed to cpia_register_camera\n");
589                 parport_unregister_device(pdev);
590                 kfree(cam);
591                 return -ENXIO;
592         }
593         ADD_TO_LIST(cam_list, cpia);
594 
595         return 0;
596 }
597 
598 static void cpia_pp_detach (struct parport *port)
599 {
600         struct cam_data *cpia;
601 
602         for(cpia = cam_list; cpia != NULL; cpia = cpia->next) {
603                 struct pp_cam_entry *cam = cpia->lowlevel_data;
604                 if (cam && cam->port->number == port->number) {
605                         REMOVE_FROM_LIST(cpia);
606                         
607                         cpia_unregister_camera(cpia);
608                         
609                         if(cam->open_count > 0) {
610                                 cpia_pp_close(cam);
611                         }
612 
613                         parport_unregister_device(cam->pdev);
614                 
615                         kfree(cam);
616                         cpia->lowlevel_data = NULL;
617                         break;
618                 }
619         }
620 }
621 
622 static void cpia_pp_attach (struct parport *port)
623 {
624         unsigned int i;
625 
626         switch (parport_nr[0])
627         {
628         case PPCPIA_PARPORT_UNSPEC:
629         case PPCPIA_PARPORT_AUTO:
630                 if (port->probe_info[0].class != PARPORT_CLASS_MEDIA ||
631                     port->probe_info[0].cmdset == NULL ||
632                     strncmp(port->probe_info[0].cmdset, "CPIA_1", 6) != 0)
633                         return;
634 
635                 cpia_pp_register(port);
636 
637                 break;
638 
639         default:
640                 for (i = 0; i < PARPORT_MAX; ++i) {
641                         if (port->number == parport_nr[i]) {
642                                 cpia_pp_register(port);
643                                 break;
644                         }
645                 }
646                 break;
647         }
648 }
649 
650 static struct parport_driver cpia_pp_driver = {
651         "cpia_pp",
652         cpia_pp_attach,
653         cpia_pp_detach,
654         NULL
655 };
656 
657 int cpia_pp_init(void)
658 {
659         printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT, 
660                CPIA_PP_MAJ_VER,CPIA_PP_MIN_VER,CPIA_PP_PATCH_VER);
661 
662         if(parport_nr[0] == PPCPIA_PARPORT_OFF) {
663                 printk("  disabled\n");
664                 return 0;
665         }
666         
667         if (parport_register_driver (&cpia_pp_driver)) {
668                 LOG ("unable to register with parport\n");
669                 return -EIO;
670         }
671 
672         return 0;
673 }
674 
675 #ifdef MODULE
676 int init_module(void)
677 {
678         if (parport[0]) {
679                 /* The user gave some parameters.  Let's see what they were. */
680                 if (!strncmp(parport[0], "auto", 4)) {
681                         parport_nr[0] = PPCPIA_PARPORT_AUTO;
682                 } else {
683                         int n;
684                         for (n = 0; n < PARPORT_MAX && parport[n]; n++) {
685                                 if (!strncmp(parport[n], "none", 4)) {
686                                         parport_nr[n] = PPCPIA_PARPORT_NONE;
687                                 } else {
688                                         char *ep;
689                                         unsigned long r = simple_strtoul(parport[n], &ep, 0);
690                                         if (ep != parport[n]) {
691                                                 parport_nr[n] = r;
692                                         } else {
693                                                 LOG("bad port specifier `%s'\n", parport[n]);
694                                                 return -ENODEV;
695                                         }
696                                 }
697                         }
698                 }
699         }
700 #if defined(CONFIG_KMOD) && defined(CONFIG_PNP_PARPORT_MODULE)
701         if(parport_enumerate() && !parport_enumerate()->probe_info.model) {
702                 request_module("parport_probe");
703         }
704 #endif
705         return cpia_pp_init();
706 }
707 
708 void cleanup_module(void)
709 {
710         parport_unregister_driver (&cpia_pp_driver);
711         return;
712 }
713 
714 #else /* !MODULE */
715 
716 static int __init cpia_pp_setup(char *str)
717 {
718 #if 0
719         /* Is this only a 2.2ism? -jerdfelt */
720         if (!str) {
721                 if (ints[0] == 0 || ints[1] == 0) {
722                         /* disable driver on "cpia_pp=" or "cpia_pp=0" */
723                         parport_nr[0] = PPCPIA_PARPORT_OFF;
724                 }
725         } else
726 #endif
727         if (!strncmp(str, "parport", 7)) {
728                 int n = simple_strtoul(str + 7, NULL, 10);
729                 if (parport_ptr < PARPORT_MAX) {
730                         parport_nr[parport_ptr++] = n;
731                 } else {
732                         LOG("too many ports, %s ignored.\n", str);
733                 }
734         } else if (!strcmp(str, "auto")) {
735                 parport_nr[0] = PPCPIA_PARPORT_AUTO;
736         } else if (!strcmp(str, "none")) {
737                 parport_nr[parport_ptr++] = PPCPIA_PARPORT_NONE;
738         }
739 
740         return 0;
741 }
742 
743 __setup("cpia_pp=", cpia_pp_setup);
744 
745 #endif /* !MODULE */
746 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.