aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/uvc/uvc_ctrl.c
AgeCommit message (Collapse)Author
2019-07-26media: uvcvideo: Fix access to uninitialized fields on probe errorOliver Neukum
[ Upstream commit 11a087f484bf15ff65f0a9f277aa5a61fd07ed2a ] We need to check whether this work we are canceling actually is initialized. Signed-off-by: Oliver Neukum <oneukum@suse.com> Reported-by: syzbot+2e1ef9188251d9cc7944@syzkaller.appspotmail.com Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-03-27media: v4l2-ctrls.c/uvc: zero v4l2_eventHans Verkuil
commit f45f3f753b0a3d739acda8e311b4f744d82dc52a upstream. Control events can leak kernel memory since they do not fully zero the event. The same code is present in both v4l2-ctrls.c and uvc_ctrl.c, so fix both. It appears that all other event code is properly zeroing the structure, it's these two places. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Reported-by: syzbot+4f021cf3697781dbd9fb@syzkaller.appspotmail.com Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-27media: uvcvideo: Send a control event when a Control Change interrupt arrivesGuennadi Liakhovetski
UVC defines a method of handling asynchronous controls, which sends a USB packet over the interrupt pipe. This patch implements support for such packets by sending a control event to the user. Since this can involve USB traffic and, therefore, scheduling, this has to be done in a work queue. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-27media: uvcvideo: Remove a redundant checkGuennadi Liakhovetski
Event subscribers cannot have a NULL file handle. They are only added at a single location in the code, and the .fh pointer is used without checking there. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-27media: uvcvideo: Fix minor spellingKieran Bingham
Provide the missing 't' from straightforward. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-06-05media: uvcvideo: Prevent setting unavailable flagsKieran Bingham
The addition of an extra operation to use the GET_INFO command overwrites all existing flags from the uvc_ctrls table. This includes setting all controls as supporting GET_MIN, GET_MAX, GET_RES, and GET_DEF regardless of whether they do or not. Move the initialisation of these control capabilities directly to the uvc_ctrl_fill_xu_info() call where they were originally located in that use case, and ensure that the new functionality in uvc_ctrl_get_flags() will only set flags based on their reported capability from the GET_INFO call. Fixes: 859086ae3636 ("media: uvcvideo: Apply flags from device to actual properties") Cc: stable@vger.kernel.org Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-02-23media: uvcvideo: Use parentheses around sizeof operandLaurent Pinchart
While the sizeof is an operator and not a function, the preferred coding style in the kernel is to enclose its operand in parentheses. To avoid mixing multiple coding styles in the driver, use parentheses around all sizeof operands. While at it replace a kmalloc() with a kmalloc_array() to silence a checkpatch warning triggered by this patch. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-23media: uvcvideo: Use internal kernel integer typesLaurent Pinchart
Replace the __[su]{8,16,32} variant of integer types with the non-underscored types as the code is internal to the driver, not exposed to userspace. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-23media: uvcvideo: Apply flags from device to actual propertiesEdgar Thier
Use flags the device exposes for UVC controls. This allows the device to define which property flags are set. Since some cameras offer auto-adjustments for properties (e.g. auto-gain), the values of other properties (e.g. gain) can change in the camera. Examining the flags ensures that the driver is aware of such properties. Signed-off-by: Edgar Thier <info@edgarthier.net> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20media: uvcvideo: Prevent heap overflow when accessing mapped controlsGuenter Roeck
The size of uvc_control_mapping is user controlled leading to a potential heap overflow in the uvc driver. This adds a check to verify the user provided size fits within the bounds of the defined buffer size. Originally-from: Richard Simmons <rssimmo@amazon.com> Cc: stable@vger.kernel.org Signed-off-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2015-12-18[media] uvcvideo: Fix reading the current exposure value of UVCAnton V. Shokurov
V4L2_CID_EXPOSURE_ABSOLUTE property does not return an updated value when autoexposure (V4L2_CID_EXPOSURE_AUTO) is turned on. This patch fixes this issue by adding the UVC_CTRL_FLAG_AUTO_UPDATE flag. Tested on a C920 camera. Signed-off-by: Anton V. Shokurov <shokurov.anton.v@yandex.ru> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-21[media] uvcvideo: Work around buggy Logitech C920 firmwareWilliam Manley
The uvcvideo webcam driver exposes the v4l2 control "Exposure (Absolute)" which allows the user to control the exposure time of the webcam, essentially controlling the brightness of the received image. By default the webcam automatically adjusts the exposure time automatically but the if you set the control "Exposure, Auto"="Manual Mode" the user can fix the exposure time. Unfortunately it seems that the Logitech C920 has a firmware bug where it will forget that it's in manual mode temporarily during initialisation. This means that the camera doesn't respect the exposure time that the user requested if they request it before starting to stream video. They end up with a video stream which is either too bright or too dark and must reset the controls after video starts streaming. This patch introduces the quirk UVC_QUIRK_RESTORE_CTRLS_ON_INIT which causes the cached controls to be re-uploaded to the camera immediately after initialising the camera. This quirk is applied to the C920 to work around this camera bug. Signed-off-by: William Manley <will@williammanley.net> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-21[media] v4l: uvcvideo: Add support for pan/tilt speed controlsVincent Palatin
Map V4L2_CID_TILT_SPEED and V4L2_CID_PAN_SPEED to the standard UVC CT_PANTILT_RELATIVE_CONTROL terminal control request. Tested by plugging a Logitech ConferenceCam C3000e USB camera and controlling pan/tilt from the userspace using the VIDIOC_S_CTRL ioctl. Verified that it can pan and tilt at the same time in both directions. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Pawel Osciak <posciak@chromium.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2013-10-17[media] uvcvideo: Fix data type for pan/tilt controlChanho Min
The pan/tilt absolute control value is signed value. If minimum value is minus, It will be changed to plus by clamp_t() as commit 64ae9958a62. ([media] uvcvideo: Fix control value clamping for unsigned integer controls). It leads to wrong setting of the control values. For example, when min and max are -36000 and 36000, the setting value between of this range is always 36000. So, its data type should be changed to signed. Signed-off-by: Chanho Min <chanho.min@lge.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-03-28[media] uvcvideo: Return -EINVAL when setting a menu control to an invalid valueLaurent Pinchart
-ERANGE is the right error code when the value is outside of the menu range, but -EINVAL must be reported for invalid values inside the range. 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-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: Return -EACCES when trying to set a read-only controlLaurent Pinchart
Commit ba68c8530a263dc4de440fa10bb20a1c5b9d4ff5 (Partly revert "[media] uvcvideo: Set error_idx properly for extended controls API failures") also reverted part of commit 30ecb936cbcd83e3735625ac63e1b4466546f5fe ("uvcvideo: Return -EACCES when trying to access a read/write-only control") by mistake. Fix it. 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: Fix control value clamping for unsigned integer controlsLaurent Pinchart
V4L2 integer controls are stored in signed 32-bit values. However, UVC controls can be either signed or unsigned. Take the UVC control signedness into account when clamping the control value to the min-max range. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-28[media] uvcvideo: Return -EACCES when trying to access a read/write-only controlLaurent Pinchart
The proper return code according to the V4L2 specification is -EACCES, not -EINVAL. 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>