Skip to contentSkip to conversation

Add HANTRO G2/HEVC decoder support for IMX8MQ

PATCH Superseded Benjamin Gaignard 5 participants 21 messages Feb 18, 2021 – Feb 22, 2021

Subsystems (8)

v2 of 13 Superseded Latest is v13 →

lore
Share & tools
lore

Benjamin Gaignard

author maintainer
#0 lore raw

v2 cover Add HANTRO G2/HEVC decoder support for IMX8MQ

The IMX8MQ got two VPUs but until now only G1 has been enabled. This series aim to add the second VPU (aka G2) and provide basic HEVC decoding support.

To be able to decode HEVC it is needed to add/update some of the structures in the uapi. In addition of them one HANTRO dedicated control is required to inform the driver of the numbre of bits to skip at the beginning of the slice header.
The hardware require to allocate few auxiliary buffers to store the references frame or tile size data.

The driver has been tested with fluster test suite stream.
For example with this command: ./fluster.py run -ts JCT-VC-HEVC_V1 -d GStreamer-H.265-V4L2SL-Gst1.0

This series depends of the reset rework posted here: https://www.spinics.net/lists/arm-kernel/msg875766.html

Finally the both VPUs will have a node the device-tree and be independent from v4l2 point of view.

A branch with all the dev is available here:
https://gitlab.collabora.com/benjamin.gaignard/for-upstream/-/commits/upstream_g2_v2

version 2:
- remove all change related to scaling
- squash commits to a coherent split
- be more verbose about the added fields
- fix the comments done by Ezequiel about dma_alloc_coherent usage
- fix Dan's comments about control copy, reverse the test logic in tile_buffer_reallocate, rework some goto and return cases.
- be more verbose about why I change the bindings
- remove all sign-off expect mime since it is confusing
- remove useless clocks in VPUs nodes

Benjamin

Benjamin Gaignard (9):
media: hevc: Modify structures to follow H265 ITU spec
media: hantro: Define HEVC codec profiles and supported features
media: hantro: Add a field to distinguish the hardware versions
media: uapi: Add a control for HANTRO driver
media: hantro: Introduce G2/HEVC decoder
media: hantro: handle V4L2_PIX_FMT_HEVC_SLICE control
media: hantro: IMX8M: add variant for G2/HEVC codec
dt-bindings: media: nxp,imx8mq-vpu: Update bindings
arm64: dts: imx8mq: Add node to G2 hardware

 .../bindings/media/nxp,imx8mq-vpu.yaml        |  54 +-
 arch/arm64/boot/dts/freescale/imx8mq.dtsi     |  41 +-
 drivers/media/v4l2-core/v4l2-ctrls.c          |  26 +-
 drivers/staging/media/hantro/Makefile         |   2 +
 drivers/staging/media/hantro/hantro.h         |  34 +-
 drivers/staging/media/hantro/hantro_drv.c     | 103 +++
 .../staging/media/hantro/hantro_g2_hevc_dec.c | 587 ++++++++++++++++++
 drivers/staging/media/hantro/hantro_g2_regs.h | 198 ++++++
 drivers/staging/media/hantro/hantro_hevc.c    | 321 ++++++++++
 drivers/staging/media/hantro/hantro_hw.h      |  48 ++
 .../staging/media/hantro/hantro_postproc.c    |  17 +
 drivers/staging/media/hantro/hantro_v4l2.c    |   1 +
 drivers/staging/media/hantro/imx8m_vpu_hw.c   |  95 ++-
 drivers/staging/media/sunxi/cedrus/cedrus.c   |   6 +
 drivers/staging/media/sunxi/cedrus/cedrus.h   |   1 +
 .../staging/media/sunxi/cedrus/cedrus_dec.c   |   2 +
 .../staging/media/sunxi/cedrus/cedrus_h265.c  |   6 +-
 include/media/hevc-ctrls.h                    |  45 +-
 include/uapi/linux/hantro-v4l2-controls.h     |  20 +
 include/uapi/linux/v4l2-controls.h            |   5 +
 20 files changed, 1557 insertions(+), 55 deletions(-)
 create mode 100644 drivers/staging/media/hantro/hantro_g2_hevc_dec.c
 create mode 100644 drivers/staging/media/hantro/hantro_g2_regs.h
 create mode 100644 drivers/staging/media/hantro/hantro_hevc.c
 create mode 100644 include/uapi/linux/hantro-v4l2-controls.h
Signature · 7 lines
2.25.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#1 lore raw

PATCH v2 1/9 media: hevc: Modify structures to follow H265 ITU spec

The H.265 ITU specification (section 7.4) define the general slice segment header semantics.
Modified/added fields are:
- video_parameter_set_id: (7.4.3.1) identifies the VPS for reference by other syntax elements.
- seq_parameter_set_id: (7.4.3.2.1) specifies the value of the vps_video_parameter_set_id of the active VPS.
- chroma_format_idc: (7.4.3.2.1) specifies the chroma sampling relative to the luma sampling
- pic_parameter_set_id: (7.4.3.3.1) identifies the PPS for reference by other syntax elements
- num_ref_idx_l0_default_active_minus1: (7.4.3.3.1) specifies the inferred value of num_ref_idx_l0_active_minus1
- num_ref_idx_l1_default_active_minus1: (7.4.3.3.1) specifies the inferred value of num_ref_idx_l1_active_minus1
- slice_segment_addr: (7.4.7.1) specifies the address of the first coding tree block in the slice segment
- num_entry_point_offsets: (7.4.7.1) specifies the number of entry_point_offset_minus1[ i ] syntax elements in the slice header

Add HEVC decode params contains the information used in section "8.3 Slice decoding process" of the specification to let the hardware perform decoding of a slices.

Adapt Cedrus driver according to these changes.

---
version 2:
- remove all change related to scaling
- squash commits to a coherent split
- be more verbose about the added fields

 drivers/media/v4l2-core/v4l2-ctrls.c          | 26 ++++++++---
 drivers/staging/media/sunxi/cedrus/cedrus.c   |  6 +++
 drivers/staging/media/sunxi/cedrus/cedrus.h   |  1 +
 .../staging/media/sunxi/cedrus/cedrus_dec.c   |  2 +
 .../staging/media/sunxi/cedrus/cedrus_h265.c  |  6 ++-
 include/media/hevc-ctrls.h                    | 45 +++++++++++++++----
 6 files changed, 69 insertions(+), 17 deletions(-)
drivers/media/v4l2-core/v4l2-ctrls.c +19 -7
index 016cf6204cbb..4060b5bcc3c0 100644
@@ -1028,6 +1028,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_MPEG_VIDEO_HEVC_SPS:			return "HEVC Sequence Parameter Set";
 	case V4L2_CID_MPEG_VIDEO_HEVC_PPS:			return "HEVC Picture Parameter Set";
 	case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:		return "HEVC Slice Parameters";
+	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS:		return "HEVC Decode Parameters";
 	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE:		return "HEVC Decode Mode";
 	case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE:		return "HEVC Start Code";
 
@@ -1482,6 +1483,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:
 		*type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS;
 		break;
+	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS:
+		*type = V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS;
+		break;
 	case V4L2_CID_UNIT_CELL_SIZE:
 		*type = V4L2_CTRL_TYPE_AREA;
 		*flags |= V4L2_CTRL_FLAG_READ_ONLY;
@@ -1833,6 +1837,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
 	struct v4l2_ctrl_hevc_sps *p_hevc_sps;
 	struct v4l2_ctrl_hevc_pps *p_hevc_pps;
 	struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
+	struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;
 	struct v4l2_area *area;
 	void *p = ptr.p + idx * ctrl->elem_size;
 	unsigned int i;
@@ -2108,23 +2113,27 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
 		zero_padding(*p_hevc_pps);
 		break;
 
-	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
-		p_hevc_slice_params = p;
+	case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
+		p_hevc_decode_params = p;
 
-		if (p_hevc_slice_params->num_active_dpb_entries >
+		if (p_hevc_decode_params->num_active_dpb_entries >
 		    V4L2_HEVC_DPB_ENTRIES_NUM_MAX)
 			return -EINVAL;
 
-		zero_padding(p_hevc_slice_params->pred_weight_table);
-
-		for (i = 0; i < p_hevc_slice_params->num_active_dpb_entries;
+		for (i = 0; i < p_hevc_decode_params->num_active_dpb_entries;
 		     i++) {
 			struct v4l2_hevc_dpb_entry *dpb_entry =
-				&p_hevc_slice_params->dpb[i];
+				&p_hevc_decode_params->dpb[i];
 
 			zero_padding(*dpb_entry);
 		}
 
+		break;
+
+	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
+		p_hevc_slice_params = p;
+
+		zero_padding(p_hevc_slice_params->pred_weight_table);
 		zero_padding(*p_hevc_slice_params);
 		break;
 
@@ -2821,6 +2830,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
 	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
 		elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
 		break;
+	case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
+		elem_size = sizeof(struct v4l2_ctrl_hevc_decode_params);
+		break;
 	case V4L2_CTRL_TYPE_AREA:
 		elem_size = sizeof(struct v4l2_area);
 		break;
drivers/staging/media/sunxi/cedrus/cedrus.c +6 -0
index 7bd9291c8d5f..4cd3cab1a257 100644
@@ -151,6 +151,12 @@ static const struct cedrus_control cedrus_controls[] = {
 		},
 		.codec		= CEDRUS_CODEC_VP8,
 	},
+	{
+		.cfg = {
+			.id = V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS,
+		},
+		.codec		= CEDRUS_CODEC_H265,
+	},
 };
 
 #define CEDRUS_CONTROLS_COUNT	ARRAY_SIZE(cedrus_controls)
drivers/staging/media/sunxi/cedrus/cedrus.h +1 -0
index 251a6a660351..2ca33ac38b9a 100644
@@ -76,6 +76,7 @@ struct cedrus_h265_run {
 	const struct v4l2_ctrl_hevc_sps			*sps;
 	const struct v4l2_ctrl_hevc_pps			*pps;
 	const struct v4l2_ctrl_hevc_slice_params	*slice_params;
+	const struct v4l2_ctrl_hevc_decode_params	*decode_params;
 };
 
 struct cedrus_vp8_run {
drivers/staging/media/sunxi/cedrus/cedrus_dec.c +2 -0
index a9090daf626a..cd821f417a14 100644
@@ -68,6 +68,8 @@ void cedrus_device_run(void *priv)
 			V4L2_CID_MPEG_VIDEO_HEVC_PPS);
 		run.h265.slice_params = cedrus_find_control_data(ctx,
 			V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS);
+		run.h265.decode_params = cedrus_find_control_data(ctx,
+			V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS);
 		break;
 
 	case V4L2_PIX_FMT_VP8_FRAME:
drivers/staging/media/sunxi/cedrus/cedrus_h265.c +4 -2
index ce497d0197df..dce5db6be13a 100644
@@ -245,6 +245,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 	const struct v4l2_ctrl_hevc_sps *sps;
 	const struct v4l2_ctrl_hevc_pps *pps;
 	const struct v4l2_ctrl_hevc_slice_params *slice_params;
+	const struct v4l2_ctrl_hevc_decode_params *decode_params;
 	const struct v4l2_hevc_pred_weight_table *pred_weight_table;
 	dma_addr_t src_buf_addr;
 	dma_addr_t src_buf_end_addr;
@@ -256,6 +257,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 	sps = run->h265.sps;
 	pps = run->h265.pps;
 	slice_params = run->h265.slice_params;
+	decode_params = run->h265.decode_params;
 	pred_weight_table = &slice_params->pred_weight_table;
 
 	/* MV column buffer size and allocation. */
@@ -487,7 +489,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 
 	reg = VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_TC_OFFSET_DIV2(slice_params->slice_tc_offset_div2) |
 	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_BETA_OFFSET_DIV2(slice_params->slice_beta_offset_div2) |
-	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST(slice_params->num_rps_poc_st_curr_after == 0) |
+	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST(decode_params->num_rps_poc_st_curr_after == 0) |
 	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CR_QP_OFFSET(slice_params->slice_cr_qp_offset) |
 	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CB_QP_OFFSET(slice_params->slice_cb_qp_offset) |
 	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_QP_DELTA(slice_params->slice_qp_delta);
@@ -528,7 +530,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 
 	/* Write decoded picture buffer in pic list. */
 	cedrus_h265_frame_info_write_dpb(ctx, slice_params->dpb,
-					 slice_params->num_active_dpb_entries);
+					 decode_params->num_active_dpb_entries);
 
 	/* Output frame. */
 
include/media/hevc-ctrls.h +37 -8

106 lines not on this page · raw message

Signature · 7 lines
2.25.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
#2 lore raw

Re: [PATCH v2 1/9] media: hevc: Modify structures to follow H265 ITU spec

Hi!

Dne četrtek, 18. februar 2021 ob 20:18:36 CET je Benjamin Gaignard napisal(a):

drivers/media/v4l2-core/

Quoted 42 lines

The H.265 ITU specification (section 7.4) define the general slice segment header semantics.
Modified/added fields are:
- video_parameter_set_id: (7.4.3.1) identifies the VPS for reference by other syntax elements.
- seq_parameter_set_id: (7.4.3.2.1) specifies the value of the vps_video_parameter_set_id of the active VPS.
- chroma_format_idc: (7.4.3.2.1) specifies the chroma sampling relative to the luma sampling
- pic_parameter_set_id: (7.4.3.3.1) identifies the PPS for reference by other syntax elements
- num_ref_idx_l0_default_active_minus1: (7.4.3.3.1) specifies the inferred value of num_ref_idx_l0_active_minus1
- num_ref_idx_l1_default_active_minus1: (7.4.3.3.1) specifies the inferred value of num_ref_idx_l1_active_minus1
- slice_segment_addr: (7.4.7.1) specifies the address of the first coding tree block in the slice segment
- num_entry_point_offsets: (7.4.7.1) specifies the number of entry_point_offset_minus1[ i ] syntax elements in the slice header

Add HEVC decode params contains the information used in section "8.3 Slice decoding process" of the specification to let the hardware perform decoding of a slices.

Adapt Cedrus driver according to these changes.

---
version 2:
- remove all change related to scaling
- squash commits to a coherent split
- be more verbose about the added fields

 drivers/media/v4l2-core/v4l2-ctrls.c          | 26 ++++++++---
 drivers/staging/media/sunxi/cedrus/cedrus.c   |  6 +++
 drivers/staging/media/sunxi/cedrus/cedrus.h   |  1 +
 .../staging/media/sunxi/cedrus/cedrus_dec.c   |  2 +
 .../staging/media/sunxi/cedrus/cedrus_h265.c  |  6 ++-
 include/media/hevc-ctrls.h                    | 45 +++++++++++++++----
 6 files changed, 69 insertions(+), 17 deletions(-)
drivers/media/v4l2-core/ renamed from drivers/media/v4l2-core/v4l2-ctrls.c +0 -0

v4l2-ctrls.c

drivers/media/v4l2-core/v4l2-ctrls.c const char *v4l2_ctrl_get_name(u32 id) · line 1028

Quoted 5 lines

index 016cf6204cbb..4060b5bcc3c0 100644

drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
@@ -1028,6 +1028,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_MPEG_VIDEO_HEVC_SPS:			

return "HEVC Sequence Parameter Set";

drivers/media/v4l2-core/v4l2-ctrls.c const char *v4l2_ctrl_get_name(u32 id) · line 1029

Quoted 1 line
drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
 	case V4L2_CID_MPEG_VIDEO_HEVC_PPS:			

return "HEVC Picture Parameter Set";

drivers/media/v4l2-core/v4l2-ctrls.c const char *v4l2_ctrl_get_name(u32 id) · line 1030

Quoted 1 line
drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
 	case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:		return 

"HEVC Slice Parameters";

drivers/media/v4l2-core/v4l2-ctrls.c void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, · line 1486

Quoted 1 line
drivers/media/v4l2-core/v4l2-ctrls.c +1 -0
+	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS:		

return "HEVC Decode Parameters";

drivers/media/v4l2-core/v4l2-ctrls.c const char *v4l2_ctrl_get_name(u32 id) · line 1032

Quoted 1 line
drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
 	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE:		return "HEVC 

Decode Mode";

drivers/media/v4l2-core/v4l2-ctrls.c const char *v4l2_ctrl_get_name(u32 id) · line 1033

Quoted 1 line
drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
 	case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE:		return 

"HEVC Start Code";

