Skip to contentSkip to conversation

venus: venc: add support for V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM control

PATCH Superseded Mansur Alisha Shaik 3 participants 4 messages May 31, 2021 – Jun 14, 2021

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 venus: venc: add support for V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM control

Add support for V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM control for H264 high profile and constrained high profile.

---
 drivers/media/platform/qcom/venus/core.h       |  1 +
 drivers/media/platform/qcom/venus/hfi_cmds.c   | 10 ++++++++++
 drivers/media/platform/qcom/venus/hfi_helper.h |  5 +++++
 drivers/media/platform/qcom/venus/venc.c       | 11 +++++++++++
 drivers/media/platform/qcom/venus/venc_ctrls.c | 12 +++++++++++-
 5 files changed, 38 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/venus/core.h +1 -0
index 745f226..103fbd8 100644
@@ -235,6 +235,7 @@ struct venc_controls {
 	u32 h264_loop_filter_mode;
 	s32 h264_loop_filter_alpha;
 	s32 h264_loop_filter_beta;
+	u32 h264_8x8_transform;
 
 	u32 hevc_i_qp;
 	u32 hevc_p_qp;
drivers/media/platform/qcom/venus/hfi_cmds.c +10 -0
index 11a8347..61d04a5 100644
@@ -1178,6 +1178,7 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt,
 {
 	void *prop_data;
 
+
 	if (!pkt || !cookie || !pdata)
 		return -EINVAL;
 
@@ -1227,6 +1228,15 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt,
 		break;
 	}
 
+	case HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8: {
+		struct hfi_h264_8x8x_transform *in = pdata, *tm = prop_data;
+
+		tm->enable_type = in->enable_type;
+		pkt->shdr.hdr.size += sizeof(u32) + sizeof(*tm);
+		break;
+
+	}
+
 	case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE:
 	case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER:
 	case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE:
drivers/media/platform/qcom/venus/hfi_helper.h +5 -0
index 63cd347..81d0536 100644
@@ -510,6 +510,7 @@
 #define HFI_PROPERTY_PARAM_VENC_MAX_NUM_B_FRAMES		0x2005020
 #define HFI_PROPERTY_PARAM_VENC_H264_VUI_BITSTREAM_RESTRC	0x2005021
 #define HFI_PROPERTY_PARAM_VENC_PRESERVE_TEXT_QUALITY		0x2005023
+#define HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8			0x2005025
 #define HFI_PROPERTY_PARAM_VENC_HIER_P_MAX_NUM_ENH_LAYER	0x2005026
 #define HFI_PROPERTY_PARAM_VENC_DISABLE_RC_TIMESTAMP		0x2005027
 #define HFI_PROPERTY_PARAM_VENC_INITIAL_QP			0x2005028
@@ -565,6 +566,10 @@ struct hfi_bitrate {
 	u32 layer_id;
 };
 
+struct hfi_h264_8x8x_transform {
+	u32 enable_type;
+};
+
 #define HFI_CAPABILITY_FRAME_WIDTH			0x01
 #define HFI_CAPABILITY_FRAME_HEIGHT			0x02
 #define HFI_CAPABILITY_MBS_PER_FRAME			0x03
drivers/media/platform/qcom/venus/venc.c +11 -0
index 8dd49d4..4ecf331 100644
@@ -567,6 +567,7 @@ static int venc_set_properties(struct venus_inst *inst)
 		struct hfi_h264_vui_timing_info info;
 		struct hfi_h264_entropy_control entropy;
 		struct hfi_h264_db_control deblock;
+		struct hfi_h264_8x8x_transform h264_transform;
 
 		ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO;
 		info.enable = 1;
@@ -597,6 +598,16 @@ static int venc_set_properties(struct venus_inst *inst)
 		ret = hfi_session_set_property(inst, ptype, &deblock);
 		if (ret)
 			return ret;
+
+		ptype = HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8;
+		if (ctr->profile.h264 == HFI_H264_PROFILE_HIGH ||
+			ctr->profile.h264 == HFI_H264_PROFILE_CONSTRAINED_HIGH)
+			h264_transform.enable_type = ctr->h264_8x8_transform;
+
+		ret = hfi_session_set_property(inst, ptype, &h264_transform);
+		if (ret)
+			return ret;
+
 	}
 
 	if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 ||
