mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API
@ 2026-10-29  3:58 ` Xilin Wu
  2026-10-29  3:58   ` [PATCH 1/5] media: iris: support decode-order output on HFI gen2 Xilin Wu
                     ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Xilin Wu @ 2026-10-29  3:58 UTC (permalink / raw)
  To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
	dragon, Chris Obbard, Deepak Sikri, Dmitry Baryshkov,
	Loic Minier, Jason Pettit, Xilin Wu

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

Signed-off-by: Xilin Wu <sophon@radxa.com>
---
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   | 136 +++++++++++++++++++++
 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       |   3 +
 10 files changed, 325 insertions(+), 6 deletions(-)
---
base-commit: 151a134a4e6ec66f69db8750c66006f5207f7a9d
change-id: 20261029-iris-va-fixes-818e0067aa28

Best regards,
--  
Xilin Wu <sophon@radxa.com>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/5] media: iris: support decode-order output on HFI gen2
  2026-10-29  3:58 ` [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API Xilin Wu
@ 2026-10-29  3:58   ` Xilin Wu
  2026-11-03 22:18     ` Nicolas Dufresne
  2026-10-29  3:58   ` [PATCH 2/5] media: iris: allow larger capture buffer pools " Xilin Wu
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Xilin Wu @ 2026-10-29  3:58 UTC (permalink / raw)
  To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
	dragon, Chris Obbard, Deepak Sikri, Dmitry Baryshkov,
	Loic Minier, Jason Pettit, Xilin Wu

Synchronous per-picture clients such as VA-API can stall when firmware
holds decoded pictures for display reordering while the client waits for
the current picture before submitting more input.

Expose the decoder display-delay controls on HFI gen2, with a zero delay
selecting decode-order output. Keep display-order output as the default.

Signed-off-by: Xilin Wu <sophon@radxa.com>
---
 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(+)

diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.c b/drivers/media/platform/qcom/iris/iris_ctrls.c
index 4f2633bbb49f..1dbea37c93c3 100644
--- a/drivers/media/platform/qcom/iris/iris_ctrls.c
+++ b/drivers/media/platform/qcom/iris/iris_ctrls.c
@@ -155,6 +155,10 @@ static enum platform_inst_fw_cap_type iris_get_cap_id(u32 id)
 		return LAYER4_BITRATE_HEVC;
 	case V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_BR:
 		return LAYER5_BITRATE_HEVC;
+	case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE:
+		return DISPLAY_DELAY_ENABLE;
+	case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY:
+		return DISPLAY_DELAY;
 	case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:
 		return REQUEST_SYNC_FRAME;
 	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE:
@@ -306,6 +310,10 @@ static u32 iris_get_v4l2_id(enum platform_inst_fw_cap_type cap_id)
 		return V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L4_BR;
 	case LAYER5_BITRATE_HEVC:
 		return V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_BR;
+	case DISPLAY_DELAY_ENABLE:
+		return V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE;
+	case DISPLAY_DELAY:
+		return V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY;
 	case REQUEST_SYNC_FRAME:
 		return V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME;
 	case SLICE_MODE:
diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2.c
index 79bbd06ef8d2..65af61b63a29 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen2.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2.c
@@ -842,6 +842,22 @@ static const struct platform_inst_fw_cap inst_fw_cap_milos_enc[] = {
 };
 
 static const struct platform_inst_fw_cap inst_fw_cap_sm8550_dec[] = {
+	{
+		.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,
+	},
 	{
 		.cap_id = PROFILE_H264,
 		.min = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE,
@@ -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,
diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
index 388a36ff2b07..a285e6fc8728 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
@@ -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) {
diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h b/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h
index 2b8b057d35a9..e89ed4075526 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h
@@ -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
diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/drivers/media/platform/qcom/iris/iris_platform_common.h
index cddab9a9c375..aa8cd2e1b3f1 100644
--- a/drivers/media/platform/qcom/iris/iris_platform_common.h
+++ b/drivers/media/platform/qcom/iris/iris_platform_common.h
@@ -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,
 };
 

-- 
2.56.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/5] media: iris: allow larger capture buffer pools on HFI gen2
  2026-10-29  3:58 ` [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API Xilin Wu
  2026-10-29  3:58   ` [PATCH 1/5] media: iris: support decode-order output on HFI gen2 Xilin Wu
