summaryrefslogtreecommitdiff
path: root/drivers/media/usb/uvc/uvc_v4l2.c
AgeCommit message (Collapse)Author
2013-06-08[media] uvcvideo: Fix open/close race conditionLaurent Pinchart
Maintaining the users count using an atomic variable makes sure that access to the counter won't be racy, but doesn't serialize access to the operations protected by the counter. This creates a race condition that could result in the status URB being submitted multiple times. Use a mutex to protect the users count and serialize access to the status start and stop operations. Reported-by: Shawn Nematbakhsh <shawnn@chromium.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-02-05[media] uvcvideo: Fix race of open and suspend in error caseOliver Neukum
Ming Lei reported: IMO, there is a minor fault in the error handling path of uvc_status_start() inside uvc_v4l2_open(), and the 'users' count should have been decreased before usb_autopm_put_interface(). In theory, a [URB resubmission] warning can be triggered when the device is opened just between usb_autopm_put_interface() and atomic_dec(&stream->dev->users). The fix is trivial. Reported-by: Ming Lei <tom.leiming@gmail.com> Signed-off-by: Oliver Neukum <oneukum@suse.de> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-02-05[media] uvcvideo: Replace memcpy with struct assignmentEzequiel Garcia
This kind of memcpy() is error-prone. Its replacement with a struct assignment is prefered because it's type-safe and much easier to read. Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-01-11[media] uvcvideo: Set error_idx properly for S_EXT_CTRLS failuresLaurent Pinchart
The uvc_set_ctrl() calls don't write to the hardware. A failure at that point thus leaves the device in a clean state, with no control modified. Set the error_idx field to the count value to reflect that, as per the V4L2 specification. TRY_EXT_CTRLS is unchanged and the error_idx field must always be set to the failed control index in that case. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-01-11[media] uvcvideo: Cleanup leftovers of partial revertLaurent Pinchart
Commit ba68c8530a263dc4de440fa10bb20a1c5b9d4ff5 (Partly revert "[media] uvcvideo: Set error_idx properly for extended controls API failures") missed two modifications. Clean them up. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-23Partly revert "[media] uvcvideo: Set error_idx properly for extended ↵Rafael J. Wysocki
controls API failures" Commit f0ed2ce840b3 ("[media] uvcvideo: Set error_idx properly for extended controls API failures") causes user space to behave incorrectly on one of my test machines (there is no sound under KDE 4.9.4 using pulseaudio and there is a knotify4 process occupying one of the CPU cores 100% of the time). Reverting that commit entirely fixes the problem for me. However, commit f0ed2ce840b3 appears to do more than it follows from its changelog, because the changelog only says about the changes related to ctrls->error_idx, while the commit additionally changes error codes returned by various functions in uvc_ctrl.c and uvc_v4l2.c. It turns out that the changes of the returned error codes confuse the user spce, so it is sufficient to revert the part of commit f0ed2ce840b3 not mentioned in its changelog to fix the problem. [ 'ENOENT' is not a valid error return from an ioctl to begin with, and I don't understand how anybody ever even thought it would be. - Linus ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: Mauro Carvalho Chehab <mchehab@redhat.com> Cc: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-11-28[media] uvcvideo: Add VIDIOC_[GS]_PRIORITY supportLaurent Pinchart
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-28[media] uvcvideo: Return -ENOTTY for unsupported ioctlsLaurent Pinchart
The proper error code is -ENOTTY instead of -EINVAL. This issue was found by the v4l2-compliance tool. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-28[media] uvcvideo: Set device_caps in VIDIOC_QUERYCAPLaurent Pinchart
Set the capabilities field to global capabilities, and the device_caps field to the video node capabilities. This issue was found by the v4l2-compliance tool. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-28[media] uvcvideo: Don't fail when an unsupported format is requestedLaurent Pinchart
Return the default format in that case. This issue was found by the v4l2-compliance tool. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-28[media] uvcvideo: Set error_idx properly for extended controls API failuresLaurent Pinchart
When one of the requested controls doesn't exist the error_idx field must reflect that situation. For G_EXT_CTRLS and S_EXT_CTRLS, error_idx must be set to the control count. For TRY_EXT_CTRLS, it must be set to the index of the unexisting control. This issue was found by the v4l2-compliance tool. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-08-15[media] rename most media/video usb drivers to media/usbMauro Carvalho Chehab
Rename all USB drivers with their own directory under drivers/media/video into drivers/media/usb and update the building system. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>