[PATCH v9 0/3] media: qcom: iris: add multi slice support
Sachin Kumar Garg <[email protected]> Sat, 01 Aug 2026 12:14:47 +0530
| Newsgroups | org.kernel.vger.linux-media,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
This series adds support for multi-slice encoding in the Qualcomm Iris driver. Multi-slice mode allows encoding a single frame into multiple slices, which can improve error resilience and enable parallel processing. The feature supports two slice modes: - MAX_MB mode: slices are created based on macroblock count, controlled via V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB - MAX_BYTES mode: slices are created based on byte size, controlled via V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES Clients can enable slice mode using the V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE control. Patch 1 is a prerequisite fix: iris_set_stage() computes a work_mode but never caches it back into inst->fw_caps[STAGE].value, leaving buffer-size and clock-frequency calculations based on a stale value. Patch 2 is another prerequisite fix: iris_set_stage() currently always selects STAGE_2 work mode for encoder sessions, but CBR rate control requires STAGE_1. This is fixed by forcing STAGE_1 when BITRATE_MODE is set to CBR. Patch 3 adds the multi-slice support itself for Iris HFI Gen2 based targets (qcm2290, sc7280, qcs8300, sm8550 and other SM8550-derived targets). 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, \ slice_partitioning_method=1,number_of_mbs_in_a_slice=460;" \ ! filesink location=/opt/test_enc.h264 Depends-on: message-id: [email protected] Changes in v9: - Rebased on top of AR50_LT enablement series v9 (https://lore.kernel.org/all/[email protected]/) - Link to v8: https://lore.kernel.org/r/[email protected] Changes in v8: - Rebased on top of AR50_LT enablement series (https://lore.kernel.org/all/[email protected]/) - Extend multi-slice support to VPU2 (sc7280) and AR50LT (qcm2290) platforms, in addition to the existing VPU3x platforms. - Rename the shared slice_caps instance from slice_caps_vpu3x to iris_vpu2_vpu3x_slice_caps to reflect that it is now shared across VPU2 and VPU3x platforms, and wire it into sc7280_data. - Add a new iris_ar50lt_slice_caps instance for the AR50LT platform, and wire it into qcm2290_data. - Link to v7: https://lore.kernel.org/r/[email protected] Changes in v7: - Moved slice_caps_vpu3x from a static const in iris_platform_vpu3x.c to a real definition in iris_hfi_gen2.c, extern-declared in iris_platform_common.h (same pattern as iris_hfi_gen2_data), so it no longer has to sit between #include lines to satisfy ordering. - Link to v6: https://lore.kernel.org/r/[email protected] Changes in v6: - Reordered local variable declarations in iris_set_slice_count() to follow reverse Christmas tree style. - Renamed default_slice_caps_vpu3x to slice_caps_vpu3x. - Link to v5: https://lore.kernel.org/r/[email protected] Changes in v5: - Fixed unbounded slice count under RC_OFF in iris_set_slice_count() for the MAX_BYTES use case. - Addressed remaining coding-style review comments. - Link to v4: https://lore.kernel.org/r/[email protected] Changes in v4: - Split out a new prerequisite patch (patch 1) to cache the computed work_mode into inst->fw_caps[STAGE].value in iris_set_stage(), since this fixes a pre-existing bug independent of the CBR change and needed its own Fixes tag. - Deduplicated the per-target slice capability limits that were previously repeated identically across platform_inst_cap_qcs8300 and platform_inst_cap_sm8550. Introduced struct platform_inst_slice_caps and moved it to iris_platform_data (one level up from platform_inst_caps), since all Iris HFI Gen2 targets share the same encoder capability table and hence the same slice limits; a single default_slice_caps_vpu3x instance is now referenced by all Gen2 platforms. - Link to v3: https://lore.kernel.org/r/[email protected] Changes in v3: - Patch 1 (force stage 1 work mode for CBR RC): cache the computed work_mode into inst->fw_caps[STAGE].value so buffer-size and clock-frequency calculations stay consistent with what is actually configured on firmware. - Patch 2 (multi-slice support): - Use inst->hfi_rc_type instead of the raw V4L2 BITRATE_MODE value when validating/deriving slice parameters, avoiding a mismatch between V4L2 and firmware rate-control enums. - Round up (instead of truncate) when computing the minimum MAX_MB and MAX_BYTES slice size floors, so the hardware's max-slices-per-frame limit is never exceeded. Changes in v2: - Added a prerequisite patch to force STAGE_1 work mode for CBR rate control on the encoder, required for multi-slice encoding to work correctly. - Addressed review comments on the multi-slice patch (updated commit subject and description). Signed-off-by: Sachin Kumar Garg <[email protected]> --- Sachin Kumar Garg (3): media: iris: cache work mode after computing it in iris_set_stage media: iris: force stage 1 work mode for CBR RC on encoder media: iris: add support for multi_slice in iris encoder drivers/media/platform/qcom/iris/iris_ctrls.c | 91 ++++++++++++++++++++++ drivers/media/platform/qcom/iris/iris_ctrls.h | 1 + drivers/media/platform/qcom/iris/iris_hfi_gen2.c | 86 ++++++++++++++++++++ .../platform/qcom/iris/iris_hfi_gen2_defines.h | 2 + .../platform/qcom/iris/iris_platform_common.h | 18 +++++ .../media/platform/qcom/iris/iris_platform_vpu2.c | 1 + .../media/platform/qcom/iris/iris_platform_vpu3x.c | 5 ++ .../platform/qcom/iris/iris_platform_vpu_ar50lt.c | 1 + 8 files changed, 205 insertions(+) --- base-commit: a4e49d59acd3ebbe00d252a5ca14c5c4c981bd60 change-id: 20260716-iris_multi_slice-5647287a9563 prerequisite-message-id: <[email protected]> prerequisite-patch-id: 564b79f382140b898543358f7f4fa87dd138d509 prerequisite-patch-id: 8dbbaedb2f9b45ab480ca7971172e2db2b51b323 prerequisite-patch-id: e669517302297a7b315c9aa4f4189e4928091e0c prerequisite-patch-id: 922bc325dbd9a499a3a209d2f8dbbce6a4166e60 prerequisite-patch-id: a5a49cda4e21d835558fa84f2f6bd25b8f7e72b4 prerequisite-patch-id: e62e8285bcbddade64c026379f23a8c5ae70fe52 prerequisite-patch-id: cac29b25348e2e791638a0286283109f2546f9a7 prerequisite-patch-id: 4dfaff2f9644d7a168b1b35fe947660b8f464af6 prerequisite-patch-id: 6198a3555246c62bc989161894bdd7d799e6885b prerequisite-patch-id: d97c79463fe1487fa7bc9eebd4cfb4610713f44a prerequisite-patch-id: 76eafea8230160a3b5e6503c68a5c9c3c2d1497e prerequisite-patch-id: ea9cd9a8e6561321cd9cf338a76da1382ff47e13 prerequisite-patch-id: 26e9083b709cc8f2f1184edf6b39fb89f365a9f1 prerequisite-patch-id: ce4576bd3d20880939a97a1cda9bb8678808ea65 prerequisite-patch-id: 6f98157cee1161d27a8bcf1b9003f57ef7730921 prerequisite-patch-id: 6e258cd475b77927d6476704cbf91bf48a63aa0d prerequisite-patch-id: 200af0b22740dcc006b6de6d4e0744da5e6a745a prerequisite-patch-id: f5479d2ca6b850c0c750944a8e0b05a7df2cc5a8 prerequisite-patch-id: 96dfec1c2df69f748c1a4bd741628e946cb7bec1 Best regards, -- Sachin Kumar Garg <[email protected]>