From: Faizel K B <faizel.kb@gmail.com>
To: Mehdi Djait <mehdi.djait@linux.intel.com>,
Michael Riesch <michael.riesch@collabora.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Heiko Stuebner <heiko@sntech.de>,
linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
libcamera-devel@lists.libcamera.org,
Robert Mader <robert.mader@collabora.com>,
Faizel K B <faizel.kb@gmail.com>
Subject: [PATCH 2/2] media: rockchip: rkcif: Honour the requested bytesperline on MIPI
Date: Thu, 5 Nov 2026 16:23:10 -0700 [thread overview]
Message-ID: <20261105232310.385463-3-faizel.kb@gmail.com> (raw)
In-Reply-To: <20261105232310.385463-1-faizel.kb@gmail.com>
The MIPI DMA uses bytesperline as the line stride, which must be a
multiple of 8 bytes, but v4l2_fill_pixfmt_mp() doesn't align it.
Any larger bytesperline requested by userspace is also replaced with
the minimum.
Align bytesperline to 8 bytes and honour a larger requested value, up
to the limit of the line width register. This allows DMA-BUF importers
that need a larger stride alignment to use the buffers directly.
Signed-off-by: Faizel K B <faizel.kb@gmail.com>
---
.../platform/rockchip/rkcif/rkcif-stream.c | 22 ++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c
index f2a24832a8cf..e50f20e40f7a 100644
--- a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c
+++ b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c
@@ -23,6 +23,7 @@
#define CIF_MIN_HEIGHT 64
#define CIF_MAX_WIDTH 8192
#define CIF_MAX_HEIGHT 8192
+#define CIF_MAX_BYTESPERLINE 0xffff8 /* VLW: 20 bits, 8-byte aligned */
static inline struct rkcif_buffer *to_rkcif_buffer(struct vb2_v4l2_buffer *vb)
{
@@ -334,20 +335,39 @@ static const struct vb2_ops rkcif_stream_vb2_ops = {
.stop_streaming = rkcif_stream_stop_streaming,
};
+static void rkcif_stream_set_bytesperline(struct v4l2_pix_format_mplane *pix,
+ u32 req_bpl)
+{
+ u32 min_bpl = ALIGN(pix->plane_fmt[0].bytesperline, 8);
+ u32 max_bpl = min_t(u32, CIF_MAX_BYTESPERLINE,
+ ALIGN_DOWN(U32_MAX / pix->height, 8));
+ u32 bpl = min_bpl;
+
+ if (req_bpl > min_bpl && req_bpl <= max_bpl)
+ bpl = ALIGN(req_bpl, 8);
+
+ pix->plane_fmt[0].bytesperline = bpl;
+ pix->plane_fmt[0].sizeimage = bpl * pix->height;
+}
+
static int rkcif_stream_fill_format(struct rkcif_stream *stream,
struct v4l2_pix_format_mplane *pix)
{
const struct rkcif_output_fmt *fmt;
- u32 height, width;
+ u32 height, width, req_bpl;
int ret;
fmt = rkcif_stream_find_output_fmt(stream, true, pix->pixelformat);
height = clamp_t(u32, pix->height, CIF_MIN_HEIGHT, CIF_MAX_HEIGHT);
width = clamp_t(u32, pix->width, CIF_MIN_WIDTH, CIF_MAX_WIDTH);
+ req_bpl = pix->plane_fmt[0].bytesperline;
ret = v4l2_fill_pixfmt_mp(pix, fmt->fourcc, width, height);
if (ret)
return ret;
+ if (stream->interface->type == RKCIF_IF_MIPI)
+ rkcif_stream_set_bytesperline(pix, req_bpl);
+
pix->field = V4L2_FIELD_NONE;
return 0;
--
2.43.0
WARNING: multiple messages have this Message-ID (diff)
From: Faizel K B <faizel.kb@gmail.com>
To: Mehdi Djait <mehdi.djait@linux.intel.com>,
Michael Riesch <michael.riesch@collabora.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Heiko Stuebner <heiko@sntech.de>,
linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
libcamera-devel@lists.libcamera.org,
Robert Mader <robert.mader@collabora.com>,
Faizel K B <faizel.kb@gmail.com>
Subject: [PATCH 2/2] media: rockchip: rkcif: Honour the requested bytesperline on MIPI
Date: Thu, 5 Nov 2026 16:23:10 -0700 [thread overview]
Message-ID: <20261105232310.385463-3-faizel.kb@gmail.com> (raw)
In-Reply-To: <20261105232310.385463-1-faizel.kb@gmail.com>
The MIPI DMA uses bytesperline as the line stride, which must be a
multiple of 8 bytes, but v4l2_fill_pixfmt_mp() doesn't align it.
Any larger bytesperline requested by userspace is also replaced with
the minimum.
Align bytesperline to 8 bytes and honour a larger requested value, up
to the limit of the line width register. This allows DMA-BUF importers
that need a larger stride alignment to use the buffers directly.
Signed-off-by: Faizel K B <faizel.kb@gmail.com>
---
.../platform/rockchip/rkcif/rkcif-stream.c | 22 ++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c
index f2a24832a8cf..e50f20e40f7a 100644
--- a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c
+++ b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c
@@ -23,6 +23,7 @@
#define CIF_MIN_HEIGHT 64
#define CIF_MAX_WIDTH 8192
#define CIF_MAX_HEIGHT 8192
+#define CIF_MAX_BYTESPERLINE 0xffff8 /* VLW: 20 bits, 8-byte aligned */
static inline struct rkcif_buffer *to_rkcif_buffer(struct vb2_v4l2_buffer *vb)
{
@@ -334,20 +335,39 @@ static const struct vb2_ops rkcif_stream_vb2_ops = {
.stop_streaming = rkcif_stream_stop_streaming,
};
+static void rkcif_stream_set_bytesperline(struct v4l2_pix_format_mplane *pix,
+ u32 req_bpl)
+{
+ u32 min_bpl = ALIGN(pix->plane_fmt[0].bytesperline, 8);
+ u32 max_bpl = min_t(u32, CIF_MAX_BYTESPERLINE,
+ ALIGN_DOWN(U32_MAX / pix->height, 8));
+ u32 bpl = min_bpl;
+
+ if (req_bpl > min_bpl && req_bpl <= max_bpl)
+ bpl = ALIGN(req_bpl, 8);
+
+ pix->plane_fmt[0].bytesperline = bpl;
+ pix->plane_fmt[0].sizeimage = bpl * pix->height;
+}
+
static int rkcif_stream_fill_format(struct rkcif_stream *stream,
struct v4l2_pix_format_mplane *pix)
{
const struct rkcif_output_fmt *fmt;
- u32 height, width;
+ u32 height, width, req_bpl;
int ret;
fmt = rkcif_stream_find_output_fmt(stream, true, pix->pixelformat);
height = clamp_t(u32, pix->height, CIF_MIN_HEIGHT, CIF_MAX_HEIGHT);
width = clamp_t(u32, pix->width, CIF_MIN_WIDTH, CIF_MAX_WIDTH);
+ req_bpl = pix->plane_fmt[0].bytesperline;
ret = v4l2_fill_pixfmt_mp(pix, fmt->fourcc, width, height);
if (ret)
return ret;
+ if (stream->interface->type == RKCIF_IF_MIPI)
+ rkcif_stream_set_bytesperline(pix, req_bpl);
+
pix->field = V4L2_FIELD_NONE;
return 0;
--
2.43.0
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2026-11-05 23:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 23:23 [PATCH 0/2] media: rockchip: rkcif: ENUM_FMT and bytesperline fixes Faizel K B
2026-11-05 23:23 ` Faizel K B
2026-11-05 23:23 ` [PATCH 1/2] media: rockchip: rkcif: Filter enumerated formats by media bus code Faizel K B
2026-11-05 23:23 ` Faizel K B
2026-11-09 12:27 ` Mehdi Djait
2026-11-09 12:27 ` Mehdi Djait
2026-11-09 19:54 ` Faizel K B
2026-11-09 19:54 ` Faizel K B
2026-11-11 9:55 ` Michael Riesch
2026-11-11 9:55 ` Michael Riesch
2026-11-05 23:23 ` Faizel K B [this message]
2026-11-05 23:23 ` [PATCH 2/2] media: rockchip: rkcif: Honour the requested bytesperline on MIPI Faizel K B
2026-11-11 9:46 ` Michael Riesch
2026-11-11 9:46 ` Michael Riesch
2026-11-12 6:20 ` Faizel K B
2026-11-12 6:20 ` Faizel K B
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=20261105232310.385463-3-faizel.kb@gmail.com \
--to=faizel.kb@gmail.com \
--cc=heiko@sntech.de \
--cc=libcamera-devel@lists.libcamera.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=mehdi.djait@linux.intel.com \
--cc=michael.riesch@collabora.com \
--cc=robert.mader@collabora.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.