From: Pavan Bobba <opensource206@gmail.com>
To: skhan@linuxfoundation.org, kieran.bingham@ideasonboard.com,
mchehab@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
Pavan Bobba <opensource206@gmail.com>
Subject: [PATCH 4/5] media: vimc: capture: support custom bytesperline values
Date: Thu, 20 Nov 2025 14:19:25 +0530 [thread overview]
Message-ID: <20251120084926.18620-5-opensource206@gmail.com> (raw)
In-Reply-To: <20251120084926.18620-1-opensource206@gmail.com>
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
next prev parent reply other threads:[~2025-11-20 8:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 8:49 [PATCH 0/5] media: vimc: add RGB/YUV input entity and improve pipeline support Pavan Bobba
2025-11-20 8:49 ` [PATCH 1/5] media: vimc: add RGB/YUV input entity implementation Pavan Bobba
2025-11-20 8:49 ` [PATCH 2/5] media: vimc: add support for V4L2_FIELD_ALTERNATE in vimc-sensor Pavan Bobba
2025-11-20 8:49 ` [PATCH 3/5] media: vimc: debayer: add support for multiple RGB formats Pavan Bobba
2025-11-20 8:49 ` Pavan Bobba [this message]
2025-11-20 8:49 ` [PATCH 5/5] docs: media: vimc: document RGB/YUV input entity Pavan Bobba
2025-11-20 16:38 ` [PATCH 0/5] media: vimc: add RGB/YUV input entity and improve pipeline support Shuah Khan
2025-11-28 3:11 ` opensource india
2025-12-09 5:04 ` opensource india
2025-12-15 19:10 ` Shuah Khan
2025-12-15 19:45 ` Shuah Khan
2025-12-16 2:57 ` opensource india
2025-12-29 16:04 ` opensource india
2025-12-31 20:43 ` Shuah Khan
2026-01-01 1:11 ` opensource india
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=20251120084926.18620-5-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).