drivers/media/platform/qcom/venus/venc_ctrls.c +11 -1
index 637c92f..e3ef611 100644
@@ -319,6 +319,13 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
 	case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
 		ctr->mastering = *ctrl->p_new.p_hdr10_mastering;
 		break;
+	case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
+		if (ctr->profile.h264 != HFI_H264_PROFILE_HIGH ||
+			ctr->profile.h264 != HFI_H264_PROFILE_CONSTRAINED_HIGH)
+			return -EINVAL;
+
+		ctr->h264_8x8_transform = ctrl->val;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -334,7 +341,7 @@ int venc_ctrl_init(struct venus_inst *inst)
 {
 	int ret;
 
-	ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 57);
+	ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 58);
 	if (ret)
 		return ret;
 
@@ -438,6 +445,9 @@ int venc_ctrl_init(struct venus_inst *inst)
 			  V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP, 1, 51, 1, 1);
 
 	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
+		V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM, 0, 1, 1, 0);
+
+	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
 			  V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP, 1, 51, 1, 1);
 
 	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation
#1 lore raw
Quoted 29 lines · Mansur Alisha Shaik

Add support for V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM control for H264 high profile and constrained high profile.

---
 drivers/media/platform/qcom/venus/core.h       |  1 +
 drivers/media/platform/qcom/venus/hfi_cmds.c   | 10 ++++++++++
 drivers/media/platform/qcom/venus/hfi_helper.h |  5 +++++
 drivers/media/platform/qcom/venus/venc.c       | 11 +++++++++++
 drivers/media/platform/qcom/venus/venc_ctrls.c | 12 +++++++++++-
 5 files changed, 38 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/venus/core.h +1 -0
