blob: c777a17b00bc21c986b08b756080a995eeeb990e [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 Verkuil3ca685a2008-08-23 04:49:13 -0300103static int maxiradio_exclusive_open(struct inode *inode, struct file *file)
104{
105 return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
106}
107
108static int maxiradio_exclusive_release(struct inode *inode, struct file *file)
109{
110 clear_bit(0, &in_use);
111 return 0;
112}
113
Arjan van de Venfa027c22007-02-12 00:55:33 -0800114static const struct 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,
Douglas Schilling Landgraf078ff792008-04-22 14:46:11 -0300119#ifdef CONFIG_COMPAT
Arnd Bergmann0d0fbf82006-01-09 15:24:57 -0200120 .compat_ioctl = v4l_compat_ioctl32,
Douglas Schilling Landgraf078ff792008-04-22 14:46:11 -0300121#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 .llseek = no_llseek,
123};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124
125static struct radio_device
126{
127 __u16 io, /* base of radio io */
128 muted, /* VIDEO_AUDIO_MUTE */
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300129 stereo, /* VIDEO_TUNER_STEREO_ON */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 tuned; /* signal strength (0 or 0xffff) */
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 unsigned long freq;
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300133
Ingo Molnar3593cab2006-02-07 06:49:14 -0200134 struct mutex lock;
Mauro Carvalho Chehab712642b2007-01-26 07:33:07 -0300135} radio_unit = {
136 .muted =1,
137 .freq = FREQ_LO,
138};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
140static void outbit(unsigned long bit, __u16 io)
141{
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300142 if (bit != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 {
144 outb( power|wren|data ,io); udelay(4);
145 outb( power|wren|data|clk ,io); udelay(4);
146 outb( power|wren|data ,io); udelay(4);
147 }
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300148 else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 {
150 outb( power|wren ,io); udelay(4);
151 outb( power|wren|clk ,io); udelay(4);
152 outb( power|wren ,io); udelay(4);
153 }
154}
155
156static void turn_power(__u16 io, int p)
157{
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300158 if (p != 0) {
159 dprintk(1, "Radio powered on\n");
160 outb(power, io);
161 } else {
162 dprintk(1, "Radio powered off\n");
163 outb(0,io);
164 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165}
166
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300167static void set_freq(__u16 io, __u32 freq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168{
169 unsigned long int si;
170 int bl;
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300171 int val = FREQ2BITS(freq);
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300172
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 /* TEA5757 shift register bits (see pdf) */
174
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300175 outbit(0, io); /* 24 search */
176 outbit(1, io); /* 23 search up/down */
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300177
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300178 outbit(0, io); /* 22 stereo/mono */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300180 outbit(0, io); /* 21 band */
181 outbit(0, io); /* 20 band (only 00=FM works I think) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300183 outbit(0, io); /* 19 port ? */
184 outbit(0, io); /* 18 port ? */
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300185
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300186 outbit(0, io); /* 17 search level */
187 outbit(0, io); /* 16 search level */
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300188
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 si = 0x8000;
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300190 for (bl = 1; bl <= 16; bl++) {
191 outbit(val & si, io);
192 si >>= 1;
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300193 }
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300194
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300195 dprintk(1, "Radio freq set to %d.%02d MHz\n",
196 freq / 16000,
197 freq % 16000 * 100 / 16000);
198
199 turn_power(io, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200}
201
202static int get_stereo(__u16 io)
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300203{
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300204 outb(power,io);
205 udelay(4);
206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 return !(inb(io) & mo_st);
208}
209
210static int get_tune(__u16 io)
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300211{
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300212 outb(power+clk,io);
213 udelay(4);
214
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 return !(inb(io) & mo_st);
216}
217
218
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300219static int vidioc_querycap (struct file *file, void *priv,
220 struct v4l2_capability *v)
221{
222 strlcpy(v->driver, "radio-maxiradio", sizeof (v->driver));
223 strlcpy(v->card, "Maxi Radio FM2000 radio", sizeof (v->card));
224 sprintf(v->bus_info,"ISA");
225 v->version = RADIO_VERSION;
226 v->capabilities = V4L2_CAP_TUNER;
227
228 return 0;
229}
230
231static int vidioc_g_tuner (struct file *file, void *priv,
232 struct v4l2_tuner *v)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233{
Hans Verkuilc170ecf2008-08-23 08:32:09 -0300234 struct radio_device *card = video_drvdata(file);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300236 if (v->index > 0)
237 return -EINVAL;
Mauro Carvalho Chehabe84fef62006-08-08 09:10:05 -0300238
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300239 memset(v,0,sizeof(*v));
240 strcpy(v->name, "FM");
241 v->type = V4L2_TUNER_RADIO;
242
243 v->rangelow=FREQ_LO;
244 v->rangehigh=FREQ_HI;
245 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
246 v->capability=V4L2_TUNER_CAP_LOW;
247 if(get_stereo(card->io))
248 v->audmode = V4L2_TUNER_MODE_STEREO;
249 else
250 v->audmode = V4L2_TUNER_MODE_MONO;
251 v->signal=0xffff*get_tune(card->io);
252
253 return 0;
254}
255
256static int vidioc_s_tuner (struct file *file, void *priv,
257 struct v4l2_tuner *v)
258{
259 if (v->index > 0)
260 return -EINVAL;
261
262 return 0;
263}
264
Mauro Carvalho Chehab140dcc42007-01-25 15:00:45 -0300265static int vidioc_g_audio (struct file *file, void *priv,
266 struct v4l2_audio *a)
267{
268 if (a->index > 1)
269 return -EINVAL;
270
Mauro Carvalho Chehabb61f8d62007-01-26 07:07:12 -0300271 strcpy(a->name, "FM");
Mauro Carvalho Chehab140dcc42007-01-25 15:00:45 -0300272 a->capability = V4L2_AUDCAP_STEREO;
273 return 0;
274}
275
Mauro Carvalho Chehaba0c05ab2007-01-25 16:48:13 -0300276static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
277{
278 *i = 0;
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300279
Mauro Carvalho Chehaba0c05ab2007-01-25 16:48:13 -0300280 return 0;
281}
282
283static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
284{
285 if (i != 0)
286 return -EINVAL;
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300287
Mauro Carvalho Chehaba0c05ab2007-01-25 16:48:13 -0300288 return 0;
289}
290
291
Mauro Carvalho Chehab140dcc42007-01-25 15:00:45 -0300292static int vidioc_s_audio (struct file *file, void *priv,
293 struct v4l2_audio *a)
294{
295 if (a->index != 0)
296 return -EINVAL;
297
298 return 0;
299}
300
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300301static int vidioc_s_frequency (struct file *file, void *priv,
302 struct v4l2_frequency *f)
303{
Hans Verkuilc170ecf2008-08-23 08:32:09 -0300304 struct radio_device *card = video_drvdata(file);
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300305
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300306 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) {
307 dprintk(1, "radio freq (%d.%02d MHz) out of range (%d-%d)\n",
308 f->frequency / 16000,
309 f->frequency % 16000 * 100 / 16000,
310 FREQ_LO / 16000, FREQ_HI / 16000);
311
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300312 return -EINVAL;
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300313 }
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300314
315 card->freq = f->frequency;
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300316 set_freq(card->io, card->freq);
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300317 msleep(125);
318
319 return 0;
320}
321
322static int vidioc_g_frequency (struct file *file, void *priv,
323 struct v4l2_frequency *f)
324{
Hans Verkuilc170ecf2008-08-23 08:32:09 -0300325 struct radio_device *card = video_drvdata(file);
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300326
327 f->type = V4L2_TUNER_RADIO;
328 f->frequency = card->freq;
329
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300330 dprintk(4, "radio freq is %d.%02d MHz",
331 f->frequency / 16000,
332 f->frequency % 16000 * 100 / 16000);
333
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300334 return 0;
335}
336
337static int vidioc_queryctrl (struct file *file, void *priv,
338 struct v4l2_queryctrl *qc)
339{
340 int i;
341
342 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
343 if (qc->id && qc->id == radio_qctrl[i].id) {
344 memcpy(qc, &(radio_qctrl[i]), sizeof(*qc));
345 return (0);
Mauro Carvalho Chehabe84fef62006-08-08 09:10:05 -0300346 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 }
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300348
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300349 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350}
351
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300352static int vidioc_g_ctrl (struct file *file, void *priv,
353 struct v4l2_control *ctrl)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354{
Hans Verkuilc170ecf2008-08-23 08:32:09 -0300355 struct radio_device *card = video_drvdata(file);
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300356
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300357 switch (ctrl->id) {
358 case V4L2_CID_AUDIO_MUTE:
359 ctrl->value=card->muted;
360 return (0);
361 }
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300362
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300363 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364}
365
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300366static int vidioc_s_ctrl (struct file *file, void *priv,
367 struct v4l2_control *ctrl)
368{
Hans Verkuilc170ecf2008-08-23 08:32:09 -0300369 struct radio_device *card = video_drvdata(file);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300371 switch (ctrl->id) {
372 case V4L2_CID_AUDIO_MUTE:
373 card->muted = ctrl->value;
374 if(card->muted)
375 turn_power(card->io, 0);
376 else
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300377 set_freq(card->io, card->freq);
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300378 return 0;
379 }
Mauro Carvalho Chehabf1557ce2007-01-26 07:23:44 -0300380
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300381 return -EINVAL;
382}
383
Hans Verkuila3998102008-07-21 02:57:38 -0300384static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = {
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300385 .vidioc_querycap = vidioc_querycap,
386 .vidioc_g_tuner = vidioc_g_tuner,
387 .vidioc_s_tuner = vidioc_s_tuner,
Mauro Carvalho Chehab140dcc42007-01-25 15:00:45 -0300388 .vidioc_g_audio = vidioc_g_audio,
389 .vidioc_s_audio = vidioc_s_audio,
Mauro Carvalho Chehaba0c05ab2007-01-25 16:48:13 -0300390 .vidioc_g_input = vidioc_g_input,
391 .vidioc_s_input = vidioc_s_input,
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300392 .vidioc_g_frequency = vidioc_g_frequency,
393 .vidioc_s_frequency = vidioc_s_frequency,
394 .vidioc_queryctrl = vidioc_queryctrl,
395 .vidioc_g_ctrl = vidioc_g_ctrl,
396 .vidioc_s_ctrl = vidioc_s_ctrl,
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300397};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
Hans Verkuila3998102008-07-21 02:57:38 -0300399static struct video_device maxiradio_radio = {
Hans Verkuilaa5e90a2008-08-23 06:23:55 -0300400 .name = "Maxi Radio FM2000 radio",
401 .fops = &maxiradio_fops,
402 .ioctl_ops = &maxiradio_ioctl_ops,
403 .release = video_device_release_empty,
Hans Verkuila3998102008-07-21 02:57:38 -0300404};
405
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
407{
408 if(!request_region(pci_resource_start(pdev, 0),
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300409 pci_resource_len(pdev, 0), "Maxi Radio FM 2000")) {
410 printk(KERN_ERR "radio-maxiradio: can't reserve I/O ports\n");
411 goto err_out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 }
413
414 if (pci_enable_device(pdev))
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300415 goto err_out_free_region;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
417 radio_unit.io = pci_resource_start(pdev, 0);
Ingo Molnar3593cab2006-02-07 06:49:14 -0200418 mutex_init(&radio_unit.lock);
Hans Verkuil601e9442008-08-23 07:24:07 -0300419 video_set_drvdata(&maxiradio_radio, &radio_unit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420
Hans Verkuilcba99ae2008-09-03 17:11:58 -0300421 if (video_register_device(&maxiradio_radio, VFL_TYPE_RADIO, radio_nr) < 0) {
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300422 printk("radio-maxiradio: can't register device!");
423 goto err_out_free_region;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 }
425
426 printk(KERN_INFO "radio-maxiradio: version "
427 DRIVER_VERSION
428 " time "
429 __TIME__ " "
430 __DATE__
431 "\n");
432
433 printk(KERN_INFO "radio-maxiradio: found Guillemot MAXI Radio device (io = 0x%x)\n",
434 radio_unit.io);
435 return 0;
436
437err_out_free_region:
438 release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
439err_out:
440 return -ENODEV;
441}
442
443static void __devexit maxiradio_remove_one(struct pci_dev *pdev)
444{
445 video_unregister_device(&maxiradio_radio);
446 release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
447}
448
449static struct pci_device_id maxiradio_pci_tbl[] = {
450 { PCI_VENDOR_ID_GUILLEMOT, PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO,
451 PCI_ANY_ID, PCI_ANY_ID, },
452 { 0,}
453};
454
455MODULE_DEVICE_TABLE(pci, maxiradio_pci_tbl);
456
457static struct pci_driver maxiradio_driver = {
458 .name = "radio-maxiradio",
459 .id_table = maxiradio_pci_tbl,
460 .probe = maxiradio_init_one,
461 .remove = __devexit_p(maxiradio_remove_one),
462};
463
464static int __init maxiradio_radio_init(void)
465{
Richard Knutsson9bfab8c2005-11-30 00:59:34 +0100466 return pci_register_driver(&maxiradio_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467}
468
469static void __exit maxiradio_radio_exit(void)
470{
471 pci_unregister_driver(&maxiradio_driver);
472}
473
474module_init(maxiradio_radio_init);
475module_exit(maxiradio_radio_exit);
Mauro Carvalho Chehab06470ed2007-01-25 09:04:34 -0300476
477MODULE_AUTHOR("Dimitromanolakis Apostolos, apdim@grecian.net");
478MODULE_DESCRIPTION("Radio driver for the Guillemot Maxi Radio FM2000 radio.");
479MODULE_LICENSE("GPL");
480
481module_param_named(debug,maxiradio_radio.debug, int, 0644);
482MODULE_PARM_DESC(debug,"activates debug info");