Commit a1314b1a authored by Douglas Landgraf's avatar Douglas Landgraf Committed by Mauro Carvalho Chehab

V4L/DVB (5541): Radio-zoltrix.c Replace zol_do_ioctl to use video_ioctl2

Convert radio-zoltrix to use video_ioctl2
Signed-off-by: default avatarDouglas Schilling Landgraf <dougsland@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent c5f822bf
...@@ -230,121 +230,123 @@ static int zol_is_stereo (struct zol_device *dev) ...@@ -230,121 +230,123 @@ static int zol_is_stereo (struct zol_device *dev)
return 0; return 0;
} }
static int zol_do_ioctl(struct inode *inode, struct file *file, static int vidioc_querycap(struct file *file, void *priv,
unsigned int cmd, void *arg) struct v4l2_capability *v)
{
strlcpy(v->driver, "radio-zoltrix", sizeof(v->driver));
strlcpy(v->card, "Zoltrix Radio", sizeof(v->card));
sprintf(v->bus_info, "ISA");
v->version = RADIO_VERSION;
v->capabilities = V4L2_CAP_TUNER;
return 0;
}
static int vidioc_g_tuner(struct file *file, void *priv,
struct v4l2_tuner *v)
{ {
struct video_device *dev = video_devdata(file); struct video_device *dev = video_devdata(file);
struct zol_device *zol = dev->priv; struct zol_device *zol = dev->priv;
switch (cmd) { if (v->index > 0)
case VIDIOC_QUERYCAP: return -EINVAL;
{
struct v4l2_capability *v = arg;
memset(v,0,sizeof(*v));
strlcpy(v->driver, "radio-zoltrix", sizeof (v->driver));
strlcpy(v->card, "Zoltrix Radio", sizeof (v->card));
sprintf(v->bus_info,"ISA");
v->version = RADIO_VERSION;
v->capabilities = V4L2_CAP_TUNER;
return 0; strcpy(v->name, "FM");
} v->type = V4L2_TUNER_RADIO;
case VIDIOC_G_TUNER: v->rangelow = (88*16000);
{ v->rangehigh = (108*16000);
struct v4l2_tuner *v = arg; v->rxsubchans = V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
v->capability = V4L2_TUNER_CAP_LOW;
if (v->index > 0) if (zol_is_stereo(zol))
return -EINVAL; v->audmode = V4L2_TUNER_MODE_STEREO;
else
memset(v,0,sizeof(*v)); v->audmode = V4L2_TUNER_MODE_MONO;
strcpy(v->name, "FM"); v->signal = 0xFFFF*zol_getsigstr(zol);
v->type = V4L2_TUNER_RADIO; return 0;
}
v->rangelow=(88*16000);
v->rangehigh=(108*16000);
v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
v->capability=V4L2_TUNER_CAP_LOW;
if(zol_is_stereo(zol))
v->audmode = V4L2_TUNER_MODE_STEREO;
else
v->audmode = V4L2_TUNER_MODE_MONO;
v->signal=0xFFFF*zol_getsigstr(zol);
return 0; static int vidioc_s_tuner(struct file *file, void *priv,
} struct v4l2_tuner *v)
case VIDIOC_S_TUNER: {
{ if (v->index > 0)
struct v4l2_tuner *v = arg; return -EINVAL;
return 0;
}
if (v->index > 0) static int vidioc_s_frequency(struct file *file, void *priv,
return -EINVAL; struct v4l2_frequency *f)
{
struct video_device *dev = video_devdata(file);
struct zol_device *zol = dev->priv;
return 0; zol->curfreq = f->frequency;
} zol_setfreq(zol, zol->curfreq);
case VIDIOC_S_FREQUENCY: return 0;
{ }
struct v4l2_frequency *f = arg;
zol->curfreq = f->frequency; static int vidioc_g_frequency(struct file *file, void *priv,
zol_setfreq(zol, zol->curfreq); struct v4l2_frequency *f)
return 0; {
} struct video_device *dev = video_devdata(file);
case VIDIOC_G_FREQUENCY: struct zol_device *zol = dev->priv;
{
struct v4l2_frequency *f = arg; f->type = V4L2_TUNER_RADIO;
f->frequency = zol->curfreq;
return 0;
}
f->type = V4L2_TUNER_RADIO; static int vidioc_queryctrl(struct file *file, void *priv,
f->frequency = zol->curfreq; struct v4l2_queryctrl *qc)
{
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 0;
} }
case VIDIOC_QUERYCTRL: }
{ return -EINVAL;
struct v4l2_queryctrl *qc = arg; }
int i;
static int vidioc_g_ctrl(struct file *file, void *priv,
for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { struct v4l2_control *ctrl)
if (qc->id && qc->id == radio_qctrl[i].id) { {
memcpy(qc, &(radio_qctrl[i]), struct video_device *dev = video_devdata(file);
sizeof(*qc)); struct zol_device *zol = dev->priv;
return (0);
} switch (ctrl->id) {
} case V4L2_CID_AUDIO_MUTE:
return -EINVAL; ctrl->value = zol->muted;
} return 0;
case VIDIOC_G_CTRL: case V4L2_CID_AUDIO_VOLUME:
{ ctrl->value = zol->curvol * 4096;
struct v4l2_control *ctrl= arg; return 0;
}
switch (ctrl->id) { return -EINVAL;
case V4L2_CID_AUDIO_MUTE: }
ctrl->value=zol->muted;
return (0); static int vidioc_s_ctrl(struct file *file, void *priv,
case V4L2_CID_AUDIO_VOLUME: struct v4l2_control *ctrl)
ctrl->value=zol->curvol * 4096; {
return (0); struct video_device *dev = video_devdata(file);
} struct zol_device *zol = dev->priv;
return -EINVAL;
switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
if (ctrl->value)
zol_mute(zol);
else {
zol_unmute(zol);
zol_setvol(zol,zol->curvol);
} }
case VIDIOC_S_CTRL: return 0;
{ case V4L2_CID_AUDIO_VOLUME:
struct v4l2_control *ctrl= arg; zol_setvol(zol,ctrl->value/4096);
return 0;
switch (ctrl->id) { }
case V4L2_CID_AUDIO_MUTE: zol->stereo = 1;
if (ctrl->value) { zol_setfreq(zol, zol->curfreq);
zol_mute(zol);
} else {
zol_unmute(zol);
zol_setvol(zol,zol->curvol);
}
return (0);
case V4L2_CID_AUDIO_VOLUME:
zol_setvol(zol,ctrl->value/4096);
return (0);
}
zol->stereo = 1;
zol_setfreq(zol, zol->curfreq);
#if 0 #if 0
/* FIXME: Implement stereo/mono switch on V4L2 */ /* FIXME: Implement stereo/mono switch on V4L2 */
if (v->mode & VIDEO_SOUND_STEREO) { if (v->mode & VIDEO_SOUND_STEREO) {
...@@ -356,19 +358,39 @@ static int zol_do_ioctl(struct inode *inode, struct file *file, ...@@ -356,19 +358,39 @@ static int zol_do_ioctl(struct inode *inode, struct file *file,
zol_setfreq(zol, zol->curfreq); zol_setfreq(zol, zol->curfreq);
} }
#endif #endif
return -EINVAL; return -EINVAL;
} }
default: static int vidioc_g_audio(struct file *file, void *priv,
return v4l_compat_translate_ioctl(inode,file,cmd,arg, struct v4l2_audio *a)
zol_do_ioctl); {
} if (a->index > 1)
return -EINVAL;
strcpy(a->name, "Radio");
a->capability = V4L2_AUDCAP_STEREO;
return 0;
}
static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
{
*i = 0;
return 0;
} }
static int zol_ioctl(struct inode *inode, struct file *file, static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
unsigned int cmd, unsigned long arg)
{ {
return video_usercopy(inode, file, cmd, arg, zol_do_ioctl); if (i != 0)
return -EINVAL;
return 0;
}
static int vidioc_s_audio(struct file *file, void *priv,
struct v4l2_audio *a)
{
if (a->index != 0)
return -EINVAL;
return 0;
} }
static struct zol_device zoltrix_unit; static struct zol_device zoltrix_unit;
...@@ -378,7 +400,7 @@ static const struct file_operations zoltrix_fops = ...@@ -378,7 +400,7 @@ static const struct file_operations zoltrix_fops =
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = video_exclusive_open, .open = video_exclusive_open,
.release = video_exclusive_release, .release = video_exclusive_release,
.ioctl = zol_ioctl, .ioctl = video_ioctl2,
.compat_ioctl = v4l_compat_ioctl32, .compat_ioctl = v4l_compat_ioctl32,
.llseek = no_llseek, .llseek = no_llseek,
}; };
...@@ -390,6 +412,18 @@ static struct video_device zoltrix_radio = ...@@ -390,6 +412,18 @@ static struct video_device zoltrix_radio =
.type = VID_TYPE_TUNER, .type = VID_TYPE_TUNER,
.hardware = 0, .hardware = 0,
.fops = &zoltrix_fops, .fops = &zoltrix_fops,
.vidioc_querycap = vidioc_querycap,
.vidioc_g_tuner = vidioc_g_tuner,
.vidioc_s_tuner = vidioc_s_tuner,
.vidioc_g_audio = vidioc_g_audio,
.vidioc_s_audio = vidioc_s_audio,
.vidioc_g_input = vidioc_g_input,
.vidioc_s_input = vidioc_s_input,
.vidioc_g_frequency = vidioc_g_frequency,
.vidioc_s_frequency = vidioc_s_frequency,
.vidioc_queryctrl = vidioc_queryctrl,
.vidioc_g_ctrl = vidioc_g_ctrl,
.vidioc_s_ctrl = vidioc_s_ctrl,
}; };
static int __init zoltrix_init(void) static int __init zoltrix_init(void)
......
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