[media] s5p-mfc: Add QP setting support for vp8 encoder
authorArun Kumar K <arun.kk@samsung.com>
Fri, 15 Nov 2013 05:29:22 +0000 (02:29 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Mon, 13 Jan 2014 12:55:27 +0000 (10:55 -0200)
Adds v4l2 controls to set MIN, MAX QP values and
I, P frame QP for vp8 encoder.

Signed-off-by: Kiran AVND <avnd.kiran@samsung.com>
Signed-off-by: Arun Kumar K <arun.kk@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Documentation/DocBook/media/v4l/controls.xml
drivers/media/platform/s5p-mfc/s5p_mfc_common.h
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
drivers/media/v4l2-core/v4l2-ctrls.c
include/uapi/linux/v4l2-controls.h

index 7a3b49b3cc3bafbb7f4a8892521e30700dd70496..e4db4ac4533f6f467937de6ce4558f33d23065b0 100644 (file)
@@ -3161,6 +3161,38 @@ V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD as a golden frame.</entry>
                </entrytbl>
              </row>
 
+             <row><entry></entry></row>
+             <row>
+               <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_VPX_MIN_QP</constant></entry>
+               <entry>integer</entry>
+             </row>
+             <row><entry spanname="descr">Minimum quantization parameter for VP8.</entry>
+             </row>
+
+             <row><entry></entry></row>
+             <row>
+               <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_VPX_MAX_QP</constant></entry>
+               <entry>integer</entry>
+             </row>
+             <row><entry spanname="descr">Maximum quantization parameter for VP8.</entry>
+             </row>
+
+             <row><entry></entry></row>
+             <row>
+               <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_VPX_I_FRAME_QP</constant>&nbsp;</entry>
+               <entry>integer</entry>
+             </row>
+             <row><entry spanname="descr">Quantization parameter for an I frame for VP8.</entry>
+             </row>
+
+             <row><entry></entry></row>
+             <row>
+               <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP</constant>&nbsp;</entry>
+               <entry>integer</entry>
+             </row>
+             <row><entry spanname="descr">Quantization parameter for a P frame for VP8.</entry>
+             </row>
+
           <row><entry></entry></row>
         </tbody>
       </tgroup>
index 6920b546181ae8368cf36ef2250922fac20412ba..d91f7575b08878a3d9c22384bc2103b1ef61b4a9 100644 (file)
@@ -422,6 +422,10 @@ struct s5p_mfc_vp8_enc_params {
        enum v4l2_vp8_golden_frame_sel golden_frame_sel;
        u8 hier_layer;
        u8 hier_layer_qp[3];
+       u8 rc_min_qp;
+       u8 rc_max_qp;
+       u8 rc_frame_qp;
+       u8 rc_p_frame_qp;
 };
 
 /**
index f0b41f85ac71a02f3ca81f20a92e65a485b8c706..cdf672c8f11e70fdc5b4b8ff74eae7d704724f9f 100644 (file)
@@ -618,6 +618,38 @@ static struct mfc_control controls[] = {
                .default_value = V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_PREV,
                .menu_skip_mask = 0,
        },
+       {
+               .id = V4L2_CID_MPEG_VIDEO_VPX_MAX_QP,
+               .type = V4L2_CTRL_TYPE_INTEGER,
+               .minimum = 0,
+               .maximum = 127,
+               .step = 1,
+               .default_value = 127,
+       },
+       {
+               .id = V4L2_CID_MPEG_VIDEO_VPX_MIN_QP,
+               .type = V4L2_CTRL_TYPE_INTEGER,
+               .minimum = 0,
+               .maximum = 11,
+               .step = 1,
+               .default_value = 0,
+       },
+       {
+               .id = V4L2_CID_MPEG_VIDEO_VPX_I_FRAME_QP,
+               .type = V4L2_CTRL_TYPE_INTEGER,
+               .minimum = 0,
+               .maximum = 127,
+               .step = 1,
+               .default_value = 10,
+       },
+       {
+               .id = V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP,
+               .type = V4L2_CTRL_TYPE_INTEGER,
+               .minimum = 0,
+               .maximum = 127,
+               .step = 1,
+               .default_value = 10,
+       },
 };
 
 #define NUM_CTRLS ARRAY_SIZE(controls)
@@ -1557,6 +1589,18 @@ static int s5p_mfc_enc_s_ctrl(struct v4l2_ctrl *ctrl)
        case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL:
                p->codec.vp8.golden_frame_sel = ctrl->val;
                break;
+       case V4L2_CID_MPEG_VIDEO_VPX_MIN_QP:
+               p->codec.vp8.rc_min_qp = ctrl->val;
+               break;
+       case V4L2_CID_MPEG_VIDEO_VPX_MAX_QP:
+               p->codec.vp8.rc_max_qp = ctrl->val;
+               break;
+       case V4L2_CID_MPEG_VIDEO_VPX_I_FRAME_QP:
+               p->codec.vp8.rc_frame_qp = ctrl->val;
+               break;
+       case V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP:
+               p->codec.vp8.rc_p_frame_qp = ctrl->val;
+               break;
        default:
                v4l2_err(&dev->v4l2_dev, "Invalid control, id=%d, val=%d\n",
                                                        ctrl->id, ctrl->val);
index 461358c4a7908fa71a3b360ffb61ef2c78ce8853..b4886d636dbe86fe8e9770bb65cfe030a0e7fdcd 100644 (file)
@@ -1218,6 +1218,26 @@ static int s5p_mfc_set_enc_params_vp8(struct s5p_mfc_ctx *ctx)
                WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE_V6);
        }
 
+       /* frame QP */
+       reg &= ~(0x7F);
+       reg |= p_vp8->rc_frame_qp & 0x7F;
+       WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6);
+
+       /* other QPs */
+       WRITEL(0x0, S5P_FIMV_E_FIXED_PICTURE_QP_V6);
+       if (!p->rc_frame && !p->rc_mb) {
+               reg = 0;
+               reg |= ((p_vp8->rc_p_frame_qp & 0x7F) << 8);
+               reg |= p_vp8->rc_frame_qp & 0x7F;
+               WRITEL(reg, S5P_FIMV_E_FIXED_PICTURE_QP_V6);
+       }
+
+       /* max QP */
+       reg = ((p_vp8->rc_max_qp & 0x7F) << 8);
+       /* min QP */
+       reg |= p_vp8->rc_min_qp & 0x7F;
+       WRITEL(reg, S5P_FIMV_E_RC_QP_BOUND_V6);
+
        /* vbv buffer size */
        if (p->frame_skip_mode ==
                        V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
index fb46790d0eca795d5e411c54bf7129d96e61d3e9..20840dff78e60cfe5cfd9b24e1acf9b689a3118e 100644 (file)
@@ -745,6 +745,10 @@ const char *v4l2_ctrl_get_name(u32 id)
        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";
+       case V4L2_CID_MPEG_VIDEO_VPX_MIN_QP:                    return "VPX Minimum QP Value";
+       case V4L2_CID_MPEG_VIDEO_VPX_MAX_QP:                    return "VPX Maximum QP Value";
+       case V4L2_CID_MPEG_VIDEO_VPX_I_FRAME_QP:                return "VPX I-Frame QP Value";
+       case V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP:                return "VPX P-Frame QP Value";
 
        /* CAMERA controls */
        /* Keep the order of the 'case's the same as in videodev2.h! */
index 8e4d1d974eda0fd68d4556b6104fd6a6ae961fa8..28cddb45afe08381b365958659ac5fc0a7e8e799 100644 (file)
@@ -558,6 +558,10 @@ enum v4l2_vp8_golden_frame_sel {
        V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_PREV           = 0,
        V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_REF_PERIOD     = 1,
 };
+#define V4L2_CID_MPEG_VIDEO_VPX_MIN_QP                 (V4L2_CID_MPEG_BASE+507)
+#define V4L2_CID_MPEG_VIDEO_VPX_MAX_QP                 (V4L2_CID_MPEG_BASE+508)
+#define V4L2_CID_MPEG_VIDEO_VPX_I_FRAME_QP             (V4L2_CID_MPEG_BASE+509)
+#define V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP             (V4L2_CID_MPEG_BASE+510)
 
 /*  MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
 #define V4L2_CID_MPEG_CX2341X_BASE                             (V4L2_CTRL_CLASS_MPEG | 0x1000)