From 161b35293a55dfc0b9b702338d1ba9840afcdf12 Mon Sep 17 00:00:00 2001 From: Jeonghee Kim Date: Sat, 17 Mar 2018 19:15:17 +0900 Subject: [PATCH] media: mfc: change VIDEO_SIGNAL_TYPE setting 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 --- .../platform/exynos/mfc/s5p_mfc_data_struct.h | 1 + .../media/platform/exynos/mfc/s5p_mfc_enc.c | 1 + .../platform/exynos/mfc/s5p_mfc_enc_param.c | 66 ++++++++++++------- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h index 6a75fc6e19c8..c5093d06bba5 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h @@ -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; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c index a7c7877734b4..9fd44a4a647b 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c @@ -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: diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c index e7e3c45853d5..1e60d80ab022 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c @@ -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(); -- 2.20.1