Re: [PATCH v7 2/6] media: qcom: iris: Add Long-Term Reference support for encoder
From: Dmitry Baryshkov
Date: Wed May 13 2026 - 07:01:13 EST
On Tue, May 12, 2026 at 04:55:11PM +0800, Wangao Wang wrote:
> Add Long-Term Reference(LTR) frame support for both gen1 and gen2
> encoders by enabling the following V4L2 controls:
> V4L2_CID_MPEG_VIDEO_LTR_COUNT
> V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES
> V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX
>
> Tested-by: Neil Armstrong <neil.armstrong@xxxxxxxxxx> # on SM8650-HDK
> Reviewed-by: Dikshita Agarwal <dikshita.agarwal@xxxxxxxxxxxxxxxx>
> Signed-off-by: Wangao Wang <wangao.wang@xxxxxxxxxxxxxxxx>
> ---
> drivers/media/platform/qcom/iris/iris_ctrls.c | 128 +++++++++++++++++++++
> drivers/media/platform/qcom/iris/iris_ctrls.h | 5 +
> drivers/media/platform/qcom/iris/iris_hfi_gen1.c | 30 +++++
> .../platform/qcom/iris/iris_hfi_gen1_command.c | 25 ++++
> .../platform/qcom/iris/iris_hfi_gen1_defines.h | 24 ++++
> drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 30 +++++
> .../platform/qcom/iris/iris_hfi_gen2_defines.h | 3 +
> .../platform/qcom/iris/iris_platform_common.h | 6 +
> drivers/media/platform/qcom/iris/iris_vpu_buffer.c | 20 +++-
> 9 files changed, 267 insertions(+), 4 deletions(-)
>
> +
> +int iris_set_use_and_mark_ltr(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id)
> +{
> + const struct iris_hfi_session_ops *hfi_ops = inst->hfi_session_ops;
> + struct vb2_queue *sq = v4l2_m2m_get_src_vq(inst->m2m_ctx);
> + struct vb2_queue *dq = v4l2_m2m_get_dst_vq(inst->m2m_ctx);
> + u32 ltr_count = inst->fw_caps[LTR_COUNT].value;
> + u32 hfi_val = inst->fw_caps[cap_id].value;
> + u32 hfi_id = inst->fw_caps[cap_id].hfi_id;
> +
> + if (!vb2_is_streaming(sq) && !vb2_is_streaming(dq))
> + return -EINVAL;
> +
> + if (!ltr_count || hfi_val == INVALID_DEFAULT_MARK_OR_USE_LTR)
> + return -EINVAL;
This means that setting the property will fail if userspace has not
updated it. Please make sure that defaults don't cause errors.
> +
> + return hfi_ops->session_set_property(inst, hfi_id,
> + HFI_HOST_FLAGS_NONE,
> + iris_get_port_info(inst, cap_id),
> + HFI_PAYLOAD_U32,
> + &hfi_val, sizeof(u32));
> +}
> +
> int iris_set_properties(struct iris_inst *inst, u32 plane)
> {
> const struct iris_hfi_session_ops *hfi_ops = inst->hfi_session_ops;
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1.c b/drivers/media/platform/qcom/iris/iris_hfi_gen1.c
> index 9344d20042fd4dd5ed123463a93188f36efbd137..6db693a602aca296f032dfc31987071f8e15bd1c 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1.c
> @@ -243,6 +243,36 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8250_enc[] = {
> .flags = CAP_FLAG_OUTPUT_PORT,
> .set = iris_set_ir_period_gen1,
> },
> + {
> + .cap_id = LTR_COUNT,
> + .min = 0,
> + .max = MAX_LTR_FRAME_COUNT_GEN1,
> + .step_or_mask = 1,
> + .value = 0,
> + .hfi_id = HFI_PROPERTY_PARAM_VENC_LTRMODE,
> + .flags = CAP_FLAG_OUTPUT_PORT,
> + .set = iris_set_ltr_count_gen1,
> + },
> + {
> + .cap_id = USE_LTR,
> + .min = 0,
> + .max = ((1 << MAX_LTR_FRAME_COUNT_GEN1) - 1),
> + .step_or_mask = 0,
> + .value = 0,
> + .hfi_id = HFI_PROPERTY_CONFIG_VENC_USELTRFRAME,
> + .flags = CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
> + .set = iris_set_use_ltr,
> + },
> + {
> + .cap_id = MARK_LTR,
> + .min = 0,
> + .max = (MAX_LTR_FRAME_COUNT_GEN1 - 1),
> + .step_or_mask = 1,
> + .value = 0,
> + .hfi_id = HFI_PROPERTY_CONFIG_VENC_MARKLTRFRAME,
> + .flags = CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
> + .set = iris_set_mark_ltr,
> + },
> };
>
> static const u32 sm8250_vdec_input_config_param_default[] = {
--
With best wishes
Dmitry