aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio')
-rw-r--r--drivers/media/radio/Kconfig2
-rw-r--r--drivers/media/radio/Makefile2
-rw-r--r--drivers/media/radio/miropcm20-radio.c17
-rw-r--r--drivers/media/radio/miropcm20-rds-core.c34
-rw-r--r--drivers/media/radio/miropcm20-rds.c2
-rw-r--r--drivers/media/radio/radio-aimslab.c51
-rw-r--r--drivers/media/radio/radio-aztech.c45
-rw-r--r--drivers/media/radio/radio-cadet.c317
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c47
-rw-r--r--drivers/media/radio/radio-gemtek.c33
-rw-r--r--drivers/media/radio/radio-maestro.c10
-rw-r--r--drivers/media/radio/radio-maxiradio.c81
-rw-r--r--drivers/media/radio/radio-rtrack2.c35
-rw-r--r--drivers/media/radio/radio-sf16fmi.c41
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c5
-rw-r--r--drivers/media/radio/radio-terratec.c63
-rw-r--r--drivers/media/radio/radio-trust.c27
-rw-r--r--drivers/media/radio/radio-typhoon.c5
-rw-r--r--drivers/media/radio/radio-zoltrix.c31
19 files changed, 432 insertions, 416 deletions
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 3fff75763693..de3128a31de8 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -136,7 +136,7 @@ config RADIO_GEMTEK_PCI
136 Choose Y here if you have this PCI FM radio card. 136 Choose Y here if you have this PCI FM radio card.
137 137
138 In order to control your radio card, you will need to use programs 138 In order to control your radio card, you will need to use programs
139 that are compatible with the Video for Linux API. Information on 139 that are compatible with the Video for Linux API. Information on
140 this API and pointers to "v4l" programs may be found at 140 this API and pointers to "v4l" programs may be found at
141 <file:Documentation/video4linux/API.html>. 141 <file:Documentation/video4linux/API.html>.
142 142
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index 8b351945d066..e95b6805e002 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -20,3 +20,5 @@ obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o
20obj-$(CONFIG_RADIO_GEMTEK_PCI) += radio-gemtek-pci.o 20obj-$(CONFIG_RADIO_GEMTEK_PCI) += radio-gemtek-pci.o
21obj-$(CONFIG_RADIO_TRUST) += radio-trust.o 21obj-$(CONFIG_RADIO_TRUST) += radio-trust.o
22obj-$(CONFIG_RADIO_MAESTRO) += radio-maestro.o 22obj-$(CONFIG_RADIO_MAESTRO) += radio-maestro.o
23
24EXTRA_CFLAGS += -Isound
diff --git a/drivers/media/radio/miropcm20-radio.c b/drivers/media/radio/miropcm20-radio.c
index dc292da2605f..c4312fa0e2f5 100644
--- a/drivers/media/radio/miropcm20-radio.c
+++ b/drivers/media/radio/miropcm20-radio.c
@@ -16,13 +16,14 @@
16 16
17/* What ever you think about the ACI, version 0x07 is not very well! 17/* What ever you think about the ACI, version 0x07 is not very well!
18 * I can't get frequency, 'tuner status', 'tuner flags' or mute/mono 18 * I can't get frequency, 'tuner status', 'tuner flags' or mute/mono
19 * conditions... Robert 19 * conditions... Robert
20 */ 20 */
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/videodev.h> 24#include <linux/videodev.h>
25#include "../../../sound/oss/aci.h" 25#include <media/v4l2-common.h>
26#include "oss/aci.h"
26#include "miropcm20-rds-core.h" 27#include "miropcm20-rds-core.h"
27 28
28static int radio_nr = -1; 29static int radio_nr = -1;
@@ -123,7 +124,7 @@ static int pcm20_do_ioctl(struct inode *inode, struct file *file,
123 struct video_device *dev = video_devdata(file); 124 struct video_device *dev = video_devdata(file);
124 struct pcm20_device *pcm20 = dev->priv; 125 struct pcm20_device *pcm20 = dev->priv;
125 int i; 126 int i;
126 127
127 switch(cmd) 128 switch(cmd)
128 { 129 {
129 case VIDIOCGCAP: 130 case VIDIOCGCAP:
@@ -139,7 +140,7 @@ static int pcm20_do_ioctl(struct inode *inode, struct file *file,
139 case VIDIOCGTUNER: 140 case VIDIOCGTUNER:
140 { 141 {
141 struct video_tuner *v = arg; 142 struct video_tuner *v = arg;
142 if(v->tuner) /* Only 1 tuner */ 143 if(v->tuner) /* Only 1 tuner */
143 return -EINVAL; 144 return -EINVAL;
144 v->rangelow=87*16000; 145 v->rangelow=87*16000;
145 v->rangehigh=108*16000; 146 v->rangehigh=108*16000;
@@ -172,7 +173,7 @@ static int pcm20_do_ioctl(struct inode *inode, struct file *file,
172 return i; 173 return i;
173 } 174 }
174 case VIDIOCGAUDIO: 175 case VIDIOCGAUDIO:
175 { 176 {
176 struct video_audio *v = arg; 177 struct video_audio *v = arg;
177 memset(v,0, sizeof(*v)); 178 memset(v,0, sizeof(*v));
178 v->flags=VIDEO_AUDIO_MUTABLE; 179 v->flags=VIDEO_AUDIO_MUTABLE;
@@ -183,12 +184,12 @@ static int pcm20_do_ioctl(struct inode *inode, struct file *file,
183 v->mode|=VIDEO_SOUND_MONO; 184 v->mode|=VIDEO_SOUND_MONO;
184 /* v->step=2048; */ 185 /* v->step=2048; */
185 strcpy(v->name, "Radio"); 186 strcpy(v->name, "Radio");
186 return 0; 187 return 0;
187 } 188 }
188 case VIDIOCSAUDIO: 189 case VIDIOCSAUDIO:
189 { 190 {
190 struct video_audio *v = arg; 191 struct video_audio *v = arg;
191 if(v->audio) 192 if(v->audio)
192 return -EINVAL; 193 return -EINVAL;
193 194
194 pcm20_mute(pcm20, !!(v->flags&VIDEO_AUDIO_MUTE)); 195 pcm20_mute(pcm20, !!(v->flags&VIDEO_AUDIO_MUTE));
@@ -237,7 +238,7 @@ static int __init pcm20_init(void)
237{ 238{
238 if(video_register_device(&pcm20_radio, VFL_TYPE_RADIO, radio_nr)==-1) 239 if(video_register_device(&pcm20_radio, VFL_TYPE_RADIO, radio_nr)==-1)
239 goto video_register_device; 240 goto video_register_device;
240 241
241 if(attach_aci_rds()<0) 242 if(attach_aci_rds()<0)
242 goto attach_aci_rds; 243 goto attach_aci_rds;
243 244
diff --git a/drivers/media/radio/miropcm20-rds-core.c b/drivers/media/radio/miropcm20-rds-core.c
index b602c73e2309..9428d8b2642c 100644
--- a/drivers/media/radio/miropcm20-rds-core.c
+++ b/drivers/media/radio/miropcm20-rds-core.c
@@ -21,7 +21,7 @@
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22 22
23#include <asm/io.h> 23#include <asm/io.h>
24#include "../../../sound/oss/aci.h" 24#include "oss/aci.h"
25#include "miropcm20-rds-core.h" 25#include "miropcm20-rds-core.h"
26 26
27#define DEBUG 0 27#define DEBUG 0
@@ -33,24 +33,24 @@ static struct mutex aci_rds_mutex;
33#define RDS_BUSYMASK 0x10 /* Bit 4 */ 33#define RDS_BUSYMASK 0x10 /* Bit 4 */
34#define RDS_CLOCKMASK 0x08 /* Bit 3 */ 34#define RDS_CLOCKMASK 0x08 /* Bit 3 */
35 35
36#define RDS_DATA(x) (((x) >> RDS_DATASHIFT) & 1) 36#define RDS_DATA(x) (((x) >> RDS_DATASHIFT) & 1)
37 37
38 38
39#if DEBUG 39#if DEBUG
40static void print_matrix(char array[], unsigned int length) 40static void print_matrix(char array[], unsigned int length)
41{ 41{
42 int i, j; 42 int i, j;
43 43
44 for (i=0; i<length; i++) { 44 for (i=0; i<length; i++) {
45 printk(KERN_DEBUG "aci-rds: "); 45 printk(KERN_DEBUG "aci-rds: ");
46 for (j=7; j>=0; j--) { 46 for (j=7; j>=0; j--) {
47 printk("%d", (array[i] >> j) & 0x1); 47 printk("%d", (array[i] >> j) & 0x1);
48 } 48 }
49 if (i%8 == 0) 49 if (i%8 == 0)
50 printk(" byte-border\n"); 50 printk(" byte-border\n");
51 else 51 else
52 printk("\n"); 52 printk("\n");
53 } 53 }
54} 54}
55#endif /* DEBUG */ 55#endif /* DEBUG */
56 56
@@ -114,7 +114,7 @@ static int rds_write(unsigned char cmd)
114{ 114{
115 unsigned char sendbuffer[8]; 115 unsigned char sendbuffer[8];
116 int i; 116 int i;
117 117
118 if (byte2trans(cmd, sendbuffer, 8) != 0){ 118 if (byte2trans(cmd, sendbuffer, 8) != 0){
119 return -1; 119 return -1;
120 } else { 120 } else {
@@ -151,7 +151,7 @@ static int rds_read(unsigned char databuffer[], int datasize)
151 I have to waitread() here */ 151 I have to waitread() here */
152 if (rds_waitread() < 0) 152 if (rds_waitread() < 0)
153 return -1; 153 return -1;
154 154
155 memset(databuffer, 0, datasize); 155 memset(databuffer, 0, datasize);
156 156
157 for (i=0; i< READSIZE; i++) 157 for (i=0; i< READSIZE; i++)
@@ -194,7 +194,7 @@ int aci_rds_cmd(unsigned char cmd, unsigned char databuffer[], int datasize)
194 ret = 0; 194 ret = 0;
195 195
196 mutex_unlock(&aci_rds_mutex); 196 mutex_unlock(&aci_rds_mutex);
197 197
198 return ret; 198 return ret;
199} 199}
200EXPORT_SYMBOL(aci_rds_cmd); 200EXPORT_SYMBOL(aci_rds_cmd);
diff --git a/drivers/media/radio/miropcm20-rds.c b/drivers/media/radio/miropcm20-rds.c
index e09214082e01..87b37b7691da 100644
--- a/drivers/media/radio/miropcm20-rds.c
+++ b/drivers/media/radio/miropcm20-rds.c
@@ -48,7 +48,7 @@ static int rds_f_release(struct inode *in, struct file *fi)
48 48
49static void print_matrix(char *ch, char out[]) 49static void print_matrix(char *ch, char out[])
50{ 50{
51 int j; 51 int j;
52 52
53 for (j=7; j>=0; j--) { 53 for (j=7; j>=0; j--) {
54 out[7-j] = ((*ch >> j) & 0x1) + '0'; 54 out[7-j] = ((*ch >> j) & 0x1) + '0';
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index 557fb5c4af38..df22a582e7a2 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -24,7 +24,7 @@
24 * out(port, start_increasing_volume); 24 * out(port, start_increasing_volume);
25 * wait(a_wee_while); 25 * wait(a_wee_while);
26 * out(port, stop_changing_the_volume); 26 * out(port, stop_changing_the_volume);
27 * 27 *
28 */ 28 */
29 29
30#include <linux/module.h> /* Modules */ 30#include <linux/module.h> /* Modules */
@@ -34,6 +34,7 @@
34#include <asm/io.h> /* outb, outb_p */ 34#include <asm/io.h> /* outb, outb_p */
35#include <asm/uaccess.h> /* copy to/from user */ 35#include <asm/uaccess.h> /* copy to/from user */
36#include <linux/videodev.h> /* kernel radio structs */ 36#include <linux/videodev.h> /* kernel radio structs */
37#include <media/v4l2-common.h>
37#include <linux/config.h> /* CONFIG_RADIO_RTRACK_PORT */ 38#include <linux/config.h> /* CONFIG_RADIO_RTRACK_PORT */
38#include <asm/semaphore.h> /* Lock for the I/O */ 39#include <asm/semaphore.h> /* Lock for the I/O */
39 40
@@ -41,7 +42,7 @@
41#define CONFIG_RADIO_RTRACK_PORT -1 42#define CONFIG_RADIO_RTRACK_PORT -1
42#endif 43#endif
43 44
44static int io = CONFIG_RADIO_RTRACK_PORT; 45static int io = CONFIG_RADIO_RTRACK_PORT;
45static int radio_nr = -1; 46static int radio_nr = -1;
46static struct mutex lock; 47static struct mutex lock;
47 48
@@ -93,12 +94,12 @@ static int rt_setvol(struct rt_device *dev, int vol)
93 int i; 94 int i;
94 95
95 mutex_lock(&lock); 96 mutex_lock(&lock);
96 97
97 if(vol == dev->curvol) { /* requested volume = current */ 98 if(vol == dev->curvol) { /* requested volume = current */
98 if (dev->muted) { /* user is unmuting the card */ 99 if (dev->muted) { /* user is unmuting the card */
99 dev->muted = 0; 100 dev->muted = 0;
100 outb (0xd8, io); /* enable card */ 101 outb (0xd8, io); /* enable card */
101 } 102 }
102 mutex_unlock(&lock); 103 mutex_unlock(&lock);
103 return 0; 104 return 0;
104 } 105 }
@@ -114,10 +115,10 @@ static int rt_setvol(struct rt_device *dev, int vol)
114 115
115 dev->muted = 0; 116 dev->muted = 0;
116 if(vol > dev->curvol) 117 if(vol > dev->curvol)
117 for(i = dev->curvol; i < vol; i++) 118 for(i = dev->curvol; i < vol; i++)
118 rt_incvol(); 119 rt_incvol();
119 else 120 else
120 for(i = dev->curvol; i > vol; i--) 121 for(i = dev->curvol; i > vol; i--)
121 rt_decvol(); 122 rt_decvol();
122 123
123 dev->curvol = vol; 124 dev->curvol = vol;
@@ -125,7 +126,7 @@ static int rt_setvol(struct rt_device *dev, int vol)
125 return 0; 126 return 0;
126} 127}
127 128
128/* the 128+64 on these outb's is to keep the volume stable while tuning 129/* the 128+64 on these outb's is to keep the volume stable while tuning
129 * without them, the volume _will_ creep up with each frequency change 130 * without them, the volume _will_ creep up with each frequency change
130 * and bit 4 (+16) is to keep the signal strength meter enabled 131 * and bit 4 (+16) is to keep the signal strength meter enabled
131 */ 132 */
@@ -140,7 +141,7 @@ static void send_0_byte(int port, struct rt_device *dev)
140 outb_p(128+64+16+8+ 1, port); /* on + wr-enable + data low */ 141 outb_p(128+64+16+8+ 1, port); /* on + wr-enable + data low */
141 outb_p(128+64+16+8+2+1, port); /* clock */ 142 outb_p(128+64+16+8+2+1, port); /* clock */
142 } 143 }
143 sleep_delay(1000); 144 sleep_delay(1000);
144} 145}
145 146
146static void send_1_byte(int port, struct rt_device *dev) 147static void send_1_byte(int port, struct rt_device *dev)
@@ -148,13 +149,13 @@ static void send_1_byte(int port, struct rt_device *dev)
148 if ((dev->curvol == 0) || (dev->muted)) { 149 if ((dev->curvol == 0) || (dev->muted)) {
149 outb_p(128+64+16+4 +1, port); /* wr-enable+data high */ 150 outb_p(128+64+16+4 +1, port); /* wr-enable+data high */
150 outb_p(128+64+16+4+2+1, port); /* clock */ 151 outb_p(128+64+16+4+2+1, port); /* clock */
151 } 152 }
152 else { 153 else {
153 outb_p(128+64+16+8+4 +1, port); /* on+wr-enable+data high */ 154 outb_p(128+64+16+8+4 +1, port); /* on+wr-enable+data high */
154 outb_p(128+64+16+8+4+2+1, port); /* clock */ 155 outb_p(128+64+16+8+4+2+1, port); /* clock */
155 } 156 }
156 157
157 sleep_delay(1000); 158 sleep_delay(1000);
158} 159}
159 160
160static int rt_setfreq(struct rt_device *dev, unsigned long freq) 161static int rt_setfreq(struct rt_device *dev, unsigned long freq)
@@ -167,9 +168,9 @@ static int rt_setfreq(struct rt_device *dev, unsigned long freq)
167 168
168 freq += 171200; /* Add 10.7 MHz IF */ 169 freq += 171200; /* Add 10.7 MHz IF */
169 freq /= 800; /* Convert to 50 kHz units */ 170 freq /= 800; /* Convert to 50 kHz units */
170 171
171 mutex_lock(&lock); /* Stop other ops interfering */ 172 mutex_lock(&lock); /* Stop other ops interfering */
172 173
173 send_0_byte (io, dev); /* 0: LSB of frequency */ 174 send_0_byte (io, dev); /* 0: LSB of frequency */
174 175
175 for (i = 0; i < 13; i++) /* : frequency bits (1-13) */ 176 for (i = 0; i < 13; i++) /* : frequency bits (1-13) */
@@ -195,7 +196,7 @@ static int rt_setfreq(struct rt_device *dev, unsigned long freq)
195 outb (0xd0, io); /* volume steady + sigstr */ 196 outb (0xd0, io); /* volume steady + sigstr */
196 else 197 else
197 outb (0xd8, io); /* volume steady + sigstr + on */ 198 outb (0xd8, io); /* volume steady + sigstr + on */
198 199
199 mutex_unlock(&lock); 200 mutex_unlock(&lock);
200 201
201 return 0; 202 return 0;
@@ -213,7 +214,7 @@ static int rt_do_ioctl(struct inode *inode, struct file *file,
213{ 214{
214 struct video_device *dev = video_devdata(file); 215 struct video_device *dev = video_devdata(file);
215 struct rt_device *rt=dev->priv; 216 struct rt_device *rt=dev->priv;
216 217
217 switch(cmd) 218 switch(cmd)
218 { 219 {
219 case VIDIOCGCAP: 220 case VIDIOCGCAP:
@@ -229,7 +230,7 @@ static int rt_do_ioctl(struct inode *inode, struct file *file,
229 case VIDIOCGTUNER: 230 case VIDIOCGTUNER:
230 { 231 {
231 struct video_tuner *v = arg; 232 struct video_tuner *v = arg;
232 if(v->tuner) /* Only 1 tuner */ 233 if(v->tuner) /* Only 1 tuner */
233 return -EINVAL; 234 return -EINVAL;
234 v->rangelow=(87*16000); 235 v->rangelow=(87*16000);
235 v->rangehigh=(108*16000); 236 v->rangehigh=(108*16000);
@@ -261,21 +262,21 @@ static int rt_do_ioctl(struct inode *inode, struct file *file,
261 return 0; 262 return 0;
262 } 263 }
263 case VIDIOCGAUDIO: 264 case VIDIOCGAUDIO:
264 { 265 {
265 struct video_audio *v = arg; 266 struct video_audio *v = arg;
266 memset(v,0, sizeof(*v)); 267 memset(v,0, sizeof(*v));
267 v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; 268 v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME;
268 v->volume=rt->curvol * 6554; 269 v->volume=rt->curvol * 6554;
269 v->step=6554; 270 v->step=6554;
270 strcpy(v->name, "Radio"); 271 strcpy(v->name, "Radio");
271 return 0; 272 return 0;
272 } 273 }
273 case VIDIOCSAUDIO: 274 case VIDIOCSAUDIO:
274 { 275 {
275 struct video_audio *v = arg; 276 struct video_audio *v = arg;
276 if(v->audio) 277 if(v->audio)
277 return -EINVAL; 278 return -EINVAL;
278 if(v->flags&VIDEO_AUDIO_MUTE) 279 if(v->flags&VIDEO_AUDIO_MUTE)
279 rt_mute(rt); 280 rt_mute(rt);
280 else 281 else
281 rt_setvol(rt,v->volume/6554); 282 rt_setvol(rt,v->volume/6554);
@@ -298,7 +299,7 @@ static struct file_operations rtrack_fops = {
298 .owner = THIS_MODULE, 299 .owner = THIS_MODULE,
299 .open = video_exclusive_open, 300 .open = video_exclusive_open,
300 .release = video_exclusive_release, 301 .release = video_exclusive_release,
301 .ioctl = rt_ioctl, 302 .ioctl = rt_ioctl,
302 .compat_ioctl = v4l_compat_ioctl32, 303 .compat_ioctl = v4l_compat_ioctl32,
303 .llseek = no_llseek, 304 .llseek = no_llseek,
304}; 305};
@@ -320,14 +321,14 @@ static int __init rtrack_init(void)
320 return -EINVAL; 321 return -EINVAL;
321 } 322 }
322 323
323 if (!request_region(io, 2, "rtrack")) 324 if (!request_region(io, 2, "rtrack"))
324 { 325 {
325 printk(KERN_ERR "rtrack: port 0x%x already in use\n", io); 326 printk(KERN_ERR "rtrack: port 0x%x already in use\n", io);
326 return -EBUSY; 327 return -EBUSY;
327 } 328 }
328 329
329 rtrack_radio.priv=&rtrack_unit; 330 rtrack_radio.priv=&rtrack_unit;
330 331
331 if(video_register_device(&rtrack_radio, VFL_TYPE_RADIO, radio_nr)==-1) 332 if(video_register_device(&rtrack_radio, VFL_TYPE_RADIO, radio_nr)==-1)
332 { 333 {
333 release_region(io, 2); 334 release_region(io, 2);
@@ -336,10 +337,10 @@ static int __init rtrack_init(void)
336 printk(KERN_INFO "AIMSlab RadioTrack/RadioReveal card driver.\n"); 337 printk(KERN_INFO "AIMSlab RadioTrack/RadioReveal card driver.\n");
337 338
338 /* Set up the I/O locking */ 339 /* Set up the I/O locking */
339 340
340 mutex_init(&lock); 341 mutex_init(&lock);
341 342
342 /* mute card - prevents noisy bootups */ 343 /* mute card - prevents noisy bootups */
343 344
344 /* this ensures that the volume is all the way down */ 345 /* this ensures that the volume is all the way down */
345 outb(0x48, io); /* volume down but still "on" */ 346 outb(0x48, io); /* volume down but still "on" */
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index 83bdae23417d..95e6322133ee 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -1,11 +1,11 @@
1/* radio-aztech.c - Aztech radio card driver for Linux 2.2 1/* radio-aztech.c - Aztech radio card driver for Linux 2.2
2 * 2 *
3 * Adapted to support the Video for Linux API by 3 * Adapted to support the Video for Linux API by
4 * Russell Kroll <rkroll@exploits.org>. Based on original tuner code by: 4 * Russell Kroll <rkroll@exploits.org>. Based on original tuner code by:
5 * 5 *
6 * Quay Ly 6 * Quay Ly
7 * Donald Song 7 * Donald Song
8 * Jason Lewis (jlewis@twilight.vtc.vsc.edu) 8 * Jason Lewis (jlewis@twilight.vtc.vsc.edu)
9 * Scott McGrath (smcgrath@twilight.vtc.vsc.edu) 9 * Scott McGrath (smcgrath@twilight.vtc.vsc.edu)
10 * William McGrath (wmcgrath@twilight.vtc.vsc.edu) 10 * William McGrath (wmcgrath@twilight.vtc.vsc.edu)
11 * 11 *
@@ -31,6 +31,7 @@
31#include <asm/io.h> /* outb, outb_p */ 31#include <asm/io.h> /* outb, outb_p */
32#include <asm/uaccess.h> /* copy to/from user */ 32#include <asm/uaccess.h> /* copy to/from user */
33#include <linux/videodev.h> /* kernel radio structs */ 33#include <linux/videodev.h> /* kernel radio structs */
34#include <media/v4l2-common.h>
34#include <linux/config.h> /* CONFIG_RADIO_AZTECH_PORT */ 35#include <linux/config.h> /* CONFIG_RADIO_AZTECH_PORT */
35 36
36/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */ 37/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */
@@ -39,7 +40,7 @@
39#define CONFIG_RADIO_AZTECH_PORT -1 40#define CONFIG_RADIO_AZTECH_PORT -1
40#endif 41#endif
41 42
42static int io = CONFIG_RADIO_AZTECH_PORT; 43static int io = CONFIG_RADIO_AZTECH_PORT;
43static int radio_nr = -1; 44static int radio_nr = -1;
44static int radio_wait_time = 1000; 45static int radio_wait_time = 1000;
45static struct mutex lock; 46static struct mutex lock;
@@ -53,15 +54,15 @@ struct az_device
53 54
54static int volconvert(int level) 55static int volconvert(int level)
55{ 56{
56 level>>=14; /* Map 16bits down to 2 bit */ 57 level>>=14; /* Map 16bits down to 2 bit */
57 level&=3; 58 level&=3;
58 59
59 /* convert to card-friendly values */ 60 /* convert to card-friendly values */
60 switch (level) 61 switch (level)
61 { 62 {
62 case 0: 63 case 0:
63 return 0; 64 return 0;
64 case 1: 65 case 1:
65 return 1; 66 return 1;
66 case 2: 67 case 2:
67 return 4; 68 return 4;
@@ -121,9 +122,9 @@ static int az_setfreq(struct az_device *dev, unsigned long frequency)
121 122
122 frequency += 171200; /* Add 10.7 MHz IF */ 123 frequency += 171200; /* Add 10.7 MHz IF */
123 frequency /= 800; /* Convert to 50 kHz units */ 124 frequency /= 800; /* Convert to 50 kHz units */
124 125
125 mutex_lock(&lock); 126 mutex_lock(&lock);
126 127
127 send_0_byte (dev); /* 0: LSB of frequency */ 128 send_0_byte (dev); /* 0: LSB of frequency */
128 129
129 for (i = 0; i < 13; i++) /* : frequency bits (1-13) */ 130 for (i = 0; i < 13; i++) /* : frequency bits (1-13) */
@@ -151,7 +152,7 @@ static int az_setfreq(struct az_device *dev, unsigned long frequency)
151 152
152 udelay (radio_wait_time); 153 udelay (radio_wait_time);
153 outb_p(128+64+volconvert(dev->curvol), io); 154 outb_p(128+64+volconvert(dev->curvol), io);
154 155
155 mutex_unlock(&lock); 156 mutex_unlock(&lock);
156 157
157 return 0; 158 return 0;
@@ -162,7 +163,7 @@ static int az_do_ioctl(struct inode *inode, struct file *file,
162{ 163{
163 struct video_device *dev = video_devdata(file); 164 struct video_device *dev = video_devdata(file);
164 struct az_device *az = dev->priv; 165 struct az_device *az = dev->priv;
165 166
166 switch(cmd) 167 switch(cmd)
167 { 168 {
168 case VIDIOCGCAP: 169 case VIDIOCGCAP:
@@ -178,7 +179,7 @@ static int az_do_ioctl(struct inode *inode, struct file *file,
178 case VIDIOCGTUNER: 179 case VIDIOCGTUNER:
179 { 180 {
180 struct video_tuner *v = arg; 181 struct video_tuner *v = arg;
181 if(v->tuner) /* Only 1 tuner */ 182 if(v->tuner) /* Only 1 tuner */
182 return -EINVAL; 183 return -EINVAL;
183 v->rangelow=(87*16000); 184 v->rangelow=(87*16000);
184 v->rangehigh=(108*16000); 185 v->rangehigh=(108*16000);
@@ -211,7 +212,7 @@ static int az_do_ioctl(struct inode *inode, struct file *file,
211 return 0; 212 return 0;
212 } 213 }
213 case VIDIOCGAUDIO: 214 case VIDIOCGAUDIO:
214 { 215 {
215 struct video_audio *v = arg; 216 struct video_audio *v = arg;
216 memset(v,0, sizeof(*v)); 217 memset(v,0, sizeof(*v));
217 v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; 218 v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME;
@@ -222,17 +223,17 @@ static int az_do_ioctl(struct inode *inode, struct file *file,
222 v->volume=az->curvol; 223 v->volume=az->curvol;
223 v->step=16384; 224 v->step=16384;
224 strcpy(v->name, "Radio"); 225 strcpy(v->name, "Radio");
225 return 0; 226 return 0;
226 } 227 }
227 case VIDIOCSAUDIO: 228 case VIDIOCSAUDIO:
228 { 229 {
229 struct video_audio *v = arg; 230 struct video_audio *v = arg;
230 if(v->audio) 231 if(v->audio)
231 return -EINVAL; 232 return -EINVAL;
232 az->curvol=v->volume; 233 az->curvol=v->volume;
233 234
234 az->stereo=(v->mode&VIDEO_SOUND_STEREO)?1:0; 235 az->stereo=(v->mode&VIDEO_SOUND_STEREO)?1:0;
235 if(v->flags&VIDEO_AUDIO_MUTE) 236 if(v->flags&VIDEO_AUDIO_MUTE)
236 az_setvol(az,0); 237 az_setvol(az,0);
237 else 238 else
238 az_setvol(az,az->curvol); 239 az_setvol(az,az->curvol);
@@ -277,7 +278,7 @@ static int __init aztech_init(void)
277 return -EINVAL; 278 return -EINVAL;
278 } 279 }
279 280
280 if (!request_region(io, 2, "aztech")) 281 if (!request_region(io, 2, "aztech"))
281 { 282 {
282 printk(KERN_ERR "aztech: port 0x%x already in use\n", io); 283 printk(KERN_ERR "aztech: port 0x%x already in use\n", io);
283 return -EBUSY; 284 return -EBUSY;
@@ -285,13 +286,13 @@ static int __init aztech_init(void)
285 286
286 mutex_init(&lock); 287 mutex_init(&lock);
287 aztech_radio.priv=&aztech_unit; 288 aztech_radio.priv=&aztech_unit;
288 289
289 if(video_register_device(&aztech_radio, VFL_TYPE_RADIO, radio_nr)==-1) 290 if(video_register_device(&aztech_radio, VFL_TYPE_RADIO, radio_nr)==-1)
290 { 291 {
291 release_region(io,2); 292 release_region(io,2);
292 return -EINVAL; 293 return -EINVAL;
293 } 294 }
294 295
295 printk(KERN_INFO "Aztech radio card driver v1.00/19990224 rkroll@exploits.org\n"); 296 printk(KERN_INFO "Aztech radio card driver v1.00/19990224 rkroll@exploits.org\n");
296 /* mute card - prevents noisy bootups */ 297 /* mute card - prevents noisy bootups */
297 outb (0, io); 298 outb (0, io);
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index f1b5ac81e9d2..8641aec7baf8 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -8,7 +8,7 @@
8 * Russell Kroll (rkroll@exploits.org) 8 * Russell Kroll (rkroll@exploits.org)
9 * Quay Ly 9 * Quay Ly
10 * Donald Song 10 * Donald Song
11 * Jason Lewis (jlewis@twilight.vtc.vsc.edu) 11 * Jason Lewis (jlewis@twilight.vtc.vsc.edu)
12 * Scott McGrath (smcgrath@twilight.vtc.vsc.edu) 12 * Scott McGrath (smcgrath@twilight.vtc.vsc.edu)
13 * William McGrath (wmcgrath@twilight.vtc.vsc.edu) 13 * William McGrath (wmcgrath@twilight.vtc.vsc.edu)
14 * 14 *
@@ -34,6 +34,7 @@
34#include <asm/io.h> /* outb, outb_p */ 34#include <asm/io.h> /* outb, outb_p */
35#include <asm/uaccess.h> /* copy to/from user */ 35#include <asm/uaccess.h> /* copy to/from user */
36#include <linux/videodev.h> /* kernel radio structs */ 36#include <linux/videodev.h> /* kernel radio structs */
37#include <media/v4l2-common.h>
37#include <linux/param.h> 38#include <linux/param.h>
38#include <linux/pnp.h> 39#include <linux/pnp.h>
39 40
@@ -55,29 +56,29 @@ static int cadet_probe(void);
55 56
56/* 57/*
57 * Signal Strength Threshold Values 58 * Signal Strength Threshold Values
58 * The V4L API spec does not define any particular unit for the signal 59 * The V4L API spec does not define any particular unit for the signal
59 * strength value. These values are in microvolts of RF at the tuner's input. 60 * strength value. These values are in microvolts of RF at the tuner's input.
60 */ 61 */
61static __u16 sigtable[2][4]={{5,10,30,150},{28,40,63,1000}}; 62static __u16 sigtable[2][4]={{5,10,30,150},{28,40,63,1000}};
62 63
63static int cadet_getrds(void) 64static int cadet_getrds(void)
64{ 65{
65 int rdsstat=0; 66 int rdsstat=0;
66 67
67 spin_lock(&cadet_io_lock); 68 spin_lock(&cadet_io_lock);
68 outb(3,io); /* Select Decoder Control/Status */ 69 outb(3,io); /* Select Decoder Control/Status */
69 outb(inb(io+1)&0x7f,io+1); /* Reset RDS detection */ 70 outb(inb(io+1)&0x7f,io+1); /* Reset RDS detection */
70 spin_unlock(&cadet_io_lock); 71 spin_unlock(&cadet_io_lock);
71 72
72 msleep(100); 73 msleep(100);
73 74
74 spin_lock(&cadet_io_lock); 75 spin_lock(&cadet_io_lock);
75 outb(3,io); /* Select Decoder Control/Status */ 76 outb(3,io); /* Select Decoder Control/Status */
76 if((inb(io+1)&0x80)!=0) { 77 if((inb(io+1)&0x80)!=0) {
77 rdsstat|=VIDEO_TUNER_RDS_ON; 78 rdsstat|=VIDEO_TUNER_RDS_ON;
78 } 79 }
79 if((inb(io+1)&0x10)!=0) { 80 if((inb(io+1)&0x10)!=0) {
80 rdsstat|=VIDEO_TUNER_MBS_ON; 81 rdsstat|=VIDEO_TUNER_MBS_ON;
81 } 82 }
82 spin_unlock(&cadet_io_lock); 83 spin_unlock(&cadet_io_lock);
83 return rdsstat; 84 return rdsstat;
@@ -86,49 +87,49 @@ static int cadet_getrds(void)
86static int cadet_getstereo(void) 87static int cadet_getstereo(void)
87{ 88{
88 int ret = 0; 89 int ret = 0;
89 if(curtuner != 0) /* Only FM has stereo capability! */ 90 if(curtuner != 0) /* Only FM has stereo capability! */
90 return 0; 91 return 0;
91 92
92 spin_lock(&cadet_io_lock); 93 spin_lock(&cadet_io_lock);
93 outb(7,io); /* Select tuner control */ 94 outb(7,io); /* Select tuner control */
94 if( (inb(io+1) & 0x40) == 0) 95 if( (inb(io+1) & 0x40) == 0)
95 ret = 1; 96 ret = 1;
96 spin_unlock(&cadet_io_lock); 97 spin_unlock(&cadet_io_lock);
97 return ret; 98 return ret;
98} 99}
99 100
100static unsigned cadet_gettune(void) 101static unsigned cadet_gettune(void)
101{ 102{
102 int curvol,i; 103 int curvol,i;
103 unsigned fifo=0; 104 unsigned fifo=0;
104 105
105 /* 106 /*
106 * Prepare for read 107 * Prepare for read
107 */ 108 */
108 109
109 spin_lock(&cadet_io_lock); 110 spin_lock(&cadet_io_lock);
110 111
111 outb(7,io); /* Select tuner control */ 112 outb(7,io); /* Select tuner control */
112 curvol=inb(io+1); /* Save current volume/mute setting */ 113 curvol=inb(io+1); /* Save current volume/mute setting */
113 outb(0x00,io+1); /* Ensure WRITE-ENABLE is LOW */ 114 outb(0x00,io+1); /* Ensure WRITE-ENABLE is LOW */
114 tunestat=0xffff; 115 tunestat=0xffff;
115 116
116 /* 117 /*
117 * Read the shift register 118 * Read the shift register
118 */ 119 */
119 for(i=0;i<25;i++) { 120 for(i=0;i<25;i++) {
120 fifo=(fifo<<1)|((inb(io+1)>>7)&0x01); 121 fifo=(fifo<<1)|((inb(io+1)>>7)&0x01);
121 if(i<24) { 122 if(i<24) {
122 outb(0x01,io+1); 123 outb(0x01,io+1);
123 tunestat&=inb(io+1); 124 tunestat&=inb(io+1);
124 outb(0x00,io+1); 125 outb(0x00,io+1);
125 } 126 }
126 } 127 }
127 128
128 /* 129 /*
129 * Restore volume/mute setting 130 * Restore volume/mute setting
130 */ 131 */
131 outb(curvol,io+1); 132 outb(curvol,io+1);
132 spin_unlock(&cadet_io_lock); 133 spin_unlock(&cadet_io_lock);
133 134
134 return fifo; 135 return fifo;
@@ -136,43 +137,43 @@ static unsigned cadet_gettune(void)
136 137
137static unsigned cadet_getfreq(void) 138static unsigned cadet_getfreq(void)
138{ 139{
139 int i; 140 int i;
140 unsigned freq=0,test,fifo=0; 141 unsigned freq=0,test,fifo=0;
141 142
142 /* 143 /*
143 * Read current tuning 144 * Read current tuning
144 */ 145 */
145 fifo=cadet_gettune(); 146 fifo=cadet_gettune();
146 147
147 /* 148 /*
148 * Convert to actual frequency 149 * Convert to actual frequency
149 */ 150 */
150 if(curtuner==0) { /* FM */ 151 if(curtuner==0) { /* FM */
151 test=12500; 152 test=12500;
152 for(i=0;i<14;i++) { 153 for(i=0;i<14;i++) {
153 if((fifo&0x01)!=0) { 154 if((fifo&0x01)!=0) {
154 freq+=test; 155 freq+=test;
155 } 156 }
156 test=test<<1; 157 test=test<<1;
157 fifo=fifo>>1; 158 fifo=fifo>>1;
158 } 159 }
159 freq-=10700000; /* IF frequency is 10.7 MHz */ 160 freq-=10700000; /* IF frequency is 10.7 MHz */
160 freq=(freq*16)/1000000; /* Make it 1/16 MHz */ 161 freq=(freq*16)/1000000; /* Make it 1/16 MHz */
161 } 162 }
162 if(curtuner==1) { /* AM */ 163 if(curtuner==1) { /* AM */
163 freq=((fifo&0x7fff)-2010)*16; 164 freq=((fifo&0x7fff)-2010)*16;
164 } 165 }
165 166
166 return freq; 167 return freq;
167} 168}
168 169
169static void cadet_settune(unsigned fifo) 170static void cadet_settune(unsigned fifo)
170{ 171{
171 int i; 172 int i;
172 unsigned test; 173 unsigned test;
173 174
174 spin_lock(&cadet_io_lock); 175 spin_lock(&cadet_io_lock);
175 176
176 outb(7,io); /* Select tuner control */ 177 outb(7,io); /* Select tuner control */
177 /* 178 /*
178 * Write the shift register 179 * Write the shift register
@@ -183,7 +184,7 @@ static void cadet_settune(unsigned fifo)
183 outb(7,io); /* Select tuner control */ 184 outb(7,io); /* Select tuner control */
184 outb(test,io+1); /* Initialize for write */ 185 outb(test,io+1); /* Initialize for write */
185 for(i=0;i<25;i++) { 186 for(i=0;i<25;i++) {
186 test|=0x01; /* Toggle SCK High */ 187 test|=0x01; /* Toggle SCK High */
187 outb(test,io+1); 188 outb(test,io+1);
188 test&=0xfe; /* Toggle SCK Low */ 189 test&=0xfe; /* Toggle SCK Low */
189 outb(test,io+1); 190 outb(test,io+1);
@@ -196,57 +197,57 @@ static void cadet_settune(unsigned fifo)
196 197
197static void cadet_setfreq(unsigned freq) 198static void cadet_setfreq(unsigned freq)
198{ 199{
199 unsigned fifo; 200 unsigned fifo;
200 int i,j,test; 201 int i,j,test;
201 int curvol; 202 int curvol;
202 203
203 /* 204 /*
204 * Formulate a fifo command 205 * Formulate a fifo command
205 */ 206 */
206 fifo=0; 207 fifo=0;
207 if(curtuner==0) { /* FM */ 208 if(curtuner==0) { /* FM */
208 test=102400; 209 test=102400;
209 freq=(freq*1000)/16; /* Make it kHz */ 210 freq=(freq*1000)/16; /* Make it kHz */
210 freq+=10700; /* IF is 10700 kHz */ 211 freq+=10700; /* IF is 10700 kHz */
211 for(i=0;i<14;i++) { 212 for(i=0;i<14;i++) {
212 fifo=fifo<<1; 213 fifo=fifo<<1;
213 if(freq>=test) { 214 if(freq>=test) {
214 fifo|=0x01; 215 fifo|=0x01;
215 freq-=test; 216 freq-=test;
216 } 217 }
217 test=test>>1; 218 test=test>>1;
218 } 219 }
219 } 220 }
220 if(curtuner==1) { /* AM */ 221 if(curtuner==1) { /* AM */
221 fifo=(freq/16)+2010; /* Make it kHz */ 222 fifo=(freq/16)+2010; /* Make it kHz */
222 fifo|=0x100000; /* Select AM Band */ 223 fifo|=0x100000; /* Select AM Band */
223 } 224 }
224 225
225 /* 226 /*
226 * Save current volume/mute setting 227 * Save current volume/mute setting
227 */ 228 */
228 229
229 spin_lock(&cadet_io_lock); 230 spin_lock(&cadet_io_lock);
230 outb(7,io); /* Select tuner control */ 231 outb(7,io); /* Select tuner control */
231 curvol=inb(io+1); 232 curvol=inb(io+1);
232 spin_unlock(&cadet_io_lock); 233 spin_unlock(&cadet_io_lock);
233 234
234 /* 235 /*
235 * Tune the card 236 * Tune the card
236 */ 237 */
237 for(j=3;j>-1;j--) { 238 for(j=3;j>-1;j--) {
238 cadet_settune(fifo|(j<<16)); 239 cadet_settune(fifo|(j<<16));
239 240
240 spin_lock(&cadet_io_lock); 241 spin_lock(&cadet_io_lock);
241 outb(7,io); /* Select tuner control */ 242 outb(7,io); /* Select tuner control */
242 outb(curvol,io+1); 243 outb(curvol,io+1);
243 spin_unlock(&cadet_io_lock); 244 spin_unlock(&cadet_io_lock);
244 245
245 msleep(100); 246 msleep(100);
246 247
247 cadet_gettune(); 248 cadet_gettune();
248 if((tunestat & 0x40) == 0) { /* Tuned */ 249 if((tunestat & 0x40) == 0) { /* Tuned */
249 sigstrength=sigtable[curtuner][j]; 250 sigstrength=sigtable[curtuner][j];
250 return; 251 return;
251 } 252 }
252 } 253 }
@@ -257,28 +258,28 @@ static void cadet_setfreq(unsigned freq)
257static int cadet_getvol(void) 258static int cadet_getvol(void)
258{ 259{
259 int ret = 0; 260 int ret = 0;
260 261
261 spin_lock(&cadet_io_lock); 262 spin_lock(&cadet_io_lock);
262 263
263 outb(7,io); /* Select tuner control */ 264 outb(7,io); /* Select tuner control */
264 if((inb(io + 1) & 0x20) != 0) 265 if((inb(io + 1) & 0x20) != 0)
265 ret = 0xffff; 266 ret = 0xffff;
266 267
267 spin_unlock(&cadet_io_lock); 268 spin_unlock(&cadet_io_lock);
268 return ret; 269 return ret;
269} 270}
270 271
271 272
272static void cadet_setvol(int vol) 273static void cadet_setvol(int vol)
273{ 274{
274 spin_lock(&cadet_io_lock); 275 spin_lock(&cadet_io_lock);
275 outb(7,io); /* Select tuner control */ 276 outb(7,io); /* Select tuner control */
276 if(vol>0) 277 if(vol>0)
277 outb(0x20,io+1); 278 outb(0x20,io+1);
278 else 279 else
279 outb(0x00,io+1); 280 outb(0x00,io+1);
280 spin_unlock(&cadet_io_lock); 281 spin_unlock(&cadet_io_lock);
281} 282}
282 283
283static void cadet_handler(unsigned long data) 284static void cadet_handler(unsigned long data)
284{ 285{
@@ -288,15 +289,15 @@ static void cadet_handler(unsigned long data)
288 289
289 if(spin_trylock(&cadet_io_lock)) 290 if(spin_trylock(&cadet_io_lock))
290 { 291 {
291 outb(0x3,io); /* Select RDS Decoder Control */ 292 outb(0x3,io); /* Select RDS Decoder Control */
292 if((inb(io+1)&0x20)!=0) { 293 if((inb(io+1)&0x20)!=0) {
293 printk(KERN_CRIT "cadet: RDS fifo overflow\n"); 294 printk(KERN_CRIT "cadet: RDS fifo overflow\n");
294 } 295 }
295 outb(0x80,io); /* Select RDS fifo */ 296 outb(0x80,io); /* Select RDS fifo */
296 while((inb(io)&0x80)!=0) { 297 while((inb(io)&0x80)!=0) {
297 rdsbuf[rdsin]=inb(io+1); 298 rdsbuf[rdsin]=inb(io+1);
298 if(rdsin==rdsout) 299 if(rdsin==rdsout)
299 printk(KERN_WARNING "cadet: RDS buffer overflow\n"); 300 printk(KERN_WARNING "cadet: RDS buffer overflow\n");
300 else 301 else
301 rdsin++; 302 rdsin++;
302 } 303 }
@@ -307,9 +308,9 @@ static void cadet_handler(unsigned long data)
307 * Service pending read 308 * Service pending read
308 */ 309 */
309 if( rdsin!=rdsout) 310 if( rdsin!=rdsout)
310 wake_up_interruptible(&read_queue); 311 wake_up_interruptible(&read_queue);
311 312
312 /* 313 /*
313 * Clean up and exit 314 * Clean up and exit
314 */ 315 */
315 init_timer(&readtimer); 316 init_timer(&readtimer);
@@ -324,12 +325,12 @@ static void cadet_handler(unsigned long data)
324static ssize_t cadet_read(struct file *file, char __user *data, 325static ssize_t cadet_read(struct file *file, char __user *data,
325 size_t count, loff_t *ppos) 326 size_t count, loff_t *ppos)
326{ 327{
327 int i=0; 328 int i=0;
328 unsigned char readbuf[RDS_BUFFER]; 329 unsigned char readbuf[RDS_BUFFER];
329 330
330 if(rdsstat==0) { 331 if(rdsstat==0) {
331 spin_lock(&cadet_io_lock); 332 spin_lock(&cadet_io_lock);
332 rdsstat=1; 333 rdsstat=1;
333 outb(0x80,io); /* Select RDS fifo */ 334 outb(0x80,io); /* Select RDS fifo */
334 spin_unlock(&cadet_io_lock); 335 spin_unlock(&cadet_io_lock);
335 init_timer(&readtimer); 336 init_timer(&readtimer);
@@ -339,15 +340,15 @@ static ssize_t cadet_read(struct file *file, char __user *data,
339 add_timer(&readtimer); 340 add_timer(&readtimer);
340 } 341 }
341 if(rdsin==rdsout) { 342 if(rdsin==rdsout) {
342 if (file->f_flags & O_NONBLOCK) 343 if (file->f_flags & O_NONBLOCK)
343 return -EWOULDBLOCK; 344 return -EWOULDBLOCK;
344 interruptible_sleep_on(&read_queue); 345 interruptible_sleep_on(&read_queue);
345 } 346 }
346 while( i<count && rdsin!=rdsout) 347 while( i<count && rdsin!=rdsout)
347 readbuf[i++]=rdsbuf[rdsout++]; 348 readbuf[i++]=rdsbuf[rdsout++];
348 349
349 if (copy_to_user(data,readbuf,i)) 350 if (copy_to_user(data,readbuf,i))
350 return -EFAULT; 351 return -EFAULT;
351 return i; 352 return i;
352} 353}
353 354
@@ -375,29 +376,29 @@ static int cadet_do_ioctl(struct inode *inode, struct file *file,
375 return -EINVAL; 376 return -EINVAL;
376 } 377 }
377 switch(v->tuner) { 378 switch(v->tuner) {
378 case 0: 379 case 0:
379 strcpy(v->name,"FM"); 380 strcpy(v->name,"FM");
380 v->rangelow=1400; /* 87.5 MHz */ 381 v->rangelow=1400; /* 87.5 MHz */
381 v->rangehigh=1728; /* 108.0 MHz */ 382 v->rangehigh=1728; /* 108.0 MHz */
382 v->flags=0; 383 v->flags=0;
383 v->mode=0; 384 v->mode=0;
384 v->mode|=VIDEO_MODE_AUTO; 385 v->mode|=VIDEO_MODE_AUTO;
385 v->signal=sigstrength; 386 v->signal=sigstrength;
386 if(cadet_getstereo()==1) { 387 if(cadet_getstereo()==1) {
387 v->flags|=VIDEO_TUNER_STEREO_ON; 388 v->flags|=VIDEO_TUNER_STEREO_ON;
388 } 389 }
389 v->flags|=cadet_getrds(); 390 v->flags|=cadet_getrds();
390 break; 391 break;
391 case 1: 392 case 1:
392 strcpy(v->name,"AM"); 393 strcpy(v->name,"AM");
393 v->rangelow=8320; /* 520 kHz */ 394 v->rangelow=8320; /* 520 kHz */
394 v->rangehigh=26400; /* 1650 kHz */ 395 v->rangehigh=26400; /* 1650 kHz */
395 v->flags=0; 396 v->flags=0;
396 v->flags|=VIDEO_TUNER_LOW; 397 v->flags|=VIDEO_TUNER_LOW;
397 v->mode=0; 398 v->mode=0;
398 v->mode|=VIDEO_MODE_AUTO; 399 v->mode|=VIDEO_MODE_AUTO;
399 v->signal=sigstrength; 400 v->signal=sigstrength;
400 break; 401 break;
401 } 402 }
402 return 0; 403 return 0;
403 } 404 }
@@ -407,49 +408,49 @@ static int cadet_do_ioctl(struct inode *inode, struct file *file,
407 if((v->tuner<0)||(v->tuner>1)) { 408 if((v->tuner<0)||(v->tuner>1)) {
408 return -EINVAL; 409 return -EINVAL;
409 } 410 }
410 curtuner=v->tuner; 411 curtuner=v->tuner;
411 return 0; 412 return 0;
412 } 413 }
413 case VIDIOCGFREQ: 414 case VIDIOCGFREQ:
414 { 415 {
415 unsigned long *freq = arg; 416 unsigned long *freq = arg;
416 *freq = cadet_getfreq(); 417 *freq = cadet_getfreq();
417 return 0; 418 return 0;
418 } 419 }
419 case VIDIOCSFREQ: 420 case VIDIOCSFREQ:
420 { 421 {
421 unsigned long *freq = arg; 422 unsigned long *freq = arg;
422 if((curtuner==0)&&((*freq<1400)||(*freq>1728))) { 423 if((curtuner==0)&&((*freq<1400)||(*freq>1728))) {
423 return -EINVAL; 424 return -EINVAL;
424 } 425 }
425 if((curtuner==1)&&((*freq<8320)||(*freq>26400))) { 426 if((curtuner==1)&&((*freq<8320)||(*freq>26400))) {
426 return -EINVAL; 427 return -EINVAL;
427 } 428 }
428 cadet_setfreq(*freq); 429 cadet_setfreq(*freq);
429 return 0; 430 return 0;
430 } 431 }
431 case VIDIOCGAUDIO: 432 case VIDIOCGAUDIO:
432 { 433 {
433 struct video_audio *v = arg; 434 struct video_audio *v = arg;
434 memset(v,0, sizeof(*v)); 435 memset(v,0, sizeof(*v));
435 v->flags=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; 436 v->flags=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME;
436 if(cadet_getstereo()==0) { 437 if(cadet_getstereo()==0) {
437 v->mode=VIDEO_SOUND_MONO; 438 v->mode=VIDEO_SOUND_MONO;
438 } else { 439 } else {
439 v->mode=VIDEO_SOUND_STEREO; 440 v->mode=VIDEO_SOUND_STEREO;
440 } 441 }
441 v->volume=cadet_getvol(); 442 v->volume=cadet_getvol();
442 v->step=0xffff; 443 v->step=0xffff;
443 strcpy(v->name, "Radio"); 444 strcpy(v->name, "Radio");
444 return 0; 445 return 0;
445 } 446 }
446 case VIDIOCSAUDIO: 447 case VIDIOCSAUDIO:
447 { 448 {
448 struct video_audio *v = arg; 449 struct video_audio *v = arg;
449 if(v->audio) 450 if(v->audio)
450 return -EINVAL; 451 return -EINVAL;
451 cadet_setvol(v->volume); 452 cadet_setvol(v->volume);
452 if(v->flags&VIDEO_AUDIO_MUTE) 453 if(v->flags&VIDEO_AUDIO_MUTE)
453 cadet_setvol(0); 454 cadet_setvol(0);
454 else 455 else
455 cadet_setvol(0xffff); 456 cadet_setvol(0xffff);
@@ -539,16 +540,16 @@ static struct pnp_driver cadet_pnp_driver = {
539 540
540static int cadet_probe(void) 541static int cadet_probe(void)
541{ 542{
542 static int iovals[8]={0x330,0x332,0x334,0x336,0x338,0x33a,0x33c,0x33e}; 543 static int iovals[8]={0x330,0x332,0x334,0x336,0x338,0x33a,0x33c,0x33e};
543 int i; 544 int i;
544 545
545 for(i=0;i<8;i++) { 546 for(i=0;i<8;i++) {
546 io=iovals[i]; 547 io=iovals[i];
547 if (request_region(io, 2, "cadet-probe")) { 548 if (request_region(io, 2, "cadet-probe")) {
548 cadet_setfreq(1410); 549 cadet_setfreq(1410);
549 if(cadet_getfreq()==1410) { 550 if(cadet_getfreq()==1410) {
550 release_region(io, 2); 551 release_region(io, 2);
551 return io; 552 return io;
552 } 553 }
553 release_region(io, 2); 554 release_region(io, 2);
554 } 555 }
@@ -556,7 +557,7 @@ static int cadet_probe(void)
556 return -1; 557 return -1;
557} 558}
558 559
559/* 560/*
560 * io should only be set if the user has used something like 561 * io should only be set if the user has used something like
561 * isapnp (the userspace program) to initialize this card for us 562 * isapnp (the userspace program) to initialize this card for us
562 */ 563 */
@@ -564,7 +565,7 @@ static int cadet_probe(void)
564static int __init cadet_init(void) 565static int __init cadet_init(void)
565{ 566{
566 spin_lock_init(&cadet_io_lock); 567 spin_lock_init(&cadet_io_lock);
567 568
568 /* 569 /*
569 * If a probe was requested then probe ISAPnP first (safest) 570 * If a probe was requested then probe ISAPnP first (safest)
570 */ 571 */
@@ -579,12 +580,12 @@ static int __init cadet_init(void)
579 /* 580 /*
580 * Else we bail out 581 * Else we bail out
581 */ 582 */
582 583
583 if(io < 0) { 584 if(io < 0) {
584#ifdef MODULE 585#ifdef MODULE
585 printk(KERN_ERR "You must set an I/O address with io=0x???\n"); 586 printk(KERN_ERR "You must set an I/O address with io=0x???\n");
586#endif 587#endif
587 goto fail; 588 goto fail;
588 } 589 }
589 if (!request_region(io,2,"cadet")) 590 if (!request_region(io,2,"cadet"))
590 goto fail; 591 goto fail;
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index 8e499b8f64c7..9f249e7e60c9 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -1,6 +1,6 @@
1/* 1/*
2 *************************************************************************** 2 ***************************************************************************
3 * 3 *
4 * radio-gemtek-pci.c - Gemtek PCI Radio driver 4 * radio-gemtek-pci.c - Gemtek PCI Radio driver
5 * (C) 2001 Vladimir Shebordaev <vshebordaev@mail.ru> 5 * (C) 2001 Vladimir Shebordaev <vshebordaev@mail.ru>
6 * 6 *
@@ -31,7 +31,7 @@
31 * radio device driver. 31 * radio device driver.
32 * 32 *
33 * Please, let me know if this piece of code was useful :) 33 * Please, let me know if this piece of code was useful :)
34 * 34 *
35 * TODO: multiple device support and portability were not tested 35 * TODO: multiple device support and portability were not tested
36 * 36 *
37 *************************************************************************** 37 ***************************************************************************
@@ -44,6 +44,7 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/pci.h> 45#include <linux/pci.h>
46#include <linux/videodev.h> 46#include <linux/videodev.h>
47#include <media/v4l2-common.h>
47#include <linux/errno.h> 48#include <linux/errno.h>
48 49
49#include <asm/io.h> 50#include <asm/io.h>
@@ -69,18 +70,18 @@
69#define TRUE (1) 70#define TRUE (1)
70#endif 71#endif
71 72
72#ifndef FALSE 73#ifndef FALSE
73#define FALSE (0) 74#define FALSE (0)
74#endif 75#endif
75 76
76struct gemtek_pci_card { 77struct gemtek_pci_card {
77 struct video_device *videodev; 78 struct video_device *videodev;
78 79
79 u32 iobase; 80 u32 iobase;
80 u32 length; 81 u32 length;
81 u8 chiprev; 82 u8 chiprev;
82 u16 model; 83 u16 model;
83 84
84 u32 current_frequency; 85 u32 current_frequency;
85 u8 mute; 86 u8 mute;
86}; 87};
@@ -96,7 +97,7 @@ static inline u8 gemtek_pci_out( u16 value, u32 port )
96 return (u8)value; 97 return (u8)value;
97} 98}
98 99
99#define _b0( v ) *((u8 *)&v) 100#define _b0( v ) *((u8 *)&v)
100static void __gemtek_pci_cmd( u16 value, u32 port, u8 *last_byte, int keep ) 101static void __gemtek_pci_cmd( u16 value, u32 port, u8 *last_byte, int keep )
101{ 102{
102 register u8 byte = *last_byte; 103 register u8 byte = *last_byte;
@@ -104,7 +105,7 @@ static void __gemtek_pci_cmd( u16 value, u32 port, u8 *last_byte, int keep )
104 if ( !value ) { 105 if ( !value ) {
105 if ( !keep ) 106 if ( !keep )
106 value = (u16)port; 107 value = (u16)port;
107 byte &= 0xfd; 108 byte &= 0xfd;
108 } else 109 } else
109 byte |= 2; 110 byte |= 2;
110 111
@@ -116,7 +117,7 @@ static void __gemtek_pci_cmd( u16 value, u32 port, u8 *last_byte, int keep )
116 byte &= 0xfe; 117 byte &= 0xfe;
117 _b0( value ) = byte; 118 _b0( value ) = byte;
118 outw( value, port ); 119 outw( value, port );
119 120
120 *last_byte = byte; 121 *last_byte = byte;
121} 122}
122 123
@@ -193,13 +194,13 @@ static int gemtek_pci_do_ioctl(struct inode *inode, struct file *file,
193 c->audios = 1; 194 c->audios = 1;
194 strcpy( c->name, "Gemtek PCI Radio" ); 195 strcpy( c->name, "Gemtek PCI Radio" );
195 return 0; 196 return 0;
196 } 197 }
197 198
198 case VIDIOCGTUNER: 199 case VIDIOCGTUNER:
199 { 200 {
200 struct video_tuner *t = arg; 201 struct video_tuner *t = arg;
201 202
202 if ( t->tuner ) 203 if ( t->tuner )
203 return -EINVAL; 204 return -EINVAL;
204 205
205 t->rangelow = GEMTEK_PCI_RANGE_LOW; 206 t->rangelow = GEMTEK_PCI_RANGE_LOW;
@@ -228,7 +229,7 @@ static int gemtek_pci_do_ioctl(struct inode *inode, struct file *file,
228 case VIDIOCSFREQ: 229 case VIDIOCSFREQ:
229 { 230 {
230 unsigned long *freq = arg; 231 unsigned long *freq = arg;
231 232
232 if ( (*freq < GEMTEK_PCI_RANGE_LOW) || 233 if ( (*freq < GEMTEK_PCI_RANGE_LOW) ||
233 (*freq > GEMTEK_PCI_RANGE_HIGH) ) 234 (*freq > GEMTEK_PCI_RANGE_HIGH) )
234 return -EINVAL; 235 return -EINVAL;
@@ -239,9 +240,9 @@ static int gemtek_pci_do_ioctl(struct inode *inode, struct file *file,
239 240
240 return 0; 241 return 0;
241 } 242 }
242 243
243 case VIDIOCGAUDIO: 244 case VIDIOCGAUDIO:
244 { 245 {
245 struct video_audio *a = arg; 246 struct video_audio *a = arg;
246 247
247 memset( a, 0, sizeof( *a ) ); 248 memset( a, 0, sizeof( *a ) );
@@ -249,17 +250,17 @@ static int gemtek_pci_do_ioctl(struct inode *inode, struct file *file,
249 a->volume = 1; 250 a->volume = 1;
250 a->step = 65535; 251 a->step = 65535;
251 strcpy( a->name, "Radio" ); 252 strcpy( a->name, "Radio" );
252 return 0; 253 return 0;
253 } 254 }
254 255
255 case VIDIOCSAUDIO: 256 case VIDIOCSAUDIO:
256 { 257 {
257 struct video_audio *a = arg; 258 struct video_audio *a = arg;
258 259
259 if ( a->audio ) 260 if ( a->audio )
260 return -EINVAL; 261 return -EINVAL;
261 262
262 if ( a->flags & VIDEO_AUDIO_MUTE ) 263 if ( a->flags & VIDEO_AUDIO_MUTE )
263 gemtek_pci_mute( card ); 264 gemtek_pci_mute( card );
264 else 265 else
265 gemtek_pci_unmute( card ); 266 gemtek_pci_unmute( card );
@@ -323,9 +324,9 @@ static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci
323 return -ENOMEM; 324 return -ENOMEM;
324 } 325 }
325 326
326 if ( pci_enable_device( pci_dev ) ) 327 if ( pci_enable_device( pci_dev ) )
327 goto err_pci; 328 goto err_pci;
328 329
329 card->iobase = pci_resource_start( pci_dev, 0 ); 330 card->iobase = pci_resource_start( pci_dev, 0 );
330 card->length = pci_resource_len( pci_dev, 0 ); 331 card->length = pci_resource_len( pci_dev, 0 );
331 332
@@ -338,7 +339,7 @@ static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci
338 pci_read_config_word( pci_dev, PCI_SUBSYSTEM_ID, &card->model ); 339 pci_read_config_word( pci_dev, PCI_SUBSYSTEM_ID, &card->model );
339 340
340 pci_set_drvdata( pci_dev, card ); 341 pci_set_drvdata( pci_dev, card );
341 342
342 if ( (devradio = kmalloc( sizeof( struct video_device ), GFP_KERNEL )) == NULL ) { 343 if ( (devradio = kmalloc( sizeof( struct video_device ), GFP_KERNEL )) == NULL ) {
343 printk( KERN_ERR "gemtek_pci: out of memory\n" ); 344 printk( KERN_ERR "gemtek_pci: out of memory\n" );
344 goto err_video; 345 goto err_video;
@@ -354,7 +355,7 @@ static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci
354 devradio->priv = card; 355 devradio->priv = card;
355 gemtek_pci_mute( card ); 356 gemtek_pci_mute( card );
356 357
357 printk( KERN_INFO "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n", 358 printk( KERN_INFO "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n",
358 card->chiprev, card->iobase, card->iobase + card->length - 1 ); 359 card->chiprev, card->iobase, card->iobase + card->length - 1 );
359 360
360 return 0; 361 return 0;
@@ -364,7 +365,7 @@ err_video:
364 365
365err_pci: 366err_pci:
366 kfree( card ); 367 kfree( card );
367 return -ENODEV; 368 return -ENODEV;
368} 369}
369 370
370static void __devexit gemtek_pci_remove( struct pci_dev *pci_dev ) 371static void __devexit gemtek_pci_remove( struct pci_dev *pci_dev )
@@ -375,12 +376,12 @@ static void __devexit gemtek_pci_remove( struct pci_dev *pci_dev )
375 kfree( card->videodev ); 376 kfree( card->videodev );
376 377
377 release_region( card->iobase, card->length ); 378 release_region( card->iobase, card->length );
378 379
379 if ( mx ) 380 if ( mx )
380 gemtek_pci_mute( card ); 381 gemtek_pci_mute( card );
381 382
382 kfree( card ); 383 kfree( card );
383 384
384 pci_set_drvdata( pci_dev, NULL ); 385 pci_set_drvdata( pci_dev, NULL );
385} 386}
386 387
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index 47173be97b9f..162f37d8bf96 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -6,7 +6,7 @@
6 * Besides the protocol changes, this is mostly a copy of: 6 * Besides the protocol changes, this is mostly a copy of:
7 * 7 *
8 * RadioTrack II driver for Linux radio support (C) 1998 Ben Pfaff 8 * RadioTrack II driver for Linux radio support (C) 1998 Ben Pfaff
9 * 9 *
10 * Based on RadioTrack I/RadioReveal (C) 1997 M. Kirkwood 10 * Based on RadioTrack I/RadioReveal (C) 1997 M. Kirkwood
11 * Converted to new API by Alan Cox <Alan.Cox@linux.org> 11 * Converted to new API by Alan Cox <Alan.Cox@linux.org>
12 * Various bugfixes and enhancements by Russell Kroll <rkroll@exploits.org> 12 * Various bugfixes and enhancements by Russell Kroll <rkroll@exploits.org>
@@ -22,6 +22,7 @@
22#include <asm/io.h> /* outb, outb_p */ 22#include <asm/io.h> /* outb, outb_p */
23#include <asm/uaccess.h> /* copy to/from user */ 23#include <asm/uaccess.h> /* copy to/from user */
24#include <linux/videodev.h> /* kernel radio structs */ 24#include <linux/videodev.h> /* kernel radio structs */
25#include <media/v4l2-common.h>
25#include <linux/config.h> /* CONFIG_RADIO_GEMTEK_PORT */ 26#include <linux/config.h> /* CONFIG_RADIO_GEMTEK_PORT */
26#include <linux/spinlock.h> 27#include <linux/spinlock.h>
27 28
@@ -29,7 +30,7 @@
29#define CONFIG_RADIO_GEMTEK_PORT -1 30#define CONFIG_RADIO_GEMTEK_PORT -1
30#endif 31#endif
31 32
32static int io = CONFIG_RADIO_GEMTEK_PORT; 33static int io = CONFIG_RADIO_GEMTEK_PORT;
33static int radio_nr = -1; 34static int radio_nr = -1;
34static spinlock_t lock; 35static spinlock_t lock;
35 36
@@ -48,7 +49,7 @@ struct gemtek_device
48 */ 49 */
49static void gemtek_mute(struct gemtek_device *dev) 50static void gemtek_mute(struct gemtek_device *dev)
50{ 51{
51 if(dev->muted) 52 if(dev->muted)
52 return; 53 return;
53 spin_lock(&lock); 54 spin_lock(&lock);
54 outb(0x10, io); 55 outb(0x10, io);
@@ -94,20 +95,20 @@ static int gemtek_setfreq(struct gemtek_device *dev, unsigned long freq)
94 freq /= 100000; 95 freq /= 100000;
95 96
96 spin_lock(&lock); 97 spin_lock(&lock);
97 98
98 /* 2 start bits */ 99 /* 2 start bits */
99 outb_p(0x03, io); 100 outb_p(0x03, io);
100 udelay(5); 101 udelay(5);
101 outb_p(0x07, io); 102 outb_p(0x07, io);
102 udelay(5); 103 udelay(5);
103 104
104 /* 28 frequency bits (lsb first) */ 105 /* 28 frequency bits (lsb first) */
105 for (i = 0; i < 14; i++) 106 for (i = 0; i < 14; i++)
106 if (freq & (1 << i)) 107 if (freq & (1 << i))
107 one(); 108 one();
108 else 109 else
109 zero(); 110 zero();
110 /* 36 unknown bits */ 111 /* 36 unknown bits */
111 for (i = 0; i < 11; i++) 112 for (i = 0; i < 11; i++)
112 zero(); 113 zero();
113 one(); 114 one();
@@ -123,7 +124,7 @@ static int gemtek_setfreq(struct gemtek_device *dev, unsigned long freq)
123 udelay(5); 124 udelay(5);
124 125
125 spin_unlock(&lock); 126 spin_unlock(&lock);
126 127
127 return 0; 128 return 0;
128} 129}
129 130
@@ -159,7 +160,7 @@ static int gemtek_do_ioctl(struct inode *inode, struct file *file,
159 case VIDIOCGTUNER: 160 case VIDIOCGTUNER:
160 { 161 {
161 struct video_tuner *v = arg; 162 struct video_tuner *v = arg;
162 if(v->tuner) /* Only 1 tuner */ 163 if(v->tuner) /* Only 1 tuner */
163 return -EINVAL; 164 return -EINVAL;
164 v->rangelow=87*16000; 165 v->rangelow=87*16000;
165 v->rangehigh=108*16000; 166 v->rangehigh=108*16000;
@@ -193,25 +194,25 @@ static int gemtek_do_ioctl(struct inode *inode, struct file *file,
193 return 0; 194 return 0;
194 } 195 }
195 case VIDIOCGAUDIO: 196 case VIDIOCGAUDIO:
196 { 197 {
197 struct video_audio *v = arg; 198 struct video_audio *v = arg;
198 memset(v,0, sizeof(*v)); 199 memset(v,0, sizeof(*v));
199 v->flags|=VIDEO_AUDIO_MUTABLE; 200 v->flags|=VIDEO_AUDIO_MUTABLE;
200 v->volume=1; 201 v->volume=1;
201 v->step=65535; 202 v->step=65535;
202 strcpy(v->name, "Radio"); 203 strcpy(v->name, "Radio");
203 return 0; 204 return 0;
204 } 205 }
205 case VIDIOCSAUDIO: 206 case VIDIOCSAUDIO:
206 { 207 {
207 struct video_audio *v = arg; 208 struct video_audio *v = arg;
208 if(v->audio) 209 if(v->audio)
209 return -EINVAL; 210 return -EINVAL;
210 211
211 if(v->flags&VIDEO_AUDIO_MUTE) 212 if(v->flags&VIDEO_AUDIO_MUTE)
212 gemtek_mute(rt); 213 gemtek_mute(rt);
213 else 214 else
214 gemtek_unmute(rt); 215 gemtek_unmute(rt);
215 216
216 return 0; 217 return 0;
217 } 218 }
@@ -254,14 +255,14 @@ static int __init gemtek_init(void)
254 return -EINVAL; 255 return -EINVAL;
255 } 256 }
256 257
257 if (!request_region(io, 4, "gemtek")) 258 if (!request_region(io, 4, "gemtek"))
258 { 259 {
259 printk(KERN_ERR "gemtek: port 0x%x already in use\n", io); 260 printk(KERN_ERR "gemtek: port 0x%x already in use\n", io);
260 return -EBUSY; 261 return -EBUSY;
261 } 262 }
262 263
263 gemtek_radio.priv=&gemtek_unit; 264 gemtek_radio.priv=&gemtek_unit;
264 265
265 if(video_register_device(&gemtek_radio, VFL_TYPE_RADIO, radio_nr)==-1) 266 if(video_register_device(&gemtek_radio, VFL_TYPE_RADIO, radio_nr)==-1)
266 { 267 {
267 release_region(io, 4); 268 release_region(io, 4);
@@ -274,7 +275,7 @@ static int __init gemtek_init(void)
274 /* this is _maybe_ unnecessary */ 275 /* this is _maybe_ unnecessary */
275 outb(0x01, io); 276 outb(0x01, io);
276 277
277 /* mute card - prevents noisy bootups */ 278 /* mute card - prevents noisy bootups */
278 gemtek_unit.muted = 0; 279 gemtek_unit.muted = 0;
279 gemtek_mute(&gemtek_unit); 280 gemtek_mute(&gemtek_unit);
280 281
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index 39c1d9118636..fcfa6c9fe225 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -2,7 +2,7 @@
2 * (c) 2000 A. Tlalka, atlka@pg.gda.pl 2 * (c) 2000 A. Tlalka, atlka@pg.gda.pl
3 * Notes on the hardware 3 * Notes on the hardware
4 * 4 *
5 * + Frequency control is done digitally 5 * + Frequency control is done digitally
6 * + No volume control - only mute/unmute - you have to use Aux line volume 6 * + No volume control - only mute/unmute - you have to use Aux line volume
7 * control on Maestro card to set the volume 7 * control on Maestro card to set the volume
8 * + Radio status (tuned/not_tuned and stereo/mono) is valid some time after 8 * + Radio status (tuned/not_tuned and stereo/mono) is valid some time after
@@ -26,7 +26,7 @@
26#include <linux/mutex.h> 26#include <linux/mutex.h>
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/videodev.h> 28#include <linux/videodev.h>
29 29#include <media/v4l2-common.h>
30 30
31#define DRIVER_VERSION "0.05" 31#define DRIVER_VERSION "0.05"
32 32
@@ -103,7 +103,7 @@ static struct video_device maestro_radio = {
103struct radio_device { 103struct radio_device {
104 u16 io, /* base of Maestro card radio io (GPIO_DATA)*/ 104 u16 io, /* base of Maestro card radio io (GPIO_DATA)*/
105 muted, /* VIDEO_AUDIO_MUTE */ 105 muted, /* VIDEO_AUDIO_MUTE */
106 stereo, /* VIDEO_TUNER_STEREO_ON */ 106 stereo, /* VIDEO_TUNER_STEREO_ON */
107 tuned; /* signal strength (0 or 0xffff) */ 107 tuned; /* signal strength (0 or 0xffff) */
108 struct mutex lock; 108 struct mutex lock;
109}; 109};
@@ -122,14 +122,14 @@ static u32 radio_bits_get(struct radio_device *dev)
122 for (l=24;l--;) { 122 for (l=24;l--;) {
123 outw(STR_CLK, io); /* HI state */ 123 outw(STR_CLK, io); /* HI state */
124 udelay(2); 124 udelay(2);
125 if(!l) 125 if(!l)
126 dev->tuned = inw(io) & STR_MOST ? 0 : 0xffff; 126 dev->tuned = inw(io) & STR_MOST ? 0 : 0xffff;
127 outw(0, io); /* LO state */ 127 outw(0, io); /* LO state */
128 udelay(2); 128 udelay(2);
129 data <<= 1; /* shift data */ 129 data <<= 1; /* shift data */
130 rdata = inw(io); 130 rdata = inw(io);
131 if(!l) 131 if(!l)
132 dev->stereo = rdata & STR_MOST ? 132 dev->stereo = rdata & STR_MOST ?
133 0 : VIDEO_TUNER_STEREO_ON; 133 0 : VIDEO_TUNER_STEREO_ON;
134 else 134 else
135 if(rdata & STR_DATA) 135 if(rdata & STR_DATA)
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index f0bf47bcb64c..f93d7afe7304 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -1,15 +1,15 @@
1/* 1/*
2 * Guillemot Maxi Radio FM 2000 PCI radio card driver for Linux 2 * Guillemot Maxi Radio FM 2000 PCI radio card driver for Linux
3 * (C) 2001 Dimitromanolakis Apostolos <apdim@grecian.net> 3 * (C) 2001 Dimitromanolakis Apostolos <apdim@grecian.net>
4 * 4 *
5 * Based in the radio Maestro PCI driver. Actually it uses the same chip 5 * Based in the radio Maestro PCI driver. Actually it uses the same chip
6 * for radio but different pci controller. 6 * for radio but different pci controller.
7 * 7 *
8 * I didn't have any specs I reversed engineered the protocol from 8 * I didn't have any specs I reversed engineered the protocol from
9 * the windows driver (radio.dll). 9 * the windows driver (radio.dll).
10 * 10 *
11 * The card uses the TEA5757 chip that includes a search function but it 11 * The card uses the TEA5757 chip that includes a search function but it
12 * is useless as I haven't found any way to read back the frequency. If 12 * is useless as I haven't found any way to read back the frequency. If
13 * anybody does please mail me. 13 * anybody does please mail me.
14 * 14 *
15 * For the pdf file see: 15 * For the pdf file see:
@@ -24,7 +24,7 @@
24 * - tiding up 24 * - tiding up
25 * - removed support for multiple devices as it didn't work anyway 25 * - removed support for multiple devices as it didn't work anyway
26 * 26 *
27 * BUGS: 27 * BUGS:
28 * - card unmutes if you change frequency 28 * - card unmutes if you change frequency
29 * 29 *
30 */ 30 */
@@ -41,6 +41,7 @@
41 41
42#include <linux/pci.h> 42#include <linux/pci.h>
43#include <linux/videodev.h> 43#include <linux/videodev.h>
44#include <media/v4l2-common.h>
44 45
45/* version 0.75 Sun Feb 4 22:51:27 EET 2001 */ 46/* version 0.75 Sun Feb 4 22:51:27 EET 2001 */
46#define DRIVER_VERSION "0.75" 47#define DRIVER_VERSION "0.75"
@@ -80,7 +81,7 @@ static struct file_operations maxiradio_fops = {
80 .owner = THIS_MODULE, 81 .owner = THIS_MODULE,
81 .open = video_exclusive_open, 82 .open = video_exclusive_open,
82 .release = video_exclusive_release, 83 .release = video_exclusive_release,
83 .ioctl = radio_ioctl, 84 .ioctl = radio_ioctl,
84 .compat_ioctl = v4l_compat_ioctl32, 85 .compat_ioctl = v4l_compat_ioctl32,
85 .llseek = no_llseek, 86 .llseek = no_llseek,
86}; 87};
@@ -97,11 +98,11 @@ static struct radio_device
97{ 98{
98 __u16 io, /* base of radio io */ 99 __u16 io, /* base of radio io */
99 muted, /* VIDEO_AUDIO_MUTE */ 100 muted, /* VIDEO_AUDIO_MUTE */
100 stereo, /* VIDEO_TUNER_STEREO_ON */ 101 stereo, /* VIDEO_TUNER_STEREO_ON */
101 tuned; /* signal strength (0 or 0xffff) */ 102 tuned; /* signal strength (0 or 0xffff) */
102 103
103 unsigned long freq; 104 unsigned long freq;
104 105
105 struct mutex lock; 106 struct mutex lock;
106} radio_unit = {0, 0, 0, 0, }; 107} radio_unit = {0, 0, 0, 0, };
107 108
@@ -114,7 +115,7 @@ static void outbit(unsigned long bit, __u16 io)
114 outb( power|wren|data|clk ,io); udelay(4); 115 outb( power|wren|data|clk ,io); udelay(4);
115 outb( power|wren|data ,io); udelay(4); 116 outb( power|wren|data ,io); udelay(4);
116 } 117 }
117 else 118 else
118 { 119 {
119 outb( power|wren ,io); udelay(4); 120 outb( power|wren ,io); udelay(4);
120 outb( power|wren|clk ,io); udelay(4); 121 outb( power|wren|clk ,io); udelay(4);
@@ -132,12 +133,12 @@ static void set_freq(__u16 io, __u32 data)
132{ 133{
133 unsigned long int si; 134 unsigned long int si;
134 int bl; 135 int bl;
135 136
136 /* TEA5757 shift register bits (see pdf) */ 137 /* TEA5757 shift register bits (see pdf) */
137 138
138 outbit(0,io); // 24 search 139 outbit(0,io); // 24 search
139 outbit(1,io); // 23 search up/down 140 outbit(1,io); // 23 search up/down
140 141
141 outbit(0,io); // 22 stereo/mono 142 outbit(0,io); // 22 stereo/mono
142 143
143 outbit(0,io); // 21 band 144 outbit(0,io); // 21 band
@@ -145,24 +146,24 @@ static void set_freq(__u16 io, __u32 data)
145 146
146 outbit(0,io); // 19 port ? 147 outbit(0,io); // 19 port ?
147 outbit(0,io); // 18 port ? 148 outbit(0,io); // 18 port ?
148 149
149 outbit(0,io); // 17 search level 150 outbit(0,io); // 17 search level
150 outbit(0,io); // 16 search level 151 outbit(0,io); // 16 search level
151 152
152 si = 0x8000; 153 si = 0x8000;
153 for(bl = 1; bl <= 16 ; bl++) { outbit(data & si,io); si >>=1; } 154 for(bl = 1; bl <= 16 ; bl++) { outbit(data & si,io); si >>=1; }
154 155
155 outb(power,io); 156 outb(power,io);
156} 157}
157 158
158static int get_stereo(__u16 io) 159static int get_stereo(__u16 io)
159{ 160{
160 outb(power,io); udelay(4); 161 outb(power,io); udelay(4);
161 return !(inb(io) & mo_st); 162 return !(inb(io) & mo_st);
162} 163}
163 164
164static int get_tune(__u16 io) 165static int get_tune(__u16 io)
165{ 166{
166 outb(power+clk,io); udelay(4); 167 outb(power+clk,io); udelay(4);
167 return !(inb(io) & mo_st); 168 return !(inb(io) & mo_st);
168} 169}
@@ -177,7 +178,7 @@ static inline int radio_function(struct inode *inode, struct file *file,
177 switch(cmd) { 178 switch(cmd) {
178 case VIDIOCGCAP: { 179 case VIDIOCGCAP: {
179 struct video_capability *v = arg; 180 struct video_capability *v = arg;
180 181
181 memset(v,0,sizeof(*v)); 182 memset(v,0,sizeof(*v));
182 strcpy(v->name, "Maxi Radio FM2000 radio"); 183 strcpy(v->name, "Maxi Radio FM2000 radio");
183 v->type=VID_TYPE_TUNER; 184 v->type=VID_TYPE_TUNER;
@@ -186,22 +187,22 @@ static inline int radio_function(struct inode *inode, struct file *file,
186 } 187 }
187 case VIDIOCGTUNER: { 188 case VIDIOCGTUNER: {
188 struct video_tuner *v = arg; 189 struct video_tuner *v = arg;
189 190
190 if(v->tuner) 191 if(v->tuner)
191 return -EINVAL; 192 return -EINVAL;
192 193
193 card->stereo = 0xffff * get_stereo(card->io); 194 card->stereo = 0xffff * get_stereo(card->io);
194 card->tuned = 0xffff * get_tune(card->io); 195 card->tuned = 0xffff * get_tune(card->io);
195 196
196 v->flags = VIDEO_TUNER_LOW | card->stereo; 197 v->flags = VIDEO_TUNER_LOW | card->stereo;
197 v->signal = card->tuned; 198 v->signal = card->tuned;
198 199
199 strcpy(v->name, "FM"); 200 strcpy(v->name, "FM");
200 201
201 v->rangelow = FREQ_LO; 202 v->rangelow = FREQ_LO;
202 v->rangehigh = FREQ_HI; 203 v->rangehigh = FREQ_HI;
203 v->mode = VIDEO_MODE_AUTO; 204 v->mode = VIDEO_MODE_AUTO;
204 205
205 return 0; 206 return 0;
206 } 207 }
207 case VIDIOCSTUNER: { 208 case VIDIOCSTUNER: {
@@ -212,13 +213,13 @@ static inline int radio_function(struct inode *inode, struct file *file,
212 } 213 }
213 case VIDIOCGFREQ: { 214 case VIDIOCGFREQ: {
214 unsigned long *freq = arg; 215 unsigned long *freq = arg;
215 216
216 *freq = card->freq; 217 *freq = card->freq;
217 return 0; 218 return 0;
218 } 219 }
219 case VIDIOCSFREQ: { 220 case VIDIOCSFREQ: {
220 unsigned long *freq = arg; 221 unsigned long *freq = arg;
221 222
222 if (*freq < FREQ_LO || *freq > FREQ_HI) 223 if (*freq < FREQ_LO || *freq > FREQ_HI)
223 return -EINVAL; 224 return -EINVAL;
224 card->freq = *freq; 225 card->freq = *freq;
@@ -226,18 +227,18 @@ static inline int radio_function(struct inode *inode, struct file *file,
226 msleep(125); 227 msleep(125);
227 return 0; 228 return 0;
228 } 229 }
229 case VIDIOCGAUDIO: { 230 case VIDIOCGAUDIO: {
230 struct video_audio *v = arg; 231 struct video_audio *v = arg;
231 memset(v,0,sizeof(*v)); 232 memset(v,0,sizeof(*v));
232 strcpy(v->name, "Radio"); 233 strcpy(v->name, "Radio");
233 v->flags=VIDEO_AUDIO_MUTABLE | card->muted; 234 v->flags=VIDEO_AUDIO_MUTABLE | card->muted;
234 v->mode=VIDEO_SOUND_STEREO; 235 v->mode=VIDEO_SOUND_STEREO;
235 return 0; 236 return 0;
236 } 237 }
237 238
238 case VIDIOCSAUDIO: { 239 case VIDIOCSAUDIO: {
239 struct video_audio *v = arg; 240 struct video_audio *v = arg;
240 241
241 if(v->audio) 242 if(v->audio)
242 return -EINVAL; 243 return -EINVAL;
243 card->muted = v->flags & VIDEO_AUDIO_MUTE; 244 card->muted = v->flags & VIDEO_AUDIO_MUTE;
@@ -249,13 +250,13 @@ static inline int radio_function(struct inode *inode, struct file *file,
249 } 250 }
250 case VIDIOCGUNIT: { 251 case VIDIOCGUNIT: {
251 struct video_unit *v = arg; 252 struct video_unit *v = arg;
252 253
253 v->video=VIDEO_NO_UNIT; 254 v->video=VIDEO_NO_UNIT;
254 v->vbi=VIDEO_NO_UNIT; 255 v->vbi=VIDEO_NO_UNIT;
255 v->radio=dev->minor; 256 v->radio=dev->minor;
256 v->audio=0; 257 v->audio=0;
257 v->teletext=VIDEO_NO_UNIT; 258 v->teletext=VIDEO_NO_UNIT;
258 return 0; 259 return 0;
259 } 260 }
260 default: return -ENOIOCTLCMD; 261 default: return -ENOIOCTLCMD;
261 } 262 }
@@ -267,7 +268,7 @@ static int radio_ioctl(struct inode *inode, struct file *file,
267 struct video_device *dev = video_devdata(file); 268 struct video_device *dev = video_devdata(file);
268 struct radio_device *card=dev->priv; 269 struct radio_device *card=dev->priv;
269 int ret; 270 int ret;
270 271
271 mutex_lock(&card->lock); 272 mutex_lock(&card->lock);
272 ret = video_usercopy(inode, file, cmd, arg, radio_function); 273 ret = video_usercopy(inode, file, cmd, arg, radio_function);
273 mutex_unlock(&card->lock); 274 mutex_unlock(&card->lock);
@@ -282,21 +283,21 @@ MODULE_LICENSE("GPL");
282static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 283static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
283{ 284{
284 if(!request_region(pci_resource_start(pdev, 0), 285 if(!request_region(pci_resource_start(pdev, 0),
285 pci_resource_len(pdev, 0), "Maxi Radio FM 2000")) { 286 pci_resource_len(pdev, 0), "Maxi Radio FM 2000")) {
286 printk(KERN_ERR "radio-maxiradio: can't reserve I/O ports\n"); 287 printk(KERN_ERR "radio-maxiradio: can't reserve I/O ports\n");
287 goto err_out; 288 goto err_out;
288 } 289 }
289 290
290 if (pci_enable_device(pdev)) 291 if (pci_enable_device(pdev))
291 goto err_out_free_region; 292 goto err_out_free_region;
292 293
293 radio_unit.io = pci_resource_start(pdev, 0); 294 radio_unit.io = pci_resource_start(pdev, 0);
294 mutex_init(&radio_unit.lock); 295 mutex_init(&radio_unit.lock);
295 maxiradio_radio.priv = &radio_unit; 296 maxiradio_radio.priv = &radio_unit;
296 297
297 if(video_register_device(&maxiradio_radio, VFL_TYPE_RADIO, radio_nr)==-1) { 298 if(video_register_device(&maxiradio_radio, VFL_TYPE_RADIO, radio_nr)==-1) {
298 printk("radio-maxiradio: can't register device!"); 299 printk("radio-maxiradio: can't register device!");
299 goto err_out_free_region; 300 goto err_out_free_region;
300 } 301 }
301 302
302 printk(KERN_INFO "radio-maxiradio: version " 303 printk(KERN_INFO "radio-maxiradio: version "
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index 28a47c9e7a81..5b68ac4c7322 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -1,5 +1,5 @@
1/* RadioTrack II driver for Linux radio support (C) 1998 Ben Pfaff 1/* RadioTrack II driver for Linux radio support (C) 1998 Ben Pfaff
2 * 2 *
3 * Based on RadioTrack I/RadioReveal (C) 1997 M. Kirkwood 3 * Based on RadioTrack I/RadioReveal (C) 1997 M. Kirkwood
4 * Converted to new API by Alan Cox <Alan.Cox@linux.org> 4 * Converted to new API by Alan Cox <Alan.Cox@linux.org>
5 * Various bugfixes and enhancements by Russell Kroll <rkroll@exploits.org> 5 * Various bugfixes and enhancements by Russell Kroll <rkroll@exploits.org>
@@ -15,6 +15,7 @@
15#include <asm/io.h> /* outb, outb_p */ 15#include <asm/io.h> /* outb, outb_p */
16#include <asm/uaccess.h> /* copy to/from user */ 16#include <asm/uaccess.h> /* copy to/from user */
17#include <linux/videodev.h> /* kernel radio structs */ 17#include <linux/videodev.h> /* kernel radio structs */
18#include <media/v4l2-common.h>
18#include <linux/config.h> /* CONFIG_RADIO_RTRACK2_PORT */ 19#include <linux/config.h> /* CONFIG_RADIO_RTRACK2_PORT */
19#include <linux/spinlock.h> 20#include <linux/spinlock.h>
20 21
@@ -22,7 +23,7 @@
22#define CONFIG_RADIO_RTRACK2_PORT -1 23#define CONFIG_RADIO_RTRACK2_PORT -1
23#endif 24#endif
24 25
25static int io = CONFIG_RADIO_RTRACK2_PORT; 26static int io = CONFIG_RADIO_RTRACK2_PORT;
26static int radio_nr = -1; 27static int radio_nr = -1;
27static spinlock_t lock; 28static spinlock_t lock;
28 29
@@ -38,7 +39,7 @@ struct rt_device
38 39
39static void rt_mute(struct rt_device *dev) 40static void rt_mute(struct rt_device *dev)
40{ 41{
41 if(dev->muted) 42 if(dev->muted)
42 return; 43 return;
43 spin_lock(&lock); 44 spin_lock(&lock);
44 outb(1, io); 45 outb(1, io);
@@ -58,14 +59,14 @@ static void rt_unmute(struct rt_device *dev)
58 59
59static void zero(void) 60static void zero(void)
60{ 61{
61 outb_p(1, io); 62 outb_p(1, io);
62 outb_p(3, io); 63 outb_p(3, io);
63 outb_p(1, io); 64 outb_p(1, io);
64} 65}
65 66
66static void one(void) 67static void one(void)
67{ 68{
68 outb_p(5, io); 69 outb_p(5, io);
69 outb_p(7, io); 70 outb_p(7, io);
70 outb_p(5, io); 71 outb_p(5, io);
71} 72}
@@ -75,7 +76,7 @@ static int rt_setfreq(struct rt_device *dev, unsigned long freq)
75 int i; 76 int i;
76 77
77 freq = freq / 200 + 856; 78 freq = freq / 200 + 856;
78 79
79 spin_lock(&lock); 80 spin_lock(&lock);
80 81
81 outb_p(0xc8, io); 82 outb_p(0xc8, io);
@@ -94,7 +95,7 @@ static int rt_setfreq(struct rt_device *dev, unsigned long freq)
94 outb_p(0xc8, io); 95 outb_p(0xc8, io);
95 if (!dev->muted) 96 if (!dev->muted)
96 outb_p(0, io); 97 outb_p(0, io);
97 98
98 spin_unlock(&lock); 99 spin_unlock(&lock);
99 return 0; 100 return 0;
100} 101}
@@ -127,7 +128,7 @@ static int rt_do_ioctl(struct inode *inode, struct file *file,
127 case VIDIOCGTUNER: 128 case VIDIOCGTUNER:
128 { 129 {
129 struct video_tuner *v = arg; 130 struct video_tuner *v = arg;
130 if(v->tuner) /* Only 1 tuner */ 131 if(v->tuner) /* Only 1 tuner */
131 return -EINVAL; 132 return -EINVAL;
132 v->rangelow=88*16000; 133 v->rangelow=88*16000;
133 v->rangehigh=108*16000; 134 v->rangehigh=108*16000;
@@ -159,25 +160,25 @@ static int rt_do_ioctl(struct inode *inode, struct file *file,
159 return 0; 160 return 0;
160 } 161 }
161 case VIDIOCGAUDIO: 162 case VIDIOCGAUDIO:
162 { 163 {
163 struct video_audio *v = arg; 164 struct video_audio *v = arg;
164 memset(v,0, sizeof(*v)); 165 memset(v,0, sizeof(*v));
165 v->flags|=VIDEO_AUDIO_MUTABLE; 166 v->flags|=VIDEO_AUDIO_MUTABLE;
166 v->volume=1; 167 v->volume=1;
167 v->step=65535; 168 v->step=65535;
168 strcpy(v->name, "Radio"); 169 strcpy(v->name, "Radio");
169 return 0; 170 return 0;
170 } 171 }
171 case VIDIOCSAUDIO: 172 case VIDIOCSAUDIO:
172 { 173 {
173 struct video_audio *v = arg; 174 struct video_audio *v = arg;
174 if(v->audio) 175 if(v->audio)
175 return -EINVAL; 176 return -EINVAL;
176 177
177 if(v->flags&VIDEO_AUDIO_MUTE) 178 if(v->flags&VIDEO_AUDIO_MUTE)
178 rt_mute(rt); 179 rt_mute(rt);
179 else 180 else
180 rt_unmute(rt); 181 rt_unmute(rt);
181 182
182 return 0; 183 return 0;
183 } 184 }
@@ -219,7 +220,7 @@ static int __init rtrack2_init(void)
219 printk(KERN_ERR "You must set an I/O address with io=0x20c or io=0x30c\n"); 220 printk(KERN_ERR "You must set an I/O address with io=0x20c or io=0x30c\n");
220 return -EINVAL; 221 return -EINVAL;
221 } 222 }
222 if (!request_region(io, 4, "rtrack2")) 223 if (!request_region(io, 4, "rtrack2"))
223 { 224 {
224 printk(KERN_ERR "rtrack2: port 0x%x already in use\n", io); 225 printk(KERN_ERR "rtrack2: port 0x%x already in use\n", io);
225 return -EBUSY; 226 return -EBUSY;
@@ -227,16 +228,16 @@ static int __init rtrack2_init(void)
227 228
228 rtrack2_radio.priv=&rtrack2_unit; 229 rtrack2_radio.priv=&rtrack2_unit;
229 230
230 spin_lock_init(&lock); 231 spin_lock_init(&lock);
231 if(video_register_device(&rtrack2_radio, VFL_TYPE_RADIO, radio_nr)==-1) 232 if(video_register_device(&rtrack2_radio, VFL_TYPE_RADIO, radio_nr)==-1)
232 { 233 {
233 release_region(io, 4); 234 release_region(io, 4);
234 return -EINVAL; 235 return -EINVAL;
235 } 236 }
236 237
237 printk(KERN_INFO "AIMSlab Radiotrack II card driver.\n"); 238 printk(KERN_INFO "AIMSlab Radiotrack II card driver.\n");
238 239
239 /* mute card - prevents noisy bootups */ 240 /* mute card - prevents noisy bootups */
240 outb(1, io); 241 outb(1, io);
241 rtrack2_unit.muted = 1; 242 rtrack2_unit.muted = 1;
242 243
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 53073b424107..efee6e339d15 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -12,7 +12,7 @@
12 * Frequency control is done digitally -- ie out(port,encodefreq(95.8)); 12 * Frequency control is done digitally -- ie out(port,encodefreq(95.8));
13 * No volume control - only mute/unmute - you have to use line volume 13 * No volume control - only mute/unmute - you have to use line volume
14 * control on SB-part of SF16FMI 14 * control on SB-part of SF16FMI
15 * 15 *
16 */ 16 */
17 17
18#include <linux/kernel.h> /* __setup */ 18#include <linux/kernel.h> /* __setup */
@@ -21,6 +21,7 @@
21#include <linux/ioport.h> /* request_region */ 21#include <linux/ioport.h> /* request_region */
22#include <linux/delay.h> /* udelay */ 22#include <linux/delay.h> /* udelay */
23#include <linux/videodev.h> /* kernel radio structs */ 23#include <linux/videodev.h> /* kernel radio structs */
24#include <media/v4l2-common.h>
24#include <linux/isapnp.h> 25#include <linux/isapnp.h>
25#include <asm/io.h> /* outb, outb_p */ 26#include <asm/io.h> /* outb, outb_p */
26#include <asm/uaccess.h> /* copy to/from user */ 27#include <asm/uaccess.h> /* copy to/from user */
@@ -29,19 +30,19 @@
29struct fmi_device 30struct fmi_device
30{ 31{
31 int port; 32 int port;
32 int curvol; /* 1 or 0 */ 33 int curvol; /* 1 or 0 */
33 unsigned long curfreq; /* freq in kHz */ 34 unsigned long curfreq; /* freq in kHz */
34 __u32 flags; 35 __u32 flags;
35}; 36};
36 37
37static int io = -1; 38static int io = -1;
38static int radio_nr = -1; 39static int radio_nr = -1;
39static struct pnp_dev *dev = NULL; 40static struct pnp_dev *dev = NULL;
40static struct mutex lock; 41static struct mutex lock;
41 42
42/* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */ 43/* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */
43/* It is only useful to give freq in intervall of 800 (=0.05Mhz), 44/* It is only useful to give freq in intervall of 800 (=0.05Mhz),
44 * other bits will be truncated, e.g 92.7400016 -> 92.7, but 45 * other bits will be truncated, e.g 92.7400016 -> 92.7, but
45 * 92.7400017 -> 92.75 46 * 92.7400017 -> 92.75
46 */ 47 */
47#define RSF16_ENCODE(x) ((x)/800+214) 48#define RSF16_ENCODE(x) ((x)/800+214)
@@ -51,7 +52,7 @@ static struct mutex lock;
51static void outbits(int bits, unsigned int data, int port) 52static void outbits(int bits, unsigned int data, int port)
52{ 53{
53 while(bits--) { 54 while(bits--) {
54 if(data & 1) { 55 if(data & 1) {
55 outb(5, port); 56 outb(5, port);
56 udelay(6); 57 udelay(6);
57 outb(7, port); 58 outb(7, port);
@@ -101,7 +102,7 @@ static inline int fmi_getsigstr(struct fmi_device *dev)
101 int res; 102 int res;
102 int myport = dev->port; 103 int myport = dev->port;
103 104
104 105
105 mutex_lock(&lock); 106 mutex_lock(&lock);
106 val = dev->curvol ? 0x08 : 0x00; /* unmute/mute */ 107 val = dev->curvol ? 0x08 : 0x00; /* unmute/mute */
107 outb(val, myport); 108 outb(val, myport);
@@ -109,7 +110,7 @@ static inline int fmi_getsigstr(struct fmi_device *dev)
109 msleep(143); /* was schedule_timeout(HZ/7) */ 110 msleep(143); /* was schedule_timeout(HZ/7) */
110 res = (int)inb(myport+1); 111 res = (int)inb(myport+1);
111 outb(val, myport); 112 outb(val, myport);
112 113
113 mutex_unlock(&lock); 114 mutex_unlock(&lock);
114 return (res & 2) ? 0 : 0xFFFF; 115 return (res & 2) ? 0 : 0xFFFF;
115} 116}
@@ -119,7 +120,7 @@ static int fmi_do_ioctl(struct inode *inode, struct file *file,
119{ 120{
120 struct video_device *dev = video_devdata(file); 121 struct video_device *dev = video_devdata(file);
121 struct fmi_device *fmi=dev->priv; 122 struct fmi_device *fmi=dev->priv;
122 123
123 switch(cmd) 124 switch(cmd)
124 { 125 {
125 case VIDIOCGCAP: 126 case VIDIOCGCAP:
@@ -174,18 +175,18 @@ static int fmi_do_ioctl(struct inode *inode, struct file *file,
174 return -EINVAL; 175 return -EINVAL;
175 /*rounding in steps of 800 to match th freq 176 /*rounding in steps of 800 to match th freq
176 that will be used */ 177 that will be used */
177 fmi->curfreq = (*freq/800)*800; 178 fmi->curfreq = (*freq/800)*800;
178 fmi_setfreq(fmi); 179 fmi_setfreq(fmi);
179 return 0; 180 return 0;
180 } 181 }
181 case VIDIOCGAUDIO: 182 case VIDIOCGAUDIO:
182 { 183 {
183 struct video_audio *v = arg; 184 struct video_audio *v = arg;
184 memset(v,0,sizeof(*v)); 185 memset(v,0,sizeof(*v));
185 v->flags=( (!fmi->curvol)*VIDEO_AUDIO_MUTE | VIDEO_AUDIO_MUTABLE); 186 v->flags=( (!fmi->curvol)*VIDEO_AUDIO_MUTE | VIDEO_AUDIO_MUTABLE);
186 strcpy(v->name, "Radio"); 187 strcpy(v->name, "Radio");
187 v->mode=VIDEO_SOUND_STEREO; 188 v->mode=VIDEO_SOUND_STEREO;
188 return 0; 189 return 0;
189 } 190 }
190 case VIDIOCSAUDIO: 191 case VIDIOCSAUDIO:
191 { 192 {
@@ -193,19 +194,19 @@ static int fmi_do_ioctl(struct inode *inode, struct file *file,
193 if(v->audio) 194 if(v->audio)
194 return -EINVAL; 195 return -EINVAL;
195 fmi->curvol= v->flags&VIDEO_AUDIO_MUTE ? 0 : 1; 196 fmi->curvol= v->flags&VIDEO_AUDIO_MUTE ? 0 : 1;
196 fmi->curvol ? 197 fmi->curvol ?
197 fmi_unmute(fmi->port) : fmi_mute(fmi->port); 198 fmi_unmute(fmi->port) : fmi_mute(fmi->port);
198 return 0; 199 return 0;
199 } 200 }
200 case VIDIOCGUNIT: 201 case VIDIOCGUNIT:
201 { 202 {
202 struct video_unit *v = arg; 203 struct video_unit *v = arg;
203 v->video=VIDEO_NO_UNIT; 204 v->video=VIDEO_NO_UNIT;
204 v->vbi=VIDEO_NO_UNIT; 205 v->vbi=VIDEO_NO_UNIT;
205 v->radio=dev->minor; 206 v->radio=dev->minor;
206 v->audio=0; /* How do we find out this??? */ 207 v->audio=0; /* How do we find out this??? */
207 v->teletext=VIDEO_NO_UNIT; 208 v->teletext=VIDEO_NO_UNIT;
208 return 0; 209 return 0;
209 } 210 }
210 default: 211 default:
211 return -ENOIOCTLCMD; 212 return -ENOIOCTLCMD;
@@ -295,14 +296,14 @@ static int __init fmi_init(void)
295 fmi_unit.curfreq = 0; 296 fmi_unit.curfreq = 0;
296 fmi_unit.flags = VIDEO_TUNER_LOW; 297 fmi_unit.flags = VIDEO_TUNER_LOW;
297 fmi_radio.priv = &fmi_unit; 298 fmi_radio.priv = &fmi_unit;
298 299
299 mutex_init(&lock); 300 mutex_init(&lock);
300 301
301 if (video_register_device(&fmi_radio, VFL_TYPE_RADIO, radio_nr) == -1) { 302 if (video_register_device(&fmi_radio, VFL_TYPE_RADIO, radio_nr) == -1) {
302 release_region(io, 2); 303 release_region(io, 2);
303 return -EINVAL; 304 return -EINVAL;
304 } 305 }
305 306
306 printk(KERN_INFO "SF16FMx radio card driver at 0x%x\n", io); 307 printk(KERN_INFO "SF16FMx radio card driver at 0x%x\n", io);
307 /* mute card - prevents noisy bootups */ 308 /* mute card - prevents noisy bootups */
308 fmi_mute(io); 309 fmi_mute(io);
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index bcebd8cb19ad..3483b2c7bc9d 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -19,6 +19,7 @@
19#include <asm/io.h> /* outb, outb_p */ 19#include <asm/io.h> /* outb, outb_p */
20#include <asm/uaccess.h> /* copy to/from user */ 20#include <asm/uaccess.h> /* copy to/from user */
21#include <linux/videodev.h> /* kernel radio structs */ 21#include <linux/videodev.h> /* kernel radio structs */
22#include <media/v4l2-common.h>
22#include <linux/mutex.h> 23#include <linux/mutex.h>
23 24
24static struct mutex lock; 25static struct mutex lock;
@@ -202,7 +203,7 @@ static int fmr2_setvolume(struct fmr2_device *dev)
202} 203}
203 204
204static int fmr2_do_ioctl(struct inode *inode, struct file *file, 205static int fmr2_do_ioctl(struct inode *inode, struct file *file,
205 unsigned int cmd, void *arg) 206 unsigned int cmd, void *arg)
206{ 207{
207 struct video_device *dev = video_devdata(file); 208 struct video_device *dev = video_devdata(file);
208 struct fmr2_device *fmr2 = dev->priv; 209 struct fmr2_device *fmr2 = dev->priv;
@@ -344,7 +345,7 @@ static int fmr2_do_ioctl(struct inode *inode, struct file *file,
344} 345}
345 346
346static int fmr2_ioctl(struct inode *inode, struct file *file, 347static int fmr2_ioctl(struct inode *inode, struct file *file,
347 unsigned int cmd, unsigned long arg) 348 unsigned int cmd, unsigned long arg)
348 { 349 {
349 return video_usercopy(inode, file, cmd, arg, fmr2_do_ioctl); 350 return video_usercopy(inode, file, cmd, arg, fmr2_do_ioctl);
350} 351}
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
index fcfde2e4f195..dfba4ae596cd 100644
--- a/drivers/media/radio/radio-terratec.c
+++ b/drivers/media/radio/radio-terratec.c
@@ -2,11 +2,11 @@
2 * (c) 1999 R. Offermanns (rolf@offermanns.de) 2 * (c) 1999 R. Offermanns (rolf@offermanns.de)
3 * based on the aimslab radio driver from M. Kirkwood 3 * based on the aimslab radio driver from M. Kirkwood
4 * many thanks to Michael Becker and Friedhelm Birth (from TerraTec) 4 * many thanks to Michael Becker and Friedhelm Birth (from TerraTec)
5 * 5 *
6 * 6 *
7 * History: 7 * History:
8 * 1999-05-21 First preview release 8 * 1999-05-21 First preview release
9 * 9 *
10 * Notes on the hardware: 10 * Notes on the hardware:
11 * There are two "main" chips on the card: 11 * There are two "main" chips on the card:
12 * - Philips OM5610 (http://www-us.semiconductors.philips.com/acrobat/datasheets/OM5610_2.pdf) 12 * - Philips OM5610 (http://www-us.semiconductors.philips.com/acrobat/datasheets/OM5610_2.pdf)
@@ -20,7 +20,7 @@
20 * (as soon i have understand how to get started :) 20 * (as soon i have understand how to get started :)
21 * If you can help me out with that, please contact me!! 21 * If you can help me out with that, please contact me!!
22 * 22 *
23 * 23 *
24 */ 24 */
25 25
26#include <linux/module.h> /* Modules */ 26#include <linux/module.h> /* Modules */
@@ -30,6 +30,7 @@
30#include <asm/io.h> /* outb, outb_p */ 30#include <asm/io.h> /* outb, outb_p */
31#include <asm/uaccess.h> /* copy to/from user */ 31#include <asm/uaccess.h> /* copy to/from user */
32#include <linux/videodev.h> /* kernel radio structs */ 32#include <linux/videodev.h> /* kernel radio structs */
33#include <media/v4l2-common.h>
33#include <linux/config.h> /* CONFIG_RADIO_TERRATEC_PORT */ 34#include <linux/config.h> /* CONFIG_RADIO_TERRATEC_PORT */
34#include <linux/spinlock.h> 35#include <linux/spinlock.h>
35 36
@@ -49,7 +50,7 @@
49#define WRT_EN 0x10 50#define WRT_EN 0x10
50/*******************************************************************/ 51/*******************************************************************/
51 52
52static int io = CONFIG_RADIO_TERRATEC_PORT; 53static int io = CONFIG_RADIO_TERRATEC_PORT;
53static int radio_nr = -1; 54static int radio_nr = -1;
54static spinlock_t lock; 55static spinlock_t lock;
55 56
@@ -88,15 +89,15 @@ static void tt_mute(struct tt_device *dev)
88 89
89static int tt_setvol(struct tt_device *dev, int vol) 90static int tt_setvol(struct tt_device *dev, int vol)
90{ 91{
91 92
92// printk(KERN_ERR "setvol called, vol = %d\n", vol); 93// printk(KERN_ERR "setvol called, vol = %d\n", vol);
93 94
94 if(vol == dev->curvol) { /* requested volume = current */ 95 if(vol == dev->curvol) { /* requested volume = current */
95 if (dev->muted) { /* user is unmuting the card */ 96 if (dev->muted) { /* user is unmuting the card */
96 dev->muted = 0; 97 dev->muted = 0;
97 cardWriteVol(vol); /* enable card */ 98 cardWriteVol(vol); /* enable card */
98 } 99 }
99 100
100 return 0; 101 return 0;
101 } 102 }
102 103
@@ -107,9 +108,9 @@ static int tt_setvol(struct tt_device *dev, int vol)
107 } 108 }
108 109
109 dev->muted = 0; 110 dev->muted = 0;
110 111
111 cardWriteVol(vol); 112 cardWriteVol(vol);
112 113
113 dev->curvol = vol; 114 dev->curvol = vol;
114 115
115 return 0; 116 return 0;
@@ -121,13 +122,13 @@ static int tt_setvol(struct tt_device *dev, int vol)
121/* many more or less strange things are going on here, but hey, it works :) */ 122/* many more or less strange things are going on here, but hey, it works :) */
122 123
123static int tt_setfreq(struct tt_device *dev, unsigned long freq1) 124static int tt_setfreq(struct tt_device *dev, unsigned long freq1)
124{ 125{
125 int freq; 126 int freq;
126 int i; 127 int i;
127 int p; 128 int p;
128 int temp; 129 int temp;
129 long rest; 130 long rest;
130 131
131 unsigned char buffer[25]; /* we have to bit shift 25 registers */ 132 unsigned char buffer[25]; /* we have to bit shift 25 registers */
132 freq = freq1/160; /* convert the freq. to a nice to handle value */ 133 freq = freq1/160; /* convert the freq. to a nice to handle value */
133 for(i=24;i>-1;i--) 134 for(i=24;i>-1;i--)
@@ -142,9 +143,9 @@ static int tt_setfreq(struct tt_device *dev, unsigned long freq1)
142 { 143 {
143 if (rest%temp == rest) 144 if (rest%temp == rest)
144 buffer[i] = 0; 145 buffer[i] = 0;
145 else 146 else
146 { 147 {
147 buffer[i] = 1; 148 buffer[i] = 1;
148 rest = rest-temp; 149 rest = rest-temp;
149 } 150 }
150 i--; 151 i--;
@@ -153,10 +154,10 @@ static int tt_setfreq(struct tt_device *dev, unsigned long freq1)
153 } 154 }
154 155
155 spin_lock(&lock); 156 spin_lock(&lock);
156 157
157 for (i=24;i>-1;i--) /* bit shift the values to the radiocard */ 158 for (i=24;i>-1;i--) /* bit shift the values to the radiocard */
158 { 159 {
159 if (buffer[i]==1) 160 if (buffer[i]==1)
160 { 161 {
161 outb(WRT_EN|DATA, BASEPORT); 162 outb(WRT_EN|DATA, BASEPORT);
162 outb(WRT_EN|DATA|CLK_ON , BASEPORT); 163 outb(WRT_EN|DATA|CLK_ON , BASEPORT);
@@ -168,11 +169,11 @@ static int tt_setfreq(struct tt_device *dev, unsigned long freq1)
168 outb(WRT_EN|0x00|CLK_ON , BASEPORT); 169 outb(WRT_EN|0x00|CLK_ON , BASEPORT);
169 } 170 }
170 } 171 }
171 outb(0x00, BASEPORT); 172 outb(0x00, BASEPORT);
172 173
173 spin_unlock(&lock); 174 spin_unlock(&lock);
174 175
175 return 0; 176 return 0;
176} 177}
177 178
178static int tt_getsigstr(struct tt_device *dev) /* TODO */ 179static int tt_getsigstr(struct tt_device *dev) /* TODO */
@@ -190,7 +191,7 @@ static int tt_do_ioctl(struct inode *inode, struct file *file,
190{ 191{
191 struct video_device *dev = video_devdata(file); 192 struct video_device *dev = video_devdata(file);
192 struct tt_device *tt=dev->priv; 193 struct tt_device *tt=dev->priv;
193 194
194 switch(cmd) 195 switch(cmd)
195 { 196 {
196 case VIDIOCGCAP: 197 case VIDIOCGCAP:
@@ -206,7 +207,7 @@ static int tt_do_ioctl(struct inode *inode, struct file *file,
206 case VIDIOCGTUNER: 207 case VIDIOCGTUNER:
207 { 208 {
208 struct video_tuner *v = arg; 209 struct video_tuner *v = arg;
209 if(v->tuner) /* Only 1 tuner */ 210 if(v->tuner) /* Only 1 tuner */
210 return -EINVAL; 211 return -EINVAL;
211 v->rangelow=(87*16000); 212 v->rangelow=(87*16000);
212 v->rangehigh=(108*16000); 213 v->rangehigh=(108*16000);
@@ -238,21 +239,21 @@ static int tt_do_ioctl(struct inode *inode, struct file *file,
238 return 0; 239 return 0;
239 } 240 }
240 case VIDIOCGAUDIO: 241 case VIDIOCGAUDIO:
241 { 242 {
242 struct video_audio *v = arg; 243 struct video_audio *v = arg;
243 memset(v,0, sizeof(*v)); 244 memset(v,0, sizeof(*v));
244 v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; 245 v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME;
245 v->volume=tt->curvol * 6554; 246 v->volume=tt->curvol * 6554;
246 v->step=6554; 247 v->step=6554;
247 strcpy(v->name, "Radio"); 248 strcpy(v->name, "Radio");
248 return 0; 249 return 0;
249 } 250 }
250 case VIDIOCSAUDIO: 251 case VIDIOCSAUDIO:
251 { 252 {
252 struct video_audio *v = arg; 253 struct video_audio *v = arg;
253 if(v->audio) 254 if(v->audio)
254 return -EINVAL; 255 return -EINVAL;
255 if(v->flags&VIDEO_AUDIO_MUTE) 256 if(v->flags&VIDEO_AUDIO_MUTE)
256 tt_mute(tt); 257 tt_mute(tt);
257 else 258 else
258 tt_setvol(tt,v->volume/6554); 259 tt_setvol(tt,v->volume/6554);
@@ -296,25 +297,25 @@ static int __init terratec_init(void)
296 printk(KERN_ERR "You must set an I/O address with io=0x???\n"); 297 printk(KERN_ERR "You must set an I/O address with io=0x???\n");
297 return -EINVAL; 298 return -EINVAL;
298 } 299 }
299 if (!request_region(io, 2, "terratec")) 300 if (!request_region(io, 2, "terratec"))
300 { 301 {
301 printk(KERN_ERR "TerraTec: port 0x%x already in use\n", io); 302 printk(KERN_ERR "TerraTec: port 0x%x already in use\n", io);
302 return -EBUSY; 303 return -EBUSY;
303 } 304 }
304 305
305 terratec_radio.priv=&terratec_unit; 306 terratec_radio.priv=&terratec_unit;
306 307
307 spin_lock_init(&lock); 308 spin_lock_init(&lock);
308 309
309 if(video_register_device(&terratec_radio, VFL_TYPE_RADIO, radio_nr)==-1) 310 if(video_register_device(&terratec_radio, VFL_TYPE_RADIO, radio_nr)==-1)
310 { 311 {
311 release_region(io,2); 312 release_region(io,2);
312 return -EINVAL; 313 return -EINVAL;
313 } 314 }
314 315
315 printk(KERN_INFO "TERRATEC ActivRadio Standalone card driver.\n"); 316 printk(KERN_INFO "TERRATEC ActivRadio Standalone card driver.\n");
316 317
317 /* mute card - prevents noisy bootups */ 318 /* mute card - prevents noisy bootups */
318 319
319 /* this ensures that the volume is all the way down */ 320 /* this ensures that the volume is all the way down */
320 cardWriteVol(0); 321 cardWriteVol(0);
@@ -334,7 +335,7 @@ static void __exit terratec_cleanup_module(void)
334{ 335{
335 video_unregister_device(&terratec_radio); 336 video_unregister_device(&terratec_radio);
336 release_region(io,2); 337 release_region(io,2);
337 printk(KERN_INFO "TERRATEC ActivRadio Standalone card driver unloaded.\n"); 338 printk(KERN_INFO "TERRATEC ActivRadio Standalone card driver unloaded.\n");
338} 339}
339 340
340module_init(terratec_init); 341module_init(terratec_init);
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c
index 5a099a50d4d0..8da4badc22b4 100644
--- a/drivers/media/radio/radio-trust.c
+++ b/drivers/media/radio/radio-trust.c
@@ -1,14 +1,14 @@
1/* radio-trust.c - Trust FM Radio card driver for Linux 2.2 1/* radio-trust.c - Trust FM Radio card driver for Linux 2.2
2 * by Eric Lammerts <eric@scintilla.utwente.nl> 2 * by Eric Lammerts <eric@scintilla.utwente.nl>
3 * 3 *
4 * Based on radio-aztech.c. Original notes: 4 * Based on radio-aztech.c. Original notes:
5 * 5 *
6 * Adapted to support the Video for Linux API by 6 * Adapted to support the Video for Linux API by
7 * Russell Kroll <rkroll@exploits.org>. Based on original tuner code by: 7 * Russell Kroll <rkroll@exploits.org>. Based on original tuner code by:
8 * 8 *
9 * Quay Ly 9 * Quay Ly
10 * Donald Song 10 * Donald Song
11 * Jason Lewis (jlewis@twilight.vtc.vsc.edu) 11 * Jason Lewis (jlewis@twilight.vtc.vsc.edu)
12 * Scott McGrath (smcgrath@twilight.vtc.vsc.edu) 12 * Scott McGrath (smcgrath@twilight.vtc.vsc.edu)
13 * William McGrath (wmcgrath@twilight.vtc.vsc.edu) 13 * William McGrath (wmcgrath@twilight.vtc.vsc.edu)
14 * 14 *
@@ -22,6 +22,7 @@
22#include <asm/io.h> 22#include <asm/io.h>
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <linux/videodev.h> 24#include <linux/videodev.h>
25#include <media/v4l2-common.h>
25#include <linux/config.h> /* CONFIG_RADIO_TRUST_PORT */ 26#include <linux/config.h> /* CONFIG_RADIO_TRUST_PORT */
26 27
27/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */ 28/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */
@@ -30,7 +31,7 @@
30#define CONFIG_RADIO_TRUST_PORT -1 31#define CONFIG_RADIO_TRUST_PORT -1
31#endif 32#endif
32 33
33static int io = CONFIG_RADIO_TRUST_PORT; 34static int io = CONFIG_RADIO_TRUST_PORT;
34static int radio_nr = -1; 35static int radio_nr = -1;
35static int ioval = 0xf; 36static int ioval = 0xf;
36static __u16 curvol; 37static __u16 curvol;
@@ -135,7 +136,7 @@ static void tr_setmute(int mute)
135static int tr_getsigstr(void) 136static int tr_getsigstr(void)
136{ 137{
137 int i, v; 138 int i, v;
138 139
139 for(i = 0, v = 0; i < 100; i++) v |= inb(io); 140 for(i = 0, v = 0; i < 100; i++) v |= inb(io);
140 return (v & 1)? 0 : 0xffff; 141 return (v & 1)? 0 : 0xffff;
141} 142}
@@ -175,7 +176,7 @@ static int tr_do_ioctl(struct inode *inode, struct file *file,
175 { 176 {
176 struct video_tuner *v = arg; 177 struct video_tuner *v = arg;
177 178
178 if(v->tuner) /* Only 1 tuner */ 179 if(v->tuner) /* Only 1 tuner */
179 return -EINVAL; 180 return -EINVAL;
180 181
181 v->rangelow = 87500 * 16; 182 v->rangelow = 87500 * 16;
@@ -211,28 +212,28 @@ static int tr_do_ioctl(struct inode *inode, struct file *file,
211 return 0; 212 return 0;
212 } 213 }
213 case VIDIOCGAUDIO: 214 case VIDIOCGAUDIO:
214 { 215 {
215 struct video_audio *v = arg; 216 struct video_audio *v = arg;
216 217
217 memset(v,0, sizeof(*v)); 218 memset(v,0, sizeof(*v));
218 v->flags = VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME | 219 v->flags = VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME |
219 VIDEO_AUDIO_BASS | VIDEO_AUDIO_TREBLE; 220 VIDEO_AUDIO_BASS | VIDEO_AUDIO_TREBLE;
220 v->mode = curstereo? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; 221 v->mode = curstereo? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO;
221 v->volume = curvol * 2048; 222 v->volume = curvol * 2048;
222 v->step = 2048; 223 v->step = 2048;
223 v->bass = curbass * 4370; 224 v->bass = curbass * 4370;
224 v->treble = curtreble * 4370; 225 v->treble = curtreble * 4370;
225 226
226 strcpy(v->name, "Trust FM Radio"); 227 strcpy(v->name, "Trust FM Radio");
227 return 0; 228 return 0;
228 } 229 }
229 case VIDIOCSAUDIO: 230 case VIDIOCSAUDIO:
230 { 231 {
231 struct video_audio *v = arg; 232 struct video_audio *v = arg;
232 233
233 if(v->audio) 234 if(v->audio)
234 return -EINVAL; 235 return -EINVAL;
235 tr_setvol(v->volume); 236 tr_setvol(v->volume);
236 tr_setbass(v->bass); 237 tr_setbass(v->bass);
237 tr_settreble(v->treble); 238 tr_settreble(v->treble);
238 tr_setstereo(v->mode & VIDEO_SOUND_STEREO); 239 tr_setstereo(v->mode & VIDEO_SOUND_STEREO);
@@ -292,7 +293,7 @@ static int __init trust_init(void)
292 write_i2c(2, TDA7318_ADDR, 0xe0); /* speaker att. RR = 0 dB */ 293 write_i2c(2, TDA7318_ADDR, 0xe0); /* speaker att. RR = 0 dB */
293 write_i2c(2, TDA7318_ADDR, 0x40); /* stereo 1 input, gain = 18.75 dB */ 294 write_i2c(2, TDA7318_ADDR, 0x40); /* stereo 1 input, gain = 18.75 dB */
294 295
295 tr_setvol(0x8000); 296 tr_setvol(0x8000);
296 tr_setbass(0x8000); 297 tr_setbass(0x8000);
297 tr_settreble(0x8000); 298 tr_settreble(0x8000);
298 tr_setstereo(1); 299 tr_setstereo(1);
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c
index e50955836d6b..edd012288669 100644
--- a/drivers/media/radio/radio-typhoon.c
+++ b/drivers/media/radio/radio-typhoon.c
@@ -36,6 +36,7 @@
36#include <asm/io.h> /* outb, outb_p */ 36#include <asm/io.h> /* outb, outb_p */
37#include <asm/uaccess.h> /* copy to/from user */ 37#include <asm/uaccess.h> /* copy to/from user */
38#include <linux/videodev.h> /* kernel radio structs */ 38#include <linux/videodev.h> /* kernel radio structs */
39#include <media/v4l2-common.h>
39#include <linux/config.h> /* CONFIG_RADIO_TYPHOON_* */ 40#include <linux/config.h> /* CONFIG_RADIO_TYPHOON_* */
40 41
41#define BANNER "Typhoon Radio Card driver v0.1\n" 42#define BANNER "Typhoon Radio Card driver v0.1\n"
@@ -361,8 +362,8 @@ static int __init typhoon_init(void)
361 362
362#ifdef CONFIG_RADIO_TYPHOON_PROC_FS 363#ifdef CONFIG_RADIO_TYPHOON_PROC_FS
363 if (!create_proc_info_entry("driver/radio-typhoon", 0, NULL, 364 if (!create_proc_info_entry("driver/radio-typhoon", 0, NULL,
364 typhoon_get_info)) 365 typhoon_get_info))
365 printk(KERN_ERR "radio-typhoon: registering /proc/driver/radio-typhoon failed\n"); 366 printk(KERN_ERR "radio-typhoon: registering /proc/driver/radio-typhoon failed\n");
366#endif 367#endif
367 368
368 return 0; 369 return 0;
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
index 7bf1a4264891..59b86a6b4b0e 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -1,7 +1,7 @@
1/* zoltrix radio plus driver for Linux radio support 1/* zoltrix radio plus driver for Linux radio support
2 * (c) 1998 C. van Schaik <carl@leg.uct.ac.za> 2 * (c) 1998 C. van Schaik <carl@leg.uct.ac.za>
3 * 3 *
4 * BUGS 4 * BUGS
5 * Due to the inconsistency in reading from the signal flags 5 * Due to the inconsistency in reading from the signal flags
6 * it is difficult to get an accurate tuned signal. 6 * it is difficult to get an accurate tuned signal.
7 * 7 *
@@ -14,7 +14,7 @@
14 * 14 *
15 * 1999-05-06 - (C. van Schaik) 15 * 1999-05-06 - (C. van Schaik)
16 * - Make signal strength and stereo scans 16 * - Make signal strength and stereo scans
17 * kinder to cpu while in delay 17 * kinder to cpu while in delay
18 * 1999-01-05 - (C. van Schaik) 18 * 1999-01-05 - (C. van Schaik)
19 * - Changed tuning to 1/160Mhz accuracy 19 * - Changed tuning to 1/160Mhz accuracy
20 * - Added stereo support 20 * - Added stereo support
@@ -33,6 +33,7 @@
33#include <asm/io.h> /* outb, outb_p */ 33#include <asm/io.h> /* outb, outb_p */
34#include <asm/uaccess.h> /* copy to/from user */ 34#include <asm/uaccess.h> /* copy to/from user */
35#include <linux/videodev.h> /* kernel radio structs */ 35#include <linux/videodev.h> /* kernel radio structs */
36#include <media/v4l2-common.h>
36#include <linux/config.h> /* CONFIG_RADIO_ZOLTRIX_PORT */ 37#include <linux/config.h> /* CONFIG_RADIO_ZOLTRIX_PORT */
37 38
38#ifndef CONFIG_RADIO_ZOLTRIX_PORT 39#ifndef CONFIG_RADIO_ZOLTRIX_PORT
@@ -105,7 +106,7 @@ static int zol_setfreq(struct zol_device *dev, unsigned long freq)
105 i = 45; 106 i = 45;
106 107
107 mutex_lock(&dev->lock); 108 mutex_lock(&dev->lock);
108 109
109 outb(0, io); 110 outb(0, io);
110 outb(0, io); 111 outb(0, io);
111 inb(io + 3); /* Zoltrix needs to be read to confirm */ 112 inb(io + 3); /* Zoltrix needs to be read to confirm */
@@ -139,8 +140,8 @@ static int zol_setfreq(struct zol_device *dev, unsigned long freq)
139 udelay(1000); 140 udelay(1000);
140 inb(io+2); 141 inb(io+2);
141 142
142 udelay(1000); 143 udelay(1000);
143 144
144 if (dev->muted) 145 if (dev->muted)
145 { 146 {
146 outb(0, io); 147 outb(0, io);
@@ -148,12 +149,12 @@ static int zol_setfreq(struct zol_device *dev, unsigned long freq)
148 inb(io + 3); 149 inb(io + 3);
149 udelay(1000); 150 udelay(1000);
150 } 151 }
151 152
152 mutex_unlock(&dev->lock); 153 mutex_unlock(&dev->lock);
153 154
154 if(!dev->muted) 155 if(!dev->muted)
155 { 156 {
156 zol_setvol(dev, dev->curvol); 157 zol_setvol(dev, dev->curvol);
157 } 158 }
158 return 0; 159 return 0;
159} 160}
@@ -174,14 +175,14 @@ static int zol_getsigstr(struct zol_device *dev)
174 b = inb(io); 175 b = inb(io);
175 176
176 mutex_unlock(&dev->lock); 177 mutex_unlock(&dev->lock);
177 178
178 if (a != b) 179 if (a != b)
179 return (0); 180 return (0);
180 181
181 if ((a == 0xcf) || (a == 0xdf) /* I found this out by playing */ 182 if ((a == 0xcf) || (a == 0xdf) /* I found this out by playing */
182 || (a == 0xef)) /* with a binary scanner on the card io */ 183 || (a == 0xef)) /* with a binary scanner on the card io */
183 return (1); 184 return (1);
184 return (0); 185 return (0);
185} 186}
186 187
187static int zol_is_stereo (struct zol_device *dev) 188static int zol_is_stereo (struct zol_device *dev)
@@ -189,7 +190,7 @@ static int zol_is_stereo (struct zol_device *dev)
189 int x1, x2; 190 int x1, x2;
190 191
191 mutex_lock(&dev->lock); 192 mutex_lock(&dev->lock);
192 193
193 outb(0x00, io); 194 outb(0x00, io);
194 outb(dev->curvol, io); 195 outb(dev->curvol, io);
195 msleep(20); 196 msleep(20);
@@ -199,7 +200,7 @@ static int zol_is_stereo (struct zol_device *dev)
199 x2 = inb(io); 200 x2 = inb(io);
200 201
201 mutex_unlock(&dev->lock); 202 mutex_unlock(&dev->lock);
202 203
203 if ((x1 == x2) && (x1 == 0xcf)) 204 if ((x1 == x2) && (x1 == 0xcf))
204 return 1; 205 return 1;
205 return 0; 206 return 0;
@@ -226,7 +227,7 @@ static int zol_do_ioctl(struct inode *inode, struct file *file,
226 case VIDIOCGTUNER: 227 case VIDIOCGTUNER:
227 { 228 {
228 struct video_tuner *v = arg; 229 struct video_tuner *v = arg;
229 if (v->tuner) 230 if (v->tuner)
230 return -EINVAL; 231 return -EINVAL;
231 strcpy(v->name, "FM"); 232 strcpy(v->name, "FM");
232 v->rangelow = (int) (88.0 * 16000); 233 v->rangelow = (int) (88.0 * 16000);
@@ -351,7 +352,7 @@ static int __init zoltrix_init(void)
351 printk(KERN_INFO "Zoltrix Radio Plus card driver.\n"); 352 printk(KERN_INFO "Zoltrix Radio Plus card driver.\n");
352 353
353 mutex_init(&zoltrix_unit.lock); 354 mutex_init(&zoltrix_unit.lock);
354 355
355 /* mute card - prevents noisy bootups */ 356 /* mute card - prevents noisy bootups */
356 357
357 /* this ensures that the volume is all the way down */ 358 /* this ensures that the volume is all the way down */