Commit d455cf5d authored by Douglas Landgraf's avatar Douglas Landgraf Committed by Mauro Carvalho Chehab

V4L/DVB (5563): Radio-maestro.c Replace radio_ioctl to use video_ioctl2

Convert radio-maestro to use video_ioctl2
Signed-off-by: default avatarDouglas Schilling Landgraf <dougsland@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 6f66446c
...@@ -75,8 +75,6 @@ static struct v4l2_queryctrl radio_qctrl[] = { ...@@ -75,8 +75,6 @@ static struct v4l2_queryctrl radio_qctrl[] = {
static int radio_nr = -1; static int radio_nr = -1;
module_param(radio_nr, int, 0); module_param(radio_nr, int, 0);
static int radio_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);
static int maestro_probe(struct pci_dev *pdev, const struct pci_device_id *ent); static int maestro_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
static void maestro_remove(struct pci_dev *pdev); static void maestro_remove(struct pci_dev *pdev);
...@@ -102,18 +100,11 @@ static const struct file_operations maestro_fops = { ...@@ -102,18 +100,11 @@ static const struct file_operations maestro_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = video_exclusive_open, .open = video_exclusive_open,
.release = video_exclusive_release, .release = video_exclusive_release,
.ioctl = radio_ioctl, .ioctl = video_ioctl2,
.compat_ioctl = v4l_compat_ioctl32, .compat_ioctl = v4l_compat_ioctl32,
.llseek = no_llseek, .llseek = no_llseek,
}; };
static struct video_device maestro_radio = {
.name = "Maestro radio",
.type = VID_TYPE_TUNER,
.hardware = 0,
.fops = &maestro_fops,
};
struct radio_device { struct radio_device {
u16 io, /* base of Maestro card radio io (GPIO_DATA)*/ u16 io, /* base of Maestro card radio io (GPIO_DATA)*/
muted, /* VIDEO_AUDIO_MUTE */ muted, /* VIDEO_AUDIO_MUTE */
...@@ -190,142 +181,153 @@ static void radio_bits_set(struct radio_device *dev, u32 data) ...@@ -190,142 +181,153 @@ static void radio_bits_set(struct radio_device *dev, u32 data)
msleep(125); msleep(125);
} }
static inline int radio_function(struct inode *inode, struct file *file, static int vidioc_querycap(struct file *file, void *priv,
unsigned int cmd, void *arg) struct v4l2_capability *v)
{
strlcpy(v->driver, "radio-maestro", sizeof(v->driver));
strlcpy(v->card, "Maestro Radio", sizeof(v->card));
sprintf(v->bus_info, "PCI");
v->version = RADIO_VERSION;
v->capabilities = V4L2_CAP_TUNER;
return 0;
}
static int vidioc_g_tuner(struct file *file, void *priv,
struct v4l2_tuner *v)
{ {
struct video_device *dev = video_devdata(file); struct video_device *dev = video_devdata(file);
struct radio_device *card = video_get_drvdata(dev); struct radio_device *card = video_get_drvdata(dev);
switch (cmd) { if (v->index > 0)
case VIDIOC_QUERYCAP: return -EINVAL;
{
struct v4l2_capability *v = arg; (void)radio_bits_get(card);
memset(v,0,sizeof(*v));
strlcpy(v->driver, "radio-maestro", sizeof (v->driver)); strcpy(v->name, "FM");
strlcpy(v->card, "Maestro Radio", sizeof (v->card)); v->type = V4L2_TUNER_RADIO;
sprintf(v->bus_info,"PCI"); v->rangelow = FREQ_LO;
v->version = RADIO_VERSION; v->rangehigh = FREQ_HI;
v->capabilities = V4L2_CAP_TUNER; v->rxsubchans = V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
v->capability = V4L2_TUNER_CAP_LOW;
return 0; if(card->stereo)
} v->audmode = V4L2_TUNER_MODE_STEREO;
case VIDIOC_G_TUNER: else
{ v->audmode = V4L2_TUNER_MODE_MONO;
struct v4l2_tuner *v = arg; v->signal = card->tuned;
return 0;
if (v->index > 0) }
return -EINVAL;
(void)radio_bits_get(card);
memset(v,0,sizeof(*v)); static int vidioc_s_tuner(struct file *file, void *priv,
strcpy(v->name, "FM"); struct v4l2_tuner *v)
v->type = V4L2_TUNER_RADIO; {
if (v->index > 0)
return -EINVAL;
return 0;
}
v->rangelow = FREQ_LO; static int vidioc_s_frequency(struct file *file, void *priv,
v->rangehigh = FREQ_HI; struct v4l2_frequency *f)
v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; {
v->capability=V4L2_TUNER_CAP_LOW; struct video_device *dev = video_devdata(file);
if(card->stereo) struct radio_device *card = video_get_drvdata(dev);
v->audmode = V4L2_TUNER_MODE_STEREO;
else
v->audmode = V4L2_TUNER_MODE_MONO;
v->signal=card->tuned;
return 0; if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
} return -EINVAL;
case VIDIOC_S_TUNER: radio_bits_set(card, FREQ2BITS(f->frequency));
{ return 0;
struct v4l2_tuner *v = arg; }
if (v->index > 0) static int vidioc_g_frequency(struct file *file, void *priv,
return -EINVAL; struct v4l2_frequency *f)
{
struct video_device *dev = video_devdata(file);
struct radio_device *card = video_get_drvdata(dev);
return 0; f->type = V4L2_TUNER_RADIO;
} f->frequency = BITS2FREQ(radio_bits_get(card));
case VIDIOC_S_FREQUENCY: return 0;
{ }
struct v4l2_frequency *f = arg;
if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) static int vidioc_queryctrl(struct file *file, void *priv,
return -EINVAL; struct v4l2_queryctrl *qc)
radio_bits_set(card, FREQ2BITS(f->frequency)); {
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 0;
} }
case VIDIOC_G_FREQUENCY: }
{ return -EINVAL;
struct v4l2_frequency *f = arg; }
f->type = V4L2_TUNER_RADIO; static int vidioc_g_ctrl(struct file *file, void *priv,
f->frequency = BITS2FREQ(radio_bits_get(card)); struct v4l2_control *ctrl)
{
struct video_device *dev = video_devdata(file);
struct radio_device *card = video_get_drvdata(dev);
return 0; switch (ctrl->id) {
} case V4L2_CID_AUDIO_MUTE:
case VIDIOC_QUERYCTRL: ctrl->value = card->muted;
{ 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 VIDIOC_G_CTRL:
{
struct v4l2_control *ctrl= arg;
switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
ctrl->value=card->muted;
return (0);
}
return -EINVAL;
}
case VIDIOC_S_CTRL:
{
struct v4l2_control *ctrl= arg;
switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
{
register u16 io = card->io;
register u16 omask = inw(io + IO_MASK);
outw(~STR_WREN, io + IO_MASK);
outw((card->muted = ctrl->value ) ?
STR_WREN : 0, io);
udelay(4);
outw(omask, io + IO_MASK);
msleep(125);
return (0);
}
}
return -EINVAL;
}
default:
return v4l_compat_translate_ioctl(inode,file,cmd,arg,
radio_function);
} }
return -EINVAL;
} }
static int radio_ioctl(struct inode *inode, struct file *file, static int vidioc_s_ctrl(struct file *file, void *priv,
unsigned int cmd, unsigned long arg) struct v4l2_control *ctrl)
{ {
struct video_device *dev = video_devdata(file); struct video_device *dev = video_devdata(file);
struct radio_device *card = video_get_drvdata(dev); struct radio_device *card = video_get_drvdata(dev);
int ret; register u16 io = card->io;
register u16 omask = inw(io + IO_MASK);
switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
outw(~STR_WREN, io + IO_MASK);
outw((card->muted = ctrl->value ) ?
STR_WREN : 0, io);
udelay(4);
outw(omask, io + IO_MASK);
msleep(125);
return 0;
}
return -EINVAL;
}
mutex_lock(&card->lock); static int vidioc_g_audio(struct file *file, void *priv,
ret = video_usercopy(inode, file, cmd, arg, radio_function); struct v4l2_audio *a)
mutex_unlock(&card->lock); {
if (a->index > 1)
return -EINVAL;
return ret; strcpy(a->name, "Radio");
a->capability = V4L2_AUDCAP_STEREO;
return 0;
}
static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
{
*i = 0;
return 0;
}
static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
{
if (i != 0)
return -EINVAL;
return 0;
}
static int vidioc_s_audio(struct file *file, void *priv,
struct v4l2_audio *a)
{
if (a->index != 0)
return -EINVAL;
return 0;
} }
static u16 __devinit radio_power_on(struct radio_device *dev) static u16 __devinit radio_power_on(struct radio_device *dev)
...@@ -352,6 +354,24 @@ static u16 __devinit radio_power_on(struct radio_device *dev) ...@@ -352,6 +354,24 @@ static u16 __devinit radio_power_on(struct radio_device *dev)
return (ofreq == radio_bits_get(dev)); return (ofreq == radio_bits_get(dev));
} }
static struct video_device maestro_radio = {
.name = "Maestro radio",
.type = VID_TYPE_TUNER,
.fops = &maestro_fops,
.vidioc_querycap = vidioc_querycap,
.vidioc_g_tuner = vidioc_g_tuner,
.vidioc_s_tuner = vidioc_s_tuner,
.vidioc_g_audio = vidioc_g_audio,
.vidioc_s_audio = vidioc_s_audio,
.vidioc_g_input = vidioc_g_input,
.vidioc_s_input = vidioc_s_input,
.vidioc_g_frequency = vidioc_g_frequency,
.vidioc_s_frequency = vidioc_s_frequency,
.vidioc_queryctrl = vidioc_queryctrl,
.vidioc_g_ctrl = vidioc_g_ctrl,
.vidioc_s_ctrl = vidioc_s_ctrl,
};
static int __devinit maestro_probe(struct pci_dev *pdev, static int __devinit maestro_probe(struct pci_dev *pdev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
......
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