V4L/DVB (4353): V4L2 conversion: radio-sf16fmi
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:
Родитель
f8c559f8c0
Коммит
a2ef73af4c
|
@ -208,7 +208,7 @@ config RADIO_MIROPCM20_RDS
|
|||
|
||||
config RADIO_SF16FMI
|
||||
tristate "SF16FMI Radio"
|
||||
depends on ISA && VIDEO_V4L1
|
||||
depends on ISA && VIDEO_V4L2
|
||||
---help---
|
||||
Choose Y here if you have one of these FM radio cards. If you
|
||||
compile the driver into the kernel and your card is not PnP one, you
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* No volume control - only mute/unmute - you have to use line volume
|
||||
* control on SB-part of SF16FMI
|
||||
*
|
||||
* Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h> /* __setup */
|
||||
|
@ -20,13 +21,26 @@
|
|||
#include <linux/init.h> /* Initdata */
|
||||
#include <linux/ioport.h> /* request_region */
|
||||
#include <linux/delay.h> /* udelay */
|
||||
#include <linux/videodev.h> /* kernel radio structs */
|
||||
#include <linux/videodev2.h> /* kernel radio structs */
|
||||
#include <media/v4l2-common.h>
|
||||
#include <linux/isapnp.h>
|
||||
#include <asm/io.h> /* outb, outb_p */
|
||||
#include <asm/uaccess.h> /* copy to/from user */
|
||||
#include <linux/mutex.h>
|
||||
|
||||
#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,
|
||||
}
|
||||
};
|
||||
|
||||
struct fmi_device
|
||||
{
|
||||
int port;
|
||||
|
@ -123,93 +137,122 @@ static int fmi_do_ioctl(struct inode *inode, struct file *file,
|
|||
|
||||
switch(cmd)
|
||||
{
|
||||
case VIDIOCGCAP:
|
||||
case VIDIOC_QUERYCAP:
|
||||
{
|
||||
struct video_capability *v = arg;
|
||||
struct v4l2_capability *v = arg;
|
||||
memset(v,0,sizeof(*v));
|
||||
strcpy(v->name, "SF16-FMx radio");
|
||||
v->type=VID_TYPE_TUNER;
|
||||
v->channels=1;
|
||||
v->audios=1;
|
||||
strlcpy(v->driver, "radio-sf16fmi", sizeof (v->driver));
|
||||
strlcpy(v->card, "SF16-FMx radio", sizeof (v->card));
|
||||
sprintf(v->bus_info,"ISA");
|
||||
v->version = RADIO_VERSION;
|
||||
v->capabilities = V4L2_CAP_TUNER;
|
||||
|
||||
return 0;
|
||||
}
|
||||
case VIDIOCGTUNER:
|
||||
case VIDIOC_G_TUNER:
|
||||
{
|
||||
struct video_tuner *v = arg;
|
||||
struct v4l2_tuner *v = arg;
|
||||
int mult;
|
||||
|
||||
if(v->tuner) /* Only 1 tuner */
|
||||
if (v->index > 0)
|
||||
return -EINVAL;
|
||||
|
||||
memset(v,0,sizeof(*v));
|
||||
strcpy(v->name, "FM");
|
||||
mult = (fmi->flags & VIDEO_TUNER_LOW) ? 1 : 1000;
|
||||
v->type = V4L2_TUNER_RADIO;
|
||||
|
||||
mult = (fmi->flags & V4L2_TUNER_CAP_LOW) ? 1 : 1000;
|
||||
v->rangelow = RSF16_MINFREQ/mult;
|
||||
v->rangehigh = RSF16_MAXFREQ/mult;
|
||||
v->flags=fmi->flags;
|
||||
v->mode=VIDEO_MODE_AUTO;
|
||||
v->rxsubchans =V4L2_TUNER_SUB_MONO | V4L2_TUNER_MODE_STEREO;
|
||||
v->capability=fmi->flags;
|
||||
v->audmode = V4L2_TUNER_MODE_STEREO;
|
||||
v->signal = fmi_getsigstr(fmi);
|
||||
|
||||
return 0;
|
||||
}
|
||||
case VIDIOCSTUNER:
|
||||
case VIDIOC_S_TUNER:
|
||||
{
|
||||
struct video_tuner *v = arg;
|
||||
if(v->tuner!=0)
|
||||
struct v4l2_tuner *v = arg;
|
||||
|
||||
if (v->index > 0)
|
||||
return -EINVAL;
|
||||
fmi->flags = v->flags & VIDEO_TUNER_LOW;
|
||||
/* Only 1 tuner so no setting needed ! */
|
||||
|
||||
return 0;
|
||||
}
|
||||
case VIDIOCGFREQ:
|
||||
case VIDIOC_S_FREQUENCY:
|
||||
{
|
||||
unsigned long *freq = arg;
|
||||
*freq = fmi->curfreq;
|
||||
if (!(fmi->flags & VIDEO_TUNER_LOW))
|
||||
*freq /= 1000;
|
||||
return 0;
|
||||
}
|
||||
case VIDIOCSFREQ:
|
||||
{
|
||||
unsigned long *freq = arg;
|
||||
if (!(fmi->flags & VIDEO_TUNER_LOW))
|
||||
*freq *= 1000;
|
||||
if (*freq < RSF16_MINFREQ || *freq > RSF16_MAXFREQ )
|
||||
struct v4l2_frequency *f = arg;
|
||||
|
||||
if (!(fmi->flags & V4L2_TUNER_CAP_LOW))
|
||||
f->frequency *= 1000;
|
||||
if (f->frequency < RSF16_MINFREQ ||
|
||||
f->frequency > RSF16_MAXFREQ )
|
||||
return -EINVAL;
|
||||
/*rounding in steps of 800 to match th freq
|
||||
that will be used */
|
||||
fmi->curfreq = (*freq/800)*800;
|
||||
fmi->curfreq = (f->frequency/800)*800;
|
||||
fmi_setfreq(fmi);
|
||||
|
||||
return 0;
|
||||
}
|
||||
case VIDIOCGAUDIO:
|
||||
case VIDIOC_G_FREQUENCY:
|
||||
{
|
||||
struct video_audio *v = arg;
|
||||
memset(v,0,sizeof(*v));
|
||||
v->flags=( (!fmi->curvol)*VIDEO_AUDIO_MUTE | VIDEO_AUDIO_MUTABLE);
|
||||
strcpy(v->name, "Radio");
|
||||
v->mode=VIDEO_SOUND_STEREO;
|
||||
struct v4l2_frequency *f = arg;
|
||||
|
||||
f->type = V4L2_TUNER_RADIO;
|
||||
f->frequency = fmi->curfreq;
|
||||
if (!(fmi->flags & V4L2_TUNER_CAP_LOW))
|
||||
f->frequency /= 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
case VIDIOCSAUDIO:
|
||||
case VIDIOC_QUERYCTRL:
|
||||
{
|
||||
struct video_audio *v = arg;
|
||||
if(v->audio)
|
||||
return -EINVAL;
|
||||
fmi->curvol= v->flags&VIDEO_AUDIO_MUTE ? 0 : 1;
|
||||
fmi->curvol ?
|
||||
fmi_unmute(fmi->port) : fmi_mute(fmi->port);
|
||||
return 0;
|
||||
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 VIDIOCGUNIT:
|
||||
case VIDIOC_G_CTRL:
|
||||
{
|
||||
struct video_unit *v = arg;
|
||||
v->video=VIDEO_NO_UNIT;
|
||||
v->vbi=VIDEO_NO_UNIT;
|
||||
v->radio=dev->minor;
|
||||
v->audio=0; /* How do we find out this??? */
|
||||
v->teletext=VIDEO_NO_UNIT;
|
||||
return 0;
|
||||
struct v4l2_control *ctrl= arg;
|
||||
|
||||
switch (ctrl->id) {
|
||||
case V4L2_CID_AUDIO_MUTE:
|
||||
ctrl->value=fmi->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)
|
||||
fmi_mute(fmi->port);
|
||||
else
|
||||
fmi_unmute(fmi->port);
|
||||
|
||||
fmi->curvol=ctrl->value;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
default:
|
||||
return -ENOIOCTLCMD;
|
||||
return v4l_compat_translate_ioctl(inode,file,cmd,arg,
|
||||
fmi_do_ioctl);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,7 +278,7 @@ static struct video_device fmi_radio=
|
|||
.owner = THIS_MODULE,
|
||||
.name = "SF16FMx radio",
|
||||
.type = VID_TYPE_TUNER,
|
||||
.hardware = VID_HARDWARE_SF16MI,
|
||||
.hardware = 0,
|
||||
.fops = &fmi_fops,
|
||||
};
|
||||
|
||||
|
@ -294,7 +337,7 @@ static int __init fmi_init(void)
|
|||
fmi_unit.port = io;
|
||||
fmi_unit.curvol = 0;
|
||||
fmi_unit.curfreq = 0;
|
||||
fmi_unit.flags = VIDEO_TUNER_LOW;
|
||||
fmi_unit.flags = V4L2_TUNER_CAP_LOW;
|
||||
fmi_radio.priv = &fmi_unit;
|
||||
|
||||
mutex_init(&lock);
|
||||
|
|
Загрузка…
Ссылка в новой задаче