blob: d7ce8fe6b5ae1a89c5c578a9f2d88d20aaeecca7 [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;
Ondrej Zaryd9ec0892013-06-14 17:01:39 -030053 u32 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 Zary67cabf52009-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
Ondrej Zaryd9ec0892013-06-14 17:01:39 -0300121static void fmi_set_freq(struct fmi *fmi)
122{
123 fmi->curfreq = clamp(fmi->curfreq, RSF16_MINFREQ, RSF16_MAXFREQ);
124 /* rounding in steps of 800 to match the freq
125 that will be used */
126 lm7000_set_freq((fmi->curfreq / 800) * 800, fmi, fmi_set_pins);
127}
128
Douglas Landgrafc123b862007-04-23 17:52:12 -0300129static int vidioc_querycap(struct file *file, void *priv,
130 struct v4l2_capability *v)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131{
Douglas Landgrafc123b862007-04-23 17:52:12 -0300132 strlcpy(v->driver, "radio-sf16fmi", sizeof(v->driver));
Ondrej Zaryabed6232012-05-19 13:18:26 -0300133 strlcpy(v->card, "SF16-FMI/FMP/FMD radio", sizeof(v->card));
Ondrej Zary92916822013-06-14 17:01:38 -0300134 strlcpy(v->bus_info, "ISA:radio-sf16fmi", sizeof(v->bus_info));
Hans Verkuilf90842d2013-02-03 09:44:14 -0300135 v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
136 v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300137 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138}
139
Douglas Landgrafc123b862007-04-23 17:52:12 -0300140static int vidioc_g_tuner(struct file *file, void *priv,
141 struct v4l2_tuner *v)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142{
Hans Verkuilc41269f2009-03-06 13:52:34 -0300143 struct fmi *fmi = video_drvdata(file);
Douglas Landgrafc123b862007-04-23 17:52:12 -0300144
145 if (v->index > 0)
146 return -EINVAL;
147
Hans Verkuilc41269f2009-03-06 13:52:34 -0300148 strlcpy(v->name, "FM", sizeof(v->name));
Douglas Landgrafc123b862007-04-23 17:52:12 -0300149 v->type = V4L2_TUNER_RADIO;
Hans Verkuil1d80db52009-05-02 12:04:13 -0300150 v->rangelow = RSF16_MINFREQ;
151 v->rangehigh = RSF16_MAXFREQ;
Hans Verkuildc47b772009-05-02 11:52:35 -0300152 v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
Hans Verkuil38092a42009-05-02 12:06:15 -0300153 v->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300154 v->audmode = V4L2_TUNER_MODE_STEREO;
155 v->signal = fmi_getsigstr(fmi);
156 return 0;
157}
158
159static int vidioc_s_tuner(struct file *file, void *priv,
Hans Verkuil2f73c7c2013-03-15 06:10:06 -0300160 const struct v4l2_tuner *v)
Douglas Landgrafc123b862007-04-23 17:52:12 -0300161{
Hans Verkuilc41269f2009-03-06 13:52:34 -0300162 return v->index ? -EINVAL : 0;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300163}
164
165static int vidioc_s_frequency(struct file *file, void *priv,
Hans Verkuilb530a442013-03-19 04:09:26 -0300166 const struct v4l2_frequency *f)
Douglas Landgrafc123b862007-04-23 17:52:12 -0300167{
Hans Verkuilc41269f2009-03-06 13:52:34 -0300168 struct fmi *fmi = video_drvdata(file);
Douglas Landgrafc123b862007-04-23 17:52:12 -0300169
Hans Verkuila3a9e282009-11-27 04:33:25 -0300170 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
171 return -EINVAL;
Ondrej Zaryd9ec0892013-06-14 17:01:39 -0300172
173 fmi->curfreq = f->frequency;
174 fmi_set_freq(fmi);
175
Douglas Landgrafc123b862007-04-23 17:52:12 -0300176 return 0;
177}
178
179static int vidioc_g_frequency(struct file *file, void *priv,
180 struct v4l2_frequency *f)
181{
Hans Verkuilc41269f2009-03-06 13:52:34 -0300182 struct fmi *fmi = video_drvdata(file);
Douglas Landgrafc123b862007-04-23 17:52:12 -0300183
Hans Verkuila3a9e282009-11-27 04:33:25 -0300184 if (f->tuner != 0)
185 return -EINVAL;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300186 f->type = V4L2_TUNER_RADIO;
187 f->frequency = fmi->curfreq;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300188 return 0;
189}
190
Hans Verkuil268d06b2013-02-03 09:51:06 -0300191static int fmi_s_ctrl(struct v4l2_ctrl *ctrl)
Douglas Landgrafc123b862007-04-23 17:52:12 -0300192{
Hans Verkuil268d06b2013-02-03 09:51:06 -0300193 struct fmi *fmi = container_of(ctrl->handler, struct fmi, hdl);
Douglas Landgrafc123b862007-04-23 17:52:12 -0300194
195 switch (ctrl->id) {
196 case V4L2_CID_AUDIO_MUTE:
Hans Verkuil268d06b2013-02-03 09:51:06 -0300197 if (ctrl->val)
Hans Verkuilc41269f2009-03-06 13:52:34 -0300198 fmi_mute(fmi);
Douglas Landgrafc123b862007-04-23 17:52:12 -0300199 else
Hans Verkuilc41269f2009-03-06 13:52:34 -0300200 fmi_unmute(fmi);
Hans Verkuil268d06b2013-02-03 09:51:06 -0300201 fmi->mute = ctrl->val;
Douglas Landgrafc123b862007-04-23 17:52:12 -0300202 return 0;
203 }
204 return -EINVAL;
205}
206
Hans Verkuil268d06b2013-02-03 09:51:06 -0300207static const struct v4l2_ctrl_ops fmi_ctrl_ops = {
208 .s_ctrl = fmi_s_ctrl,
209};
210
Hans Verkuilbec43662008-12-30 06:58:20 -0300211static const struct v4l2_file_operations fmi_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 .owner = THIS_MODULE,
Hans Verkuil0dc5d822013-02-03 09:51:59 -0300213 .open = v4l2_fh_open,
214 .release = v4l2_fh_release,
215 .poll = v4l2_ctrl_poll,
Hans Verkuil32958fd2010-11-14 09:36:23 -0300216 .unlocked_ioctl = video_ioctl2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217};
218
Hans Verkuila3998102008-07-21 02:57:38 -0300219static const struct v4l2_ioctl_ops fmi_ioctl_ops = {
Douglas Landgrafc123b862007-04-23 17:52:12 -0300220 .vidioc_querycap = vidioc_querycap,
221 .vidioc_g_tuner = vidioc_g_tuner,
222 .vidioc_s_tuner = vidioc_s_tuner,
Douglas Landgrafc123b862007-04-23 17:52:12 -0300223 .vidioc_g_frequency = vidioc_g_frequency,
224 .vidioc_s_frequency = vidioc_s_frequency,
Hans Verkuil0dc5d822013-02-03 09:51:59 -0300225 .vidioc_log_status = v4l2_ctrl_log_status,
226 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
227 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228};
229
230/* ladis: this is my card. does any other types exist? */
Greg Kroah-Hartman4c62e972012-12-21 13:17:53 -0800231static struct isapnp_device_id id_table[] = {
Ondrej Zaryabed6232012-05-19 13:18:26 -0300232 /* SF16-FMI */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 { ISAPNP_ANY_ID, ISAPNP_ANY_ID,
234 ISAPNP_VENDOR('M','F','R'), ISAPNP_FUNCTION(0xad10), 0},
Ondrej Zaryabed6232012-05-19 13:18:26 -0300235 /* SF16-FMD */
236 { ISAPNP_ANY_ID, ISAPNP_ANY_ID,
237 ISAPNP_VENDOR('M','F','R'), ISAPNP_FUNCTION(0xad12), 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 { ISAPNP_CARD_END, },
239};
240
241MODULE_DEVICE_TABLE(isapnp, id_table);
242
Randy Dunlapa9993372008-01-23 02:39:39 -0300243static int __init isapnp_fmi_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244{
245 int i = 0;
246
247 while (id_table[i].card_vendor != 0 && dev == NULL) {
248 dev = pnp_find_dev(NULL, id_table[i].vendor,
249 id_table[i].function, NULL);
250 i++;
251 }
252
253 if (!dev)
254 return -ENODEV;
255 if (pnp_device_attach(dev) < 0)
256 return -EAGAIN;
257 if (pnp_activate_dev(dev) < 0) {
Hans Verkuilc41269f2009-03-06 13:52:34 -0300258 printk(KERN_ERR "radio-sf16fmi: PnP configure failed (out of resources?)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 pnp_device_detach(dev);
260 return -ENOMEM;
261 }
262 if (!pnp_port_valid(dev, 0)) {
263 pnp_device_detach(dev);
264 return -ENODEV;
265 }
266
267 i = pnp_port_start(dev, 0);
Hans Verkuilc41269f2009-03-06 13:52:34 -0300268 printk(KERN_INFO "radio-sf16fmi: PnP reports card at %#x\n", i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
270 return i;
271}
272
273static int __init fmi_init(void)
274{
Hans Verkuilc41269f2009-03-06 13:52:34 -0300275 struct fmi *fmi = &fmi_card;
276 struct v4l2_device *v4l2_dev = &fmi->v4l2_dev;
Hans Verkuil268d06b2013-02-03 09:51:06 -0300277 struct v4l2_ctrl_handler *hdl = &fmi->hdl;
Ondrej Zary67cabf52009-12-10 17:12:32 -0300278 int res, i;
279 int probe_ports[] = { 0, 0x284, 0x384 };
Hans Verkuilc41269f2009-03-06 13:52:34 -0300280
Ondrej Zary67cabf52009-12-10 17:12:32 -0300281 if (io < 0) {
282 for (i = 0; i < ARRAY_SIZE(probe_ports); i++) {
283 io = probe_ports[i];
284 if (io == 0) {
285 io = isapnp_fmi_probe();
286 if (io < 0)
287 continue;
288 pnp_attached = 1;
289 }
290 if (!request_region(io, 2, "radio-sf16fmi")) {
291 if (pnp_attached)
292 pnp_device_detach(dev);
293 io = -1;
294 continue;
295 }
296 if (pnp_attached ||
297 ((inb(io) & 0xf9) == 0xf9 && (inb(io) & 0x4) == 0))
298 break;
299 release_region(io, 2);
300 io = -1;
301 }
302 } else {
303 if (!request_region(io, 2, "radio-sf16fmi")) {
304 printk(KERN_ERR "radio-sf16fmi: port %#x already in use\n", io);
305 return -EBUSY;
306 }
307 if (inb(io) == 0xff) {
308 printk(KERN_ERR "radio-sf16fmi: card not present at %#x\n", io);
309 release_region(io, 2);
310 return -ENODEV;
311 }
312 }
313 if (io < 0) {
314 printk(KERN_ERR "radio-sf16fmi: no cards found\n");
315 return -ENODEV;
316 }
317
Hans Verkuilc41269f2009-03-06 13:52:34 -0300318 strlcpy(v4l2_dev->name, "sf16fmi", sizeof(v4l2_dev->name));
319 fmi->io = io;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
Hans Verkuilc41269f2009-03-06 13:52:34 -0300321 res = v4l2_device_register(NULL, v4l2_dev);
322 if (res < 0) {
323 release_region(fmi->io, 2);
Ondrej Zary67cabf52009-12-10 17:12:32 -0300324 if (pnp_attached)
325 pnp_device_detach(dev);
Hans Verkuilc41269f2009-03-06 13:52:34 -0300326 v4l2_err(v4l2_dev, "Could not register v4l2_device\n");
327 return res;
328 }
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300329
Hans Verkuil268d06b2013-02-03 09:51:06 -0300330 v4l2_ctrl_handler_init(hdl, 1);
331 v4l2_ctrl_new_std(hdl, &fmi_ctrl_ops,
332 V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1);
333 v4l2_dev->ctrl_handler = hdl;
334 if (hdl->error) {
335 res = hdl->error;
336 v4l2_err(v4l2_dev, "Could not register controls\n");
337 v4l2_ctrl_handler_free(hdl);
338 v4l2_device_unregister(v4l2_dev);
339 return res;
340 }
341
Hans Verkuilc41269f2009-03-06 13:52:34 -0300342 strlcpy(fmi->vdev.name, v4l2_dev->name, sizeof(fmi->vdev.name));
343 fmi->vdev.v4l2_dev = v4l2_dev;
344 fmi->vdev.fops = &fmi_fops;
345 fmi->vdev.ioctl_ops = &fmi_ioctl_ops;
346 fmi->vdev.release = video_device_release_empty;
347 video_set_drvdata(&fmi->vdev, fmi);
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300348
Hans Verkuilc41269f2009-03-06 13:52:34 -0300349 mutex_init(&fmi->lock);
350
Ondrej Zaryd9ec0892013-06-14 17:01:39 -0300351 /* mute card and set default frequency */
352 fmi->mute = 1;
353 fmi->curfreq = RSF16_MINFREQ;
354 fmi_set_freq(fmi);
Hans Verkuil32958fd2010-11-14 09:36:23 -0300355
Hans Verkuilc41269f2009-03-06 13:52:34 -0300356 if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
Hans Verkuil268d06b2013-02-03 09:51:06 -0300357 v4l2_ctrl_handler_free(hdl);
Hans Verkuilc41269f2009-03-06 13:52:34 -0300358 v4l2_device_unregister(v4l2_dev);
359 release_region(fmi->io, 2);
Ondrej Zary67cabf52009-12-10 17:12:32 -0300360 if (pnp_attached)
361 pnp_device_detach(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 return -EINVAL;
363 }
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300364
Hans Verkuilc41269f2009-03-06 13:52:34 -0300365 v4l2_info(v4l2_dev, "card driver at 0x%x\n", fmi->io);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 return 0;
367}
368
Hans Verkuilc41269f2009-03-06 13:52:34 -0300369static void __exit fmi_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370{
Hans Verkuilc41269f2009-03-06 13:52:34 -0300371 struct fmi *fmi = &fmi_card;
372
Hans Verkuil268d06b2013-02-03 09:51:06 -0300373 v4l2_ctrl_handler_free(&fmi->hdl);
Hans Verkuilc41269f2009-03-06 13:52:34 -0300374 video_unregister_device(&fmi->vdev);
375 v4l2_device_unregister(&fmi->v4l2_dev);
376 release_region(fmi->io, 2);
Ondrej Zary67cabf52009-12-10 17:12:32 -0300377 if (dev && pnp_attached)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 pnp_device_detach(dev);
379}
380
381module_init(fmi_init);
Hans Verkuilc41269f2009-03-06 13:52:34 -0300382module_exit(fmi_exit);