From: Volodymyr Chapman <volodymyrchapman@gmail.com>
To: Hans de Goede <hansg@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
Andy Shevchenko <andy@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org,
Volodymyr Chapman <volodymyrchapman@gmail.com>
Subject: [PATCH 1/2] media: atomisp: Don't enumerate frame sizes the preview pipe can't output
Date: Mon, 16 Nov 2026 17:57:49 +0000 [thread overview]
Message-ID: <20261116175750.21905-2-volodymyrchapman@gmail.com> (raw)
In-Reply-To: <20261116175750.21905-1-volodymyrchapman@gmail.com>
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@gmail.com>
---
.../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
next prev parent reply other threads:[~2026-11-16 17:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 17:57 [PATCH 0/2] media: atomisp: Fix PipeWire/Firefox streaming for sensors without crop or frame interval support Volodymyr Chapman
2026-11-16 17:57 ` Volodymyr Chapman [this message]
2026-11-17 10:31 ` [PATCH 1/2] media: atomisp: Don't enumerate frame sizes the preview pipe can't output Andy Shevchenko
2026-11-16 17:57 ` [PATCH 2/2] media: atomisp: Report frame interval for sensors without enum_frame_interval Volodymyr Chapman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116175750.21905-2-volodymyrchapman@gmail.com \
--to=volodymyrchapman@gmail.com \
--cc=andy@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®