diff options
author | Thierry Reding <thierry.reding@avionic-design.de> | 2011-08-04 04:14:13 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-08-31 17:21:23 -0300 |
commit | dd0c8abf2ac853dad9a360f5e9d3d1cb5e5f7621 (patch) | |
tree | 616d21ad6e4b85e9692f3875dc8144711f94687b /drivers | |
parent | 88e834a841bde22b4c0aa71809e02c118c5b219d (diff) | |
download | linux-dd0c8abf2ac853dad9a360f5e9d3d1cb5e5f7621.tar.bz2 |
[media] tm6000: Execute lightweight reset on close
When the last user closes the device, perform a lightweight reset of the
device to bring it into a well-known state.
Note that this is not always enough with the TM6010, which sometimes
needs a hard reset to get into a working state again.
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/tm6000/tm6000-core.c | 43 | ||||
-rw-r--r-- | drivers/staging/tm6000/tm6000-video.c | 7 | ||||
-rw-r--r-- | drivers/staging/tm6000/tm6000.h | 1 |
3 files changed, 51 insertions, 0 deletions
diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c index 31fdf15477e1..9cef1d11a01e 100644 --- a/drivers/staging/tm6000/tm6000-core.c +++ b/drivers/staging/tm6000/tm6000-core.c @@ -599,6 +599,49 @@ int tm6000_init(struct tm6000_core *dev) return rc; } +int tm6000_reset(struct tm6000_core *dev) +{ + int pipe; + int err; + + msleep(500); + + err = usb_set_interface(dev->udev, dev->isoc_in.bInterfaceNumber, 0); + if (err < 0) { + tm6000_err("failed to select interface %d, alt. setting 0\n", + dev->isoc_in.bInterfaceNumber); + return err; + } + + err = usb_reset_configuration(dev->udev); + if (err < 0) { + tm6000_err("failed to reset configuration\n"); + return err; + } + + msleep(5); + + err = usb_set_interface(dev->udev, dev->isoc_in.bInterfaceNumber, 2); + if (err < 0) { + tm6000_err("failed to select interface %d, alt. setting 2\n", + dev->isoc_in.bInterfaceNumber); + return err; + } + + msleep(5); + + pipe = usb_rcvintpipe(dev->udev, + dev->int_in.endp->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); + + err = usb_clear_halt(dev->udev, pipe); + if (err < 0) { + tm6000_err("usb_clear_halt failed: %d\n", err); + return err; + } + + return 0; +} + int tm6000_set_audio_bitrate(struct tm6000_core *dev, int bitrate) { int val = 0; diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c index 873c8ee8b3ba..df8e25301d2f 100644 --- a/drivers/staging/tm6000/tm6000-video.c +++ b/drivers/staging/tm6000/tm6000-video.c @@ -1603,9 +1603,16 @@ static int tm6000_release(struct file *file) dev->users--; res_free(dev, fh); + if (!dev->users) { + int err; + tm6000_uninit_isoc(dev); videobuf_mmap_free(&fh->vb_vidq); + + err = tm6000_reset(dev); + if (err < 0) + dev_err(&vdev->dev, "reset failed: %d\n", err); } kfree(fh); diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h index cf57e1e3aa62..dac20637c696 100644 --- a/drivers/staging/tm6000/tm6000.h +++ b/drivers/staging/tm6000/tm6000.h @@ -311,6 +311,7 @@ int tm6000_set_reg_mask(struct tm6000_core *dev, u8 req, u16 value, u16 index, u16 mask); int tm6000_i2c_reset(struct tm6000_core *dev, u16 tsleep); int tm6000_init(struct tm6000_core *dev); +int tm6000_reset(struct tm6000_core *dev); int tm6000_init_analog_mode(struct tm6000_core *dev); int tm6000_init_digital_mode(struct tm6000_core *dev); |