blob: ed7299d42a24e42138625265b5633157a8ebe5df [file] [log] [blame]
Ondrej Zaryabed6232012-05-19 13:18:26 -03001/* SF16-FMI, SF16-FMP and SF16-FMD radio driver for Linux radio support
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * heavily based on rtrack driver...
3 * (c) 1997 M. Kirkwood
4 * (c) 1998 Petr Vandrovec, vandrove@vc.cvut.cz
5 *
Alan Coxd9b01442008-10-27 15:13:47 -03006 * Fitted to new interface by Alan Cox <alan@lxorguk.ukuu.org.uk>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * Made working and cleaned up functions <mikael.hedin@irf.se>
8 * Support for ISAPnP by Ladislav Michl <ladis@psi.cz>
9 *
10 * Notes on the hardware
11 *
12 * Frequency control is done digitally -- ie out(port,encodefreq(95.8));
13 * No volume control - only mute/unmute - you have to use line volume
Ondrej Zaryabed6232012-05-19 13:18:26 -030014 * control on SB-part of SF16-FMI/SF16-FMP/SF16-FMD
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -030015 *
Mauro Carvalho Chehaba2ef73a2006-08-08 09:10:02 -030016 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
18
19#include <linux/kernel.h> /* __setup */
20#include <linux/module.h> /* Modules */
21#include <linux/init.h> /* Initdata */
Peter Osterlundfb911ee2005-09-13 01:25:15 -070022#include <linux/ioport.h> /* request_region */
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/delay.h> /* udelay */
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/isapnp.h>
Ingo Molnar3593cab2006-02-07 06:49:14 -020025#include <linux/mutex.h>
Hans Verkuilc41269f2009-03-06 13:52:34 -030026#include <linux/videodev2.h> /* kernel radio structs */
27#include <linux/io.h> /* outb, outb_p */
Hans Verkuilc41269f2009-03-06 13:52:34 -030028#include <media/v4l2-device.h>
29#include <media/v4l2-ioctl.h>
Hans Verkuil268d06b2013-02-03 09:51:06 -030030#include <media/v4l2-ctrls.h>
Hans Verkuil0dc5d822013-02-03 09:51:59 -030031#include <media/v4l2-event.h>
Ondrej Zary6b390232012-06-13 17:25:44 -030032#include "lm7000.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Hans Verkuilc41269f2009-03-06 13:52:34 -030034MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood");
Ondrej Zaryabed6232012-05-19 13:18:26 -030035MODULE_DESCRIPTION("A driver for the SF16-FMI, SF16-FMP and SF16-FMD radio.");
Hans Verkuilc41269f2009-03-06 13:52:34 -030036MODULE_LICENSE("GPL");
Mauro Carvalho Chehab29834c12011-06-25 10:15:42 -030037MODULE_VERSION("0.0.3");
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -030039static int io = -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040static int radio_nr = -1;
Hans Verkuilc41269f2009-03-06 13:52:34 -030041
42module_param(io, int, 0);
Ondrej Zaryabed6232012-05-19 13:18:26 -030043MODULE_PARM_DESC(io, "I/O address of the SF16-FMI/SF16-FMP/SF16-FMD card (0x284 or 0x384)");
Hans Verkuilc41269f2009-03-06 13:52:34 -030044module_param(radio_nr, int, 0);
45
Hans Verkuilc41269f2009-03-06 13:52:34 -030046struct fmi
47{
48 struct v4l2_device v4l2_dev;
Hans Verkuil268d06b2013-02-03 09:51:06 -030049 struct v4l2_ctrl_handler hdl;
Hans Verkuilc41269f2009-03-06 13:52:34 -030050 struct video_device vdev;
51 int io;
Ondrej Zary4b830372009-12-10 17:06:44 -030052 bool mute;
Hans Verkuilc41269f2009-03-06 13:52:34 -030053 unsigned long curfreq; /* freq in kHz */
Hans Verkuilc41269f2009-03-06 13:52:34 -030054 struct mutex lock;
55};
56
57static struct fmi fmi_card;
58static struct pnp_dev *dev;
Ondrej Zary67cabf502009-12-10 17:12:32 -030059bool pnp_attached;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Hans Verkuil96bb42b2013-05-31 06:21:03 -030061#define RSF16_MINFREQ (87U * 16000)
62#define RSF16_MAXFREQ (108U * 16000)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
Ondrej Zary6b390232012-06-13 17:25:44 -030064#define FMI_BIT_TUN_CE (1 << 0)
65#define FMI_BIT_TUN_CLK (1 << 1)
66#define FMI_BIT_TUN_DATA (1 << 2)
67#define FMI_BIT_VOL_SW (1 << 3)
68#define FMI_BIT_TUN_STRQ (1 << 4)
69
Mauro Carvalho Chehaba5133b12012-10-27 13:43:05 -030070static void fmi_set_pins(void *handle, u8 pins)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
Ondrej Zary6b390232012-06-13 17:25:44 -030072 struct fmi *fmi = handle;
73 u8 bits = FMI_BIT_TUN_STRQ;
74
75 if (!fmi->mute)
76 bits |= FMI_BIT_VOL_SW;
77
78 if (pins & LM7000_DATA)
79 bits |= FMI_BIT_TUN_DATA;
80 if (pins & LM7000_CLK)
81 bits |= FMI_BIT_TUN_CLK;
82 if (pins & LM7000_CE)
83 bits |= FMI_BIT_TUN_CE;
84
85 mutex_lock(&fmi->lock);
86 outb_p(bits, fmi->io);
87 mutex_unlock(&fmi->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088}
89
Hans Verkuilc41269f2009-03-06 13:52:34 -030090static inline void fmi_mute(struct fmi *fmi)
Linus Torvalds1da177e2005-04-16 15:20:36 -070091{
Hans Verkuilc41269f2009-03-06 13:52:34 -030092 mutex_lock(&fmi->lock);
93 outb(0x00, fmi->io);
94 mutex_unlock(&fmi->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070095}
96
Hans Verkuilc41269f2009-03-06 13:52:34 -030097static inline void fmi_unmute(struct fmi *fmi)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098{
Hans Verkuilc41269f2009-03-06 13:52:34 -030099 mutex_lock(&fmi->lock);
100 outb(0x08, fmi->io);
101 mutex_unlock(&fmi->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102}
103
Hans Verkuilc41269f2009-03-06 13:52:34 -0300104static inline int fmi_getsigstr(struct fmi *fmi)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105{
106 int val;
107 int res;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
Hans Verkuilc41269f2009-03-06 13:52:34 -0300109 mutex_lock(&fmi->lock);
Ondrej Zary4b830372009-12-10 17:06:44 -0300110 val = fmi->mute ? 0x00 : 0x08; /* mute/unmute */
Hans Verkuilc41269f2009-03-06 13:52:34 -0300111 outb(val, fmi->io);
112 outb(val | 0x10, fmi->io);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 msleep(143); /* was schedule_timeout(HZ/7) */
Hans Verkuilc41269f2009-03-06 13:52:34 -0300114 res = (int)inb(fmi->io + 1);
115 outb(val, fmi->io);
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300116
Hans Verkuilc41269f2009-03-06 13:52:34 -0300117 mutex_unlock(&fmi->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 return (res & 2) ? 0 : 0xFFFF;
119}
120
Douglas Landgrafc123b862007-04-23 17:52:12 -0300121static int vidioc_querycap(struct file *file, void *priv,
122 struct v4l2_capability *v)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123{
Douglas Landgrafc123b862007-04-23 17:52:12 -0300124 strlcpy(v->driver, "radio-sf16fmi", sizeof(v->driver));
Ondrej Zaryabed6232012-05-19 13:18:26 -0300125 strlcpy(v->card, "SF16-FMI/FMP/FMD radio", sizeof(v->card));
Ondrej Zary92916822013-06-14 17:01:38 -0300126 strlcpy(v->bus_info, "ISA:radio-sf16fmi", sizeof(v->bus_info));
Hans Verkuilf90842d2013-02-03 09:44:14 -0300127 v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
128 v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300129 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130}
131
Douglas Landgrafc123b862007-04-23 17:52:12 -0300132static int vidioc_g_tuner(struct file *file, void *priv,
133 struct v4l2_tuner *v)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134{
Hans Verkuilc41269f2009-03-06 13:52:34 -0300135 struct fmi *fmi = video_drvdata(file);
Douglas Landgrafc123b862007-04-23 17:52:12 -0300136
137 if (v->index > 0)
138 return -EINVAL;
139
Hans Verkuilc41269f2009-03-06 13:52:34 -0300140 strlcpy(v->name, "FM", sizeof(v->name));
Douglas Landgrafc123b862007-04-23 17:52:12 -0300141 v->type = V4L2_TUNER_RADIO;
Hans Verkuil1d80db52009-05-02 12:04:13 -0300142 v->rangelow = RSF16_MINFREQ;
143 v->rangehigh = RSF16_MAXFREQ;
Hans Verkuildc47b772009-05-02 11:52:35 -0300144 v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
Hans Verkuil38092a42009-05-02 12:06:15 -0300145 v->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300146 v->audmode = V4L2_TUNER_MODE_STEREO;
147 v->signal = fmi_getsigstr(fmi);
148 return 0;
149}
150
151static int vidioc_s_tuner(struct file *file, void *priv,
Hans Verkuil2f73c7c2013-03-15 06:10:06 -0300152 const struct v4l2_tuner *v)
Douglas Landgrafc123b862007-04-23 17:52:12 -0300153{
Hans Verkuilc41269f2009-03-06 13:52:34 -0300154 return v->index ? -EINVAL : 0;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300155}
156
157static int vidioc_s_frequency(struct file *file, void *priv,
Hans Verkuilb530a442013-03-19 04:09:26 -0300158 const struct v4l2_frequency *f)
Douglas Landgrafc123b862007-04-23 17:52:12 -0300159{
Hans Verkuilc41269f2009-03-06 13:52:34 -0300160 struct fmi *fmi = video_drvdata(file);
Hans Verkuil96bb42b2013-05-31 06:21:03 -0300161 unsigned freq = f->frequency;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300162
Hans Verkuila3a9e282009-11-27 04:33:25 -0300163 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
164 return -EINVAL;
Hans Verkuil96bb42b2013-05-31 06:21:03 -0300165 clamp(freq, RSF16_MINFREQ, RSF16_MAXFREQ);
Hans Verkuilc41269f2009-03-06 13:52:34 -0300166 /* rounding in steps of 800 to match the freq
167 that will be used */
Hans Verkuil96bb42b2013-05-31 06:21:03 -0300168 lm7000_set_freq((freq / 800) * 800, fmi, fmi_set_pins);
Douglas Landgrafc123b862007-04-23 17:52:12 -0300169 return 0;
170}
171
172static int vidioc_g_frequency(struct file *file, void *priv,
173 struct v4l2_frequency *f)
174{
Hans Verkuilc41269f2009-03-06 13:52:34 -0300175 struct fmi *fmi = video_drvdata(file);
Douglas Landgrafc123b862007-04-23 17:52:12 -0300176
Hans Verkuila3a9e282009-11-27 04:33:25 -0300177 if (f->tuner != 0)
178 return -EINVAL;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300179 f->type = V4L2_TUNER_RADIO;
180 f->frequency = fmi->curfreq;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300181 return 0;
182}
183
Hans Verkuil268d06b2013-02-03 09:51:06 -0300184static int fmi_s_ctrl(struct v4l2_ctrl *ctrl)
Douglas Landgrafc123b862007-04-23 17:52:12 -0300185{
Hans Verkuil268d06b2013-02-03 09:51:06 -0300186 struct fmi *fmi = container_of(ctrl->handler, struct fmi, hdl);
Douglas Landgrafc123b862007-04-23 17:52:12 -0300187
188 switch (ctrl->id) {
189 case V4L2_CID_AUDIO_MUTE:
Hans Verkuil268d06b2013-02-03 09:51:06 -0300190 if (ctrl->val)
Hans Verkuilc41269f2009-03-06 13:52:34 -0300191 fmi_mute(fmi);
Douglas Landgrafc123b862007-04-23 17:52:12 -0300192 else
Hans Verkuilc41269f2009-03-06 13:52:34 -0300193 fmi_unmute(fmi);
Hans Verkuil268d06b2013-02-03 09:51:06 -0300194 fmi->mute = ctrl->val;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300195 return 0;
196 }
197 return -EINVAL;
198}
199
Hans Verkuil268d06b2013-02-03 09:51:06 -0300200static const struct v4l2_ctrl_ops fmi_ctrl_ops = {
201 .s_ctrl = fmi_s_ctrl,
202};
203
Hans Verkuilbec43662008-12-30 06:58:20 -0300204static const struct v4l2_file_operations fmi_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 .owner = THIS_MODULE,
Hans Verkuil0dc5d822013-02-03 09:51:59 -0300206 .open = v4l2_fh_open,
207 .release = v4l2_fh_release,
208 .poll = v4l2_ctrl_poll,
Hans Verkuil32958fd2010-11-14 09:36:23 -0300209 .unlocked_ioctl = video_ioctl2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210};
211
Hans Verkuila3998102008-07-21 02:57:38 -0300212static const struct v4l2_ioctl_ops fmi_ioctl_ops = {
Douglas Landgrafc123b862007-04-23 17:52:12 -0300213 .vidioc_querycap = vidioc_querycap,
214 .vidioc_g_tuner = vidioc_g_tuner,
215 .vidioc_s_tuner = vidioc_s_tuner,
Douglas Landgrafc123b862007-04-23 17:52:12 -0300216 .vidioc_g_frequency = vidioc_g_frequency,
217 .vidioc_s_frequency = vidioc_s_frequency,
Hans Verkuil0dc5d822013-02-03 09:51:59 -0300218 .vidioc_log_status = v4l2_ctrl_log_status,
219 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
220 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221};
222
223/* ladis: this is my card. does any other types exist? */
Greg Kroah-Hartman4c62e972012-12-21 13:17:53 -0800224static struct isapnp_device_id id_table[] = {
Ondrej Zaryabed6232012-05-19 13:18:26 -0300225 /* SF16-FMI */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 { ISAPNP_ANY_ID, ISAPNP_ANY_ID,
227 ISAPNP_VENDOR('M','F','R'), ISAPNP_FUNCTION(0xad10), 0},
Ondrej Zaryabed6232012-05-19 13:18:26 -0300228 /* SF16-FMD */
229 { ISAPNP_ANY_ID, ISAPNP_ANY_ID,
230 ISAPNP_VENDOR('M','F','R'), ISAPNP_FUNCTION(0xad12), 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 { ISAPNP_CARD_END, },
232};
233
234MODULE_DEVICE_TABLE(isapnp, id_table);
235
Randy Dunlapa9993372008-01-23 02:39:39 -0300236static int __init isapnp_fmi_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237{
238 int i = 0;
239
240 while (id_table[i].card_vendor != 0 && dev == NULL) {
241 dev = pnp_find_dev(NULL, id_table[i].vendor,
242 id_table[i].function, NULL);
243 i++;
244 }
245
246 if (!dev)
247 return -ENODEV;
248 if (pnp_device_attach(dev) < 0)
249 return -EAGAIN;
250 if (pnp_activate_dev(dev) < 0) {
Hans Verkuilc41269f2009-03-06 13:52:34 -0300251 printk(KERN_ERR "radio-sf16fmi: PnP configure failed (out of resources?)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 pnp_device_detach(dev);
253 return -ENOMEM;
254 }
255 if (!pnp_port_valid(dev, 0)) {
256 pnp_device_detach(dev);
257 return -ENODEV;
258 }
259
260 i = pnp_port_start(dev, 0);
Hans Verkuilc41269f2009-03-06 13:52:34 -0300261 printk(KERN_INFO "radio-sf16fmi: PnP reports card at %#x\n", i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
263 return i;
264}
265
266static int __init fmi_init(void)
267{
Hans Verkuilc41269f2009-03-06 13:52:34 -0300268 struct fmi *fmi = &fmi_card;
269 struct v4l2_device *v4l2_dev = &fmi->v4l2_dev;
Hans Verkuil268d06b2013-02-03 09:51:06 -0300270 struct v4l2_ctrl_handler *hdl = &fmi->hdl;
Ondrej Zary67cabf502009-12-10 17:12:32 -0300271 int res, i;
272 int probe_ports[] = { 0, 0x284, 0x384 };
Hans Verkuilc41269f2009-03-06 13:52:34 -0300273
Ondrej Zary67cabf502009-12-10 17:12:32 -0300274 if (io < 0) {
275 for (i = 0; i < ARRAY_SIZE(probe_ports); i++) {
276 io = probe_ports[i];
277 if (io == 0) {
278 io = isapnp_fmi_probe();
279 if (io < 0)
280 continue;
281 pnp_attached = 1;
282 }
283 if (!request_region(io, 2, "radio-sf16fmi")) {
284 if (pnp_attached)
285 pnp_device_detach(dev);
286 io = -1;
287 continue;
288 }
289 if (pnp_attached ||
290 ((inb(io) & 0xf9) == 0xf9 && (inb(io) & 0x4) == 0))
291 break;
292 release_region(io, 2);
293 io = -1;
294 }
295 } else {
296 if (!request_region(io, 2, "radio-sf16fmi")) {
297 printk(KERN_ERR "radio-sf16fmi: port %#x already in use\n", io);
298 return -EBUSY;
299 }
300 if (inb(io) == 0xff) {
301 printk(KERN_ERR "radio-sf16fmi: card not present at %#x\n", io);
302 release_region(io, 2);
303 return -ENODEV;
304 }
305 }
306 if (io < 0) {
307 printk(KERN_ERR "radio-sf16fmi: no cards found\n");
308 return -ENODEV;
309 }
310
Hans Verkuilc41269f2009-03-06 13:52:34 -0300311 strlcpy(v4l2_dev->name, "sf16fmi", sizeof(v4l2_dev->name));
312 fmi->io = io;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
Hans Verkuilc41269f2009-03-06 13:52:34 -0300314 res = v4l2_device_register(NULL, v4l2_dev);
315 if (res < 0) {
316 release_region(fmi->io, 2);
Ondrej Zary67cabf502009-12-10 17:12:32 -0300317 if (pnp_attached)
318 pnp_device_detach(dev);
Hans Verkuilc41269f2009-03-06 13:52:34 -0300319 v4l2_err(v4l2_dev, "Could not register v4l2_device\n");
320 return res;
321 }
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300322
Hans Verkuil268d06b2013-02-03 09:51:06 -0300323 v4l2_ctrl_handler_init(hdl, 1);
324 v4l2_ctrl_new_std(hdl, &fmi_ctrl_ops,
325 V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1);
326 v4l2_dev->ctrl_handler = hdl;
327 if (hdl->error) {
328 res = hdl->error;
329 v4l2_err(v4l2_dev, "Could not register controls\n");
330 v4l2_ctrl_handler_free(hdl);
331 v4l2_device_unregister(v4l2_dev);
332 return res;
333 }
334
Hans Verkuilc41269f2009-03-06 13:52:34 -0300335 strlcpy(fmi->vdev.name, v4l2_dev->name, sizeof(fmi->vdev.name));
336 fmi->vdev.v4l2_dev = v4l2_dev;
337 fmi->vdev.fops = &fmi_fops;
338 fmi->vdev.ioctl_ops = &fmi_ioctl_ops;
339 fmi->vdev.release = video_device_release_empty;
Hans Verkuil0dc5d822013-02-03 09:51:59 -0300340 set_bit(V4L2_FL_USE_FH_PRIO, &fmi->vdev.flags);
Hans Verkuilc41269f2009-03-06 13:52:34 -0300341 video_set_drvdata(&fmi->vdev, fmi);
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300342
Hans Verkuilc41269f2009-03-06 13:52:34 -0300343 mutex_init(&fmi->lock);
344
Hans Verkuil32958fd2010-11-14 09:36:23 -0300345 /* mute card - prevents noisy bootups */
346 fmi_mute(fmi);
347
Hans Verkuilc41269f2009-03-06 13:52:34 -0300348 if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
Hans Verkuil268d06b2013-02-03 09:51:06 -0300349 v4l2_ctrl_handler_free(hdl);
Hans Verkuilc41269f2009-03-06 13:52:34 -0300350 v4l2_device_unregister(v4l2_dev);
351 release_region(fmi->io, 2);
Ondrej Zary67cabf502009-12-10 17:12:32 -0300352 if (pnp_attached)
353 pnp_device_detach(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 return -EINVAL;
355 }
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300356
Hans Verkuilc41269f2009-03-06 13:52:34 -0300357 v4l2_info(v4l2_dev, "card driver at 0x%x\n", fmi->io);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 return 0;
359}
360
Hans Verkuilc41269f2009-03-06 13:52:34 -0300361static void __exit fmi_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362{
Hans Verkuilc41269f2009-03-06 13:52:34 -0300363 struct fmi *fmi = &fmi_card;
364
Hans Verkuil268d06b2013-02-03 09:51:06 -0300365 v4l2_ctrl_handler_free(&fmi->hdl);
Hans Verkuilc41269f2009-03-06 13:52:34 -0300366 video_unregister_device(&fmi->vdev);
367 v4l2_device_unregister(&fmi->v4l2_dev);
368 release_region(fmi->io, 2);
Ondrej Zary67cabf502009-12-10 17:12:32 -0300369 if (dev && pnp_attached)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 pnp_device_detach(dev);
371}
372
373module_init(fmi_init);
Hans Verkuilc41269f2009-03-06 13:52:34 -0300374module_exit(fmi_exit);