[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251120084926.18620-5-opensource206@gmail.com>
Date: Thu, 20 Nov 2025 14:19:25 +0530
From: Pavan Bobba <opensource206@...il.com>
To: skhan@...uxfoundation.org,
kieran.bingham@...asonboard.com,
mchehab@...nel.org
Cc: linux-kernel@...r.kernel.org,
linux-media@...r.kernel.org,
Pavan Bobba <opensource206@...il.com>
Subject: [PATCH 4/5] media: vimc: capture: support custom bytesperline values
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@...il.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
Powered by blists - more mailing lists