1 /* RadioTrack II driver for Linux radio support (C) 1998 Ben Pfaff
3 * Based on RadioTrack I/RadioReveal (C) 1997 M. Kirkwood
4 * Coverted 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> /* check_region, 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 */
20 #ifndef CONFIG_RADIO_RTRACK2_PORT
21 #define CONFIG_RADIO_RTRACK2_PORT -1
24 static int io
= CONFIG_RADIO_RTRACK2_PORT
;
30 unsigned long curfreq
;
37 static void rt_mute(struct rt_device
*dev
)
45 static void rt_unmute(struct rt_device
*dev
)
53 static void zero(void)
67 static int rt_setfreq(struct rt_device
*dev
, unsigned long freq
)
71 freq
= freq
/ 200 + 856;
77 for (i
= 0; i
< 10; i
++)
80 for (i
= 14; i
>= 0; i
--)
92 int rt_getsigstr(struct rt_device
*dev
)
94 if (inb(io
) & 2) /* bit set = no signal present */
96 return 1; /* signal present */
99 static int rt_ioctl(struct video_device
*dev
, unsigned int cmd
, void *arg
)
101 struct rt_device
*rt
=dev
->priv
;
107 struct video_capability v
;
108 v
.type
=VID_TYPE_TUNER
;
111 /* No we don't do pictures */
116 strcpy(v
.name
, "RadioTrack II");
117 if(copy_to_user(arg
,&v
,sizeof(v
)))
123 struct video_tuner v
;
124 if(copy_from_user(&v
, arg
,sizeof(v
))!=0)
126 if(v
.tuner
) /* Only 1 tuner */
129 v
.rangehigh
=108*16000;
130 v
.flags
=VIDEO_TUNER_LOW
;
131 v
.mode
=VIDEO_MODE_AUTO
;
132 v
.signal
=0xFFFF*rt_getsigstr(rt
);
133 if(copy_to_user(arg
,&v
, sizeof(v
)))
139 struct video_tuner v
;
140 if(copy_from_user(&v
, arg
, sizeof(v
)))
144 /* Only 1 tuner so no setting needed ! */
148 if(copy_to_user(arg
, &rt
->curfreq
, sizeof(rt
->curfreq
)))
152 if(copy_from_user(&rt
->curfreq
, arg
,sizeof(rt
->curfreq
)))
154 rt_setfreq(rt
, rt
->curfreq
);
158 struct video_audio v
;
159 memset(&v
,0, sizeof(v
));
160 v
.flags
|=VIDEO_AUDIO_MUTABLE
;
163 strcpy(v
.name
, "Radio");
164 if(copy_to_user(arg
,&v
, sizeof(v
)))
170 struct video_audio v
;
171 if(copy_from_user(&v
, arg
, sizeof(v
)))
176 if(v
.flags
&VIDEO_AUDIO_MUTE
)
188 static int rt_open(struct video_device
*dev
, int flags
)
197 static void rt_close(struct video_device
*dev
)
203 static struct rt_device rtrack2_unit
;
205 static struct video_device rtrack2_radio
=
207 "RadioTrack II radio",
209 VID_HARDWARE_RTRACK2
,
212 NULL
, /* Can't read (no capture ability) */
213 NULL
, /* Can't write */
214 NULL
, /* Can't poll */
220 __initfunc(int rtrack2_init(struct video_init
*v
))
222 if (check_region(io
, 4))
224 printk(KERN_ERR
"rtrack2: port 0x%x already in use\n", io
);
228 rtrack2_radio
.priv
=&rtrack2_unit
;
230 if(video_register_device(&rtrack2_radio
, VFL_TYPE_RADIO
)==-1)
233 request_region(io
, 4, "rtrack2");
234 printk(KERN_INFO
"AIMSlab Radiotrack II card driver.\n");
236 /* mute card - prevents noisy bootups */
238 rtrack2_unit
.muted
= 1;
245 MODULE_AUTHOR("Ben Pfaff");
246 MODULE_DESCRIPTION("A driver for the RadioTrack II radio card.");
247 MODULE_PARM(io
, "i");
248 MODULE_PARM_DESC(io
, "I/O address of the RadioTrack card (0x20c or 0x30c)");
252 int init_module(void)
256 printk(KERN_ERR
"You must set an I/O address with io=0x20c or io=0x30c\n");
259 return rtrack2_init(NULL
);
262 void cleanup_module(void)
264 video_unregister_device(&rtrack2_radio
);
265 release_region(io
,4);
272 compile-command: "gcc -c -DMODVERSIONS -D__KERNEL__ -DMODULE -O6 -Wall -Wstrict-prototypes -I /home/blp/tmp/linux-2.1.111-rtrack/include radio-rtrack2.c"