aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-08-08 08:10:03 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-09-26 10:53:14 -0400
commit55ac7b690f086112ab8ac35764189269cdfae768 (patch)
tree9b036219a82f747049120adee626013338af2910 /drivers/media/radio
parentacda0e71857c8ec4e5348d08b53a52d35b92e6aa (diff)
V4L/DVB (4356): V4L2 conversion: radio-terratec
Driver conversion to V4L2 API. Require some testing, since this obsolete hardware is not common those days. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/radio')
-rw-r--r--drivers/media/radio/Kconfig2
-rw-r--r--drivers/media/radio/radio-terratec.c153
2 files changed, 111 insertions, 44 deletions
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index fddfd5c32233..79d6b1bcd1a4 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -239,7 +239,7 @@ config RADIO_SF16FMR2
239 239
240config RADIO_TERRATEC 240config RADIO_TERRATEC
241 tristate "TerraTec ActiveRadio ISA Standalone" 241 tristate "TerraTec ActiveRadio ISA Standalone"
242 depends on ISA && VIDEO_V4L1 242 depends on ISA && VIDEO_V4L2
243 ---help--- 243 ---help---
244 Choose Y here if you have this FM radio card, and then fill in the 244 Choose Y here if you have this FM radio card, and then fill in the
245 port address below. (TODO) 245 port address below. (TODO)
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
index 72d82ca6af6e..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,10 +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/spinlock.h> 35#include <linux/spinlock.h>
35 36
37#include <linux/version.h> /* for KERNEL_VERSION MACRO */
38#define RADIO_VERSION KERNEL_VERSION(0,0,2)
39
40static 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
36#ifndef CONFIG_RADIO_TERRATEC_PORT 59#ifndef CONFIG_RADIO_TERRATEC_PORT
37#define CONFIG_RADIO_TERRATEC_PORT 0x590 60#define CONFIG_RADIO_TERRATEC_PORT 0x590
38#endif 61#endif
@@ -193,73 +216,117 @@ static int tt_do_ioctl(struct inode *inode, struct file *file,
193 216
194 switch(cmd) 217 switch(cmd)
195 { 218 {
196 case VIDIOCGCAP: 219 case VIDIOC_QUERYCAP:
197 { 220 {
198 struct video_capability *v = arg; 221 struct v4l2_capability *v = arg;
199 memset(v,0,sizeof(*v)); 222 memset(v,0,sizeof(*v));
200 v->type=VID_TYPE_TUNER; 223 strlcpy(v->driver, "radio-terratec", sizeof (v->driver));
201 v->channels=1; 224 strlcpy(v->card, "ActiveRadio", sizeof (v->card));
202 v->audios=1; 225 sprintf(v->bus_info,"ISA");
203 strcpy(v->name, "ActiveRadio"); 226 v->version = RADIO_VERSION;
227 v->capabilities = V4L2_CAP_TUNER;
228
204 return 0; 229 return 0;
205 } 230 }
206 case VIDIOCGTUNER: 231 case VIDIOC_G_TUNER:
207 { 232 {
208 struct video_tuner *v = arg; 233 struct v4l2_tuner *v = arg;
209 if(v->tuner) /* Only 1 tuner */ 234
235 if (v->index > 0)
210 return -EINVAL; 236 return -EINVAL;
237
238 memset(v,0,sizeof(*v));
239 strcpy(v->name, "FM");
240 v->type = V4L2_TUNER_RADIO;
241
211 v->rangelow=(87*16000); 242 v->rangelow=(87*16000);
212 v->rangehigh=(108*16000); 243 v->rangehigh=(108*16000);
213 v->flags=VIDEO_TUNER_LOW; 244 v->rxsubchans =V4L2_TUNER_SUB_MONO;
214 v->mode=VIDEO_MODE_AUTO; 245 v->capability=V4L2_TUNER_CAP_LOW;
215 strcpy(v->name, "FM"); 246 v->audmode = V4L2_TUNER_MODE_MONO;
216 v->signal=0xFFFF*tt_getsigstr(tt); 247 v->signal=0xFFFF*tt_getsigstr(tt);
248
217 return 0; 249 return 0;
218 } 250 }
219 case VIDIOCSTUNER: 251 case VIDIOC_S_TUNER:
220 { 252 {
221 struct video_tuner *v = arg; 253 struct v4l2_tuner *v = arg;
222 if(v->tuner!=0) 254
255 if (v->index > 0)
223 return -EINVAL; 256 return -EINVAL;
224 /* Only 1 tuner so no setting needed ! */ 257
225 return 0; 258 return 0;
226 } 259 }
227 case VIDIOCGFREQ: 260 case VIDIOC_S_FREQUENCY:
228 { 261 {
229 unsigned long *freq = arg; 262 struct v4l2_frequency *f = arg;
230 *freq = tt->curfreq; 263
264 tt->curfreq = f->frequency;
265 tt_setfreq(tt, tt->curfreq);
231 return 0; 266 return 0;
232 } 267 }
233 case VIDIOCSFREQ: 268 case VIDIOC_G_FREQUENCY:
234 { 269 {
235 unsigned long *freq = arg; 270 struct v4l2_frequency *f = arg;
236 tt->curfreq = *freq; 271
237 tt_setfreq(tt, tt->curfreq); 272 f->type = V4L2_TUNER_RADIO;
273 f->frequency = tt->curfreq;
274
238 return 0; 275 return 0;
239 } 276 }
240 case VIDIOCGAUDIO: 277 case VIDIOC_QUERYCTRL:
241 { 278 {
242 struct video_audio *v = arg; 279 struct v4l2_queryctrl *qc = arg;
243 memset(v,0, sizeof(*v)); 280 int i;
244 v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; 281
245 v->volume=tt->curvol * 6554; 282 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
246 v->step=6554; 283 if (qc->id && qc->id == radio_qctrl[i].id) {
247 strcpy(v->name, "Radio"); 284 memcpy(qc, &(radio_qctrl[i]),
248 return 0; 285 sizeof(*qc));
286 return (0);
287 }
288 }
289 return -EINVAL;
249 } 290 }
250 case VIDIOCSAUDIO: 291 case VIDIOC_G_CTRL:
251 { 292 {
252 struct video_audio *v = arg; 293 struct v4l2_control *ctrl= arg;
253 if(v->audio) 294
254 return -EINVAL; 295 switch (ctrl->id) {
255 if(v->flags&VIDEO_AUDIO_MUTE) 296 case V4L2_CID_AUDIO_MUTE:
256 tt_mute(tt); 297 if (tt->muted)
257 else 298 ctrl->value=1;
258 tt_setvol(tt,v->volume/6554); 299 else
259 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;
260 } 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
261 default: 327 default:
262 return -ENOIOCTLCMD; 328 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
329 tt_do_ioctl);
263 } 330 }
264} 331}
265 332
@@ -285,7 +352,7 @@ static struct video_device terratec_radio=
285 .owner = THIS_MODULE, 352 .owner = THIS_MODULE,
286 .name = "TerraTec ActiveRadio", 353 .name = "TerraTec ActiveRadio",
287 .type = VID_TYPE_TUNER, 354 .type = VID_TYPE_TUNER,
288 .hardware = VID_HARDWARE_TERRATEC, 355 .hardware = 0,
289 .fops = &terratec_fops, 356 .fops = &terratec_fops,
290}; 357};
291 358