Commit f8c559f8 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

V4L/DVB (4352): V4L2 conversion: radio-rtrack2

Driver conversion to V4L2 API.
Require some testing, since this obsolete hardware is not
common those days.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent b6055d7b
...@@ -59,7 +59,7 @@ config RADIO_RTRACK_PORT ...@@ -59,7 +59,7 @@ config RADIO_RTRACK_PORT
config RADIO_RTRACK2 config RADIO_RTRACK2
tristate "AIMSlab RadioTrack II support" tristate "AIMSlab RadioTrack II support"
depends on ISA && VIDEO_V4L1 depends on ISA && VIDEO_V4L2
---help--- ---help---
Choose Y here if you have this FM radio card, and then fill in the Choose Y here if you have this FM radio card, and then fill in the
port address below. port address below.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
* *
* TODO: Allow for more than one of these foolish entities :-) * TODO: Allow for more than one of these foolish entities :-)
* *
* Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
*/ */
#include <linux/module.h> /* Modules */ #include <linux/module.h> /* Modules */
...@@ -14,10 +15,32 @@ ...@@ -14,10 +15,32 @@
#include <linux/delay.h> /* udelay */ #include <linux/delay.h> /* udelay */
#include <asm/io.h> /* outb, outb_p */ #include <asm/io.h> /* outb, outb_p */
#include <asm/uaccess.h> /* copy to/from user */ #include <asm/uaccess.h> /* copy to/from user */
#include <linux/videodev.h> /* kernel radio structs */ #include <linux/videodev2.h> /* kernel radio structs */
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/version.h> /* 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 = 65535,
.step = 65535,
.default_value = 0xff,
.type = V4L2_CTRL_TYPE_INTEGER,
}
};
#ifndef CONFIG_RADIO_RTRACK2_PORT #ifndef CONFIG_RADIO_RTRACK2_PORT
#define CONFIG_RADIO_RTRACK2_PORT -1 #define CONFIG_RADIO_RTRACK2_PORT -1
#endif #endif
...@@ -114,75 +137,120 @@ static int rt_do_ioctl(struct inode *inode, struct file *file, ...@@ -114,75 +137,120 @@ static int rt_do_ioctl(struct inode *inode, struct file *file,
switch(cmd) switch(cmd)
{ {
case VIDIOCGCAP: case VIDIOC_QUERYCAP:
{ {
struct video_capability *v = arg; struct v4l2_capability *v = arg;
memset(v,0,sizeof(*v)); memset(v,0,sizeof(*v));
v->type=VID_TYPE_TUNER; strlcpy(v->driver, "radio-rtrack2", sizeof (v->driver));
v->channels=1; strlcpy(v->card, "RadioTrack II", sizeof (v->card));
v->audios=1; sprintf(v->bus_info,"ISA");
strcpy(v->name, "RadioTrack II"); v->version = RADIO_VERSION;
v->capabilities = V4L2_CAP_TUNER;
return 0; return 0;
} }
case VIDIOCGTUNER: case VIDIOC_G_TUNER:
{ {
struct video_tuner *v = arg; struct v4l2_tuner *v = arg;
if(v->tuner) /* Only 1 tuner */
if (v->index > 0)
return -EINVAL; return -EINVAL;
v->rangelow=88*16000;
v->rangehigh=108*16000; memset(v,0,sizeof(*v));
v->flags=VIDEO_TUNER_LOW;
v->mode=VIDEO_MODE_AUTO;
v->signal=0xFFFF*rt_getsigstr(rt);
strcpy(v->name, "FM"); strcpy(v->name, "FM");
v->type = V4L2_TUNER_RADIO;
v->rangelow=(88*16000);
v->rangehigh=(108*16000);
v->rxsubchans =V4L2_TUNER_SUB_MONO;
v->capability=V4L2_TUNER_CAP_LOW;
v->audmode = V4L2_TUNER_MODE_MONO;
v->signal=0xFFFF*rt_getsigstr(rt);
return 0; return 0;
} }
case VIDIOCSTUNER: case VIDIOC_S_TUNER:
{ {
struct video_tuner *v = arg; struct v4l2_tuner *v = arg;
if(v->tuner!=0)
if (v->index > 0)
return -EINVAL; return -EINVAL;
/* Only 1 tuner so no setting needed ! */
return 0; return 0;
} }
case VIDIOCGFREQ: case VIDIOC_S_FREQUENCY:
{ {
unsigned long *freq = arg; struct v4l2_frequency *f = arg;
*freq = rt->curfreq;
rt->curfreq = f->frequency;
rt_setfreq(rt, rt->curfreq);
return 0; return 0;
} }
case VIDIOCSFREQ: case VIDIOC_G_FREQUENCY:
{ {
unsigned long *freq = arg; struct v4l2_frequency *f = arg;
rt->curfreq = *freq;
rt_setfreq(rt, rt->curfreq); f->type = V4L2_TUNER_RADIO;
f->frequency = rt->curfreq;
return 0; return 0;
} }
case VIDIOCGAUDIO: case VIDIOC_QUERYCTRL:
{ {
struct video_audio *v = arg; struct v4l2_queryctrl *qc = arg;
memset(v,0, sizeof(*v)); int i;
v->flags|=VIDEO_AUDIO_MUTABLE;
v->volume=1; for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
v->step=65535; if (qc->id && qc->id == radio_qctrl[i].id) {
strcpy(v->name, "Radio"); memcpy(qc, &(radio_qctrl[i]),
return 0; sizeof(*qc));
return (0);
}
}
return -EINVAL;
} }
case VIDIOCSAUDIO: case VIDIOC_G_CTRL:
{ {
struct video_audio *v = arg; struct v4l2_control *ctrl= arg;
if(v->audio)
return -EINVAL; switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
if(v->flags&VIDEO_AUDIO_MUTE) ctrl->value=rt->muted;
rt_mute(rt); return (0);
else case V4L2_CID_AUDIO_VOLUME:
rt_unmute(rt); if (rt->muted)
ctrl->value=0;
return 0; else
ctrl->value=65535;
return (0);
}
return -EINVAL;
}
case VIDIOC_S_CTRL:
{
struct v4l2_control *ctrl= arg;
switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
if (ctrl->value) {
rt_mute(rt);
} else {
rt_unmute(rt);
}
return (0);
case V4L2_CID_AUDIO_VOLUME:
if (ctrl->value) {
rt_unmute(rt);
} else {
rt_mute(rt);
}
return (0);
}
return -EINVAL;
} }
default: default:
return -ENOIOCTLCMD; return v4l_compat_translate_ioctl(inode,file,cmd,arg,
rt_do_ioctl);
} }
} }
...@@ -208,7 +276,7 @@ static struct video_device rtrack2_radio= ...@@ -208,7 +276,7 @@ static struct video_device rtrack2_radio=
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "RadioTrack II radio", .name = "RadioTrack II radio",
.type = VID_TYPE_TUNER, .type = VID_TYPE_TUNER,
.hardware = VID_HARDWARE_RTRACK2, .hardware = 0,
.fops = &rtrack2_fops, .fops = &rtrack2_fops,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment