1 /* RadioTrack II driver for Linux radio support (C) 1998 Ben Pfaff
3 * Based on RadioTrack I/RadioReveal (C) 1997 M. Kirkwood
4 * Converted to new API by Alan Cox <Alan.Cox@linux.org>
5 * Various bugfixes and enhancements by Russell Kroll <rkroll@exploits.org>
7 * TODO: Allow for more than one of these foolish entities :-)
11 #include <linux/module.h> /* Modules */
12 #include <linux/init.h> /* Initdata */
13 #include <linux/ioport.h> /* request_region */
14 #include <linux/delay.h> /* udelay */
15 #include <asm/io.h> /* outb, outb_p */
16 #include <asm/uaccess.h> /* copy to/from user */
17 #include <linux/videodev.h> /* kernel radio structs */
18 #include <linux/config.h> /* CONFIG_RADIO_RTRACK2_PORT */
19 #include <linux/spinlock.h>
21 #ifndef CONFIG_RADIO_RTRACK2_PORT
22 #define CONFIG_RADIO_RTRACK2_PORT -1
25 static int io
= CONFIG_RADIO_RTRACK2_PORT
;
26 static int radio_nr
= -1;
27 static spinlock_t lock
;
32 unsigned long curfreq
;
39 static void rt_mute(struct rt_device
*dev
)
49 static void rt_unmute(struct rt_device
*dev
)
59 static void zero(void)
73 static int rt_setfreq(struct rt_device
*dev
, unsigned long freq
)
77 freq
= freq
/ 200 + 856;
85 for (i
= 0; i
< 10; i
++)
88 for (i
= 14; i
>= 0; i
--)
102 static int rt_getsigstr(struct rt_device
*dev
)
104 if (inb(io
) & 2) /* bit set = no signal present */
106 return 1; /* signal present */
109 static int rt_do_ioctl(struct inode
*inode
, struct file
*file
,
110 unsigned int cmd
, void *arg
)
112 struct video_device
*dev
= video_devdata(file
);
113 struct rt_device
*rt
=dev
->priv
;
119 struct video_capability
*v
= arg
;
120 memset(v
,0,sizeof(*v
));
121 v
->type
=VID_TYPE_TUNER
;
124 strcpy(v
->name
, "RadioTrack II");
129 struct video_tuner
*v
= arg
;
130 if(v
->tuner
) /* Only 1 tuner */
132 v
->rangelow
=88*16000;
133 v
->rangehigh
=108*16000;
134 v
->flags
=VIDEO_TUNER_LOW
;
135 v
->mode
=VIDEO_MODE_AUTO
;
136 v
->signal
=0xFFFF*rt_getsigstr(rt
);
137 strcpy(v
->name
, "FM");
142 struct video_tuner
*v
= arg
;
145 /* Only 1 tuner so no setting needed ! */
150 unsigned long *freq
= arg
;
156 unsigned long *freq
= arg
;
158 rt_setfreq(rt
, rt
->curfreq
);
163 struct video_audio
*v
= arg
;
164 memset(v
,0, sizeof(*v
));
165 v
->flags
|=VIDEO_AUDIO_MUTABLE
;
168 strcpy(v
->name
, "Radio");
173 struct video_audio
*v
= arg
;
177 if(v
->flags
&VIDEO_AUDIO_MUTE
)
189 static int rt_ioctl(struct inode
*inode
, struct file
*file
,
190 unsigned int cmd
, unsigned long arg
)
192 return video_usercopy(inode
, file
, cmd
, arg
, rt_do_ioctl
);
195 static struct rt_device rtrack2_unit
;
197 static struct file_operations rtrack2_fops
= {
198 .owner
= THIS_MODULE
,
199 .open
= video_exclusive_open
,
200 .release
= video_exclusive_release
,
205 static struct video_device rtrack2_radio
=
207 .owner
= THIS_MODULE
,
208 .name
= "RadioTrack II radio",
209 .type
= VID_TYPE_TUNER
,
210 .hardware
= VID_HARDWARE_RTRACK2
,
211 .fops
= &rtrack2_fops
,
214 static int __init
rtrack2_init(void)
218 printk(KERN_ERR
"You must set an I/O address with io=0x20c or io=0x30c\n");
221 if (!request_region(io
, 4, "rtrack2"))
223 printk(KERN_ERR
"rtrack2: port 0x%x already in use\n", io
);
227 rtrack2_radio
.priv
=&rtrack2_unit
;
229 spin_lock_init(&lock
);
230 if(video_register_device(&rtrack2_radio
, VFL_TYPE_RADIO
, radio_nr
)==-1)
232 release_region(io
, 4);
236 printk(KERN_INFO
"AIMSlab Radiotrack II card driver.\n");
238 /* mute card - prevents noisy bootups */
240 rtrack2_unit
.muted
= 1;
245 MODULE_AUTHOR("Ben Pfaff");
246 MODULE_DESCRIPTION("A driver for the RadioTrack II radio card.");
247 MODULE_LICENSE("GPL");
249 module_param(io
, int, 0);
250 MODULE_PARM_DESC(io
, "I/O address of the RadioTrack card (0x20c or 0x30c)");
251 module_param(radio_nr
, int, 0);
253 static void __exit
rtrack2_cleanup_module(void)
255 video_unregister_device(&rtrack2_radio
);
256 release_region(io
,4);
259 module_init(rtrack2_init
);
260 module_exit(rtrack2_cleanup_module
);
264 compile-command: "mmake"