diff options
author | Thierry MERLE <thierry.merle@free.fr> | 2007-05-02 23:43:55 +0200 |
---|---|---|
committer | Thierry MERLE <thierry.merle@free.fr> | 2007-05-02 23:43:55 +0200 |
commit | c51cba09e36c2d42943277fde19a035512fdfcb2 (patch) | |
tree | 7592eac45a4cde89126f2d433c42300f7d16b323 /linux/drivers/media/video/usbvision | |
parent | 3a13092e3270b919e5ac73ad8dde0044b23b07e0 (diff) | |
download | mediapointer-dvb-s2-c51cba09e36c2d42943277fde19a035512fdfcb2.tar.gz mediapointer-dvb-s2-c51cba09e36c2d42943277fde19a035512fdfcb2.tar.bz2 |
usbvision: make common video and radio ioctls
From: Thierry MERLE <thierry.merle@free.fr>
Radio and video ioctls are the same,
delete the usbvision_do_radio_ioctl function
add the special cases for radio in usbvision_v4l2_do_ioctl
Signed-off-by: Thierry MERLE <thierry.merle@free.fr>
Diffstat (limited to 'linux/drivers/media/video/usbvision')
-rw-r--r-- | linux/drivers/media/video/usbvision/usbvision-video.c | 166 |
1 files changed, 22 insertions, 144 deletions
diff --git a/linux/drivers/media/video/usbvision/usbvision-video.c b/linux/drivers/media/video/usbvision/usbvision-video.c index 6a32c1479..bd31d57c1 100644 --- a/linux/drivers/media/video/usbvision/usbvision-video.c +++ b/linux/drivers/media/video/usbvision/usbvision-video.c @@ -733,11 +733,18 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file, if (!usbvision->have_tuner || vt->index) // Only tuner 0 return -EINVAL; - strcpy(vt->name, "Television"); + if(usbvision->radio) { + strcpy(vt->name, "Radio"); + vt->type = V4L2_TUNER_RADIO; + } + else { + strcpy(vt->name, "Television"); + } /* Let clients fill in the remainder of this struct */ call_i2c_clients(usbvision,VIDIOC_G_TUNER,vt); - PDEBUG(DBG_IOCTL, "VIDIOC_G_TUNER signal=%x, afc=%x",vt->signal,vt->afc); + PDEBUG(DBG_IOCTL, "VIDIOC_G_TUNER for %s signal=%x, afc=%x", + vt->name, vt->signal,vt->afc); return 0; } case VIDIOC_S_TUNER: @@ -758,7 +765,12 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file, struct v4l2_frequency *freq = arg; freq->tuner = 0; // Only one tuner - freq->type = V4L2_TUNER_ANALOG_TV; + if(usbvision->radio) { + freq->type = V4L2_TUNER_RADIO; + } + else { + freq->type = V4L2_TUNER_ANALOG_TV; + } freq->frequency = usbvision->freq; PDEBUG(DBG_IOCTL, "VIDIOC_G_FREQUENCY freq=0x%X", (unsigned)freq->frequency); return 0; @@ -780,7 +792,12 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file, { struct v4l2_audio *v = arg; memset(v,0, sizeof(v)); - strcpy(v->name, "TV"); + if(usbvision->radio) { + strcpy(v->name,"Radio"); + } + else { + strcpy(v->name, "TV"); + } PDEBUG(DBG_IOCTL, "VIDIOC_G_AUDIO"); return 0; } @@ -1280,7 +1297,6 @@ static int usbvision_radio_open(struct inode *inode, struct file *file) struct video_device *dev = video_devdata(file); struct usb_usbvision *usbvision = (struct usb_usbvision *) video_get_drvdata(dev); #endif - struct v4l2_frequency freq; int errCode = 0; PDEBUG(DBG_IO, "%s:", __FUNCTION__); @@ -1313,8 +1329,6 @@ static int usbvision_radio_open(struct inode *inode, struct file *file) // If so far no errors then we shall start the radio usbvision->radio = 1; call_i2c_clients(usbvision,AUDC_SET_RADIO,&usbvision->tuner_type); - freq.frequency = 1517; //SWR3 @ 94.8MHz - call_i2c_clients(usbvision, VIDIOC_S_FREQUENCY, &freq); usbvision_set_audio(usbvision, USBVISION_AUDIO_RADIO); usbvision->user++; } @@ -1382,146 +1396,10 @@ static int usbvision_radio_close(struct inode *inode, struct file *file) #endif } -static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, void *arg) -{ - struct video_device *dev = video_devdata(file); - struct usb_usbvision *usbvision = (struct usb_usbvision *) video_get_drvdata(dev); - - if (!USBVISION_IS_OPERATIONAL(usbvision)) - return -EIO; - - switch (cmd) { - case VIDIOC_QUERYCAP: - { - struct v4l2_capability *vc=arg; - - memset(vc, 0, sizeof(*vc)); - strlcpy(vc->driver, "USBVision", sizeof(vc->driver)); - strlcpy(vc->card, usbvision_device_data[usbvision->DevModel].ModelString, - sizeof(vc->card)); - strlcpy(vc->bus_info, usbvision->dev->dev.bus_id, - sizeof(vc->bus_info)); - vc->version = USBVISION_DRIVER_VERSION; - vc->capabilities = (usbvision->have_tuner ? V4L2_CAP_TUNER : 0); - PDEBUG(DBG_IO, "VIDIOC_QUERYCAP"); - return 0; - } - case VIDIOC_QUERYCTRL: - { - struct v4l2_queryctrl *ctrl = arg; - int id=ctrl->id; - - memset(ctrl,0,sizeof(*ctrl)); - ctrl->id=id; - - call_i2c_clients(usbvision, cmd, arg); - PDEBUG(DBG_IO,"VIDIOC_QUERYCTRL id=%x value=%x",ctrl->id,ctrl->type); - - if (ctrl->type) - return 0; - else - return -EINVAL; - - } - case VIDIOC_G_CTRL: - { - struct v4l2_control *ctrl = arg; - - call_i2c_clients(usbvision, VIDIOC_G_CTRL, ctrl); - PDEBUG(DBG_IO,"VIDIOC_G_CTRL id=%x value=%x",ctrl->id,ctrl->value); - return 0; - } - case VIDIOC_S_CTRL: - { - struct v4l2_control *ctrl = arg; - - call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl); - PDEBUG(DBG_IO, "VIDIOC_S_CTRL id=%x value=%x",ctrl->id,ctrl->value); - return 0; - } - case VIDIOC_G_TUNER: - { - struct v4l2_tuner *t = arg; - - if (t->index > 0) - return -EINVAL; - - memset(t,0,sizeof(*t)); - strcpy(t->name, "Radio"); - t->type = V4L2_TUNER_RADIO; - - /* Let clients fill in the remainder of this struct */ - call_i2c_clients(usbvision,VIDIOC_G_TUNER,t); - PDEBUG(DBG_IO, "VIDIOC_G_TUNER signal=%x, afc=%x",t->signal,t->afc); - return 0; - } - case VIDIOC_S_TUNER: - { - struct v4l2_tuner *vt = arg; - - // Only no or one tuner for now - if (!usbvision->have_tuner || vt->index) - return -EINVAL; - /* let clients handle this */ - call_i2c_clients(usbvision,VIDIOC_S_TUNER,vt); - - PDEBUG(DBG_IO, "VIDIOC_S_TUNER"); - return 0; - } - case VIDIOC_G_AUDIO: - { - struct v4l2_audio *a = arg; - - memset(a,0,sizeof(*a)); - strcpy(a->name,"Radio"); - PDEBUG(DBG_IO, "VIDIOC_G_AUDIO"); - return 0; - } - case VIDIOC_S_AUDIO: - case VIDIOC_S_INPUT: - case VIDIOC_S_STD: - return 0; - - case VIDIOC_G_FREQUENCY: - { - struct v4l2_frequency *f = arg; - - memset(f,0,sizeof(*f)); - - f->type = V4L2_TUNER_RADIO; - f->frequency = usbvision->freq; - call_i2c_clients(usbvision, cmd, f); - PDEBUG(DBG_IO, "VIDIOC_G_FREQUENCY freq=0x%X", (unsigned)f->frequency); - - return 0; - } - case VIDIOC_S_FREQUENCY: - { - struct v4l2_frequency *f = arg; - - if (f->tuner != 0) - return -EINVAL; - usbvision->freq = f->frequency; - call_i2c_clients(usbvision, cmd, f); - PDEBUG(DBG_IO, "VIDIOC_S_FREQUENCY freq=0x%X", (unsigned)f->frequency); - - return 0; - } - default: - { - PDEBUG(DBG_IO, "%s: Unknown command %x", __FUNCTION__, cmd); - return -ENOIOCTLCMD; - } - } - return 0; -} - - static int usbvision_radio_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { - return video_usercopy(inode, file, cmd, arg, usbvision_do_radio_ioctl); + return video_usercopy(inode, file, cmd, arg, usbvision_v4l2_do_ioctl); } |