diff options
Diffstat (limited to 'drivers/media/radio/radio-terratec.c')
-rw-r--r-- | drivers/media/radio/radio-terratec.c | 154 |
1 files changed, 110 insertions, 44 deletions
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c index dfba4ae596cd..f539491a0d76 100644 --- a/drivers/media/radio/radio-terratec.c +++ b/drivers/media/radio/radio-terratec.c | |||
@@ -21,6 +21,7 @@ | |||
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 | * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org> | ||
24 | */ | 25 | */ |
25 | 26 | ||
26 | #include <linux/module.h> /* Modules */ | 27 | #include <linux/module.h> /* Modules */ |
@@ -29,11 +30,32 @@ | |||
29 | #include <linux/delay.h> /* udelay */ | 30 | #include <linux/delay.h> /* udelay */ |
30 | #include <asm/io.h> /* outb, outb_p */ | 31 | #include <asm/io.h> /* outb, outb_p */ |
31 | #include <asm/uaccess.h> /* copy to/from user */ | 32 | #include <asm/uaccess.h> /* copy to/from user */ |
32 | #include <linux/videodev.h> /* kernel radio structs */ | 33 | #include <linux/videodev2.h> /* kernel radio structs */ |
33 | #include <media/v4l2-common.h> | 34 | #include <media/v4l2-common.h> |
34 | #include <linux/config.h> /* CONFIG_RADIO_TERRATEC_PORT */ | ||
35 | #include <linux/spinlock.h> | 35 | #include <linux/spinlock.h> |
36 | 36 | ||
37 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | ||
38 | #define RADIO_VERSION KERNEL_VERSION(0,0,2) | ||
39 | |||
40 | static struct v4l2_queryctrl radio_qctrl[] = { | ||
41 | { | ||
42 | .id = V4L2_CID_AUDIO_MUTE, | ||
43 | .name = "Mute", | ||
44 | .minimum = 0, | ||
45 | .maximum = 1, | ||
46 | .default_value = 1, | ||
47 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
48 | },{ | ||
49 | .id = V4L2_CID_AUDIO_VOLUME, | ||
50 | .name = "Volume", | ||
51 | .minimum = 0, | ||
52 | .maximum = 0xff, | ||
53 | .step = 1, | ||
54 | .default_value = 0xff, | ||
55 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
56 | } | ||
57 | }; | ||
58 | |||
37 | #ifndef CONFIG_RADIO_TERRATEC_PORT | 59 | #ifndef CONFIG_RADIO_TERRATEC_PORT |
38 | #define CONFIG_RADIO_TERRATEC_PORT 0x590 | 60 | #define CONFIG_RADIO_TERRATEC_PORT 0x590 |
39 | #endif | 61 | #endif |
@@ -194,73 +216,117 @@ static int tt_do_ioctl(struct inode *inode, struct file *file, | |||
194 | 216 | ||
195 | switch(cmd) | 217 | switch(cmd) |
196 | { | 218 | { |
197 | case VIDIOCGCAP: | 219 | case VIDIOC_QUERYCAP: |
198 | { | 220 | { |
199 | struct video_capability *v = arg; | 221 | struct v4l2_capability *v = arg; |
200 | memset(v,0,sizeof(*v)); | 222 | memset(v,0,sizeof(*v)); |
201 | v->type=VID_TYPE_TUNER; | 223 | strlcpy(v->driver, "radio-terratec", sizeof (v->driver)); |
202 | v->channels=1; | 224 | strlcpy(v->card, "ActiveRadio", sizeof (v->card)); |
203 | v->audios=1; | 225 | sprintf(v->bus_info,"ISA"); |
204 | strcpy(v->name, "ActiveRadio"); | 226 | v->version = RADIO_VERSION; |
227 | v->capabilities = V4L2_CAP_TUNER; | ||
228 | |||
205 | return 0; | 229 | return 0; |
206 | } | 230 | } |
207 | case VIDIOCGTUNER: | 231 | case VIDIOC_G_TUNER: |
208 | { | 232 | { |
209 | struct video_tuner *v = arg; | 233 | struct v4l2_tuner *v = arg; |
210 | if(v->tuner) /* Only 1 tuner */ | 234 | |
235 | if (v->index > 0) | ||
211 | return -EINVAL; | 236 | return -EINVAL; |
237 | |||
238 | memset(v,0,sizeof(*v)); | ||
239 | strcpy(v->name, "FM"); | ||
240 | v->type = V4L2_TUNER_RADIO; | ||
241 | |||
212 | v->rangelow=(87*16000); | 242 | v->rangelow=(87*16000); |
213 | v->rangehigh=(108*16000); | 243 | v->rangehigh=(108*16000); |
214 | v->flags=VIDEO_TUNER_LOW; | 244 | v->rxsubchans =V4L2_TUNER_SUB_MONO; |
215 | v->mode=VIDEO_MODE_AUTO; | 245 | v->capability=V4L2_TUNER_CAP_LOW; |
216 | strcpy(v->name, "FM"); | 246 | v->audmode = V4L2_TUNER_MODE_MONO; |
217 | v->signal=0xFFFF*tt_getsigstr(tt); | 247 | v->signal=0xFFFF*tt_getsigstr(tt); |
248 | |||
218 | return 0; | 249 | return 0; |
219 | } | 250 | } |
220 | case VIDIOCSTUNER: | 251 | case VIDIOC_S_TUNER: |
221 | { | 252 | { |
222 | struct video_tuner *v = arg; | 253 | struct v4l2_tuner *v = arg; |
223 | if(v->tuner!=0) | 254 | |
255 | if (v->index > 0) | ||
224 | return -EINVAL; | 256 | return -EINVAL; |
225 | /* Only 1 tuner so no setting needed ! */ | 257 | |
226 | return 0; | 258 | return 0; |
227 | } | 259 | } |
228 | case VIDIOCGFREQ: | 260 | case VIDIOC_S_FREQUENCY: |
229 | { | 261 | { |
230 | unsigned long *freq = arg; | 262 | struct v4l2_frequency *f = arg; |
231 | *freq = tt->curfreq; | 263 | |
264 | tt->curfreq = f->frequency; | ||
265 | tt_setfreq(tt, tt->curfreq); | ||
232 | return 0; | 266 | return 0; |
233 | } | 267 | } |
234 | case VIDIOCSFREQ: | 268 | case VIDIOC_G_FREQUENCY: |
235 | { | 269 | { |
236 | unsigned long *freq = arg; | 270 | struct v4l2_frequency *f = arg; |
237 | tt->curfreq = *freq; | 271 | |
238 | tt_setfreq(tt, tt->curfreq); | 272 | f->type = V4L2_TUNER_RADIO; |
273 | f->frequency = tt->curfreq; | ||
274 | |||
239 | return 0; | 275 | return 0; |
240 | } | 276 | } |
241 | case VIDIOCGAUDIO: | 277 | case VIDIOC_QUERYCTRL: |
242 | { | 278 | { |
243 | struct video_audio *v = arg; | 279 | struct v4l2_queryctrl *qc = arg; |
244 | memset(v,0, sizeof(*v)); | 280 | int i; |
245 | v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; | 281 | |
246 | v->volume=tt->curvol * 6554; | 282 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { |
247 | v->step=6554; | 283 | if (qc->id && qc->id == radio_qctrl[i].id) { |
248 | strcpy(v->name, "Radio"); | 284 | memcpy(qc, &(radio_qctrl[i]), |
249 | return 0; | 285 | sizeof(*qc)); |
286 | return (0); | ||
287 | } | ||
288 | } | ||
289 | return -EINVAL; | ||
250 | } | 290 | } |
251 | case VIDIOCSAUDIO: | 291 | case VIDIOC_G_CTRL: |
252 | { | 292 | { |
253 | struct video_audio *v = arg; | 293 | struct v4l2_control *ctrl= arg; |
254 | if(v->audio) | 294 | |
255 | return -EINVAL; | 295 | switch (ctrl->id) { |
256 | if(v->flags&VIDEO_AUDIO_MUTE) | 296 | case V4L2_CID_AUDIO_MUTE: |
257 | tt_mute(tt); | 297 | if (tt->muted) |
258 | else | 298 | ctrl->value=1; |
259 | tt_setvol(tt,v->volume/6554); | 299 | else |
260 | return 0; | 300 | ctrl->value=0; |
301 | return (0); | ||
302 | case V4L2_CID_AUDIO_VOLUME: | ||
303 | ctrl->value=tt->curvol * 6554; | ||
304 | return (0); | ||
305 | } | ||
306 | return -EINVAL; | ||
261 | } | 307 | } |
308 | case VIDIOC_S_CTRL: | ||
309 | { | ||
310 | struct v4l2_control *ctrl= arg; | ||
311 | |||
312 | switch (ctrl->id) { | ||
313 | case V4L2_CID_AUDIO_MUTE: | ||
314 | if (ctrl->value) { | ||
315 | tt_mute(tt); | ||
316 | } else { | ||
317 | tt_setvol(tt,tt->curvol); | ||
318 | } | ||
319 | return (0); | ||
320 | case V4L2_CID_AUDIO_VOLUME: | ||
321 | tt_setvol(tt,ctrl->value); | ||
322 | return (0); | ||
323 | } | ||
324 | return -EINVAL; | ||
325 | } | ||
326 | |||
262 | default: | 327 | default: |
263 | return -ENOIOCTLCMD; | 328 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, |
329 | tt_do_ioctl); | ||
264 | } | 330 | } |
265 | } | 331 | } |
266 | 332 | ||
@@ -286,7 +352,7 @@ static struct video_device terratec_radio= | |||
286 | .owner = THIS_MODULE, | 352 | .owner = THIS_MODULE, |
287 | .name = "TerraTec ActiveRadio", | 353 | .name = "TerraTec ActiveRadio", |
288 | .type = VID_TYPE_TUNER, | 354 | .type = VID_TYPE_TUNER, |
289 | .hardware = VID_HARDWARE_TERRATEC, | 355 | .hardware = 0, |
290 | .fops = &terratec_fops, | 356 | .fops = &terratec_fops, |
291 | }; | 357 | }; |
292 | 358 | ||