From: Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
To: Wangao Wang <wangao.wang@oss.qualcomm.com>,
Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Bryan O'Donoghue <bod@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: quic_qiweil@quicinc.com,
Renjiang Han <renjiang.han@oss.qualcomm.com>,
linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] media: qcom: iris: Add B frames support for encoder
Date: Wed, 3 Dec 2025 12:25:47 +0530 [thread overview]
Message-ID: <8dc699bf-1e3a-2899-fa20-2fe282ffc730@oss.qualcomm.com> (raw)
In-Reply-To: <20251127-batch2_iris_encoder_enhancements-v1-3-5ea78e2de2ae@oss.qualcomm.com>
On 11/27/2025 1:14 PM, Wangao Wang wrote:
> Add support for B-frame configuration on both gen1 and gen2 encoders by
> enabling V4L2_CID_MPEG_VIDEO_B_FRAMES control.
>
> Key changes:
> Added capability IDs for B-frame and intra period.
> Implemented handler for GOP structure with B-frames.
> Defined HFI property and structure for gen1.
> Updated platform tables and buffer logic for gen2.
>
> Signed-off-by: Wangao Wang <wangao.wang@oss.qualcomm.com>
> ---
> drivers/media/platform/qcom/iris/iris_ctrls.c | 25 ++++++++++++++++++++++
> drivers/media/platform/qcom/iris/iris_ctrls.h | 1 +
> .../platform/qcom/iris/iris_hfi_gen1_command.c | 8 +++++++
> .../platform/qcom/iris/iris_hfi_gen1_defines.h | 6 ++++++
> .../platform/qcom/iris/iris_platform_common.h | 2 ++
> .../media/platform/qcom/iris/iris_platform_gen1.c | 19 +++++++++++++++-
> .../media/platform/qcom/iris/iris_platform_gen2.c | 10 +++++++++
> drivers/media/platform/qcom/iris/iris_vpu_buffer.c | 6 +++++-
> 8 files changed, 75 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.c b/drivers/media/platform/qcom/iris/iris_ctrls.c
> index 33e104142a5bb51c952550fa45e81b3bdc723ac2..9aec8a2006e9f8e545d05e40cb68ef0ae8502f79 100644
> --- a/drivers/media/platform/qcom/iris/iris_ctrls.c
> +++ b/drivers/media/platform/qcom/iris/iris_ctrls.c
> @@ -114,6 +114,8 @@ static enum platform_inst_fw_cap_type iris_get_cap_id(u32 id)
> return USE_LTR;
> case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX:
> return MARK_LTR;
> + case V4L2_CID_MPEG_VIDEO_B_FRAMES:
> + return B_FRAME;
> default:
> return INST_FW_CAP_MAX;
> }
> @@ -217,6 +219,8 @@ static u32 iris_get_v4l2_id(enum platform_inst_fw_cap_type cap_id)
> return V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES;
> case MARK_LTR:
> return V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX;
> + case B_FRAME:
> + return V4L2_CID_MPEG_VIDEO_B_FRAMES;
> default:
> return 0;
> }
> @@ -1148,6 +1152,27 @@ int iris_set_use_and_mark_ltr(struct iris_inst *inst, enum platform_inst_fw_cap_
> &hfi_val, sizeof(u32));
> }
>
> +int iris_set_intra_period(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id)
> +{
> + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops;
> + u32 gop_size = inst->fw_caps[GOP_SIZE].value;
> + u32 b_frame = inst->fw_caps[B_FRAME].value;
> + u32 hfi_id = inst->fw_caps[cap_id].hfi_id;
> + struct hfi_intra_period intra_period;
> +
> + if (!gop_size || b_frame >= gop_size)
> + return -EINVAL;
> +
> + intra_period.pframes = (gop_size - 1) / (b_frame + 1);
> + intra_period.bframes = b_frame;
> +
> + return hfi_ops->session_set_property(inst, hfi_id,
> + HFI_HOST_FLAGS_NONE,
> + iris_get_port_info(inst, cap_id),
> + HFI_PAYLOAD_STRUCTURE,
> + &intra_period, sizeof(intra_period));
> +}
> +
> int iris_set_properties(struct iris_inst *inst, u32 plane)
> {
> const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops;
> diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.h b/drivers/media/platform/qcom/iris/iris_ctrls.h
> index 996c83fdc6f492dc252771129fc1d62e8b7a7e07..609258c81517b71523b682ca994786cdd020b07f 100644
> --- a/drivers/media/platform/qcom/iris/iris_ctrls.h
> +++ b/drivers/media/platform/qcom/iris/iris_ctrls.h
> @@ -41,6 +41,7 @@ int iris_set_ltr_count_gen2(struct iris_inst *inst, enum platform_inst_fw_cap_ty
> int iris_set_use_ltr(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
> int iris_set_mark_ltr(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
> int iris_set_use_and_mark_ltr(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
> +int iris_set_intra_period(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
> int iris_set_properties(struct iris_inst *inst, u32 plane);
>
> #endif
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c
> index 139e7a9321d30d3e348671f99b0fa81afed4827e..fe51eccb903be146e83a4fb2faf4b4092875dea4 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c
> @@ -718,6 +718,14 @@ iris_hfi_gen1_packet_session_set_property(struct hfi_session_set_property_pkt *p
> packet->shdr.hdr.size += sizeof(u32) + sizeof(*ltr_mark);
> break;
> }
> + case HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD: {
> + struct hfi_intra_period *in = pdata, *intra_period = prop_data;
> +
> + intra_period->pframes = in->pframes;
> + intra_period->bframes = in->bframes;
> + packet->shdr.hdr.size += sizeof(u32) + sizeof(*intra_period);
> + break;
> + }
> default:
> return -EINVAL;
> }
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h b/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h
> index 34249fc0d047918c2463517b8303e30df3666b97..476177add1ec860d46d85960dd09617ad347f60a 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h
> @@ -155,6 +155,7 @@
> #define HFI_PROPERTY_PARAM_VENC_LTRMODE 0x200501c
> #define HFI_PROPERTY_PARAM_VENC_MAX_NUM_B_FRAMES 0x2005020
> #define HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE 0x2006001
> +#define HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD 0x2006003
do we need to set HFI_PROPERTY_PARAM_VENC_MAX_NUM_B_FRAMES as well for
gen1? Please check.
> #define HFI_PROPERTY_CONFIG_VENC_MARKLTRFRAME 0x2006009
> #define HFI_PROPERTY_CONFIG_VENC_USELTRFRAME 0x200600a
> #define HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER 0x2006008
> @@ -484,6 +485,11 @@ struct hfi_ltr_mark {
> u32 mark_frame;
> };
>
> +struct hfi_intra_period {
> + u32 pframes;
> + u32 bframes;
> +};
> +
> struct hfi_event_data {
> u32 error;
> u32 height;
> diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/drivers/media/platform/qcom/iris/iris_platform_common.h
> index c48dfb6d47734fadd4f2e4123c93560f55355b86..34deb32eb5be0899fee779ff99b3f4b8bd91529f 100644
> --- a/drivers/media/platform/qcom/iris/iris_platform_common.h
> +++ b/drivers/media/platform/qcom/iris/iris_platform_common.h
> @@ -154,6 +154,8 @@ enum platform_inst_fw_cap_type {
> LTR_COUNT,
> USE_LTR,
> MARK_LTR,
> + B_FRAME,
> + INTRA_PERIOD,
> INST_FW_CAP_MAX,
> };
>
> diff --git a/drivers/media/platform/qcom/iris/iris_platform_gen1.c b/drivers/media/platform/qcom/iris/iris_platform_gen1.c
> index 13cee5f72a443b85136d30b41b589aeb0db8eb9a..b76f0ecaa721f3469bc63b7ff4ce5fc6ea19a8e1 100644
> --- a/drivers/media/platform/qcom/iris/iris_platform_gen1.c
> +++ b/drivers/media/platform/qcom/iris/iris_platform_gen1.c
> @@ -177,7 +177,6 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8250_enc[] = {
> .max = (1 << 16) - 1,
> .step_or_mask = 1,
> .value = 30,
> - .set = iris_set_u32
what is being removed here and why?
> },
> {
> .cap_id = ENTROPY_MODE,
> @@ -279,6 +278,24 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8250_enc[] = {
> .flags = CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
> .set = iris_set_mark_ltr,
> },
> + {
> + .cap_id = B_FRAME,
> + .min = 0,
> + .max = 3,
> + .step_or_mask = 1,
> + .value = 0,
> + .flags = CAP_FLAG_OUTPUT_PORT,
> + },
> + {
> + .cap_id = INTRA_PERIOD,
> + .min = 0,
> + .max = 1,
> + .step_or_mask = 1,
> + .value = 0,
> + .hfi_id = HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD,
> + .flags = CAP_FLAG_OUTPUT_PORT,
> + .set = iris_set_intra_period,
> + },
> };
>
> static struct platform_inst_caps platform_inst_cap_sm8550 = {
> diff --git a/drivers/media/platform/qcom/iris/iris_vpu_buffer.c b/drivers/media/platform/qcom/iris/iris_vpu_buffer.c
> index 8139fefe40fe179ff7862bbca879ce94c71c1f89..4a854a4dab322eabb16a52b1cf816c18d78acc81 100644
> --- a/drivers/media/platform/qcom/iris/iris_vpu_buffer.c
> +++ b/drivers/media/platform/qcom/iris/iris_vpu_buffer.c
> @@ -670,11 +670,15 @@ static u32 iris_vpu_enc_bin_size(struct iris_inst *inst)
>
> static inline u32 hfi_buffer_get_recon_count(struct iris_inst *inst)
> {
> + u32 bframe_count, ltr_count;
> u32 num_ref = 1;
> - u32 ltr_count;
>
> + bframe_count = inst->fw_caps[B_FRAME].value;
> ltr_count = inst->fw_caps[LTR_COUNT].value;
>
> + if (bframe_count)
> + num_ref = 2;
this would impact the scratch2 size calculation as well, please check if
this is as expected for scratch2.
Thanks,
Dikshita
> +
> if (ltr_count)
> num_ref = num_ref + ltr_count;
>
>
next prev parent reply other threads:[~2025-12-03 6:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-27 7:44 [PATCH 0/4] media: qcom: iris: encoder feature enhancements batch2 Wangao Wang
2025-11-27 7:44 ` [PATCH 1/4] media: qcom: iris: Add intra refresh support for gen1 encoder Wangao Wang
2025-11-27 10:35 ` Bryan O'Donoghue
2025-12-02 6:35 ` Wangao Wang
2025-12-03 4:28 ` Dikshita Agarwal
2025-12-04 2:21 ` Wangao Wang
2025-11-27 7:44 ` [PATCH 2/4] media: qcom: iris: Add Long-Term Reference support for encoder Wangao Wang
2025-11-27 10:41 ` Bryan O'Donoghue
2025-12-02 6:38 ` Wangao Wang
2025-12-03 6:29 ` Dikshita Agarwal
2025-12-03 6:56 ` Dikshita Agarwal
2025-11-27 7:44 ` [PATCH 3/4] media: qcom: iris: Add B frames " Wangao Wang
2025-11-27 10:43 ` Bryan O'Donoghue
2025-12-02 6:46 ` Wangao Wang
2025-12-03 6:55 ` Dikshita Agarwal [this message]
2025-11-27 7:44 ` [PATCH 4/4] media: qcom: iris: Add hierarchical coding " Wangao Wang
2025-11-27 10:50 ` Bryan O'Donoghue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8dc699bf-1e3a-2899-fa20-2fe282ffc730@oss.qualcomm.com \
--to=dikshita.agarwal@oss.qualcomm.com \
--cc=abhinav.kumar@linux.dev \
--cc=bod@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=quic_qiweil@quicinc.com \
--cc=renjiang.han@oss.qualcomm.com \
--cc=vikash.garodia@oss.qualcomm.com \
--cc=wangao.wang@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.