[PATCH 45/74] media: qcom: camss: vfe: Add support for pix pad data-types
From: Bryan O'Donoghue
Date: Mon Oct 05 2026 - 13:50:26 EST
We already export src and sink for the simple RDI pads.
The pix sub-device will need to export
- Downscalers
- Statistics
- Parameters
Put code in place to describe these pads when a given VFE declares
support for them:
- DS4 and DS16 report a format derived from the source pad on every
read, and enumerate only that code
- Statistics and parameters report MEDIA_BUS_FMT_METADATA_FIXED and
have no frame size
- Selection is rejected on every pad other than the sink (compose) and
the source (crop)
No VFE declares these pads yet, so there is no functional change.
Signed-off-by: Bryan O'Donoghue <bod@xxxxxxxxxx>
---
drivers/media/platform/qcom/camss/camss-vfe.c | 59 ++++++++++++++++++++++++++-
drivers/media/platform/qcom/camss/camss-vfe.h | 7 +++-
2 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index e57590b417f3d..8726353b52d3d 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -1529,8 +1529,10 @@ static void vfe_try_format(struct vfe_line *line,
struct v4l2_mbus_framefmt *fmt,
enum v4l2_subdev_format_whence which)
{
+ struct v4l2_mbus_framefmt *src;
unsigned int i;
u32 code;
+ u32 w, h;
switch (pad) {
case MSM_VFE_PAD_SINK:
@@ -1571,6 +1573,28 @@ static void vfe_try_format(struct vfe_line *line,
}
break;
+
+ case MSM_VFE_PAD_SRC_DS4:
+ case MSM_VFE_PAD_SRC_DS16:
+ src = __vfe_get_format(line, sd_state, MSM_VFE_PAD_SRC, which);
+ w = ALIGN(src->width, 8) / 4;
+ h = ALIGN(src->height, 8) / 4;
+
+ if (pad == MSM_VFE_PAD_SRC_DS16) {
+ w = (w / 4) & ~1u;
+ h = (h / 4) & ~1u;
+ }
+ *fmt = *src;
+ fmt->width = w;
+ fmt->height = h;
+
+ break;
+ case MSM_VFE_PAD_SRC_STATS:
+ case MSM_VFE_PAD_SINK_PARAMS:
+ memset(fmt, 0, sizeof(*fmt));
+ fmt->code = MEDIA_BUS_FMT_METADATA_FIXED;
+ fmt->field = V4L2_FIELD_NONE;
+ return;
}
fmt->colorspace = V4L2_COLORSPACE_SRGB;
@@ -1672,6 +1696,22 @@ static int vfe_enum_mbus_code(struct v4l2_subdev *sd,
{
struct vfe_line *line = v4l2_get_subdevdata(sd);
+ switch (code->pad) {
+ case MSM_VFE_PAD_SRC_DS4:
+ case MSM_VFE_PAD_SRC_DS16:
+ if (code->index)
+ return -EINVAL;
+ code->code = __vfe_get_format(line, sd_state, MSM_VFE_PAD_SRC,
+ code->which)->code;
+ return 0;
+ case MSM_VFE_PAD_SRC_STATS:
+ case MSM_VFE_PAD_SINK_PARAMS:
+ if (code->index)
+ return -EINVAL;
+ code->code = MEDIA_BUS_FMT_METADATA_FIXED;
+ return 0;
+ }
+
if (code->pad == MSM_VFE_PAD_SINK) {
if (code->index >= line->nformats)
return -EINVAL;
@@ -1707,6 +1747,11 @@ static int vfe_enum_frame_size(struct v4l2_subdev *sd,
struct vfe_line *line = v4l2_get_subdevdata(sd);
struct v4l2_mbus_framefmt format;
+ /* Metadata has no frame size */
+ if (fse->pad == MSM_VFE_PAD_SRC_STATS ||
+ fse->pad == MSM_VFE_PAD_SINK_PARAMS)
+ return -ENOTTY;
+
if (fse->index != 0)
return -EINVAL;
@@ -1749,7 +1794,11 @@ static int vfe_get_format(struct v4l2_subdev *sd,
if (format == NULL)
return -EINVAL;
- fmt->format = *format;
+ /* Every pad past the src - downscalers, stats, params don't get assigned */
+ if (fmt->pad > MSM_VFE_PAD_SRC)
+ vfe_try_format(line, sd_state, fmt->pad, &fmt->format, fmt->which);
+ else
+ fmt->format = *format;
return 0;
}
@@ -1875,6 +1924,8 @@ static int vfe_get_selection(struct v4l2_subdev *sd,
default:
return -EINVAL;
}
+ else
+ return -EINVAL;
return 0;
}
@@ -2294,6 +2345,12 @@ int msm_vfe_register_entities(struct vfe_device *vfe,
pads[MSM_VFE_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
pads[MSM_VFE_PAD_SRC].flags = MEDIA_PAD_FL_SOURCE;
+ if (vfe->line[i].num_pads == MSM_VFE_PAD_NUM_PIX) {
+ pads[MSM_VFE_PAD_SRC_DS4].flags = MEDIA_PAD_FL_SOURCE;
+ pads[MSM_VFE_PAD_SRC_DS16].flags = MEDIA_PAD_FL_SOURCE;
+ pads[MSM_VFE_PAD_SRC_STATS].flags = MEDIA_PAD_FL_SOURCE;
+ pads[MSM_VFE_PAD_SINK_PARAMS].flags = MEDIA_PAD_FL_SINK;
+ }
sd->entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER;
sd->entity.ops = &vfe_media_ops;
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h
index b84b324940b64..18403bf46178c 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.h
+++ b/drivers/media/platform/qcom/camss/camss-vfe.h
@@ -21,8 +21,13 @@
#define MSM_VFE_PAD_SINK 0
#define MSM_VFE_PAD_SRC 1
+#define MSM_VFE_PAD_SRC_DS4 2
+#define MSM_VFE_PAD_SRC_DS16 3
+#define MSM_VFE_PAD_SRC_STATS 4
+#define MSM_VFE_PAD_SINK_PARAMS 5
#define MSM_VFE_PAD_NUM_RDI 2
-#define MSM_VFE_MAX_PADS MSM_VFE_PAD_NUM_RDI
+#define MSM_VFE_PAD_NUM_PIX 6
+#define MSM_VFE_MAX_PADS MSM_VFE_PAD_NUM_PIX
#define MSM_VFE_NUM_OUTPUTS 1
#define MSM_VFE_IMAGE_MASTERS_NUM 7
--
2.55.0