blob: c5dc00aa9c9f467f2704ca3f13ef531b36248e93 [file] [log] [blame]
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -03001/*
2 * Guillemot Maxi Radio FM 2000 PCI radio card driver for Linux
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * (C) 2001 Dimitromanolakis Apostolos <apdim@grecian.net>
4 *
5 * Based in the radio Maestro PCI driver. Actually it uses the same chip
6 * for radio but different pci controller.
7 *
8 * I didn't have any specs I reversed engineered the protocol from
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -03009 * the windows driver (radio.dll).
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * The card uses the TEA5757 chip that includes a search function but it
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -030012 * is useless as I haven't found any way to read back the frequency. If
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 * anybody does please mail me.
14 *
15 * For the pdf file see:
16 * http://www.semiconductors.philips.com/pip/TEA5757H/V1
17 *
18 *
19 * CHANGES:
20 * 0.75b
21 * - better pci interface thanks to Francois Romieu <romieu@cogenit.fr>
22 *
Mauro Carvalho Chehabe84fef62006-08-08 09:10:05 -030023 * 0.75 Sun Feb 4 22:51:27 EET 2001
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 * - tiding up
25 * - removed support for multiple devices as it didn't work anyway
26 *
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -030027 * BUGS:
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 * - card unmutes if you change frequency
29 *
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -030030 * (c) 2006, 2007 by Mauro Carvalho Chehab <mchehab@infradead.org>:
31 * - Conversion to V4L2 API
32 * - Uses video_ioctl2 for parsing and to add debug support
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 */
34
35
36#include <linux/module.h>
37#include <linux/init.h>
38#include <linux/ioport.h>
39#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <asm/io.h>
41#include <asm/uaccess.h>
Ingo Molnar3593cab2006-02-07 06:49:14 -020042#include <linux/mutex.h>
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <linux/pci.h>
Mauro Carvalho Chehabe84fef62006-08-08 09:10:05 -030045#include <linux/videodev2.h>
Mauro Carvalho Chehab5e87efa2006-06-05 10:26:32 -030046#include <media/v4l2-common.h>
Hans Verkuil35ea11f2008-07-20 08:12:02 -030047#include <media/v4l2-ioctl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -030049#define DRIVER_VERSION "0.77"
Mauro Carvalho Chehabe84fef62006-08-08 09:10:05 -030050
51#include <linux/version.h> /* for KERNEL_VERSION MACRO */
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -030052#define RADIO_VERSION KERNEL_VERSION(0,7,7)
53
54static struct video_device maxiradio_radio;
55
56#define dprintk(num, fmt, arg...) \
57 do { \
58 if (maxiradio_radio.debug >= num) \
59 printk(KERN_DEBUG "%s: " fmt, \
60 maxiradio_radio.name, ## arg); } while (0)
Mauro Carvalho Chehabe84fef62006-08-08 09:10:05 -030061
62static struct v4l2_queryctrl radio_qctrl[] = {
63 {
64 .id = V4L2_CID_AUDIO_MUTE,
65 .name = "Mute",
66 .minimum = 0,
67 .maximum = 1,
68 .default_value = 1,
69 .type = V4L2_CTRL_TYPE_BOOLEAN,
70 }
71};
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73#ifndef PCI_VENDOR_ID_GUILLEMOT
74#define PCI_VENDOR_ID_GUILLEMOT 0x5046
75#endif
76
77#ifndef PCI_DEVICE_ID_GUILLEMOT
78#define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
79#endif
80
81
82/* TEA5757 pin mappings */
83static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16 ;
84
85static int radio_nr = -1;
86module_param(radio_nr, int, 0);
87
Hans Verkuil3ca685a2008-08-23 04:49:13 -030088static unsigned long in_use;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90#define FREQ_LO 50*16000
91#define FREQ_HI 150*16000
92
93#define FREQ_IF 171200 /* 10.7*16000 */
94#define FREQ_STEP 200 /* 12.5*16 */
95
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -030096/* (x==fmhz*16*1000) -> bits */
97#define FREQ2BITS(x) ((( (unsigned int)(x)+FREQ_IF+(FREQ_STEP<<1)) \
98 /(FREQ_STEP<<2))<<2)
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100#define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF)
101
102
Hans Verkuilbec43662008-12-30 06:58:20 -0300103static int maxiradio_exclusive_open(struct file *file)
Hans Verkuil3ca685a2008-08-23 04:49:13 -0300104{
105 return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
106}
107
Hans Verkuilbec43662008-12-30 06:58:20 -0300108static int maxiradio_exclusive_release(struct file *file)
Hans Verkuil3ca685a2008-08-23 04:49:13 -0300109{
110 clear_bit(0, &in_use);
111 return 0;
112}
113
Hans Verkuilbec43662008-12-30 06:58:20 -0300114static const struct v4l2_file_operations maxiradio_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 .owner = THIS_MODULE,
Hans Verkuil3ca685a2008-08-23 04:49:13 -0300116 .open = maxiradio_exclusive_open,
117 .release = maxiradio_exclusive_release,
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300118 .ioctl = video_ioctl2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
121static struct radio_device
122{
123 __u16 io, /* base of radio io */
124 muted, /* VIDEO_AUDIO_MUTE */
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300125 stereo, /* VIDEO_TUNER_STEREO_ON */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 tuned; /* signal strength (0 or 0xffff) */
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300127
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 unsigned long freq;
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300129
Ingo Molnar3593cab2006-02-07 06:49:14 -0200130 struct mutex lock;
Mauro Carvalho Chehab712642b2007-01-26 07:33:07 -0300131} radio_unit = {
132 .muted =1,
133 .freq = FREQ_LO,
134};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
136static void outbit(unsigned long bit, __u16 io)
137{
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300138 if (bit != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 {
140 outb( power|wren|data ,io); udelay(4);
141 outb( power|wren|data|clk ,io); udelay(4);
142 outb( power|wren|data ,io); udelay(4);
143 }
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300144 else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 {
146 outb( power|wren ,io); udelay(4);
147 outb( power|wren|clk ,io); udelay(4);
148 outb( power|wren ,io); udelay(4);
149 }
150}
151
152static void turn_power(__u16 io, int p)
153{
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300154 if (p != 0) {
155 dprintk(1, "Radio powered on\n");
156 outb(power, io);
157 } else {
158 dprintk(1, "Radio powered off\n");
159 outb(0,io);
160 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161}
162
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300163static void set_freq(__u16 io, __u32 freq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164{
165 unsigned long int si;
166 int bl;
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300167 int val = FREQ2BITS(freq);
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300168
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 /* TEA5757 shift register bits (see pdf) */
170
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300171 outbit(0, io); /* 24 search */
172 outbit(1, io); /* 23 search up/down */
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300173
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300174 outbit(0, io); /* 22 stereo/mono */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300176 outbit(0, io); /* 21 band */
177 outbit(0, io); /* 20 band (only 00=FM works I think) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300179 outbit(0, io); /* 19 port ? */
180 outbit(0, io); /* 18 port ? */
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300181
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300182 outbit(0, io); /* 17 search level */
183 outbit(0, io); /* 16 search level */
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300184
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 si = 0x8000;
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300186 for (bl = 1; bl <= 16; bl++) {
187 outbit(val & si, io);
188 si >>= 1;
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300189 }
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300190
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300191 dprintk(1, "Radio freq set to %d.%02d MHz\n",
192 freq / 16000,
193 freq % 16000 * 100 / 16000);
194
195 turn_power(io, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196}
197
198static int get_stereo(__u16 io)
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300199{
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300200 outb(power,io);
201 udelay(4);
202
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 return !(inb(io) & mo_st);
204}
205
206static int get_tune(__u16 io)
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300207{
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300208 outb(power+clk,io);
209 udelay(4);
210
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 return !(inb(io) & mo_st);
212}
213
214
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300215static int vidioc_querycap (struct file *file, void *priv,
216 struct v4l2_capability *v)
217{
218 strlcpy(v->driver, "radio-maxiradio", sizeof (v->driver));
219 strlcpy(v->card, "Maxi Radio FM2000 radio", sizeof (v->card));
220 sprintf(v->bus_info,"ISA");
221 v->version = RADIO_VERSION;
222 v->capabilities = V4L2_CAP_TUNER;
223
224 return 0;
225}
226
227static int vidioc_g_tuner (struct file *file, void *priv,
228 struct v4l2_tuner *v)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229{
Hans Verkuilc170ecf2008-08-23 08:32:09 -0300230 struct radio_device *card = video_drvdata(file);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300232 if (v->index > 0)
233 return -EINVAL;
Mauro Carvalho Chehabe84fef62006-08-08 09:10:05 -0300234
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300235 memset(v,0,sizeof(*v));
236 strcpy(v->name, "FM");
237 v->type = V4L2_TUNER_RADIO;
238
239 v->rangelow=FREQ_LO;
240 v->rangehigh=FREQ_HI;
241 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
242 v->capability=V4L2_TUNER_CAP_LOW;
243 if(get_stereo(card->io))
244 v->audmode = V4L2_TUNER_MODE_STEREO;
245 else
246 v->audmode = V4L2_TUNER_MODE_MONO;
247 v->signal=0xffff*get_tune(card->io);
248
249 return 0;
250}
251
252static int vidioc_s_tuner (struct file *file, void *priv,
253 struct v4l2_tuner *v)
254{
255 if (v->index > 0)
256 return -EINVAL;
257
258 return 0;
259}
260
Mauro Carvalho Chehab140dcc42007-01-25 15:00:45 -0300261static int vidioc_g_audio (struct file *file, void *priv,
262 struct v4l2_audio *a)
263{
264 if (a->index > 1)
265 return -EINVAL;
266
Mauro Carvalho Chehabb61f8d62007-01-26 07:07:12 -0300267 strcpy(a->name, "FM");
Mauro Carvalho Chehab140dcc42007-01-25 15:00:45 -0300268 a->capability = V4L2_AUDCAP_STEREO;
269 return 0;
270}
271
Mauro Carvalho Chehaba0c05ab2007-01-25 16:48:13 -0300272static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
273{
274 *i = 0;
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300275
Mauro Carvalho Chehaba0c05ab2007-01-25 16:48:13 -0300276 return 0;
277}
278
279static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
280{
281 if (i != 0)
282 return -EINVAL;
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300283
Mauro Carvalho Chehaba0c05ab2007-01-25 16:48:13 -0300284 return 0;
285}
286
287
Mauro Carvalho Chehab140dcc42007-01-25 15:00:45 -0300288static int vidioc_s_audio (struct file *file, void *priv,
289 struct v4l2_audio *a)
290{
291 if (a->index != 0)
292 return -EINVAL;
293
294 return 0;
295}
296
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300297static int vidioc_s_frequency (struct file *file, void *priv,
298 struct v4l2_frequency *f)
299{
Hans Verkuilc170ecf2008-08-23 08:32:09 -0300300 struct radio_device *card = video_drvdata(file);
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300301
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300302 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) {
303 dprintk(1, "radio freq (%d.%02d MHz) out of range (%d-%d)\n",
304 f->frequency / 16000,
305 f->frequency % 16000 * 100 / 16000,
306 FREQ_LO / 16000, FREQ_HI / 16000);
307
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300308 return -EINVAL;
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300309 }
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300310
311 card->freq = f->frequency;
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300312 set_freq(card->io, card->freq);
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300313 msleep(125);
314
315 return 0;
316}
317
318static int vidioc_g_frequency (struct file *file, void *priv,
319 struct v4l2_frequency *f)
320{
Hans Verkuilc170ecf2008-08-23 08:32:09 -0300321 struct radio_device *card = video_drvdata(file);
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300322
323 f->type = V4L2_TUNER_RADIO;
324 f->frequency = card->freq;
325
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300326 dprintk(4, "radio freq is %d.%02d MHz",
327 f->frequency / 16000,
328 f->frequency % 16000 * 100 / 16000);
329
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300330 return 0;
331}
332
333static int vidioc_queryctrl (struct file *file, void *priv,
334 struct v4l2_queryctrl *qc)
335{
336 int i;
337
338 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
339 if (qc->id && qc->id == radio_qctrl[i].id) {
340 memcpy(qc, &(radio_qctrl[i]), sizeof(*qc));
341 return (0);
Mauro Carvalho Chehabe84fef62006-08-08 09:10:05 -0300342 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 }
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300344
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300345 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346}
347
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300348static int vidioc_g_ctrl (struct file *file, void *priv,
349 struct v4l2_control *ctrl)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350{
Hans Verkuilc170ecf2008-08-23 08:32:09 -0300351 struct radio_device *card = video_drvdata(file);
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300352
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300353 switch (ctrl->id) {
354 case V4L2_CID_AUDIO_MUTE:
355 ctrl->value=card->muted;
356 return (0);
357 }
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300358
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300359 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360}
361
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300362static int vidioc_s_ctrl (struct file *file, void *priv,
363 struct v4l2_control *ctrl)
364{
Hans Verkuilc170ecf2008-08-23 08:32:09 -0300365 struct radio_device *card = video_drvdata(file);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300367 switch (ctrl->id) {
368 case V4L2_CID_AUDIO_MUTE:
369 card->muted = ctrl->value;
370 if(card->muted)
371 turn_power(card->io, 0);
372 else
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300373 set_freq(card->io, card->freq);
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300374 return 0;
375 }
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300376
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300377 return -EINVAL;
378}
379
Hans Verkuila3998102008-07-21 02:57:38 -0300380static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = {
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300381 .vidioc_querycap = vidioc_querycap,
382 .vidioc_g_tuner = vidioc_g_tuner,
383 .vidioc_s_tuner = vidioc_s_tuner,
Mauro Carvalho Chehab140dcc42007-01-25 15:00:45 -0300384 .vidioc_g_audio = vidioc_g_audio,
385 .vidioc_s_audio = vidioc_s_audio,
Mauro Carvalho Chehaba0c05ab2007-01-25 16:48:13 -0300386 .vidioc_g_input = vidioc_g_input,
387 .vidioc_s_input = vidioc_s_input,
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300388 .vidioc_g_frequency = vidioc_g_frequency,
389 .vidioc_s_frequency = vidioc_s_frequency,
390 .vidioc_queryctrl = vidioc_queryctrl,
391 .vidioc_g_ctrl = vidioc_g_ctrl,
392 .vidioc_s_ctrl = vidioc_s_ctrl,
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300393};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
Hans Verkuila3998102008-07-21 02:57:38 -0300395static struct video_device maxiradio_radio = {
Hans Verkuilaa5e90a2008-08-23 06:23:55 -0300396 .name = "Maxi Radio FM2000 radio",
397 .fops = &maxiradio_fops,
398 .ioctl_ops = &maxiradio_ioctl_ops,
399 .release = video_device_release_empty,
Hans Verkuila3998102008-07-21 02:57:38 -0300400};
401
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
403{
404 if(!request_region(pci_resource_start(pdev, 0),
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300405 pci_resource_len(pdev, 0), "Maxi Radio FM 2000")) {
406 printk(KERN_ERR "radio-maxiradio: can't reserve I/O ports\n");
407 goto err_out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 }
409
410 if (pci_enable_device(pdev))
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300411 goto err_out_free_region;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412
413 radio_unit.io = pci_resource_start(pdev, 0);
Ingo Molnar3593cab2006-02-07 06:49:14 -0200414 mutex_init(&radio_unit.lock);
Hans Verkuil601e9442008-08-23 07:24:07 -0300415 video_set_drvdata(&maxiradio_radio, &radio_unit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
Hans Verkuilcba99ae2008-09-03 17:11:58 -0300417 if (video_register_device(&maxiradio_radio, VFL_TYPE_RADIO, radio_nr) < 0) {
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300418 printk("radio-maxiradio: can't register device!");
419 goto err_out_free_region;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 }
421
422 printk(KERN_INFO "radio-maxiradio: version "
423 DRIVER_VERSION
424 " time "
425 __TIME__ " "
426 __DATE__
427 "\n");
428
429 printk(KERN_INFO "radio-maxiradio: found Guillemot MAXI Radio device (io = 0x%x)\n",
430 radio_unit.io);
431 return 0;
432
433err_out_free_region:
434 release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
435err_out:
436 return -ENODEV;
437}
438
439static void __devexit maxiradio_remove_one(struct pci_dev *pdev)
440{
441 video_unregister_device(&maxiradio_radio);
442 release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
443}
444
445static struct pci_device_id maxiradio_pci_tbl[] = {
446 { PCI_VENDOR_ID_GUILLEMOT, PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO,
447 PCI_ANY_ID, PCI_ANY_ID, },
448 { 0,}
449};
450
451MODULE_DEVICE_TABLE(pci, maxiradio_pci_tbl);
452
453static struct pci_driver maxiradio_driver = {
454 .name = "radio-maxiradio",
455 .id_table = maxiradio_pci_tbl,
456 .probe = maxiradio_init_one,
457 .remove = __devexit_p(maxiradio_remove_one),
458};
459
460static int __init maxiradio_radio_init(void)
461{
Richard Knutsson9bfab8c2005-11-30 00:59:34 +0100462 return pci_register_driver(&maxiradio_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463}
464
465static void __exit maxiradio_radio_exit(void)
466{
467 pci_unregister_driver(&maxiradio_driver);
468}
469
470module_init(maxiradio_radio_init);
471module_exit(maxiradio_radio_exit);
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300472
473MODULE_AUTHOR("Dimitromanolakis Apostolos, apdim@grecian.net");
474MODULE_DESCRIPTION("Radio driver for the Guillemot Maxi Radio FM2000 radio.");
475MODULE_LICENSE("GPL");
476
477module_param_named(debug,maxiradio_radio.debug, int, 0644);
478MODULE_PARM_DESC(debug,"activates debug info");