[PATCH RFC 6/7] media: qcom: iris: vdec: update find_format to handle 8bit and 10bit formats

From: Neil Armstrong

Date: Wed Apr 08 2026 - 12:45:33 EST


The 10bit pixel format can be only used when the decoder identifies the
stream as decoding into 10bit pixel format buffers, so update the
find_format helpers to filter the formats.

Signed-off-by: Neil Armstrong <neil.armstrong@xxxxxxxxxx>
---
.../platform/qcom/iris/iris_platform_common.h | 1 +
drivers/media/platform/qcom/iris/iris_vdec.c | 41 ++++++++++++++++++++--
2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/drivers/media/platform/qcom/iris/iris_platform_common.h
index 5a489917580e..cd3509da4b75 100644
--- a/drivers/media/platform/qcom/iris/iris_platform_common.h
+++ b/drivers/media/platform/qcom/iris/iris_platform_common.h
@@ -18,6 +18,7 @@ struct iris_inst;

#define REGISTER_BIT_DEPTH(luma, chroma) ((luma) << 16 | (chroma))
#define BIT_DEPTH_8 REGISTER_BIT_DEPTH(8, 8)
+#define BIT_DEPTH_10 REGISTER_BIT_DEPTH(10, 10)
#define CODED_FRAMES_PROGRESSIVE 0x0
#define DEFAULT_MAX_HOST_BUF_COUNT 64
#define DEFAULT_MAX_HOST_BURST_BUF_COUNT 256
diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/platform/qcom/iris/iris_vdec.c
index ca0518c27834..bfc13c1044c7 100644
--- a/drivers/media/platform/qcom/iris/iris_vdec.c
+++ b/drivers/media/platform/qcom/iris/iris_vdec.c
@@ -105,6 +105,16 @@ find_format(struct iris_inst *inst, u32 pixfmt, u32 type)
if (i == size || fmt[i].type != type)
return NULL;

+ if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+ if (iris_fmt_is_8bit(fmt[i].pixfmt) &&
+ inst->fw_caps[BIT_DEPTH].value == BIT_DEPTH_8)
+ return NULL;
+
+ if (iris_fmt_is_10bit(fmt[i].pixfmt) &&
+ inst->fw_caps[BIT_DEPTH].value != BIT_DEPTH_10)
+ return NULL;
+ }
+
return &fmt[i];
}

@@ -113,6 +123,7 @@ find_format_by_index(struct iris_inst *inst, u32 index, u32 type)
{
const struct iris_fmt *fmt = NULL;
unsigned int size = 0;
+ unsigned int i, k = 0;

switch (type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
@@ -127,10 +138,36 @@ find_format_by_index(struct iris_inst *inst, u32 index, u32 type)
return NULL;
}

- if (index >= size || fmt[index].type != type)
+ if (index >= size)
return NULL;

- return &fmt[index];
+ if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+ if (fmt[index].type != type)
+ return NULL;
+
+ return &fmt[index];
+ }
+
+ /* Loop over the valid capture formats and return the index */
+ for (i = 0; i < size; i++) {
+ if (fmt[i].type != type)
+ continue;
+
+ if (iris_fmt_is_8bit(fmt[i].pixfmt) &&
+ inst->fw_caps[BIT_DEPTH].value == BIT_DEPTH_10)
+ continue;
+
+ if (iris_fmt_is_10bit(fmt[i].pixfmt) &&
+ inst->fw_caps[BIT_DEPTH].value != BIT_DEPTH_10)
+ continue;
+
+ if (k == index)
+ return &fmt[i];
+
+ k++;
+ }
+
+ return NULL;
}

int iris_vdec_enum_fmt(struct iris_inst *inst, struct v4l2_fmtdesc *f)

--
2.34.1