[PATCH v12 57/86] media: imx219: Add image stream

Sakari Ailus
2026-04-09T20:15:04Z

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

In preparation for embedded data stream support, introduce a new
imx219_stream_ids enumeration for stream IDs, with a single value,
IMX219_STREAM_IMAGE for the image data stream. Use it when accessing the
formats, crop and compose rectangles on the source pad. This is meant to
reduce the size of further commits, and doesn't introduce any functional
change.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Co-developed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/imx219.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index b4aa62cbb826..bb7b2e4b34fd 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -347,6 +347,10 @@ enum imx219_pad_ids {
IMX219_NUM_PADS,
};

+enum imx219_stream_ids {
+ IMX219_STREAM_IMAGE,
+};
+
struct imx219 {
struct v4l2_subdev sd;
struct media_pad pads[IMX219_NUM_PADS];
@@ -417,9 +421,10 @@ static void imx219_get_binning(struct v4l2_subdev_state *state, u8 *bin_h,
u8 *bin_v)
{
const struct v4l2_mbus_framefmt *format =
- v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);
const struct v4l2_rect *crop =
- v4l2_subdev_state_get_crop(state, IMX219_PAD_SOURCE);
+ v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
u32 hbin = crop->width / format->width;
u32 vbin = crop->height / format->height;

@@ -447,7 +452,8 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
int ret = 0;

state = v4l2_subdev_get_locked_active_state(&imx219->sd);
- format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);

if (ctrl->id == V4L2_CID_VBLANK) {
int exposure_max, exposure_def;
@@ -672,7 +678,8 @@ static int imx219_set_framefmt(struct imx219 *imx219,
u32 bpp;
int ret = 0;

- format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);
crop = v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
bpp = imx219_get_format_bpp(format);

@@ -862,7 +869,8 @@ static int imx219_set_pad_format_compat(struct v4l2_subdev *sd,
u8 bin_h, bin_v, bin_hv;
int ret;

- format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);

/*
* Adjust the requested format to match the closest mode. The Bayer
@@ -894,7 +902,7 @@ static int imx219_set_pad_format_compat(struct v4l2_subdev *sd,
/* Ensure bin_h and bin_v are same to avoid 1:2 or 2:1 stretching */
bin_hv = min(bin_h, bin_v);

- crop = v4l2_subdev_state_get_crop(state, IMX219_PAD_SOURCE);
+ crop = v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
crop->width = format->width * bin_hv;
crop->height = format->height * bin_hv;
crop->left = (IMX219_PIXEL_ARRAY_WIDTH - crop->width) / 2;
@@ -964,7 +972,8 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
if (fmt->pad != IMX219_PAD_SOURCE)
return v4l2_subdev_get_fmt(sd, ci, state, fmt);

- format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);

format->code = fmt->format.code =
imx219_get_format_code(imx219, fmt->format.code);
@@ -1047,7 +1056,8 @@ static int imx219_init_state(struct v4l2_subdev *sd,
struct v4l2_rect *compose =
v4l2_subdev_state_get_compose(state, IMX219_PAD_IMAGE);
struct v4l2_mbus_framefmt *source_format =
- v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);

/* The image pad models the pixel array, and thus has a fixed format. */
pixel_array_format->code = MEDIA_BUS_FMT_RAW_10;
--
2.47.3