index 745f226..103fbd8 100644
@@ -235,6 +235,7 @@ struct venc_controls {
 	u32 h264_loop_filter_mode;
 	s32 h264_loop_filter_alpha;
 	s32 h264_loop_filter_beta;
+	u32 h264_8x8_transform;
 
 	u32 hevc_i_qp;
 	u32 hevc_p_qp;
drivers/media/platform/qcom/venus/hfi_cmds.c +0 -0
index 11a8347..61d04a5 100644

drivers/media/platform/qcom/venus/hfi_cmds.c pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt, · line 1181

Quoted 4 lines
drivers/media/platform/qcom/venus/hfi_cmds.c +1 -0
@@ -1178,6 +1178,7 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt,
 {
 	void *prop_data;
 
+

Uneeded new blank line.

drivers/media/platform/qcom/venus/hfi_cmds.c pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt, · line 1232

Quoted 9 lines
drivers/media/platform/qcom/venus/hfi_cmds.c +2 -0
 	if (!pkt || !cookie || !pdata)
 		return -EINVAL;
 
@@ -1227,6 +1228,15 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt,
 		break;
 	}
 
+	case HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8: {
+		struct hfi_h264_8x8x_transform *in = pdata, *tm = prop_data;

s/hfi_h264_8x8x_transform/hfi_h264_8x8_transform

Quoted 23 lines
drivers/media/platform/qcom/venus/hfi_cmds.c +7 -0
+
+		tm->enable_type = in->enable_type;
+		pkt->shdr.hdr.size += sizeof(u32) + sizeof(*tm);
+		break;
+
+	}
+
 	case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE:
 	case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER:
 	case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE:
drivers/media/platform/qcom/venus/hfi_helper.h +1 -0
index 63cd347..81d0536 100644
@@ -510,6 +510,7 @@
 #define HFI_PROPERTY_PARAM_VENC_MAX_NUM_B_FRAMES		0x2005020
 #define HFI_PROPERTY_PARAM_VENC_H264_VUI_BITSTREAM_RESTRC	0x2005021
 #define HFI_PROPERTY_PARAM_VENC_PRESERVE_TEXT_QUALITY		0x2005023
+#define HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8			0x2005025
 #define HFI_PROPERTY_PARAM_VENC_HIER_P_MAX_NUM_ENH_LAYER	0x2005026
 #define HFI_PROPERTY_PARAM_VENC_DISABLE_RC_TIMESTAMP		0x2005027
 #define HFI_PROPERTY_PARAM_VENC_INITIAL_QP			0x2005028

drivers/media/platform/qcom/venus/hfi_helper.h struct hfi_bitrate { · line 569

Quoted 4 lines
drivers/media/platform/qcom/venus/hfi_helper.h +1 -0
@@ -565,6 +566,10 @@ struct hfi_bitrate {
 	u32 layer_id;
 };
 
+struct hfi_h264_8x8x_transform {

s/hfi_h264_8x8x_transform/hfi_h264_8x8_transform

Quoted 11 lines
drivers/media/platform/qcom/venus/hfi_helper.h +3 -0
+	u32 enable_type;
+};
+
 #define HFI_CAPABILITY_FRAME_WIDTH			0x01
 #define HFI_CAPABILITY_FRAME_HEIGHT			0x02
 #define HFI_CAPABILITY_MBS_PER_FRAME			0x03
drivers/media/platform/qcom/venus/venc.c +0 -0
index 8dd49d4..4ecf331 100644

drivers/media/platform/qcom/venus/venc.c static int venc_set_properties(struct venus_inst *inst) · line 570

Quoted 4 lines
drivers/media/platform/qcom/venus/venc.c +1 -0
@@ -567,6 +567,7 @@ static int venc_set_properties(struct venus_inst *inst)
 		struct hfi_h264_vui_timing_info info;
 		struct hfi_h264_entropy_control entropy;
 		struct hfi_h264_db_control deblock;
+		struct hfi_h264_8x8x_transform h264_transform;

ditto

drivers/media/platform/qcom/venus/venc.c static int venc_set_properties(struct venus_inst *inst) · line 604

Quoted 11 lines
drivers/media/platform/qcom/venus/venc.c +4 -0
 		ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO;
 		info.enable = 1;
@@ -597,6 +598,16 @@ static int venc_set_properties(struct venus_inst *inst)
 		ret = hfi_session_set_property(inst, ptype, &deblock);
 		if (ret)
 			return ret;
+
+		ptype = HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8;
+		if (ctr->profile.h264 == HFI_H264_PROFILE_HIGH ||
+			ctr->profile.h264 == HFI_H264_PROFILE_CONSTRAINED_HIGH)

checkpatch.pl --strict should complain about this ctr->profile.h264 alignment.

Quoted 14 lines
drivers/media/platform/qcom/venus/venc.c +6 -0
+			h264_transform.enable_type = ctr->h264_8x8_transform;
+
+		ret = hfi_session_set_property(inst, ptype, &h264_transform);
+		if (ret)
+			return ret;
+
 	}
 
 	if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 ||
drivers/media/platform/qcom/venus/venc_ctrls.c +0 -0
index 637c92f..e3ef611 100644

drivers/media/platform/qcom/venus/venc_ctrls.c static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) · line 324

Quoted 6 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +3 -0
@@ -319,6 +319,13 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
 	case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
 		ctr->mastering = *ctrl->p_new.p_hdr10_mastering;
 		break;
+	case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
+		if (ctr->profile.h264 != HFI_H264_PROFILE_HIGH ||
+			ctr->profile.h264 != HFI_H264_PROFILE_CONSTRAINED_HIGH)

ditto

Quoted 27 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +8 -1
+			return -EINVAL;
+
+		ctr->h264_8x8_transform = ctrl->val;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -334,7 +341,7 @@ int venc_ctrl_init(struct venus_inst *inst)
 {
 	int ret;
 
-	ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 57);
+	ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 58);
 	if (ret)
 		return ret;
 
@@ -438,6 +445,9 @@ int venc_ctrl_init(struct venus_inst *inst)
 			  V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP, 1, 51, 1, 1);
 
 	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
+		V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM, 0, 1, 1, 0);
+
+	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
 			  V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP, 1, 51, 1, 1);
 
 	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
Signature · 2 lines
regards,
Stan
#2 lore raw
In reply to Mansur Alisha Shaik
Quoted 110 lines · Mansur Alisha Shaik

Add support for V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM control for H264 high profile and constrained high profile.

---
 drivers/media/platform/qcom/venus/core.h       |  1 +
 drivers/media/platform/qcom/venus/hfi_cmds.c   | 10 ++++++++++
 drivers/media/platform/qcom/venus/hfi_helper.h |  5 +++++
 drivers/media/platform/qcom/venus/venc.c       | 11 +++++++++++
 drivers/media/platform/qcom/venus/venc_ctrls.c | 12 +++++++++++-
 5 files changed, 38 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/venus/core.h +1 -0
