On Mon, Jun 07, 2021 at 10:17:35PM +0200, Ricardo Ribalda Delgado wrote: > Maybe you want to handle this with a quirk? I suspect that some > devices might work differently with this patches? Furthermore, for the affected devices, shouldn't the driver cache the value of the control and apply it only after starting streaming ? Otherwise a V4L2_S_CTRL() with a new value before streaming will break the device. > On Sun, Jun 6, 2021 at 3:36 PM Hans Petter Selasky <hps@xxxxxxxxxxx> wrote: > > > > Hi, > > > > Some USB video class compliant devices, like Genesys Logic camera chips, > > used in cheap microscopes, doesn't provide any image if there are UVC > > SET current value commands for the processing unit, before the camera > > stream is activated. Fix this by not issuing any UVC SET current value > > commands, if the value was not changed. This should also work fine with > > existing UVC compliant webcams and optimized the number of needed > > processing unit control endpoint requests. > > > > Signed-off-by: Hans Petter Selasky <hps@xxxxxxxxxxx> > > > > diff --git a/drivers/media/usb/uvc/uvc_ctrl.c > > b/drivers/media/usb/uvc/uvc_ctrl.c > > index b3dde98499f4..0d7137eca331 100644 > > --- a/drivers/media/usb/uvc/uvc_ctrl.c > > +++ b/drivers/media/usb/uvc/uvc_ctrl.c > > @@ -1697,7 +1697,13 @@ int uvc_ctrl_set(struct uvc_fh *handle, > > if (ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS) > > ctrl->handle = handle; > > > > - ctrl->dirty = 1; > > + /* Avoid setting the current value. */ > > + if (!ctrl->dirty && > > + memcmp(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_BACKUP), > > + uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), > > + ctrl->info.size) != 0) > > + ctrl->dirty = 1; > > + > > ctrl->modified = 1; > > return 0; > > } -- Regards, Laurent Pinchart