]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/media/video/uvc/uvc_ctrl.c
V4L/DVB: uvcvideo: Power line frequency control doesn't support GET_MIN/MAX/RES
[net-next-2.6.git] / drivers / media / video / uvc / uvc_ctrl.c
index 6d3850b37161ed21914deb4f06c7569f549a68ee..27a79f087b15c565004f44f14631be68ff78b890 100644 (file)
@@ -122,8 +122,8 @@ static struct uvc_control_info uvc_ctrls[] = {
                .selector       = UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
                .index          = 10,
                .size           = 1,
-               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
-                               | UVC_CONTROL_RESTORE,
+               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
+                               | UVC_CONTROL_GET_DEF | UVC_CONTROL_RESTORE,
        },
        {
                .entity         = UVC_GUID_UVC_PROCESSING,
@@ -217,8 +217,7 @@ static struct uvc_control_info uvc_ctrls[] = {
                .selector       = UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL,
                .index          = 4,
                .size           = 1,
-               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
-                               | UVC_CONTROL_RESTORE,
+               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_RESTORE,
        },
        {
                .entity         = UVC_GUID_UVC_CAMERA,
@@ -233,8 +232,9 @@ static struct uvc_control_info uvc_ctrls[] = {
                .selector       = UVC_CT_FOCUS_RELATIVE_CONTROL,
                .index          = 6,
                .size           = 2,
-               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
-                               | UVC_CONTROL_AUTO_UPDATE,
+               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_MIN
+                               | UVC_CONTROL_GET_MAX | UVC_CONTROL_GET_RES
+                               | UVC_CONTROL_GET_DEF | UVC_CONTROL_AUTO_UPDATE,
        },
        {
                .entity         = UVC_GUID_UVC_CAMERA,
@@ -249,8 +249,7 @@ static struct uvc_control_info uvc_ctrls[] = {
                .selector       = UVC_CT_IRIS_RELATIVE_CONTROL,
                .index          = 8,
                .size           = 1,
-               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
-                               | UVC_CONTROL_AUTO_UPDATE,
+               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_AUTO_UPDATE,
        },
        {
                .entity         = UVC_GUID_UVC_CAMERA,
@@ -265,8 +264,9 @@ static struct uvc_control_info uvc_ctrls[] = {
                .selector       = UVC_CT_ZOOM_RELATIVE_CONTROL,
                .index          = 10,
                .size           = 3,
-               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
-                               | UVC_CONTROL_AUTO_UPDATE,
+               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_MIN
+                               | UVC_CONTROL_GET_MAX | UVC_CONTROL_GET_RES
+                               | UVC_CONTROL_GET_DEF | UVC_CONTROL_AUTO_UPDATE,
        },
        {
                .entity         = UVC_GUID_UVC_CAMERA,
@@ -281,8 +281,9 @@ static struct uvc_control_info uvc_ctrls[] = {
                .selector       = UVC_CT_PANTILT_RELATIVE_CONTROL,
                .index          = 12,
                .size           = 4,
-               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
-                               | UVC_CONTROL_AUTO_UPDATE,
+               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_MIN
+                               | UVC_CONTROL_GET_MAX | UVC_CONTROL_GET_RES
+                               | UVC_CONTROL_GET_DEF | UVC_CONTROL_AUTO_UPDATE,
        },
        {
                .entity         = UVC_GUID_UVC_CAMERA,
@@ -297,8 +298,9 @@ static struct uvc_control_info uvc_ctrls[] = {
                .selector       = UVC_CT_ROLL_RELATIVE_CONTROL,
                .index          = 14,
                .size           = 2,
-               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
-                               | UVC_CONTROL_AUTO_UPDATE,
+               .flags          = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_MIN
+                               | UVC_CONTROL_GET_MAX | UVC_CONTROL_GET_RES
+                               | UVC_CONTROL_GET_DEF | UVC_CONTROL_AUTO_UPDATE,
        },
        {
                .entity         = UVC_GUID_UVC_CAMERA,
@@ -561,6 +563,26 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
                .v4l2_type      = V4L2_CTRL_TYPE_BOOLEAN,
                .data_type      = UVC_CTRL_DATA_TYPE_BOOLEAN,
        },
+       {
+               .id             = V4L2_CID_IRIS_ABSOLUTE,
+               .name           = "Iris, Absolute",
+               .entity         = UVC_GUID_UVC_CAMERA,
+               .selector       = UVC_CT_IRIS_ABSOLUTE_CONTROL,
+               .size           = 16,
+               .offset         = 0,
+               .v4l2_type      = V4L2_CTRL_TYPE_INTEGER,
+               .data_type      = UVC_CTRL_DATA_TYPE_UNSIGNED,
+       },
+       {
+               .id             = V4L2_CID_IRIS_RELATIVE,
+               .name           = "Iris, Relative",
+               .entity         = UVC_GUID_UVC_CAMERA,
+               .selector       = UVC_CT_IRIS_RELATIVE_CONTROL,
+               .size           = 8,
+               .offset         = 0,
+               .v4l2_type      = V4L2_CTRL_TYPE_INTEGER,
+               .data_type      = UVC_CTRL_DATA_TYPE_SIGNED,
+       },
        {
                .id             = V4L2_CID_ZOOM_ABSOLUTE,
                .name           = "Zoom, Absolute",
@@ -822,6 +844,8 @@ int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
        strlcpy(v4l2_ctrl->name, mapping->name, sizeof v4l2_ctrl->name);
        v4l2_ctrl->flags = 0;
 
+       if (!(ctrl->info->flags & UVC_CONTROL_GET_CUR))
+               v4l2_ctrl->flags |= V4L2_CTRL_FLAG_WRITE_ONLY;
        if (!(ctrl->info->flags & UVC_CONTROL_SET_CUR))
                v4l2_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
@@ -1047,6 +1071,8 @@ int uvc_ctrl_set(struct uvc_video_chain *chain,
                                   uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MAX));
                step = mapping->get(mapping, UVC_GET_RES,
                                    uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES));
+               if (step == 0)
+                       step = 1;
 
                xctrl->value = min + (xctrl->value - min + step/2) / step * step;
                xctrl->value = clamp(xctrl->value, min, max);