index 745f226..103fbd8 100644
@@ -235,6 +235,7 @@ struct venc_controls {
        u32 h264_loop_filter_mode;
        s32 h264_loop_filter_alpha;
        s32 h264_loop_filter_beta;
+       u32 h264_8x8_transform;
 
        u32 hevc_i_qp;
        u32 hevc_p_qp;
drivers/media/platform/qcom/venus/hfi_cmds.c +10 -0
index 11a8347..61d04a5 100644
@@ -1178,6 +1178,7 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt,
 {
        void *prop_data;
 
+
        if (!pkt || !cookie || !pdata)
                return -EINVAL;
 
@@ -1227,6 +1228,15 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt,
                break;
        }
 
+       case HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8: {
+               struct hfi_h264_8x8x_transform *in = pdata, *tm = prop_data;
+
+               tm->enable_type = in->enable_type;
+               pkt->shdr.hdr.size += sizeof(u32) + sizeof(*tm);
+               break;
+
+       }
+
        case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE:
        case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER:
        case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE:
drivers/media/platform/qcom/venus/hfi_helper.h +5 -0
index 63cd347..81d0536 100644
@@ -510,6 +510,7 @@
 #define HFI_PROPERTY_PARAM_VENC_MAX_NUM_B_FRAMES               0x2005020
 #define HFI_PROPERTY_PARAM_VENC_H264_VUI_BITSTREAM_RESTRC      0x2005021
 #define HFI_PROPERTY_PARAM_VENC_PRESERVE_TEXT_QUALITY          0x2005023
+#define HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8                     0x2005025
 #define HFI_PROPERTY_PARAM_VENC_HIER_P_MAX_NUM_ENH_LAYER       0x2005026
 #define HFI_PROPERTY_PARAM_VENC_DISABLE_RC_TIMESTAMP           0x2005027
 #define HFI_PROPERTY_PARAM_VENC_INITIAL_QP                     0x2005028
@@ -565,6 +566,10 @@ struct hfi_bitrate {
        u32 layer_id;
 };
 
+struct hfi_h264_8x8x_transform {
+       u32 enable_type;
+};
+
 #define HFI_CAPABILITY_FRAME_WIDTH                     0x01
 #define HFI_CAPABILITY_FRAME_HEIGHT                    0x02
 #define HFI_CAPABILITY_MBS_PER_FRAME                   0x03
drivers/media/platform/qcom/venus/venc.c +11 -0
index 8dd49d4..4ecf331 100644
@@ -567,6 +567,7 @@ static int venc_set_properties(struct venus_inst *inst)
                struct hfi_h264_vui_timing_info info;
                struct hfi_h264_entropy_control entropy;
                struct hfi_h264_db_control deblock;
+               struct hfi_h264_8x8x_transform h264_transform;
 
                ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO;
                info.enable = 1;
@@ -597,6 +598,16 @@ static int venc_set_properties(struct venus_inst *inst)
                ret = hfi_session_set_property(inst, ptype, &deblock);
                if (ret)
                        return ret;
+
+               ptype = HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8;
+               if (ctr->profile.h264 == HFI_H264_PROFILE_HIGH ||
+                       ctr->profile.h264 == HFI_H264_PROFILE_CONSTRAINED_HIGH)
+                       h264_transform.enable_type = ctr->h264_8x8_transform;
+
+               ret = hfi_session_set_property(inst, ptype, &h264_transform);
+               if (ret)
+                       return ret;
+
        }
 
        if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 ||
drivers/media/platform/qcom/venus/venc_ctrls.c +0 -0
index 637c92f..e3ef611 100644

drivers/media/platform/qcom/venus/venc_ctrls.c static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) · line 324

Quoted 6 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +3 -0
@@ -319,6 +319,13 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
        case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
                ctr->mastering = *ctrl->p_new.p_hdr10_mastering;
                break;
+       case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
+               if (ctr->profile.h264 != HFI_H264_PROFILE_HIGH ||
+                       ctr->profile.h264 != HFI_H264_PROFILE_CONSTRAINED_HIGH)

