From 21c8e2109a7cecd4bb04c081f259ce27bb7721f9 Mon Sep 17 00:00:00 2001 From: Jeonghee Kim Date: Wed, 25 Apr 2018 13:02:44 +0900 Subject: [PATCH] media: mfc: support encoder static info Change-Id: I0d7d157751d0b51fc95d6a9000398381fbd8d75c Signed-off-by: Jeonghee Kim --- .../platform/exynos/mfc/exynos_mfc_media.h | 2 + .../platform/exynos/mfc/s5p_mfc_common.h | 3 + .../platform/exynos/mfc/s5p_mfc_data_struct.h | 10 +++ .../media/platform/exynos/mfc/s5p_mfc_enc.c | 30 +++++++ .../exynos/mfc/s5p_mfc_enc_internal.h | 81 +++++++++++++++++++ .../platform/exynos/mfc/s5p_mfc_enc_param.c | 41 +++++++++- .../platform/exynos/mfc/s5p_mfc_regs_v10.h | 9 +++ 7 files changed, 173 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/exynos_mfc_media.h b/drivers/media/platform/exynos/mfc/exynos_mfc_media.h index 83d794a6b9ea..d032b0c0be46 100644 --- a/drivers/media/platform/exynos/mfc/exynos_mfc_media.h +++ b/drivers/media/platform/exynos/mfc/exynos_mfc_media.h @@ -493,6 +493,8 @@ enum v4l2_mpeg_video_hevc_hierarchical_coding_type { (V4L2_CID_MPEG_MFC_BASE + 230) #define V4L2_CID_MPEG_VIDEO_TRANSFER_CHARACTERISTICS \ (V4L2_CID_MPEG_MFC_BASE + 231) +#define V4L2_CID_MPEG_VIDEO_STATIC_INFO_ENABLE \ + (V4L2_CID_MPEG_MFC_BASE + 232) #define V4L2_CID_MPEG_VIDEO_BPG_THUMBNAIL_SIZE \ (V4L2_CID_MPEG_MFC_BASE + 250) diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_common.h b/drivers/media/platform/exynos/mfc/s5p_mfc_common.h index e5857e9e8a66..81bf93214183 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_common.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_common.h @@ -175,6 +175,7 @@ #define ENC_SET_RATIO_OF_INTRA (1 << 8) #define ENC_SET_COLOR_ASPECT (1 << 9) #define ENC_SET_HP_BITRATE_CONTROL (1 << 10) +#define ENC_SET_STATIC_INFO (1 << 11) #define MFC_VER_MAJOR(dev) ((dev->pdata->ip_ver >> 8) & 0xFF) #define MFC_VER_MINOR(dev) (dev->pdata->ip_ver & 0xFF) @@ -212,4 +213,6 @@ (dev->fw.date >= 0x171023)) #define FW_HAS_HP_BITRATE_CONTROL(dev) (FROM_MFCV11X(dev) && \ (dev->fw.date >= 0x180314)) +#define FW_HAS_ENC_STATIC_INFO(dev) (IS_MFCV13X(dev) && \ + (dev->fw.date >= 0x180314)) #endif /* __S5P_MFC_COMMON_H */ 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 dabf52f9b266..6864e5e3741e 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h @@ -1006,6 +1006,16 @@ struct s5p_mfc_enc_params { u32 transfer_characteristics; u32 matrix_coefficients; + u32 static_info_enable; + u32 max_pic_average_light; + u32 max_content_light; + u32 max_display_luminance; + u32 min_display_luminance; + u32 white_point; + u32 display_primaries_0; + u32 display_primaries_1; + u32 display_primaries_2; + union { struct s5p_mfc_h264_enc_params h264; struct s5p_mfc_mpeg4_enc_params mpeg4; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c index 3ad33ca64a48..511233e0bf99 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c @@ -767,6 +767,9 @@ static int mfc_enc_ext_info(struct s5p_mfc_ctx *ctx) if (FW_HAS_HP_BITRATE_CONTROL(dev)) val |= ENC_SET_HP_BITRATE_CONTROL; + if (FW_HAS_ENC_STATIC_INFO(dev)) + val |= ENC_SET_STATIC_INFO; + return val; } @@ -1600,6 +1603,33 @@ static int mfc_enc_set_param(struct s5p_mfc_ctx *ctx, struct v4l2_control *ctrl) case V4L2_CID_MPEG_VIDEO_HIERARCHICAL_BITRATE_CTRL: p->hier_bitrate_ctrl = ctrl->value; break; + case V4L2_CID_MPEG_VIDEO_STATIC_INFO_ENABLE: + p->static_info_enable = ctrl->value; + break; + case V4L2_CID_MPEG_VIDEO_SEI_MAX_PIC_AVERAGE_LIGHT: + p->max_pic_average_light = ctrl->value; + break; + case V4L2_CID_MPEG_VIDEO_SEI_MAX_CONTENT_LIGHT: + p->max_content_light = ctrl->value; + break; + case V4L2_CID_MPEG_VIDEO_SEI_MAX_DISPLAY_LUMINANCE: + p->max_display_luminance = ctrl->value; + break; + case V4L2_CID_MPEG_VIDEO_SEI_MIN_DISPLAY_LUMINANCE: + p->min_display_luminance = ctrl->value; + break; + case V4L2_CID_MPEG_VIDEO_SEI_WHITE_POINT: + p->white_point = ctrl->value; + break; + case V4L2_CID_MPEG_VIDEO_SEI_DISPLAY_PRIMARIES_0: + p->display_primaries_0 = ctrl->value; + break; + case V4L2_CID_MPEG_VIDEO_SEI_DISPLAY_PRIMARIES_1: + p->display_primaries_1 = ctrl->value; + break; + case V4L2_CID_MPEG_VIDEO_SEI_DISPLAY_PRIMARIES_2: + p->display_primaries_2 = ctrl->value; + break; default: mfc_err_ctx("Invalid control: 0x%08x\n", ctrl->id); ret = -EINVAL; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_internal.h b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_internal.h index cecafe200bc3..2af7ef229c43 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_internal.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_internal.h @@ -2282,6 +2282,87 @@ static struct v4l2_queryctrl controls[] = { .step = 1, .default_value = 1, }, + { + .id = V4L2_CID_MPEG_VIDEO_STATIC_INFO_ENABLE, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "Static info enable", + .minimum = 0, + .maximum = 1, + .step = 1, + .default_value = 0, + }, + { + .id = V4L2_CID_MPEG_VIDEO_SEI_MAX_PIC_AVERAGE_LIGHT, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "Max pic average light", + .minimum = 0, + .maximum = 0xFFFF, + .step = 1, + .default_value = 0, + }, + { + .id = V4L2_CID_MPEG_VIDEO_SEI_MAX_CONTENT_LIGHT, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "Max content light", + .minimum = 0, + .maximum = 0xFFFF, + .step = 1, + .default_value = 0, + }, + { + .id = V4L2_CID_MPEG_VIDEO_SEI_MAX_DISPLAY_LUMINANCE, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "Max display luminance", + .minimum = INT_MIN, + .maximum = INT_MAX, + .step = 1, + .default_value = 0, + }, + { + .id = V4L2_CID_MPEG_VIDEO_SEI_MIN_DISPLAY_LUMINANCE, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "Min display luminance", + .minimum = INT_MIN, + .maximum = INT_MAX, + .step = 1, + .default_value = 0, + }, + { + .id = V4L2_CID_MPEG_VIDEO_SEI_WHITE_POINT, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "White point", + .minimum = INT_MIN, + .maximum = INT_MAX, + .step = 1, + .default_value = 0, + }, + { + .id = V4L2_CID_MPEG_VIDEO_SEI_DISPLAY_PRIMARIES_0, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "Display primaries 0", + .minimum = INT_MIN, + .maximum = INT_MAX, + .step = 1, + .default_value = 0, + }, + { + .id = V4L2_CID_MPEG_VIDEO_SEI_DISPLAY_PRIMARIES_1, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "Display primaries 1", + .minimum = INT_MIN, + .maximum = INT_MAX, + .step = 1, + .default_value = 0, + }, + { + .id = V4L2_CID_MPEG_VIDEO_SEI_DISPLAY_PRIMARIES_2, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "Display primaries 2", + .minimum = INT_MIN, + .maximum = INT_MAX, + .step = 1, + .default_value = 0, + }, }; #define NUM_CTRLS ARRAY_SIZE(controls) 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 b509a36d7e82..77ea7292c26e 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c @@ -668,7 +668,7 @@ void s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx) 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", + mfc_debug(2, "[HDR] 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 { @@ -1132,7 +1132,7 @@ void s5p_mfc_set_enc_params_vp9(struct s5p_mfc_ctx *ctx) reg &= ~(0x1 << 25); reg |= p->color_range << 25; MFC_WRITEL(reg, S5P_FIMV_E_VIDEO_SIGNAL_TYPE); - mfc_debug(2, "VP9 ENC Color aspect: range:%s, space: %d\n", + mfc_debug(2, "[HDR] 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); @@ -1390,13 +1390,48 @@ void s5p_mfc_set_enc_params_hevc(struct s5p_mfc_ctx *ctx) 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", + mfc_debug(2, "[HDR] 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); } + if (FW_HAS_ENC_STATIC_INFO(dev) && p->static_info_enable && ctx->is_10bit) { + reg = MFC_READL(S5P_FIMV_E_HEVC_OPTIONS_2); + /* HDR_STATIC_INFO_ENABLE */ + reg |= p->static_info_enable; + MFC_WRITEL(reg, S5P_FIMV_E_HEVC_OPTIONS_2); + /* MAX_PIC_AVERAGE_LIGHT & MAX_CONTENT_LIGHT */ + reg = p->max_pic_average_light; + reg |= (p->max_content_light << 16); + MFC_WRITEL(reg, S5P_FIMV_E_CONTENT_LIGHT_LEVEL_INFO_SEI); + /* MAX_DISPLAY_LUMINANCE */ + MFC_WRITEL(p->max_display_luminance, S5P_FIMV_E_MASTERING_DISPLAY_COLOUR_VOLUME_SEI_0); + /* MIN DISPLAY LUMINANCE */ + MFC_WRITEL(p->min_display_luminance, S5P_FIMV_E_MASTERING_DISPLAY_COLOUR_VOLUME_SEI_1); + /* WHITE_POINT */ + MFC_WRITEL(p->white_point, S5P_FIMV_E_MASTERING_DISPLAY_COLOUR_VOLUME_SEI_2); + /* DISPLAY PRIMARIES_0 */ + MFC_WRITEL(p->display_primaries_0, S5P_FIMV_E_MASTERING_DISPLAY_COLOUR_VOLUME_SEI_3); + /* DISPLAY PRIMARIES_1 */ + MFC_WRITEL(p->display_primaries_1, S5P_FIMV_E_MASTERING_DISPLAY_COLOUR_VOLUME_SEI_4); + /* DISPLAY PRIMARIES_2 */ + MFC_WRITEL(p->display_primaries_2, S5P_FIMV_E_MASTERING_DISPLAY_COLOUR_VOLUME_SEI_5); + + mfc_debug(2, "[HDR] HEVC ENC static info: enable(%d), max_pic(0x%x), max_content(0x%x)\n", + p->static_info_enable, p->max_pic_average_light, p->max_content_light); + mfc_debug(2, "[HDR] max_disp(0x%x), min_disp(0x%x), white_point(0x%x)\n", + p->max_display_luminance, p->min_display_luminance, p->white_point); + mfc_debug(2, "[HDR] disp_pri_0(0x%x), disp_pri_1(0x%x), disp_pri_2(0x%x)\n", + p->display_primaries_0, p->display_primaries_1, p->display_primaries_2); + } else { + reg = MFC_READL(S5P_FIMV_E_HEVC_OPTIONS_2); + /* HDR_STATIC_INFO_ENABLE */ + reg &= ~(0x1); + MFC_WRITEL(reg, S5P_FIMV_E_HEVC_OPTIONS_2); + } + mfc_debug_leave(); } diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_regs_v10.h b/drivers/media/platform/exynos/mfc/s5p_mfc_regs_v10.h index 5b48ad58016c..3679d1e28045 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_regs_v10.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_regs_v10.h @@ -405,6 +405,8 @@ #define S5P_FIMV_E_VP8_FILTER_OPTION 0xFDB4 #define S5P_FIMV_E_VP8_GOLDEN_FRAME_OPTION 0xFDB8 +#define S5P_FIMV_E_HEVC_OPTIONS_2 0xFDC4 + #define S5P_FIMV_E_HEVC_OPTIONS 0xFDD4 #define S5P_FIMV_E_HEVC_REFRESH_PERIOD 0xFDD8 #define S5P_FIMV_E_HEVC_CHROMA_QP_OFFSET 0xFDDC @@ -414,6 +416,13 @@ #define S5P_FIMV_E_VP8_NAL_CONTROL 0xFDF0 #define S5P_FIMV_E_VP9_NAL_CONTROL 0xFDF4 +#define S5P_FIMV_E_CONTENT_LIGHT_LEVEL_INFO_SEI 0xFDF8 +#define S5P_FIMV_E_MASTERING_DISPLAY_COLOUR_VOLUME_SEI_0 0xFDFC +#define S5P_FIMV_E_MASTERING_DISPLAY_COLOUR_VOLUME_SEI_1 0xFE00 +#define S5P_FIMV_E_MASTERING_DISPLAY_COLOUR_VOLUME_SEI_2 0xFE04 +#define S5P_FIMV_E_MASTERING_DISPLAY_COLOUR_VOLUME_SEI_3 0xFE08 +#define S5P_FIMV_E_MASTERING_DISPLAY_COLOUR_VOLUME_SEI_4 0xFE0C +#define S5P_FIMV_E_MASTERING_DISPLAY_COLOUR_VOLUME_SEI_5 0xFE10 #define S5P_FIMV_REG_CLEAR_BEGIN 0xf000 -- 2.20.1