]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/media/v4l2-core/v4l2-ctrls.c
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target...
[karo-tx-linux.git] / drivers / media / v4l2-core / v4l2-ctrls.c
index fccd08b66d1a04e16cfc127bb672e2c0fbe18e4d..60dcc0f3b32e7b445352b455d377f5b2b794b4fb 100644 (file)
@@ -424,6 +424,12 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
                NULL,
        };
 
+       static const char * const vpx_golden_frame_sel[] = {
+               "Use Previous Frame",
+               "Use Previous Specific Frame",
+               NULL,
+       };
+
        static const char * const flash_led_mode[] = {
                "Off",
                "Flash",
@@ -538,6 +544,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
                return mpeg_mpeg4_level;
        case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
                return mpeg4_profile;
+       case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL:
+               return vpx_golden_frame_sel;
        case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
                return jpeg_chroma_subsampling;
        case V4L2_CID_DV_TX_MODE:
@@ -552,6 +560,33 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 }
 EXPORT_SYMBOL(v4l2_ctrl_get_menu);
 
+#define __v4l2_qmenu_int_len(arr, len) ({ *(len) = ARRAY_SIZE(arr); arr; })
+/*
+ * Returns NULL or an s64 type array containing the menu for given
+ * control ID. The total number of the menu items is returned in @len.
+ */
+const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len)
+{
+       static const s64 qmenu_int_vpx_num_partitions[] = {
+               1, 2, 4, 8,
+       };
+
+       static const s64 qmenu_int_vpx_num_ref_frames[] = {
+               1, 2, 3,
+       };
+
+       switch (id) {
+       case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS:
+               return __v4l2_qmenu_int_len(qmenu_int_vpx_num_partitions, len);
+       case V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES:
+               return __v4l2_qmenu_int_len(qmenu_int_vpx_num_ref_frames, len);
+       default:
+               *len = 0;
+               return NULL;
+       }
+}
+EXPORT_SYMBOL(v4l2_ctrl_get_int_menu);
+
 /* Return the control name. */
 const char *v4l2_ctrl_get_name(u32 id)
 {
@@ -600,9 +635,11 @@ const char *v4l2_ctrl_get_name(u32 id)
        case V4L2_CID_ALPHA_COMPONENT:          return "Alpha Component";
        case V4L2_CID_COLORFX_CBCR:             return "Color Effects, CbCr";
 
-       /* MPEG controls */
+       /* Codec controls */
+       /* The MPEG controls are applicable to all codec controls
+        * and the 'MPEG' part of the define is historical */
        /* Keep the order of the 'case's the same as in videodev2.h! */
-       case V4L2_CID_MPEG_CLASS:               return "MPEG Encoder Controls";
+       case V4L2_CID_MPEG_CLASS:               return "Codec Controls";
        case V4L2_CID_MPEG_STREAM_TYPE:         return "Stream Type";
        case V4L2_CID_MPEG_STREAM_PID_PMT:      return "Stream PMT Program ID";
        case V4L2_CID_MPEG_STREAM_PID_AUDIO:    return "Stream Audio Program ID";
@@ -700,6 +737,15 @@ const char *v4l2_ctrl_get_name(u32 id)
        case V4L2_CID_MPEG_VIDEO_VBV_DELAY:                     return "Initial Delay for VBV Control";
        case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER:             return "Repeat Sequence Header";
 
+       /* VPX controls */
+       case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS:            return "VPX Number of Partitions";
+       case V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4:           return "VPX Intra Mode Decision Disable";
+       case V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES:            return "VPX No. of Refs for P Frame";
+       case V4L2_CID_MPEG_VIDEO_VPX_FILTER_LEVEL:              return "VPX Loop Filter Level Range";
+       case V4L2_CID_MPEG_VIDEO_VPX_FILTER_SHARPNESS:          return "VPX Deblocking Effect Control";
+       case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD:   return "VPX Golden Frame Refresh Period";
+       case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL:          return "VPX Golden Frame Indicator";
+
        /* CAMERA controls */
        /* Keep the order of the 'case's the same as in videodev2.h! */
        case V4L2_CID_CAMERA_CLASS:             return "Camera Controls";
@@ -914,6 +960,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
        case V4L2_CID_DV_RX_RGB_RANGE:
        case V4L2_CID_TEST_PATTERN:
        case V4L2_CID_TUNE_DEEMPHASIS:
+       case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL:
                *type = V4L2_CTRL_TYPE_MENU;
                break;
        case V4L2_CID_LINK_FREQ:
@@ -925,6 +972,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
                break;
        case V4L2_CID_ISO_SENSITIVITY:
        case V4L2_CID_AUTO_EXPOSURE_BIAS:
+       case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS:
+       case V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES:
                *type = V4L2_CTRL_TYPE_INTEGER_MENU;
                break;
        case V4L2_CID_USER_CLASS:
@@ -1712,7 +1761,9 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
                        const struct v4l2_ctrl_ops *ops,
                        u32 id, s32 max, s32 mask, s32 def)
 {
-       const char * const *qmenu = v4l2_ctrl_get_menu(id);
+       const char * const *qmenu = NULL;
+       const s64 *qmenu_int = NULL;
+       unsigned int qmenu_int_len = 0;
        const char *name;
        enum v4l2_ctrl_type type;
        s32 min;
@@ -1720,12 +1771,18 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
        u32 flags;
 
        v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags);
-       if (type != V4L2_CTRL_TYPE_MENU) {
+
+       if (type == V4L2_CTRL_TYPE_MENU)
+               qmenu = v4l2_ctrl_get_menu(id);
+       else if (type == V4L2_CTRL_TYPE_INTEGER_MENU)
+               qmenu_int = v4l2_ctrl_get_int_menu(id, &qmenu_int_len);
+
+       if ((!qmenu && !qmenu_int) || (qmenu_int && max > qmenu_int_len)) {
                handler_set_err(hdl, -EINVAL);
                return NULL;
        }
        return v4l2_ctrl_new(hdl, ops, id, name, type,
-                            0, max, mask, def, flags, qmenu, NULL, NULL);
+                            0, max, mask, def, flags, qmenu, qmenu_int, NULL);
 }
 EXPORT_SYMBOL(v4l2_ctrl_new_std_menu);