@ 2026-10-29  3:58   ` Xilin Wu
  2026-11-03 22:20     ` Nicolas Dufresne
  2026-10-29  3:58   ` [PATCH 3/5] media: iris: Add deblocking filter controls for " Xilin Wu
                     ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Xilin Wu @ 2026-10-29  3:58 UTC (permalink / raw)
  To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
	dragon, Chris Obbard, Deepak Sikri, Dmitry Baryshkov,
	Loic Minier, Jason Pettit, Xilin Wu

VLC with VA-API frame threading can require more than the default vb2
limit of 32 CAPTURE buffers.

Raise the HFI gen2 decoder CAPTURE queue limit to 64 buffers.

Signed-off-by: Xilin Wu <sophon@radxa.com>
---
 drivers/media/platform/qcom/iris/iris_vidc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
index 05aab6e3005d..8c96b007b391 100644
--- a/drivers/media/platform/qcom/iris/iris_vidc.c
+++ b/drivers/media/platform/qcom/iris/iris_vidc.c
@@ -140,6 +140,9 @@ 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 (inst->domain == DECODER &&
+	    inst->core->iris_firmware_data == &iris_hfi_gen2_data)
+		dst_vq->max_num_buffers = DEFAULT_MAX_HOST_BUF_COUNT;
 	dst_vq->dev = inst->core->dev;
 	dst_vq->lock = &inst->ctx_q_lock;
 

-- 
2.56.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 3/5] media: iris: Add deblocking filter controls for HFI gen2
  2026-10-29  3:58 ` [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API Xilin Wu
  2026-10-29  3:58   ` [PATCH 1/5] media: iris: support decode-order output on HFI gen2 Xilin Wu
  2026-10-29  3:58   ` [PATCH 2/5] media: iris: allow larger capture buffer pools " Xilin Wu
@ 2026-10-29  3:58   ` Xilin Wu
  2026-10-29  3:58   ` [PATCH 4/5] media: iris: Preserve timestamps on error buffers Xilin Wu
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Xilin Wu @ 2026-10-29  3:58 UTC (permalink / raw)
  To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
	dragon, Chris Obbard, Deepak Sikri, Dmitry Baryshkov,
	Loic Minier, Jason Pettit, 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.

Signed-off-by: Xilin Wu <sophon@radxa.com>
---
 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(+)

diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.c b/drivers/media/platform/qcom/iris/iris_ctrls.c
index 1dbea37c93c3..a9b8124aca56 100644
--- a/drivers/media/platform/qcom/iris/iris_ctrls.c
+++ b/drivers/media/platform/qcom/iris/iris_ctrls.c
@@ -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;
diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.h b/drivers/media/platform/qcom/iris/iris_ctrls.h
index 08db80744420..82437f4e19c1 100644
--- a/drivers/media/platform/qcom/iris/iris_ctrls.h
+++ b/drivers/media/platform/qcom/iris/iris_ctrls.h
@@ -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);
diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2.c
index 65af61b63a29..a271858fd06a 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen2.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2.c
@@ -357,6 +357,64 @@ static const struct platform_inst_fw_cap inst_fw_cap_milos_enc[] = {
 		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
 		.set = iris_set_entropy_mode_gen2,
 	},
