cpia_pp.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:18k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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