drivers/media/v4l2-core/v4l2-ctrls.c void v4l2_ctrl_fill(u32 id, const char **name, enum

Quoted 2 lines
drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
@@ -1482,6 +1483,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 

v4l2_ctrl_type *type,

drivers/media/v4l2-core/v4l2-ctrls.c static int std_validate_compound(const struct

Quoted 10 lines
drivers/media/v4l2-core/v4l2-ctrls.c +3 -0
 	case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:
 		*type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS;
 		break;
+	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS:
+		*type = V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS;
+		break;
 	case V4L2_CID_UNIT_CELL_SIZE:
 		*type = V4L2_CTRL_TYPE_AREA;
 		*flags |= V4L2_CTRL_FLAG_READ_ONLY;
@@ -1833,6 +1837,7 @@ static int std_validate_compound(const struct 

v4l2_ctrl *ctrl, u32 idx,

drivers/media/v4l2-core/v4l2-ctrls.c static int std_validate_compound(const struct

Quoted 8 lines
drivers/media/v4l2-core/v4l2-ctrls.c +1 -0
 	struct v4l2_ctrl_hevc_sps *p_hevc_sps;
 	struct v4l2_ctrl_hevc_pps *p_hevc_pps;
 	struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
+	struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;
 	struct v4l2_area *area;
 	void *p = ptr.p + idx * ctrl->elem_size;
 	unsigned int i;
@@ -2108,23 +2113,27 @@ static int std_validate_compound(const struct 

v4l2_ctrl *ctrl, u32 idx,

drivers/media/v4l2-core/v4l2-ctrls.c static struct v4l2_ctrl *v4l2_ctrl_new(struct

Quoted 37 lines
drivers/media/v4l2-core/v4l2-ctrls.c +11 -7
 		zero_padding(*p_hevc_pps);
 		break;
 
-	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
-		p_hevc_slice_params = p;
+	case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
+		p_hevc_decode_params = p;
 
-		if (p_hevc_slice_params->num_active_dpb_entries >
+		if (p_hevc_decode_params->num_active_dpb_entries >
 		    V4L2_HEVC_DPB_ENTRIES_NUM_MAX)
 			return -EINVAL;
 
-		zero_padding(p_hevc_slice_params->pred_weight_table);
-
-		for (i = 0; i < p_hevc_slice_params-
 num_active_dpb_entries;
+		for (i = 0; i < p_hevc_decode_params-
 num_active_dpb_entries;
 		     i++) {
 			struct v4l2_hevc_dpb_entry *dpb_entry =
-				&p_hevc_slice_params->dpb[i];
+				&p_hevc_decode_params->dpb[i];
 
 			zero_padding(*dpb_entry);
 		}
 
+		break;
+
+	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
+		p_hevc_slice_params = p;
+
+		zero_padding(p_hevc_slice_params->pred_weight_table);
 		zero_padding(*p_hevc_slice_params);
drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
 		break;
@@ -2821,6 +2830,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 

v4l2_ctrl_handler *hdl,

drivers/staging/

Quoted 10 lines
drivers/media/v4l2-core/v4l2-ctrls.c +3 -0
 	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
 		elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
 		break;
+	case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
+		elem_size = sizeof(struct v4l2_ctrl_hevc_decode_params);
+		break;
 	case V4L2_CTRL_TYPE_AREA:
 		elem_size = sizeof(struct v4l2_area);
 		break;
drivers/staging/ renamed from drivers/staging/media/sunxi/cedrus/cedrus.c +0 -0

media/sunxi/cedrus/cedrus.c

drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] =

Quoted 4 lines

index 7bd9291c8d5f..4cd3cab1a257 100644

drivers/staging/media/sunxi/cedrus/cedrus.c +0 -0
@@ -151,6 +151,12 @@ static const struct cedrus_control cedrus_controls[] = 

{

drivers/staging/

Quoted 13 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +6 -0
 		},
 		.codec		= CEDRUS_CODEC_VP8,
 	},
+	{
+		.cfg = {
+			.id = V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS,
+		},
+		.codec		= CEDRUS_CODEC_H265,
+	},
 };
 
 #define CEDRUS_CONTROLS_COUNT	ARRAY_SIZE(cedrus_controls)
drivers/staging/ renamed from drivers/staging/media/sunxi/cedrus/cedrus.h +0 -0

media/sunxi/cedrus/cedrus.h

drivers/

Quoted 12 lines

index 251a6a660351..2ca33ac38b9a 100644

drivers/staging/media/sunxi/cedrus/cedrus.h +1 -0
@@ -76,6 +76,7 @@ struct cedrus_h265_run {
 	const struct v4l2_ctrl_hevc_sps			*sps;
 	const struct v4l2_ctrl_hevc_pps			*pps;
 	const struct v4l2_ctrl_hevc_slice_params	*slice_params;
+	const struct v4l2_ctrl_hevc_decode_params	*decode_params;
 };
 
 struct cedrus_vp8_run {
drivers/ renamed from drivers/staging/media/sunxi/cedrus/cedrus_dec.c +0 -0

staging/media/sunxi/cedrus/cedrus_dec.c

drivers/

Quoted 13 lines

index a9090daf626a..cd821f417a14 100644

drivers/staging/media/sunxi/cedrus/cedrus_dec.c +2 -0
@@ -68,6 +68,8 @@ void cedrus_device_run(void *priv)
 			V4L2_CID_MPEG_VIDEO_HEVC_PPS);
 		run.h265.slice_params = cedrus_find_control_data(ctx,
 			V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS);
+		run.h265.decode_params = cedrus_find_control_data(ctx,
+			V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS);
 		break;
 
 	case V4L2_PIX_FMT_VP8_FRAME:
drivers/ renamed from drivers/staging/media/sunxi/cedrus/cedrus_h265.c +0 -0

staging/media/sunxi/cedrus/cedrus_h265.c

Quoted 20 lines

index ce497d0197df..dce5db6be13a 100644

drivers/staging/media/sunxi/cedrus/cedrus_h265.c +2 -0
@@ -245,6 +245,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 	const struct v4l2_ctrl_hevc_sps *sps;
 	const struct v4l2_ctrl_hevc_pps *pps;
 	const struct v4l2_ctrl_hevc_slice_params *slice_params;
+	const struct v4l2_ctrl_hevc_decode_params *decode_params;
 	const struct v4l2_hevc_pred_weight_table *pred_weight_table;
 	dma_addr_t src_buf_addr;
 	dma_addr_t src_buf_end_addr;
@@ -256,6 +257,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 	sps = run->h265.sps;
 	pps = run->h265.pps;
 	slice_params = run->h265.slice_params;
+	decode_params = run->h265.decode_params;
 	pred_weight_table = &slice_params->pred_weight_table;
 
 	/* MV column buffer size and allocation. */

drivers/staging/media/sunxi/cedrus/cedrus_h265.c static void cedrus_h265_setup(struct cedrus_ctx *ctx, · line 490

Quoted 2 lines
drivers/staging/media/sunxi/cedrus/cedrus_h265.c +0 -0
@@ -487,7 +489,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 
 	reg = 

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_TC_OFFSET_DIV2(slice_params-

Quoted 2 lines

slice_tc_offset_div2) |

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_BETA_OFFSET_DIV2(slice_params-

drivers/staging/media/sunxi/cedrus/cedrus_h265.c

Quoted 2 lines

slice_beta_offset_div2) |

drivers/staging/media/sunxi/cedrus/cedrus_h265.c +0 -1
-	      

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST(slice_params-

drivers/staging/media/sunxi/cedrus/cedrus_h265.c

Quoted 2 lines

num_rps_poc_st_curr_after == 0) |

drivers/staging/media/sunxi/cedrus/cedrus_h265.c +1 -0
+	      

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST(decode_params-

Quoted 2 lines

num_rps_poc_st_curr_after == 0) |

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CR_QP_OFFSET(slice_params-

Quoted 2 lines

slice_cr_qp_offset) |

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CB_QP_OFFSET(slice_params-

Quoted 19 lines

slice_cb_qp_offset) |
VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_QP_DELTA(slice_params-
slice_qp_delta);

drivers/staging/media/sunxi/cedrus/cedrus_h265.c +1 -1
@@ -528,7 +530,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 
 	/* Write decoded picture buffer in pic list. */
 	cedrus_h265_frame_info_write_dpb(ctx, slice_params->dpb,
-					 slice_params-
 num_active_dpb_entries);
+					 decode_params-
 num_active_dpb_entries);
 
drivers/staging/media/sunxi/cedrus/cedrus_h265.c +0 -0
 	/* Output frame. */
include/media/hevc-ctrls.h +0 -0
index b4cb2ef02f17..7fe704a08f77 100644

include/media/hevc-ctrls.h line 19

Quoted 1 line
include/media/hevc-ctrls.h +0 -0
@@ -19,6 +19,7 @@
 #define V4L2_CID_MPEG_VIDEO_HEVC_SPS		(V4L2_CID_CODEC_BASE + 

1008)

include/media/hevc-ctrls.h line 20

Quoted 1 line
include/media/hevc-ctrls.h +0 -0
 #define V4L2_CID_MPEG_VIDEO_HEVC_PPS		(V4L2_CID_CODEC_BASE + 

1009)

include/media/hevc-ctrls.h line 21

Quoted 1 line
include/media/hevc-ctrls.h +0 -0
 #define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS	(V4L2_CID_CODEC_BASE + 

1010)

include/media/hevc-ctrls.h line 22

Quoted 1 line
include/media/hevc-ctrls.h +1 -0
+#define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS	(V4L2_CID_CODEC_BASE + 

1012)

include/media/hevc-ctrls.h line 23

Quoted 1 line
include/media/hevc-ctrls.h +0 -0
 #define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE	(V4L2_CID_CODEC_BASE + 

1015)

include/media/hevc-ctrls.h line 24

Quoted 1 line
include/media/hevc-ctrls.h +0 -0
 #define V4L2_CID_MPEG_VIDEO_HEVC_START_CODE	(V4L2_CID_CODEC_BASE + 

1016)

