Commit 2ab65299 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

V4L/DVB (4358): V4L2 conversion: radio-zoltrix

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 30c48305
...@@ -330,7 +330,7 @@ config RADIO_TYPHOON_MUTEFREQ ...@@ -330,7 +330,7 @@ config RADIO_TYPHOON_MUTEFREQ
config RADIO_ZOLTRIX config RADIO_ZOLTRIX
tristate "Zoltrix Radio" tristate "Zoltrix Radio"
depends on ISA && VIDEO_V4L1 depends on ISA && VIDEO_V4L2
---help--- ---help---
Choose Y here if you have one of these FM radio cards, and then fill Choose Y here if you have one of these FM radio cards, and then fill
in the port address below. in the port address below.
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
* - Added unmute function * - Added unmute function
* - Reworked ioctl functions * - Reworked ioctl functions
* 2002-07-15 - Fix Stereo typo * 2002-07-15 - Fix Stereo typo
*
* 2006-07-24 - Converted to V4L2 API
* by Mauro Carvalho Chehab <mchehab@infradead.org>
*/ */
#include <linux/module.h> /* Modules */ #include <linux/module.h> /* Modules */
...@@ -32,9 +35,31 @@ ...@@ -32,9 +35,31 @@
#include <linux/delay.h> /* udelay, msleep */ #include <linux/delay.h> /* udelay, msleep */
#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/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 = 4096,
.default_value = 0xff,
.type = V4L2_CTRL_TYPE_INTEGER,
}
};
#ifndef CONFIG_RADIO_ZOLTRIX_PORT #ifndef CONFIG_RADIO_ZOLTRIX_PORT
#define CONFIG_RADIO_ZOLTRIX_PORT -1 #define CONFIG_RADIO_ZOLTRIX_PORT -1
#endif #endif
...@@ -212,78 +237,116 @@ static int zol_do_ioctl(struct inode *inode, struct file *file, ...@@ -212,78 +237,116 @@ static int zol_do_ioctl(struct inode *inode, struct file *file,
struct zol_device *zol = dev->priv; struct zol_device *zol = dev->priv;
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-zoltrix", sizeof (v->driver));
v->channels = 1 + zol->stereo; strlcpy(v->card, "Zoltrix Radio", sizeof (v->card));
v->audios = 1; sprintf(v->bus_info,"ISA");
strcpy(v->name, "Zoltrix Radio"); 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)
if (v->index > 0)
return -EINVAL; return -EINVAL;
memset(v,0,sizeof(*v));
strcpy(v->name, "FM"); strcpy(v->name, "FM");
v->rangelow = (int) (88.0 * 16000); v->type = V4L2_TUNER_RADIO;
v->rangehigh = (int) (108.0 * 16000);
v->flags = zol_is_stereo(zol) v->rangelow=(88*16000);
? VIDEO_TUNER_STEREO_ON : 0; v->rangehigh=(108*16000);
v->flags |= VIDEO_TUNER_LOW; v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
v->mode = VIDEO_MODE_AUTO; v->capability=V4L2_TUNER_CAP_LOW;
v->signal = 0xFFFF * zol_getsigstr(zol); 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; 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 = zol->curfreq;
zol->curfreq = f->frequency;
zol_setfreq(zol, zol->curfreq);
return 0; return 0;
} }
case VIDIOCSFREQ: case VIDIOC_G_FREQUENCY:
{ {
unsigned long *freq = arg; struct v4l2_frequency *f = arg;
zol->curfreq = *freq;
zol_setfreq(zol, zol->curfreq); f->type = V4L2_TUNER_RADIO;
f->frequency = zol->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 | VIDEO_AUDIO_VOLUME;
v->mode |= zol_is_stereo(zol) for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; if (qc->id && qc->id == radio_qctrl[i].id) {
v->volume = zol->curvol * 4096; memcpy(qc, &(radio_qctrl[i]),
v->step = 4096; sizeof(*qc));
strcpy(v->name, "Zoltrix Radio"); return (0);
return 0; }
}
return -EINVAL;
} }
case VIDIOCSAUDIO: case VIDIOC_G_CTRL:
{ {
struct video_audio *v = arg; struct v4l2_control *ctrl= arg;
if (v->audio)
switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
ctrl->value=zol->muted;
return (0);
case V4L2_CID_AUDIO_VOLUME:
ctrl->value=zol->curvol * 4096;
return (0);
}
return -EINVAL; return -EINVAL;
}
case VIDIOC_S_CTRL:
{
struct v4l2_control *ctrl= arg;
if (v->flags & VIDEO_AUDIO_MUTE) switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
if (ctrl->value) {
zol_mute(zol); zol_mute(zol);
else { } else {
zol_unmute(zol); zol_unmute(zol);
zol_setvol(zol, v->volume / 4096); 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
/* FIXME: Implement stereo/mono switch on V4L2 */
if (v->mode & VIDEO_SOUND_STEREO) { if (v->mode & VIDEO_SOUND_STEREO) {
zol->stereo = 1; zol->stereo = 1;
zol_setfreq(zol, zol->curfreq); zol_setfreq(zol, zol->curfreq);
...@@ -292,10 +355,13 @@ static int zol_do_ioctl(struct inode *inode, struct file *file, ...@@ -292,10 +355,13 @@ static int zol_do_ioctl(struct inode *inode, struct file *file,
zol->stereo = 0; zol->stereo = 0;
zol_setfreq(zol, zol->curfreq); zol_setfreq(zol, zol->curfreq);
} }
return 0; #endif
return -EINVAL;
} }
default: default:
return -ENOIOCTLCMD; return v4l_compat_translate_ioctl(inode,file,cmd,arg,
zol_do_ioctl);
} }
} }
...@@ -322,7 +388,7 @@ static struct video_device zoltrix_radio = ...@@ -322,7 +388,7 @@ static struct video_device zoltrix_radio =
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "Zoltrix Radio Plus", .name = "Zoltrix Radio Plus",
.type = VID_TYPE_TUNER, .type = VID_TYPE_TUNER,
.hardware = VID_HARDWARE_ZOLTRIX, .hardware = 0,
.fops = &zoltrix_fops, .fops = &zoltrix_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