From patchwork Thu Nov 5 23:23:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faizel K B X-Patchwork-Id: 28780 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CF559C3307 for ; Thu, 5 Nov 2026 23:23:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8708E6A7C6; Fri, 6 Nov 2026 00:23:44 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mtrK0iNe"; dkim-atps=neutral Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 74D886A7BC for ; Fri, 6 Nov 2026 00:23:41 +0100 (CET) Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-3b0b8b5d28cso11837a91.1 for ; Thu, 05 Nov 2026 15:23:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793921020; x=1794525820; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0qFTCorgq4hyV4vVhWj25+4lzr8cjg0FBjQeaIcgYqM=; b=mtrK0iNebvjn85zC2CO5LzDfSgYmBLSIWPhlZytBgJ8zy7yK0QFt4N6jyUir4xaEn2 SoaQOOLrqqhATlVUjej7y6aTvL+qaaqSHVQ8RcnibECRdDGVKALKp1dEB95/b1IELWbx yQls8ML2fqr8VHv6l95/oXt8dg3A9rNFQaULK2NnlYGIHgnSr5L0PkbA0PixEIlCUMM0 zyG3bWWK1/mb4zmkAGoHSYMsYjoarSkhH/MYQ7DIDMdRiwDqXLBci7zC/jTs8Q7MrRtQ erEMAqCu8+nkaBQcyGlEpqm6HXflGoH3eZU9DrAJfTfNNnCn3jrAiFKrmbR1rZC8Sxcb akDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793921020; x=1794525820; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=0qFTCorgq4hyV4vVhWj25+4lzr8cjg0FBjQeaIcgYqM=; b=Z9UUOXOyb493tkxlAiaAqAMhHHDCRbiS7XfCsOX8PtHzue+fxXngBBTiY6hq38CTV+ nCT3HJSQq6a1AQPoz4NnD5xAxcseQPurycOWIgw4ZBwIIVJu0IygkCJ2kLn3WwGe+p3D iOlnYtfTpGiSA7RhtSkqzQC57zetX2hVdOVzEGcxw5NKk7mZuo+F1IepJBtvl7L5mdI2 2GoHHPhbRcmOLW1oapqSjUQ4p4xtsB7tz5xWKFKIbkKW+O8hYJ1ckbeIDnLBKWdJqegj OvfdcBkHgVrSRPn/eOA4sW64ruzf2LN2Pkyy1SeXEvexbZ0HupQ8IELmIXbq932Xj9p3 z/ZA== X-Forwarded-Encrypted: i=1; AKwUvBww2fHIkRdypHae9e+k97VSVc0Y2dPgrP2dIqJ71lHU3dxkqtq9v6lVHBeZWl8+kFdrnc/W5IPV0aMEB+n7ThE=@lists.libcamera.org X-Gm-Message-State: APuU4Z+JRrBFg+QNdpi5i3hkoPq3LeGmAIGZKoWZraicNXWkBHYRNp8h ZsoG34g0+rpA+kXYtR3Wk1z909SnbD+5um/FYIE8+w9p/baJQbus4NGY X-Gm-Gg: AYBFou028ilBwA9VeZekQTl2M9ef1RjOHHoytJA406fMh6rIp2i0TajJfdf06EK6AH/ phvXAXeG+FPQ6Oef8/IH+5d9kq+MMpSSLpsCWFyyDeAxKWbTf2mIzhNKrzLhSo+236H/tGXHAED /ys/RskFwvopF/S/3ZhwjErOkrO3+xCQn4cB5HgUtIUefcV5ucl/wJi5AXOCY8v09RqNaVsaX+f tHIPo2CzJGdbgRnZwrJq5svv4DcWoBqUJ7GjruC/RmjbiC58+O40eYRXXafFJ+0RjyCFbmg8/Fp oMbbr3jeKBKc7DyJuwn+TUUZfij6lRW7ynNxkehBNrw2eEelvFbZTUdyUGJYLE9ELrWaMAi1/2Q cL+xtKt1LjzRoDsNtdlf94vTX/C1UzfKzGDmFoudY5r0++lL9t5PMlJFyg4zPEHvvyxfAoqm3Qy FNz6Py/A5nwkcIewJTfvmdapDl9nM49Yg64JyTyFbLuBNfnhFErnraGQH2T1TiiDgVVkS83+NYq 2wO7lb3Q3IIG6mWUQr2e8HYJES7/TXQ/LViWwGhysxlKfjF8Qwa6EhdkZTY+9qXJxnTDexI2avF Mc8JubITRuNKASMz2QFw1d71H8hRvRx5NdTOgS3fC2qpaJi2otCpoxusCvFHfQ== X-Received: by 2002:a17:90b:1e4f:b0:3ac:9c37:9422 with SMTP id 98e67ed59e1d1-3b0db62690dmr1018448a91.2.1793921019958; Thu, 05 Nov 2026 15:23:39 -0800 (PST) Received: from FAIZEL-KB.. ([2001:569:5b64:e100:f564:53e0:ae9d:9600]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-3b0b323cd3csm5317297a91.3.2026.11.05.15.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 15:23:39 -0800 (PST) From: Faizel K B To: Mehdi Djait , Michael Riesch Cc: Mauro Carvalho Chehab , Heiko Stuebner , 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 , Faizel K B Subject: [PATCH 2/2] media: rockchip: rkcif: Honour the requested bytesperline on MIPI Date: Thu, 5 Nov 2026 16:23:10 -0700 Message-ID: <20261105232310.385463-3-faizel.kb@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261105232310.385463-1-faizel.kb@gmail.com> References: <20261105232310.385463-1-faizel.kb@gmail.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 --- .../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;