* [PATCH] media: vimc: capture: support custom bytesperline values
@ 2025-11-03 6:30 Pavan Bobba
0 siblings, 0 replies; only message in thread
From: Pavan Bobba @ 2025-11-03 6:30 UTC (permalink / raw)
To: skhan, kieran.bingham, mchehab; +Cc: linux-media, linux-kernel, Pavan Bobba
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-11-03 6:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-03 6:30 [PATCH] media: vimc: capture: support custom bytesperline values Pavan Bobba
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).