[media] uvcvideo: Ignore GET_RES error for XU controls
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Thu, 30 Sep 2010 12:04:03 +0000 (09:04 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 11 Dec 2011 13:15:01 +0000 (11:15 -0200)
GET_RES request support is mandatory for extension units, but some
cameras still choke on it (one example is the Logitech QuickCam PTZ that
returns a single byte for the PTZ relative control instead of four).

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/uvc/uvc_ctrl.c
drivers/media/video/uvc/uvcvideo.h

index 254d32688843bdc3f0a38a782e13fef2ec8d5a18..3e849d977bd4b2fc8bf0acd66ef964be92b8a9fe 100644 (file)
@@ -878,8 +878,21 @@ static int uvc_ctrl_populate_cache(struct uvc_video_chain *chain,
                                     chain->dev->intfnum, ctrl->info.selector,
                                     uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES),
                                     ctrl->info.size);
-               if (ret < 0)
-                       return ret;
+               if (ret < 0) {
+                       if (UVC_ENTITY_TYPE(ctrl->entity) !=
+                           UVC_VC_EXTENSION_UNIT)
+                               return ret;
+
+                       /* GET_RES is mandatory for XU controls, but some
+                        * cameras still choke on it. Ignore errors and set the
+                        * resolution value to zero.
+                        */
+                       uvc_warn_once(chain->dev, UVC_WARN_XU_GET_RES,
+                                     "UVC non compliance - GET_RES failed on "
+                                     "an XU control. Enabling workaround.\n");
+                       memset(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES), 0,
+                              ctrl->info.size);
+               }
        }
 
        ctrl->cached = 1;
index 882159aab610dfe8f6163cee229a3c513f845ab8..2b84cbb49665aa807d84d57fc93ee56e2a78e681 100644 (file)
@@ -477,6 +477,7 @@ struct uvc_driver {
 
 #define UVC_WARN_MINMAX                0
 #define UVC_WARN_PROBE_DEF     1
+#define UVC_WARN_XU_GET_RES    2
 
 extern unsigned int uvc_clock_param;
 extern unsigned int uvc_no_drop_param;