Commit 982eddb9 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

V4L/DVB (4363): V4L2 conversion: radio-trust

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 2acadefa
...@@ -268,7 +268,7 @@ config RADIO_TERRATEC_PORT ...@@ -268,7 +268,7 @@ config RADIO_TERRATEC_PORT
config RADIO_TRUST config RADIO_TRUST
tristate "Trust FM radio card" tristate "Trust FM radio card"
depends on ISA && VIDEO_V4L1 depends on ISA && VIDEO_V4L2
help help
This is a driver for the Trust FM radio cards. Say Y if you have This is a driver for the Trust FM radio cards. Say Y if you have
such a card and want to use it under Linux. such a card and want to use it under Linux.
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Scott McGrath (smcgrath@twilight.vtc.vsc.edu) * Scott McGrath (smcgrath@twilight.vtc.vsc.edu)
* William McGrath (wmcgrath@twilight.vtc.vsc.edu) * William McGrath (wmcgrath@twilight.vtc.vsc.edu)
* *
* The basis for this code may be found at http://bigbang.vtc.vsc.edu/fmradio/ * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
*/ */
#include <stdarg.h> #include <stdarg.h>
...@@ -21,9 +21,47 @@ ...@@ -21,9 +21,47 @@
#include <linux/ioport.h> #include <linux/ioport.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/videodev.h> #include <linux/videodev2.h>
#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 = 2048,
.default_value = 65535,
.type = V4L2_CTRL_TYPE_INTEGER,
},{
.id = V4L2_CID_AUDIO_BASS,
.name = "Bass",
.minimum = 0,
.maximum = 65535,
.step = 4370,
.default_value = 32768,
.type = V4L2_CTRL_TYPE_INTEGER,
},{
.id = V4L2_CID_AUDIO_TREBLE,
.name = "Treble",
.minimum = 0,
.maximum = 65535,
.step = 4370,
.default_value = 32768,
.type = V4L2_CTRL_TYPE_INTEGER,
},
};
/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */ /* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */
#ifndef CONFIG_RADIO_TRUST_PORT #ifndef CONFIG_RADIO_TRUST_PORT
...@@ -159,88 +197,125 @@ static int tr_do_ioctl(struct inode *inode, struct file *file, ...@@ -159,88 +197,125 @@ static int tr_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-trust", sizeof (v->driver));
v->channels=1; strlcpy(v->card, "Trust FM Radio", sizeof (v->card));
v->audios=1; sprintf(v->bus_info,"ISA");
strcpy(v->name, "Trust FM 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;
v->rangelow = 87500 * 16; memset(v,0,sizeof(*v));
v->rangehigh = 108000 * 16; strcpy(v->name, "FM");
v->flags = VIDEO_TUNER_LOW; v->type = V4L2_TUNER_RADIO;
v->mode = VIDEO_MODE_AUTO;
v->signal = tr_getsigstr(); v->rangelow=(87.5*16000);
v->rangehigh=(108*16000);
v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
v->capability=V4L2_TUNER_CAP_LOW;
if(tr_getstereo()) if(tr_getstereo())
v->flags |= VIDEO_TUNER_STEREO_ON; v->audmode = V4L2_TUNER_MODE_STEREO;
else
strcpy(v->name, "FM"); v->audmode = V4L2_TUNER_MODE_MONO;
v->signal=tr_getsigstr();
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 = curfreq;
curfreq = f->frequency;
tr_setfreq(curfreq);
return 0; return 0;
} }
case VIDIOCSFREQ: case VIDIOC_G_FREQUENCY:
{ {
unsigned long *freq = arg; struct v4l2_frequency *f = arg;
tr_setfreq(*freq);
f->type = V4L2_TUNER_RADIO;
f->frequency = curfreq;
return 0; return 0;
} }
case VIDIOCGAUDIO: case VIDIOC_QUERYCTRL:
{ {
struct video_audio *v = arg; struct v4l2_queryctrl *qc = arg;
int i;
memset(v,0, sizeof(*v));
v->flags = VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
VIDEO_AUDIO_BASS | VIDEO_AUDIO_TREBLE; if (qc->id && qc->id == radio_qctrl[i].id) {
v->mode = curstereo? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; memcpy(qc, &(radio_qctrl[i]),
v->volume = curvol * 2048; sizeof(*qc));
v->step = 2048; return (0);
v->bass = curbass * 4370; }
v->treble = curtreble * 4370; }
return -EINVAL;
strcpy(v->name, "Trust FM Radio");
return 0;
} }
case VIDIOCSAUDIO: case VIDIOC_G_CTRL:
{ {
struct video_audio *v = arg; struct v4l2_control *ctrl= arg;
if(v->audio) switch (ctrl->id) {
return -EINVAL; case V4L2_CID_AUDIO_MUTE:
tr_setvol(v->volume); ctrl->value=curmute;
tr_setbass(v->bass); return (0);
tr_settreble(v->treble); case V4L2_CID_AUDIO_VOLUME:
tr_setstereo(v->mode & VIDEO_SOUND_STEREO); ctrl->value= curvol * 2048;
tr_setmute(v->flags & VIDEO_AUDIO_MUTE); return (0);
return 0; case V4L2_CID_AUDIO_BASS:
ctrl->value= curbass * 4370;
return (0);
case V4L2_CID_AUDIO_TREBLE:
ctrl->value= curtreble * 4370;
return (0);
}
return -EINVAL;
} }
case VIDIOC_S_CTRL:
{
struct v4l2_control *ctrl= arg;
switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
tr_setmute(ctrl->value);
return 0;
case V4L2_CID_AUDIO_VOLUME:
tr_setvol(ctrl->value);
return 0;
case V4L2_CID_AUDIO_BASS:
tr_setbass(ctrl->value);
return 0;
case V4L2_CID_AUDIO_TREBLE:
tr_settreble(ctrl->value);
return (0);
}
return -EINVAL;
}
default: default:
return -ENOIOCTLCMD; return v4l_compat_translate_ioctl(inode,file,cmd,arg,
tr_do_ioctl);
} }
} }
...@@ -264,7 +339,7 @@ static struct video_device trust_radio= ...@@ -264,7 +339,7 @@ static struct video_device trust_radio=
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "Trust FM Radio", .name = "Trust FM Radio",
.type = VID_TYPE_TUNER, .type = VID_TYPE_TUNER,
.hardware = VID_HARDWARE_TRUST, .hardware = 0,
.fops = &trust_fops, .fops = &trust_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