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

V4L/DVB (4347): V4L2 conversion: radio_aztech

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 46ff2c72
...@@ -82,7 +82,7 @@ config RADIO_RTRACK2_PORT ...@@ -82,7 +82,7 @@ config RADIO_RTRACK2_PORT
config RADIO_AZTECH config RADIO_AZTECH
tristate "Aztech/Packard Bell Radio" tristate "Aztech/Packard Bell 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.
......
/* radio-aztech.c - Aztech radio card driver for Linux 2.2 /* radio-aztech.c - Aztech radio card driver for Linux 2.2
* *
* Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
* Adapted to support the Video for Linux API by * Adapted to support the Video for Linux API by
* Russell Kroll <rkroll@exploits.org>. Based on original tuner code by: * Russell Kroll <rkroll@exploits.org>. Based on original tuner code by:
* *
...@@ -30,9 +31,31 @@ ...@@ -30,9 +31,31 @@
#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/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 = 0xff,
.step = 1,
.default_value = 0xff,
.type = V4L2_CTRL_TYPE_INTEGER,
}
};
/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */ /* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */
#ifndef CONFIG_RADIO_AZTECH_PORT #ifndef CONFIG_RADIO_AZTECH_PORT
...@@ -165,81 +188,121 @@ static int az_do_ioctl(struct inode *inode, struct file *file, ...@@ -165,81 +188,121 @@ static int az_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-aztech", sizeof (v->driver));
v->channels=1; strlcpy(v->card, "Aztech Radio", sizeof (v->card));
v->audios=1; sprintf(v->bus_info,"ISA");
strcpy(v->name, "Aztech 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) /* Only 1 tuner */
if (v->index > 0)
return -EINVAL; return -EINVAL;
memset(v,0,sizeof(*v));
strcpy(v->name, "FM");
v->type = V4L2_TUNER_RADIO;
v->rangelow=(87*16000); v->rangelow=(87*16000);
v->rangehigh=(108*16000); 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*az_getsigstr(az);
if(az_getstereo(az)) if(az_getstereo(az))
v->flags|=VIDEO_TUNER_STEREO_ON; v->audmode = V4L2_TUNER_MODE_STEREO;
strcpy(v->name, "FM"); else
v->audmode = V4L2_TUNER_MODE_MONO;
v->signal=0xFFFF*az_getsigstr(az);
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;
return 0; return 0;
} }
case VIDIOCGFREQ: case VIDIOC_S_FREQUENCY:
{ {
unsigned long *freq = arg; struct v4l2_frequency *f = arg;
*freq = az->curfreq;
az->curfreq = f->frequency;
az_setfreq(az, az->curfreq);
return 0; return 0;
} }
case VIDIOCSFREQ: case VIDIOC_G_FREQUENCY:
{ {
unsigned long *freq = arg; struct v4l2_frequency *f = arg;
az->curfreq = *freq;
az_setfreq(az, az->curfreq); f->type = V4L2_TUNER_RADIO;
f->frequency = az->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;
if(az->stereo) for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
v->mode=VIDEO_SOUND_STEREO; if (qc->id && qc->id == radio_qctrl[i].id) {
else memcpy(qc, &(radio_qctrl[i]),
v->mode=VIDEO_SOUND_MONO; sizeof(*qc));
v->volume=az->curvol; return (0);
v->step=16384; }
strcpy(v->name, "Radio"); }
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) {
az->curvol=v->volume; case V4L2_CID_AUDIO_MUTE:
if (az->curvol==0)
az->stereo=(v->mode&VIDEO_SOUND_STEREO)?1:0; ctrl->value=1;
if(v->flags&VIDEO_AUDIO_MUTE) else
az_setvol(az,0); ctrl->value=0;
else return (0);
az_setvol(az,az->curvol); case V4L2_CID_AUDIO_VOLUME:
return 0; ctrl->value=az->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) {
az_setvol(az,0);
} else {
az_setvol(az,az->curvol);
}
return (0);
case V4L2_CID_AUDIO_VOLUME:
az_setvol(az,ctrl->value);
return (0);
}
return -EINVAL;
} }
default: default:
return -ENOIOCTLCMD; return v4l_compat_translate_ioctl(inode,file,cmd,arg,
az_do_ioctl);
} }
} }
......
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