diff options
Diffstat (limited to 'drivers/media/radio/radio-terratec.c')
-rw-r--r-- | drivers/media/radio/radio-terratec.c | 63 |
1 files changed, 32 insertions, 31 deletions
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 | ||
52 | static int io = CONFIG_RADIO_TERRATEC_PORT; | 53 | static int io = CONFIG_RADIO_TERRATEC_PORT; |
53 | static int radio_nr = -1; | 54 | static int radio_nr = -1; |
54 | static spinlock_t lock; | 55 | static spinlock_t lock; |
55 | 56 | ||
@@ -88,15 +89,15 @@ static void tt_mute(struct tt_device *dev) | |||
88 | 89 | ||
89 | static int tt_setvol(struct tt_device *dev, int vol) | 90 | static 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 | ||
123 | static int tt_setfreq(struct tt_device *dev, unsigned long freq1) | 124 | static 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 | ||
178 | static int tt_getsigstr(struct tt_device *dev) /* TODO */ | 179 | static 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 | ||
340 | module_init(terratec_init); | 341 | module_init(terratec_init); |