Skip to contentSkip to conversation

media: iris: HFI gen2 features and fixes for VA-API

PATCH In review Xilin Wu 2 participants 9 messages Nov 27

Subsystems (4)
lore
Share & tools
lore

Xilin Wu

author
#0 lore raw

v2 cover media: iris: HFI gen2 features and fixes for VA-API

This series adds features and fixes to Iris HFI gen2 to support qcom-va-driver [1], a userspace VA-API backend for the V4L2 stateful codec interface.

It enables decode-order output and larger CAPTURE buffer pools for VA-API clients, and exposes encoder deblocking controls. It also fixes error-buffer timestamps and handling of non-display AV1 and VP9 pictures, which affect both VA-API and direct V4L2 clients.

[1] https://github.com/radxa-pkg/qcom-va-driver

Fluster results on SC8280XP (Radxa Dragon Q8B) with the HFI gen2 firmware (video-firmware.2.4.2) and the GStreamer 1.28.9 V4L2 decoders, on a v7.3.6 based tree carrying this series, with and without patch 5:

  Test suite        Decoder               without 5/5  with 5/5
  VP9-TEST-VECTORS  GStreamer-VP9-V4L2        201/305   232/305
  JVT-AVC_V1        GStreamer-H.264-V4L2       77/135    77/135
  JCT-VC-HEVC_V1    GStreamer-H.265-V4L2      141/147   142/147

Patch 5 fixes these 30 VP9 vectors, with no regressions:

vp90-2-02-size-lf-1920x1080
vp90-2-07-frame_parallel
vp90-2-08-tile_1x2, vp90-2-08-tile_1x2_frame_parallel vp90-2-08-tile_1x4, vp90-2-08-tile_1x4_frame_parallel vp90-2-09-aq2, vp90-2-09-lf_deltas vp90-2-10-show-existing-frame, vp90-2-10-show-existing-frame2 vp90-2-11-size-351x287, vp90-2-11-size-351x288, vp90-2-11-size-352x287 vp90-2-14-resize-10frames-fp-tiles-* (all 14) vp90-2-15-segkey_adpq
vp90-2-20-big_superframe-01, vp90-2-20-big_superframe-02

The HEVC difference is PS_B_VIDYO_3 timing out once in the run without patch 5; it is not related to this change. AV1 was not tested, as the SC8280XP VPU does not decode AV1.

---
Changes in v2:
- Patch 1: move the new caps entries and switch cases to the end, to
match the enum order (Vishnu)
- Patch 1: describe the controls as feature parity with Venus
(Nicolas)
- Patch 2: add OUTPUT_BUF_HOST_MAX_COUNT to the HFI gen2 decoder caps
and size the CAPTURE queue from it, instead of checking the
firmware data (Nicolas). Dropped the Tested-by, as the
implementation changed
- Collect tags
- Rebase on next-20261126
- Link to v1: https://patch.msgid.link/[email protected]

To: Vikash Garodia <[email protected]>
To: Dikshita Agarwal <[email protected]>
To: Abhinav Kumar <[email protected]>
To: Bryan O'Donoghue <[email protected]>
To: Mauro Carvalho Chehab <[email protected]>
To: Hans Verkuil <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Bryan O'Donoghue <[email protected]>

---
Xilin Wu (5):
media: iris: support decode-order output on HFI gen2
media: iris: allow larger capture buffer pools on HFI gen2
media: iris: Add deblocking filter controls for HFI gen2
media: iris: Preserve timestamps on error buffers
media: iris: Recycle decoder buffers for non-display pictures

 drivers/media/platform/qcom/iris/iris_buffer.c     |   3 +-
 drivers/media/platform/qcom/iris/iris_ctrls.c      |  93 ++++++++++++
 drivers/media/platform/qcom/iris/iris_ctrls.h      |   1 +
 drivers/media/platform/qcom/iris/iris_hfi_gen2.c   | 166 +++++++++++++++++++++
 drivers/media/platform/qcom/iris/iris_hfi_gen2.h   |   2 +
 .../platform/qcom/iris/iris_hfi_gen2_command.c     |  29 +++-
 .../platform/qcom/iris/iris_hfi_gen2_defines.h     |   9 ++
 .../platform/qcom/iris/iris_hfi_gen2_response.c    |  47 +++++-
 .../platform/qcom/iris/iris_platform_common.h      |   8 +
 drivers/media/platform/qcom/iris/iris_vidc.c       |   8 +
 10 files changed, 360 insertions(+), 6 deletions(-)