This appears to be incorrect as the comparison will always be true. I think it should be written as:

               if (ctr->profile.h264 == HFI_H264_PROFILE_HIGH ||
                       ctr->profile.h264 == HFI_H264_PROFILE_CONSTRAINED_HIGH)
                       ctr->h264_8x8_transform = ctrl->val;

drivers/media/platform/qcom/venus/venc_ctrls.c static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) · line 325

Quoted 1 line
drivers/media/platform/qcom/venus/venc_ctrls.c +1 -0
+                       return -EINVAL;

I'm not sure -EINVAL is appropriate here. venc_op_s_ctrl will be called to initialize the default control values from v4l2_ctrl_handler_setup. If the default profile isn't high or constrained high, the driver will fail to initialize.

Quoted 30 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +3 -0
+
+               ctr->h264_8x8_transform = ctrl->val;
+               break;
 
        default:
                return -EINVAL;
        }
drivers/media/platform/qcom/venus/venc_ctrls.c +4 -2
@@ -334,7 +341,7 @@ int venc_ctrl_init(struct venus_inst *inst)
 {
        int ret;
 
-       ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 57);
+       ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 58);
        if (ret)
                return ret;
 
@@ -438,6 +445,9 @@ int venc_ctrl_init(struct venus_inst *inst)
                          V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP, 1, 51, 1, 1);
 
        v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
+               V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM, 0, 1, 1, 0);
+
+       v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
                          V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP, 1, 51, 1, 1);
 
        v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
--

QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

#3 lore raw
Quoted 145 lines · Fritz Koenig
Quoted 144 lines
Quoted 126 lines · Mansur Alisha Shaik

Add support for V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM control for H264 high profile and constrained high profile.

---
 drivers/media/platform/qcom/venus/core.h       |  1 +
 drivers/media/platform/qcom/venus/hfi_cmds.c   | 10 ++++++++++
 drivers/media/platform/qcom/venus/hfi_helper.h |  5 +++++
 drivers/media/platform/qcom/venus/venc.c       | 11 +++++++++++
 drivers/media/platform/qcom/venus/venc_ctrls.c | 12 +++++++++++-
 5 files changed, 38 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/venus/core.h +1 -0
