V4L/DVB (4357): V4L2 conversion: radio-typhoon
Driver conversion to V4L2 API. Require some testing, since this obsolete hardware is not common those days. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
parent
55ac7b690f
commit
30c48305ba
2 changed files with 117 additions and 55 deletions
|
@ -286,7 +286,7 @@ config RADIO_TRUST_PORT
|
||||||
|
|
||||||
config RADIO_TYPHOON
|
config RADIO_TYPHOON
|
||||||
tristate "Typhoon Radio (a.k.a. EcoRadio)"
|
tristate "Typhoon Radio (a.k.a. EcoRadio)"
|
||||||
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 and the frequency used for muting below.
|
in the port address and the frequency used for muting below.
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
* value where I do expect just noise and turn the speaker volume down.
|
* value where I do expect just noise and turn the speaker volume down.
|
||||||
* The frequency change is necessary since the card never seems to be
|
* The frequency change is necessary since the card never seems to be
|
||||||
* completely silent.
|
* completely silent.
|
||||||
|
*
|
||||||
|
* Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/module.h> /* Modules */
|
#include <linux/module.h> /* Modules */
|
||||||
|
@ -35,10 +37,32 @@
|
||||||
#include <linux/proc_fs.h> /* radio card status report */
|
#include <linux/proc_fs.h> /* radio card status report */
|
||||||
#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>
|
||||||
|
|
||||||
#define BANNER "Typhoon Radio Card driver v0.1\n"
|
#include <linux/version.h> /* for KERNEL_VERSION MACRO */
|
||||||
|
#define RADIO_VERSION KERNEL_VERSION(0,1,1)
|
||||||
|
#define BANNER "Typhoon Radio Card driver v0.1.1\n"
|
||||||
|
|
||||||
|
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 = 1<<14,
|
||||||
|
.default_value = 0xff,
|
||||||
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifndef CONFIG_RADIO_TYPHOON_PORT
|
#ifndef CONFIG_RADIO_TYPHOON_PORT
|
||||||
#define CONFIG_RADIO_TYPHOON_PORT -1
|
#define CONFIG_RADIO_TYPHOON_PORT -1
|
||||||
|
@ -170,76 +194,114 @@ static int typhoon_do_ioctl(struct inode *inode, struct file *file,
|
||||||
struct typhoon_device *typhoon = dev->priv;
|
struct typhoon_device *typhoon = 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-typhoon", sizeof (v->driver));
|
||||||
v->channels = 1;
|
strlcpy(v->card, "Typhoon Radio", sizeof (v->card));
|
||||||
v->audios = 1;
|
sprintf(v->bus_info,"ISA");
|
||||||
strcpy(v->name, "Typhoon 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 = 875 * 1600;
|
|
||||||
v->rangehigh = 1080 * 1600;
|
memset(v,0,sizeof(*v));
|
||||||
v->flags = VIDEO_TUNER_LOW;
|
|
||||||
v->mode = VIDEO_MODE_AUTO;
|
|
||||||
v->signal = 0xFFFF; /* We can't get the signal strength */
|
|
||||||
strcpy(v->name, "FM");
|
strcpy(v->name, "FM");
|
||||||
|
v->type = V4L2_TUNER_RADIO;
|
||||||
|
|
||||||
|
v->rangelow=(87.5*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; /* We can't get the signal strength */
|
||||||
|
|
||||||
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;
|
|
||||||
*freq = typhoon->curfreq;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
case VIDIOCSFREQ:
|
|
||||||
{
|
|
||||||
unsigned long *freq = arg;
|
|
||||||
typhoon->curfreq = *freq;
|
|
||||||
typhoon_setfreq(typhoon, typhoon->curfreq);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
case VIDIOCGAUDIO:
|
|
||||||
{
|
{
|
||||||
struct video_audio *v = arg;
|
struct v4l2_frequency *f = arg;
|
||||||
memset(v, 0, sizeof(*v));
|
|
||||||
v->flags |= VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME;
|
typhoon->curfreq = f->frequency;
|
||||||
v->mode |= VIDEO_SOUND_MONO;
|
typhoon_setfreq(typhoon, typhoon->curfreq);
|
||||||
v->volume = typhoon->curvol;
|
|
||||||
v->step = 1 << 14;
|
|
||||||
strcpy(v->name, "Typhoon Radio");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case VIDIOCSAUDIO:
|
case VIDIOC_G_FREQUENCY:
|
||||||
{
|
{
|
||||||
struct video_audio *v = arg;
|
struct v4l2_frequency *f = arg;
|
||||||
if (v->audio)
|
|
||||||
return -EINVAL;
|
f->type = V4L2_TUNER_RADIO;
|
||||||
if (v->flags & VIDEO_AUDIO_MUTE)
|
f->frequency = typhoon->curfreq;
|
||||||
typhoon_mute(typhoon);
|
|
||||||
else
|
|
||||||
typhoon_unmute(typhoon);
|
|
||||||
if (v->flags & VIDEO_AUDIO_VOLUME)
|
|
||||||
typhoon_setvol(typhoon, v->volume);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
default:
|
case VIDIOC_QUERYCTRL:
|
||||||
return -ENOIOCTLCMD;
|
{
|
||||||
|
struct v4l2_queryctrl *qc = arg;
|
||||||
|
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 -EINVAL;
|
||||||
|
}
|
||||||
|
case VIDIOC_G_CTRL:
|
||||||
|
{
|
||||||
|
struct v4l2_control *ctrl= arg;
|
||||||
|
|
||||||
|
switch (ctrl->id) {
|
||||||
|
case V4L2_CID_AUDIO_MUTE:
|
||||||
|
ctrl->value=typhoon->muted;
|
||||||
|
return (0);
|
||||||
|
case V4L2_CID_AUDIO_VOLUME:
|
||||||
|
ctrl->value=typhoon->curvol;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
case VIDIOC_S_CTRL:
|
||||||
|
{
|
||||||
|
struct v4l2_control *ctrl= arg;
|
||||||
|
|
||||||
|
switch (ctrl->id) {
|
||||||
|
case V4L2_CID_AUDIO_MUTE:
|
||||||
|
if (ctrl->value) {
|
||||||
|
typhoon_mute(typhoon);
|
||||||
|
} else {
|
||||||
|
typhoon_unmute(typhoon);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
case V4L2_CID_AUDIO_VOLUME:
|
||||||
|
typhoon_setvol(typhoon, ctrl->value);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return v4l_compat_translate_ioctl(inode,file,cmd,arg,
|
||||||
|
typhon_do_ioctl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +332,7 @@ static struct video_device typhoon_radio =
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.name = "Typhoon Radio",
|
.name = "Typhoon Radio",
|
||||||
.type = VID_TYPE_TUNER,
|
.type = VID_TYPE_TUNER,
|
||||||
.hardware = VID_HARDWARE_TYPHOON,
|
.hardware = 0,
|
||||||
.fops = &typhoon_fops,
|
.fops = &typhoon_fops,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Reference in a new issue