---
base-commit: a9c48428cbd8d96b26f92631d0db6f8519c5fcc5
change-id: 20261029-iris-va-fixes-818e0067aa28

Best regards,

Signature · 1 line
Xilin Wu <[email protected]>
author
#1 lore raw

PATCH v2 1/5 media: iris: support decode-order output on HFI gen2

Venus implements V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE and V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY, which let a client ask for decoded pictures in decode order instead of waiting for display reordering. Iris does not expose them on HFI gen2.

Add both controls for HFI gen2 decoders. Enabling the display delay with a delay of zero, the only supported value, selects decode-order output through HFI_PROP_DECODE_ORDER_OUTPUT. Display-order output stays the default.

---
 drivers/media/platform/qcom/iris/iris_ctrls.c        |  8 ++++++++
 drivers/media/platform/qcom/iris/iris_hfi_gen2.c     | 20 ++++++++++++++++++++
 .../media/platform/qcom/iris/iris_hfi_gen2_command.c | 18 ++++++++++++++++++
 .../media/platform/qcom/iris/iris_hfi_gen2_defines.h |  1 +
 .../media/platform/qcom/iris/iris_platform_common.h  |  2 ++
 5 files changed, 49 insertions(+)
drivers/media/platform/qcom/iris/iris_ctrls.c +8 -0
index 4f2633bbb49f..0b59fc79971c 100644
@@ -163,6 +163,10 @@ static enum platform_inst_fw_cap_type iris_get_cap_id(u32 id)
 		return SLICE_MAX_BYTES;
 	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB:
 		return SLICE_MAX_MB;
+	case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE:
+		return DISPLAY_DELAY_ENABLE;
+	case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY:
+		return DISPLAY_DELAY;
 	default:
 		return INST_FW_CAP_MAX;
 	}
@@ -314,6 +318,10 @@ static u32 iris_get_v4l2_id(enum platform_inst_fw_cap_type cap_id)
 		return V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
 	case SLICE_MAX_MB:
 		return V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
+	case DISPLAY_DELAY_ENABLE:
+		return V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE;
+	case DISPLAY_DELAY:
+		return V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY;
 	default:
 		return 0;
 	}
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +20 -0
index 79bbd06ef8d2..7a1204da17ca 100644
@@ -1106,6 +1106,22 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_dec[] = {
 		.flags = CAP_FLAG_INPUT_PORT,
 		.set = iris_set_u32,
 	},