+	{
+		.cap_id = DEBLOCK_MODE_H264,
+		.min = V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED,
+		.max = V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY,
+		.step_or_mask =
+			BIT(V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED) |
+			BIT(V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED) |
+			BIT(V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY),
+		.value = V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED,
+		.hfi_id = HFI_PROP_DEBLOCKING_MODE,
+		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		.set = iris_set_deblock_gen2,
+	},
+	{
+		.cap_id = DEBLOCK_ALPHA_H264,
+		.min = -6,
+		.max = 6,
+		.step_or_mask = 1,
+		.value = 0,
+		.flags = CAP_FLAG_OUTPUT_PORT,
+	},
+	{
+		.cap_id = DEBLOCK_BETA_H264,
+		.min = -6,
+		.max = 6,
+		.step_or_mask = 1,
+		.value = 0,
+		.flags = CAP_FLAG_OUTPUT_PORT,
+	},
+	{
+		.cap_id = DEBLOCK_MODE_HEVC,
+		.min = V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_DISABLED,
+		.max = V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY,
+		.step_or_mask =
+			BIT(V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_ENABLED) |
+			BIT(V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_DISABLED) |
+			BIT(V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY),
+		.value = V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_ENABLED,
+		.hfi_id = HFI_PROP_DEBLOCKING_MODE,
+		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		.set = iris_set_deblock_gen2,
+	},
+	{
+		.cap_id = DEBLOCK_TC_HEVC,
+		.min = -6,
+		.max = 6,
+		.step_or_mask = 1,
+		.value = 0,
+		.flags = CAP_FLAG_OUTPUT_PORT,
+	},
+	{
+		.cap_id = DEBLOCK_BETA_HEVC,
+		.min = -6,
+		.max = 6,
+		.step_or_mask = 1,
+		.value = 0,
+		.flags = CAP_FLAG_OUTPUT_PORT,
+	},
 	{
 		.cap_id = MIN_FRAME_QP_H264,
 		.min = MIN_QP_8BIT,
@@ -1309,6 +1367,64 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = {
 		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
 		.set = iris_set_entropy_mode_gen2,
 	},
+	{
+		.cap_id = DEBLOCK_MODE_H264,
+		.min = V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED,
+		.max = V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY,
+		.step_or_mask =
+			BIT(V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED) |
+			BIT(V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED) |
+			BIT(V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY),
+		.value = V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED,
+		.hfi_id = HFI_PROP_DEBLOCKING_MODE,
+		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		.set = iris_set_deblock_gen2,
+	},
+	{
+		.cap_id = DEBLOCK_ALPHA_H264,
+		.min = -6,
+		.max = 6,
+		.step_or_mask = 1,
+		.value = 0,
+		.flags = CAP_FLAG_OUTPUT_PORT,
+	},
+	{
+		.cap_id = DEBLOCK_BETA_H264,
+		.min = -6,
+		.max = 6,
+		.step_or_mask = 1,
+		.value = 0,
+		.flags = CAP_FLAG_OUTPUT_PORT,
+	},
+	{
+		.cap_id = DEBLOCK_MODE_HEVC,
+		.min = V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_DISABLED,
+		.max = V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY,
+		.step_or_mask =
+			BIT(V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_ENABLED) |
+			BIT(V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_DISABLED) |
+			BIT(V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY),
+		.value = V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_ENABLED,
+		.hfi_id = HFI_PROP_DEBLOCKING_MODE,
+		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		.set = iris_set_deblock_gen2,
+	},
+	{
+		.cap_id = DEBLOCK_TC_HEVC,
+		.min = -6,
+		.max = 6,
+		.step_or_mask = 1,
+		.value = 0,
+		.flags = CAP_FLAG_OUTPUT_PORT,
+	},
+	{
+		.cap_id = DEBLOCK_BETA_HEVC,
+		.min = -6,
+		.max = 6,
+		.step_or_mask = 1,
+		.value = 0,
+		.flags = CAP_FLAG_OUTPUT_PORT,
+	},
 	{
 		.cap_id = MIN_FRAME_QP_H264,
 		.min = MIN_QP_8BIT,
diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h b/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h
index e89ed4075526..04e5429328eb 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h
@@ -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,
diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/drivers/media/platform/qcom/iris/iris_platform_common.h
index aa8cd2e1b3f1..75e56d10f5d0 100644
--- a/drivers/media/platform/qcom/iris/iris_platform_common.h
+++ b/drivers/media/platform/qcom/iris/iris_platform_common.h
@@ -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,

-- 
2.56.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 4/5] media: iris: Preserve timestamps on error buffers
  2026-10-29  3:58 ` [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API Xilin Wu
                     ` (2 preceding siblings ...)
  2026-10-29  3:58   ` [PATCH 3/5] media: iris: Add deblocking filter controls for " Xilin Wu
@ 2026-10-29  3:58   ` Xilin Wu
  2026-11-03 21:57     ` Bryan O'Donoghue
  2026-10-29  3:58   ` [PATCH 5/5] media: iris: Recycle decoder buffers for non-display pictures Xilin Wu
  2026-11-03 22:00   ` [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API Bryan O'Donoghue
  5 siblings, 1 reply; 13+ messages in thread
From: Xilin Wu @ 2026-10-29  3:58 UTC (permalink / raw)
  To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
	dragon, Chris Obbard, Deepak Sikri, Dmitry Baryshkov,
	Loic Minier, Jason Pettit, 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")
Signed-off-by: Xilin Wu <sophon@radxa.com>
---
 drivers/media/platform/qcom/iris/iris_buffer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media/platform/qcom/iris/iris_buffer.c
index eb8de60c1177..f790483d13d4 100644
--- a/drivers/media/platform/qcom/iris/iris_buffer.c
+++ b/drivers/media/platform/qcom/iris/iris_buffer.c
@@ -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;
 	}

-- 
2.56.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 5/5] media: iris: Recycle decoder buffers for non-display pictures
  2026-10-29  3:58 ` [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API Xilin Wu
                     ` (3 preceding siblings ...)
  2026-10-29  3:58   ` [PATCH 4/5] media: iris: Preserve timestamps on error buffers Xilin Wu
@ 2026-10-29  3:58   ` Xilin Wu
  2026-11-03 22:25     ` Nicolas Dufresne
  2026-11-03 22:00   ` [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API Bryan O'Donoghue
  5 siblings, 1 reply; 13+ messages in thread
From: Xilin Wu @ 2026-10-29  3:58 UTC (permalink / raw)
  To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
	dragon, Chris Obbard, Deepak Sikri, Dmitry Baryshkov,
	Loic Minier, Jason Pettit, 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")
Signed-off-by: Xilin Wu <sophon@radxa.com>
---
 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(-)

diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2.h b/drivers/media/platform/qcom/iris/iris_hfi_gen2.h
index 21ab58e0aa84..79aac2d4e500 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen2.h
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2.h
@@ -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;
diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
index a285e6fc8728..77ea153bf2d7 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
@@ -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)
diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
index f0782c4b1e6e..a545410d1e8d 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
@@ -101,9 +101,7 @@ static int iris_hfi_gen2_get_driver_buffer_flags(struct iris_inst *inst, u32 hfi
 		HFI_GEN2_PICTURE_CRA | HFI_GEN2_PICTURE_BLA;
 	u32 driver_flags = 0;
 
-	if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_GEN2_PICTURE_NOSHOW)
-		driver_flags |= V4L2_BUF_FLAG_ERROR;
-	else if (inst_hfi_gen2->hfi_frame_info.picture_type & keyframe)
+	if (inst_hfi_gen2->hfi_frame_info.picture_type & keyframe)
 		driver_flags |= V4L2_BUF_FLAG_KEYFRAME;
 	else if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_GEN2_PICTURE_P)
 		driver_flags |= V4L2_BUF_FLAG_PFRAME;
@@ -345,9 +343,40 @@ static int iris_hfi_gen2_handle_input_buffer(struct iris_inst *inst,
 	return 0;
 }
 
+static int iris_hfi_gen2_requeue_output_buffer(struct iris_inst *inst,
+					       struct iris_buffer *buf)
+{
+	struct iris_inst_hfi_gen2 *inst_hfi_gen2 = to_iris_inst_hfi_gen2(inst);
+	u64 timestamp = buf->timestamp;
+	int ret;
+
+	buf->data_size = 0;
+	buf->timestamp = 0;
+	buf->flags = 0;
+	buf->attr &= ~BUF_ATTR_DEQUEUED;
+	buf->attr |= BUF_ATTR_DEFERRED;
+
+	/* Leave stopped buffers for streamoff cleanup or the next streamon. */
+	if (inst_hfi_gen2->output_stopping ||
+	    (inst->state != IRIS_INST_STREAMING &&
+	     inst->state != IRIS_INST_OUTPUT_STREAMING))
+		return 0;
+
+	ret = iris_queue_buffer(inst, buf);
+	if (ret) {
+		buf->attr &= ~BUF_ATTR_DEFERRED;
+		buf->attr |= BUF_ATTR_DEQUEUED;
+		buf->flags = V4L2_BUF_FLAG_ERROR;
+		buf->timestamp = timestamp;
+	}
+
+	return ret;
+}
+
 static int iris_hfi_gen2_handle_output_buffer(struct iris_inst *inst,
 					      struct iris_hfi_buffer *hfi_buffer)
 {
+	struct iris_inst_hfi_gen2 *inst_hfi_gen2 = to_iris_inst_hfi_gen2(inst);
 	struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx;
 	struct v4l2_m2m_buffer *m2m_buffer, *n;
 	struct iris_buffer *buf;
@@ -390,8 +419,18 @@ static int iris_hfi_gen2_handle_output_buffer(struct iris_inst *inst,
 
 	buf->flags = iris_hfi_gen2_get_driver_buffer_flags(inst, hfi_buffer->flags);
 
+	if (inst->domain == DECODER &&
+	    inst_hfi_gen2->hfi_frame_info.picture_type & HFI_GEN2_PICTURE_NOSHOW) {
+		/* A hidden reference picture is neither a display frame nor an error. */
+		buf->data_size = 0;
+		if (inst->state == IRIS_INST_ERROR)
+			buf->flags |= V4L2_BUF_FLAG_ERROR;
+		if (!(buf->flags & (V4L2_BUF_FLAG_ERROR | V4L2_BUF_FLAG_LAST)))
+			return iris_hfi_gen2_requeue_output_buffer(inst, buf);
+	}
+
 	if (!buf->data_size && inst->state == IRIS_INST_STREAMING &&
-	    !(hfi_buffer->flags & HFI_BUF_FW_FLAG_LAST)) {
+	    !(buf->flags & V4L2_BUF_FLAG_LAST)) {
 		buf->flags |= V4L2_BUF_FLAG_ERROR;
 	}
 

-- 
2.56.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/5] media: iris: Preserve timestamps on error buffers
  2026-10-29  3:58   ` [PATCH 4/5] media: iris: Preserve timestamps on error buffers Xilin Wu
@ 2026-11-03 21:57     ` Bryan O'Donoghue
  2026-11-03 22:14       ` Nicolas Dufresne
  0 siblings, 1 reply; 13+ messages in thread
From: Bryan O'Donoghue @ 2026-11-03 21:57 UTC (permalink / raw)
  To: Xilin Wu, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
	dragon, Chris Obbard, Deepak Sikri, Dmitry Baryshkov,
	Loic Minier, Jason Pettit

On 29/10/2026 04:58, Xilin Wu wrote:
> 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")
> Signed-off-by: Xilin Wu <sophon@radxa.com>
> ---
>   drivers/media/platform/qcom/iris/iris_buffer.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media/platform/qcom/iris/iris_buffer.c
> index eb8de60c1177..f790483d13d4 100644
> --- a/drivers/media/platform/qcom/iris/iris_buffer.c
> +++ b/drivers/media/platform/qcom/iris/iris_buffer.c
> @@ -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;
>   	}
> 
> --
> 2.56.0
> 
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API
  2026-10-29  3:58 ` [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API Xilin Wu
                     ` (4 preceding siblings ...)
  2026-10-29  3:58   ` [PATCH 5/5] media: iris: Recycle decoder buffers for non-display pictures Xilin Wu
@ 2026-11-03 22:00   ` Bryan O'Donoghue
  2026-11-03 22:29     ` Nicolas Dufresne
  5 siblings, 1 reply; 13+ messages in thread
From: Bryan O'Donoghue @ 2026-11-03 22:00 UTC (permalink / raw)
  To: Xilin Wu, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
	dragon, Chris Obbard, Deepak Sikri, Dmitry Baryshkov,
	Loic Minier, Jason Pettit

On 29/10/2026 04:58, Xilin Wu wrote:
> 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

Is this code based on https://github.com/intel/libva and is there a 
route to getting it into the upstream of that repository ?

---
bod

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/5] media: iris: Preserve timestamps on error buffers
  2026-11-03 21:57     ` Bryan O'Donoghue
@ 2026-11-03 22:14       ` Nicolas Dufresne
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Dufresne @ 2026-11-03 22:14 UTC (permalink / raw)
  To: Bryan O'Donoghue, Xilin Wu, Vikash Garodia, Dikshita Agarwal,
	Abhinav Kumar, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, dragon, Chris Obbard,
	Deepak Sikri, Dmitry Baryshkov, Loic Minier, Jason Pettit

[-- Attachment #1: Type: text/plain, Size: 1761 bytes --]

Le mardi 03 novembre 2026 à 22:57 +0100, Bryan O'Donoghue a écrit :
> On 29/10/2026 04:58, Xilin Wu wrote:
> > 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")
> > Signed-off-by: Xilin Wu <sophon@radxa.com>
> > ---
> >   drivers/media/platform/qcom/iris/iris_buffer.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media/platform/qcom/iris/iris_buffer.c
> > index eb8de60c1177..f790483d13d4 100644
> > --- a/drivers/media/platform/qcom/iris/iris_buffer.c
> > +++ b/drivers/media/platform/qcom/iris/iris_buffer.c
> > @@ -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;
> >   	}
> > 
> > --
> > 2.56.0
> > 
> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

I'm generally ok with the change, not that I think libva-v4l2 is a good idea,
but we should not intentionally make userspace life difficult. Userspace should
not though assume that every OUTPUT buffer in error will generate an CAPTURE
buffer with error and copied timestamp, this would be completely off spec.

Nicolas

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/5] media: iris: support decode-order output on HFI gen2
  2026-10-29  3:58   ` [PATCH 1/5] media: iris: support decode-order output on HFI gen2 Xilin Wu
@ 2026-11-03 22:18     ` Nicolas Dufresne
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Dufresne @ 2026-11-03 22:18 UTC (permalink / raw)
  To: Xilin Wu, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
	dragon, Chris Obbard, Deepak Sikri, Dmitry Baryshkov,
	Loic Minier, Jason Pettit

[-- Attachment #1: Type: text/plain, Size: 7453 bytes --]

Le jeudi 29 octobre 2026 à 11:58 +0800, Xilin Wu a écrit :
> Synchronous per-picture clients such as VA-API can stall when firmware
> holds decoded pictures for display reordering while the client waits for
> the current picture before submitting more input.
> 
> Expose the decoder display-delay controls on HFI gen2, with a zero delay
> selecting decode-order output. Keep display-order output as the default.

Ack-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

A better justification would be to match Venus feature here. Doing VA-API is a
bit borderline as nobody will understand that VA does not work in the normal
V4L2 stateful decoder order, nor the level of spurious effort needed to glue
these two things together.

Nicolas

> 
> Signed-off-by: Xilin Wu <sophon@radxa.com>
> ---
>  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(+)
> 
> diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.c b/drivers/media/platform/qcom/iris/iris_ctrls.c
> index 4f2633bbb49f..1dbea37c93c3 100644
> --- a/drivers/media/platform/qcom/iris/iris_ctrls.c
> +++ b/drivers/media/platform/qcom/iris/iris_ctrls.c
> @@ -155,6 +155,10 @@ static enum platform_inst_fw_cap_type iris_get_cap_id(u32 id)
>  		return LAYER4_BITRATE_HEVC;
>  	case V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_BR:
>  		return LAYER5_BITRATE_HEVC;
> +	case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE:
> +		return DISPLAY_DELAY_ENABLE;
> +	case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY:
> +		return DISPLAY_DELAY;
>  	case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:
>  		return REQUEST_SYNC_FRAME;
>  	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE:
> @@ -306,6 +310,10 @@ static u32 iris_get_v4l2_id(enum platform_inst_fw_cap_type cap_id)
>  		return V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L4_BR;
>  	case LAYER5_BITRATE_HEVC:
>  		return V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_BR;
> +	case DISPLAY_DELAY_ENABLE:
> +		return V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE;
> +	case DISPLAY_DELAY:
> +		return V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY;
>  	case REQUEST_SYNC_FRAME:
>  		return V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME;
>  	case SLICE_MODE:
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2.c
> index 79bbd06ef8d2..65af61b63a29 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2.c
> @@ -842,6 +842,22 @@ static const struct platform_inst_fw_cap inst_fw_cap_milos_enc[] = {
>  };
>  
>  static const struct platform_inst_fw_cap inst_fw_cap_sm8550_dec[] = {
> +	{
> +		.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,
> +	},
>  	{
>  		.cap_id = PROFILE_H264,
>  		.min = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE,
> @@ -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,
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> index 388a36ff2b07..a285e6fc8728 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> @@ -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) {
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h b/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h
> index 2b8b057d35a9..e89ed4075526 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h
> @@ -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
> diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/drivers/media/platform/qcom/iris/iris_platform_common.h
> index cddab9a9c375..aa8cd2e1b3f1 100644
> --- a/drivers/media/platform/qcom/iris/iris_platform_common.h
> +++ b/drivers/media/platform/qcom/iris/iris_platform_common.h
> @@ -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,
>  };
>  

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/5] media: iris: allow larger capture buffer pools on HFI gen2
  2026-10-29  3:58   ` [PATCH 2/5] media: iris: allow larger capture buffer pools " Xilin Wu
@ 2026-11-03 22:20     ` Nicolas Dufresne
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Dufresne @ 2026-11-03 22:20 UTC (permalink / raw)
  To: Xilin Wu, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
	dragon, Chris Obbard, Deepak Sikri, Dmitry Baryshkov,
	Loic Minier, Jason Pettit

[-- Attachment #1: Type: text/plain, Size: 1273 bytes --]

Le jeudi 29 octobre 2026 à 11:58 +0800, Xilin Wu a écrit :
> VLC with VA-API frame threading can require more than the default vb2
> limit of 32 CAPTURE buffers.
> 
> Raise the HFI gen2 decoder CAPTURE queue limit to 64 buffers.
> 
> Signed-off-by: Xilin Wu <sophon@radxa.com>
> ---
>  drivers/media/platform/qcom/iris/iris_vidc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
> index 05aab6e3005d..8c96b007b391 100644
> --- a/drivers/media/platform/qcom/iris/iris_vidc.c
> +++ b/drivers/media/platform/qcom/iris/iris_vidc.c
> @@ -140,6 +140,9 @@ 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 (inst->domain == DECODER &&
> +	    inst->core->iris_firmware_data == &iris_hfi_gen2_data)
> +		dst_vq->max_num_buffers = DEFAULT_MAX_HOST_BUF_COUNT;

Why is this limited to decoders? Also, why not move the max into the firmware
data, so this code path can stay idiomatic.

Nicolas

>  	dst_vq->dev = inst->core->dev;
>  	dst_vq->lock = &inst->ctx_q_lock;
>  

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/5] media: iris: Recycle decoder buffers for non-display pictures
  2026-10-29  3:58   ` [PATCH 5/5] media: iris: Recycle decoder buffers for non-display pictures Xilin Wu
@ 2026-11-03 22:25     ` Nicolas Dufresne
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Dufresne @ 2026-11-03 22:25 UTC (permalink / raw)
  To: Xilin Wu, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
	dragon, Chris Obbard, Deepak Sikri, Dmitry Baryshkov,
	Loic Minier, Jason Pettit

[-- Attachment #1: Type: text/plain, Size: 6291 bytes --]

Le jeudi 29 octobre 2026 à 11:58 +0800, Xilin Wu a écrit :
> 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.

This change is expected to improve conformance, even though you still can't
display multiple time the same reference in V4L2 stateful. Can you run fluster
and share any conformance test that failed before and succeed today?

Nicolas

> 
> Fixes: ac72ad9deafa ("media: iris: Add handling for no show frames")
> Signed-off-by: Xilin Wu <sophon@radxa.com>
> ---
>  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(-)
> 
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2.h b/drivers/media/platform/qcom/iris/iris_hfi_gen2.h
> index 21ab58e0aa84..79aac2d4e500 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2.h
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2.h
> @@ -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;
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> index a285e6fc8728..77ea153bf2d7 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> @@ -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)
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
> index f0782c4b1e6e..a545410d1e8d 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
> @@ -101,9 +101,7 @@ static int iris_hfi_gen2_get_driver_buffer_flags(struct iris_inst *inst, u32 hfi
>  		HFI_GEN2_PICTURE_CRA | HFI_GEN2_PICTURE_BLA;
>  	u32 driver_flags = 0;
>  
> -	if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_GEN2_PICTURE_NOSHOW)
> -		driver_flags |= V4L2_BUF_FLAG_ERROR;
> -	else if (inst_hfi_gen2->hfi_frame_info.picture_type & keyframe)
> +	if (inst_hfi_gen2->hfi_frame_info.picture_type & keyframe)
>  		driver_flags |= V4L2_BUF_FLAG_KEYFRAME;
>  	else if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_GEN2_PICTURE_P)
>  		driver_flags |= V4L2_BUF_FLAG_PFRAME;
> @@ -345,9 +343,40 @@ static int iris_hfi_gen2_handle_input_buffer(struct iris_inst *inst,
>  	return 0;
>  }
>  
> +static int iris_hfi_gen2_requeue_output_buffer(struct iris_inst *inst,
> +					       struct iris_buffer *buf)
> +{
> +	struct iris_inst_hfi_gen2 *inst_hfi_gen2 = to_iris_inst_hfi_gen2(inst);
> +	u64 timestamp = buf->timestamp;
> +	int ret;
> +
> +	buf->data_size = 0;
> +	buf->timestamp = 0;
> +	buf->flags = 0;
> +	buf->attr &= ~BUF_ATTR_DEQUEUED;
> +	buf->attr |= BUF_ATTR_DEFERRED;
> +
> +	/* Leave stopped buffers for streamoff cleanup or the next streamon. */
> +	if (inst_hfi_gen2->output_stopping ||
> +	    (inst->state != IRIS_INST_STREAMING &&
> +	     inst->state != IRIS_INST_OUTPUT_STREAMING))
> +		return 0;
> +
> +	ret = iris_queue_buffer(inst, buf);
> +	if (ret) {
> +		buf->attr &= ~BUF_ATTR_DEFERRED;
> +		buf->attr |= BUF_ATTR_DEQUEUED;
> +		buf->flags = V4L2_BUF_FLAG_ERROR;
> +		buf->timestamp = timestamp;
> +	}
> +
> +	return ret;
> +}
> +
>  static int iris_hfi_gen2_handle_output_buffer(struct iris_inst *inst,
>  					      struct iris_hfi_buffer *hfi_buffer)
>  {
> +	struct iris_inst_hfi_gen2 *inst_hfi_gen2 = to_iris_inst_hfi_gen2(inst);
>  	struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx;
>  	struct v4l2_m2m_buffer *m2m_buffer, *n;
>  	struct iris_buffer *buf;
> @@ -390,8 +419,18 @@ static int iris_hfi_gen2_handle_output_buffer(struct iris_inst *inst,
>  
>  	buf->flags = iris_hfi_gen2_get_driver_buffer_flags(inst, hfi_buffer->flags);
>  
> +	if (inst->domain == DECODER &&
> +	    inst_hfi_gen2->hfi_frame_info.picture_type & HFI_GEN2_PICTURE_NOSHOW) {
> +		/* A hidden reference picture is neither a display frame nor an error. */
> +		buf->data_size = 0;
> +		if (inst->state == IRIS_INST_ERROR)
> +			buf->flags |= V4L2_BUF_FLAG_ERROR;
> +		if (!(buf->flags & (V4L2_BUF_FLAG_ERROR | V4L2_BUF_FLAG_LAST)))
> +			return iris_hfi_gen2_requeue_output_buffer(inst, buf);
> +	}
> +
>  	if (!buf->data_size && inst->state == IRIS_INST_STREAMING &&
> -	    !(hfi_buffer->flags & HFI_BUF_FW_FLAG_LAST)) {
> +	    !(buf->flags & V4L2_BUF_FLAG_LAST)) {
>  		buf->flags |= V4L2_BUF_FLAG_ERROR;
>  	}
>  

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API
  2026-11-03 22:00   ` [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API Bryan O'Donoghue
@ 2026-11-03 22:29     ` Nicolas Dufresne
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Dufresne @ 2026-11-03 22:29 UTC (permalink / raw)
  To: Bryan O'Donoghue, Xilin Wu, Vikash Garodia, Dikshita Agarwal,
	Abhinav Kumar, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
	dragon, Chris Obbard, Deepak Sikri, Dmitry Baryshkov,
	Loic Minier, Jason Pettit

[-- Attachment #1: Type: text/plain, Size: 1317 bytes --]

Le mardi 03 novembre 2026 à 23:00 +0100, Bryan O'Donoghue a écrit :
> On 29/10/2026 04:58, Xilin Wu wrote:
> > 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
> 
> Is this code based on https://github.com/intel/libva and is there a 
> route to getting it into the upstream of that repository ?

libva is the runtime, qcom-va-driver is a driver, so that won't happen. Also,
qcom-va-drivers does all sort of guessing heuristic, bitstream crafting and the
readme show that it cost as much as 15% in throuput performance. Let's be
honest, this is a bit of hack, not really a solution. A proper stateless
firmware and driver would do a way better job and reduce complexity instead of
increasing it. The provided patches though seems to all have merit, matching
feature with venus, fixing bugs. A bit of spec work would not hurt though.

Nicolas

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-11-03 22:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <2a2gB7bYZ9q2UTG-mF855lyJvWdn3Ba6jqrFTEVO1EAjAIXMh7_-65v4XlrZmljww-5ozkNYL2-lWKTIH4oqOw==@protonmail.internalid>
2026-10-29  3:58 ` [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API Xilin Wu
2026-10-29  3:58   ` [PATCH 1/5] media: iris: support decode-order output on HFI gen2 Xilin Wu
2026-11-03 22:18     ` Nicolas Dufresne
2026-10-29  3:58   ` [PATCH 2/5] media: iris: allow larger capture buffer pools " Xilin Wu
2026-11-03 22:20     ` Nicolas Dufresne
2026-10-29  3:58   ` [PATCH 3/5] media: iris: Add deblocking filter controls for " Xilin Wu
2026-10-29  3:58   ` [PATCH 4/5] media: iris: Preserve timestamps on error buffers Xilin Wu
2026-11-03 21:57     ` Bryan O'Donoghue
2026-11-03 22:14       ` Nicolas Dufresne
2026-10-29  3:58   ` [PATCH 5/5] media: iris: Recycle decoder buffers for non-display pictures Xilin Wu
2026-11-03 22:25     ` Nicolas Dufresne
2026-11-03 22:00   ` [PATCH 0/5] media: iris: HFI gen2 features and fixes for VA-API Bryan O'Donoghue
2026-11-03 22:29     ` Nicolas Dufresne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®