[PATCH 1/2] media: atomisp: Don't enumerate frame sizes the preview pipe can't output
From: Volodymyr Chapman
Date: Mon Nov 16 2026 - 12:58:56 EST
In preview mode atomisp_try_fmt() limits the size to 1920x1440, since the
preview pipeline cannot output anything larger. For sensors without crop
support atomisp_enum_framesizes() however passes on all sensor sizes,
minus the padding, so VIDIOC_ENUM_FRAMESIZES lists sizes for which
VIDIOC_S_FMT returns a different, smaller size.
Userspace which picks the largest enumerated size and then checks that
S_FMT gave it that size fails. For example PipeWire's V4L2 source cannot
negotiate a format with Firefox for the IMX175 rear sensor of a Lenovo
ThinkPad 10, which lists 3264x2448 and 1624x1216: Firefox picks
3264x2448, S_FMT returns 1624x1216 and the stream fails with "error set
output format: -22 (Invalid argument)".
Skip the sizes which do not fit the preview pipeline when in preview mode,
so that only sizes which S_FMT can set are enumerated.
Tested on a Lenovo ThinkPad 10 (20C3, Atom Z3795) with this file built out
of tree against a 7.2.15 kernel: ENUM_FRAMESIZES for the IMX175 now lists
only 1624x1216, and Firefox 160 streams from both the IMX175 and the
OV2722 front sensor through PipeWire. This was build-tested on top of
media.git next.
The problem was investigated and this patch drafted with the help of an
AI coding assistant (Claude); the testing was done on the hardware by the
submitter.
Fixes: d86c33af672d ("media: atomisp: Clamp width to max 1920 pixels when in ATOMISP_RUN_MODE_PREVIEW")
Signed-off-by: Volodymyr Chapman <volodymyrchapman@xxxxxxxxx>
---
.../staging/media/atomisp/pci/atomisp_ioctl.c | 22 ++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
index 50366bf10..046a95857 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
@@ -532,11 +532,11 @@ static int atomisp_enum_framesizes(struct file *file, void *priv,
struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
struct atomisp_input_subdev *input = &isp->inputs[asd->input_curr];
struct v4l2_subdev_frame_size_enum fse = {
- .index = fsize->index,
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
.code = input->code,
};
struct v4l2_subdev_state *act_sd_state;
+ unsigned int valid_sizes = 0;
int ret;
if (!input->sensor)
@@ -546,8 +546,24 @@ static int atomisp_enum_framesizes(struct file *file, void *priv,
return atomisp_enum_framesizes_crop(isp, fsize);
act_sd_state = v4l2_subdev_lock_and_get_active_state(input->sensor);
- ret = v4l2_subdev_call(input->sensor, pad, enum_frame_size,
- act_sd_state, &fse);
+ for (fse.index = 0; ; fse.index++) {
+ ret = v4l2_subdev_call(input->sensor, pad, enum_frame_size,
+ act_sd_state, &fse);
+ if (ret)
+ break;
+
+ /*
+ * Skip sizes the preview pipeline cannot output, for which
+ * atomisp_try_fmt() would return a smaller size.
+ */
+ if (asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW &&
+ (fse.max_width - pad_w > 1920 ||
+ fse.max_height - pad_h > 1440))
+ continue;
+
+ if (valid_sizes++ == fsize->index)
+ break;
+ }
if (act_sd_state)
v4l2_subdev_unlock_state(act_sd_state);
if (ret)
--
2.43.0