media: mfc: support encoder static info
authorJeonghee Kim <jhhhh.kim@samsung.com>
Wed, 25 Apr 2018 04:02:44 +0000 (13:02 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:22:22 +0000 (20:22 +0300)
Change-Id: I0d7d157751d0b51fc95d6a9000398381fbd8d75c
Signed-off-by: Jeonghee Kim <jhhhh.kim@samsung.com>
drivers/media/platform/exynos/mfc/exynos_mfc_media.h
drivers/media/platform/exynos/mfc/s5p_mfc_common.h
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_internal.h
drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c
drivers/media/platform/exynos/mfc/s5p_mfc_regs_v10.h

index 83d794a6b9eae7dc78864ecb319ab31928885d89..d032b0c0be4638dc9825121b1f1622a4d8dd3ddb 100644 (file)
@@ -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)
index e5857e9e8a66a5bc1ed161857896f24878aedb33..81bf93214183ab18dbd016c4b45dfc89e2703050 100644 (file)
 #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)
                                        (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 */
index dabf52f9b266d37c283f59d3639c079362acd6df..6864e5e3741eb80f644dd2c3a742eb065c6bebd2 100644 (file)
@@ -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;
index 3ad33ca64a482022e0a5806345d945c7023458a1..511233e0bf99808f28e79e52984b6f5b0bdd308a 100644 (file)
@@ -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;
index cecafe200bc3ad1aa6142791057db62136c684c9..2af7ef229c434656e3fc4fd31b5a9413a01d8c78 100644 (file)
@@ -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)
index b509a36d7e8284db8370c628ec843776fdd10caa..77ea7292c26ec34d19bcd701e62c09ef0a9b7741 100644 (file)
@@ -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();
 }
 
index 5b48ad58016cdd2c3e833a935221184af2a43d2b..3679d1e28045b6156fb8d12e7958aeda2d262026 100644 (file)
 #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
 
 #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