109c434b8SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 2abed623cSOndrej Zary /* SF16-FMI, SF16-FMP and SF16-FMD radio driver for Linux radio support 31da177e4SLinus Torvalds * heavily based on rtrack driver... 41da177e4SLinus Torvalds * (c) 1997 M. Kirkwood 51da177e4SLinus Torvalds * (c) 1998 Petr Vandrovec, vandrove@vc.cvut.cz 61da177e4SLinus Torvalds * 7d9b01449SAlan Cox * Fitted to new interface by Alan Cox <alan@lxorguk.ukuu.org.uk> 81da177e4SLinus Torvalds * Made working and cleaned up functions <mikael.hedin@irf.se> 91da177e4SLinus Torvalds * Support for ISAPnP by Ladislav Michl <ladis@psi.cz> 101da177e4SLinus Torvalds * 111da177e4SLinus Torvalds * Notes on the hardware 121da177e4SLinus Torvalds * 131da177e4SLinus Torvalds * Frequency control is done digitally -- ie out(port,encodefreq(95.8)); 141da177e4SLinus Torvalds * No volume control - only mute/unmute - you have to use line volume 15abed623cSOndrej Zary * control on SB-part of SF16-FMI/SF16-FMP/SF16-FMD 161da177e4SLinus Torvalds * 1732590819SMauro Carvalho Chehab * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@kernel.org> 181da177e4SLinus Torvalds */ 191da177e4SLinus Torvalds 201da177e4SLinus Torvalds #include <linux/kernel.h> /* __setup */ 211da177e4SLinus Torvalds #include <linux/module.h> /* Modules */ 221da177e4SLinus Torvalds #include <linux/init.h> /* Initdata */ 23fb911ee8SPeter Osterlund #include <linux/ioport.h> /* request_region */ 241da177e4SLinus Torvalds #include <linux/delay.h> /* udelay */ 251da177e4SLinus Torvalds #include <linux/isapnp.h> 263593cab5SIngo Molnar #include <linux/mutex.h> 27c41269fdSHans Verkuil #include <linux/videodev2.h> /* kernel radio structs */ 28c41269fdSHans Verkuil #include <linux/io.h> /* outb, outb_p */ 29c41269fdSHans Verkuil #include <media/v4l2-device.h> 30c41269fdSHans Verkuil #include <media/v4l2-ioctl.h> 31268d06bbSHans Verkuil #include <media/v4l2-ctrls.h> 320dc5d82dSHans Verkuil #include <media/v4l2-event.h> 336b39023aSOndrej Zary #include "lm7000.h" 341da177e4SLinus Torvalds 35c41269fdSHans Verkuil MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood"); 36abed623cSOndrej Zary MODULE_DESCRIPTION("A driver for the SF16-FMI, SF16-FMP and SF16-FMD radio."); 37c41269fdSHans Verkuil MODULE_LICENSE("GPL"); 3829834c1aSMauro Carvalho Chehab MODULE_VERSION("0.0.3"); 391da177e4SLinus Torvalds 401da177e4SLinus Torvalds static int io = -1; 411da177e4SLinus Torvalds static int radio_nr = -1; 42c41269fdSHans Verkuil 43c41269fdSHans Verkuil module_param(io, int, 0); 44abed623cSOndrej Zary MODULE_PARM_DESC(io, "I/O address of the SF16-FMI/SF16-FMP/SF16-FMD card (0x284 or 0x384)"); 45c41269fdSHans Verkuil module_param(radio_nr, int, 0); 46c41269fdSHans Verkuil 47c41269fdSHans Verkuil struct fmi 48c41269fdSHans Verkuil { 49c41269fdSHans Verkuil struct v4l2_device v4l2_dev; 50268d06bbSHans Verkuil struct v4l2_ctrl_handler hdl; 51c41269fdSHans Verkuil struct video_device vdev; 52c41269fdSHans Verkuil int io; 534b830374SOndrej Zary bool mute; 54d9ec089eSOndrej Zary u32 curfreq; /* freq in kHz */ 55c41269fdSHans Verkuil struct mutex lock; 56c41269fdSHans Verkuil }; 57c41269fdSHans Verkuil 58c41269fdSHans Verkuil static struct fmi fmi_card; 59c41269fdSHans Verkuil static struct pnp_dev *dev; 6024c8f11fSMauro Carvalho Chehab static bool pnp_attached; 611da177e4SLinus Torvalds 6296bb42b8SHans Verkuil #define RSF16_MINFREQ (87U * 16000) 6396bb42b8SHans Verkuil #define RSF16_MAXFREQ (108U * 16000) 641da177e4SLinus Torvalds 656b39023aSOndrej Zary #define FMI_BIT_TUN_CE (1 << 0) 666b39023aSOndrej Zary #define FMI_BIT_TUN_CLK (1 << 1) 676b39023aSOndrej Zary #define FMI_BIT_TUN_DATA (1 << 2) 686b39023aSOndrej Zary #define FMI_BIT_VOL_SW (1 << 3) 696b39023aSOndrej Zary #define FMI_BIT_TUN_STRQ (1 << 4) 706b39023aSOndrej Zary 71a5133b17SMauro Carvalho Chehab static void fmi_set_pins(void *handle, u8 pins) 721da177e4SLinus Torvalds { 736b39023aSOndrej Zary struct fmi *fmi = handle; 746b39023aSOndrej Zary u8 bits = FMI_BIT_TUN_STRQ; 756b39023aSOndrej Zary 766b39023aSOndrej Zary if (!fmi->mute) 776b39023aSOndrej Zary bits |= FMI_BIT_VOL_SW; 786b39023aSOndrej Zary 796b39023aSOndrej Zary if (pins & LM7000_DATA) 806b39023aSOndrej Zary bits |= FMI_BIT_TUN_DATA; 816b39023aSOndrej Zary if (pins & LM7000_CLK) 826b39023aSOndrej Zary bits |= FMI_BIT_TUN_CLK; 836b39023aSOndrej Zary if (pins & LM7000_CE) 846b39023aSOndrej Zary bits |= FMI_BIT_TUN_CE; 856b39023aSOndrej Zary 866b39023aSOndrej Zary mutex_lock(&fmi->lock); 876b39023aSOndrej Zary outb_p(bits, fmi->io); 886b39023aSOndrej Zary mutex_unlock(&fmi->lock); 891da177e4SLinus Torvalds } 901da177e4SLinus Torvalds 91c41269fdSHans Verkuil static inline void fmi_mute(struct fmi *fmi) 921da177e4SLinus Torvalds { 93c41269fdSHans Verkuil mutex_lock(&fmi->lock); 94c41269fdSHans Verkuil outb(0x00, fmi->io); 95c41269fdSHans Verkuil mutex_unlock(&fmi->lock); 961da177e4SLinus Torvalds } 971da177e4SLinus Torvalds 98c41269fdSHans Verkuil static inline void fmi_unmute(struct fmi *fmi) 991da177e4SLinus Torvalds { 100c41269fdSHans Verkuil mutex_lock(&fmi->lock); 101c41269fdSHans Verkuil outb(0x08, fmi->io); 102c41269fdSHans Verkuil mutex_unlock(&fmi->lock); 1031da177e4SLinus Torvalds } 1041da177e4SLinus Torvalds 105c41269fdSHans Verkuil static inline int fmi_getsigstr(struct fmi *fmi) 1061da177e4SLinus Torvalds { 1071da177e4SLinus Torvalds int val; 1081da177e4SLinus Torvalds int res; 1091da177e4SLinus Torvalds 110c41269fdSHans Verkuil mutex_lock(&fmi->lock); 1114b830374SOndrej Zary val = fmi->mute ? 0x00 : 0x08; /* mute/unmute */ 112c41269fdSHans Verkuil outb(val, fmi->io); 113c41269fdSHans Verkuil outb(val | 0x10, fmi->io); 1141da177e4SLinus Torvalds msleep(143); /* was schedule_timeout(HZ/7) */ 115c41269fdSHans Verkuil res = (int)inb(fmi->io + 1); 116c41269fdSHans Verkuil outb(val, fmi->io); 1171da177e4SLinus Torvalds 118c41269fdSHans Verkuil mutex_unlock(&fmi->lock); 1191da177e4SLinus Torvalds return (res & 2) ? 0 : 0xFFFF; 1201da177e4SLinus Torvalds } 1211da177e4SLinus Torvalds 122d9ec089eSOndrej Zary static void fmi_set_freq(struct fmi *fmi) 123d9ec089eSOndrej Zary { 124d9ec089eSOndrej Zary fmi->curfreq = clamp(fmi->curfreq, RSF16_MINFREQ, RSF16_MAXFREQ); 125d9ec089eSOndrej Zary /* rounding in steps of 800 to match the freq 126d9ec089eSOndrej Zary that will be used */ 127d9ec089eSOndrej Zary lm7000_set_freq((fmi->curfreq / 800) * 800, fmi, fmi_set_pins); 128d9ec089eSOndrej Zary } 129d9ec089eSOndrej Zary 130c123b867SDouglas Landgraf static int vidioc_querycap(struct file *file, void *priv, 131c123b867SDouglas Landgraf struct v4l2_capability *v) 1321da177e4SLinus Torvalds { 133c0decac1SMauro Carvalho Chehab strscpy(v->driver, "radio-sf16fmi", sizeof(v->driver)); 134c0decac1SMauro Carvalho Chehab strscpy(v->card, "SF16-FMI/FMP/FMD radio", sizeof(v->card)); 135c0decac1SMauro Carvalho Chehab strscpy(v->bus_info, "ISA:radio-sf16fmi", sizeof(v->bus_info)); 1361da177e4SLinus Torvalds return 0; 1371da177e4SLinus Torvalds } 138c123b867SDouglas Landgraf 139c123b867SDouglas Landgraf static int vidioc_g_tuner(struct file *file, void *priv, 140c123b867SDouglas Landgraf struct v4l2_tuner *v) 1411da177e4SLinus Torvalds { 142c41269fdSHans Verkuil struct fmi *fmi = video_drvdata(file); 1431da177e4SLinus Torvalds 144a2ef73afSMauro Carvalho Chehab if (v->index > 0) 1451da177e4SLinus Torvalds return -EINVAL; 146a2ef73afSMauro Carvalho Chehab 147c0decac1SMauro Carvalho Chehab strscpy(v->name, "FM", sizeof(v->name)); 148a2ef73afSMauro Carvalho Chehab v->type = V4L2_TUNER_RADIO; 1491d80db56SHans Verkuil v->rangelow = RSF16_MINFREQ; 1501d80db56SHans Verkuil v->rangehigh = RSF16_MAXFREQ; 151dc47b778SHans Verkuil v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; 15238092a44SHans Verkuil v->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW; 153a2ef73afSMauro Carvalho Chehab v->audmode = V4L2_TUNER_MODE_STEREO; 1541da177e4SLinus Torvalds v->signal = fmi_getsigstr(fmi); 1551da177e4SLinus Torvalds return 0; 1561da177e4SLinus Torvalds } 157a2ef73afSMauro Carvalho Chehab 158c123b867SDouglas Landgraf static int vidioc_s_tuner(struct file *file, void *priv, 1592f73c7c5SHans Verkuil const struct v4l2_tuner *v) 160c123b867SDouglas Landgraf { 161c41269fdSHans Verkuil return v->index ? -EINVAL : 0; 1621da177e4SLinus Torvalds } 163c123b867SDouglas Landgraf 164c123b867SDouglas Landgraf static int vidioc_s_frequency(struct file *file, void *priv, 165b530a447SHans Verkuil const struct v4l2_frequency *f) 1661da177e4SLinus Torvalds { 167c41269fdSHans Verkuil struct fmi *fmi = video_drvdata(file); 168a2ef73afSMauro Carvalho Chehab 169a3a9e287SHans Verkuil if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) 170a3a9e287SHans Verkuil return -EINVAL; 171d9ec089eSOndrej Zary 172d9ec089eSOndrej Zary fmi->curfreq = f->frequency; 173d9ec089eSOndrej Zary fmi_set_freq(fmi); 174d9ec089eSOndrej Zary 1751da177e4SLinus Torvalds return 0; 1761da177e4SLinus Torvalds } 177c123b867SDouglas Landgraf 178c123b867SDouglas Landgraf static int vidioc_g_frequency(struct file *file, void *priv, 179c123b867SDouglas Landgraf struct v4l2_frequency *f) 1801da177e4SLinus Torvalds { 181c41269fdSHans Verkuil struct fmi *fmi = video_drvdata(file); 182a2ef73afSMauro Carvalho Chehab 183a3a9e287SHans Verkuil if (f->tuner != 0) 184a3a9e287SHans Verkuil return -EINVAL; 185a2ef73afSMauro Carvalho Chehab f->type = V4L2_TUNER_RADIO; 186a2ef73afSMauro Carvalho Chehab f->frequency = fmi->curfreq; 1871da177e4SLinus Torvalds return 0; 1881da177e4SLinus Torvalds } 189c123b867SDouglas Landgraf 190268d06bbSHans Verkuil static int fmi_s_ctrl(struct v4l2_ctrl *ctrl) 1911da177e4SLinus Torvalds { 192268d06bbSHans Verkuil struct fmi *fmi = container_of(ctrl->handler, struct fmi, hdl); 193a2ef73afSMauro Carvalho Chehab 194a2ef73afSMauro Carvalho Chehab switch (ctrl->id) { 195a2ef73afSMauro Carvalho Chehab case V4L2_CID_AUDIO_MUTE: 196268d06bbSHans Verkuil if (ctrl->val) 197c41269fdSHans Verkuil fmi_mute(fmi); 198a2ef73afSMauro Carvalho Chehab else 199c41269fdSHans Verkuil fmi_unmute(fmi); 200268d06bbSHans Verkuil fmi->mute = ctrl->val; 201c123b867SDouglas Landgraf return 0; 202a2ef73afSMauro Carvalho Chehab } 203a2ef73afSMauro Carvalho Chehab return -EINVAL; 2041da177e4SLinus Torvalds } 205c123b867SDouglas Landgraf 206268d06bbSHans Verkuil static const struct v4l2_ctrl_ops fmi_ctrl_ops = { 207268d06bbSHans Verkuil .s_ctrl = fmi_s_ctrl, 208268d06bbSHans Verkuil }; 209268d06bbSHans Verkuil 210bec43661SHans Verkuil static const struct v4l2_file_operations fmi_fops = { 2111da177e4SLinus Torvalds .owner = THIS_MODULE, 2120dc5d82dSHans Verkuil .open = v4l2_fh_open, 2130dc5d82dSHans Verkuil .release = v4l2_fh_release, 2140dc5d82dSHans Verkuil .poll = v4l2_ctrl_poll, 21532958fddSHans Verkuil .unlocked_ioctl = video_ioctl2, 2161da177e4SLinus Torvalds }; 2171da177e4SLinus Torvalds 218a399810cSHans Verkuil static const struct v4l2_ioctl_ops fmi_ioctl_ops = { 219c123b867SDouglas Landgraf .vidioc_querycap = vidioc_querycap, 220c123b867SDouglas Landgraf .vidioc_g_tuner = vidioc_g_tuner, 221c123b867SDouglas Landgraf .vidioc_s_tuner = vidioc_s_tuner, 222c123b867SDouglas Landgraf .vidioc_g_frequency = vidioc_g_frequency, 223c123b867SDouglas Landgraf .vidioc_s_frequency = vidioc_s_frequency, 2240dc5d82dSHans Verkuil .vidioc_log_status = v4l2_ctrl_log_status, 2250dc5d82dSHans Verkuil .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, 2260dc5d82dSHans Verkuil .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 2271da177e4SLinus Torvalds }; 2281da177e4SLinus Torvalds 2291da177e4SLinus Torvalds /* ladis: this is my card. does any other types exist? */ 2304c62e976SGreg Kroah-Hartman static struct isapnp_device_id id_table[] = { 231abed623cSOndrej Zary /* SF16-FMI */ 2321da177e4SLinus Torvalds { ISAPNP_ANY_ID, ISAPNP_ANY_ID, 2331da177e4SLinus Torvalds ISAPNP_VENDOR('M','F','R'), ISAPNP_FUNCTION(0xad10), 0}, 234abed623cSOndrej Zary /* SF16-FMD */ 235abed623cSOndrej Zary { ISAPNP_ANY_ID, ISAPNP_ANY_ID, 236abed623cSOndrej Zary ISAPNP_VENDOR('M','F','R'), ISAPNP_FUNCTION(0xad12), 0}, 2371da177e4SLinus Torvalds { ISAPNP_CARD_END, }, 2381da177e4SLinus Torvalds }; 2391da177e4SLinus Torvalds 2401da177e4SLinus Torvalds MODULE_DEVICE_TABLE(isapnp, id_table); 2411da177e4SLinus Torvalds 242a999337bSRandy Dunlap static int __init isapnp_fmi_probe(void) 2431da177e4SLinus Torvalds { 2441da177e4SLinus Torvalds int i = 0; 2451da177e4SLinus Torvalds 2461da177e4SLinus Torvalds while (id_table[i].card_vendor != 0 && dev == NULL) { 2471da177e4SLinus Torvalds dev = pnp_find_dev(NULL, id_table[i].vendor, 2481da177e4SLinus Torvalds id_table[i].function, NULL); 2491da177e4SLinus Torvalds i++; 2501da177e4SLinus Torvalds } 2511da177e4SLinus Torvalds 2521da177e4SLinus Torvalds if (!dev) 2531da177e4SLinus Torvalds return -ENODEV; 2541da177e4SLinus Torvalds if (pnp_device_attach(dev) < 0) 2551da177e4SLinus Torvalds return -EAGAIN; 2561da177e4SLinus Torvalds if (pnp_activate_dev(dev) < 0) { 257c41269fdSHans Verkuil printk(KERN_ERR "radio-sf16fmi: PnP configure failed (out of resources?)\n"); 2581da177e4SLinus Torvalds pnp_device_detach(dev); 2591da177e4SLinus Torvalds return -ENOMEM; 2601da177e4SLinus Torvalds } 2611da177e4SLinus Torvalds if (!pnp_port_valid(dev, 0)) { 2621da177e4SLinus Torvalds pnp_device_detach(dev); 2631da177e4SLinus Torvalds return -ENODEV; 2641da177e4SLinus Torvalds } 2651da177e4SLinus Torvalds 2661da177e4SLinus Torvalds i = pnp_port_start(dev, 0); 267c41269fdSHans Verkuil printk(KERN_INFO "radio-sf16fmi: PnP reports card at %#x\n", i); 2681da177e4SLinus Torvalds 2691da177e4SLinus Torvalds return i; 2701da177e4SLinus Torvalds } 2711da177e4SLinus Torvalds 2721da177e4SLinus Torvalds static int __init fmi_init(void) 2731da177e4SLinus Torvalds { 274c41269fdSHans Verkuil struct fmi *fmi = &fmi_card; 275c41269fdSHans Verkuil struct v4l2_device *v4l2_dev = &fmi->v4l2_dev; 276268d06bbSHans Verkuil struct v4l2_ctrl_handler *hdl = &fmi->hdl; 27767cabf50SOndrej Zary int res, i; 27867cabf50SOndrej Zary int probe_ports[] = { 0, 0x284, 0x384 }; 279c41269fdSHans Verkuil 28067cabf50SOndrej Zary if (io < 0) { 28167cabf50SOndrej Zary for (i = 0; i < ARRAY_SIZE(probe_ports); i++) { 28267cabf50SOndrej Zary io = probe_ports[i]; 28367cabf50SOndrej Zary if (io == 0) { 2841da177e4SLinus Torvalds io = isapnp_fmi_probe(); 28567cabf50SOndrej Zary if (io < 0) 28667cabf50SOndrej Zary continue; 2878b4b6818SMauro Carvalho Chehab pnp_attached = true; 2881da177e4SLinus Torvalds } 2891da177e4SLinus Torvalds if (!request_region(io, 2, "radio-sf16fmi")) { 29067cabf50SOndrej Zary if (pnp_attached) 291e08a8c9dSMauro Carvalho Chehab pnp_device_detach(dev); 29267cabf50SOndrej Zary io = -1; 29367cabf50SOndrej Zary continue; 29467cabf50SOndrej Zary } 29567cabf50SOndrej Zary if (pnp_attached || 29667cabf50SOndrej Zary ((inb(io) & 0xf9) == 0xf9 && (inb(io) & 0x4) == 0)) 29767cabf50SOndrej Zary break; 29867cabf50SOndrej Zary release_region(io, 2); 29967cabf50SOndrej Zary io = -1; 30067cabf50SOndrej Zary } 30167cabf50SOndrej Zary } else { 30267cabf50SOndrej Zary if (!request_region(io, 2, "radio-sf16fmi")) { 30367cabf50SOndrej Zary printk(KERN_ERR "radio-sf16fmi: port %#x already in use\n", io); 3041da177e4SLinus Torvalds return -EBUSY; 3051da177e4SLinus Torvalds } 30667cabf50SOndrej Zary if (inb(io) == 0xff) { 30767cabf50SOndrej Zary printk(KERN_ERR "radio-sf16fmi: card not present at %#x\n", io); 30867cabf50SOndrej Zary release_region(io, 2); 30967cabf50SOndrej Zary return -ENODEV; 31067cabf50SOndrej Zary } 31167cabf50SOndrej Zary } 31267cabf50SOndrej Zary if (io < 0) { 31367cabf50SOndrej Zary printk(KERN_ERR "radio-sf16fmi: no cards found\n"); 31467cabf50SOndrej Zary return -ENODEV; 31567cabf50SOndrej Zary } 31667cabf50SOndrej Zary 317c0decac1SMauro Carvalho Chehab strscpy(v4l2_dev->name, "sf16fmi", sizeof(v4l2_dev->name)); 31867cabf50SOndrej Zary fmi->io = io; 3191da177e4SLinus Torvalds 320c41269fdSHans Verkuil res = v4l2_device_register(NULL, v4l2_dev); 321c41269fdSHans Verkuil if (res < 0) { 322c41269fdSHans Verkuil release_region(fmi->io, 2); 32367cabf50SOndrej Zary if (pnp_attached) 324c41269fdSHans Verkuil pnp_device_detach(dev); 325c41269fdSHans Verkuil v4l2_err(v4l2_dev, "Could not register v4l2_device\n"); 326c41269fdSHans Verkuil return res; 327c41269fdSHans Verkuil } 3281da177e4SLinus Torvalds 329268d06bbSHans Verkuil v4l2_ctrl_handler_init(hdl, 1); 330268d06bbSHans Verkuil v4l2_ctrl_new_std(hdl, &fmi_ctrl_ops, 331268d06bbSHans Verkuil V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); 332268d06bbSHans Verkuil v4l2_dev->ctrl_handler = hdl; 333268d06bbSHans Verkuil if (hdl->error) { 334268d06bbSHans Verkuil res = hdl->error; 335268d06bbSHans Verkuil v4l2_err(v4l2_dev, "Could not register controls\n"); 336268d06bbSHans Verkuil v4l2_ctrl_handler_free(hdl); 337268d06bbSHans Verkuil v4l2_device_unregister(v4l2_dev); 338268d06bbSHans Verkuil return res; 339268d06bbSHans Verkuil } 340268d06bbSHans Verkuil 341c0decac1SMauro Carvalho Chehab strscpy(fmi->vdev.name, v4l2_dev->name, sizeof(fmi->vdev.name)); 342c41269fdSHans Verkuil fmi->vdev.v4l2_dev = v4l2_dev; 343c41269fdSHans Verkuil fmi->vdev.fops = &fmi_fops; 344c41269fdSHans Verkuil fmi->vdev.ioctl_ops = &fmi_ioctl_ops; 345c41269fdSHans Verkuil fmi->vdev.release = video_device_release_empty; 346*e83ce300SHans Verkuil fmi->vdev.device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; 347c41269fdSHans Verkuil video_set_drvdata(&fmi->vdev, fmi); 3481da177e4SLinus Torvalds 349c41269fdSHans Verkuil mutex_init(&fmi->lock); 350c41269fdSHans Verkuil 351d9ec089eSOndrej Zary /* mute card and set default frequency */ 3528b4b6818SMauro Carvalho Chehab fmi->mute = true; 353d9ec089eSOndrej Zary fmi->curfreq = RSF16_MINFREQ; 354d9ec089eSOndrej Zary fmi_set_freq(fmi); 35532958fddSHans Verkuil 356c41269fdSHans Verkuil if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 357268d06bbSHans Verkuil v4l2_ctrl_handler_free(hdl); 358c41269fdSHans Verkuil v4l2_device_unregister(v4l2_dev); 359c41269fdSHans Verkuil release_region(fmi->io, 2); 36067cabf50SOndrej Zary if (pnp_attached) 361c41269fdSHans Verkuil pnp_device_detach(dev); 3621da177e4SLinus Torvalds return -EINVAL; 3631da177e4SLinus Torvalds } 3641da177e4SLinus Torvalds 365c41269fdSHans Verkuil v4l2_info(v4l2_dev, "card driver at 0x%x\n", fmi->io); 3661da177e4SLinus Torvalds return 0; 3671da177e4SLinus Torvalds } 3681da177e4SLinus Torvalds 369c41269fdSHans Verkuil static void __exit fmi_exit(void) 3701da177e4SLinus Torvalds { 371c41269fdSHans Verkuil struct fmi *fmi = &fmi_card; 372c41269fdSHans Verkuil 373268d06bbSHans Verkuil v4l2_ctrl_handler_free(&fmi->hdl); 374c41269fdSHans Verkuil video_unregister_device(&fmi->vdev); 375c41269fdSHans Verkuil v4l2_device_unregister(&fmi->v4l2_dev); 376c41269fdSHans Verkuil release_region(fmi->io, 2); 37767cabf50SOndrej Zary if (dev && pnp_attached) 3781da177e4SLinus Torvalds pnp_device_detach(dev); 3791da177e4SLinus Torvalds } 3801da177e4SLinus Torvalds 3811da177e4SLinus Torvalds module_init(fmi_init); 382c41269fdSHans Verkuil module_exit(fmi_exit); 383