From: Pavan Bobba <opensource206@gmail.com>
To: skhan@linuxfoundation.org, kieran.bingham@ideasonboard.com,
mchehab@kernel.org
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Pavan Bobba <opensource206@gmail.com>
Subject: [PATCH] media: vimc: capture: support custom bytesperline values
Date: Mon, 3 Nov 2025 12:00:27 +0530 [thread overview]
Message-ID: <20251103063027.31858-1-opensource206@gmail.com> (raw)
Allow userspace to request custom bytesperline (stride) values in the
vimc capture driver. The driver now clamps the requested value to a
valid range instead of forcing a fixed stride.
The minimum bytesperline is width * bytes_per_pixel, while the maximum
is limited by VIMC_FRAME_MAX_WIDTH * bytes_per_pixel. This makes the
virtual capture node behave more like real hardware that supports
aligned or padded scanlines.
Signed-off-by: Pavan Bobba <opensource206@gmail.com>
---
drivers/media/test-drivers/vimc/vimc-capture.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media/test-drivers/vimc/vimc-capture.c
index 7f6124025fc9..7164ec51eb80 100644
--- a/drivers/media/test-drivers/vimc/vimc-capture.c
+++ b/drivers/media/test-drivers/vimc/vimc-capture.c
@@ -85,6 +85,7 @@ static int vimc_capture_try_fmt_vid_cap(struct file *file, void *priv,
{
struct v4l2_pix_format *format = &f->fmt.pix;
const struct vimc_pix_map *vpix;
+ u32 min_bpl, max_bpl;
format->width = clamp_t(u32, format->width, VIMC_FRAME_MIN_WIDTH,
VIMC_FRAME_MAX_WIDTH) & ~1;
@@ -97,8 +98,18 @@ static int vimc_capture_try_fmt_vid_cap(struct file *file, void *priv,
format->pixelformat = fmt_default.pixelformat;
vpix = vimc_pix_map_by_pixelformat(format->pixelformat);
}
- /* TODO: Add support for custom bytesperline values */
- format->bytesperline = format->width * vpix->bpp;
+
+ /* Calculate the minimum supported bytesperline value */
+ min_bpl = format->width * vpix->bpp;
+ /* Calculate the maximum supported bytesperline value */
+ max_bpl = VIMC_FRAME_MAX_WIDTH * vpix->bpp;
+
+ /* Clamp bytesperline to the valid range */
+ if (format->bytesperline > max_bpl)
+ format->bytesperline = max_bpl;
+ if (format->bytesperline < min_bpl)
+ format->bytesperline = min_bpl;
+
format->sizeimage = format->bytesperline * format->height;
if (format->field == V4L2_FIELD_ANY)
--
2.43.0
reply other threads:[~2025-11-03 6:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20251103063027.31858-1-opensource206@gmail.com \
--to=opensource206@gmail.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=skhan@linuxfoundation.org \
/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;
as well as URLs for NNTP newsgroup(s).