media: iris: add vbv delay support
Subsystems (4)
cover media: iris: add vbv delay support
This series adds VBV_DELAY (V4L2_CID_MPEG_VIDEO_VBV_DELAY) support for Qualcomm iris encoder sessions, allowing users to configure the initial VBV (Video Buffer Verifier) delay for CBR-encoded streams. This is useful for latency-sensitive encoding use cases (e.g. low-latency streaming) where the client needs explicit control over the encoder's buffering delay.
Patch 1 is a prerequisite for patch 2. The PIPE capability (control over the number of VPP hardware pipes used for a session) was previously only wired up for decoder sessions. Achieving low VBV delay values (34-100 ms) requires the encoder to be constrained to a single VPP pipe, so patch 1 enables the PIPE capability on the encoder path as well, which patch 2 then relies on to force single-pipe operation when VBV delay falls in that low-latency range.
Patch 2 adds the VBV_DELAY capability: it registers HFI_PROP_VBV_DELAY, wires up the V4L2_CID_MPEG_VIDEO_VBV_DELAY control for the gen2 encoder, and only applies the property when rate control is set to CBR since VBV delay is only meaningful for constant-bitrate encoding. It adds vbv_delay support for iris HFI Gen2 based targets (qcs8300, sm8550, sm8650, sm8750, x1p42100). Support for HFI Gen1 targets will be added in a follow-up series.
This series has been verified with GST level testing.
Command used:
gst-launch-1.0 -v videotestsrc ! video/x-raw,format=NV12, \
width=1280,height=720,framerate=30/1 ! v4l2h264enc output-io-mode=4 \
capture-io-mode=4 extra-controls="controls,video_bitrate_mode=1, \
initial_delay_for_vbv_control=300;" ! filesink location=/opt/test_enc.h264
---
Sachin Kumar Garg (2):
media: iris: enable pipe for hfi gen2 encoder
media: iris: add support for vbv delay
drivers/media/platform/qcom/iris/iris_ctrls.c | 47 ++++++++++++++++++++-- drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 19 ++++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 65 insertions(+), 4 deletions(-)
---
base-commit: a52e6f7923c17a672135b485ffd96fbd72f46267
change-id: 20260730-iris_vbv_delay-343d2fa30842
Best regards,
Signature · 1 line
Sachin Kumar Garg <[email protected]>
PATCH 1/2 media: iris: enable pipe for hfi gen2 encoder
Currently the PIPE capability (HFI_PROP_PIPE / work-route) is only wired up for the HFI Gen2 decoder. Add a PIPE entry to the HFI Gen2 encoder instance capability table, and extend the encoder branch of iris_session_init_caps() to derive PIPE's min/max/value from the platform's num_vpp_pipe, mirroring the existing decoder handling.
--- drivers/media/platform/qcom/iris/iris_ctrls.c | 16 +++++++++++++--- drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/iris/iris_ctrls.c +13 -3
@@ -453,13 +453,23 @@ void iris_session_init_caps(struct iris_core *core)continue ; core->inst_fw_caps_enc[cap_id].cap_id = caps[i].cap_id; - core->inst_fw_caps_enc[cap_id].min = caps[i].min; - core->inst_fw_caps_enc[cap_id].max = caps[i].max; core->inst_fw_caps_enc[cap_id].step_or_mask = caps[i].step_or_mask; - core->inst_fw_caps_enc[cap_id].value = caps[i].value; core->inst_fw_caps_enc[cap_id].flags = caps[i].flags; core->inst_fw_caps_enc[cap_id].hfi_id = caps[i].hfi_id; core->inst_fw_caps_enc[cap_id].set = caps[i].set; + +if (cap_id ==PIPE ) { + core->inst_fw_caps_enc[cap_id].value = + core->iris_platform_data->num_vpp_pipe; + core->inst_fw_caps_enc[cap_id].min = + core->iris_platform_data->num_vpp_pipe; + core->inst_fw_caps_enc[cap_id].max = + core->iris_platform_data->num_vpp_pipe; + }else { + core->inst_fw_caps_enc[cap_id].min = caps[i].min; + core->inst_fw_caps_enc[cap_id].max = caps[i].max; + core->inst_fw_caps_enc[cap_id].value = caps[i].value; + } } }
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +7 -0
@@ -365,6 +365,13 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = { .hfi_id = HFI_PROP_STAGE, .set = iris_set_stage, }, + { + .cap_id = PIPE, + /* .max, .min and .value are set via platform data */ + .step_or_mask = 1, + .hfi_id = HFI_PROP_PIPE, + .set = iris_set_pipe, + }, { .cap_id = HEADER_MODE, .min = V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE,
Signature · 1 line
2.34.1
Re: [PATCH 1/2] media: iris: enable pipe for hfi gen2 encoder
Quoted 7 lines · Sachin Kumar Garg
Currently the PIPE capability (
HFI_PROP_PIPE/ work-route) is only wired up for the HFI Gen2 decoder. Add a PIPE entry to the HFI Gen2 encoder instance capability table, and extend the encoder branch ofiris_session_init_caps()to derive PIPE's min/max/value from the platform'snum_vpp_pipe, mirroring the existing decoder handling.
Quoted 5 lines
Signed-off-by Sachin Kumar Garg<[email protected]>--- drivers/media/platform/qcom/iris/iris_ctrls.c | 16 +++++++++++++--- drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-)
PATCH 2/2 media: iris: add support for vbv delay
In reply to Sachin Kumar GargAdd the VBV_DELAY instance capability for the HFI Gen2 encoder, exposed to userspace via V4L2_CID_MPEG_VIDEO_VBV_DELAY and mapped to HFI_PROP_VBV_DELAY through a new iris_set_vbv_delay(). The property is only meaningful for CBR rate-control modes.
Low VBV delay values (34-100 ms) require the encoder to run with a single video pipe, so extend iris_set_pipe() to force work_route to 1 whenever the configured VBV_DELAY falls in that range.
--- drivers/media/platform/qcom/iris/iris_ctrls.c | 31 ++++++++++++++++++++++ drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 12 ++++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 45 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_ctrls.c +31 -0
@@ -154,6 +154,8 @@ 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_VBV_DELAY : +return VBV_DELAY ;default :return INST_FW_CAP_MAX ; }
@@ -297,6 +299,8 @@ 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 VBV_DELAY : +return V4L2_CID_MPEG_VIDEO_VBV_DELAY ;default :return 0 ; }
@@ -544,6 +548,11 @@ int iris_set_pipe(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id)u32 work_route = inst->fw_caps[PIPE ].value;u32 hfi_id = inst->fw_caps[cap_id].hfi_id; +if (inst->domain ==ENCODER ) { +if (inst->fw_caps[VBV_DELAY ].value >34 && inst->fw_caps[VBV_DELAY ].value <100 ) + work_route =1 ; + } + return hfi_ops->session_set_property(inst, hfi_id, HFI_HOST_FLAGS_NONE, iris_get_port_info(inst, cap_id),
@@ -1487,6 +1496,28 @@ int iris_set_layer_bitrate(struct iris_inst *inst, enum platform_inst_fw_cap_typ &bitrate, sizeof(u32)); } +int iris_set_vbv_delay (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 rc_type = inst->hfi_rc_type; +u32 hfi_val; + +if (rc_type !=HFI_RC_CBR_VFR && + rc_type !=HFI_RC_CBR_CFR ) { +dev_err (inst->core->dev,"vbv_delay unsupported, rc_type: %#x\n" , rc_type); +return -EINVAL ; + } + + hfi_val = inst->fw_caps[cap_id].value; + +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;
drivers/media/platform/qcom/iris/iris_ctrls.h +1 -0
@@ -47,6 +47,7 @@ int iris_set_layer_type(struct iris_inst *inst, enum platform_inst_fw_cap_type cint iris_set_layer_count_gen1 (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id);int iris_set_layer_count_gen2 (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id);int iris_set_layer_bitrate (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id); +int iris_set_vbv_delay (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id);int iris_set_properties (struct iris_inst *inst,u32 plane);#endif
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +11 -1
@@ -944,7 +944,17 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = { .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, .set = iris_set_layer_bitrate, - } + }, + { + .cap_id = VBV_DELAY, + .min = 34, + .max = 300, + .step_or_mask = 1, + .value = 300, + .hfi_id = HFI_PROP_VBV_DELAY, + .flags = CAP_FLAG_OUTPUT_PORT, + .set = iris_set_vbv_delay, + }, };static const u32 sm8550_vdec_input_config_params_default[] = {
drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h +1 -0
@@ -127,6 +127,7 @@ enum hfi_flip {#define HFI_PROP_BUFFER_MARK 0x0300016c#define HFI_PROP_WORST_COMPRESSION_RATIO 0x03000174#define HFI_PROP_WORST_COMPLEXITY_FACTOR 0x03000175 +#define HFI_PROP_VBV_DELAY 0x03000176#define HFI_PROP_RAW_RESOLUTION 0x03000178#define HFI_PROP_TOTAL_PEAK_BITRATE 0x0300017C#define HFI_PROP_AV1_FILM_GRAIN_PRESENT 0x03000180
drivers/media/platform/qcom/iris/iris_platform_common.h +1 -0
@@ -183,6 +183,7 @@ enum platform_inst_fw_cap_type {LAYER3_BITRATE_HEVC ,LAYER4_BITRATE_HEVC ,LAYER5_BITRATE_HEVC , +VBV_DELAY , INST_FW_CAP_MAX, };
Signature · 1 line
2.34.1
Re: [PATCH 2/2] media: iris: add support for vbv delay
Quoted 10 lines · Sachin Kumar Garg
Add the
VBV_DELAYinstance capability for the HFI Gen2 encoder, exposed to userspace viaV4L2_CID_MPEG_VIDEO_VBV_DELAYand mapped toHFI_PROP_VBV_DELAYthrough a newiris_set_vbv_delay(). The property is only meaningful for CBR rate-control modes.Low VBV delay values (34-100 ms) require the encoder to run with a single video pipe, so extend
iris_set_pipe()to forcework_routeto 1 whenever the configuredVBV_DELAYfalls in that range.
Quoted 8 lines
Signed-off-by Sachin Kumar Garg<[email protected]>--- drivers/media/platform/qcom/iris/iris_ctrls.c | 31 ++++++++++++++++++++++ drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 12 ++++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 45 insertions(+), 1 deletion(-)
v2 cover media: iris: add vbv delay support
In reply to Sachin Kumar GargThis series adds VBV_DELAY (V4L2_CID_MPEG_VIDEO_VBV_DELAY) support for Qualcomm iris encoder sessions, allowing users to configure the initial VBV (Video Buffer Verifier) delay for CBR-encoded streams. This is useful for latency-sensitive encoding use cases (e.g. low-latency streaming) where the client needs explicit control over the encoder's buffering delay.
Patch 1 is a prerequisite for patch 2. The PIPE capability (control over the number of VPP hardware pipes used for a session) was previously only wired up for decoder sessions. Achieving low VBV delay values (34-100 ms) requires the encoder to be constrained to a single VPP pipe, so patch 1 enables the PIPE capability on the encoder path as well, which patch 2 then relies on to force single-pipe operation when VBV delay falls in that low-latency range.
Patch 2 adds the VBV_DELAY capability: it registers HFI_PROP_VBV_DELAY, wires up the V4L2_CID_MPEG_VIDEO_VBV_DELAY control for the gen2 encoder, and only applies the property when rate control is set to CBR since VBV delay is only meaningful for constant-bitrate encoding. It adds vbv_delay support for iris HFI Gen2 based targets (qcs8300, sm8550, sm8650, sm8750, x1p42100). Support for HFI Gen1 targets will be added in a follow-up series.
This series has been verified with GST level testing.
Command used:
gst-launch-1.0 -v videotestsrc ! video/x-raw,format=NV12, \
width=1280,height=720,framerate=30/1 ! v4l2h264enc output-io-mode=4 \
capture-io-mode=4 extra-controls="controls,video_bitrate_mode=1, \
initial_delay_for_vbv_control=300;" ! filesink location=/opt/test_enc.h264
---
Changes in v2:
- iris_set_pipe(): use inclusive VBV_DELAY bounds (>= 34 && <= 100 ms)
matching the documented range.
- iris_set_pipe(): only force single-pipe under CBR rate control so
a stale in-range VBV_DELAY no longer affects non-CBR streams.
- iris_set_pipe(): read fw_caps[VBV_DELAY].value once instead of
twice in the same condition, and derive the default work_route from
the immutable fw_caps[PIPE].max instead of the self-mutated .value,
writing the final decision back into .value so frequency scaling
picks up the corrected pipe count instead of a stale one.
- iris_set_vbv_delay(): drop the dev_err() logged for non-CBR rate
control; that is an expected, valid configuration, not an error.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Sachin Kumar Garg (2):
media: iris: enable pipe for hfi gen2 encoder
media: iris: add support for vbv delay
drivers/media/platform/qcom/iris/iris_ctrls.c | 52 ++++++++++++++++++++-- drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 19 +++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 69 insertions(+), 5 deletions(-)
---
base-commit: a52e6f7923c17a672135b485ffd96fbd72f46267
change-id: 20260730-iris_vbv_delay-343d2fa30842
Best regards,
Signature · 1 line
Sachin Kumar Garg <[email protected]>
PATCH v2 1/2 media: iris: enable pipe for hfi gen2 encoder
Currently the PIPE capability (HFI_PROP_PIPE / work-route) is only wired up for the HFI Gen2 decoder. Add a PIPE entry to the HFI Gen2 encoder instance capability table, and extend the encoder branch of iris_session_init_caps() to derive PIPE's min/max/value from the platform's num_vpp_pipe, mirroring the existing decoder handling.
--- drivers/media/platform/qcom/iris/iris_ctrls.c | 16 +++++++++++++--- drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/iris/iris_ctrls.c +13 -3
@@ -453,13 +453,23 @@ void iris_session_init_caps(struct iris_core *core)continue ; core->inst_fw_caps_enc[cap_id].cap_id = caps[i].cap_id; - core->inst_fw_caps_enc[cap_id].min = caps[i].min; - core->inst_fw_caps_enc[cap_id].max = caps[i].max; core->inst_fw_caps_enc[cap_id].step_or_mask = caps[i].step_or_mask; - core->inst_fw_caps_enc[cap_id].value = caps[i].value; core->inst_fw_caps_enc[cap_id].flags = caps[i].flags; core->inst_fw_caps_enc[cap_id].hfi_id = caps[i].hfi_id; core->inst_fw_caps_enc[cap_id].set = caps[i].set; + +if (cap_id ==PIPE ) { + core->inst_fw_caps_enc[cap_id].value = + core->iris_platform_data->num_vpp_pipe; + core->inst_fw_caps_enc[cap_id].min = + core->iris_platform_data->num_vpp_pipe; + core->inst_fw_caps_enc[cap_id].max = + core->iris_platform_data->num_vpp_pipe; + }else { + core->inst_fw_caps_enc[cap_id].min = caps[i].min; + core->inst_fw_caps_enc[cap_id].max = caps[i].max; + core->inst_fw_caps_enc[cap_id].value = caps[i].value; + } } }
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +7 -0
@@ -365,6 +365,13 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = { .hfi_id = HFI_PROP_STAGE, .set = iris_set_stage, }, + { + .cap_id = PIPE, + /* .max, .min and .value are set via platform data */ + .step_or_mask = 1, + .hfi_id = HFI_PROP_PIPE, + .set = iris_set_pipe, + }, { .cap_id = HEADER_MODE, .min = V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE,
Signature · 1 line
2.34.1
PATCH v2 2/2 media: iris: add support for vbv delay
In reply to Sachin Kumar GargAdd the VBV_DELAY instance capability for the HFI Gen2 encoder, exposed to userspace via V4L2_CID_MPEG_VIDEO_VBV_DELAY and mapped to HFI_PROP_VBV_DELAY through a new iris_set_vbv_delay(). The property is only meaningful for CBR rate-control modes.
Low VBV delay values (34-100 ms) require the encoder to run with a single video pipe, so extend iris_set_pipe() to force work_route to 1 whenever the configured VBV_DELAY falls in that range.
--- drivers/media/platform/qcom/iris/iris_ctrls.c | 36 +++++++++++++++++++++- drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 12 +++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 49 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/iris/iris_ctrls.c +35 -1
@@ -154,6 +154,8 @@ 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_VBV_DELAY : +return VBV_DELAY ;default :return INST_FW_CAP_MAX ; }
@@ -297,6 +299,8 @@ 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 VBV_DELAY : +return V4L2_CID_MPEG_VIDEO_VBV_DELAY ;default :return 0 ; }
@@ -541,8 +545,18 @@ int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_idint iris_set_pipe (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 work_route = inst->fw_caps[PIPE ].value; +u32 work_route = inst->fw_caps[PIPE ].max;u32 hfi_id = inst->fw_caps[cap_id].hfi_id; +u32 vbv_delay; + +if (inst->domain ==ENCODER && + (inst->hfi_rc_type ==HFI_RC_CBR_VFR || inst->hfi_rc_type ==HFI_RC_CBR_CFR )) { + vbv_delay = inst->fw_caps[VBV_DELAY ].value; +if (vbv_delay >=34 && vbv_delay <=100 ) + work_route =1 ; + } + + inst->fw_caps[PIPE ].value = work_route; return hfi_ops->session_set_property(inst, hfi_id, HFI_HOST_FLAGS_NONE,
@@ -1487,6 +1501,26 @@ int iris_set_layer_bitrate(struct iris_inst *inst, enum platform_inst_fw_cap_typ &bitrate, sizeof(u32)); } +int iris_set_vbv_delay (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 rc_type = inst->hfi_rc_type; +u32 hfi_val; + +if (rc_type !=HFI_RC_CBR_VFR && + rc_type !=HFI_RC_CBR_CFR ) +return -EINVAL ; + + hfi_val = inst->fw_caps[cap_id].value; + +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;
drivers/media/platform/qcom/iris/iris_ctrls.h +1 -0
@@ -47,6 +47,7 @@ int iris_set_layer_type(struct iris_inst *inst, enum platform_inst_fw_cap_type cint iris_set_layer_count_gen1 (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id);int iris_set_layer_count_gen2 (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id);int iris_set_layer_bitrate (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id); +int iris_set_vbv_delay (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id);int iris_set_properties (struct iris_inst *inst,u32 plane);#endif
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +11 -1
@@ -944,7 +944,17 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = { .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, .set = iris_set_layer_bitrate, - } + }, + { + .cap_id = VBV_DELAY, + .min = 34, + .max = 300, + .step_or_mask = 1, + .value = 300, + .hfi_id = HFI_PROP_VBV_DELAY, + .flags = CAP_FLAG_OUTPUT_PORT, + .set = iris_set_vbv_delay, + }, };static const u32 sm8550_vdec_input_config_params_default[] = {
drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h +1 -0
@@ -127,6 +127,7 @@ enum hfi_flip {#define HFI_PROP_BUFFER_MARK 0x0300016c#define HFI_PROP_WORST_COMPRESSION_RATIO 0x03000174#define HFI_PROP_WORST_COMPLEXITY_FACTOR 0x03000175 +#define HFI_PROP_VBV_DELAY 0x03000176#define HFI_PROP_RAW_RESOLUTION 0x03000178#define HFI_PROP_TOTAL_PEAK_BITRATE 0x0300017C#define HFI_PROP_AV1_FILM_GRAIN_PRESENT 0x03000180
drivers/media/platform/qcom/iris/iris_platform_common.h +1 -0
@@ -183,6 +183,7 @@ enum platform_inst_fw_cap_type {LAYER3_BITRATE_HEVC ,LAYER4_BITRATE_HEVC ,LAYER5_BITRATE_HEVC , +VBV_DELAY , INST_FW_CAP_MAX, };
Signature · 1 line
2.34.1
v3 cover media: iris: add vbv delay support
In reply to Sachin Kumar GargThis series adds VBV_DELAY (V4L2_CID_MPEG_VIDEO_VBV_DELAY) support for Qualcomm iris encoder sessions, allowing users to configure the initial VBV (Video Buffer Verifier) delay for CBR-encoded streams. This is useful for latency-sensitive encoding use cases (e.g. low-latency streaming) where the client needs explicit control over the encoder's buffering delay.
Patch 1 is a prerequisite for patch 2. The PIPE capability (control over the number of VPP hardware pipes used for a session) was previously only wired up for decoder sessions. Achieving low VBV delay values (34-100 ms) requires the encoder to be constrained to a single VPP pipe, so patch 1 enables the PIPE capability on the encoder path as well, which patch 2 then relies on to force single-pipe operation when VBV delay falls in that low-latency range.
Patch 2 adds the VBV_DELAY capability: it registers HFI_PROP_VBV_DELAY, wires up the V4L2_CID_MPEG_VIDEO_VBV_DELAY control for the gen2 encoder, and only applies the property when rate control is set to CBR since VBV delay is only meaningful for constant-bitrate encoding. It adds vbv_delay support for iris HFI Gen2 based targets (qcs8300, sm8550, sm8650, sm8750, x1p42100). Support for HFI Gen1 targets will be added in a follow-up series.
This series has been verified with GST level testing.
Command used:
gst-launch-1.0 -v videotestsrc ! video/x-raw,format=NV12, \
width=1280,height=720,framerate=30/1 ! v4l2h264enc output-io-mode=4 \
capture-io-mode=4 extra-controls="controls,video_bitrate_mode=1, \
initial_delay_for_vbv_control=300;" ! filesink location=/opt/test_enc.h264
---
Changes in v3:
- iris_set_pipe(): check fw_caps[BITRATE_MODE].value directly instead of inst->hfi_rc_type, which is stale here since BITRATE_MODE is applied
after PIPE in platform_inst_fw_cap_type order.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- iris_set_pipe(): use inclusive VBV_DELAY bounds (>= 34 && <= 100 ms)
matching the documented range.
- iris_set_pipe(): only force single-pipe under CBR rate control so
a stale in-range VBV_DELAY no longer affects non-CBR streams.
- iris_set_pipe(): read fw_caps[VBV_DELAY].value once instead of
twice in the same condition, and derive the default work_route from
the immutable fw_caps[PIPE].max instead of the self-mutated .value,
writing the final decision back into .value so frequency scaling
picks up the corrected pipe count instead of a stale one.
- iris_set_vbv_delay(): drop the dev_err() logged for non-CBR rate
control; that is an expected, valid configuration, not an error.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Sachin Kumar Garg (2):
media: iris: enable pipe for hfi gen2 encoder
media: iris: add support for vbv delay
drivers/media/platform/qcom/iris/iris_ctrls.c | 52 ++++++++++++++++++++-- drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 19 +++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 69 insertions(+), 5 deletions(-)
---
base-commit: a52e6f7923c17a672135b485ffd96fbd72f46267
change-id: 20260730-iris_vbv_delay-343d2fa30842
Best regards,
Signature · 1 line
Sachin Kumar Garg <[email protected]>
PATCH v3 1/2 media: iris: enable pipe for hfi gen2 encoder
Currently the PIPE capability (HFI_PROP_PIPE / work-route) is only wired up for the HFI Gen2 decoder. Add a PIPE entry to the HFI Gen2 encoder instance capability table, and extend the encoder branch of iris_session_init_caps() to derive PIPE's min/max/value from the platform's num_vpp_pipe, mirroring the existing decoder handling.
--- drivers/media/platform/qcom/iris/iris_ctrls.c | 16 +++++++++++++--- drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/iris/iris_ctrls.c +13 -3
@@ -453,13 +453,23 @@ void iris_session_init_caps(struct iris_core *core)continue ; core->inst_fw_caps_enc[cap_id].cap_id = caps[i].cap_id; - core->inst_fw_caps_enc[cap_id].min = caps[i].min; - core->inst_fw_caps_enc[cap_id].max = caps[i].max; core->inst_fw_caps_enc[cap_id].step_or_mask = caps[i].step_or_mask; - core->inst_fw_caps_enc[cap_id].value = caps[i].value; core->inst_fw_caps_enc[cap_id].flags = caps[i].flags; core->inst_fw_caps_enc[cap_id].hfi_id = caps[i].hfi_id; core->inst_fw_caps_enc[cap_id].set = caps[i].set; + +if (cap_id ==PIPE ) { + core->inst_fw_caps_enc[cap_id].value = + core->iris_platform_data->num_vpp_pipe; + core->inst_fw_caps_enc[cap_id].min = + core->iris_platform_data->num_vpp_pipe; + core->inst_fw_caps_enc[cap_id].max = + core->iris_platform_data->num_vpp_pipe; + }else { + core->inst_fw_caps_enc[cap_id].min = caps[i].min; + core->inst_fw_caps_enc[cap_id].max = caps[i].max; + core->inst_fw_caps_enc[cap_id].value = caps[i].value; + } } }
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +7 -0
@@ -365,6 +365,13 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = { .hfi_id = HFI_PROP_STAGE, .set = iris_set_stage, }, + { + .cap_id = PIPE, + /* .max, .min and .value are set via platform data */ + .step_or_mask = 1, + .hfi_id = HFI_PROP_PIPE, + .set = iris_set_pipe, + }, { .cap_id = HEADER_MODE, .min = V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE,
Signature · 1 line
2.34.1
PATCH v3 2/2 media: iris: add support for vbv delay
In reply to Sachin Kumar GargAdd the VBV_DELAY instance capability for the HFI Gen2 encoder, exposed to userspace via V4L2_CID_MPEG_VIDEO_VBV_DELAY and mapped to HFI_PROP_VBV_DELAY through a new iris_set_vbv_delay(). The property is only meaningful for CBR rate-control modes.
Low VBV delay values (34-100 ms) require the encoder to run with a single video pipe, so extend iris_set_pipe() to force work_route to 1 whenever the configured VBV_DELAY falls in that range.
--- drivers/media/platform/qcom/iris/iris_ctrls.c | 36 +++++++++++++++++++++- drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 12 +++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 49 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/iris/iris_ctrls.c +35 -1
@@ -154,6 +154,8 @@ 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_VBV_DELAY : +return VBV_DELAY ;default :return INST_FW_CAP_MAX ; }
@@ -297,6 +299,8 @@ 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 VBV_DELAY : +return V4L2_CID_MPEG_VIDEO_VBV_DELAY ;default :return 0 ; }
@@ -541,8 +545,18 @@ int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_idint iris_set_pipe (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 work_route = inst->fw_caps[PIPE ].value; +u32 work_route = inst->fw_caps[PIPE ].max;u32 hfi_id = inst->fw_caps[cap_id].hfi_id; +u32 vbv_delay; + +if (inst->domain ==ENCODER && + inst->fw_caps[BITRATE_MODE ].value ==V4L2_MPEG_VIDEO_BITRATE_MODE_CBR ) { + vbv_delay = inst->fw_caps[VBV_DELAY ].value; +if (vbv_delay >=34 && vbv_delay <=100 ) + work_route =1 ; + } + + inst->fw_caps[PIPE ].value = work_route; return hfi_ops->session_set_property(inst, hfi_id, HFI_HOST_FLAGS_NONE,
@@ -1487,6 +1501,26 @@ int iris_set_layer_bitrate(struct iris_inst *inst, enum platform_inst_fw_cap_typ &bitrate, sizeof(u32)); } +int iris_set_vbv_delay (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 rc_type = inst->hfi_rc_type; +u32 hfi_val; + +if (rc_type !=HFI_RC_CBR_VFR && + rc_type !=HFI_RC_CBR_CFR ) +return -EINVAL ; + + hfi_val = inst->fw_caps[cap_id].value; + +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;
drivers/media/platform/qcom/iris/iris_ctrls.h +1 -0
@@ -47,6 +47,7 @@ int iris_set_layer_type(struct iris_inst *inst, enum platform_inst_fw_cap_type cint iris_set_layer_count_gen1 (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id);int iris_set_layer_count_gen2 (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id);int iris_set_layer_bitrate (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id); +int iris_set_vbv_delay (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id);int iris_set_properties (struct iris_inst *inst,u32 plane);#endif
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +11 -1
@@ -944,7 +944,17 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = { .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, .set = iris_set_layer_bitrate, - } + }, + { + .cap_id = VBV_DELAY, + .min = 34, + .max = 300, + .step_or_mask = 1, + .value = 300, + .hfi_id = HFI_PROP_VBV_DELAY, + .flags = CAP_FLAG_OUTPUT_PORT, + .set = iris_set_vbv_delay, + }, };static const u32 sm8550_vdec_input_config_params_default[] = {
drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h +1 -0
@@ -127,6 +127,7 @@ enum hfi_flip {#define HFI_PROP_BUFFER_MARK 0x0300016c#define HFI_PROP_WORST_COMPRESSION_RATIO 0x03000174#define HFI_PROP_WORST_COMPLEXITY_FACTOR 0x03000175 +#define HFI_PROP_VBV_DELAY 0x03000176#define HFI_PROP_RAW_RESOLUTION 0x03000178#define HFI_PROP_TOTAL_PEAK_BITRATE 0x0300017C#define HFI_PROP_AV1_FILM_GRAIN_PRESENT 0x03000180
drivers/media/platform/qcom/iris/iris_platform_common.h +1 -0
@@ -183,6 +183,7 @@ enum platform_inst_fw_cap_type {LAYER3_BITRATE_HEVC ,LAYER4_BITRATE_HEVC ,LAYER5_BITRATE_HEVC , +VBV_DELAY , INST_FW_CAP_MAX, };
Signature · 1 line
2.34.1
v4 cover media: iris: add vbv delay support
In reply to Sachin Kumar GargThis series adds VBV_DELAY (V4L2_CID_MPEG_VIDEO_VBV_DELAY) support for Qualcomm iris encoder sessions, allowing users to configure the initial VBV (Video Buffer Verifier) delay for CBR-encoded streams. This is useful for latency-sensitive encoding use cases (e.g. low-latency streaming) where the client needs explicit control over the encoder's buffering delay.
Patch 1 is a prerequisite for patch 2. The PIPE capability (control over the number of VPP hardware pipes used for a session) was previously only wired up for decoder sessions. Achieving low VBV delay values (34-100 ms) requires the encoder to be constrained to a single VPP pipe, so patch 1 enables the PIPE capability on the encoder path as well, which patch 2 then relies on to force single-pipe operation when VBV delay falls in that low-latency range.
Patch 2 adds the VBV_DELAY capability: it registers HFI_PROP_VBV_DELAY, wires up the V4L2_CID_MPEG_VIDEO_VBV_DELAY control for the gen2 encoder, and only applies the property when rate control is set to CBR since VBV delay is only meaningful for constant-bitrate encoding. It adds vbv_delay support for iris HFI Gen2 based targets (qcs8300, sm8550, sm8650, sm8750, x1p42100). Support for HFI Gen1 targets will be added in a follow-up series.
This series has been verified with GST level testing.
Command used:
gst-launch-1.0 -v videotestsrc ! video/x-raw,format=NV12, \
width=1280,height=720,framerate=30/1 ! v4l2h264enc output-io-mode=4 \
capture-io-mode=4 extra-controls="controls,video_bitrate_mode=1, \
initial_delay_for_vbv_control=300;" ! filesink location=/opt/test_enc.h264
---
Changes in v4:
- iris_set_pipe(): also require fw_caps[FRAME_RC_ENABLE].value before
forcing single-pipe, since disabling rate control makes the bitrate
mode (and VBV delay) meaningless regardless of CBR/VBR selection.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- iris_set_pipe(): check fw_caps[BITRATE_MODE].value directly instead of inst->hfi_rc_type, which is stale here since BITRATE_MODE is applied
after PIPE in platform_inst_fw_cap_type order.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- iris_set_pipe(): use inclusive VBV_DELAY bounds (>= 34 && <= 100 ms)
matching the documented range.
- iris_set_pipe(): only force single-pipe under CBR rate control so
a stale in-range VBV_DELAY no longer affects non-CBR streams.
- iris_set_pipe(): read fw_caps[VBV_DELAY].value once instead of
twice in the same condition, and derive the default work_route from
the immutable fw_caps[PIPE].max instead of the self-mutated .value,
writing the final decision back into .value so frequency scaling
picks up the corrected pipe count instead of a stale one.
- iris_set_vbv_delay(): drop the dev_err() logged for non-CBR rate
control; that is an expected, valid configuration, not an error.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Sachin Kumar Garg (2):
media: iris: enable pipe for hfi gen2 encoder
media: iris: add support for vbv delay
drivers/media/platform/qcom/iris/iris_ctrls.c | 53 ++++++++++++++++++++-- drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 19 +++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 70 insertions(+), 5 deletions(-)
---
base-commit: a52e6f7923c17a672135b485ffd96fbd72f46267
change-id: 20260730-iris_vbv_delay-343d2fa30842
Best regards,
Signature · 1 line
Sachin Kumar Garg <[email protected]>
PATCH v4 1/2 media: iris: enable pipe for hfi gen2 encoder
Currently the PIPE capability (HFI_PROP_PIPE / work-route) is only wired up for the HFI Gen2 decoder. Add a PIPE entry to the HFI Gen2 encoder instance capability table, and extend the encoder branch of iris_session_init_caps() to derive PIPE's min/max/value from the platform's num_vpp_pipe, mirroring the existing decoder handling.
--- drivers/media/platform/qcom/iris/iris_ctrls.c | 16 +++++++++++++--- drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/iris/iris_ctrls.c +13 -3
@@ -453,13 +453,23 @@ void iris_session_init_caps(struct iris_core *core)continue ; core->inst_fw_caps_enc[cap_id].cap_id = caps[i].cap_id; - core->inst_fw_caps_enc[cap_id].min = caps[i].min; - core->inst_fw_caps_enc[cap_id].max = caps[i].max; core->inst_fw_caps_enc[cap_id].step_or_mask = caps[i].step_or_mask; - core->inst_fw_caps_enc[cap_id].value = caps[i].value; core->inst_fw_caps_enc[cap_id].flags = caps[i].flags; core->inst_fw_caps_enc[cap_id].hfi_id = caps[i].hfi_id; core->inst_fw_caps_enc[cap_id].set = caps[i].set; + +if (cap_id ==PIPE ) { + core->inst_fw_caps_enc[cap_id].value = + core->iris_platform_data->num_vpp_pipe; + core->inst_fw_caps_enc[cap_id].min = + core->iris_platform_data->num_vpp_pipe; + core->inst_fw_caps_enc[cap_id].max = + core->iris_platform_data->num_vpp_pipe; + }else { + core->inst_fw_caps_enc[cap_id].min = caps[i].min; + core->inst_fw_caps_enc[cap_id].max = caps[i].max; + core->inst_fw_caps_enc[cap_id].value = caps[i].value; + } } }
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +7 -0
@@ -365,6 +365,13 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = { .hfi_id = HFI_PROP_STAGE, .set = iris_set_stage, }, + { + .cap_id = PIPE, + /* .max, .min and .value are set via platform data */ + .step_or_mask = 1, + .hfi_id = HFI_PROP_PIPE, + .set = iris_set_pipe, + }, { .cap_id = HEADER_MODE, .min = V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE,
Signature · 1 line
2.34.1
Re: [PATCH v4 1/2] media: iris: enable pipe for hfi gen2 encoder
Quoted 7 lines · Sachin Kumar Garg
Currently the PIPE capability (
HFI_PROP_PIPE/ work-route) is only wired up for the HFI Gen2 decoder. Add a PIPE entry to the HFI Gen2 encoder instance capability table, and extend the encoder branch ofiris_session_init_caps()to derive PIPE's min/max/value from the platform'snum_vpp_pipe, mirroring the existing decoder handling.
Quoted 7 lines
Reviewed-by Vikash Garodia <[email protected]>Signed-off-by Sachin Kumar Garg <[email protected]>--- drivers/media/platform/qcom/iris/iris_ctrls.c | 16 +++++++++++++--- drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-)
Nit: it's strongly recommended to send new iterations of the series as a new thread instead of sending it as a reply to the previous iteration.
Signature · 2 lines
With best wishes Dmitry
PATCH v4 2/2 media: iris: add support for vbv delay
In reply to Sachin Kumar GargAdd the VBV_DELAY instance capability for the HFI Gen2 encoder, exposed to userspace via V4L2_CID_MPEG_VIDEO_VBV_DELAY and mapped to HFI_PROP_VBV_DELAY through a new iris_set_vbv_delay(). The property is only meaningful for CBR rate-control modes.
Low VBV delay values (34-100 ms) require the encoder to run with a single video pipe, so extend iris_set_pipe() to force work_route to 1 whenever the configured VBV_DELAY falls in that range.
--- drivers/media/platform/qcom/iris/iris_ctrls.c | 37 +++++++++++++++++++++- drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 12 ++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 50 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/iris/iris_ctrls.c +36 -1
@@ -154,6 +154,8 @@ 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_VBV_DELAY : +return VBV_DELAY ;default :return INST_FW_CAP_MAX ; }
@@ -297,6 +299,8 @@ 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 VBV_DELAY : +return V4L2_CID_MPEG_VIDEO_VBV_DELAY ;default :return 0 ; }
@@ -541,8 +545,19 @@ int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_idint iris_set_pipe (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 work_route = inst->fw_caps[PIPE ].value; +u32 work_route = inst->fw_caps[PIPE ].max;u32 hfi_id = inst->fw_caps[cap_id].hfi_id; +u32 vbv_delay; + +if (inst->domain ==ENCODER && + inst->fw_caps[FRAME_RC_ENABLE ].value && + inst->fw_caps[BITRATE_MODE ].value ==V4L2_MPEG_VIDEO_BITRATE_MODE_CBR ) { + vbv_delay = inst->fw_caps[VBV_DELAY ].value; +if (vbv_delay >=34 && vbv_delay <=100 ) + work_route =1 ; + } + + inst->fw_caps[PIPE ].value = work_route; return hfi_ops->session_set_property(inst, hfi_id, HFI_HOST_FLAGS_NONE,
@@ -1487,6 +1502,26 @@ int iris_set_layer_bitrate(struct iris_inst *inst, enum platform_inst_fw_cap_typ &bitrate, sizeof(u32)); } +int iris_set_vbv_delay (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 rc_type = inst->hfi_rc_type; +u32 hfi_val; + +if (rc_type !=HFI_RC_CBR_VFR && + rc_type !=HFI_RC_CBR_CFR ) +return -EINVAL ; + + hfi_val = inst->fw_caps[cap_id].value; + +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;
drivers/media/platform/qcom/iris/iris_ctrls.h +1 -0
@@ -47,6 +47,7 @@ int iris_set_layer_type(struct iris_inst *inst, enum platform_inst_fw_cap_type cint iris_set_layer_count_gen1 (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id);int iris_set_layer_count_gen2 (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id);int iris_set_layer_bitrate (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id); +int iris_set_vbv_delay (struct iris_inst *inst,enum platform_inst_fw_cap_type cap_id);int iris_set_properties (struct iris_inst *inst,u32 plane);#endif
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +11 -1
@@ -944,7 +944,17 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = { .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, .set = iris_set_layer_bitrate, - } + }, + { + .cap_id = VBV_DELAY, + .min = 34, + .max = 300, + .step_or_mask = 1, + .value = 300, + .hfi_id = HFI_PROP_VBV_DELAY, + .flags = CAP_FLAG_OUTPUT_PORT, + .set = iris_set_vbv_delay, + }, };static const u32 sm8550_vdec_input_config_params_default[] = {
drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h +1 -0
@@ -127,6 +127,7 @@ enum hfi_flip {#define HFI_PROP_BUFFER_MARK 0x0300016c#define HFI_PROP_WORST_COMPRESSION_RATIO 0x03000174#define HFI_PROP_WORST_COMPLEXITY_FACTOR 0x03000175 +#define HFI_PROP_VBV_DELAY 0x03000176#define HFI_PROP_RAW_RESOLUTION 0x03000178#define HFI_PROP_TOTAL_PEAK_BITRATE 0x0300017C#define HFI_PROP_AV1_FILM_GRAIN_PRESENT 0x03000180
drivers/media/platform/qcom/iris/iris_platform_common.h +1 -0
@@ -183,6 +183,7 @@ enum platform_inst_fw_cap_type {LAYER3_BITRATE_HEVC ,LAYER4_BITRATE_HEVC ,LAYER5_BITRATE_HEVC , +VBV_DELAY , INST_FW_CAP_MAX, };
Signature · 1 line
2.34.1
Re: [PATCH v4 2/2] media: iris: add support for vbv delay
Quoted 21 lines · Sachin Kumar Garg
Add the
VBV_DELAYinstance capability for the HFI Gen2 encoder, exposed to userspace viaV4L2_CID_MPEG_VIDEO_VBV_DELAYand mapped toHFI_PROP_VBV_DELAYthrough a newiris_set_vbv_delay(). The property is only meaningful for CBR rate-control modes.Low VBV delay values (34-100 ms) require the encoder to run with a single video pipe, so extend
iris_set_pipe()to forcework_routeto 1 whenever the configuredVBV_DELAYfalls in that range.Reviewed-by Vikash Garodia <[email protected]>Signed-off-by Sachin Kumar Garg <[email protected]>--- drivers/media/platform/qcom/iris/iris_ctrls.c | 37 +++++++++++++++++++++- drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 12 ++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 50 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/iris/iris_ctrls.c int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id · line 548
Quoted 5 lines
drivers/media/platform/qcom/iris/iris_ctrls.c +1
-1@@ -541,8 +545,19 @@ int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_idint iris_set_pipe (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 work_route = inst->fw_caps[PIPE ].value; +u32 work_route = inst->fw_caps[PIPE ].max;
Why is being set to the max value instead of using the .value?
Quoted 15 lines
drivers/media/platform/qcom/iris/iris_ctrls.c +11
-0u32 hfi_id = inst->fw_caps[cap_id].hfi_id; +u32 vbv_delay; + +if (inst->domain ==ENCODER && + inst->fw_caps[FRAME_RC_ENABLE ].value && + inst->fw_caps[BITRATE_MODE ].value ==V4L2_MPEG_VIDEO_BITRATE_MODE_CBR ) { + vbv_delay = inst->fw_caps[VBV_DELAY ].value; +if (vbv_delay >=34 && vbv_delay <=100 ) + work_route =1 ; + } + + inst->fw_caps[PIPE ].value = work_route; return hfi_ops->session_set_property(inst, hfi_id, HFI_HOST_FLAGS_NONE,
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v4 2/2] media: iris: add support for vbv delay
Quoted 21 lines · Dmitry Baryshkov
Quoted 20 lines · Sachin Kumar Garg
Add the
VBV_DELAYinstance capability for the HFI Gen2 encoder, exposed to userspace viaV4L2_CID_MPEG_VIDEO_VBV_DELAYand mapped toHFI_PROP_VBV_DELAYthrough a newiris_set_vbv_delay(). The property is only meaningful for CBR rate-control modes.Low VBV delay values (34-100 ms) require the encoder to run with a single video pipe, so extend
iris_set_pipe()to forcework_routeto 1 whenever the configuredVBV_DELAYfalls in that range.Reviewed-by Vikash Garodia <[email protected]>Signed-off-by Sachin Kumar Garg <[email protected]>--- drivers/media/platform/qcom/iris/iris_ctrls.c | 37 +++++++++++++++++++++- drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 12 ++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 50 insertions(+), 2 deletions(-)
Quoted 9 lines
drivers/media/platform/qcom/iris/iris_ctrls.c int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id · line 548
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_ctrls.c +1
-1@@ -541,8 +545,19 @@ int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_idint iris_set_pipe (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 work_route = inst->fw_caps[PIPE ].value; +u32 work_route = inst->fw_caps[PIPE ].max;Why is being set to the max value instead of using the .value?
fw_caps[PIPE].min/.max/.value are all seeded from the same platform constant (num_vpp_pipe) at init, so .max and .value were interchangeable before this patch. This patch now writes the applied pipe count back into .value (used elsewhere for power/cycle estimation), which makes .value stateful. Since iris_set_pipe() is re-invoked on every resolution change while streaming, seeding work_route from .value would let a previous single-pipe override persist as the new baseline on the next call, even after the VBV-delay/CBR condition no longer applies. Reading from .max instead keeps the default pipe count stable and re-evaluates the workaround fresh on every call.
Regards,
Sachin>> u32 hfi_id = inst->fw_caps[cap_id].hfi_id;
Quoted 14 lines
Quoted 14 lines
drivers/media/platform/qcom/iris/iris_ctrls.c +11
-0+u32 vbv_delay; + +if (inst->domain ==ENCODER && + inst->fw_caps[FRAME_RC_ENABLE ].value && + inst->fw_caps[BITRATE_MODE ].value ==V4L2_MPEG_VIDEO_BITRATE_MODE_CBR ) { + vbv_delay = inst->fw_caps[VBV_DELAY ].value; +if (vbv_delay >=34 && vbv_delay <=100 ) + work_route =1 ; + } + + inst->fw_caps[PIPE ].value = work_route; return hfi_ops->session_set_property(inst, hfi_id, HFI_HOST_FLAGS_NONE,
Re: [PATCH v4 2/2] media: iris: add support for vbv delay
Quoted 35 lines · Sachin Kumar Garg
Quoted 21 lines · Dmitry Baryshkov
Quoted 20 lines · Sachin Kumar Garg
Add the
VBV_DELAYinstance capability for the HFI Gen2 encoder, exposed to userspace viaV4L2_CID_MPEG_VIDEO_VBV_DELAYand mapped toHFI_PROP_VBV_DELAYthrough a newiris_set_vbv_delay(). The property is only meaningful for CBR rate-control modes.Low VBV delay values (34-100 ms) require the encoder to run with a single video pipe, so extend
iris_set_pipe()to forcework_routeto 1 whenever the configuredVBV_DELAYfalls in that range.Reviewed-by Vikash Garodia <[email protected]>Signed-off-by Sachin Kumar Garg <[email protected]>--- drivers/media/platform/qcom/iris/iris_ctrls.c | 37 +++++++++++++++++++++- drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 12 ++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 50 insertions(+), 2 deletions(-)Quoted 9 lines
drivers/media/platform/qcom/iris/iris_ctrls.c int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id · line 548
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_ctrls.c +1
-1@@ -541,8 +545,19 @@ int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_idint iris_set_pipe (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 work_route = inst->fw_caps[PIPE ].value; +u32 work_route = inst->fw_caps[PIPE ].max;Why is being set to the max value instead of using the .value?
Quoted 10 lines
fw_caps[PIPE].min/.max/.value are all seeded from the same platform constant (
num_vpp_pipe) at init, so .max and .value were interchangeable before this patch. This patch now writes the applied pipe count back into .value (used elsewhere for power/cycle estimation), which makes .value stateful. Sinceiris_set_pipe()is re-invoked on every resolution change while streaming, seedingwork_routefrom .value would let a previous single-pipe override persist as the new baseline on the next call, even after the VBV-delay/CBR condition no longer applies. Reading from .max instead keeps the default pipe count stable and re-evaluates the workaround fresh on every call.
With the .value being written, does it need a lock protection?
Quoted 18 lines
Regards,
Sachin>> u32hfi_id= inst->fw_caps[cap_id].hfi_id;Quoted 14 lines
Quoted 14 lines
drivers/media/platform/qcom/iris/iris_ctrls.c +11
-0+u32 vbv_delay; + +if (inst->domain ==ENCODER && + inst->fw_caps[FRAME_RC_ENABLE ].value && + inst->fw_caps[BITRATE_MODE ].value ==V4L2_MPEG_VIDEO_BITRATE_MODE_CBR ) { + vbv_delay = inst->fw_caps[VBV_DELAY ].value; +if (vbv_delay >=34 && vbv_delay <=100 ) + work_route =1 ; + } + + inst->fw_caps[PIPE ].value = work_route; return hfi_ops->session_set_property(inst, hfi_id, HFI_HOST_FLAGS_NONE,
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v4 2/2] media: iris: add support for vbv delay
Quoted 48 lines · Dmitry Baryshkov
Quoted 35 lines · Sachin Kumar Garg
Quoted 21 lines · Dmitry Baryshkov
Quoted 20 lines · Sachin Kumar Garg
Add the
VBV_DELAYinstance capability for the HFI Gen2 encoder, exposed to userspace viaV4L2_CID_MPEG_VIDEO_VBV_DELAYand mapped toHFI_PROP_VBV_DELAYthrough a newiris_set_vbv_delay(). The property is only meaningful for CBR rate-control modes.Low VBV delay values (34-100 ms) require the encoder to run with a single video pipe, so extend
iris_set_pipe()to forcework_routeto 1 whenever the configuredVBV_DELAYfalls in that range.Reviewed-by Vikash Garodia <[email protected]>Signed-off-by Sachin Kumar Garg <[email protected]>--- drivers/media/platform/qcom/iris/iris_ctrls.c | 37 +++++++++++++++++++++- drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 12 ++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 50 insertions(+), 2 deletions(-)Quoted 9 lines
drivers/media/platform/qcom/iris/iris_ctrls.c int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id · line 548
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_ctrls.c +1
-1@@ -541,8 +545,19 @@ int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_idint iris_set_pipe (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 work_route = inst->fw_caps[PIPE ].value; +u32 work_route = inst->fw_caps[PIPE ].max;Why is being set to the max value instead of using the .value?
Quoted 10 lines
fw_caps[PIPE].min/.max/.value are all seeded from the same platform constant (
num_vpp_pipe) at init, so .max and .value were interchangeable before this patch. This patch now writes the applied pipe count back into .value (used elsewhere for power/cycle estimation), which makes .value stateful. Sinceiris_set_pipe()is re-invoked on every resolution change while streaming, seedingwork_routefrom .value would let a previous single-pipe override persist as the new baseline on the next call, even after the VBV-delay/CBR condition no longer applies. Reading from .max instead keeps the default pipe count stable and re-evaluates the workaround fresh on every call.
Quoted 2 lines
With the .value being written, does it need a lock protection?
No — inst->lock already serializes this. iris_set_pipe()'s write to fw_caps[PIPE].value only happens inside start_streaming (iris_venc/vdec_streamon_output(), both the iris_set_properties() cap loop and the DRC re-apply path), and start_streaming takes inst->lock before reaching either. The only reader outside that same call chain is the power/clock-scaling code (iris_vpu3x_vpu4x_calculate_frequency()), which is only invoked via iris_scale_power(), itself called from start_streaming and buf_queue — both of which also hold inst->lock. So writer and readers already can't run concurrently; adding a lock here would just be redundant with the existing vb2-op locking, and no other .set() callback in this file takes one either.
Regards,
Sachin>>
Quoted 19 lines
Quoted 17 lines
Regards,
Sachin>> u32hfi_id= inst->fw_caps[cap_id].hfi_id;Quoted 14 lines
Quoted 14 lines
drivers/media/platform/qcom/iris/iris_ctrls.c +11
-0+u32 vbv_delay; + +if (inst->domain ==ENCODER && + inst->fw_caps[FRAME_RC_ENABLE ].value && + inst->fw_caps[BITRATE_MODE ].value ==V4L2_MPEG_VIDEO_BITRATE_MODE_CBR ) { + vbv_delay = inst->fw_caps[VBV_DELAY ].value; +if (vbv_delay >=34 && vbv_delay <=100 ) + work_route =1 ; + } + + inst->fw_caps[PIPE ].value = work_route; return hfi_ops->session_set_property(inst, hfi_id, HFI_HOST_FLAGS_NONE,
Dmitry Baryshkov
Reviewed-byRe: [PATCH v4 2/2] media: iris: add support for vbv delay
Quoted 53 lines · Sachin Kumar Garg
Quoted 48 lines · Dmitry Baryshkov
Quoted 35 lines · Sachin Kumar Garg
Quoted 21 lines · Dmitry Baryshkov
Quoted 20 lines · Sachin Kumar Garg
Add the
VBV_DELAYinstance capability for the HFI Gen2 encoder, exposed to userspace viaV4L2_CID_MPEG_VIDEO_VBV_DELAYand mapped toHFI_PROP_VBV_DELAYthrough a newiris_set_vbv_delay(). The property is only meaningful for CBR rate-control modes.Low VBV delay values (34-100 ms) require the encoder to run with a single video pipe, so extend
iris_set_pipe()to forcework_routeto 1 whenever the configuredVBV_DELAYfalls in that range.Reviewed-by Vikash Garodia <[email protected]>Signed-off-by Sachin Kumar Garg <[email protected]>--- drivers/media/platform/qcom/iris/iris_ctrls.c | 37 +++++++++++++++++++++- drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 12 ++++++- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 1 + .../platform/qcom/iris/iris_platform_common.h | 1 + 5 files changed, 50 insertions(+), 2 deletions(-)Quoted 9 lines
drivers/media/platform/qcom/iris/iris_ctrls.c int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id · line 548
Quoted 6 lines
drivers/media/platform/qcom/iris/iris_ctrls.c +1
-1@@ -541,8 +545,19 @@ int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_idint iris_set_pipe (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 work_route = inst->fw_caps[PIPE ].value; +u32 work_route = inst->fw_caps[PIPE ].max;Why is being set to the max value instead of using the .value?
Quoted 10 lines
fw_caps[PIPE].min/.max/.value are all seeded from the same platform constant (
num_vpp_pipe) at init, so .max and .value were interchangeable before this patch. This patch now writes the applied pipe count back into .value (used elsewhere for power/cycle estimation), which makes .value stateful. Sinceiris_set_pipe()is re-invoked on every resolution change while streaming, seedingwork_routefrom .value would let a previous single-pipe override persist as the new baseline on the next call, even after the VBV-delay/CBR condition no longer applies. Reading from .max instead keeps the default pipe count stable and re-evaluates the workaround fresh on every call.Quoted 2 lines
With the .value being written, does it need a lock protection?
Quoted 11 lines
No —
inst->lockalready serializes this. iris_set_pipe()'s write to fw_caps[PIPE].value only happens insidestart_streaming(iris_venc/vdec_streamon_output(), both theiris_set_properties()cap loop and the DRC re-apply path), andstart_streamingtakesinst->lockbefore reaching either. The only reader outside that same call chain is the power/clock-scaling code (iris_vpu3x_vpu4x_calculate_frequency()), which is only invoked viairis_scale_power(), itself called fromstart_streamingandbuf_queue— both of which also holdinst->lock. So writer and readers already can't run concurrently; adding a lock here would just be redundant with the existing vb2-op locking, and no other .set() callback in this file takes one either.
Signature · 2 lines
With best wishes Dmitry