index 745f226..103fbd8 100644
@@ -235,6 +235,7 @@ struct venc_controls {
        u32 h264_loop_filter_mode;
        s32 h264_loop_filter_alpha;
        s32 h264_loop_filter_beta;
+       u32 h264_8x8_transform;
 
        u32 hevc_i_qp;
        u32 hevc_p_qp;
drivers/media/platform/qcom/venus/hfi_cmds.c +10 -0
index 11a8347..61d04a5 100644
@@ -1178,6 +1178,7 @@ pkt_session_set_property_4xx(struct 
 hfi_session_set_property_pkt *pkt,
 {
        void *prop_data;
 
+
        if (!pkt || !cookie || !pdata)
                return -EINVAL;
@@ -1227,6 +1228,15 @@ pkt_session_set_property_4xx(struct 
 hfi_session_set_property_pkt *pkt,
                break;
        }
 
+       case HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8: {
+               struct hfi_h264_8x8x_transform *in = pdata, *tm = 
 prop_data;
+
+               tm->enable_type = in->enable_type;
+               pkt->shdr.hdr.size += sizeof(u32) + sizeof(*tm);
+               break;
+
+       }
+
        case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE:

case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER:
case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE:

drivers/media/platform/qcom/venus/hfi_helper.h +0 -0
index 63cd347..81d0536 100644
@@ -510,6 +510,7 @@
 #define HFI_PROPERTY_PARAM_VENC_MAX_NUM_B_FRAMES               

0x2005020
#define HFI_PROPERTY_PARAM_VENC_H264_VUI_BITSTREAM_RESTRC
0x2005021
#define HFI_PROPERTY_PARAM_VENC_PRESERVE_TEXT_QUALITY
0x2005023
+#define HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8
0x2005025
#define HFI_PROPERTY_PARAM_VENC_HIER_P_MAX_NUM_ENH_LAYER
0x2005026
#define HFI_PROPERTY_PARAM_VENC_DISABLE_RC_TIMESTAMP
0x2005027
#define HFI_PROPERTY_PARAM_VENC_INITIAL_QP
0x2005028

drivers/media/platform/qcom/venus/hfi_helper.h +4 -0
@@ -565,6 +566,10 @@ struct hfi_bitrate {
        u32 layer_id;
 };
 
+struct hfi_h264_8x8x_transform {
+       u32 enable_type;
+};
+
 #define HFI_CAPABILITY_FRAME_WIDTH                     0x01
 #define HFI_CAPABILITY_FRAME_HEIGHT                    0x02
 #define HFI_CAPABILITY_MBS_PER_FRAME                   0x03
drivers/media/platform/qcom/venus/venc.c +1 -0
index 8dd49d4..4ecf331 100644
@@ -567,6 +567,7 @@ static int venc_set_properties(struct venus_inst 
 *inst)
                struct hfi_h264_vui_timing_info info;
                struct hfi_h264_entropy_control entropy;
                struct hfi_h264_db_control deblock;
+               struct hfi_h264_8x8x_transform h264_transform;
 
                ptype = HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO;
                info.enable = 1;
drivers/media/platform/qcom/venus/venc.c +5 -0
@@ -597,6 +598,16 @@ static int venc_set_properties(struct venus_inst 
 *inst)
                ret = hfi_session_set_property(inst, ptype, 
 &deblock);
                if (ret)
                        return ret;
+
+               ptype = HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8;
+               if (ctr->profile.h264 == HFI_H264_PROFILE_HIGH ||
+                       ctr->profile.h264 == 
 HFI_H264_PROFILE_CONSTRAINED_HIGH)
+                       h264_transform.enable_type = 

ctr->h264_8x8_transform;

drivers/media/platform/qcom/venus/venc.c +2 -0
+
+               ret = hfi_session_set_property(inst, ptype, 

&h264_transform);

drivers/media/platform/qcom/venus/venc.c +3 -0
+               if (ret)
+                       return ret;
+
        }
 
        if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 ||
drivers/media/platform/qcom/venus/venc_ctrls.c +0 -0
index 637c92f..e3ef611 100644

drivers/media/platform/qcom/venus/venc_ctrls.c static int venc_op_s_ctrl(struct v4l2_ctrl · line 326

Quoted 8 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +3 -0
@@ -319,6 +319,13 @@ static int venc_op_s_ctrl(struct v4l2_ctrl 
 *ctrl)
        case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY:
                ctr->mastering = *ctrl->p_new.p_hdr10_mastering;
                break;
+       case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM:
+               if (ctr->profile.h264 != HFI_H264_PROFILE_HIGH ||
+                       ctr->profile.h264 != 
 HFI_H264_PROFILE_CONSTRAINED_HIGH)

This appears to be incorrect as the comparison will always be true. I think it should be written as:

               if (ctr->profile.h264 == HFI_H264_PROFILE_HIGH ||
                       ctr->profile.h264 == 
HFI_H264_PROFILE_CONSTRAINED_HIGH)
                       ctr->h264_8x8_transform = ctrl->val;
Quoted 7 lines
Quoted 7 lines

drivers/media/platform/qcom/venus/venc_ctrls.c static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) · line 325

Quoted 1 line
drivers/media/platform/qcom/venus/venc_ctrls.c +1 -0
+                       return -EINVAL;

I'm not sure -EINVAL is appropriate here. venc_op_s_ctrl will be called to initialize the default control values from v4l2_ctrl_handler_setup. If the default profile isn't high or constrained high, the driver will fail to initialize.

As per codec spec, the 8x8 transform is enabled for high profile and constrained high profile, but I didn't found any document what happens when we set 8x8 transform for other profiles.
Hence added a check to reject other profiles to inform the same to client

Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +3 -0
+
+               ctr->h264_8x8_transform = ctrl->val;
+               break;
 
        default:
                return -EINVAL;
        }
drivers/media/platform/qcom/venus/venc_ctrls.c +4 -1
@@ -334,7 +341,7 @@ int venc_ctrl_init(struct venus_inst *inst)
 {
        int ret;
 
-       ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 57);
+       ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 58);
        if (ret)
                return ret;
 
@@ -438,6 +445,9 @@ int venc_ctrl_init(struct venus_inst *inst)
                          V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP, 1, 
 51, 1, 1);
 
        v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
+               V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM, 0, 1, 1, 0);
+
+       v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
                          V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP, 1, 
 51, 1, 1);
        v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,

--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation