* [PATCH v2 0/2] media: rockchip: rkcif: ENUM_FMT and bytesperline fixes @ 2026-11-18 20:31 Faizel K B 2026-11-18 20:31 ` [PATCH v2 1/2] media: rockchip: rkcif: Filter enumerated formats by media bus code Faizel K B 2026-11-18 20:31 ` [PATCH v2 2/2] media: rockchip: rkcif: Honour the requested bytesperline Faizel K B 0 siblings, 2 replies; 5+ messages in thread From: Faizel K B @ 2026-11-18 20:31 UTC (permalink / raw) To: Mehdi Djait, Michael Riesch Cc: Mauro Carvalho Chehab, Heiko Stuebner, linux-media, linux-rockchip, linux-arm-kernel, linux-kernel, libcamera-devel, Robert Mader, Faizel K B Two fixes for rkcif capture. Patch 1 filters VIDIOC_ENUM_FMT by the media bus code, as the video devices set V4L2_CAP_IO_MC. Patch 2 aligns bytesperline to 8 bytes and honours a larger value requested by userspace, so DMA-BUF importers that need a larger stride alignment can use the buffers directly. Tested on RK3588 (Radxa ROCK 5B+) with an IMX415 sensor, using libcamera with the GPU software ISP. The DVP part is compile-tested only. Changes in v2: - Patch 1: don't filter the DVP output formats, which have no media bus code (Mehdi) - Patch 2: handle all planes and the DVP interface, and limit the stride to the line width register of each interface (Michael) - Patch 2: drop "on MIPI" from the subject v1: https://lore.kernel.org/linux-media/20261105232310.385463-1-faizel.kb@gmail.com Faizel K B (2): media: rockchip: rkcif: Filter enumerated formats by media bus code media: rockchip: rkcif: Honour the requested bytesperline .../rockchip/rkcif/rkcif-capture-dvp.c | 4 ++ .../rockchip/rkcif/rkcif-capture-mipi.c | 3 + .../platform/rockchip/rkcif/rkcif-common.h | 1 + .../platform/rockchip/rkcif/rkcif-stream.c | 66 +++++++++++++++++-- 4 files changed, 68 insertions(+), 6 deletions(-) base-commit: 7969a6f407cf55b5254c824c87875452655ef11e -- 2.43.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] media: rockchip: rkcif: Filter enumerated formats by media bus code 2026-11-18 20:31 [PATCH v2 0/2] media: rockchip: rkcif: ENUM_FMT and bytesperline fixes Faizel K B @ 2026-11-18 20:31 ` Faizel K B 2026-11-24 10:26 ` Michael Riesch 2026-11-18 20:31 ` [PATCH v2 2/2] media: rockchip: rkcif: Honour the requested bytesperline Faizel K B 1 sibling, 1 reply; 5+ messages in thread From: Faizel K B @ 2026-11-18 20:31 UTC (permalink / raw) To: Mehdi Djait, Michael Riesch Cc: Mauro Carvalho Chehab, Heiko Stuebner, linux-media, linux-rockchip, linux-arm-kernel, linux-kernel, libcamera-devel, Robert Mader, Faizel K B VIDIOC_ENUM_FMT ignores the mbus_code field and returns all formats, although the video devices set V4L2_CAP_IO_MC. Return only the formats that match the requested media bus code. The DVP output formats have no media bus code, so they are still all returned. Otherwise userspace can pick a pixel format that doesn't match the media bus format, and then interprets the captured data in the wrong format. Signed-off-by: Faizel K B <faizel.kb@gmail.com> --- .../platform/rockchip/rkcif/rkcif-stream.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c index 3130d420ad55..b117ba57bc75 100644 --- a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c +++ b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c @@ -395,13 +395,23 @@ static int rkcif_stream_enum_formats(struct file *file, void *priv, struct v4l2_fmtdesc *f) { struct rkcif_stream *stream = video_drvdata(file); + const struct rkcif_output_fmt *fmt; + unsigned int i, n = 0; - if (f->index >= stream->out_fmts_num) - return -EINVAL; + for (i = 0; i < stream->out_fmts_num; i++) { + fmt = &stream->out_fmts[i]; - f->pixelformat = stream->out_fmts[f->index].fourcc; + if (f->mbus_code && fmt->mbus_code && + fmt->mbus_code != f->mbus_code) + continue; - return 0; + if (n++ == f->index) { + f->pixelformat = fmt->fourcc; + return 0; + } + } + + return -EINVAL; } static int rkcif_stream_enum_framesizes(struct file *file, void *fh, -- 2.43.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] media: rockchip: rkcif: Filter enumerated formats by media bus code 2026-11-18 20:31 ` [PATCH v2 1/2] media: rockchip: rkcif: Filter enumerated formats by media bus code Faizel K B @ 2026-11-24 10:26 ` Michael Riesch 0 siblings, 0 replies; 5+ messages in thread From: Michael Riesch @ 2026-11-24 10:26 UTC (permalink / raw) To: Faizel K B, Mehdi Djait Cc: Mauro Carvalho Chehab, Heiko Stuebner, linux-media, linux-rockchip, linux-arm-kernel, linux-kernel, libcamera-devel, Robert Mader Hi Faizel, Thanks for your patch. On 11/18/26 21:31, Faizel K B wrote: > VIDIOC_ENUM_FMT ignores the mbus_code field and returns all formats, > although the video devices set V4L2_CAP_IO_MC. Return only the formats > that match the requested media bus code. The DVP output formats have no > media bus code, so they are still all returned. > > Otherwise userspace can pick a pixel format that doesn't match the > media bus format, and then interprets the captured data in the wrong > format. > > Signed-off-by: Faizel K B <faizel.kb@gmail.com> Reviewed-by: Michael Riesch <michael.riesch@collabora.com> Best regards, Michael > --- > .../platform/rockchip/rkcif/rkcif-stream.c | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c > index 3130d420ad55..b117ba57bc75 100644 > --- a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c > +++ b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c > @@ -395,13 +395,23 @@ static int rkcif_stream_enum_formats(struct file *file, void *priv, > struct v4l2_fmtdesc *f) > { > struct rkcif_stream *stream = video_drvdata(file); > + const struct rkcif_output_fmt *fmt; > + unsigned int i, n = 0; > > - if (f->index >= stream->out_fmts_num) > - return -EINVAL; > + for (i = 0; i < stream->out_fmts_num; i++) { > + fmt = &stream->out_fmts[i]; > > - f->pixelformat = stream->out_fmts[f->index].fourcc; > + if (f->mbus_code && fmt->mbus_code && > + fmt->mbus_code != f->mbus_code) > + continue; > > - return 0; > + if (n++ == f->index) { > + f->pixelformat = fmt->fourcc; > + return 0; > + } > + } > + > + return -EINVAL; > } > > static int rkcif_stream_enum_framesizes(struct file *file, void *fh, ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] media: rockchip: rkcif: Honour the requested bytesperline 2026-11-18 20:31 [PATCH v2 0/2] media: rockchip: rkcif: ENUM_FMT and bytesperline fixes Faizel K B 2026-11-18 20:31 ` [PATCH v2 1/2] media: rockchip: rkcif: Filter enumerated formats by media bus code Faizel K B @ 2026-11-18 20:31 ` Faizel K B 2026-11-24 11:13 ` Michael Riesch 1 sibling, 1 reply; 5+ messages in thread From: Faizel K B @ 2026-11-18 20:31 UTC (permalink / raw) To: Mehdi Djait, Michael Riesch Cc: Mauro Carvalho Chehab, Heiko Stuebner, linux-media, linux-rockchip, linux-arm-kernel, linux-kernel, libcamera-devel, Robert Mader, Faizel K B The 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 the largest value requested for any plane, up to the limit of the line width register. The Y and UV planes share the same line width. On the DVP, program the line width from bytesperline, keeping the current value as the minimum. 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> --- .../rockchip/rkcif/rkcif-capture-dvp.c | 4 ++ .../rockchip/rkcif/rkcif-capture-mipi.c | 3 ++ .../platform/rockchip/rkcif/rkcif-common.h | 1 + .../platform/rockchip/rkcif/rkcif-stream.c | 48 ++++++++++++++++++- 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-capture-dvp.c b/drivers/media/platform/rockchip/rkcif/rkcif-capture-dvp.c index dbaf7636aeeb..64a37d6877e2 100644 --- a/drivers/media/platform/rockchip/rkcif/rkcif-capture-dvp.c +++ b/drivers/media/platform/rockchip/rkcif/rkcif-capture-dvp.c @@ -20,6 +20,8 @@ #include "rkcif-regs.h" #include "rkcif-stream.h" +#define RKCIF_DVP_MAX_BYTESPERLINE 0x7ff8 /* VIR_LINE_WIDTH: 15 bits */ + static const struct rkcif_output_fmt dvp_out_fmts[] = { { .fourcc = V4L2_PIX_FMT_NV16, @@ -689,6 +691,7 @@ static int rkcif_dvp_start_streaming(struct rkcif_stream *stream) val = stream->pix.width; if (active_in_fmt->fmt_type == RKCIF_FMT_TYPE_RAW) val = stream->pix.width * 2; + val = max(val, stream->pix.plane_fmt[0].bytesperline); rkcif_dvp_write(rkcif, RKCIF_DVP_VIR_LINE_WIDTH, val); val = RKCIF_XY_COORD(stream->pix.width, stream->pix.height); @@ -827,6 +830,7 @@ int rkcif_dvp_register(struct rkcif_device *rkcif) stream->interface = interface; stream->out_fmts = rkcif->match_data->dvp->out_fmts; stream->out_fmts_num = rkcif->match_data->dvp->out_fmts_num; + stream->max_bytesperline = RKCIF_DVP_MAX_BYTESPERLINE; stream->queue_buffer = rkcif_dvp_queue_buffer; stream->start_streaming = rkcif_dvp_start_streaming; stream->stop_streaming = rkcif_dvp_stop_streaming; diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c b/drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c index 53e62d059764..d5eaedd2c43b 100644 --- a/drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c +++ b/drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c @@ -24,6 +24,8 @@ #include "rkcif-regs.h" #include "rkcif-stream.h" +#define RKCIF_MIPI_MAX_BYTESPERLINE 0xffff8 /* VLW: 20 bits */ + #define RK3568_MIPI_CTRL0_HIGH_ALIGN BIT(31) #define RK3568_MIPI_CTRL0_UV_SWAP_EN BIT(7) #define RK3568_MIPI_CTRL0_COMPACT_EN BIT(6) @@ -1026,6 +1028,7 @@ int rkcif_mipi_register(struct rkcif_device *rkcif) stream->interface = interface; stream->out_fmts = mipi_out_fmts; stream->out_fmts_num = ARRAY_SIZE(mipi_out_fmts); + stream->max_bytesperline = RKCIF_MIPI_MAX_BYTESPERLINE; stream->queue_buffer = rkcif_mipi_queue_buffer; stream->start_streaming = rkcif_mipi_start_streaming; stream->stop_streaming = rkcif_mipi_stop_streaming; diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-common.h b/drivers/media/platform/rockchip/rkcif/rkcif-common.h index 08a213438d34..63e5a221cd73 100644 --- a/drivers/media/platform/rockchip/rkcif/rkcif-common.h +++ b/drivers/media/platform/rockchip/rkcif/rkcif-common.h @@ -145,6 +145,7 @@ struct rkcif_stream { struct rkcif_interface *interface; const struct rkcif_output_fmt *out_fmts; unsigned int out_fmts_num; + u32 max_bytesperline; /* in ping-pong mode, two buffers can be provided to the HW */ struct rkcif_buffer *buffers[2]; diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c index b117ba57bc75..f700b40ab099 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_BYTESPERLINE_ALIGN 8 static inline struct rkcif_buffer *to_rkcif_buffer(struct vb2_v4l2_buffer *vb) { @@ -334,20 +335,63 @@ static const struct vb2_ops rkcif_stream_vb2_ops = { .stop_streaming = rkcif_stream_stop_streaming, }; +static u32 rkcif_stream_plane_lines(const struct v4l2_format_info *info, + unsigned int plane, u32 height) +{ + return plane ? DIV_ROUND_UP(height, info->vdiv) : height; +} + +static void rkcif_stream_set_bytesperline(struct rkcif_stream *stream, + struct v4l2_pix_format_mplane *pix, + u32 req_bpl) +{ + const struct v4l2_format_info *info = v4l2_format_info(pix->pixelformat); + u32 bpl = pix->plane_fmt[0].bytesperline; + u32 total_lines = 0, max_bpl; + unsigned int i; + + for (i = 0; i < info->comp_planes; i++) + total_lines += rkcif_stream_plane_lines(info, i, pix->height); + + max_bpl = min(stream->max_bytesperline, + ALIGN_DOWN(U32_MAX / total_lines, CIF_BYTESPERLINE_ALIGN)); + if (req_bpl > bpl && req_bpl <= max_bpl) + bpl = ALIGN(req_bpl, CIF_BYTESPERLINE_ALIGN); + + /* The Y and UV planes share the same line width. */ + if (info->mem_planes == 1) { + pix->plane_fmt[0].bytesperline = bpl; + pix->plane_fmt[0].sizeimage = bpl * total_lines; + } else { + for (i = 0; i < info->mem_planes; i++) { + pix->plane_fmt[i].bytesperline = bpl; + pix->plane_fmt[i].sizeimage = + bpl * rkcif_stream_plane_lines(info, i, + 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 = 0; + unsigned int i; 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); - ret = v4l2_fill_pixfmt_mp(pix, fmt->fourcc, width, height); + for (i = 0; i < pix->num_planes; i++) + req_bpl = max(req_bpl, pix->plane_fmt[i].bytesperline); + ret = v4l2_fill_pixfmt_mp_aligned(pix, fmt->fourcc, width, height, + CIF_BYTESPERLINE_ALIGN); if (ret) return ret; + rkcif_stream_set_bytesperline(stream, pix, req_bpl); + pix->field = V4L2_FIELD_NONE; return 0; -- 2.43.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] media: rockchip: rkcif: Honour the requested bytesperline 2026-11-18 20:31 ` [PATCH v2 2/2] media: rockchip: rkcif: Honour the requested bytesperline Faizel K B @ 2026-11-24 11:13 ` Michael Riesch 0 siblings, 0 replies; 5+ messages in thread From: Michael Riesch @ 2026-11-24 11:13 UTC (permalink / raw) To: Faizel K B, Mehdi Djait Cc: Mauro Carvalho Chehab, Heiko Stuebner, linux-media, linux-rockchip, linux-arm-kernel, linux-kernel, libcamera-devel, Robert Mader Hi Faizel, Thanks for the patch. On 11/18/26 21:31, Faizel K B wrote: > The 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 the largest value requested > for any plane, up to the limit of the line width register. The Y and > UV planes share the same line width. On the DVP, program the line width > from bytesperline, keeping the current value as the minimum. > > 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> > --- > .../rockchip/rkcif/rkcif-capture-dvp.c | 4 ++ > .../rockchip/rkcif/rkcif-capture-mipi.c | 3 ++ > .../platform/rockchip/rkcif/rkcif-common.h | 1 + > .../platform/rockchip/rkcif/rkcif-stream.c | 48 ++++++++++++++++++- > 4 files changed, 54 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-capture-dvp.c b/drivers/media/platform/rockchip/rkcif/rkcif-capture-dvp.c > index dbaf7636aeeb..64a37d6877e2 100644 > --- a/drivers/media/platform/rockchip/rkcif/rkcif-capture-dvp.c > +++ b/drivers/media/platform/rockchip/rkcif/rkcif-capture-dvp.c > @@ -20,6 +20,8 @@ > #include "rkcif-regs.h" > #include "rkcif-stream.h" > > +#define RKCIF_DVP_MAX_BYTESPERLINE 0x7ff8 /* VIR_LINE_WIDTH: 15 bits */ > + > static const struct rkcif_output_fmt dvp_out_fmts[] = { > { > .fourcc = V4L2_PIX_FMT_NV16, > @@ -689,6 +691,7 @@ static int rkcif_dvp_start_streaming(struct rkcif_stream *stream) > val = stream->pix.width; > if (active_in_fmt->fmt_type == RKCIF_FMT_TYPE_RAW) > val = stream->pix.width * 2; > + val = max(val, stream->pix.plane_fmt[0].bytesperline); > rkcif_dvp_write(rkcif, RKCIF_DVP_VIR_LINE_WIDTH, val); > > val = RKCIF_XY_COORD(stream->pix.width, stream->pix.height); > @@ -827,6 +830,7 @@ int rkcif_dvp_register(struct rkcif_device *rkcif) > stream->interface = interface; > stream->out_fmts = rkcif->match_data->dvp->out_fmts; > stream->out_fmts_num = rkcif->match_data->dvp->out_fmts_num; > + stream->max_bytesperline = RKCIF_DVP_MAX_BYTESPERLINE; > stream->queue_buffer = rkcif_dvp_queue_buffer; > stream->start_streaming = rkcif_dvp_start_streaming; > stream->stop_streaming = rkcif_dvp_stop_streaming; > diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c b/drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c > index 53e62d059764..d5eaedd2c43b 100644 > --- a/drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c > +++ b/drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c > @@ -24,6 +24,8 @@ > #include "rkcif-regs.h" > #include "rkcif-stream.h" > > +#define RKCIF_MIPI_MAX_BYTESPERLINE 0xffff8 /* VLW: 20 bits */ > + > #define RK3568_MIPI_CTRL0_HIGH_ALIGN BIT(31) > #define RK3568_MIPI_CTRL0_UV_SWAP_EN BIT(7) > #define RK3568_MIPI_CTRL0_COMPACT_EN BIT(6) > @@ -1026,6 +1028,7 @@ int rkcif_mipi_register(struct rkcif_device *rkcif) > stream->interface = interface; > stream->out_fmts = mipi_out_fmts; > stream->out_fmts_num = ARRAY_SIZE(mipi_out_fmts); > + stream->max_bytesperline = RKCIF_MIPI_MAX_BYTESPERLINE; > stream->queue_buffer = rkcif_mipi_queue_buffer; > stream->start_streaming = rkcif_mipi_start_streaming; > stream->stop_streaming = rkcif_mipi_stop_streaming; > diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-common.h b/drivers/media/platform/rockchip/rkcif/rkcif-common.h > index 08a213438d34..63e5a221cd73 100644 > --- a/drivers/media/platform/rockchip/rkcif/rkcif-common.h > +++ b/drivers/media/platform/rockchip/rkcif/rkcif-common.h > @@ -145,6 +145,7 @@ struct rkcif_stream { > struct rkcif_interface *interface; > const struct rkcif_output_fmt *out_fmts; > unsigned int out_fmts_num; > + u32 max_bytesperline; > > /* in ping-pong mode, two buffers can be provided to the HW */ > struct rkcif_buffer *buffers[2]; > diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c > index b117ba57bc75..f700b40ab099 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_BYTESPERLINE_ALIGN 8 > > static inline struct rkcif_buffer *to_rkcif_buffer(struct vb2_v4l2_buffer *vb) > { > @@ -334,20 +335,63 @@ static const struct vb2_ops rkcif_stream_vb2_ops = { > .stop_streaming = rkcif_stream_stop_streaming, > }; > > +static u32 rkcif_stream_plane_lines(const struct v4l2_format_info *info, > + unsigned int plane, u32 height) > +{ > + return plane ? DIV_ROUND_UP(height, info->vdiv) : height; > +} Is this the same as v4l2_format_plane_height? And if yes, would it make sense to reuse this one (of course it must be made public for that)? > + > +static void rkcif_stream_set_bytesperline(struct rkcif_stream *stream, > + struct v4l2_pix_format_mplane *pix, > + u32 req_bpl) > +{ > + const struct v4l2_format_info *info = v4l2_format_info(pix->pixelformat); > + u32 bpl = pix->plane_fmt[0].bytesperline; > + u32 total_lines = 0, max_bpl; > + unsigned int i; > + > + for (i = 0; i < info->comp_planes; i++) > + total_lines += rkcif_stream_plane_lines(info, i, pix->height); Just to be on the same page: What exactly are you doing here? > + > + max_bpl = min(stream->max_bytesperline, > + ALIGN_DOWN(U32_MAX / total_lines, CIF_BYTESPERLINE_ALIGN)); > + if (req_bpl > bpl && req_bpl <= max_bpl) > + bpl = ALIGN(req_bpl, CIF_BYTESPERLINE_ALIGN); > + > + /* The Y and UV planes share the same line width. */ > + if (info->mem_planes == 1) { > + pix->plane_fmt[0].bytesperline = bpl; > + pix->plane_fmt[0].sizeimage = bpl * total_lines; > + } else { > + for (i = 0; i < info->mem_planes; i++) { > + pix->plane_fmt[i].bytesperline = bpl; > + pix->plane_fmt[i].sizeimage = > + bpl * rkcif_stream_plane_lines(info, i, > + pix->height); v4l2_format_plane_size? > + } > + } > +} > + > 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 = 0; > + unsigned int i; > 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); > - ret = v4l2_fill_pixfmt_mp(pix, fmt->fourcc, width, height); > + for (i = 0; i < pix->num_planes; i++) > + req_bpl = max(req_bpl, pix->plane_fmt[i].bytesperline); > + ret = v4l2_fill_pixfmt_mp_aligned(pix, fmt->fourcc, width, height, > + CIF_BYTESPERLINE_ALIGN); > if (ret) > return ret; > > + rkcif_stream_set_bytesperline(stream, pix, req_bpl); Wouldn't calling v4l2_fill_pixfmt_mp_aligned(pix, fmt->fourcc, width, height, req_bpl) do the trick? In summary: I think this is a common problem, so there should be a common solution. Reuse helpers, or extend them if required. Best regards, Michael > + > pix->field = V4L2_FIELD_NONE; > > return 0; ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-24 11:13 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-11-18 20:31 [PATCH v2 0/2] media: rockchip: rkcif: ENUM_FMT and bytesperline fixes Faizel K B 2026-11-18 20:31 ` [PATCH v2 1/2] media: rockchip: rkcif: Filter enumerated formats by media bus code Faizel K B 2026-11-24 10:26 ` Michael Riesch 2026-11-18 20:31 ` [PATCH v2 2/2] media: rockchip: rkcif: Honour the requested bytesperline Faizel K B 2026-11-24 11:13 ` Michael Riesch
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®