Commit 4773ab99 authored by Arun Kumar K's avatar Arun Kumar K Committed by Mauro Carvalho Chehab

[media] s5p-mfc: Add QP setting support for vp8 encoder

Adds v4l2 controls to set MIN, MAX QP values and
I, P frame QP for vp8 encoder.
Signed-off-by: default avatarKiran AVND <avnd.kiran@samsung.com>
Signed-off-by: default avatarArun Kumar K <arun.kk@samsung.com>
Signed-off-by: default avatarKamil Debski <k.debski@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent ee97207c
...@@ -3161,6 +3161,38 @@ V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD as a golden frame.</entry> ...@@ -3161,6 +3161,38 @@ V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD as a golden frame.</entry>
</entrytbl> </entrytbl>
</row> </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> <row><entry></entry></row>
</tbody> </tbody>
</tgroup> </tgroup>
......
...@@ -422,6 +422,10 @@ struct s5p_mfc_vp8_enc_params { ...@@ -422,6 +422,10 @@ struct s5p_mfc_vp8_enc_params {
enum v4l2_vp8_golden_frame_sel golden_frame_sel; enum v4l2_vp8_golden_frame_sel golden_frame_sel;
u8 hier_layer; u8 hier_layer;
u8 hier_layer_qp[3]; u8 hier_layer_qp[3];
u8 rc_min_qp;
u8 rc_max_qp;
u8 rc_frame_qp;
u8 rc_p_frame_qp;
}; };
/** /**
......
...@@ -618,6 +618,38 @@ static struct mfc_control controls[] = { ...@@ -618,6 +618,38 @@ static struct mfc_control controls[] = {
.default_value = V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_PREV, .default_value = V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_PREV,
.menu_skip_mask = 0, .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) #define NUM_CTRLS ARRAY_SIZE(controls)
...@@ -1557,6 +1589,18 @@ static int s5p_mfc_enc_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -1557,6 +1589,18 @@ static int s5p_mfc_enc_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL: case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL:
p->codec.vp8.golden_frame_sel = ctrl->val; p->codec.vp8.golden_frame_sel = ctrl->val;
break; 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: default:
v4l2_err(&dev->v4l2_dev, "Invalid control, id=%d, val=%d\n", v4l2_err(&dev->v4l2_dev, "Invalid control, id=%d, val=%d\n",
ctrl->id, ctrl->val); ctrl->id, ctrl->val);
......
...@@ -1218,6 +1218,26 @@ static int s5p_mfc_set_enc_params_vp8(struct s5p_mfc_ctx *ctx) ...@@ -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); 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 */ /* vbv buffer size */
if (p->frame_skip_mode == if (p->frame_skip_mode ==
V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) { V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
......
...@@ -745,6 +745,10 @@ const char *v4l2_ctrl_get_name(u32 id) ...@@ -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_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_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_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 */ /* CAMERA controls */
/* Keep the order of the 'case's the same as in videodev2.h! */ /* Keep the order of the 'case's the same as in videodev2.h! */
......
...@@ -558,6 +558,10 @@ enum v4l2_vp8_golden_frame_sel { ...@@ -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_PREV = 0,
V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_REF_PERIOD = 1, 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 */ /* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) #define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment