diff options
Diffstat (limited to 'drivers/media/usb/au0828/au0828-video.c')
-rw-r--r-- | drivers/media/usb/au0828/au0828-video.c | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 9038194513c5..98f7ea1d6d63 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -787,23 +787,40 @@ static int au0828_i2s_init(struct au0828_dev *dev) /* * Auvitek au0828 analog stream enable - * Please set interface0 to AS5 before enable the stream */ static int au0828_analog_stream_enable(struct au0828_dev *d) { + struct usb_interface *iface; + int ret, h, w; + dprintk(1, "au0828_analog_stream_enable called\n"); + + iface = usb_ifnum_to_if(d->usbdev, 0); + if (iface && iface->cur_altsetting->desc.bAlternateSetting != 5) { + dprintk(1, "Changing intf#0 to alt 5\n"); + /* set au0828 interface0 to AS5 here again */ + ret = usb_set_interface(d->usbdev, 0, 5); + if (ret < 0) { + printk(KERN_INFO "Au0828 can't set alt setting to 5!\n"); + return -EBUSY; + } + } + + h = d->height / 2 + 2; + w = d->width * 2; + au0828_writereg(d, AU0828_SENSORCTRL_VBI_103, 0x00); au0828_writereg(d, 0x106, 0x00); /* set x position */ au0828_writereg(d, 0x110, 0x00); au0828_writereg(d, 0x111, 0x00); - au0828_writereg(d, 0x114, 0xa0); - au0828_writereg(d, 0x115, 0x05); + au0828_writereg(d, 0x114, w & 0xff); + au0828_writereg(d, 0x115, w >> 8); /* set y position */ au0828_writereg(d, 0x112, 0x00); au0828_writereg(d, 0x113, 0x00); - au0828_writereg(d, 0x116, 0xf2); - au0828_writereg(d, 0x117, 0x00); + au0828_writereg(d, 0x116, h & 0xff); + au0828_writereg(d, 0x117, h >> 8); au0828_writereg(d, AU0828_SENSORCTRL_100, 0xb3); return 0; @@ -1002,15 +1019,6 @@ static int au0828_v4l2_open(struct file *filp) return -ERESTARTSYS; } if (dev->users == 0) { - /* set au0828 interface0 to AS5 here again */ - ret = usb_set_interface(dev->usbdev, 0, 5); - if (ret < 0) { - mutex_unlock(&dev->lock); - printk(KERN_INFO "Au0828 can't set alternate to 5!\n"); - kfree(fh); - return -EBUSY; - } - au0828_analog_stream_enable(dev); au0828_analog_stream_reset(dev); @@ -1252,13 +1260,6 @@ static int au0828_set_format(struct au0828_dev *dev, unsigned int cmd, } } - /* set au0828 interface0 to AS5 here again */ - ret = usb_set_interface(dev->usbdev, 0, 5); - if (ret < 0) { - printk(KERN_INFO "Au0828 can't set alt setting to 5!\n"); - return -EBUSY; - } - au0828_analog_stream_enable(dev); return 0; @@ -1364,9 +1365,11 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm) i2c_gate_ctrl(dev, 1); - /* FIXME: when we support something other than NTSC, we are going to - have to make the au0828 bridge adjust the size of its capture - buffer, which is currently hardcoded at 720x480 */ + /* + * FIXME: when we support something other than 60Hz standards, + * we are going to have to make the au0828 bridge adjust the size + * of its capture buffer, which is currently hardcoded at 720x480 + */ v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_std, norm); @@ -1723,6 +1726,7 @@ static int vidioc_streamoff(struct file *file, void *priv, dev->vid_timeout_running = 0; del_timer_sync(&dev->vid_timeout); + au0828_analog_stream_disable(dev); v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0); rc = au0828_stream_interrupt(dev); if (rc != 0) @@ -1915,7 +1919,7 @@ static const struct video_device au0828_video_template = { .fops = &au0828_v4l_fops, .release = video_device_release, .ioctl_ops = &video_ioctl_ops, - .tvnorms = V4L2_STD_NTSC_M, + .tvnorms = V4L2_STD_NTSC_M | V4L2_STD_PAL_M, }; /**************************************************************************/ @@ -1928,7 +1932,8 @@ int au0828_analog_register(struct au0828_dev *dev, struct usb_endpoint_descriptor *endpoint; int i, ret; - dprintk(1, "au0828_analog_register called!\n"); + dprintk(1, "au0828_analog_register called for intf#%d!\n", + interface->cur_altsetting->desc.bInterfaceNumber); /* set au0828 usb interface0 to as5 */ retval = usb_set_interface(dev->usbdev, @@ -1952,6 +1957,9 @@ int au0828_analog_register(struct au0828_dev *dev, dev->max_pkt_size = (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); dev->isoc_in_endpointaddr = endpoint->bEndpointAddress; + dprintk(1, + "Found isoc endpoint 0x%02x, max size = %d\n", + dev->isoc_in_endpointaddr, dev->max_pkt_size); } } if (!(dev->isoc_in_endpointaddr)) { @@ -2008,14 +2016,12 @@ int au0828_analog_register(struct au0828_dev *dev, *dev->vdev = au0828_video_template; dev->vdev->v4l2_dev = &dev->v4l2_dev; dev->vdev->lock = &dev->lock; - set_bit(V4L2_FL_USE_FH_PRIO, &dev->vdev->flags); strcpy(dev->vdev->name, "au0828a video"); /* Setup the VBI device */ *dev->vbi_dev = au0828_video_template; dev->vbi_dev->v4l2_dev = &dev->v4l2_dev; dev->vbi_dev->lock = &dev->lock; - set_bit(V4L2_FL_USE_FH_PRIO, &dev->vbi_dev->flags); strcpy(dev->vbi_dev->name, "au0828a vbi"); /* Register the v4l2 device */ |