Commit 9172652d authored by Stanimir Varbanov's avatar Stanimir Varbanov Committed by Mauro Carvalho Chehab

media: venus: venc: Add support for CLL and Mastering display controls

Create CLL and Mastering display colour volume v4l2 controls for
encoder, add handling of HDR10 PQ SEI packet payloads for v4.
Signed-off-by: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 5f8beb7d
......@@ -243,6 +243,8 @@ struct venc_controls {
u32 base_priority_id;
u32 ltr_count;
struct v4l2_ctrl_hdr10_cll_info cll;
struct v4l2_ctrl_hdr10_mastering_display mastering;
};
struct venus_buffer {
......
......@@ -1219,6 +1219,14 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt,
pkt->shdr.hdr.size += sizeof(u32) + sizeof(*cu);
break;
}
case HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI: {
struct hfi_hdr10_pq_sei *in = pdata, *hdr10 = prop_data;
memcpy(hdr10, in, sizeof(*hdr10));
pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hdr10);
break;
}
case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE:
case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER:
case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE:
......
......@@ -513,6 +513,7 @@
#define HFI_PROPERTY_PARAM_VENC_VPX_ERROR_RESILIENCE_MODE 0x2005029
#define HFI_PROPERTY_PARAM_VENC_HIER_B_MAX_NUM_ENH_LAYER 0x200502c
#define HFI_PROPERTY_PARAM_VENC_HIER_P_HYBRID_MODE 0x200502f
#define HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI 0x2005036
/*
* HFI_PROPERTY_CONFIG_VENC_COMMON_START
......@@ -819,6 +820,25 @@ struct hfi_ltr_mark {
u32 mark_frame;
};
struct hfi_mastering_display_colour_sei_payload {
u32 display_primaries_x[3];
u32 display_primaries_y[3];
u32 white_point_x;
u32 white_point_y;
u32 max_display_mastering_luminance;
u32 min_display_mastering_luminance;
};
struct hfi_content_light_level_sei_payload {
u32 max_content_light;
u32 max_pic_average_light;
};
struct hfi_hdr10_pq_sei {
struct hfi_mastering_display_colour_sei_payload mastering;
struct hfi_content_light_level_sei_payload cll;
};
struct hfi_framesize {
u32 buffer_type;
u32 width;
......
......@@ -613,6 +613,35 @@ static int venc_set_properties(struct venus_inst *inst)
return ret;
}
if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) {
struct hfi_hdr10_pq_sei hdr10;
unsigned int c;
ptype = HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI;
for (c = 0; c < 3; c++) {
hdr10.mastering.display_primaries_x[c] =
ctr->mastering.display_primaries_x[c];
hdr10.mastering.display_primaries_y[c] =
ctr->mastering.display_primaries_y[c];
}
hdr10.mastering.white_point_x = ctr->mastering.white_point_x;
hdr10.mastering.white_point_y = ctr->mastering.white_point_y;
hdr10.mastering.max_display_mastering_luminance =
ctr->mastering.max_display_mastering_luminance;
hdr10.mastering.min_display_mastering_luminance =
ctr->mastering.min_display_mastering_luminance;
hdr10.cll.max_content_light = ctr->cll.max_content_light_level;
hdr10.cll.max_pic_average_light =
ctr->cll.max_pic_average_light_level;
ret = hfi_session_set_property(inst, ptype, &hdr10);
if (ret)
return ret;
}
if (ctr->num_b_frames) {
u32 max_num_b_frames = NUM_B_FRAMES_MAX;
......
......@@ -313,6 +313,12 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
}
mutex_unlock(&inst->lock);
break;
case V4L2_CID_COLORIMETRY_HDR10_CLL_INFO:
ctr->cll = *ctrl->p_new.p_hdr10_cll;
break;
case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
ctr->mastering = *ctrl->p_new.p_hdr10_mastering;
break;
default:
return -EINVAL;
}
......@@ -328,7 +334,7 @@ int venc_ctrl_init(struct venus_inst *inst)
{
int ret;
ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 55);
ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 57);
if (ret)
return ret;
......@@ -550,6 +556,14 @@ int venc_ctrl_init(struct venus_inst *inst)
V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX, 0,
(MAX_LTR_FRAME_COUNT - 1), 1, 0);
v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops,
V4L2_CID_COLORIMETRY_HDR10_CLL_INFO,
v4l2_ctrl_ptr_create(NULL));
v4l2_ctrl_new_std_compound(&inst->ctrl_handler, &venc_ctrl_ops,
V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY,
v4l2_ctrl_ptr_create(NULL));
ret = inst->ctrl_handler.error;
if (ret)
goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment