aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-aimslab.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-aimslab.c')
-rw-r--r--drivers/media/radio/radio-aimslab.c51
1 files changed, 26 insertions, 25 deletions
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" */