Commit 06470ed6 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

V4L/DVB (5149): Convert radio-maxiradio to use video_ioctl2

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 99218fe4
......@@ -27,7 +27,9 @@
* BUGS:
* - card unmutes if you change frequency
*
* Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
* (c) 2006, 2007 by Mauro Carvalho Chehab <mchehab@infradead.org>:
* - Conversion to V4L2 API
* - Uses video_ioctl2 for parsing and to add debug support
*/
......@@ -87,24 +89,14 @@ module_param(radio_nr, int, 0);
#define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF)
static int radio_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);
static const struct file_operations maxiradio_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
.release = video_exclusive_release,
.ioctl = radio_ioctl,
.ioctl = video_ioctl2,
.compat_ioctl = v4l_compat_ioctl32,
.llseek = no_llseek,
};
static struct video_device maxiradio_radio =
{
.owner = THIS_MODULE,
.name = "Maxi Radio FM2000 radio",
.type = VID_TYPE_TUNER,
.fops = &maxiradio_fops,
};
static struct radio_device
{
......@@ -181,17 +173,9 @@ static int get_tune(__u16 io)
}
static inline int radio_function(struct inode *inode, struct file *file,
unsigned int cmd, void *arg)
static int vidioc_querycap (struct file *file, void *priv,
struct v4l2_capability *v)
{
struct video_device *dev = video_devdata(file);
struct radio_device *card=dev->priv;
switch(cmd) {
case VIDIOC_QUERYCAP:
{
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");
......@@ -199,10 +183,13 @@ static inline int radio_function(struct inode *inode, struct file *file,
v->capabilities = V4L2_CAP_TUNER;
return 0;
}
case VIDIOC_G_TUNER:
{
struct v4l2_tuner *v = arg;
}
static int vidioc_g_tuner (struct file *file, void *priv,
struct v4l2_tuner *v)
{
struct video_device *dev = video_devdata(file);
struct radio_device *card=dev->priv;
if (v->index > 0)
return -EINVAL;
......@@ -222,19 +209,22 @@ static inline int radio_function(struct inode *inode, struct file *file,
v->signal=0xffff*get_tune(card->io);
return 0;
}
case VIDIOC_S_TUNER:
{
struct v4l2_tuner *v = arg;
}
static int vidioc_s_tuner (struct file *file, void *priv,
struct v4l2_tuner *v)
{
if (v->index > 0)
return -EINVAL;
return 0;
}
case VIDIOC_S_FREQUENCY:
{
struct v4l2_frequency *f = arg;
}
static int vidioc_s_frequency (struct file *file, void *priv,
struct v4l2_frequency *f)
{
struct video_device *dev = video_devdata(file);
struct radio_device *card=dev->priv;
if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
return -EINVAL;
......@@ -242,34 +232,41 @@ static inline int radio_function(struct inode *inode, struct file *file,
card->freq = f->frequency;
set_freq(card->io, FREQ2BITS(card->freq));
msleep(125);
return 0;
}
case VIDIOC_G_FREQUENCY:
{
struct v4l2_frequency *f = arg;
}
static int vidioc_g_frequency (struct file *file, void *priv,
struct v4l2_frequency *f)
{
struct video_device *dev = video_devdata(file);
struct radio_device *card=dev->priv;
f->type = V4L2_TUNER_RADIO;
f->frequency = card->freq;
return 0;
}
case VIDIOC_QUERYCTRL:
{
struct v4l2_queryctrl *qc = arg;
}
static int vidioc_queryctrl (struct file *file, void *priv,
struct v4l2_queryctrl *qc)
{
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));
memcpy(qc, &(radio_qctrl[i]), sizeof(*qc));
return (0);
}
}
return -EINVAL;
}
case VIDIOC_G_CTRL:
{
struct v4l2_control *ctrl= arg;
}
static int vidioc_g_ctrl (struct file *file, void *priv,
struct v4l2_control *ctrl)
{
struct video_device *dev = video_devdata(file);
struct radio_device *card=dev->priv;
switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
......@@ -277,10 +274,13 @@ static inline int radio_function(struct inode *inode, struct file *file,
return (0);
}
return -EINVAL;
}
case VIDIOC_S_CTRL:
{
struct v4l2_control *ctrl= arg;
}
static int vidioc_s_ctrl (struct file *file, void *priv,
struct v4l2_control *ctrl)
{
struct video_device *dev = video_devdata(file);
struct radio_device *card=dev->priv;
switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
......@@ -292,32 +292,25 @@ static inline int radio_function(struct inode *inode, struct file *file,
return 0;
}
return -EINVAL;
}
default:
return v4l_compat_translate_ioctl(inode,file,cmd,arg,
radio_function);
}
}
static int radio_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
static struct video_device maxiradio_radio =
{
struct video_device *dev = video_devdata(file);
struct radio_device *card=dev->priv;
int ret;
mutex_lock(&card->lock);
ret = video_usercopy(inode, file, cmd, arg, radio_function);
mutex_unlock(&card->lock);
return ret;
}
.owner = THIS_MODULE,
.name = "Maxi Radio FM2000 radio",
.type = VID_TYPE_TUNER,
.fops = &maxiradio_fops,
MODULE_AUTHOR("Dimitromanolakis Apostolos, apdim@grecian.net");
MODULE_DESCRIPTION("Radio driver for the Guillemot Maxi Radio FM2000 radio.");
MODULE_LICENSE("GPL");
.vidioc_querycap = vidioc_querycap,
.vidioc_g_tuner = vidioc_g_tuner,
.vidioc_s_tuner = vidioc_s_tuner,
.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 maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
......@@ -389,3 +382,10 @@ static void __exit maxiradio_radio_exit(void)
module_init(maxiradio_radio_init);
module_exit(maxiradio_radio_exit);
MODULE_AUTHOR("Dimitromanolakis Apostolos, apdim@grecian.net");
MODULE_DESCRIPTION("Radio driver for the Guillemot Maxi Radio FM2000 radio.");
MODULE_LICENSE("GPL");
module_param_named(debug,maxiradio_radio.debug, int, 0644);
MODULE_PARM_DESC(debug,"activates debug info");
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