X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmedia%2Fradio%2Fradio-terratec.c;h=f539491a0d76f31e7cdfa874a075c8e24e71a043;hb=refs%2Fheads%2Fvserver;hp=dfba4ae596cd342abb3e737234274d4488ae4e23;hpb=16c70f8c1b54b61c3b951b6fb220df250fe09b32;p=linux-2.6.git diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c index dfba4ae59..f539491a0 100644 --- a/drivers/media/radio/radio-terratec.c +++ b/drivers/media/radio/radio-terratec.c @@ -21,6 +21,7 @@ * If you can help me out with that, please contact me!! * * + * Converted to V4L2 API by Mauro Carvalho Chehab */ #include /* Modules */ @@ -29,11 +30,32 @@ #include /* udelay */ #include /* outb, outb_p */ #include /* copy to/from user */ -#include /* kernel radio structs */ +#include /* kernel radio structs */ #include -#include /* CONFIG_RADIO_TERRATEC_PORT */ #include +#include /* for KERNEL_VERSION MACRO */ +#define RADIO_VERSION KERNEL_VERSION(0,0,2) + +static struct v4l2_queryctrl radio_qctrl[] = { + { + .id = V4L2_CID_AUDIO_MUTE, + .name = "Mute", + .minimum = 0, + .maximum = 1, + .default_value = 1, + .type = V4L2_CTRL_TYPE_BOOLEAN, + },{ + .id = V4L2_CID_AUDIO_VOLUME, + .name = "Volume", + .minimum = 0, + .maximum = 0xff, + .step = 1, + .default_value = 0xff, + .type = V4L2_CTRL_TYPE_INTEGER, + } +}; + #ifndef CONFIG_RADIO_TERRATEC_PORT #define CONFIG_RADIO_TERRATEC_PORT 0x590 #endif @@ -194,73 +216,117 @@ static int tt_do_ioctl(struct inode *inode, struct file *file, switch(cmd) { - case VIDIOCGCAP: + case VIDIOC_QUERYCAP: { - struct video_capability *v = arg; + struct v4l2_capability *v = arg; memset(v,0,sizeof(*v)); - v->type=VID_TYPE_TUNER; - v->channels=1; - v->audios=1; - strcpy(v->name, "ActiveRadio"); + strlcpy(v->driver, "radio-terratec", sizeof (v->driver)); + strlcpy(v->card, "ActiveRadio", sizeof (v->card)); + sprintf(v->bus_info,"ISA"); + v->version = RADIO_VERSION; + v->capabilities = V4L2_CAP_TUNER; + return 0; } - case VIDIOCGTUNER: + case VIDIOC_G_TUNER: { - struct video_tuner *v = arg; - if(v->tuner) /* Only 1 tuner */ + struct v4l2_tuner *v = arg; + + if (v->index > 0) return -EINVAL; + + memset(v,0,sizeof(*v)); + strcpy(v->name, "FM"); + v->type = V4L2_TUNER_RADIO; + v->rangelow=(87*16000); v->rangehigh=(108*16000); - v->flags=VIDEO_TUNER_LOW; - v->mode=VIDEO_MODE_AUTO; - strcpy(v->name, "FM"); + v->rxsubchans =V4L2_TUNER_SUB_MONO; + v->capability=V4L2_TUNER_CAP_LOW; + v->audmode = V4L2_TUNER_MODE_MONO; v->signal=0xFFFF*tt_getsigstr(tt); + return 0; } - case VIDIOCSTUNER: + case VIDIOC_S_TUNER: { - struct video_tuner *v = arg; - if(v->tuner!=0) + struct v4l2_tuner *v = arg; + + if (v->index > 0) return -EINVAL; - /* Only 1 tuner so no setting needed ! */ + return 0; } - case VIDIOCGFREQ: + case VIDIOC_S_FREQUENCY: { - unsigned long *freq = arg; - *freq = tt->curfreq; + struct v4l2_frequency *f = arg; + + tt->curfreq = f->frequency; + tt_setfreq(tt, tt->curfreq); return 0; } - case VIDIOCSFREQ: + case VIDIOC_G_FREQUENCY: { - unsigned long *freq = arg; - tt->curfreq = *freq; - tt_setfreq(tt, tt->curfreq); + struct v4l2_frequency *f = arg; + + f->type = V4L2_TUNER_RADIO; + f->frequency = tt->curfreq; + return 0; } - case VIDIOCGAUDIO: + case VIDIOC_QUERYCTRL: { - struct video_audio *v = arg; - memset(v,0, sizeof(*v)); - v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; - v->volume=tt->curvol * 6554; - v->step=6554; - strcpy(v->name, "Radio"); - return 0; + struct v4l2_queryctrl *qc = arg; + int i; + + for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { + if (qc->id && qc->id == radio_qctrl[i].id) { + memcpy(qc, &(radio_qctrl[i]), + sizeof(*qc)); + return (0); + } + } + return -EINVAL; } - case VIDIOCSAUDIO: + case VIDIOC_G_CTRL: { - struct video_audio *v = arg; - if(v->audio) - return -EINVAL; - if(v->flags&VIDEO_AUDIO_MUTE) - tt_mute(tt); - else - tt_setvol(tt,v->volume/6554); - return 0; + struct v4l2_control *ctrl= arg; + + switch (ctrl->id) { + case V4L2_CID_AUDIO_MUTE: + if (tt->muted) + ctrl->value=1; + else + ctrl->value=0; + return (0); + case V4L2_CID_AUDIO_VOLUME: + ctrl->value=tt->curvol * 6554; + return (0); + } + return -EINVAL; } + case VIDIOC_S_CTRL: + { + struct v4l2_control *ctrl= arg; + + switch (ctrl->id) { + case V4L2_CID_AUDIO_MUTE: + if (ctrl->value) { + tt_mute(tt); + } else { + tt_setvol(tt,tt->curvol); + } + return (0); + case V4L2_CID_AUDIO_VOLUME: + tt_setvol(tt,ctrl->value); + return (0); + } + return -EINVAL; + } + default: - return -ENOIOCTLCMD; + return v4l_compat_translate_ioctl(inode,file,cmd,arg, + tt_do_ioctl); } } @@ -286,7 +352,7 @@ static struct video_device terratec_radio= .owner = THIS_MODULE, .name = "TerraTec ActiveRadio", .type = VID_TYPE_TUNER, - .hardware = VID_HARDWARE_TERRATEC, + .hardware = 0, .fops = &terratec_fops, };