media: mfc: change VIDEO_SIGNAL_TYPE setting
authorJeonghee Kim <jhhhh.kim@samsung.com>
Sat, 17 Mar 2018 10:15:17 +0000 (19:15 +0900)
committerSunyoung Kang <sy0816.kang@samsung.com>
Tue, 29 May 2018 06:59:18 +0000 (15:59 +0900)
Set VIDEO_SIGNAL_TYPE_FLAG
only when the control of the color range is called.
Set COLOUR_DESCRIPTION_PRESENT_FLAG
only when the color information is not the reserved value.

Change-Id: I9bd980b3cffabd9cb8ef3a1198a1e69b15245621
Signed-off-by: Jeonghee Kim <jhhhh.kim@samsung.com>
drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h
drivers/media/platform/exynos/mfc/s5p_mfc_enc.c
drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c

index 6a75fc6e19c88d4995c5c508f612be4dd7dff6e9..c5093d06bba54f0343e949587f15ea6681b93d53 100644 (file)
@@ -994,6 +994,7 @@ struct s5p_mfc_enc_params {
        u32 i_frm_ctrl_mode;
        u32 i_frm_ctrl;
 
+       u32 check_color_range;
        u32 color_range;
        u32 colour_primaries;
        u32 transfer_characteristics;
index a7c7877734b46196889a65310892188307d8475f..9fd44a4a647b7120cbabe9c89d679899c610e263 100644 (file)
@@ -1582,6 +1582,7 @@ static int mfc_enc_set_param(struct s5p_mfc_ctx *ctx, struct v4l2_control *ctrl)
                p->ratio_intra = ctrl->value;
                break;
        case V4L2_CID_MPEG_VIDEO_FULL_RANGE_FLAG:
+               p->check_color_range = 1;
                p->color_range = ctrl->value;
                break;
        case V4L2_CID_MPEG_VIDEO_COLOUR_PRIMARIES:
index e7e3c45853d542a7b2089ab8f6fc3d3c7ecaf0db..1e60d80ab022f17fc35b3316044ab01dd8ac9010 100644 (file)
@@ -641,28 +641,35 @@ void s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx)
                MFC_WRITEL(reg, S5P_FIMV_E_H264_FRAME_PACKING_SEI_INFO);
        }
 