+	{
+		.cap_id = DISPLAY_DELAY_ENABLE,
+		.min = 0,
+		.max = 1,
+		.step_or_mask = 1,
+		.value = 0,
+		.hfi_id = HFI_PROP_DECODE_ORDER_OUTPUT,
+		.flags = CAP_FLAG_INPUT_PORT,
+	},
+	{
+		.cap_id = DISPLAY_DELAY,
+		.min = 0,
+		.max = 0,
+		.step_or_mask = 1,
+		.value = 0,
+	},
 };
 
 static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = {
@@ -1818,6 +1834,7 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = {
 };
 
 static const u32 sm8550_vdec_input_config_params_default[] = {
+	HFI_PROP_DECODE_ORDER_OUTPUT,
 	HFI_PROP_BITSTREAM_RESOLUTION,
 	HFI_PROP_CROP_OFFSETS,
 	HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
@@ -1830,6 +1847,7 @@ static const u32 sm8550_vdec_input_config_params_default[] = {
 };
 
 static const u32 sm8550_vdec_input_config_param_hevc[] = {
+	HFI_PROP_DECODE_ORDER_OUTPUT,
 	HFI_PROP_BITSTREAM_RESOLUTION,
 	HFI_PROP_CROP_OFFSETS,
 	HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
@@ -1841,6 +1859,7 @@ static const u32 sm8550_vdec_input_config_param_hevc[] = {
 };
 
 static const u32 sm8550_vdec_input_config_param_vp9[] = {
+	HFI_PROP_DECODE_ORDER_OUTPUT,
 	HFI_PROP_BITSTREAM_RESOLUTION,
 	HFI_PROP_CROP_OFFSETS,
 	HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
@@ -1850,6 +1869,7 @@ static const u32 sm8550_vdec_input_config_param_vp9[] = {
 };
 
 static const u32 sm8550_vdec_input_config_param_av1[] = {
+	HFI_PROP_DECODE_ORDER_OUTPUT,
 	HFI_PROP_BITSTREAM_RESOLUTION,
 	HFI_PROP_CROP_OFFSETS,
 	HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c +18 -0
index 388a36ff2b07..a285e6fc8728 100644
@@ -665,6 +665,23 @@ static int iris_hfi_gen2_set_super_block(struct iris_inst *inst, u32 plane)
 						  sizeof(u32));
 }
 
+static int iris_hfi_gen2_set_decode_order_output(struct iris_inst *inst, u32 plane)
+{
+	struct platform_inst_fw_cap *cap = &inst->fw_caps[DISPLAY_DELAY_ENABLE];
+	u32 decode_order = cap->value;
+
+	/* Leave the firmware default unchanged unless userspace sets the control. */
+	if (!(cap->flags & CAP_FLAG_CLIENT_SET))
+		return 0;
+
+	return iris_hfi_gen2_session_set_property(inst,
+						  HFI_PROP_DECODE_ORDER_OUTPUT,
+						  HFI_HOST_FLAGS_NONE,
+						  HFI_PORT_BITSTREAM,
+						  HFI_PAYLOAD_U32,
+						  &decode_order, sizeof(decode_order));
+}
+
 static int iris_hfi_gen2_session_set_config_params(struct iris_inst *inst, u32 plane)
 {
 	const struct iris_firmware_data *fdata = inst->core->iris_firmware_data;
@@ -691,6 +708,7 @@ static int iris_hfi_gen2_session_set_config_params(struct iris_inst *inst, u32 p
 		{HFI_PROP_FRAME_RATE,                 iris_hfi_gen2_set_frame_rate             },
 		{HFI_PROP_AV1_FILM_GRAIN_PRESENT,     iris_hfi_gen2_set_film_grain             },
 		{HFI_PROP_AV1_SUPER_BLOCK_ENABLED,    iris_hfi_gen2_set_super_block            },
+		{HFI_PROP_DECODE_ORDER_OUTPUT,        iris_hfi_gen2_set_decode_order_output    },
 	};
 
 	if (inst->domain == DECODER) {
drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h +1 -0
index 2b8b057d35a9..e89ed4075526 100644
@@ -130,6 +130,7 @@ enum hfi_flip {
 
 #define HFI_PROP_FLIP				0x0300014c
 #define HFI_PROP_SIGNAL_COLOR_INFO		0x03000155
+#define HFI_PROP_DECODE_ORDER_OUTPUT		0x0300015b
 #define HFI_PROP_PICTURE_TYPE			0x03000162
 #define HFI_PROP_DEC_DEFAULT_HEADER		0x03000168
 #define HFI_PROP_DEC_START_FROM_RAP_FRAME	0x03000169
drivers/media/platform/qcom/iris/iris_platform_common.h +2 -0
index cddab9a9c375..aa8cd2e1b3f1 100644
@@ -211,6 +211,8 @@ enum platform_inst_fw_cap_type {
 	SLICE_MODE,
 	SLICE_MAX_BYTES,
 	SLICE_MAX_MB,
+	DISPLAY_DELAY_ENABLE,
+	DISPLAY_DELAY,
 	INST_FW_CAP_MAX,
 };
 
Signature · 1 line
2.56.1
maintainer
#2 lore raw

Re: [PATCH v2 1/5] media: iris: support decode-order output on HFI gen2

drivers/media/platform/qcom/iris/iris_hfi_gen2.c static const struct platform_inst_fw_cap inst_fw_cap_sm8550_dec[] = {

Quoted 52 lines · Xilin Wu

Venus implements V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE and V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY, which let a client ask for decoded pictures in decode order instead of waiting for display reordering. Iris does not expose them on HFI gen2.

Add both controls for HFI gen2 decoders. Enabling the display delay with a delay of zero, the only supported value, selects decode-order output through HFI_PROP_DECODE_ORDER_OUTPUT. Display-order output stays the default.

---
  drivers/media/platform/qcom/iris/iris_ctrls.c        |  8 ++++++++
  drivers/media/platform/qcom/iris/iris_hfi_gen2.c     | 20 ++++++++++++++++++++
  .../media/platform/qcom/iris/iris_hfi_gen2_command.c | 18 ++++++++++++++++++
  .../media/platform/qcom/iris/iris_hfi_gen2_defines.h |  1 +
  .../media/platform/qcom/iris/iris_platform_common.h  |  2 ++
  5 files changed, 49 insertions(+)
drivers/media/platform/qcom/iris/iris_ctrls.c +8 -0
index 4f2633bbb49f..0b59fc79971c 100644
@@ -163,6 +163,10 @@ static enum platform_inst_fw_cap_type iris_get_cap_id(u32 id)
  		return SLICE_MAX_BYTES;
  	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB:
  		return SLICE_MAX_MB;
+	case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE:
+		return DISPLAY_DELAY_ENABLE;
+	case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY:
+		return DISPLAY_DELAY;
  	default:
  		return INST_FW_CAP_MAX;
  	}
@@ -314,6 +318,10 @@ static u32 iris_get_v4l2_id(enum platform_inst_fw_cap_type cap_id)
  		return V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
  	case SLICE_MAX_MB:
  		return V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
+	case DISPLAY_DELAY_ENABLE:
+		return V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE;
+	case DISPLAY_DELAY:
+		return V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY;
  	default:
  		return 0;
  	}
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +0 -0
index 79bbd06ef8d2..7a1204da17ca 100644
@@ -1106,6 +1106,22 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_dec[] = {

Take care for adding other platforms too

Quoted 23 lines
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +16 -0
  		.flags = CAP_FLAG_INPUT_PORT,
  		.set = iris_set_u32,
  	},
+	{
+		.cap_id = DISPLAY_DELAY_ENABLE,
+		.min = 0,
+		.max = 1,
+		.step_or_mask = 1,
+		.value = 0,
+		.hfi_id = HFI_PROP_DECODE_ORDER_OUTPUT,
+		.flags = CAP_FLAG_INPUT_PORT,
+	},
+	{
+		.cap_id = DISPLAY_DELAY,
+		.min = 0,
+		.max = 0,
+		.step_or_mask = 1,
+		.value = 0,
+	},
  };
 
  static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = {

drivers/media/platform/qcom/iris/iris_hfi_gen2.c static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = { · line 1837

Quoted 4 lines
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +1 -0
@@ -1818,6 +1834,7 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = {
  };
 
  static const u32 sm8550_vdec_input_config_params_default[] = {
+	HFI_PROP_DECODE_ORDER_OUTPUT,

No need to add them under these array, which gets picked as subscription "iris_hfi_gen2_subscribe_change_param" property by driver to firmware.

Please use .set callback to set these parameters.

Regards,
Vikash

author
#3 lore raw

PATCH v2 2/5 media: iris: allow larger capture buffer pools on HFI gen2

In reply to Xilin Wu

vb2 limits a queue to 32 buffers unless the driver sets max_num_buffers. Clients with deep decode pipelines, such as VLC with frame threading, can need more CAPTURE buffers than that.

HFI gen2 firmware takes the number of host buffers for each port through HFI_PROP_BUFFER_HOST_MAX_COUNT. The encoder caps set it for both ports, while the decoder caps only set it for the bitstream port.

Add OUTPUT_BUF_HOST_MAX_COUNT to the HFI gen2 decoder caps, and size the CAPTURE queue from that capability when the platform provides it. Platforms without it, such as HFI gen1, keep the vb2 default.

---
 drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 30 ++++++++++++++++++++++++
 drivers/media/platform/qcom/iris/iris_vidc.c     |  8 +++++++
 2 files changed, 38 insertions(+)
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +30 -0
index 7a1204da17ca..90cba1ae534b 100644
@@ -137,6 +137,16 @@ static const struct platform_inst_fw_cap inst_fw_cap_milos_dec[] = {
 		.flags = CAP_FLAG_INPUT_PORT,
 		.set = iris_set_u32,
 	},
+	{
+		.cap_id = OUTPUT_BUF_HOST_MAX_COUNT,
+		.min = DEFAULT_MAX_HOST_BUF_COUNT,
+		.max = DEFAULT_MAX_HOST_BURST_BUF_COUNT,
+		.step_or_mask = 1,
+		.value = DEFAULT_MAX_HOST_BUF_COUNT,
+		.hfi_id = HFI_PROP_BUFFER_HOST_MAX_COUNT,
+		.flags = CAP_FLAG_OUTPUT_PORT,
+		.set = iris_set_u32,
+	},
 	{
 		.cap_id = STAGE,
 		.min = STAGE_1,
@@ -1056,6 +1066,16 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_dec[] = {
 		.flags = CAP_FLAG_INPUT_PORT,
 		.set = iris_set_u32,
 	},
+	{
+		.cap_id = OUTPUT_BUF_HOST_MAX_COUNT,
+		.min = DEFAULT_MAX_HOST_BUF_COUNT,
+		.max = DEFAULT_MAX_HOST_BURST_BUF_COUNT,
+		.step_or_mask = 1,
+		.value = DEFAULT_MAX_HOST_BUF_COUNT,
+		.hfi_id = HFI_PROP_BUFFER_HOST_MAX_COUNT,
+		.flags = CAP_FLAG_OUTPUT_PORT,
+		.set = iris_set_u32,
+	},
 	{
 		.cap_id = STAGE,
 		.min = STAGE_1,
@@ -2188,6 +2208,16 @@ static const struct platform_inst_fw_cap inst_fw_cap_gen2_ar50lt_dec[] = {
 		.flags = CAP_FLAG_INPUT_PORT,
 		.set = iris_set_u32,
 	},
+	{
+		.cap_id = OUTPUT_BUF_HOST_MAX_COUNT,
+		.min = DEFAULT_MAX_HOST_BUF_COUNT,
+		.max = DEFAULT_MAX_HOST_BURST_BUF_COUNT,
+		.step_or_mask = 1,
+		.value = DEFAULT_MAX_HOST_BUF_COUNT,
+		.hfi_id = HFI_PROP_BUFFER_HOST_MAX_COUNT,
+		.flags = CAP_FLAG_OUTPUT_PORT,
+		.set = iris_set_u32,
+	},
 	{
 		.cap_id = STAGE,
 		.min = STAGE_1,
drivers/media/platform/qcom/iris/iris_vidc.c +8 -0
index 05aab6e3005d..4a2cb965a824 100644
@@ -116,8 +116,14 @@ static int
 iris_m2m_queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq)
 {
 	struct iris_inst *inst = priv;
+	struct iris_core *core = inst->core;
+	const struct platform_inst_fw_cap *caps;
 	int ret;
 
+	/* inst->fw_caps is set up later, in iris_vdec/venc_inst_init(). */
+	caps = inst->domain == DECODER ? core->inst_fw_caps_dec :
+					 core->inst_fw_caps_enc;
+
 	src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
 	src_vq->io_modes = VB2_MMAP | VB2_DMABUF;
 	src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
@@ -140,6 +146,8 @@ iris_m2m_queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_
 	dst_vq->drv_priv = inst;
 	dst_vq->buf_struct_size = sizeof(struct iris_buffer);
 	dst_vq->min_reqbufs_allocation = MIN_BUFFERS;
+	if (caps[OUTPUT_BUF_HOST_MAX_COUNT].cap_id)
+		dst_vq->max_num_buffers = caps[OUTPUT_BUF_HOST_MAX_COUNT].value;
 	dst_vq->dev = inst->core->dev;
 	dst_vq->lock = &inst->ctx_q_lock;
 
Signature · 1 line
2.56.1
maintainer Reviewed-by on v2 2/5
#4 lore raw

Re: [PATCH v2 2/5] media: iris: allow larger capture buffer pools on HFI gen2

Quoted 12 lines · Xilin Wu

vb2 limits a queue to 32 buffers unless the driver sets max_num_buffers. Clients with deep decode pipelines, such as VLC with frame threading, can need more CAPTURE buffers than that.

HFI gen2 firmware takes the number of host buffers for each port through HFI_PROP_BUFFER_HOST_MAX_COUNT. The encoder caps set it for both ports, while the decoder caps only set it for the bitstream port.

Add OUTPUT_BUF_HOST_MAX_COUNT to the HFI gen2 decoder caps, and size the CAPTURE queue from that capability when the platform provides it. Platforms without it, such as HFI gen1, keep the vb2 default.

Quoted 5 lines
---
  drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 30 ++++++++++++++++++++++++
  drivers/media/platform/qcom/iris/iris_vidc.c     |  8 +++++++
  2 files changed, 38 insertions(+)
author
#5 lore raw

PATCH v2 3/5 media: iris: Add deblocking filter controls for HFI gen2

In reply to Xilin Wu

HFI gen2 encoders do not expose deblocking filter controls, preventing applications from configuring the filter mode and offsets.

Add the standard V4L2 H.264 and HEVC loop filter controls.

---
 drivers/media/platform/qcom/iris/iris_ctrls.c      |  85 +++++++++++++++
 drivers/media/platform/qcom/iris/iris_ctrls.h      |   1 +
 drivers/media/platform/qcom/iris/iris_hfi_gen2.c   | 116 +++++++++++++++++++++
 .../platform/qcom/iris/iris_hfi_gen2_defines.h     |   8 ++
 .../platform/qcom/iris/iris_platform_common.h      |   6 ++
 5 files changed, 216 insertions(+)
drivers/media/platform/qcom/iris/iris_ctrls.c +85 -0
index 0b59fc79971c..aa98499b48c0 100644
@@ -55,6 +55,18 @@ static enum platform_inst_fw_cap_type iris_get_cap_id(u32 id)
 		return GOP_SIZE;
 	case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE:
 		return ENTROPY_MODE;
+	case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE:
+		return DEBLOCK_MODE_H264;
+	case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA:
+		return DEBLOCK_ALPHA_H264;
+	case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA:
+		return DEBLOCK_BETA_H264;
+	case V4L2_CID_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE:
+		return DEBLOCK_MODE_HEVC;
+	case V4L2_CID_MPEG_VIDEO_HEVC_LF_TC_OFFSET_DIV2:
+		return DEBLOCK_TC_HEVC;
+	case V4L2_CID_MPEG_VIDEO_HEVC_LF_BETA_OFFSET_DIV2:
+		return DEBLOCK_BETA_HEVC;
 	case V4L2_CID_MPEG_VIDEO_H264_MIN_QP:
 		return MIN_FRAME_QP_H264;
 	case V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP:
@@ -210,6 +222,18 @@ static u32 iris_get_v4l2_id(enum platform_inst_fw_cap_type cap_id)
 		return V4L2_CID_MPEG_VIDEO_GOP_SIZE;
 	case ENTROPY_MODE:
 		return V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE;
+	case DEBLOCK_MODE_H264:
+		return V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE;
+	case DEBLOCK_ALPHA_H264:
+		return V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA;
+	case DEBLOCK_BETA_H264:
+		return V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA;
+	case DEBLOCK_MODE_HEVC:
+		return V4L2_CID_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE;
+	case DEBLOCK_TC_HEVC:
+		return V4L2_CID_MPEG_VIDEO_HEVC_LF_TC_OFFSET_DIV2;
+	case DEBLOCK_BETA_HEVC:
+		return V4L2_CID_MPEG_VIDEO_HEVC_LF_BETA_OFFSET_DIV2;
 	case MIN_FRAME_QP_H264:
 		return V4L2_CID_MPEG_VIDEO_H264_MIN_QP;
 	case MIN_FRAME_QP_HEVC:
@@ -884,6 +908,67 @@ int iris_set_entropy_mode_gen2(struct iris_inst *inst, enum platform_inst_fw_cap
 				     &entropy_mode, sizeof(u32));
 }
 
+int iris_set_deblock_gen2(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id)
+{
+	const struct iris_hfi_session_ops *hfi_ops = inst->hfi_session_ops;
+	u32 hfi_id = inst->fw_caps[cap_id].hfi_id;
+	u32 mode = inst->fw_caps[cap_id].value;
+	u32 alpha_tc, beta, hfi_value;
+
+	if (inst->codec == V4L2_PIX_FMT_H264) {
+		if (cap_id != DEBLOCK_MODE_H264)
+			return 0;
+
+		switch (mode) {
+		case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED:
+			mode = HFI_DEBLOCK_ALL_BOUNDARY;
+			break;
+		case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED:
+			mode = HFI_DEBLOCK_DISABLE;
+			break;
+		case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY:
+			mode = HFI_DEBLOCK_DISABLE_AT_SLICE_BOUNDARY;
+			break;
+		default:
+			return -EINVAL;
+		}
+
+		alpha_tc = inst->fw_caps[DEBLOCK_ALPHA_H264].value + 6;
+		beta = inst->fw_caps[DEBLOCK_BETA_H264].value + 6;
+	} else if (inst->codec == V4L2_PIX_FMT_HEVC) {
+		if (cap_id != DEBLOCK_MODE_HEVC)
+			return 0;
+
+		switch (mode) {
+		case V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_ENABLED:
+			mode = HFI_DEBLOCK_ALL_BOUNDARY;
+			break;
+		case V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_DISABLED:
+			mode = HFI_DEBLOCK_DISABLE;
+			break;
+		case V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY:
+			mode = HFI_DEBLOCK_DISABLE_AT_SLICE_BOUNDARY;
+			break;
+		default:
+			return -EINVAL;
+		}
+
+		alpha_tc = inst->fw_caps[DEBLOCK_TC_HEVC].value + 6;
+		beta = inst->fw_caps[DEBLOCK_BETA_HEVC].value + 6;
+	} else {
+		return 0;
+	}
+
+	/* Firmware expects offsets biased by 6, with alpha or HEVC tc in bits 23:16. */
+	hfi_value = alpha_tc << 16 | beta << 8 | mode;
+
+	return hfi_ops->session_set_property(inst, hfi_id,
+					     HFI_HOST_FLAGS_NONE,
+					     iris_get_port_info(inst, cap_id),
+					     HFI_PAYLOAD_32_PACKED,
+					     &hfi_value, sizeof(hfi_value));
+}
+
 int iris_set_min_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id)
 {
 	const struct iris_hfi_session_ops *hfi_ops = inst->hfi_session_ops;
drivers/media/platform/qcom/iris/iris_ctrls.h +1 -0
index 08db80744420..82437f4e19c1 100644
@@ -29,6 +29,7 @@ int iris_set_bitrate_mode_gen1(struct iris_inst *inst, enum platform_inst_fw_cap
 int iris_set_bitrate_mode_gen2(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
 int iris_set_entropy_mode_gen1(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
 int iris_set_entropy_mode_gen2(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
+int iris_set_deblock_gen2(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
 int iris_set_min_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
 int iris_set_max_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
 int iris_set_frame_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +116 -0

128 lines not on this page · raw message

drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h +8 -0
index e89ed4075526..04e5429328eb 100644
@@ -57,6 +57,14 @@
 #define HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT	0x03000124
 #define HFI_PROP_PIC_ORDER_CNT_TYPE		0x03000128
 
+enum hfi_deblock_mode {
+	HFI_DEBLOCK_ALL_BOUNDARY			= 0x0,
+	HFI_DEBLOCK_DISABLE			= 0x1,
+	HFI_DEBLOCK_DISABLE_AT_SLICE_BOUNDARY	= 0x2,
+};
+
+#define HFI_PROP_DEBLOCKING_MODE			0x03000129
+
 enum hfi_rate_control {
 	HFI_RC_VBR_CFR		= 0x00000000,
 	HFI_RC_CBR_CFR		= 0x00000001,
drivers/media/platform/qcom/iris/iris_platform_common.h +6 -0
index aa8cd2e1b3f1..75e56d10f5d0 100644
@@ -158,6 +158,12 @@ enum platform_inst_fw_cap_type {
 	FRAME_RC_ENABLE,
 	GOP_SIZE,
 	ENTROPY_MODE,
+	DEBLOCK_MODE_H264,
+	DEBLOCK_ALPHA_H264,
+	DEBLOCK_BETA_H264,
+	DEBLOCK_MODE_HEVC,
+	DEBLOCK_TC_HEVC,
+	DEBLOCK_BETA_HEVC,
 	MIN_FRAME_QP_H264,
 	MIN_FRAME_QP_HEVC,
 	MAX_FRAME_QP_H264,
Signature · 1 line
2.56.1
author
#6 lore raw

PATCH v2 4/5 media: iris: Preserve timestamps on error buffers

In reply to Xilin Wu

Clearing timestamps on error buffers prevents clients such as libva-v4l2 from identifying the failed picture and can cause synchronization timeouts.

Preserve the firmware-provided timestamp when returning an error buffer.

Fixes b791dcfcba3a ("media: iris: Add handling for corrupt and drop frames")
---
 drivers/media/platform/qcom/iris/iris_buffer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_buffer.c +2 -1
index eb8de60c1177..f790483d13d4 100644
@@ -899,7 +899,8 @@ int iris_vb2_buffer_done(struct iris_inst *inst, struct iris_buffer *buf)
 	if (buf->flags & V4L2_BUF_FLAG_ERROR) {
 		state = VB2_BUF_STATE_ERROR;
 		vb2_set_plane_payload(vb2, 0, 0);
-		vb2->timestamp = 0;
+		/* Allow userspace to associate the error with the input frame. */
+		vb2->timestamp = buf->timestamp;
 		v4l2_m2m_buf_done(vbuf, state);
 		return 0;
 	}
Signature · 1 line
2.56.1
maintainer Reviewed-by on v2 4/5
#7 lore raw

Re: [PATCH v2 4/5] media: iris: Preserve timestamps on error buffers

Quoted 5 lines · Xilin Wu

Clearing timestamps on error buffers prevents clients such as libva-v4l2 from identifying the failed picture and can cause synchronization timeouts.

Preserve the firmware-provided timestamp when returning an error buffer.

Quoted 8 lines
Fixes b791dcfcba3a ("media: iris: Add handling for corrupt and drop frames")
---
  drivers/media/platform/qcom/iris/iris_buffer.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
author
#8 lore raw

PATCH v2 5/5 media: iris: Recycle decoder buffers for non-display pictures

In reply to Xilin Wu

HFI gen2 reports non-display pictures with HFI_GEN2_PICTURE_NOSHOW, but Iris returns them as errors. For AV1, hidden and displayed pictures can share a timestamp, so GStreamer's v4l2av1dec drops the pending frame and loses the displayed picture.

Recycle successful non-display buffers within the driver instead of returning them to userspace as errors. This also fixes VP9 streams using hidden alt-ref frames.

Fixes ac72ad9deafa ("media: iris: Add handling for no show frames")
---
 drivers/media/platform/qcom/iris/iris_hfi_gen2.h   |  2 +
 .../platform/qcom/iris/iris_hfi_gen2_command.c     | 11 ++++-
 .../platform/qcom/iris/iris_hfi_gen2_response.c    | 47 ++++++++++++++++++++--
 3 files changed, 55 insertions(+), 5 deletions(-)
drivers/media/platform/qcom/iris/iris_hfi_gen2.h +2 -0
index 21ab58e0aa84..79aac2d4e500 100644
@@ -20,6 +20,7 @@ struct iris_core;
  * @packet: HFI packet
  * @ipsc_properties_set: boolean to set ipsc properties to fw
  * @opsc_properties_set: boolean to set opsc properties to fw
+ * @output_stopping: capture STOP command is awaiting its response
  * @hfi_frame_info: structure of frame info
  * @src_subcr_params: subscription params to fw on input port
  * @dst_subcr_params: subscription params to fw on output port
@@ -29,6 +30,7 @@ struct iris_inst_hfi_gen2 {
 	struct iris_hfi_header		*packet;
 	bool				ipsc_properties_set;
 	bool				opsc_properties_set;
+	bool				output_stopping;
 	struct iris_hfi_frame_info	hfi_frame_info;
 	struct hfi_subscription_params	src_subcr_params;
 	struct hfi_subscription_params	dst_subcr_params;
drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c +10 -1
index a285e6fc8728..77ea153bf2d7 100644
@@ -1172,7 +1172,16 @@ static int iris_hfi_gen2_session_stop(struct iris_inst *inst, u32 plane)
 	if (ret)
 		return ret;
 
-	return iris_wait_for_session_response(inst, false);
+	/* The response wait drops inst->lock, allowing buffers to be returned. */
+	if (plane == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+		inst_hfi_gen2->output_stopping = true;
+
+	ret = iris_wait_for_session_response(inst, false);
+
+	if (plane == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+		inst_hfi_gen2->output_stopping = false;
+
+	return ret;
 }
 
 static int iris_hfi_gen2_session_pause(struct iris_inst *inst, u32 plane)
drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c +43 -4

69 lines not on this page · raw message

Signature · 1 line
2.56.1