]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/media/radio/radio-cadet.c
V4L/DVB (10884): radio-gemtek: convert to v4l2_device.
[linux-2.6-omap-h63xx.git] / drivers / media / radio / radio-cadet.c
1 /* radio-cadet.c - A video4linux driver for the ADS Cadet AM/FM Radio Card
2  *
3  * by Fred Gleason <fredg@wava.com>
4  * Version 0.3.3
5  *
6  * (Loosely) based on code for the Aztech radio card by
7  *
8  * Russell Kroll    (rkroll@exploits.org)
9  * Quay Ly
10  * Donald Song
11  * Jason Lewis      (jlewis@twilight.vtc.vsc.edu)
12  * Scott McGrath    (smcgrath@twilight.vtc.vsc.edu)
13  * William McGrath  (wmcgrath@twilight.vtc.vsc.edu)
14  *
15  * History:
16  * 2000-04-29   Russell Kroll <rkroll@exploits.org>
17  *              Added ISAPnP detection for Linux 2.3/2.4
18  *
19  * 2001-01-10   Russell Kroll <rkroll@exploits.org>
20  *              Removed dead CONFIG_RADIO_CADET_PORT code
21  *              PnP detection on load is now default (no args necessary)
22  *
23  * 2002-01-17   Adam Belay <ambx1@neo.rr.com>
24  *              Updated to latest pnp code
25  *
26  * 2003-01-31   Alan Cox <alan@lxorguk.ukuu.org.uk>
27  *              Cleaned up locking, delay code, general odds and ends
28  *
29  * 2006-07-30   Hans J. Koch <koch@hjk-az.de>
30  *              Changed API to V4L2
31  */
32
33 #include <linux/version.h>
34 #include <linux/module.h>       /* Modules                      */
35 #include <linux/init.h>         /* Initdata                     */
36 #include <linux/ioport.h>       /* request_region               */
37 #include <linux/delay.h>        /* udelay                       */
38 #include <linux/videodev2.h>    /* V4L2 API defs                */
39 #include <linux/param.h>
40 #include <linux/pnp.h>
41 #include <linux/io.h>           /* outb, outb_p                 */
42 #include <linux/uaccess.h>      /* copy to/from user            */
43 #include <media/v4l2-device.h>
44 #include <media/v4l2-ioctl.h>
45
46 MODULE_AUTHOR("Fred Gleason, Russell Kroll, Quay Lu, Donald Song, Jason Lewis, Scott McGrath, William McGrath");
47 MODULE_DESCRIPTION("A driver for the ADS Cadet AM/FM/RDS radio card.");
48 MODULE_LICENSE("GPL");
49
50 static int io = -1;             /* default to isapnp activation */
51 static int radio_nr = -1;
52
53 module_param(io, int, 0);
54 MODULE_PARM_DESC(io, "I/O address of Cadet card (0x330,0x332,0x334,0x336,0x338,0x33a,0x33c,0x33e)");
55 module_param(radio_nr, int, 0);
56
57 #define CADET_VERSION KERNEL_VERSION(0, 3, 3)
58
59 #define RDS_BUFFER 256
60 #define RDS_RX_FLAG 1
61 #define MBS_RX_FLAG 2
62
63 struct cadet {
64         struct v4l2_device v4l2_dev;
65         struct video_device vdev;
66         int io;
67         int users;
68         int curtuner;
69         int tunestat;
70         int sigstrength;
71         wait_queue_head_t read_queue;
72         struct timer_list readtimer;
73         __u8 rdsin, rdsout, rdsstat;
74         unsigned char rdsbuf[RDS_BUFFER];
75         struct mutex lock;
76         int reading;
77 };
78
79 static struct cadet cadet_card;
80
81 /*
82  * Signal Strength Threshold Values
83  * The V4L API spec does not define any particular unit for the signal
84  * strength value.  These values are in microvolts of RF at the tuner's input.
85  */
86 static __u16 sigtable[2][4] = {
87         {  5, 10, 30,  150 },
88         { 28, 40, 63, 1000 }
89 };
90
91
92 static int cadet_getstereo(struct cadet *dev)
93 {
94         int ret = V4L2_TUNER_SUB_MONO;
95
96         if (dev->curtuner != 0) /* Only FM has stereo capability! */
97                 return V4L2_TUNER_SUB_MONO;
98
99         mutex_lock(&dev->lock);
100         outb(7, dev->io);          /* Select tuner control */
101         if ((inb(dev->io + 1) & 0x40) == 0)
102                 ret = V4L2_TUNER_SUB_STEREO;
103         mutex_unlock(&dev->lock);
104         return ret;
105 }
106
107 static unsigned cadet_gettune(struct cadet *dev)
108 {
109         int curvol, i;
110         unsigned fifo = 0;
111
112         /*
113          * Prepare for read
114          */
115
116         mutex_lock(&dev->lock);
117
118         outb(7, dev->io);       /* Select tuner control */
119         curvol = inb(dev->io + 1); /* Save current volume/mute setting */
120         outb(0x00, dev->io + 1);  /* Ensure WRITE-ENABLE is LOW */
121         dev->tunestat = 0xffff;
122
123         /*
124          * Read the shift register
125          */
126         for (i = 0; i < 25; i++) {
127                 fifo = (fifo << 1) | ((inb(dev->io + 1) >> 7) & 0x01);
128                 if (i < 24) {
129                         outb(0x01, dev->io + 1);
130                         dev->tunestat &= inb(dev->io + 1);
131                         outb(0x00, dev->io + 1);
132                 }
133         }
134
135         /*
136          * Restore volume/mute setting
137          */
138         outb(curvol, dev->io + 1);
139         mutex_unlock(&dev->lock);
140
141         return fifo;
142 }
143
144 static unsigned cadet_getfreq(struct cadet *dev)
145 {
146         int i;
147         unsigned freq = 0, test, fifo = 0;
148
149         /*
150          * Read current tuning
151          */
152         fifo = cadet_gettune(dev);
153
154         /*
155          * Convert to actual frequency
156          */
157         if (dev->curtuner == 0) {    /* FM */
158                 test = 12500;
159                 for (i = 0; i < 14; i++) {
160                         if ((fifo & 0x01) != 0)
161                                 freq += test;
162                         test = test << 1;
163                         fifo = fifo >> 1;
164                 }
165                 freq -= 10700000;           /* IF frequency is 10.7 MHz */
166                 freq = (freq * 16) / 1000000;   /* Make it 1/16 MHz */
167         }
168         if (dev->curtuner == 1)    /* AM */
169                 freq = ((fifo & 0x7fff) - 2010) * 16;
170
171         return freq;
172 }
173
174 static void cadet_settune(struct cadet *dev, unsigned fifo)
175 {
176         int i;
177         unsigned test;
178
179         mutex_lock(&dev->lock);
180
181         outb(7, dev->io);                /* Select tuner control */
182         /*
183          * Write the shift register
184          */
185         test = 0;
186         test = (fifo >> 23) & 0x02;      /* Align data for SDO */
187         test |= 0x1c;                /* SDM=1, SWE=1, SEN=1, SCK=0 */
188         outb(7, dev->io);                /* Select tuner control */
189         outb(test, dev->io + 1);           /* Initialize for write */
190         for (i = 0; i < 25; i++) {
191                 test |= 0x01;              /* Toggle SCK High */
192                 outb(test, dev->io + 1);
193                 test &= 0xfe;              /* Toggle SCK Low */
194                 outb(test, dev->io + 1);
195                 fifo = fifo << 1;            /* Prepare the next bit */
196                 test = 0x1c | ((fifo >> 23) & 0x02);
197                 outb(test, dev->io + 1);
198         }
199         mutex_unlock(&dev->lock);
200 }
201
202 static void cadet_setfreq(struct cadet *dev, unsigned freq)
203 {
204         unsigned fifo;
205         int i, j, test;
206         int curvol;
207
208         /*
209          * Formulate a fifo command
210          */
211         fifo = 0;
212         if (dev->curtuner == 0) {    /* FM */
213                 test = 102400;
214                 freq = (freq * 1000) / 16;       /* Make it kHz */
215                 freq += 10700;               /* IF is 10700 kHz */
216                 for (i = 0; i < 14; i++) {
217                         fifo = fifo << 1;
218                         if (freq >= test) {
219                                 fifo |= 0x01;
220                                 freq -= test;
221                         }
222                         test = test >> 1;
223                 }
224         }
225         if (dev->curtuner == 1) {    /* AM */
226                 fifo = (freq / 16) + 2010;            /* Make it kHz */
227                 fifo |= 0x100000;            /* Select AM Band */
228         }
229
230         /*
231          * Save current volume/mute setting
232          */
233
234         mutex_lock(&dev->lock);
235         outb(7, dev->io);                /* Select tuner control */
236         curvol = inb(dev->io + 1);
237         mutex_unlock(&dev->lock);
238
239         /*
240          * Tune the card
241          */
242         for (j = 3; j > -1; j--) {
243                 cadet_settune(dev, fifo | (j << 16));
244
245                 mutex_lock(&dev->lock);
246                 outb(7, dev->io);         /* Select tuner control */
247                 outb(curvol, dev->io + 1);
248                 mutex_unlock(&dev->lock);
249
250                 msleep(100);
251
252                 cadet_gettune(dev);
253                 if ((dev->tunestat & 0x40) == 0) {   /* Tuned */
254                         dev->sigstrength = sigtable[dev->curtuner][j];
255                         return;
256                 }
257         }
258         dev->sigstrength = 0;
259 }
260
261
262 static int cadet_getvol(struct cadet *dev)
263 {
264         int ret = 0;
265
266         mutex_lock(&dev->lock);
267
268         outb(7, dev->io);                /* Select tuner control */
269         if ((inb(dev->io + 1) & 0x20) != 0)
270                 ret = 0xffff;
271
272         mutex_unlock(&dev->lock);
273         return ret;
274 }
275
276
277 static void cadet_setvol(struct cadet *dev, int vol)
278 {
279         mutex_lock(&dev->lock);
280         outb(7, dev->io);                /* Select tuner control */
281         if (vol > 0)
282                 outb(0x20, dev->io + 1);
283         else
284                 outb(0x00, dev->io + 1);
285         mutex_unlock(&dev->lock);
286 }
287
288 static void cadet_handler(unsigned long data)
289 {
290         struct cadet *dev = (void *)data;
291
292         /* Service the RDS fifo */
293         if (mutex_trylock(&dev->lock)) {
294                 outb(0x3, dev->io);       /* Select RDS Decoder Control */
295                 if ((inb(dev->io + 1) & 0x20) != 0)
296                         printk(KERN_CRIT "cadet: RDS fifo overflow\n");
297                 outb(0x80, dev->io);      /* Select RDS fifo */
298                 while ((inb(dev->io) & 0x80) != 0) {
299                         dev->rdsbuf[dev->rdsin] = inb(dev->io + 1);
300                         if (dev->rdsin == dev->rdsout)
301                                 printk(KERN_WARNING "cadet: RDS buffer overflow\n");
302                         else
303                                 dev->rdsin++;
304                 }
305                 mutex_unlock(&dev->lock);
306         }
307
308         /*
309          * Service pending read
310          */
311         if (dev->rdsin != dev->rdsout)
312                 wake_up_interruptible(&dev->read_queue);
313
314         /*
315          * Clean up and exit
316          */
317         init_timer(&dev->readtimer);
318         dev->readtimer.function = cadet_handler;
319         dev->readtimer.data = (unsigned long)0;
320         dev->readtimer.expires = jiffies + msecs_to_jiffies(50);
321         add_timer(&dev->readtimer);
322 }
323
324
325 static ssize_t cadet_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
326 {
327         struct cadet *dev = video_drvdata(file);
328         unsigned char readbuf[RDS_BUFFER];
329         int i = 0;
330
331         if (dev->rdsstat == 0) {
332                 mutex_lock(&dev->lock);
333                 dev->rdsstat = 1;
334                 outb(0x80, dev->io);        /* Select RDS fifo */
335                 mutex_unlock(&dev->lock);
336                 init_timer(&dev->readtimer);
337                 dev->readtimer.function = cadet_handler;
338                 dev->readtimer.data = (unsigned long)dev;
339                 dev->readtimer.expires = jiffies + msecs_to_jiffies(50);
340                 add_timer(&dev->readtimer);
341         }
342         if (dev->rdsin == dev->rdsout) {
343                 if (file->f_flags & O_NONBLOCK)
344                         return -EWOULDBLOCK;
345                 interruptible_sleep_on(&dev->read_queue);
346         }
347         while (i < count && dev->rdsin != dev->rdsout)
348                 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
349
350         if (copy_to_user(data, readbuf, i))
351                 return -EFAULT;
352         return i;
353 }
354
355
356 static int vidioc_querycap(struct file *file, void *priv,
357                                 struct v4l2_capability *v)
358 {
359         strlcpy(v->driver, "ADS Cadet", sizeof(v->driver));
360         strlcpy(v->card, "ADS Cadet", sizeof(v->card));
361         strlcpy(v->bus_info, "ISA", sizeof(v->bus_info));
362         v->version = CADET_VERSION;
363         v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO | V4L2_CAP_READWRITE;
364         return 0;
365 }
366
367 static int vidioc_g_tuner(struct file *file, void *priv,
368                                 struct v4l2_tuner *v)
369 {
370         struct cadet *dev = video_drvdata(file);
371
372         v->type = V4L2_TUNER_RADIO;
373         switch (v->index) {
374         case 0:
375                 strlcpy(v->name, "FM", sizeof(v->name));
376                 v->capability = V4L2_TUNER_CAP_STEREO;
377                 v->rangelow = 1400;     /* 87.5 MHz */
378                 v->rangehigh = 1728;    /* 108.0 MHz */
379                 v->rxsubchans = cadet_getstereo(dev);
380                 switch (v->rxsubchans) {
381                 case V4L2_TUNER_SUB_MONO:
382                         v->audmode = V4L2_TUNER_MODE_MONO;
383                         break;
384                 case V4L2_TUNER_SUB_STEREO:
385                         v->audmode = V4L2_TUNER_MODE_STEREO;
386                         break;
387                 default:
388                         break;
389                 }
390                 break;
391         case 1:
392                 strlcpy(v->name, "AM", sizeof(v->name));
393                 v->capability = V4L2_TUNER_CAP_LOW;
394                 v->rangelow = 8320;      /* 520 kHz */
395                 v->rangehigh = 26400;    /* 1650 kHz */
396                 v->rxsubchans = V4L2_TUNER_SUB_MONO;
397                 v->audmode = V4L2_TUNER_MODE_MONO;
398                 break;
399         default:
400                 return -EINVAL;
401         }
402         v->signal = dev->sigstrength; /* We might need to modify scaling of this */
403         return 0;
404 }
405
406 static int vidioc_s_tuner(struct file *file, void *priv,
407                                 struct v4l2_tuner *v)
408 {
409         struct cadet *dev = video_drvdata(file);
410
411         if (v->index != 0 && v->index != 1)
412                 return -EINVAL;
413         dev->curtuner = v->index;
414         return 0;
415 }
416
417 static int vidioc_g_frequency(struct file *file, void *priv,
418                                 struct v4l2_frequency *f)
419 {
420         struct cadet *dev = video_drvdata(file);
421
422         f->tuner = dev->curtuner;
423         f->type = V4L2_TUNER_RADIO;
424         f->frequency = cadet_getfreq(dev);
425         return 0;
426 }
427
428
429 static int vidioc_s_frequency(struct file *file, void *priv,
430                                 struct v4l2_frequency *f)
431 {
432         struct cadet *dev = video_drvdata(file);
433
434         if (f->type != V4L2_TUNER_RADIO)
435                 return -EINVAL;
436         if (dev->curtuner == 0 && (f->frequency < 1400 || f->frequency > 1728))
437                 return -EINVAL;
438         if (dev->curtuner == 1 && (f->frequency < 8320 || f->frequency > 26400))
439                 return -EINVAL;
440         cadet_setfreq(dev, f->frequency);
441         return 0;
442 }
443
444 static int vidioc_queryctrl(struct file *file, void *priv,
445                                 struct v4l2_queryctrl *qc)
446 {
447         switch (qc->id) {
448         case V4L2_CID_AUDIO_MUTE:
449                 return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
450         case V4L2_CID_AUDIO_VOLUME:
451                 return v4l2_ctrl_query_fill(qc, 0, 0xff, 1, 0xff);
452         }
453         return -EINVAL;
454 }
455
456 static int vidioc_g_ctrl(struct file *file, void *priv,
457                                 struct v4l2_control *ctrl)
458 {
459         struct cadet *dev = video_drvdata(file);
460
461         switch (ctrl->id) {
462         case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */
463                 ctrl->value = (cadet_getvol(dev) == 0);
464                 break;
465         case V4L2_CID_AUDIO_VOLUME:
466                 ctrl->value = cadet_getvol(dev);
467                 break;
468         default:
469                 return -EINVAL;
470         }
471         return 0;
472 }
473
474 static int vidioc_s_ctrl(struct file *file, void *priv,
475                                 struct v4l2_control *ctrl)
476 {
477         struct cadet *dev = video_drvdata(file);
478
479         switch (ctrl->id){
480         case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */
481                 if (ctrl->value)
482                         cadet_setvol(dev, 0);
483                 else
484                         cadet_setvol(dev, 0xffff);
485                 break;
486         case V4L2_CID_AUDIO_VOLUME:
487                 cadet_setvol(dev, ctrl->value);
488                 break;
489         default:
490                 return -EINVAL;
491         }
492         return 0;
493 }
494
495 static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
496 {
497         *i = 0;
498         return 0;
499 }
500
501 static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
502 {
503         return i ? -EINVAL : 0;
504 }
505
506 static int vidioc_g_audio(struct file *file, void *priv,
507                                 struct v4l2_audio *a)
508 {
509         a->index = 0;
510         strlcpy(a->name, "Radio", sizeof(a->name));
511         a->capability = V4L2_AUDCAP_STEREO;
512         return 0;
513 }
514
515 static int vidioc_s_audio(struct file *file, void *priv,
516                                 struct v4l2_audio *a)
517 {
518         return a->index ? -EINVAL : 0;
519 }
520
521 static int cadet_open(struct file *file)
522 {
523         struct cadet *dev = video_drvdata(file);
524
525         dev->users++;
526         if (1 == dev->users)
527                 init_waitqueue_head(&dev->read_queue);
528         return 0;
529 }
530
531 static int cadet_release(struct file *file)
532 {
533         struct cadet *dev = video_drvdata(file);
534
535         dev->users--;
536         if (0 == dev->users) {
537                 del_timer_sync(&dev->readtimer);
538                 dev->rdsstat = 0;
539         }
540         return 0;
541 }
542
543 static unsigned int cadet_poll(struct file *file, struct poll_table_struct *wait)
544 {
545         struct cadet *dev = video_drvdata(file);
546
547         poll_wait(file, &dev->read_queue, wait);
548         if (dev->rdsin != dev->rdsout)
549                 return POLLIN | POLLRDNORM;
550         return 0;
551 }
552
553
554 static const struct v4l2_file_operations cadet_fops = {
555         .owner          = THIS_MODULE,
556         .open           = cadet_open,
557         .release        = cadet_release,
558         .read           = cadet_read,
559         .ioctl          = video_ioctl2,
560         .poll           = cadet_poll,
561 };
562
563 static const struct v4l2_ioctl_ops cadet_ioctl_ops = {
564         .vidioc_querycap    = vidioc_querycap,
565         .vidioc_g_tuner     = vidioc_g_tuner,
566         .vidioc_s_tuner     = vidioc_s_tuner,
567         .vidioc_g_frequency = vidioc_g_frequency,
568         .vidioc_s_frequency = vidioc_s_frequency,
569         .vidioc_queryctrl   = vidioc_queryctrl,
570         .vidioc_g_ctrl      = vidioc_g_ctrl,
571         .vidioc_s_ctrl      = vidioc_s_ctrl,
572         .vidioc_g_audio     = vidioc_g_audio,
573         .vidioc_s_audio     = vidioc_s_audio,
574         .vidioc_g_input     = vidioc_g_input,
575         .vidioc_s_input     = vidioc_s_input,
576 };
577
578 #ifdef CONFIG_PNP
579
580 static struct pnp_device_id cadet_pnp_devices[] = {
581         /* ADS Cadet AM/FM Radio Card */
582         {.id = "MSM0c24", .driver_data = 0},
583         {.id = ""}
584 };
585
586 MODULE_DEVICE_TABLE(pnp, cadet_pnp_devices);
587
588 static int cadet_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
589 {
590         if (!dev)
591                 return -ENODEV;
592         /* only support one device */
593         if (io > 0)
594                 return -EBUSY;
595
596         if (!pnp_port_valid(dev, 0))
597                 return -ENODEV;
598
599         io = pnp_port_start(dev, 0);
600
601         printk(KERN_INFO "radio-cadet: PnP reports device at %#x\n", io);
602
603         return io;
604 }
605
606 static struct pnp_driver cadet_pnp_driver = {
607         .name           = "radio-cadet",
608         .id_table       = cadet_pnp_devices,
609         .probe          = cadet_pnp_probe,
610         .remove         = NULL,
611 };
612
613 #else
614 static struct pnp_driver cadet_pnp_driver;
615 #endif
616
617 static void cadet_probe(struct cadet *dev)
618 {
619         static int iovals[8] = { 0x330, 0x332, 0x334, 0x336, 0x338, 0x33a, 0x33c, 0x33e };
620         int i;
621
622         for (i = 0; i < 8; i++) {
623                 dev->io = iovals[i];
624                 if (request_region(dev->io, 2, "cadet-probe")) {
625                         cadet_setfreq(dev, 1410);
626                         if (cadet_getfreq(dev) == 1410) {
627                                 release_region(dev->io, 2);
628                                 return;
629                         }
630                         release_region(dev->io, 2);
631                 }
632         }
633         dev->io = -1;
634 }
635
636 /*
637  * io should only be set if the user has used something like
638  * isapnp (the userspace program) to initialize this card for us
639  */
640
641 static int __init cadet_init(void)
642 {
643         struct cadet *dev = &cadet_card;
644         struct v4l2_device *v4l2_dev = &dev->v4l2_dev;
645         int res;
646
647         strlcpy(v4l2_dev->name, "cadet", sizeof(v4l2_dev->name));
648         mutex_init(&dev->lock);
649
650         /* If a probe was requested then probe ISAPnP first (safest) */
651         if (io < 0)
652                 pnp_register_driver(&cadet_pnp_driver);
653         dev->io = io;
654
655         /* If that fails then probe unsafely if probe is requested */
656         if (dev->io < 0)
657                 cadet_probe(dev);
658
659         /* Else we bail out */
660         if (dev->io < 0) {
661 #ifdef MODULE
662                 v4l2_err(v4l2_dev, "you must set an I/O address with io=0x???\n");
663 #endif
664                 goto fail;
665         }
666         if (!request_region(dev->io, 2, "cadet"))
667                 goto fail;
668
669         res = v4l2_device_register(NULL, v4l2_dev);
670         if (res < 0) {
671                 release_region(dev->io, 2);
672                 v4l2_err(v4l2_dev, "could not register v4l2_device\n");
673                 goto fail;
674         }
675
676         strlcpy(dev->vdev.name, v4l2_dev->name, sizeof(dev->vdev.name));
677         dev->vdev.v4l2_dev = v4l2_dev;
678         dev->vdev.fops = &cadet_fops;
679         dev->vdev.ioctl_ops = &cadet_ioctl_ops;
680         dev->vdev.release = video_device_release_empty;
681         video_set_drvdata(&dev->vdev, dev);
682
683         if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
684                 v4l2_device_unregister(v4l2_dev);
685                 release_region(dev->io, 2);
686                 goto fail;
687         }
688         v4l2_info(v4l2_dev, "ADS Cadet Radio Card at 0x%x\n", dev->io);
689         return 0;
690 fail:
691         pnp_unregister_driver(&cadet_pnp_driver);
692         return -ENODEV;
693 }
694
695 static void __exit cadet_exit(void)
696 {
697         struct cadet *dev = &cadet_card;
698
699         video_unregister_device(&dev->vdev);
700         v4l2_device_unregister(&dev->v4l2_dev);
701         release_region(dev->io, 2);
702         pnp_unregister_driver(&cadet_pnp_driver);
703 }
704
705 module_init(cadet_init);
706 module_exit(cadet_exit);
707