-       if (FW_HAS_ENC_COLOR_ASPECT(dev)) {
+       if (FW_HAS_ENC_COLOR_ASPECT(dev) && p->check_color_range) {
                reg = MFC_READL(S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
                /* VIDEO_SIGNAL_TYPE_FLAG */
                reg |= 0x1 << 31;
                /* COLOR_RANGE */
                reg &= ~(0x1 << 25);
                reg |= p->color_range << 25;
-               /* COLOUR_DESCRIPTION_PRESENT_FLAG */
-               reg |= 0x1 << 24;
-               /* COLOUR_PRIMARIES */
-               reg &= ~(0xFF << 16);
-               reg |= p->colour_primaries << 16;
-               /* TRANSFER_CHARACTERISTICS */
-               reg &= ~(0xFF << 8);
-               reg |= p->transfer_characteristics << 8;
-               /* MATRIX_COEFFICIENTS */
-               reg &= ~(0xFF);
-               reg |= p->matrix_coefficients;
+               if ((p->colour_primaries != 0) && (p->transfer_characteristics != 0) &&
+                               (p->matrix_coefficients != 3)) {
+                       /* COLOUR_DESCRIPTION_PRESENT_FLAG */
+                       reg |= 0x1 << 24;
+                       /* COLOUR_PRIMARIES */
+                       reg &= ~(0xFF << 16);
+                       reg |= p->colour_primaries << 16;
+                       /* TRANSFER_CHARACTERISTICS */
+                       reg &= ~(0xFF << 8);
+                       reg |= p->transfer_characteristics << 8;
+                       /* MATRIX_COEFFICIENTS */
+                       reg &= ~(0xFF);
+                       reg |= p->matrix_coefficients;
+               } else {
+                       reg &= ~(0x1 << 24);
+               }
                MFC_WRITEL(reg, S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
                mfc_debug(2, "H264 ENC Color aspect: range:%s, pri:%d, trans:%d, mat:%d\n",
                                p->color_range ? "Full" : "Limited", p->colour_primaries,
                                p->transfer_characteristics, p->matrix_coefficients);
+       } else {
+               MFC_WRITEL(0, S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
        }
 
        mfc_set_fmo_slice_map_h264(ctx, p_264);
@@ -1105,7 +1112,7 @@ void s5p_mfc_set_enc_params_vp9(struct s5p_mfc_ctx *ctx)
        reg |= p_vp9->rc_min_qp_p & 0xFF;
        MFC_WRITEL(reg, S5P_FIMV_E_RC_QP_BOUND_PB);
 
-       if (FW_HAS_ENC_COLOR_ASPECT(dev)) {
+       if (FW_HAS_ENC_COLOR_ASPECT(dev) && p->check_color_range) {
                reg = MFC_READL(S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
                /* VIDEO_SIGNAL_TYPE_FLAG */
                reg |= 0x1 << 31;
@@ -1118,6 +1125,8 @@ void s5p_mfc_set_enc_params_vp9(struct s5p_mfc_ctx *ctx)
                MFC_WRITEL(reg, S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
                mfc_debug(2, "VP9 ENC Color aspect: range:%s, space: %d\n",
                                p->color_range ? "Full" : "Limited", p->colour_primaries);
+       } else {
+               MFC_WRITEL(0, S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
        }
 
        mfc_debug_leave();
@@ -1346,28 +1355,35 @@ void s5p_mfc_set_enc_params_hevc(struct s5p_mfc_ctx *ctx)
        MFC_WRITEL(reg, S5P_FIMV_E_RC_ROI_CTRL);
        mfc_debug(3, "ROI: HEVC ROI enable\n");
 
-       if (FW_HAS_ENC_COLOR_ASPECT(dev)) {
+       if (FW_HAS_ENC_COLOR_ASPECT(dev) && p->check_color_range) {
                reg = MFC_READL(S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
                /* VIDEO_SIGNAL_TYPE_FLAG */
                reg |= 0x1 << 31;
                /* COLOR_RANGE */
                reg &= ~(0x1 << 25);
                reg |= p->color_range << 25;
-               /* COLOUR_DESCRIPTION_PRESENT_FLAG */
-               reg |= 0x1 << 24;
-               /* COLOUR_PRIMARIES */
-               reg &= ~(0xFF << 16);
-               reg |= p->colour_primaries << 16;
-               /* TRANSFER_CHARACTERISTICS */
-               reg &= ~(0xFF << 8);
-               reg |= p->transfer_characteristics << 8;
-               /* MATRIX_COEFFICIENTS */
-               reg &= ~(0xFF);
-               reg |= p->matrix_coefficients;
+               if ((p->colour_primaries != 0) && (p->transfer_characteristics != 0) &&
+                               (p->matrix_coefficients != 3)) {
+                       /* COLOUR_DESCRIPTION_PRESENT_FLAG */
+                       reg |= 0x1 << 24;
+                       /* COLOUR_PRIMARIES */
+                       reg &= ~(0xFF << 16);
+                       reg |= p->colour_primaries << 16;
+                       /* TRANSFER_CHARACTERISTICS */
+                       reg &= ~(0xFF << 8);
+                       reg |= p->transfer_characteristics << 8;
+                       /* MATRIX_COEFFICIENTS */
+                       reg &= ~(0xFF);
+                       reg |= p->matrix_coefficients;
+               } else {
+                       reg &= ~(0x1 << 24);
+               }
                MFC_WRITEL(reg, S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
                mfc_debug(2, "HEVC ENC Color aspect: range:%s, pri:%d, trans:%d, mat:%d\n",
                                p->color_range ? "Full" : "Limited", p->colour_primaries,
                                p->transfer_characteristics, p->matrix_coefficients);
+       } else {
+               MFC_WRITEL(0, S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
        }
 
        mfc_debug_leave();