include/media/hevc-ctrls.h enum v4l2_mpeg_video_hevc_start_code { · line 56

Quoted 11 lines
include/media/hevc-ctrls.h +1 -0
@@ -26,6 +27,7 @@
 #define V4L2_CTRL_TYPE_HEVC_SPS 0x0120
 #define V4L2_CTRL_TYPE_HEVC_PPS 0x0121
 #define V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS 0x0122
+#define V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS 0x0124
 
 enum v4l2_mpeg_video_hevc_decode_mode {
 	V4L2_MPEG_VIDEO_HEVC_DECODE_MODE_SLICE_BASED,
@@ -54,6 +56,9 @@ enum v4l2_mpeg_video_hevc_start_code {
 /* The controls are not stable at the moment and will likely be reworked. 

*/

Quoted 21 lines
include/media/hevc-ctrls.h +5 -2
 struct v4l2_ctrl_hevc_sps {
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: Sequence parameter set */
+	__u8	video_parameter_set_id;
+	__u8	seq_parameter_set_id;
+	__u8	chroma_format_idc;
 	__u16	pic_width_in_luma_samples;
 	__u16	pic_height_in_luma_samples;
 	__u8	bit_depth_luma_minus8;
@@ -74,9 +79,9 @@ struct v4l2_ctrl_hevc_sps {
 	__u8	log2_diff_max_min_pcm_luma_coding_block_size;
 	__u8	num_short_term_ref_pic_sets;
 	__u8	num_long_term_ref_pics_sps;
-	__u8	chroma_format_idc;
 
-	__u8	padding;
+	__u8	num_slices;
+	__u8	padding[6];
 
 	__u64	flags;
 };

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_sps { · line 107

Quoted 3 lines
include/media/hevc-ctrls.h +0 -0
@@ -100,10 +105,15 @@ struct v4l2_ctrl_hevc_sps {
 #define V4L2_HEVC_PPS_FLAG_PPS_DISABLE_DEBLOCKING_FILTER	(1ULL << 16)
 #define V4L2_HEVC_PPS_FLAG_LISTS_MODIFICATION_PRESENT		(1ULL << 17)
 #define V4L2_HEVC_PPS_FLAG_SLICE_SEGMENT_HEADER_EXTENSION_PRESENT (1ULL << 

18)

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_sps { · line 109

Quoted 2 lines
include/media/hevc-ctrls.h +2 -0
+#define V4L2_HEVC_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT	(1ULL << 19)
+#define V4L2_HEVC_PPS_FLAG_UNIFORM_SPACING			

(1ULL << 20)

Quoted 20 lines
include/media/hevc-ctrls.h +4 -1
 struct v4l2_ctrl_hevc_pps {
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture parameter set */
+	__u8	pic_parameter_set_id;
 	__u8	num_extra_slice_header_bits;
+	__u8	num_ref_idx_l0_default_active_minus1;
+	__u8	num_ref_idx_l1_default_active_minus1;
 	__s8	init_qp_minus26;
 	__u8	diff_cu_qp_delta_depth;
 	__s8	pps_cb_qp_offset;
@@ -116,7 +126,7 @@ struct v4l2_ctrl_hevc_pps {
 	__s8	pps_tc_offset_div2;
 	__u8	log2_parallel_merge_level_minus2;
 
-	__u8	padding[4];
+	__u8	padding;
 	__u64	flags;
 };
 

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_slice_params { · line 178

Quoted 4 lines
include/media/hevc-ctrls.h +1 -0
@@ -165,6 +175,10 @@ struct v4l2_ctrl_hevc_slice_params {
 	__u32	bit_size;
 	__u32	data_bit_offset;
 
+	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header 

*/

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_slice_params { · line 206

Quoted 10 lines
include/media/hevc-ctrls.h +3 -0
+	__u32	slice_segment_addr;
+	__u32	num_entry_point_offsets;
+
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: NAL unit header */
 	__u8	nal_unit_type;
 	__u8	nuh_temporal_id_plus1;
@@ -190,15 +204,13 @@ struct v4l2_ctrl_hevc_slice_params {
 	__u8	pic_struct;
 
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header 

*/

Quoted 4 lines
include/media/hevc-ctrls.h +0 -1
-	__u8	num_active_dpb_entries;
 	__u8	ref_idx_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
 	__u8	ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
 

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_slice_params {

Quoted 10 lines
include/media/hevc-ctrls.h +3 -4
-	__u8	num_rps_poc_st_curr_before;
-	__u8	num_rps_poc_st_curr_after;
-	__u8	num_rps_poc_lt_curr;
+	__u16	short_term_ref_pic_set_size;
+	__u16	long_term_ref_pic_set_size;
 
-	__u8	padding;
+	__u8	padding[5];
 
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header 

*/

Quoted 11 lines
include/media/hevc-ctrls.h +6 -0
 	struct v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
@@ -209,4 +221,21 @@ struct v4l2_ctrl_hevc_slice_params {
 	__u64	flags;
 };
 
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IRAP_PIC		0x1
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IDR_PIC		0x2
+#define V4L2_HEVC_DECODE_PARAM_FLAG_NO_OUTPUT_OF_PRIOR  0x4
+
+struct v4l2_ctrl_hevc_decode_params {
+	__s32	pic_order_cnt_val;

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_slice_params { · line 239

Quoted 10 lines
include/media/hevc-ctrls.h +10 -0
+	__u8	num_active_dpb_entries;
+	struct	v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u8	num_rps_poc_st_curr_before;
+	__u8	num_rps_poc_st_curr_after;
+	__u8	num_rps_poc_lt_curr;
+	__u8	rps_st_curr_before[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u8	rps_st_curr_after[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u8	rps_lt_curr[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u64	flags;
+};

Current practice is to also add/update controls documentation in Documentation/userspace-api/media/v4l/

With your changes, v4l2_ctrl_hevc_pps and v4l2_ctrl_hevc_slice_params descriptions are out of sync and v4l2_ctrl_hevc_decode_params description is completely missing.

Best regards,
Jernej

Quoted 6 lines
include/media/hevc-ctrls.h +1 -0
+
 #endif
Signature · 1 line
2.25.1

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

author maintainer
#3 lore raw

Re: [PATCH v2 1/9] media: hevc: Modify structures to follow H265 ITU spec

Le 18/02/2021 à 22:43, Jernej Škrabec a écrit :

Quoted 364 lines

Hi!

Dne četrtek, 18. februar 2021 ob 20:18:36 CET je Benjamin Gaignard napisal(a):

drivers/media/v4l2-core/

Quoted 42 lines

The H.265 ITU specification (section 7.4) define the general slice segment header semantics.
Modified/added fields are:
- video_parameter_set_id: (7.4.3.1) identifies the VPS for reference by other syntax elements.
- seq_parameter_set_id: (7.4.3.2.1) specifies the value of the vps_video_parameter_set_id of the active VPS.
- chroma_format_idc: (7.4.3.2.1) specifies the chroma sampling relative to the luma sampling
- pic_parameter_set_id: (7.4.3.3.1) identifies the PPS for reference by other syntax elements
- num_ref_idx_l0_default_active_minus1: (7.4.3.3.1) specifies the inferred value of num_ref_idx_l0_active_minus1
- num_ref_idx_l1_default_active_minus1: (7.4.3.3.1) specifies the inferred value of num_ref_idx_l1_active_minus1
- slice_segment_addr: (7.4.7.1) specifies the address of the first coding tree block in the slice segment
- num_entry_point_offsets: (7.4.7.1) specifies the number of entry_point_offset_minus1[ i ] syntax elements in the slice header

Add HEVC decode params contains the information used in section "8.3 Slice decoding process" of the specification to let the hardware perform decoding of a slices.

Adapt Cedrus driver according to these changes.

---
version 2:
- remove all change related to scaling
- squash commits to a coherent split
- be more verbose about the added fields

  drivers/media/v4l2-core/v4l2-ctrls.c          | 26 ++++++++---
  drivers/staging/media/sunxi/cedrus/cedrus.c   |  6 +++
  drivers/staging/media/sunxi/cedrus/cedrus.h   |  1 +
  .../staging/media/sunxi/cedrus/cedrus_dec.c   |  2 +
  .../staging/media/sunxi/cedrus/cedrus_h265.c  |  6 ++-
  include/media/hevc-ctrls.h                    | 45 +++++++++++++++----
  6 files changed, 69 insertions(+), 17 deletions(-)
drivers/media/v4l2-core/ renamed from drivers/media/v4l2-core/v4l2-ctrls.c +0 -0

v4l2-ctrls.c

drivers/media/v4l2-core/v4l2-ctrls.c const char *v4l2_ctrl_get_name(u32 id) · line 1028

Quoted 5 lines

index 016cf6204cbb..4060b5bcc3c0 100644

drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
@@ -1028,6 +1028,7 @@ const char *v4l2_ctrl_get_name(u32 id)
  	case V4L2_CID_MPEG_VIDEO_HEVC_SPS:			

return "HEVC Sequence Parameter Set";

drivers/media/v4l2-core/v4l2-ctrls.c const char *v4l2_ctrl_get_name(u32 id) · line 1029

Quoted 1 line
drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
  	case V4L2_CID_MPEG_VIDEO_HEVC_PPS:			

return "HEVC Picture Parameter Set";

drivers/media/v4l2-core/v4l2-ctrls.c const char *v4l2_ctrl_get_name(u32 id) · line 1030

Quoted 1 line
drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
  	case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:		return

"HEVC Slice Parameters";

drivers/media/v4l2-core/v4l2-ctrls.c void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, · line 1486

Quoted 1 line
drivers/media/v4l2-core/v4l2-ctrls.c +1 -0
+	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS:		

return "HEVC Decode Parameters";

drivers/media/v4l2-core/v4l2-ctrls.c const char *v4l2_ctrl_get_name(u32 id) · line 1032

Quoted 1 line
drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
  	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE:		return "HEVC

Decode Mode";

drivers/media/v4l2-core/v4l2-ctrls.c const char *v4l2_ctrl_get_name(u32 id) · line 1033

Quoted 1 line
drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
  	case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE:		return

"HEVC Start Code";

drivers/media/v4l2-core/v4l2-ctrls.c void v4l2_ctrl_fill(u32 id, const char **name, enum

Quoted 2 lines
drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
@@ -1482,6 +1483,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum

v4l2_ctrl_type *type,

drivers/media/v4l2-core/v4l2-ctrls.c static int std_validate_compound(const struct

Quoted 10 lines
drivers/media/v4l2-core/v4l2-ctrls.c +3 -0
  	case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:
  		*type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS;
  		break;
+	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS:
+		*type = V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS;
+		break;
  	case V4L2_CID_UNIT_CELL_SIZE:
  		*type = V4L2_CTRL_TYPE_AREA;
  		*flags |= V4L2_CTRL_FLAG_READ_ONLY;
@@ -1833,6 +1837,7 @@ static int std_validate_compound(const struct

v4l2_ctrl *ctrl, u32 idx,

drivers/media/v4l2-core/v4l2-ctrls.c static int std_validate_compound(const struct

Quoted 8 lines
drivers/media/v4l2-core/v4l2-ctrls.c +1 -0
  	struct v4l2_ctrl_hevc_sps *p_hevc_sps;
  	struct v4l2_ctrl_hevc_pps *p_hevc_pps;
  	struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
+	struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;
  	struct v4l2_area *area;
  	void *p = ptr.p + idx * ctrl->elem_size;
  	unsigned int i;
@@ -2108,23 +2113,27 @@ static int std_validate_compound(const struct

v4l2_ctrl *ctrl, u32 idx,

drivers/media/v4l2-core/v4l2-ctrls.c static struct v4l2_ctrl *v4l2_ctrl_new(struct

Quoted 37 lines
drivers/media/v4l2-core/v4l2-ctrls.c +11 -7
  		zero_padding(*p_hevc_pps);
  		break;
 
-	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
-		p_hevc_slice_params = p;
+	case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
+		p_hevc_decode_params = p;
 
-		if (p_hevc_slice_params->num_active_dpb_entries >
+		if (p_hevc_decode_params->num_active_dpb_entries >
  		    V4L2_HEVC_DPB_ENTRIES_NUM_MAX)
  			return -EINVAL;
 
-		zero_padding(p_hevc_slice_params->pred_weight_table);
-
-		for (i = 0; i < p_hevc_slice_params-
 num_active_dpb_entries;
+		for (i = 0; i < p_hevc_decode_params-
 num_active_dpb_entries;
  		     i++) {
  			struct v4l2_hevc_dpb_entry *dpb_entry =
-				&p_hevc_slice_params->dpb[i];
+				&p_hevc_decode_params->dpb[i];
 
  			zero_padding(*dpb_entry);
  		}
 
+		break;
+
+	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
+		p_hevc_slice_params = p;
+
+		zero_padding(p_hevc_slice_params->pred_weight_table);
  		zero_padding(*p_hevc_slice_params);

break;

drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
@@ -2821,6 +2830,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct

v4l2_ctrl_handler *hdl,

drivers/staging/

Quoted 10 lines
drivers/media/v4l2-core/v4l2-ctrls.c +3 -0
  	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
  		elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
  		break;
+	case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
+		elem_size = sizeof(struct v4l2_ctrl_hevc_decode_params);
+		break;
  	case V4L2_CTRL_TYPE_AREA:
  		elem_size = sizeof(struct v4l2_area);
  		break;
drivers/staging/ renamed from drivers/staging/media/sunxi/cedrus/cedrus.c +0 -0

media/sunxi/cedrus/cedrus.c

drivers/staging/media/sunxi/cedrus/cedrus.c static const struct cedrus_control cedrus_controls[] =

Quoted 4 lines

index 7bd9291c8d5f..4cd3cab1a257 100644

drivers/staging/media/sunxi/cedrus/cedrus.c +0 -0
@@ -151,6 +151,12 @@ static const struct cedrus_control cedrus_controls[] =

{

drivers/staging/

Quoted 13 lines
drivers/staging/media/sunxi/cedrus/cedrus.c +6 -0
  		},
  		.codec		= CEDRUS_CODEC_VP8,
  	},
+	{
+		.cfg = {
+			.id = V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS,
+		},
+		.codec		= CEDRUS_CODEC_H265,
+	},
  };
 
  #define CEDRUS_CONTROLS_COUNT	ARRAY_SIZE(cedrus_controls)
drivers/staging/ renamed from drivers/staging/media/sunxi/cedrus/cedrus.h +0 -0

media/sunxi/cedrus/cedrus.h

drivers/

Quoted 12 lines

index 251a6a660351..2ca33ac38b9a 100644

drivers/staging/media/sunxi/cedrus/cedrus.h +1 -0
@@ -76,6 +76,7 @@ struct cedrus_h265_run {
  	const struct v4l2_ctrl_hevc_sps			*sps;
  	const struct v4l2_ctrl_hevc_pps			*pps;
  	const struct v4l2_ctrl_hevc_slice_params	*slice_params;
+	const struct v4l2_ctrl_hevc_decode_params	*decode_params;
  };
 
  struct cedrus_vp8_run {
drivers/ renamed from drivers/staging/media/sunxi/cedrus/cedrus_dec.c +0 -0

staging/media/sunxi/cedrus/cedrus_dec.c

drivers/

Quoted 13 lines

index a9090daf626a..cd821f417a14 100644

drivers/staging/media/sunxi/cedrus/cedrus_dec.c +2 -0
@@ -68,6 +68,8 @@ void cedrus_device_run(void *priv)
  			V4L2_CID_MPEG_VIDEO_HEVC_PPS);
  		run.h265.slice_params = cedrus_find_control_data(ctx,
  			V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS);
+		run.h265.decode_params = cedrus_find_control_data(ctx,
+			V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS);
  		break;
 
  	case V4L2_PIX_FMT_VP8_FRAME:
drivers/ renamed from drivers/staging/media/sunxi/cedrus/cedrus_h265.c +0 -0

staging/media/sunxi/cedrus/cedrus_h265.c

Quoted 20 lines

index ce497d0197df..dce5db6be13a 100644

drivers/staging/media/sunxi/cedrus/cedrus_h265.c +2 -0
@@ -245,6 +245,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
  	const struct v4l2_ctrl_hevc_sps *sps;
  	const struct v4l2_ctrl_hevc_pps *pps;
  	const struct v4l2_ctrl_hevc_slice_params *slice_params;
+	const struct v4l2_ctrl_hevc_decode_params *decode_params;
  	const struct v4l2_hevc_pred_weight_table *pred_weight_table;
  	dma_addr_t src_buf_addr;
  	dma_addr_t src_buf_end_addr;
@@ -256,6 +257,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
  	sps = run->h265.sps;
  	pps = run->h265.pps;
  	slice_params = run->h265.slice_params;
+	decode_params = run->h265.decode_params;
  	pred_weight_table = &slice_params->pred_weight_table;
 
  	/* MV column buffer size and allocation. */

drivers/staging/media/sunxi/cedrus/cedrus_h265.c static void cedrus_h265_setup(struct cedrus_ctx *ctx, · line 490

Quoted 2 lines
drivers/staging/media/sunxi/cedrus/cedrus_h265.c +0 -0
@@ -487,7 +489,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 
  	reg =

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_TC_OFFSET_DIV2(slice_params-

Quoted 2 lines

slice_tc_offset_div2) |

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_BETA_OFFSET_DIV2(slice_params-

drivers/staging/media/sunxi/cedrus/cedrus_h265.c

Quoted 2 lines

slice_beta_offset_div2) |

drivers/staging/media/sunxi/cedrus/cedrus_h265.c +0 -1
-	

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST(slice_params-

drivers/staging/media/sunxi/cedrus/cedrus_h265.c

Quoted 2 lines

num_rps_poc_st_curr_after == 0) |

drivers/staging/media/sunxi/cedrus/cedrus_h265.c +1 -0
+	

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST(decode_params-

Quoted 2 lines

num_rps_poc_st_curr_after == 0) |

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CR_QP_OFFSET(slice_params-

Quoted 2 lines

slice_cr_qp_offset) |

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CB_QP_OFFSET(slice_params-

Quoted 19 lines

slice_cb_qp_offset) |
VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_QP_DELTA(slice_params-
slice_qp_delta);

drivers/staging/media/sunxi/cedrus/cedrus_h265.c +1 -1
@@ -528,7 +530,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 
  	/* Write decoded picture buffer in pic list. */
  	cedrus_h265_frame_info_write_dpb(ctx, slice_params->dpb,
-					 slice_params-
 num_active_dpb_entries);
+					 decode_params-
 num_active_dpb_entries);
 

/* Output frame. */

include/media/hevc-ctrls.h +0 -0
index b4cb2ef02f17..7fe704a08f77 100644

include/media/hevc-ctrls.h line 19

Quoted 1 line
include/media/hevc-ctrls.h +0 -0
@@ -19,6 +19,7 @@
  #define V4L2_CID_MPEG_VIDEO_HEVC_SPS		(V4L2_CID_CODEC_BASE +

1008)

include/media/hevc-ctrls.h line 20

Quoted 1 line
include/media/hevc-ctrls.h +0 -0
  #define V4L2_CID_MPEG_VIDEO_HEVC_PPS		(V4L2_CID_CODEC_BASE +

1009)

include/media/hevc-ctrls.h line 21

Quoted 1 line
include/media/hevc-ctrls.h +0 -0
  #define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS	(V4L2_CID_CODEC_BASE +

1010)

include/media/hevc-ctrls.h line 22

Quoted 1 line
include/media/hevc-ctrls.h +1 -0
+#define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS	(V4L2_CID_CODEC_BASE +

1012)

include/media/hevc-ctrls.h line 23

Quoted 1 line
include/media/hevc-ctrls.h +0 -0
  #define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE	(V4L2_CID_CODEC_BASE +

1015)

include/media/hevc-ctrls.h line 24

Quoted 1 line
include/media/hevc-ctrls.h +0 -0
  #define V4L2_CID_MPEG_VIDEO_HEVC_START_CODE	(V4L2_CID_CODEC_BASE +

1016)

include/media/hevc-ctrls.h enum v4l2_mpeg_video_hevc_start_code { · line 56

Quoted 11 lines
include/media/hevc-ctrls.h +1 -0
@@ -26,6 +27,7 @@
  #define V4L2_CTRL_TYPE_HEVC_SPS 0x0120
  #define V4L2_CTRL_TYPE_HEVC_PPS 0x0121
  #define V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS 0x0122
+#define V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS 0x0124
 
  enum v4l2_mpeg_video_hevc_decode_mode {
  	V4L2_MPEG_VIDEO_HEVC_DECODE_MODE_SLICE_BASED,
@@ -54,6 +56,9 @@ enum v4l2_mpeg_video_hevc_start_code {
  /* The controls are not stable at the moment and will likely be reworked.

*/

Quoted 21 lines
include/media/hevc-ctrls.h +5 -2
  struct v4l2_ctrl_hevc_sps {
  	/* ISO/IEC 23008-2, ITU-T Rec. H.265: Sequence parameter set */
+	__u8	video_parameter_set_id;
+	__u8	seq_parameter_set_id;
+	__u8	chroma_format_idc;
  	__u16	pic_width_in_luma_samples;
  	__u16	pic_height_in_luma_samples;
  	__u8	bit_depth_luma_minus8;
@@ -74,9 +79,9 @@ struct v4l2_ctrl_hevc_sps {
  	__u8	log2_diff_max_min_pcm_luma_coding_block_size;
  	__u8	num_short_term_ref_pic_sets;
  	__u8	num_long_term_ref_pics_sps;
-	__u8	chroma_format_idc;
 
-	__u8	padding;
+	__u8	num_slices;
+	__u8	padding[6];
 
  	__u64	flags;
  };

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_sps { · line 107

Quoted 3 lines
include/media/hevc-ctrls.h +0 -0
@@ -100,10 +105,15 @@ struct v4l2_ctrl_hevc_sps {
  #define V4L2_HEVC_PPS_FLAG_PPS_DISABLE_DEBLOCKING_FILTER	(1ULL << 16)
  #define V4L2_HEVC_PPS_FLAG_LISTS_MODIFICATION_PRESENT		(1ULL << 17)
  #define V4L2_HEVC_PPS_FLAG_SLICE_SEGMENT_HEADER_EXTENSION_PRESENT (1ULL <<

18)

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_sps { · line 109

Quoted 2 lines
include/media/hevc-ctrls.h +2 -0
+#define V4L2_HEVC_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT	(1ULL << 19)
+#define V4L2_HEVC_PPS_FLAG_UNIFORM_SPACING			

(1ULL << 20)

Quoted 20 lines
include/media/hevc-ctrls.h +4 -1
  struct v4l2_ctrl_hevc_pps {
  	/* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture parameter set */
+	__u8	pic_parameter_set_id;
  	__u8	num_extra_slice_header_bits;
+	__u8	num_ref_idx_l0_default_active_minus1;
+	__u8	num_ref_idx_l1_default_active_minus1;
  	__s8	init_qp_minus26;
  	__u8	diff_cu_qp_delta_depth;
  	__s8	pps_cb_qp_offset;
@@ -116,7 +126,7 @@ struct v4l2_ctrl_hevc_pps {
  	__s8	pps_tc_offset_div2;
  	__u8	log2_parallel_merge_level_minus2;
 
-	__u8	padding[4];
+	__u8	padding;
  	__u64	flags;
  };
 

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_slice_params { · line 178

Quoted 4 lines
include/media/hevc-ctrls.h +1 -0
@@ -165,6 +175,10 @@ struct v4l2_ctrl_hevc_slice_params {
  	__u32	bit_size;
  	__u32	data_bit_offset;
 
+	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header

*/

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_slice_params { · line 206

Quoted 10 lines
include/media/hevc-ctrls.h +3 -0
+	__u32	slice_segment_addr;
+	__u32	num_entry_point_offsets;
+
  	/* ISO/IEC 23008-2, ITU-T Rec. H.265: NAL unit header */
  	__u8	nal_unit_type;
  	__u8	nuh_temporal_id_plus1;
@@ -190,15 +204,13 @@ struct v4l2_ctrl_hevc_slice_params {
  	__u8	pic_struct;
 
  	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header

*/

Quoted 4 lines
include/media/hevc-ctrls.h +0 -1
-	__u8	num_active_dpb_entries;
  	__u8	ref_idx_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
  	__u8	ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
 

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_slice_params {

Quoted 10 lines
include/media/hevc-ctrls.h +3 -4
-	__u8	num_rps_poc_st_curr_before;
-	__u8	num_rps_poc_st_curr_after;
-	__u8	num_rps_poc_lt_curr;
+	__u16	short_term_ref_pic_set_size;
+	__u16	long_term_ref_pic_set_size;
 
-	__u8	padding;
+	__u8	padding[5];
 
  	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header

*/

Quoted 11 lines
include/media/hevc-ctrls.h +6 -0
  	struct v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
@@ -209,4 +221,21 @@ struct v4l2_ctrl_hevc_slice_params {
  	__u64	flags;
  };
 
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IRAP_PIC		0x1
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IDR_PIC		0x2
+#define V4L2_HEVC_DECODE_PARAM_FLAG_NO_OUTPUT_OF_PRIOR  0x4
+
+struct v4l2_ctrl_hevc_decode_params {
+	__s32	pic_order_cnt_val;

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_slice_params { · line 239

Quoted 10 lines
include/media/hevc-ctrls.h +10 -0
+	__u8	num_active_dpb_entries;
+	struct	v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u8	num_rps_poc_st_curr_before;
+	__u8	num_rps_poc_st_curr_after;
+	__u8	num_rps_poc_lt_curr;
+	__u8	rps_st_curr_before[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u8	rps_st_curr_after[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u8	rps_lt_curr[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u64	flags;
+};

Current practice is to also add/update controls documentation in Documentation/userspace-api/media/v4l/

Quoted 3 lines

With your changes, v4l2_ctrl_hevc_pps and v4l2_ctrl_hevc_slice_params descriptions are out of sync and v4l2_ctrl_hevc_decode_params description is completely missing.

Thanks for your comment.
That will be fix in v3.

Benjamin

Quoted 11 lines

Best regards,
Jernej

Quoted 6 lines
include/media/hevc-ctrls.h +1 -0
+
  #endif
Signature · 1 line
2.25.1

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#4 lore raw

Re: [PATCH v2 1/9] media: hevc: Modify structures to follow H265 ITU spec

In reply to Benjamin Gaignard
Quoted 217 lines

The H.265 ITU specification (section 7.4) define the general slice segment header semantics.
Modified/added fields are:
- video_parameter_set_id: (7.4.3.1) identifies the VPS for reference by other syntax elements.
- seq_parameter_set_id: (7.4.3.2.1) specifies the value of the vps_video_parameter_set_id of the active VPS.
- chroma_format_idc: (7.4.3.2.1) specifies the chroma sampling relative to the luma sampling
- pic_parameter_set_id: (7.4.3.3.1) identifies the PPS for reference by other syntax elements
- num_ref_idx_l0_default_active_minus1: (7.4.3.3.1) specifies the inferred value of num_ref_idx_l0_active_minus1
- num_ref_idx_l1_default_active_minus1: (7.4.3.3.1) specifies the inferred value of num_ref_idx_l1_active_minus1
- slice_segment_addr: (7.4.7.1) specifies the address of the first coding tree block in the slice segment
- num_entry_point_offsets: (7.4.7.1) specifies the number of entry_point_offset_minus1[ i ] syntax elements in the slice header

Add HEVC decode params contains the information used in section "8.3 Slice decoding process" of the specification to let the hardware perform decoding of a slices.

Adapt Cedrus driver according to these changes.

---
version 2:
- remove all change related to scaling
- squash commits to a coherent split
- be more verbose about the added fields

drivers/media/v4l2-core/v4l2-ctrls.c          | 26 ++++++++---
drivers/staging/media/sunxi/cedrus/cedrus.c   |  6 +++
drivers/staging/media/sunxi/cedrus/cedrus.h   |  1 +
.../staging/media/sunxi/cedrus/cedrus_dec.c   |  2 +
.../staging/media/sunxi/cedrus/cedrus_h265.c  |  6 ++-
include/media/hevc-ctrls.h                    | 45 +++++++++++++++----
6 files changed, 69 insertions(+), 17 deletions(-)
drivers/media/v4l2-core/v4l2-ctrls.c +19 -7
index 016cf6204cbb..4060b5bcc3c0 100644
@@ -1028,6 +1028,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_MPEG_VIDEO_HEVC_SPS:			return "HEVC Sequence Parameter Set";
 	case V4L2_CID_MPEG_VIDEO_HEVC_PPS:			return "HEVC Picture Parameter Set";
 	case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:		return "HEVC Slice Parameters";
+	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS:		return "HEVC Decode Parameters";
 	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE:		return "HEVC Decode Mode";
 	case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE:		return "HEVC Start Code";
 
@@ -1482,6 +1483,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:
 		*type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS;
 		break;
+	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS:
+		*type = V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS;
+		break;
 	case V4L2_CID_UNIT_CELL_SIZE:
 		*type = V4L2_CTRL_TYPE_AREA;
 		*flags |= V4L2_CTRL_FLAG_READ_ONLY;
@@ -1833,6 +1837,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
 	struct v4l2_ctrl_hevc_sps *p_hevc_sps;
 	struct v4l2_ctrl_hevc_pps *p_hevc_pps;
 	struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
+	struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;
 	struct v4l2_area *area;
 	void *p = ptr.p + idx * ctrl->elem_size;
 	unsigned int i;
@@ -2108,23 +2113,27 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
 		zero_padding(*p_hevc_pps);
 		break;
 
-	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
-		p_hevc_slice_params = p;
+	case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
+		p_hevc_decode_params = p;
 
-		if (p_hevc_slice_params->num_active_dpb_entries >
+		if (p_hevc_decode_params->num_active_dpb_entries >
 		    V4L2_HEVC_DPB_ENTRIES_NUM_MAX)
 			return -EINVAL;
 
-		zero_padding(p_hevc_slice_params->pred_weight_table);
-
-		for (i = 0; i < p_hevc_slice_params->num_active_dpb_entries;
+		for (i = 0; i < p_hevc_decode_params->num_active_dpb_entries;
 		     i++) {
 			struct v4l2_hevc_dpb_entry *dpb_entry =
-				&p_hevc_slice_params->dpb[i];
+				&p_hevc_decode_params->dpb[i];
 
 			zero_padding(*dpb_entry);
 		}
 
+		break;
+
+	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
+		p_hevc_slice_params = p;
+
+		zero_padding(p_hevc_slice_params->pred_weight_table);
 		zero_padding(*p_hevc_slice_params);
 		break;
 
@@ -2821,6 +2830,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
 	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
 		elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
 		break;
+	case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
+		elem_size = sizeof(struct v4l2_ctrl_hevc_decode_params);
+		break;
 	case V4L2_CTRL_TYPE_AREA:
 		elem_size = sizeof(struct v4l2_area);
 		break;
drivers/staging/media/sunxi/cedrus/cedrus.c +6 -0
index 7bd9291c8d5f..4cd3cab1a257 100644
@@ -151,6 +151,12 @@ static const struct cedrus_control cedrus_controls[] = {
 		},
 		.codec		= CEDRUS_CODEC_VP8,
 	},
+	{
+		.cfg = {
+			.id = V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS,
+		},
+		.codec		= CEDRUS_CODEC_H265,
+	},
 };
 
 #define CEDRUS_CONTROLS_COUNT	ARRAY_SIZE(cedrus_controls)
drivers/staging/media/sunxi/cedrus/cedrus.h +1 -0
index 251a6a660351..2ca33ac38b9a 100644
@@ -76,6 +76,7 @@ struct cedrus_h265_run {
 	const struct v4l2_ctrl_hevc_sps			*sps;
 	const struct v4l2_ctrl_hevc_pps			*pps;
 	const struct v4l2_ctrl_hevc_slice_params	*slice_params;
+	const struct v4l2_ctrl_hevc_decode_params	*decode_params;
 };
 
 struct cedrus_vp8_run {
drivers/staging/media/sunxi/cedrus/cedrus_dec.c +2 -0
index a9090daf626a..cd821f417a14 100644
@@ -68,6 +68,8 @@ void cedrus_device_run(void *priv)
 			V4L2_CID_MPEG_VIDEO_HEVC_PPS);
 		run.h265.slice_params = cedrus_find_control_data(ctx,
 			V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS);
+		run.h265.decode_params = cedrus_find_control_data(ctx,
+			V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS);
 		break;
 
 	case V4L2_PIX_FMT_VP8_FRAME:
drivers/staging/media/sunxi/cedrus/cedrus_h265.c +4 -2
index ce497d0197df..dce5db6be13a 100644
@@ -245,6 +245,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 	const struct v4l2_ctrl_hevc_sps *sps;
 	const struct v4l2_ctrl_hevc_pps *pps;
 	const struct v4l2_ctrl_hevc_slice_params *slice_params;
+	const struct v4l2_ctrl_hevc_decode_params *decode_params;
 	const struct v4l2_hevc_pred_weight_table *pred_weight_table;
 	dma_addr_t src_buf_addr;
 	dma_addr_t src_buf_end_addr;
@@ -256,6 +257,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 	sps = run->h265.sps;
 	pps = run->h265.pps;
 	slice_params = run->h265.slice_params;
+	decode_params = run->h265.decode_params;
 	pred_weight_table = &slice_params->pred_weight_table;
 
 	/* MV column buffer size and allocation. */
@@ -487,7 +489,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 
 	reg = VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_TC_OFFSET_DIV2(slice_params->slice_tc_offset_div2) |
 	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_BETA_OFFSET_DIV2(slice_params->slice_beta_offset_div2) |
-	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST(slice_params->num_rps_poc_st_curr_after == 0) |
+	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST(decode_params->num_rps_poc_st_curr_after == 0) |
 	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CR_QP_OFFSET(slice_params->slice_cr_qp_offset) |
 	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CB_QP_OFFSET(slice_params->slice_cb_qp_offset) |
 	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_QP_DELTA(slice_params->slice_qp_delta);
@@ -528,7 +530,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 
 	/* Write decoded picture buffer in pic list. */
 	cedrus_h265_frame_info_write_dpb(ctx, slice_params->dpb,
-					 slice_params->num_active_dpb_entries);
+					 decode_params->num_active_dpb_entries);
 
 	/* Output frame. */
 
include/media/hevc-ctrls.h +2 -0
index b4cb2ef02f17..7fe704a08f77 100644
@@ -19,6 +19,7 @@
 #define V4L2_CID_MPEG_VIDEO_HEVC_SPS		(V4L2_CID_CODEC_BASE + 1008)
 #define V4L2_CID_MPEG_VIDEO_HEVC_PPS		(V4L2_CID_CODEC_BASE + 1009)
 #define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS	(V4L2_CID_CODEC_BASE + 1010)
+#define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS	(V4L2_CID_CODEC_BASE + 1012)
 #define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE	(V4L2_CID_CODEC_BASE + 1015)
 #define V4L2_CID_MPEG_VIDEO_HEVC_START_CODE	(V4L2_CID_CODEC_BASE + 1016)
 
@@ -26,6 +27,7 @@
 #define V4L2_CTRL_TYPE_HEVC_SPS 0x0120
 #define V4L2_CTRL_TYPE_HEVC_PPS 0x0121
 #define V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS 0x0122
+#define V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS 0x0124
 
 enum v4l2_mpeg_video_hevc_decode_mode {
 	V4L2_MPEG_VIDEO_HEVC_DECODE_MODE_SLICE_BASED,

include/media/hevc-ctrls.h enum v4l2_mpeg_video_hevc_start_code { · line 59

Quoted 4 lines
include/media/hevc-ctrls.h +1 -0
@@ -54,6 +56,9 @@ enum v4l2_mpeg_video_hevc_start_code {
 /* The controls are not stable at the moment and will likely be reworked. */
 struct v4l2_ctrl_hevc_sps {
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: Sequence parameter set */
+	__u8	video_parameter_set_id;

Whilst I don't object to the addition of vps id why do we need it if the VPS is never passed?

Quoted 84 lines
include/media/hevc-ctrls.h +25 -8
+	__u8	seq_parameter_set_id;
+	__u8	chroma_format_idc;
 	__u16	pic_width_in_luma_samples;
 	__u16	pic_height_in_luma_samples;
 	__u8	bit_depth_luma_minus8;
@@ -74,9 +79,9 @@ struct v4l2_ctrl_hevc_sps {
 	__u8	log2_diff_max_min_pcm_luma_coding_block_size;
 	__u8	num_short_term_ref_pic_sets;
 	__u8	num_long_term_ref_pics_sps;
-	__u8	chroma_format_idc;
 
-	__u8	padding;
+	__u8	num_slices;
+	__u8	padding[6];
 
 	__u64	flags;
 };
@@ -100,10 +105,15 @@ struct v4l2_ctrl_hevc_sps {
 #define V4L2_HEVC_PPS_FLAG_PPS_DISABLE_DEBLOCKING_FILTER	(1ULL << 16)
 #define V4L2_HEVC_PPS_FLAG_LISTS_MODIFICATION_PRESENT		(1ULL << 17)
 #define V4L2_HEVC_PPS_FLAG_SLICE_SEGMENT_HEADER_EXTENSION_PRESENT (1ULL << 18)
+#define V4L2_HEVC_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT	(1ULL << 19)
+#define V4L2_HEVC_PPS_FLAG_UNIFORM_SPACING			(1ULL << 20)
 
 struct v4l2_ctrl_hevc_pps {
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture parameter set */
+	__u8	pic_parameter_set_id;
 	__u8	num_extra_slice_header_bits;
+	__u8	num_ref_idx_l0_default_active_minus1;
+	__u8	num_ref_idx_l1_default_active_minus1;
 	__s8	init_qp_minus26;
 	__u8	diff_cu_qp_delta_depth;
 	__s8	pps_cb_qp_offset;
@@ -116,7 +126,7 @@ struct v4l2_ctrl_hevc_pps {
 	__s8	pps_tc_offset_div2;
 	__u8	log2_parallel_merge_level_minus2;
 
-	__u8	padding[4];
+	__u8	padding;
 	__u64	flags;
 };
 
@@ -165,6 +175,10 @@ struct v4l2_ctrl_hevc_slice_params {
 	__u32	bit_size;
 	__u32	data_bit_offset;
 
+	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
+	__u32	slice_segment_addr;
+	__u32	num_entry_point_offsets;
+
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: NAL unit header */
 	__u8	nal_unit_type;
 	__u8	nuh_temporal_id_plus1;
@@ -190,15 +204,13 @@ struct v4l2_ctrl_hevc_slice_params {
 	__u8	pic_struct;
 
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
-	__u8	num_active_dpb_entries;
 	__u8	ref_idx_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
 	__u8	ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
 
-	__u8	num_rps_poc_st_curr_before;
-	__u8	num_rps_poc_st_curr_after;
-	__u8	num_rps_poc_lt_curr;
+	__u16	short_term_ref_pic_set_size;
+	__u16	long_term_ref_pic_set_size;
 
-	__u8	padding;
+	__u8	padding[5];
 
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
 	struct v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
@@ -209,4 +221,21 @@ struct v4l2_ctrl_hevc_slice_params {
 	__u64	flags;
 };
 
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IRAP_PIC		0x1
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IDR_PIC		0x2
+#define V4L2_HEVC_DECODE_PARAM_FLAG_NO_OUTPUT_OF_PRIOR  0x4
+
+struct v4l2_ctrl_hevc_decode_params {
+	__s32	pic_order_cnt_val;
+	__u8	num_active_dpb_entries;
+	struct	v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_slice_params { · line 241

Quoted 10 lines
include/media/hevc-ctrls.h +9 -0
+	__u8	num_rps_poc_st_curr_before;
+	__u8	num_rps_poc_st_curr_after;
+	__u8	num_rps_poc_lt_curr;
+	__u8	rps_st_curr_before[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u8	rps_st_curr_after[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u8	rps_lt_curr[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u64	flags;
+};
+
 #endif

While you are adding stuff is there any chance you could also add:

#define V4L2_HEVC_SLICE_PARAMS_FLAG_DEPENDENT_SLICE_SEGMENT (1ULL << 9)

to the slice flags? The rpi H265 decoder needs it to deal with cases where dependant_slice_segment is set in the slice header.

Thanks

John Cox

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

author maintainer
#5 lore raw

Re: [PATCH v2 1/9] media: hevc: Modify structures to follow H265 ITU spec

Le 22/02/2021 à 17:24, John Cox a écrit :

Quoted 214 lines
Quoted 214 lines

The H.265 ITU specification (section 7.4) define the general slice segment header semantics.
Modified/added fields are:
- video_parameter_set_id: (7.4.3.1) identifies the VPS for reference by other syntax elements.
- seq_parameter_set_id: (7.4.3.2.1) specifies the value of the vps_video_parameter_set_id of the active VPS.
- chroma_format_idc: (7.4.3.2.1) specifies the chroma sampling relative to the luma sampling
- pic_parameter_set_id: (7.4.3.3.1) identifies the PPS for reference by other syntax elements
- num_ref_idx_l0_default_active_minus1: (7.4.3.3.1) specifies the inferred value of num_ref_idx_l0_active_minus1
- num_ref_idx_l1_default_active_minus1: (7.4.3.3.1) specifies the inferred value of num_ref_idx_l1_active_minus1
- slice_segment_addr: (7.4.7.1) specifies the address of the first coding tree block in the slice segment
- num_entry_point_offsets: (7.4.7.1) specifies the number of entry_point_offset_minus1[ i ] syntax elements in the slice header

Add HEVC decode params contains the information used in section "8.3 Slice decoding process" of the specification to let the hardware perform decoding of a slices.

Adapt Cedrus driver according to these changes.

---
version 2:
- remove all change related to scaling
- squash commits to a coherent split
- be more verbose about the added fields

drivers/media/v4l2-core/v4l2-ctrls.c          | 26 ++++++++---
drivers/staging/media/sunxi/cedrus/cedrus.c   |  6 +++
drivers/staging/media/sunxi/cedrus/cedrus.h   |  1 +
.../staging/media/sunxi/cedrus/cedrus_dec.c   |  2 +
.../staging/media/sunxi/cedrus/cedrus_h265.c  |  6 ++-
include/media/hevc-ctrls.h                    | 45 +++++++++++++++----
6 files changed, 69 insertions(+), 17 deletions(-)
drivers/media/v4l2-core/v4l2-ctrls.c +19 -7
index 016cf6204cbb..4060b5bcc3c0 100644
@@ -1028,6 +1028,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_MPEG_VIDEO_HEVC_SPS:			return "HEVC Sequence Parameter Set";
 	case V4L2_CID_MPEG_VIDEO_HEVC_PPS:			return "HEVC Picture Parameter Set";
 	case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:		return "HEVC Slice Parameters";
+	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS:		return "HEVC Decode Parameters";
 	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE:		return "HEVC Decode Mode";
 	case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE:		return "HEVC Start Code";
 
@@ -1482,6 +1483,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:
 		*type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS;
 		break;
+	case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS:
+		*type = V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS;
+		break;
 	case V4L2_CID_UNIT_CELL_SIZE:
 		*type = V4L2_CTRL_TYPE_AREA;
 		*flags |= V4L2_CTRL_FLAG_READ_ONLY;
@@ -1833,6 +1837,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
 	struct v4l2_ctrl_hevc_sps *p_hevc_sps;
 	struct v4l2_ctrl_hevc_pps *p_hevc_pps;
 	struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
+	struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;
 	struct v4l2_area *area;
 	void *p = ptr.p + idx * ctrl->elem_size;
 	unsigned int i;
@@ -2108,23 +2113,27 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
 		zero_padding(*p_hevc_pps);
 		break;
 
-	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
-		p_hevc_slice_params = p;
+	case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
+		p_hevc_decode_params = p;
 
-		if (p_hevc_slice_params->num_active_dpb_entries >
+		if (p_hevc_decode_params->num_active_dpb_entries >
 		    V4L2_HEVC_DPB_ENTRIES_NUM_MAX)
 			return -EINVAL;
 
-		zero_padding(p_hevc_slice_params->pred_weight_table);
-
-		for (i = 0; i < p_hevc_slice_params->num_active_dpb_entries;
+		for (i = 0; i < p_hevc_decode_params->num_active_dpb_entries;
 		     i++) {
 			struct v4l2_hevc_dpb_entry *dpb_entry =
-				&p_hevc_slice_params->dpb[i];
+				&p_hevc_decode_params->dpb[i];
 
 			zero_padding(*dpb_entry);
 		}
 
+		break;
+
+	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
+		p_hevc_slice_params = p;
+
+		zero_padding(p_hevc_slice_params->pred_weight_table);
 		zero_padding(*p_hevc_slice_params);
 		break;
 
@@ -2821,6 +2830,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
 	case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
 		elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
 		break;
+	case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
+		elem_size = sizeof(struct v4l2_ctrl_hevc_decode_params);
+		break;
 	case V4L2_CTRL_TYPE_AREA:
 		elem_size = sizeof(struct v4l2_area);
 		break;
drivers/staging/media/sunxi/cedrus/cedrus.c +6 -0
index 7bd9291c8d5f..4cd3cab1a257 100644
@@ -151,6 +151,12 @@ static const struct cedrus_control cedrus_controls[] = {
 		},
 		.codec		= CEDRUS_CODEC_VP8,
 	},
+	{
+		.cfg = {
+			.id = V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS,
+		},
+		.codec		= CEDRUS_CODEC_H265,
+	},
 };
 
 #define CEDRUS_CONTROLS_COUNT	ARRAY_SIZE(cedrus_controls)
drivers/staging/media/sunxi/cedrus/cedrus.h +1 -0
index 251a6a660351..2ca33ac38b9a 100644
@@ -76,6 +76,7 @@ struct cedrus_h265_run {
 	const struct v4l2_ctrl_hevc_sps			*sps;
 	const struct v4l2_ctrl_hevc_pps			*pps;
 	const struct v4l2_ctrl_hevc_slice_params	*slice_params;
+	const struct v4l2_ctrl_hevc_decode_params	*decode_params;
 };
 
 struct cedrus_vp8_run {
drivers/staging/media/sunxi/cedrus/cedrus_dec.c +2 -0
index a9090daf626a..cd821f417a14 100644
@@ -68,6 +68,8 @@ void cedrus_device_run(void *priv)
 			V4L2_CID_MPEG_VIDEO_HEVC_PPS);
 		run.h265.slice_params = cedrus_find_control_data(ctx,
 			V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS);
+		run.h265.decode_params = cedrus_find_control_data(ctx,
+			V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS);
 		break;
 
 	case V4L2_PIX_FMT_VP8_FRAME:
drivers/staging/media/sunxi/cedrus/cedrus_h265.c +4 -2
index ce497d0197df..dce5db6be13a 100644
@@ -245,6 +245,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 	const struct v4l2_ctrl_hevc_sps *sps;
 	const struct v4l2_ctrl_hevc_pps *pps;
 	const struct v4l2_ctrl_hevc_slice_params *slice_params;
+	const struct v4l2_ctrl_hevc_decode_params *decode_params;
 	const struct v4l2_hevc_pred_weight_table *pred_weight_table;
 	dma_addr_t src_buf_addr;
 	dma_addr_t src_buf_end_addr;
@@ -256,6 +257,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 	sps = run->h265.sps;
 	pps = run->h265.pps;
 	slice_params = run->h265.slice_params;
+	decode_params = run->h265.decode_params;
 	pred_weight_table = &slice_params->pred_weight_table;
 
 	/* MV column buffer size and allocation. */
@@ -487,7 +489,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 
 	reg = VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_TC_OFFSET_DIV2(slice_params->slice_tc_offset_div2) |
 	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_BETA_OFFSET_DIV2(slice_params->slice_beta_offset_div2) |
-	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST(slice_params->num_rps_poc_st_curr_after == 0) |
+	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST(decode_params->num_rps_poc_st_curr_after == 0) |
 	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CR_QP_OFFSET(slice_params->slice_cr_qp_offset) |
 	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CB_QP_OFFSET(slice_params->slice_cb_qp_offset) |
 	      VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_QP_DELTA(slice_params->slice_qp_delta);
@@ -528,7 +530,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 
 	/* Write decoded picture buffer in pic list. */
 	cedrus_h265_frame_info_write_dpb(ctx, slice_params->dpb,
-					 slice_params->num_active_dpb_entries);
+					 decode_params->num_active_dpb_entries);
 
 	/* Output frame. */
 
include/media/hevc-ctrls.h +2 -0
index b4cb2ef02f17..7fe704a08f77 100644
@@ -19,6 +19,7 @@
 #define V4L2_CID_MPEG_VIDEO_HEVC_SPS		(V4L2_CID_CODEC_BASE + 1008)
 #define V4L2_CID_MPEG_VIDEO_HEVC_PPS		(V4L2_CID_CODEC_BASE + 1009)
 #define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS	(V4L2_CID_CODEC_BASE + 1010)
+#define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS	(V4L2_CID_CODEC_BASE + 1012)
 #define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE	(V4L2_CID_CODEC_BASE + 1015)
 #define V4L2_CID_MPEG_VIDEO_HEVC_START_CODE	(V4L2_CID_CODEC_BASE + 1016)
 
@@ -26,6 +27,7 @@
 #define V4L2_CTRL_TYPE_HEVC_SPS 0x0120
 #define V4L2_CTRL_TYPE_HEVC_PPS 0x0121
 #define V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS 0x0122
+#define V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS 0x0124
 
Quoted 9 lines

include/media/hevc-ctrls.h enum v4l2_mpeg_video_hevc_start_code { · line 59

Quoted 7 lines
include/media/hevc-ctrls.h +1 -0
 enum v4l2_mpeg_video_hevc_decode_mode {
 	V4L2_MPEG_VIDEO_HEVC_DECODE_MODE_SLICE_BASED,
@@ -54,6 +56,9 @@ enum v4l2_mpeg_video_hevc_start_code {
 /* The controls are not stable at the moment and will likely be reworked. */
 struct v4l2_ctrl_hevc_sps {
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: Sequence parameter set */
+	__u8	video_parameter_set_id;

Whilst I don't object to the addition of vps id why do we need it if the VPS is never passed?

You are right I could remove it.

Quoted 97 lines
Quoted 85 lines
include/media/hevc-ctrls.h +25 -8
+	__u8	seq_parameter_set_id;
+	__u8	chroma_format_idc;
 	__u16	pic_width_in_luma_samples;
 	__u16	pic_height_in_luma_samples;
 	__u8	bit_depth_luma_minus8;
@@ -74,9 +79,9 @@ struct v4l2_ctrl_hevc_sps {
 	__u8	log2_diff_max_min_pcm_luma_coding_block_size;
 	__u8	num_short_term_ref_pic_sets;
 	__u8	num_long_term_ref_pics_sps;
-	__u8	chroma_format_idc;
 
-	__u8	padding;
+	__u8	num_slices;
+	__u8	padding[6];
 
 	__u64	flags;
 };
@@ -100,10 +105,15 @@ struct v4l2_ctrl_hevc_sps {
 #define V4L2_HEVC_PPS_FLAG_PPS_DISABLE_DEBLOCKING_FILTER	(1ULL << 16)
 #define V4L2_HEVC_PPS_FLAG_LISTS_MODIFICATION_PRESENT		(1ULL << 17)
 #define V4L2_HEVC_PPS_FLAG_SLICE_SEGMENT_HEADER_EXTENSION_PRESENT (1ULL << 18)
+#define V4L2_HEVC_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT	(1ULL << 19)
+#define V4L2_HEVC_PPS_FLAG_UNIFORM_SPACING			(1ULL << 20)
 
 struct v4l2_ctrl_hevc_pps {
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture parameter set */
+	__u8	pic_parameter_set_id;
 	__u8	num_extra_slice_header_bits;
+	__u8	num_ref_idx_l0_default_active_minus1;
+	__u8	num_ref_idx_l1_default_active_minus1;
 	__s8	init_qp_minus26;
 	__u8	diff_cu_qp_delta_depth;
 	__s8	pps_cb_qp_offset;
@@ -116,7 +126,7 @@ struct v4l2_ctrl_hevc_pps {
 	__s8	pps_tc_offset_div2;
 	__u8	log2_parallel_merge_level_minus2;
 
-	__u8	padding[4];
+	__u8	padding;
 	__u64	flags;
 };
 
@@ -165,6 +175,10 @@ struct v4l2_ctrl_hevc_slice_params {
 	__u32	bit_size;
 	__u32	data_bit_offset;
 
+	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
+	__u32	slice_segment_addr;
+	__u32	num_entry_point_offsets;
+
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: NAL unit header */
 	__u8	nal_unit_type;
 	__u8	nuh_temporal_id_plus1;
@@ -190,15 +204,13 @@ struct v4l2_ctrl_hevc_slice_params {
 	__u8	pic_struct;
 
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
-	__u8	num_active_dpb_entries;
 	__u8	ref_idx_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
 	__u8	ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
 
-	__u8	num_rps_poc_st_curr_before;
-	__u8	num_rps_poc_st_curr_after;
-	__u8	num_rps_poc_lt_curr;
+	__u16	short_term_ref_pic_set_size;
+	__u16	long_term_ref_pic_set_size;
 
-	__u8	padding;
+	__u8	padding[5];
 
 	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
 	struct v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
@@ -209,4 +221,21 @@ struct v4l2_ctrl_hevc_slice_params {
 	__u64	flags;
 };
 
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IRAP_PIC		0x1
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IDR_PIC		0x2
+#define V4L2_HEVC_DECODE_PARAM_FLAG_NO_OUTPUT_OF_PRIOR  0x4
+
+struct v4l2_ctrl_hevc_decode_params {
+	__s32	pic_order_cnt_val;
+	__u8	num_active_dpb_entries;
+	struct	v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_slice_params { · line 241

Quoted 10 lines
include/media/hevc-ctrls.h +9 -0
+	__u8	num_rps_poc_st_curr_before;
+	__u8	num_rps_poc_st_curr_after;
+	__u8	num_rps_poc_lt_curr;
+	__u8	rps_st_curr_before[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u8	rps_st_curr_after[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u8	rps_lt_curr[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+	__u64	flags;
+};
+
 #endif

While you are adding stuff is there any chance you could also add:

Quoted 4 lines

#define V4L2_HEVC_SLICE_PARAMS_FLAG_DEPENDENT_SLICE_SEGMENT (1ULL << 9)

to the slice flags? The rpi H265 decoder needs it to deal with cases where dependant_slice_segment is set in the slice header.

Remarks on previous versions suggest to only add what it is used by driver (like scaling feature) so I will wait to have an usage of this flag to introduce it.

Benjamin

Quoted 5 lines

Thanks

John Cox

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

maintainer
#6 lore raw

Re: [PATCH v2 1/9] media: hevc: Modify structures to follow H265 ITU spec

Hi John,

Le lundi 22 février 2021 à 17:39 +0100, Benjamin Gaignard a écrit :

Quoted 373 lines

Le 22/02/2021 à 17:24, John Cox a écrit :

Quoted 253 lines
Quoted 253 lines

The H.265 ITU specification (section 7.4) define the general slice segment header semantics.
Modified/added fields are:
- video_parameter_set_id: (7.4.3.1) identifies the VPS for reference by other syntax elements.
- seq_parameter_set_id: (7.4.3.2.1) specifies the value of the vps_video_parameter_set_id of the active VPS.
- chroma_format_idc: (7.4.3.2.1) specifies the chroma sampling relative to the luma sampling
- pic_parameter_set_id: (7.4.3.3.1) identifies the PPS for reference by other syntax elements
- num_ref_idx_l0_default_active_minus1: (7.4.3.3.1) specifies the inferred value of num_ref_idx_l0_active_minus1
- num_ref_idx_l1_default_active_minus1: (7.4.3.3.1) specifies the inferred value of num_ref_idx_l1_active_minus1
- slice_segment_addr: (7.4.7.1) specifies the address of the first coding tree block in the slice segment
- num_entry_point_offsets: (7.4.7.1) specifies the number of entry_point_offset_minus1[ i ] syntax elements in the slice header

Add HEVC decode params contains the information used in section "8.3 Slice decoding process" of the specification to let the hardware perform decoding of a slices.

Adapt Cedrus driver according to these changes.

---
version 2:
- remove all change related to scaling
- squash commits to a coherent split
- be more verbose about the added fields

drivers/media/v4l2-core/v4l2-ctrls.c          | 26 ++++++++---

drivers/staging/media/sunxi/cedrus/cedrus.c   |  6 +++
drivers/staging/media/sunxi/cedrus/cedrus.h   |  1 +
.../staging/media/sunxi/cedrus/cedrus_dec.c   |  2 +
.../staging/media/sunxi/cedrus/cedrus_h265.c  |  6 ++-
include/media/hevc-ctrls.h                    | 45 +++++++++++++++----
6 files changed, 69 insertions(+), 17 deletions(-)
drivers/media/v4l2- renamed from drivers/media/v4l2-core/v4l2-ctrls.c +0 -0

core/v4l2-ctrls.c
index 016cf6204cbb..4060b5bcc3c0 100644

drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
@@ -1028,6 +1028,7 @@ const char *v4l2_ctrl_get_name(u32 id)

        case V4L2_CID_MPEG_VIDEO_HEVC_SPS:                      return "HEVC Sequence Parameter Set";
        case V4L2_CID_MPEG_VIDEO_HEVC_PPS:                      return "HEVC Picture Parameter Set";
        case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:             return "HEVC Slice Parameters";
+       case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS:            return "HEVC Decode Parameters";
        case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE:              return "HEVC Decode Mode";
        case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE:               return "HEVC Start Code";

drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
@@ -1482,6 +1483,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum
 v4l2_ctrl_type *type,

        case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:
                *type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS; break;
+       case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS:
+               *type = V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS; +               break;
        case V4L2_CID_UNIT_CELL_SIZE:
                *type = V4L2_CTRL_TYPE_AREA; *flags |= V4L2_CTRL_FLAG_READ_ONLY;

drivers/media/v4l2-core/v4l2-ctrls.c +1 -0
@@ -1833,6 +1837,7 @@ static int std_validate_compound(const struct
 v4l2_ctrl *ctrl, u32 idx,
         struct v4l2_ctrl_hevc_sps *p_hevc_sps;
         struct v4l2_ctrl_hevc_pps *p_hevc_pps;
         struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
+       struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;
         struct v4l2_area *area;
         void *p = ptr.p + idx * ctrl->elem_size;

        unsigned int i;

drivers/media/v4l2-core/v4l2-ctrls.c +4 -6
@@ -2108,23 +2113,27 @@ static int std_validate_compound(const struct
 v4l2_ctrl *ctrl, u32 idx,
                 zero_padding(*p_hevc_pps);
                 break;
 
-       case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
-               p_hevc_slice_params = p;
+       case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
+               p_hevc_decode_params = p;
 
-               if (p_hevc_slice_params->num_active_dpb_entries >
+               if (p_hevc_decode_params->num_active_dpb_entries >
                     V4L2_HEVC_DPB_ENTRIES_NUM_MAX)
                         return -EINVAL;
 
-               zero_padding(p_hevc_slice_params->pred_weight_table);
-
-               for (i = 0; i < p_hevc_slice_params-
 >num_active_dpb_entries;
+               for (i = 0; i < p_hevc_decode_params-
 >num_active_dpb_entries;
                      i++) {

                        struct v4l2_hevc_dpb_entry *dpb_entry = -                               &p_hevc_slice_params->dpb[i]; +                               &p_hevc_decode_params->dpb[i];

                        zero_padding(*dpb_entry);
                }

+               break;

drivers/media/v4l2-core/v4l2-ctrls.c +5 -0
+
+       case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
+               p_hevc_slice_params = p;
+
+               zero_padding(p_hevc_slice_params->pred_weight_table);

                zero_padding(*p_hevc_slice_params); break;

drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
@@ -2821,6 +2830,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct
 v4l2_ctrl_handler *hdl,

        case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
                elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params); break;
+       case V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:
+               elem_size = sizeof(struct v4l2_ctrl_hevc_decode_params); +               break;
        case V4L2_CTRL_TYPE_AREA:
                elem_size = sizeof(struct v4l2_area);
                break;

drivers/staging/media/sunxi/cedrus/cedrus.c +6 -0
index 7bd9291c8d5f..4cd3cab1a257 100644
@@ -151,6 +151,12 @@ static const struct cedrus_control cedrus_controls[]
 = {
                 },
                 .codec          = CEDRUS_CODEC_VP8,
         },
+       {
+               .cfg = {
+                       .id = V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS,
+               },
+               .codec          = CEDRUS_CODEC_H265,
+       },
 };
 

#define CEDRUS_CONTROLS_COUNT   ARRAY_SIZE(cedrus_controls)

drivers/staging/media/sunxi/cedrus/cedrus.h +1 -0
index 251a6a660351..2ca33ac38b9a 100644
@@ -76,6 +76,7 @@ struct cedrus_h265_run {
         const struct v4l2_ctrl_hevc_sps                 *sps;
         const struct v4l2_ctrl_hevc_pps                 *pps;
         const struct v4l2_ctrl_hevc_slice_params        *slice_params;
+       const struct v4l2_ctrl_hevc_decode_params       *decode_params;
 };
 
 struct cedrus_vp8_run {
drivers/staging/media/sunxi/cedrus/cedrus_dec.c +2 -0
index a9090daf626a..cd821f417a14 100644
@@ -68,6 +68,8 @@ void cedrus_device_run(void *priv)
                         V4L2_CID_MPEG_VIDEO_HEVC_PPS);
                 run.h265.slice_params = cedrus_find_control_data(ctx,
                         V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS);
+               run.h265.decode_params = cedrus_find_control_data(ctx,
+                       V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS);
                 break;
 

        case V4L2_PIX_FMT_VP8_FRAME:

drivers/staging/media/sunxi/cedrus/cedrus_h265.c +2 -0
index ce497d0197df..dce5db6be13a 100644
@@ -245,6 +245,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
         const struct v4l2_ctrl_hevc_sps *sps;
         const struct v4l2_ctrl_hevc_pps *pps;
         const struct v4l2_ctrl_hevc_slice_params *slice_params;
+       const struct v4l2_ctrl_hevc_decode_params *decode_params;
         const struct v4l2_hevc_pred_weight_table *pred_weight_table;
         dma_addr_t src_buf_addr;
         dma_addr_t src_buf_end_addr;
@@ -256,6 +257,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
         sps = run->h265.sps;
         pps = run->h265.pps;
         slice_params = run->h265.slice_params;
+       decode_params = run->h265.decode_params;
         pred_weight_table = &slice_params->pred_weight_table;
 
         /* MV column buffer size and allocation. */
@@ -487,7 +489,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 

        reg = VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_TC_OFFSET_DIV2(slice_params-

Quoted 1 line

slice_tc_offset_div2) |

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_BETA_OFFSET_DIV2(slice_params-

Quoted 1 line

slice_beta_offset_div2) |

- VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST(slice_params-

Quoted 1 line

num_rps_poc_st_curr_after == 0) |

+ VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST(decode_params-

Quoted 1 line

num_rps_poc_st_curr_after == 0) |

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CR_QP_OFFSET(slice_params-

Quoted 1 line

slice_cr_qp_offset) |

VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CB_QP_OFFSET(slice_params-

Quoted 1 line

slice_cb_qp_offset) |

              VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_QP_DELTA(slice_params-

Quoted 1 line

slice_qp_delta);

drivers/staging/media/sunxi/cedrus/cedrus_h265.c +1 -1
@@ -528,7 +530,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
 
         /* Write decoded picture buffer in pic list. */
         cedrus_h265_frame_info_write_dpb(ctx, slice_params->dpb,
-                                        slice_params-
 >num_active_dpb_entries);
+                                        decode_params-
 >num_active_dpb_entries);
 

        /* Output frame. */

include/media/hevc-ctrls.h +1 -0
index b4cb2ef02f17..7fe704a08f77 100644
@@ -19,6 +19,7 @@
 #define V4L2_CID_MPEG_VIDEO_HEVC_SPS            (V4L2_CID_CODEC_BASE +
 1008)
 #define V4L2_CID_MPEG_VIDEO_HEVC_PPS            (V4L2_CID_CODEC_BASE +
 1009)
 #define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS   (V4L2_CID_CODEC_BASE +
 1010)
+#define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS (V4L2_CID_CODEC_BASE +

1012)
#define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE    (V4L2_CID_CODEC_BASE + 1015)
#define V4L2_CID_MPEG_VIDEO_HEVC_START_CODE     (V4L2_CID_CODEC_BASE + 1016)

include/media/hevc-ctrls.h +1 -0
@@ -26,6 +27,7 @@
 #define V4L2_CTRL_TYPE_HEVC_SPS 0x0120
 #define V4L2_CTRL_TYPE_HEVC_PPS 0x0121
 #define V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS 0x0122
+#define V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS 0x0124
 
Quoted 10 lines

include/media/hevc-ctrls.h enum v4l2_mpeg_video_hevc_start_code { · line 60

Quoted 8 lines
include/media/hevc-ctrls.h +1 -0
 enum v4l2_mpeg_video_hevc_decode_mode {
         V4L2_MPEG_VIDEO_HEVC_DECODE_MODE_SLICE_BASED,
@@ -54,6 +56,9 @@ enum v4l2_mpeg_video_hevc_start_code {
 /* The controls are not stable at the moment and will likely be reworked.
 */
 struct v4l2_ctrl_hevc_sps {
         /* ISO/IEC 23008-2, ITU-T Rec. H.265: Sequence parameter set */
+       __u8    video_parameter_set_id;

Whilst I don't object to the addition of vps id why do we need it if the VPS is never passed?

You are right I could remove it.

Quoted 105 lines
Quoted 93 lines
include/media/hevc-ctrls.h +2 -0
+       __u8    seq_parameter_set_id;
+       __u8    chroma_format_idc;
         __u16   pic_width_in_luma_samples;
         __u16   pic_height_in_luma_samples;

        __u8    bit_depth_luma_minus8;

include/media/hevc-ctrls.h +4 -2
@@ -74,9 +79,9 @@ struct v4l2_ctrl_hevc_sps {
         __u8    log2_diff_max_min_pcm_luma_coding_block_size;
         __u8    num_short_term_ref_pic_sets;
         __u8    num_long_term_ref_pics_sps;
-       __u8    chroma_format_idc;
 
-       __u8    padding;
+       __u8    num_slices;
+       __u8    padding[6];
 
         __u64   flags;
 };
@@ -100,10 +105,15 @@ struct v4l2_ctrl_hevc_sps {
 #define V4L2_HEVC_PPS_FLAG_PPS_DISABLE_DEBLOCKING_FILTER        (1ULL <<
 16)
 #define V4L2_HEVC_PPS_FLAG_LISTS_MODIFICATION_PRESENT           (1ULL <<
 17)
 #define V4L2_HEVC_PPS_FLAG_SLICE_SEGMENT_HEADER_EXTENSION_PRESENT (1ULL <<
 18)
+#define V4L2_HEVC_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT   (1ULL <<
 19)
+#define V4L2_HEVC_PPS_FLAG_UNIFORM_SPACING                     (1ULL <<
 20)
 
 struct v4l2_ctrl_hevc_pps {

        /* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture parameter set */ +       __u8    pic_parameter_set_id;
        __u8    num_extra_slice_header_bits;
+       __u8    num_ref_idx_l0_default_active_minus1;
+       __u8    num_ref_idx_l1_default_active_minus1;
        __s8    init_qp_minus26;
        __u8    diff_cu_qp_delta_depth;
        __s8    pps_cb_qp_offset;

include/media/hevc-ctrls.h +5 -1
@@ -116,7 +126,7 @@ struct v4l2_ctrl_hevc_pps {
         __s8    pps_tc_offset_div2;
         __u8    log2_parallel_merge_level_minus2;
 
-       __u8    padding[4];
+       __u8    padding;
         __u64   flags;
 };
 
@@ -165,6 +175,10 @@ struct v4l2_ctrl_hevc_slice_params {
         __u32   bit_size;
         __u32   data_bit_offset;
 
+       /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header
 */
+       __u32   slice_segment_addr;
+       __u32   num_entry_point_offsets;
+
         /* ISO/IEC 23008-2, ITU-T Rec. H.265: NAL unit header */
         __u8    nal_unit_type;

        __u8    nuh_temporal_id_plus1;

include/media/hevc-ctrls.h +3 -5
@@ -190,15 +204,13 @@ struct v4l2_ctrl_hevc_slice_params {
         __u8    pic_struct;
 
         /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header
 */
-       __u8    num_active_dpb_entries;
         __u8    ref_idx_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
         __u8    ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
 
-       __u8    num_rps_poc_st_curr_before;
-       __u8    num_rps_poc_st_curr_after;
-       __u8    num_rps_poc_lt_curr;
+       __u16   short_term_ref_pic_set_size;
+       __u16   long_term_ref_pic_set_size;
 
-       __u8    padding;
+       __u8    padding[5];
 
         /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header

*/
        struct v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];

include/media/hevc-ctrls.h +8 -0
@@ -209,4 +221,21 @@ struct v4l2_ctrl_hevc_slice_params {
         __u64   flags;
 };
 
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IRAP_PIC           0x1
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IDR_PIC            0x2
+#define V4L2_HEVC_DECODE_PARAM_FLAG_NO_OUTPUT_OF_PRIOR  0x4
+
+struct v4l2_ctrl_hevc_decode_params {
+       __s32   pic_order_cnt_val;
+       __u8    num_active_dpb_entries;
+       struct  v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];

include/media/hevc-ctrls.h struct v4l2_ctrl_hevc_slice_params { · line 241

Quoted 10 lines
include/media/hevc-ctrls.h +9 -0
+       __u8    num_rps_poc_st_curr_before;
+       __u8    num_rps_poc_st_curr_after;
+       __u8    num_rps_poc_lt_curr;
+       __u8    rps_st_curr_before[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+       __u8    rps_st_curr_after[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+       __u8    rps_lt_curr[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+       __u64   flags;
+};
+
 #endif

While you are adding stuff is there any chance you could also add:

Quoted 8 lines
Quoted 4 lines

#define V4L2_HEVC_SLICE_PARAMS_FLAG_DEPENDENT_SLICE_SEGMENT     (1ULL << 9)

to the slice flags?  The rpi H265 decoder needs it to deal with cases where dependant_slice_segment is set in the slice header.

Remarks on previous versions suggest to only add what it is used by driver (like scaling feature) so I will wait to have an usage of this flag to introduce it.

Any chance we can have a link to the related kernel code ? Userspace is already expected to fill the blank in the slice_params, but perhaps we missed something.

Quoted 9 lines

Benjamin

Quoted 5 lines

Thanks

John Cox

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

author maintainer
#7 lore raw

PATCH v2 2/9 media: hantro: Define HEVC codec profiles and supported features

In reply to Benjamin Gaignard

Define which HEVC profiles (up to level 5.1) and features (no scaling, no 10 bits) are supported by the driver.

---
 drivers/staging/media/hantro/hantro.h     |  2 +
 drivers/staging/media/hantro/hantro_drv.c | 58 +++++++++++++++++++++++
 2 files changed, 60 insertions(+)
drivers/staging/media/hantro/hantro.h +2 -0
index 65f9f7ea7dcf..bde65231f22f 100644
@@ -99,6 +99,7 @@ struct hantro_variant {
  * @HANTRO_MODE_H264_DEC: H264 decoder.
  * @HANTRO_MODE_MPEG2_DEC: MPEG-2 decoder.
  * @HANTRO_MODE_VP8_DEC: VP8 decoder.
+ * @HANTRO_MODE_HEVC_DEC: HEVC decoder.
  */
 enum hantro_codec_mode {
 	HANTRO_MODE_NONE = -1,
@@ -106,6 +107,7 @@ enum hantro_codec_mode {
 	HANTRO_MODE_H264_DEC,
 	HANTRO_MODE_MPEG2_DEC,
 	HANTRO_MODE_VP8_DEC,
+	HANTRO_MODE_HEVC_DEC,
 };
 
 /*
drivers/staging/media/hantro/hantro_drv.c +58 -0

70 lines not on this page · raw message

Signature · 7 lines
2.25.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#8 lore raw

PATCH v2 3/9 media: hantro: Add a field to distinguish the hardware versions

In reply to Benjamin Gaignard

Decoders hardware blocks could exist in multiple versions: add a field to distinguish them at runtime.
G2 hardware block doesn't have postprocessor hantro_needs_postproc function should always returns false in for this hardware. hantro_needs_postproc function becoming to much complex to stay inline in .h file move it to .c file.

Keep the default behavoir to be G1 hardware.

---
version 2:
- squash this commit with the post processor change to show one usage of core_hw_dec_rev

 drivers/staging/media/hantro/hantro.h          | 13 +++++++------
 drivers/staging/media/hantro/hantro_drv.c      |  2 ++
 drivers/staging/media/hantro/hantro_postproc.c | 17 +++++++++++++++++
 3 files changed, 26 insertions(+), 6 deletions(-)
drivers/staging/media/hantro/hantro.h +7 -6
index bde65231f22f..352930bd49fc 100644
@@ -36,6 +36,9 @@ struct hantro_codec_ops;
 #define HANTRO_H264_DECODER	BIT(18)
 #define HANTRO_DECODERS		0xffff0000
 
+#define HANTRO_G1_REV		0x6731
+#define HANTRO_G2_REV		0x6732
+
 /**
  * struct hantro_irq - irq handler and name
  *
@@ -170,6 +173,7 @@ hantro_vdev_to_func(struct video_device *vdev)
  * @enc_base:		Mapped address of VPU encoder register for convenience.
  * @dec_base:		Mapped address of VPU decoder register for convenience.
  * @ctrl_base:		Mapped address of VPU control block.
+ * @core_hw_dec_rev	Runtime detected HW decoder core revision
  * @vpu_mutex:		Mutex to synchronize V4L2 calls.
  * @irqlock:		Spinlock to synchronize access to data structures
  *			shared with interrupt handlers.
@@ -189,6 +193,7 @@ struct hantro_dev {
 	void __iomem *enc_base;
 	void __iomem *dec_base;
 	void __iomem *ctrl_base;
+	u32 core_hw_dec_rev;
 
 	struct mutex vpu_mutex;	/* video_device lock */
 	spinlock_t irqlock;
@@ -411,12 +416,8 @@ hantro_get_dst_buf(struct hantro_ctx *ctx)
 	return v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
 }
 
-static inline bool
-hantro_needs_postproc(const struct hantro_ctx *ctx,
-		      const struct hantro_fmt *fmt)
-{
-	return !ctx->is_encoder && fmt->fourcc != V4L2_PIX_FMT_NV12;
-}
+bool hantro_needs_postproc(const struct hantro_ctx *ctx,
+			   const struct hantro_fmt *fmt);
 
 static inline dma_addr_t
 hantro_get_dec_buf_addr(struct hantro_ctx *ctx, struct vb2_buffer *vb)
drivers/staging/media/hantro/hantro_drv.c +2 -0
index d86e322a5980..0a62beb0bfbd 100644
@@ -834,6 +834,8 @@ static int hantro_probe(struct platform_device *pdev)
 	}
 	vpu->enc_base = vpu->reg_bases[0] + vpu->variant->enc_offset;
 	vpu->dec_base = vpu->reg_bases[0] + vpu->variant->dec_offset;
+	/* by default decoder is G1 */
+	vpu->core_hw_dec_rev = HANTRO_G1_REV;
 
 	ret = dma_set_coherent_mask(vpu->dev, DMA_BIT_MASK(32));
 	if (ret) {
drivers/staging/media/hantro/hantro_postproc.c +17 -0
index 6d2a8f2a8f0b..050880f720d6 100644
@@ -50,6 +50,23 @@ const struct hantro_postproc_regs hantro_g1_postproc_regs = {
 	.display_width = {G1_REG_PP_DISPLAY_WIDTH, 0, 0xfff},
 };
 
+bool hantro_needs_postproc(const struct hantro_ctx *ctx,
+			   const struct hantro_fmt *fmt)
+{
+	struct hantro_dev *vpu = ctx->dev;
+
+	if (ctx->is_encoder)
+		return false;
+
+	if (vpu->core_hw_dec_rev == HANTRO_G1_REV)
+		return fmt->fourcc != V4L2_PIX_FMT_NV12;
+
+	if (vpu->core_hw_dec_rev == HANTRO_G2_REV)
+		return false;
+
+	return false;
+}
+
 void hantro_postproc_enable(struct hantro_ctx *ctx)
 {
 	struct hantro_dev *vpu = ctx->dev;
Signature · 7 lines
2.25.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#9 lore raw

PATCH v2 4/9 media: uapi: Add a control for HANTRO driver

In reply to Benjamin Gaignard

The HEVC HANTRO driver needs to know the number of bits to skip at the beginning of the slice header.
That is a hardware specific requirement so create a dedicated control that this purpose.

---
 include/uapi/linux/hantro-v4l2-controls.h | 20 ++++++++++++++++++++
 include/uapi/linux/v4l2-controls.h        |  5 +++++
 2 files changed, 25 insertions(+)
 create mode 100644 include/uapi/linux/hantro-v4l2-controls.h
include/uapi/linux/hantro-v4l2-controls.h new file +20 -0
new file mode 100644
index 000000000000..30b1999b7af3
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+#ifndef __UAPI_HANTRO_V4L2_CONYTROLS_H__
+#define __UAPI_HANTRO_V4L2_CONYTROLS_H__
+
+#include <linux/v4l2-controls.h>
+#include <media/hevc-ctrls.h>
+
+#define V4L2_CID_HANTRO_HEVC_EXTRA_DECODE_PARAMS	(V4L2_CID_USER_HANTRO_BASE + 0)
+
+/**
+ * struct hantro_hevc_extra_decode_params - extra decode parameters for hantro driver
+ * @hevc_hdr_skip_lenght:	header first bits offset
+ */
+struct hantro_hevc_extra_decode_params {
+	__u32	hevc_hdr_skip_lenght;
+	__u8	padding[4];
+};
+
+#endif
include/uapi/linux/v4l2-controls.h +5 -0
index 039c0d7add1b..ced7486c7f46 100644
@@ -209,6 +209,11 @@ enum v4l2_colorfx {
  * We reserve 128 controls for this driver.
  */
 #define V4L2_CID_USER_CCS_BASE			(V4L2_CID_USER_BASE + 0x10f0)
+/*
+ * The base for HANTRO driver controls.
+ * We reserve 32 controls for this driver.
+ */
+#define V4L2_CID_USER_HANTRO_BASE		(V4L2_CID_USER_BASE + 0x1170)
 
 /* MPEG-class control IDs */
 /* The MPEG controls are applicable to all codec controls
Signature · 7 lines
2.25.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
#10 lore raw

Re: [PATCH v2 4/9] media: uapi: Add a control for HANTRO driver

Hi!

Dne četrtek, 18. februar 2021 ob 20:18:39 CET je Benjamin Gaignard napisal(a):

include/uapi/linux/

Quoted 13 lines

The HEVC HANTRO driver needs to know the number of bits to skip at the beginning of the slice header.
That is a hardware specific requirement so create a dedicated control that this purpose.

---
 include/uapi/linux/hantro-v4l2-controls.h | 20 ++++++++++++++++++++
 include/uapi/linux/v4l2-controls.h        |  5 +++++
 2 files changed, 25 insertions(+)
 create mode 100644 include/uapi/linux/hantro-v4l2-controls.h
include/uapi/linux/ renamed from include/uapi/linux/hantro-v4l2-controls.h +0 -0

hantro-v4l2-controls.h

Quoted 5 lines

new file mode 100644
index 000000000000..30b1999b7af3

include/uapi/linux/hantro-v4l2-controls.h line 9

Quoted 9 lines
include/uapi/linux/hantro-v4l2-controls.h new file +9 -0
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+#ifndef __UAPI_HANTRO_V4L2_CONYTROLS_H__
+#define __UAPI_HANTRO_V4L2_CONYTROLS_H__
+
+#include <linux/v4l2-controls.h>
+#include <media/hevc-ctrls.h>
+
+#define V4L2_CID_HANTRO_HEVC_EXTRA_DECODE_PARAMS	

(V4L2_CID_USER_HANTRO_BASE + 0)

include/uapi/linux/hantro-v4l2-controls.h

Quoted 3 lines
include/uapi/linux/hantro-v4l2-controls.h new file +3 -0
+
+/**
+ * struct hantro_hevc_extra_decode_params - extra decode parameters for 

hantro driver

include/uapi/linux/hantro-v4l2-controls.h line 16

Quoted 4 lines
include/uapi/linux/hantro-v4l2-controls.h new file +4 -0
+ * @hevc_hdr_skip_lenght:	header first bits offset
+ */
+struct hantro_hevc_extra_decode_params {
+	__u32	hevc_hdr_skip_lenght;

typo: lenght -> length

Same mistake in description above.

Best regards,
Jernej

include/uapi/linux/v4l2-

Quoted 5 lines
include/uapi/linux/hantro-v4l2-controls.h new file +4 -0
+	__u8	padding[4];
+};
+
+#endif
include/uapi/linux/v4l2- renamed from include/uapi/linux/v4l2-controls.h +0 -0

controls.h

include/uapi/linux/v4l2-controls.h enum v4l2_colorfx { · line 211

Quoted 7 lines

index 039c0d7add1b..ced7486c7f46 100644

include/uapi/linux/v4l2-controls.h +0 -0
@@ -209,6 +209,11 @@ enum v4l2_colorfx {
  * We reserve 128 controls for this driver.
  */
 #define V4L2_CID_USER_CCS_BASE			(V4L2_CID_USER_BASE + 

0x10f0)

include/uapi/linux/v4l2-controls.h enum v4l2_colorfx {

Quoted 5 lines
include/uapi/linux/v4l2-controls.h +5 -0
+/*
+ * The base for HANTRO driver controls.
+ * We reserve 32 controls for this driver.
+ */
+#define V4L2_CID_USER_HANTRO_BASE		(V4L2_CID_USER_BASE + 

0x1170)

Quoted 7 lines
include/uapi/linux/v4l2-controls.h +0 -0
 /* MPEG-class control IDs */
 /* The MPEG controls are applicable to all codec controls
Signature · 1 line
2.25.1

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

author maintainer
#11 lore raw

Re: [PATCH v2 4/9] media: uapi: Add a control for HANTRO driver

Le 18/02/2021 à 22:34, Jernej Škrabec a écrit :

Quoted 36 lines

Hi!

Dne četrtek, 18. februar 2021 ob 20:18:39 CET je Benjamin Gaignard napisal(a):

include/uapi/linux/

Quoted 13 lines

The HEVC HANTRO driver needs to know the number of bits to skip at the beginning of the slice header.
That is a hardware specific requirement so create a dedicated control that this purpose.

---
  include/uapi/linux/hantro-v4l2-controls.h | 20 ++++++++++++++++++++
  include/uapi/linux/v4l2-controls.h        |  5 +++++
  2 files changed, 25 insertions(+)

create mode 100644 include/uapi/linux/hantro-v4l2-controls.h

include/uapi/linux/ renamed from include/uapi/linux/hantro-v4l2-controls.h +0 -0

hantro-v4l2-controls.h

Quoted 5 lines

new file mode 100644
index 000000000000..30b1999b7af3

include/uapi/linux/hantro-v4l2-controls.h line 9

Quoted 9 lines
include/uapi/linux/hantro-v4l2-controls.h new file +9 -0
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+#ifndef __UAPI_HANTRO_V4L2_CONYTROLS_H__
+#define __UAPI_HANTRO_V4L2_CONYTROLS_H__
+
+#include <linux/v4l2-controls.h>
+#include <media/hevc-ctrls.h>
+
+#define V4L2_CID_HANTRO_HEVC_EXTRA_DECODE_PARAMS	

(V4L2_CID_USER_HANTRO_BASE + 0)

include/uapi/linux/hantro-v4l2-controls.h

Quoted 3 lines
include/uapi/linux/hantro-v4l2-controls.h new file +3 -0
+
+/**
+ * struct hantro_hevc_extra_decode_params - extra decode parameters for

hantro driver

Quoted 7 lines

include/uapi/linux/hantro-v4l2-controls.h line 16

Quoted 4 lines
include/uapi/linux/hantro-v4l2-controls.h new file +4 -0
+ * @hevc_hdr_skip_lenght:	header first bits offset
+ */
+struct hantro_hevc_extra_decode_params {
+	__u32	hevc_hdr_skip_lenght;

typo: lenght -> length

Same mistake in description above.

Thanks I will fix that in v3

Benjamin

Quoted 18 lines

Best regards,
Jernej

include/uapi/linux/v4l2-

Quoted 5 lines
include/uapi/linux/hantro-v4l2-controls.h new file +4 -0
+	__u8	padding[4];
+};
+
+#endif
include/uapi/linux/v4l2- renamed from include/uapi/linux/v4l2-controls.h +0 -0

controls.h

include/uapi/linux/v4l2-controls.h enum v4l2_colorfx { · line 211

Quoted 7 lines

index 039c0d7add1b..ced7486c7f46 100644

include/uapi/linux/v4l2-controls.h +0 -0
@@ -209,6 +209,11 @@ enum v4l2_colorfx {
   * We reserve 128 controls for this driver.
   */
  #define V4L2_CID_USER_CCS_BASE			(V4L2_CID_USER_BASE +

0x10f0)

Quoted 15 lines

include/uapi/linux/v4l2-controls.h enum v4l2_colorfx {

Quoted 5 lines
include/uapi/linux/v4l2-controls.h +5 -0
+/*
+ * The base for HANTRO driver controls.
+ * We reserve 32 controls for this driver.
+ */
+#define V4L2_CID_USER_HANTRO_BASE		(V4L2_CID_USER_BASE +

0x1170)

Quoted 7 lines
include/uapi/linux/v4l2-controls.h +0 -0
  /* MPEG-class control IDs */
  /* The MPEG controls are applicable to all codec controls
Signature · 1 line
2.25.1

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#12 lore raw

Re: [PATCH v2 4/9] media: uapi: Add a control for HANTRO driver

In reply to Benjamin Gaignard
Quoted 26 lines

The HEVC HANTRO driver needs to know the number of bits to skip at the beginning of the slice header.
That is a hardware specific requirement so create a dedicated control that this purpose.

---
include/uapi/linux/hantro-v4l2-controls.h | 20 ++++++++++++++++++++
include/uapi/linux/v4l2-controls.h | 5 +++++

2 files changed, 25 insertions(+)

create mode 100644 include/uapi/linux/hantro-v4l2-controls.h

include/uapi/linux/hantro-v4l2-controls.h new file +8 -0
new file mode 100644
index 000000000000..30b1999b7af3
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+#ifndef __UAPI_HANTRO_V4L2_CONYTROLS_H__
+#define __UAPI_HANTRO_V4L2_CONYTROLS_H__
+
+#include <linux/v4l2-controls.h>
+#include <media/hevc-ctrls.h>
+

include/uapi/linux/hantro-v4l2-controls.h line 18

Quoted 10 lines
include/uapi/linux/hantro-v4l2-controls.h new file +10 -0
+#define V4L2_CID_HANTRO_HEVC_EXTRA_DECODE_PARAMS	(V4L2_CID_USER_HANTRO_BASE + 0)
+
+/**
+ * struct hantro_hevc_extra_decode_params - extra decode parameters for hantro driver
+ * @hevc_hdr_skip_lenght:	header first bits offset
+ */
+struct hantro_hevc_extra_decode_params {
+	__u32	hevc_hdr_skip_lenght;
+	__u8	padding[4];
+};

Can you clarify how hevc_hdr_skip_length differs from v4l2_ctrl_hevc_slice_params.data_bit_offset? At first sight they would appear to be very similar.

Regards

John Cox

Quoted 7 lines
include/uapi/linux/hantro-v4l2-controls.h new file +1 -0
+#endif
include/uapi/linux/v4l2-controls.h +0 -0
index 039c0d7add1b..ced7486c7f46 100644
@@ -209,6 +209,11 @@ enum v4l2_colorfx {
 * We reserve 128 controls for this driver.

include/uapi/linux/v4l2-controls.h enum v4l2_colorfx { · line 219

Quoted 10 lines
include/uapi/linux/v4l2-controls.h +5 -0
 */
 #define V4L2_CID_USER_CCS_BASE			(V4L2_CID_USER_BASE + 0x10f0)
+/*
+ * The base for HANTRO driver controls.
+ * We reserve 32 controls for this driver.
+ */
+#define V4L2_CID_USER_HANTRO_BASE		(V4L2_CID_USER_BASE + 0x1170)
 
 /* MPEG-class control IDs */
 /* The MPEG controls are applicable to all codec controls

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

author maintainer
#13 lore raw

Re: [PATCH v2 4/9] media: uapi: Add a control for HANTRO driver

Le 22/02/2021 à 17:16, John Cox a écrit :

Quoted 31 lines
Quoted 31 lines

The HEVC HANTRO driver needs to know the number of bits to skip at the beginning of the slice header.
That is a hardware specific requirement so create a dedicated control that this purpose.

---
include/uapi/linux/hantro-v4l2-controls.h | 20 ++++++++++++++++++++
include/uapi/linux/v4l2-controls.h | 5 +++++

2 files changed, 25 insertions(+)

create mode 100644 include/uapi/linux/hantro-v4l2-controls.h

include/uapi/linux/hantro-v4l2-controls.h new file +13 -0
new file mode 100644
index 000000000000..30b1999b7af3
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+#ifndef __UAPI_HANTRO_V4L2_CONYTROLS_H__
+#define __UAPI_HANTRO_V4L2_CONYTROLS_H__
+
+#include <linux/v4l2-controls.h>
+#include <media/hevc-ctrls.h>
+
+#define V4L2_CID_HANTRO_HEVC_EXTRA_DECODE_PARAMS	(V4L2_CID_USER_HANTRO_BASE + 0)
+
+/**
+ * struct hantro_hevc_extra_decode_params - extra decode parameters for hantro driver
+ * @hevc_hdr_skip_lenght:	header first bits offset
Quoted 8 lines

include/uapi/linux/hantro-v4l2-controls.h line 18

Quoted 5 lines
include/uapi/linux/hantro-v4l2-controls.h new file +5 -0
+ */
+struct hantro_hevc_extra_decode_params {
+	__u32	hevc_hdr_skip_lenght;
+	__u8	padding[4];
+};

Can you clarify how hevc_hdr_skip_length differs from v4l2_ctrl_hevc_slice_params.data_bit_offset? At first sight they would appear to be very similar.

hevc_hdr_skip_length is the difference between the start positions of 2 nals. v4l2_ctrl_hevc_slice_params.data_bit_offset is the offset of the data in the nal.

Benjamin

Quoted 20 lines

Regards

John Cox

Quoted 15 lines
include/uapi/linux/hantro-v4l2-controls.h new file +1 -0
+#endif
include/uapi/linux/v4l2-controls.h +5 -0
index 039c0d7add1b..ced7486c7f46 100644
@@ -209,6 +209,11 @@ enum v4l2_colorfx {
  * We reserve 128 controls for this driver.
  */
 #define V4L2_CID_USER_CCS_BASE			(V4L2_CID_USER_BASE + 0x10f0)
+/*
+ * The base for HANTRO driver controls.
+ * We reserve 32 controls for this driver.
+ */
+#define V4L2_CID_USER_HANTRO_BASE		(V4L2_CID_USER_BASE + 0x1170)
 
Quoted 2 lines

include/uapi/linux/v4l2-controls.h enum v4l2_colorfx { · line 219

Quoted 2 lines
include/uapi/linux/v4l2-controls.h +0 -0
 /* MPEG-class control IDs */
 /* The MPEG controls are applicable to all codec controls

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#14 lore raw

Re: [PATCH v2 4/9] media: uapi: Add a control for HANTRO driver

Quoted 42 lines · Benjamin Gaignard

Le 22/02/2021 à 17:16, John Cox a écrit :

Quoted 31 lines
Quoted 31 lines

The HEVC HANTRO driver needs to know the number of bits to skip at the beginning of the slice header.
That is a hardware specific requirement so create a dedicated control that this purpose.

---
include/uapi/linux/hantro-v4l2-controls.h | 20 ++++++++++++++++++++ include/uapi/linux/v4l2-controls.h        |  5 +++++

2 files changed, 25 insertions(+)

create mode 100644 include/uapi/linux/hantro-v4l2-controls.h

include/uapi/linux/hantro-v4l2-controls.h new file +13 -0
new file mode 100644
index 000000000000..30b1999b7af3
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+#ifndef __UAPI_HANTRO_V4L2_CONYTROLS_H__
+#define __UAPI_HANTRO_V4L2_CONYTROLS_H__
+
+#include <linux/v4l2-controls.h>
+#include <media/hevc-ctrls.h>
+
+#define V4L2_CID_HANTRO_HEVC_EXTRA_DECODE_PARAMS       (V4L2_CID_USER_HANTRO_BASE + 0)
+
+/**
+ * struct hantro_hevc_extra_decode_params - extra decode parameters for hantro driver
+ * @hevc_hdr_skip_lenght:      header first bits offset
Quoted 8 lines

include/uapi/linux/hantro-v4l2-controls.h line 18

Quoted 5 lines
include/uapi/linux/hantro-v4l2-controls.h new file +5 -0
+ */
+struct hantro_hevc_extra_decode_params {
+       __u32   hevc_hdr_skip_lenght;
+       __u8    padding[4];
+};

Can you clarify how hevc_hdr_skip_length differs from v4l2_ctrl_hevc_slice_params.data_bit_offset?  At first sight they would appear to be very similar.

Quoted 3 lines

hevc_hdr_skip_length is the difference between the start positions of 2 nals. v4l2_ctrl_hevc_slice_params.data_bit_offset is the offset of the data in the nal.

I think the hardware is weird enough that we should have detailed documentation to the exact expectation for this control, i.e. detailing exactly what syntax elements userspace is expected to pass the distance.

Maybe documenting this somewhere in Documentation/.../media/something, and then linking that in the kernel-doc comment for hantro_hevc_extra_decode_params.

Thanks,
Ezequiel

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

maintainer
#15 lore raw

Re: [PATCH v2 4/9] media: uapi: Add a control for HANTRO driver

In reply to Benjamin Gaignard

Le lundi 22 février 2021 à 17:28 +0100, Benjamin Gaignard a écrit :

Quoted 46 lines

Le 22/02/2021 à 17:16, John Cox a écrit :

Quoted 35 lines
Quoted 35 lines

The HEVC HANTRO driver needs to know the number of bits to skip at the beginning of the slice header.
That is a hardware specific requirement so create a dedicated control that this purpose.

---
include/uapi/linux/hantro-v4l2-controls.h | 20 ++++++++++++++++++++ include/uapi/linux/v4l2-controls.h        |  5 +++++

2 files changed, 25 insertions(+)

create mode 100644 include/uapi/linux/hantro-v4l2-controls.h

include/uapi/linux/hantro-v4l2-controls.h new file +9 -0
new file mode 100644
index 000000000000..30b1999b7af3
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+#ifndef __UAPI_HANTRO_V4L2_CONYTROLS_H__
+#define __UAPI_HANTRO_V4L2_CONYTROLS_H__
+
+#include <linux/v4l2-controls.h>
+#include <media/hevc-ctrls.h>
+
+#define

V4L2_CID_HANTRO_HEVC_EXTRA_DECODE_PARAMS       (V4L2_CID_USER_HANTRO_BASE
+ 0)

include/uapi/linux/hantro-v4l2-controls.h new file +3 -0
+
+/**
+ * struct hantro_hevc_extra_decode_params - extra decode parameters for

hantro driver
+ * @hevc_hdr_skip_lenght:      header first bits offset

Quoted 8 lines

include/uapi/linux/hantro-v4l2-controls.h line 18

Quoted 5 lines

+ */

include/uapi/linux/hantro-v4l2-controls.h new file +4 -0
+struct hantro_hevc_extra_decode_params {
+       __u32   hevc_hdr_skip_lenght;
+       __u8    padding[4];
+};

Can you clarify how hevc_hdr_skip_length differs from v4l2_ctrl_hevc_slice_params.data_bit_offset?  At first sight they would appear to be very similar.

Quoted 3 lines

hevc_hdr_skip_length is the difference between the start positions of 2 nals. v4l2_ctrl_hevc_slice_params.data_bit_offset is the offset of the data in the nal.

More precisely (and doc should reflect this please), the Hantro skip is the distance in bits for data in the slice_segment_header() header syntax after 'slice_type'. The slice_segment_header_extension_length and bytes seems excluded from reading the reference code, we don't know if this is because this extended header is simply not supported or if it's being parsed by the HW. I believe we need to clarify this before merging the control.

If dependent_slice_segment_flag is set, then this offsets seems to be 0. This fact also needs further investigation since this flag, as you mention, isn't passed and is needed to decide whether to parse or not the slice_type.

Benjamin, I think we need some HW fact checking for all these, and finally better documentation.

Quoted 27 lines

Benjamin

Quoted 23 lines

Regards

John Cox

Quoted 18 lines
include/uapi/linux/hantro-v4l2-controls.h new file +1 -0
+#endif
include/uapi/linux/v4l2- renamed from include/uapi/linux/v4l2-controls.h +0 -0

controls.h
index 039c0d7add1b..ced7486c7f46 100644

include/uapi/linux/v4l2-controls.h +5 -0
@@ -209,6 +209,11 @@ enum v4l2_colorfx {
   * We reserve 128 controls for this driver.
   */
 #define V4L2_CID_USER_CCS_BASE                  (V4L2_CID_USER_BASE +
 0x10f0)
+/*
+ * The base for HANTRO driver controls.
+ * We reserve 32 controls for this driver.
+ */
+#define V4L2_CID_USER_HANTRO_BASE              (V4L2_CID_USER_BASE +
 0x1170)
 
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

/* MPEG-class control IDs */
/* The MPEG controls are applicable to all codec controls

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

author maintainer
#16 lore raw

PATCH v2 5/9 media: hantro: Introduce G2/HEVC decoder

In reply to Benjamin Gaignard

Implement all the logic to get G2 hardware decoding HEVC frames. It support up level 5.1 HEVC stream.
It doesn't support yet 10 bits formats or scaling feature.

Add HANTRO HEVC dedicated control to skip some bits at the beginning of the slice header. That is very specific to this hardware so can't go into uapi structures. Compute the needed value is complex and require information from the stream that only the userland knows so let it provide the correct value to the driver.

---
version 2:
- squash multiple commits in this one.
- fix the comments done by Ezequiel about dma_alloc_coherent usage
- fix Dan's comments about control copy, reverse the test logic in tile_buffer_reallocate, rework some goto and return cases.

 drivers/staging/media/hantro/Makefile         |   2 +
 drivers/staging/media/hantro/hantro.h         |  19 +
 drivers/staging/media/hantro/hantro_drv.c     |  42 ++
 .../staging/media/hantro/hantro_g2_hevc_dec.c | 587 ++++++++++++++++++
 drivers/staging/media/hantro/hantro_g2_regs.h | 198 ++++++
 drivers/staging/media/hantro/hantro_hevc.c    | 321 ++++++++++
 drivers/staging/media/hantro/hantro_hw.h      |  47 ++
 7 files changed, 1216 insertions(+)
 create mode 100644 drivers/staging/media/hantro/hantro_g2_hevc_dec.c
 create mode 100644 drivers/staging/media/hantro/hantro_g2_regs.h
 create mode 100644 drivers/staging/media/hantro/hantro_hevc.c
drivers/staging/media/hantro/Makefile +2 -0
index 743ce08eb184..0357f1772267 100644
@@ -9,12 +9,14 @@ hantro-vpu-y += \
 		hantro_h1_jpeg_enc.o \
 		hantro_g1_h264_dec.o \
 		hantro_g1_mpeg2_dec.o \
+		hantro_g2_hevc_dec.o \
 		hantro_g1_vp8_dec.o \
 		rk3399_vpu_hw_jpeg_enc.o \
 		rk3399_vpu_hw_mpeg2_dec.o \
 		rk3399_vpu_hw_vp8_dec.o \
 		hantro_jpeg.o \
 		hantro_h264.o \
+		hantro_hevc.o \
 		hantro_mpeg2.o \
 		hantro_vp8.o
 
drivers/staging/media/hantro/hantro.h +19 -0
index 352930bd49fc..a9b80b2c9124 100644
@@ -34,6 +34,7 @@ struct hantro_codec_ops;
 #define HANTRO_MPEG2_DECODER	BIT(16)
 #define HANTRO_VP8_DECODER	BIT(17)
 #define HANTRO_H264_DECODER	BIT(18)
+#define HANTRO_HEVC_DECODER	BIT(19)
 #define HANTRO_DECODERS		0xffff0000
 
 #define HANTRO_G1_REV		0x6731
@@ -224,6 +225,7 @@ struct hantro_dev {
  * @jpeg_enc:		JPEG-encoding context.
  * @mpeg2_dec:		MPEG-2-decoding context.
  * @vp8_dec:		VP8-decoding context.
+ * @hevc_dec:		HEVC-decoding context.
  */
 struct hantro_ctx {
 	struct hantro_dev *dev;
@@ -250,6 +252,7 @@ struct hantro_ctx {
 		struct hantro_jpeg_enc_hw_ctx jpeg_enc;
 		struct hantro_mpeg2_dec_hw_ctx mpeg2_dec;
 		struct hantro_vp8_dec_hw_ctx vp8_dec;
+		struct hantro_hevc_dec_hw_ctx hevc_dec;
 	};
 };
 
@@ -427,6 +430,22 @@ hantro_get_dec_buf_addr(struct hantro_ctx *ctx, struct vb2_buffer *vb)
 	return vb2_dma_contig_plane_dma_addr(vb, 0);
 }
 
+static inline size_t
+hantro_get_dec_buf_size(struct hantro_ctx *ctx, struct vb2_buffer *vb)
+{
+	if (hantro_needs_postproc(ctx, ctx->vpu_dst_fmt))
+		return ctx->postproc.dec_q[vb->index].size;
+	return vb2_plane_size(vb, 0);
+}
+
+static inline void *
+hantro_get_dec_buf(struct hantro_ctx *ctx, struct vb2_buffer *vb)
+{
+	if (hantro_needs_postproc(ctx, ctx->vpu_dst_fmt))
+		return ctx->postproc.dec_q[vb->index].cpu;
+	return vb2_plane_vaddr(vb, 0);
+}
+
 void hantro_postproc_disable(struct hantro_ctx *ctx);
 void hantro_postproc_enable(struct hantro_ctx *ctx);
 void hantro_postproc_free(struct hantro_ctx *ctx);
drivers/staging/media/hantro/hantro_drv.c +42 -0

60 lines not on this page · raw message

drivers/staging/media/hantro/hantro_g2_hevc_dec.c new file +587 -0

587 lines not on this page · raw message

drivers/staging/media/hantro/hantro_g2_regs.h new file +198 -0

198 lines not on this page · raw message

drivers/staging/media/hantro/hantro_hevc.c new file +321 -0

321 lines not on this page · raw message

drivers/staging/media/hantro/hantro_hw.h +47 -0

71 lines not on this page · raw message

Signature · 7 lines
2.25.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#17 lore raw

PATCH v2 6/9 media: hantro: handle V4L2_PIX_FMT_HEVC_SLICE control

In reply to Benjamin Gaignard

Make sure that V4L2_PIX_FMT_HEVC_SLICE is correctly handle by v4l2 of the driver.

---
 drivers/staging/media/hantro/hantro_v4l2.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/media/hantro/hantro_v4l2.c +1 -0
index 1bc118e375a1..e16d5fd0b9f7 100644
@@ -390,6 +390,7 @@ hantro_update_requires_request(struct hantro_ctx *ctx, u32 fourcc)
 	case V4L2_PIX_FMT_MPEG2_SLICE:
 	case V4L2_PIX_FMT_VP8_FRAME:
 	case V4L2_PIX_FMT_H264_SLICE:
+	case V4L2_PIX_FMT_HEVC_SLICE:
 		ctx->fh.m2m_ctx->out_q_ctx.q.requires_requests = true;
 		break;
 	default:
Signature · 7 lines
2.25.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#18 lore raw

PATCH v2 7/9 media: hantro: IMX8M: add variant for G2/HEVC codec

In reply to Benjamin Gaignard

Add variant to IMX8M to enable G2/HEVC codec.
Define the capabilities for the hardware up to 3840x2160. Retrieve the hardware version at init to distinguish G1 from G2.

---
version 2:
- remove useless clocks

 drivers/staging/media/hantro/hantro_drv.c   |  1 +
 drivers/staging/media/hantro/hantro_hw.h    |  1 +
 drivers/staging/media/hantro/imx8m_vpu_hw.c | 95 ++++++++++++++++++++-
 3 files changed, 93 insertions(+), 4 deletions(-)
drivers/staging/media/hantro/hantro_drv.c +1 -0
index c009941dff3e..b6eb933b008c 100644
@@ -578,6 +578,7 @@ static const struct of_device_id of_hantro_match[] = {
 #endif
 #ifdef CONFIG_VIDEO_HANTRO_IMX8M
 	{ .compatible = "nxp,imx8mq-vpu", .data = &imx8mq_vpu_variant, },
+	{ .compatible = "nxp,imx8mq-vpu-g2", .data = &imx8mq_vpu_g2_variant },
 #endif
 	{ /* sentinel */ }
 };
drivers/staging/media/hantro/hantro_hw.h +1 -0
index 82e19b477173..77d6c065cea1 100644
@@ -190,6 +190,7 @@ extern const struct hantro_variant rk3399_vpu_variant;
 extern const struct hantro_variant rk3328_vpu_variant;
 extern const struct hantro_variant rk3288_vpu_variant;
 extern const struct hantro_variant imx8mq_vpu_variant;
+extern const struct hantro_variant imx8mq_vpu_g2_variant;
 
 extern const struct hantro_postproc_regs hantro_g1_postproc_regs;
 
drivers/staging/media/hantro/imx8m_vpu_hw.c +91 -4

132 lines not on this page · raw message

Signature · 7 lines
2.25.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#19 lore raw

PATCH v2 8/9 dt-bindings: media: nxp,imx8mq-vpu: Update bindings

In reply to Benjamin Gaignard

The current bindings seem to make the assumption that the two VPUs hardware blocks (G1 and G2) are only one set of registers.
After implementing the VPU reset driver and G2 decoder driver it shows that all the VPUs are independent and don't need to know about the registers of the other blocks.
Remove from the bindings the need to set all blocks register but keep reg-names property because removing it from the driver may affect other variants.

---
version 2:
- be more verbose about why I change the bindings
Keep in mind that series comes after: https://www.spinics.net/lists/arm-kernel/msg875766.html
without that review and ack it won't work

 .../bindings/media/nxp,imx8mq-vpu.yaml        | 54 ++++++++++++-------
 1 file changed, 36 insertions(+), 18 deletions(-)
Documentation/devicetree/bindings/media/nxp,imx8mq-vpu.yaml +36 -18
index 762be3f96ce9..468435c70eef 100644
@@ -15,24 +15,25 @@ description:
 
 properties:
   compatible:
-    const: nxp,imx8mq-vpu
+    enum:
+      - nxp,imx8mq-vpu
+      - nxp,imx8mq-vpu-g2
 
   reg:
-    maxItems: 3
+    maxItems: 1
 
   reg-names:
-    items:
-      - const: g1
-      - const: g2
-      - const: ctrl
+    enum:
+      - g1
+      - g2
 
   interrupts:
-    maxItems: 2
+    maxItems: 1
 
   interrupt-names:
-    items:
-      - const: g1
-      - const: g2
+    enum:
+      - g1
+      - g2
 
   clocks:
     maxItems: 3
@@ -46,6 +47,9 @@ properties:
   power-domains:
     maxItems: 1
 
+  resets:
+    maxItems: 1
+
 required:
   - compatible
   - reg
@@ -54,6 +58,7 @@ required:
   - interrupt-names
   - clocks
   - clock-names
+  - resets
 
 additionalProperties: false
 
@@ -61,19 +66,32 @@ examples:
   - |
         #include <dt-bindings/clock/imx8mq-clock.h>
         #include <dt-bindings/interrupt-controller/arm-gic.h>
+        #include <dt-bindings/reset/imx8mq-vpu-reset.h>
 
-        vpu: video-codec@38300000 {
+        vpu_g1: video-codec@38300000 {
                 compatible = "nxp,imx8mq-vpu";
-                reg = <0x38300000 0x10000>,
-                      <0x38310000 0x10000>,
-                      <0x38320000 0x10000>;
-                reg-names = "g1", "g2", "ctrl";
-                interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>,
-                             <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
-                interrupt-names = "g1", "g2";
+                reg = <0x38300000 0x10000>;
+                reg-names = "g1";
+                interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
+                interrupt-names = "g1";
+                clocks = <&clk IMX8MQ_CLK_VPU_G1_ROOT>,
+                         <&clk IMX8MQ_CLK_VPU_G2_ROOT>,
+                         <&clk IMX8MQ_CLK_VPU_DEC_ROOT>;
+                clock-names = "g1", "g2", "bus";
+                power-domains = <&pgc_vpu>;
+                resets = <&vpu_reset IMX8MQ_RESET_VPU_RESET_G1>;
+        };
+
+        vpu_g2: video-codec@38310000 {
+                compatible = "nxp,imx8mq-vpu-g2";
+                reg = <0x38310000 0x10000>;
+                reg-names = "g2";
+                interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
+                interrupt-names = "g2";
                 clocks = <&clk IMX8MQ_CLK_VPU_G1_ROOT>,
                          <&clk IMX8MQ_CLK_VPU_G2_ROOT>,
                          <&clk IMX8MQ_CLK_VPU_DEC_ROOT>;
                 clock-names = "g1", "g2", "bus";
                 power-domains = <&pgc_vpu>;
+                resets = <&vpu_reset IMX8MQ_RESET_VPU_RESET_G2>;
         };
Signature · 7 lines
2.25.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#20 lore raw

PATCH v2 9/9 arm64: dts: imx8mq: Add node to G2 hardware

In reply to Benjamin Gaignard

Split VPU node in two: one for G1 and one for G2 since they are different hardware blocks.

---
version 2:
- remove useless clocks in VPUs nodes

 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 41 +++++++++++++++++------
 1 file changed, 31 insertions(+), 10 deletions(-)
arch/arm64/boot/dts/freescale/imx8mq.dtsi +31 -10
index d9d9efc8592d..8358e214d696 100644
@@ -1287,17 +1287,15 @@ vpu_reset: vpu-reset@38320000 {
 			#reset-cells = <1>;
 		};
 
-		vpu: video-codec@38300000 {
+		vpu_g1: video-codec@38300000 {
 			compatible = "nxp,imx8mq-vpu";
-			reg = <0x38300000 0x10000>,
-			      <0x38310000 0x10000>;
-			reg-names = "g1", "g2";
-			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>,
-				     <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
-			interrupt-names = "g1", "g2";
+			reg = <0x38300000 0x10000>;
+			reg-names = "g1";
+			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "g1";
 			clocks = <&clk IMX8MQ_CLK_VPU_G1_ROOT>,
-				 <&clk IMX8MQ_CLK_VPU_G2_ROOT>;
-			clock-names = "g1", "g2";
+				 <&clk IMX8MQ_CLK_VPU_DEC_ROOT>;
+			clock-names = "g1", "bus";
 			assigned-clocks = <&clk IMX8MQ_CLK_VPU_G1>,
 					  <&clk IMX8MQ_CLK_VPU_G2>,
 					  <&clk IMX8MQ_CLK_VPU_BUS>,
@@ -1306,12 +1304,35 @@ vpu: video-codec@38300000 {
 						 <&clk IMX8MQ_VPU_PLL_OUT>,
 						 <&clk IMX8MQ_SYS1_PLL_800M>,
 						 <&clk IMX8MQ_VPU_PLL>;
-			assigned-clock-rates = <600000000>, <600000000>,
+			assigned-clock-rates = <600000000>, <300000000>,
 					       <800000000>, <0>;
 			resets = <&vpu_reset IMX8MQ_RESET_VPU_RESET_G1>;
 			power-domains = <&pgc_vpu>;
 		};
 
+		vpu_g2: video-codec@38310000 {
+			compatible = "nxp,imx8mq-vpu-g2";
+			reg = <0x38310000 0x10000>;
+			reg-names = "g2";
+			interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "g2";
+			clocks = <&clk IMX8MQ_CLK_VPU_G2_ROOT>,
+				 <&clk IMX8MQ_CLK_VPU_DEC_ROOT>;
+			clock-names = "g2",  "bus";
+			assigned-clocks = <&clk IMX8MQ_CLK_VPU_G1>,
+					  <&clk IMX8MQ_CLK_VPU_G2>,
+					  <&clk IMX8MQ_CLK_VPU_BUS>,
+					  <&clk IMX8MQ_VPU_PLL_BYPASS>;
+			assigned-clock-parents = <&clk IMX8MQ_VPU_PLL_OUT>,
+						 <&clk IMX8MQ_VPU_PLL_OUT>,
+						 <&clk IMX8MQ_SYS1_PLL_800M>,
+						 <&clk IMX8MQ_VPU_PLL>;
+			assigned-clock-rates = <600000000>, <300000000>,
+					       <800000000>, <0>;
+			resets = <&vpu_reset IMX8MQ_RESET_VPU_RESET_G2>;
+			power-domains = <&pgc_vpu>;
+		};
+
 		pcie0: pcie@33800000 {
 			compatible = "fsl,imx8mq-pcie";
 			reg = <0x33800000 0x400000>,
Signature · 7 lines
2.25.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip