V4L/DVB (4364): V4L2 conversion: radio-maxiradio

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:
Mauro Carvalho Chehab 2006-08-08 09:10:05 -03:00
parent 982eddb911
commit e84fef6b4a
2 changed files with 107 additions and 67 deletions

View File

@ -145,7 +145,7 @@ config RADIO_GEMTEK_PCI
config RADIO_MAXIRADIO config RADIO_MAXIRADIO
tristate "Guillemot MAXI Radio FM 2000 radio" tristate "Guillemot MAXI Radio FM 2000 radio"
depends on VIDEO_V4L1 && PCI depends on VIDEO_V4L2 && PCI
---help--- ---help---
Choose Y here if you have this radio card. This card may also be Choose Y here if you have this radio card. This card may also be
found as Gemtek PCI FM. found as Gemtek PCI FM.

View File

@ -20,13 +20,14 @@
* 0.75b * 0.75b
* - better pci interface thanks to Francois Romieu <romieu@cogenit.fr> * - better pci interface thanks to Francois Romieu <romieu@cogenit.fr>
* *
* 0.75 * 0.75 Sun Feb 4 22:51:27 EET 2001
* - tiding up * - tiding up
* - removed support for multiple devices as it didn't work anyway * - removed support for multiple devices as it didn't work anyway
* *
* BUGS: * BUGS:
* - card unmutes if you change frequency * - card unmutes if you change frequency
* *
* Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
*/ */
@ -40,11 +41,24 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/videodev.h> #include <linux/videodev2.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
/* version 0.75 Sun Feb 4 22:51:27 EET 2001 */ #define DRIVER_VERSION "0.76"
#define DRIVER_VERSION "0.75"
#include <linux/version.h> /* for KERNEL_VERSION MACRO */
#define RADIO_VERSION KERNEL_VERSION(0,7,6)
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,
}
};
#ifndef PCI_VENDOR_ID_GUILLEMOT #ifndef PCI_VENDOR_ID_GUILLEMOT
#define PCI_VENDOR_ID_GUILLEMOT 0x5046 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
@ -90,7 +104,6 @@ static struct video_device maxiradio_radio =
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "Maxi Radio FM2000 radio", .name = "Maxi Radio FM2000 radio",
.type = VID_TYPE_TUNER, .type = VID_TYPE_TUNER,
.hardware = VID_HARDWARE_SF16MI,
.fops = &maxiradio_fops, .fops = &maxiradio_fops,
}; };
@ -176,89 +189,116 @@ static inline int radio_function(struct inode *inode, struct file *file,
struct radio_device *card=dev->priv; struct radio_device *card=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));
strlcpy(v->driver, "radio-maxiradio", sizeof (v->driver));
strlcpy(v->card, "Maxi Radio FM2000 radio", sizeof (v->card));
sprintf(v->bus_info,"ISA");
v->version = RADIO_VERSION;
v->capabilities = V4L2_CAP_TUNER;
return 0;
}
case VIDIOC_G_TUNER:
{
struct v4l2_tuner *v = arg;
if (v->index > 0)
return -EINVAL;
memset(v,0,sizeof(*v)); memset(v,0,sizeof(*v));
strcpy(v->name, "Maxi Radio FM2000 radio");
v->type=VID_TYPE_TUNER;
v->channels=v->audios=1;
return 0;
}
case VIDIOCGTUNER: {
struct video_tuner *v = arg;
if(v->tuner)
return -EINVAL;
card->stereo = 0xffff * get_stereo(card->io);
card->tuned = 0xffff * get_tune(card->io);
v->flags = VIDEO_TUNER_LOW | card->stereo;
v->signal = card->tuned;
strcpy(v->name, "FM"); strcpy(v->name, "FM");
v->type = V4L2_TUNER_RADIO;
v->rangelow = FREQ_LO; v->rangelow=FREQ_LO;
v->rangehigh = FREQ_HI; v->rangehigh=FREQ_HI;
v->mode = VIDEO_MODE_AUTO; v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
v->capability=V4L2_TUNER_CAP_LOW;
if(get_stereo(card->io))
v->audmode = V4L2_TUNER_MODE_STEREO;
else
v->audmode = V4L2_TUNER_MODE_MONO;
v->signal=0xffff*get_tune(card->io);
return 0; 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; return -EINVAL;
return 0; return 0;
} }
case VIDIOCGFREQ: { case VIDIOC_S_FREQUENCY:
unsigned long *freq = arg; {
struct v4l2_frequency *f = arg;
*freq = card->freq; if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
return 0;
}
case VIDIOCSFREQ: {
unsigned long *freq = arg;
if (*freq < FREQ_LO || *freq > FREQ_HI)
return -EINVAL; return -EINVAL;
card->freq = *freq;
card->freq = f->frequency;
set_freq(card->io, FREQ2BITS(card->freq)); set_freq(card->io, FREQ2BITS(card->freq));
msleep(125); msleep(125);
return 0; return 0;
} }
case VIDIOCGAUDIO: { case VIDIOC_G_FREQUENCY:
struct video_audio *v = arg; {
memset(v,0,sizeof(*v)); struct v4l2_frequency *f = arg;
strcpy(v->name, "Radio");
v->flags=VIDEO_AUDIO_MUTABLE | card->muted; f->type = V4L2_TUNER_RADIO;
v->mode=VIDEO_SOUND_STEREO; f->frequency = card->freq;
return 0; return 0;
} }
case VIDIOC_QUERYCTRL:
{
struct v4l2_queryctrl *qc = arg;
int i;
case VIDIOCSAUDIO: { for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
struct video_audio *v = arg; if (qc->id && qc->id == radio_qctrl[i].id) {
memcpy(qc, &(radio_qctrl[i]),
if(v->audio) sizeof(*qc));
return -EINVAL; return (0);
card->muted = v->flags & VIDEO_AUDIO_MUTE; }
if(card->muted) }
turn_power(card->io, 0); return -EINVAL;
else
set_freq(card->io, FREQ2BITS(card->freq));
return 0;
} }
case VIDIOCGUNIT: { case VIDIOC_G_CTRL:
struct video_unit *v = arg; {
struct v4l2_control *ctrl= arg;
v->video=VIDEO_NO_UNIT; switch (ctrl->id) {
v->vbi=VIDEO_NO_UNIT; case V4L2_CID_AUDIO_MUTE:
v->radio=dev->minor; ctrl->value=card->muted;
v->audio=0; return (0);
v->teletext=VIDEO_NO_UNIT; }
return 0; return -EINVAL;
} }
default: return -ENOIOCTLCMD; case VIDIOC_S_CTRL:
{
struct v4l2_control *ctrl= arg;
switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
card->muted = ctrl->value;
if(card->muted)
turn_power(card->io, 0);
else
set_freq(card->io, FREQ2BITS(card->freq));
return 0;
}
return -EINVAL;
}
default:
return v4l_compat_translate_ioctl(inode,file,cmd,arg,
radio_function);
} }
} }