[COMMON] media: mfc: fix frame rate change with delta
authorAyoung Sim <a.sim@samsung.com>
Mon, 20 May 2019 10:14:59 +0000 (19:14 +0900)
committerKim Gunho <gunho.kim@samsung.com>
Fri, 28 Jun 2019 14:45:49 +0000 (23:45 +0900)
If the frame rate changes, the DELTA and RESOLUTION
must be recalculated.
Because we set RESOLUTION to 1000ms
for "drop control" feature forward.

Change-Id: Ica4e65835c757acdfbf601263b88934ffb49a6da
Signed-off-by: Ayoung Sim <a.sim@samsung.com>
drivers/media/platform/exynos/mfc/mfc_enc_ctrl.c
drivers/media/platform/exynos/mfc/mfc_enc_internal.h
drivers/media/platform/exynos/mfc/mfc_enc_v4l2.c

index 7a99fa1c966e2a8b329858c0f9be8ba47d67d7d7..146775880d40c8db621115183f47561e99367d06 100644 (file)
@@ -112,7 +112,7 @@ static struct mfc_ctrl_cfg mfc_ctrl_list[] = {
                .is_volatile = 1,
                .mode = MFC_CTRL_MODE_SFR,
                .addr = MFC_REG_E_RC_FRAME_RATE,
-               .mask = 0xFFFFFFFF,
+               .mask = 0x0000FFFF,
                .shft = 0,
                .flag_mode = MFC_CTRL_MODE_SFR,
                .flag_addr = MFC_REG_E_PARAM_CHANGE,
@@ -1141,6 +1141,15 @@ static void __mfc_enc_set_buf_ctrls_exception(struct mfc_ctx *ctx,
                                buf_ctrl->val);
        }
 
+       /* set frame rate change with delta */
+       if (buf_ctrl->id == V4L2_CID_MPEG_MFC51_VIDEO_FRAME_RATE_CH) {
+               p->rc_frame_delta = FRAME_RATE_RESOLUTION / buf_ctrl->val;
+               value = MFC_READL(buf_ctrl->addr);
+               value &= ~(buf_ctrl->mask << buf_ctrl->shft);
+               value |= ((p->rc_frame_delta & buf_ctrl->mask) << buf_ctrl->shft);
+               MFC_WRITEL(value, buf_ctrl->addr);
+       }
+
        /* set drop control */
        if (buf_ctrl->id == V4L2_CID_MPEG_VIDEO_DROP_CONTROL) {
                if (!ctx->ts_last_interval) {
@@ -1274,9 +1283,12 @@ static int mfc_enc_set_buf_ctrls_val_nal_q(struct mfc_ctx *ctx,
                        param_change = 1;
                        break;
                case V4L2_CID_MPEG_MFC51_VIDEO_FRAME_RATE_CH:
+                       p->rc_frame_delta = FRAME_RATE_RESOLUTION / buf_ctrl->val;
+                       pInStr->RcFrameRate &= ~(0xFFFF << 16);
+                       pInStr->RcFrameRate |= (FRAME_RATE_RESOLUTION & 0xFFFF) << 16;
                        pInStr->RcFrameRate &= ~(buf_ctrl->mask << buf_ctrl->shft);
                        pInStr->RcFrameRate |=
-                               (buf_ctrl->val & buf_ctrl->mask) << buf_ctrl->shft;
+                               (p->rc_frame_delta & buf_ctrl->mask) << buf_ctrl->shft;
                        param_change = 1;
                        break;
                case V4L2_CID_MPEG_MFC51_VIDEO_BIT_RATE_CH:
index 2daacf3cdc5335f520e9395fb3f154bc19e1c627..5f685d5bd54dcd8f067786bbb287673dbe50fd80 100644 (file)
@@ -542,7 +542,7 @@ static struct v4l2_queryctrl controls[] = {
                .type = V4L2_CTRL_TYPE_INTEGER,
                .name = "H264 Frame rate",
                .minimum = 1,
-               .maximum = (1 << 16) - 1,
+               .maximum = FRAME_RATE_RESOLUTION,
                .step = 1,
                .default_value = 1,
        },
index e29eaaae23e4615037a2645a675795f638c2d4ef..2fe96fbd90a9f7ef0fccc165f29e99b5fcfa5df9 100644 (file)
@@ -1861,13 +1861,6 @@ static int __mfc_enc_set_ctrl_val(struct mfc_ctx *ctx, struct v4l2_control *ctrl
                        if (ctx_ctrl->id == ctrl->id) {
                                ctx_ctrl->has_new = 1;
                                ctx_ctrl->val = ctrl->value;
-                               if (ctx_ctrl->id == \
-                                       V4L2_CID_MPEG_MFC51_VIDEO_FRAME_RATE_CH) {
-                                       ctx_ctrl->val &= ~(0xFFFF << 16);
-                                       ctx_ctrl->val |= ctx_ctrl->val << 16;
-                                       ctx_ctrl->val &= ~(0xFFFF);
-                                       ctx_ctrl->val |= p->rc_frame_delta & 0xFFFF;
-                               }
                                if ((ctx_ctrl->id == \
                                        V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_CH) ||
                                        (ctx_ctrl->id == \