From patchwork Wed Nov 18 20:31:33 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: 29038 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 2D674C3304 for ; Wed, 18 Nov 2026 20:33:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D79726A920; Wed, 18 Nov 2026 21:33:55 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="wShnzNkp"; dkim-atps=neutral Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E9BE6A90A for ; Wed, 18 Nov 2026 21:33:53 +0100 (CET) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-8b5e147f101so170132b3a.3 for ; Wed, 18 Nov 2026 12:33:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795034032; x=1795638832; 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=YixFM3AWmT7jYQ+cnCQNR8AFTxM/A/eG60HgEXpPHIc=; b=wShnzNkp4mg6CI3YHTPWcKGtD0JF+0iKtsvffsosE7XTQ2LdMOoviKfE6k67aJWIu/ J4CGKZUIku1v5WN8J42+d8ToD8HdiPR39qAuswQlmLm+FJ6KuT+5ej5mEElJU81JvqtW ajiuksXD6Ie6B0qu1HZc9uLAcbeMOCJfXDL+7II7iHYAAdRe2uYaCxMEzUG3ps0X34W8 PiZ/OjaEMCEXg3+rDK4X1ACIJQVeXThjiuljCSSmK6EYRaGXrTcRzj9XuTBZDW6EGzRT L16UFYLcfg6NswE9IGfVrvXSwFJLZITc8kE1eM0ZGq1t3xCYqvcu2tLecdAH6t5f0g+S DWkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795034032; x=1795638832; 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=YixFM3AWmT7jYQ+cnCQNR8AFTxM/A/eG60HgEXpPHIc=; b=zrbPGNTNuYFZZt67xXudrow/kZAM0JISlAiM8ewLwtdbWULpm8l/3AdTox6Uavgqa/ NBDWvKtbSyK+1/IS6Ro/2CH4ePnvDEIsNMtH3s5g2mDbQeh+l+SQwzxwVzPj4PpLp9w9 Kf1qHeuPv7ZYPeL4xZwC60azFw//d5+hSPPOGSIO2ffZDNyOFk6SwjWElrJsAZxoGqWV fW1FwW3W6UYV4UAtiwh5zU6rd3tPKDkgLvcY3oA/ROQjVyYg2IjavZ4vDr/xMK1324A9 dE6vGZEPFNBbNX09vpY39mwToUJ3kh+Sa9DinksXSVlfhfvkZbLgfWRd8T8Sjo9aVV1C 2PyA== X-Forwarded-Encrypted: i=1; AL+hErGNGvn3pSIvPGKhoo00f5lqJ9JH8aOKKCPILZt+dt+7opqiEcaXqSXTOhJsMYw5RZpmrigA1H/eEVFxCstzveQ=@lists.libcamera.org X-Gm-Message-State: APuU4Z//fqPv+DkAFyUNja1BZ3A6i+0LdMB6TBLhERkru3QUaBn/PO01 666sWlsQOAQ2PTZwvf6m+/4MullGZ6QzeW7BZ3ZdThuqQfRIho57IbeQ X-Gm-Gg: AZFdTZeD1MuEIpR1Pmqw6ZC9mMMQHCBCOaRT8UOov4WhSwHSwBQINGd2E/NE/VmAVRd 0cX98LzyyHf5nUJsOwdFRl8a15sXbkRpDWGu8X6Vw0hT8Vadrd1z1DJhLIMtnjovvNeAt3l6YGD OUDGFnHGXOFiE2VZqIFBhkdEhfxyfrzqYEFmQL+ro54AdZO7T37JQrpeSmjpI2YeSrIpDlGCcaL +omG692H8GoZjYzpYHVPeem67TlnXBX71EC1esWBqc08XHRa0B/JLXa1wNVOw2qxe0OzEA/aXE4 IfVC1OMeY5yfWrcXYjRGlR9qBIRrLMc0PRx0nLa5Vqo+zswfL0ubc9Fqc2xsibclDyr5lgeQbgx ELAZTwEYTSHMpjrEYtgs89IGG+z0mvKhKzARzf2gMcHaLk/RlYd/U4PDiJQJjPIhRzsV1nD+KGt PCc6XwclOPkTrW7Cv6SJBh+vb+8kqaVMXduPu6x2v6a8PvNzfuKXxrUx+rM6VduDjtYmQYb9D85 e9oJ5CslicpT5LENiy51vgL25vLam2UM5hrCrOzbf3zbxZRwIgpCsqt3T+LwpIpF8cAl7ii24Qq MWHt2mv4dR5g5015l30b+ELWBOG6yb7BqFvrAF1V0qu1WGk6wQW/39UoZBfoFw== X-Received: by 2002:a17:902:e888:b0:2ed:29a5:782d with SMTP id d9443c01a7336-2eff72e15f0mr59296815ad.2.1795034031819; Wed, 18 Nov 2026 12:33:51 -0800 (PST) Received: from FAIZEL-KB.. ([2001:569:52f5:4b00:cfaf:4885:b023:6316]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-2eff6116331sm19166825ad.22.2026.11.18.12.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2026 12:33:51 -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 v2 1/2] media: rockchip: rkcif: Filter enumerated formats by media bus code Date: Wed, 18 Nov 2026 13:31:33 -0700 Message-ID: <20261118203134.315591-2-faizel.kb@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261118203134.315591-1-faizel.kb@gmail.com> References: <20261118203134.315591-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" 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 --- .../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, From patchwork Wed Nov 18 20:31:34 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: 29039 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 B8462C3304 for ; Wed, 18 Nov 2026 20:33:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 71A406A919; Wed, 18 Nov 2026 21:33:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="b2xLc4wZ"; dkim-atps=neutral Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 01B8C6A90A for ; Wed, 18 Nov 2026 21:33:57 +0100 (CET) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-2eb33b5c067so1119115ad.1 for ; Wed, 18 Nov 2026 12:33:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795034035; x=1795638835; 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=y75oxAwlO6c2EjPrPmHn9WTGzz0GY9XzQAVscbqDFeA=; b=b2xLc4wZfUpUXLZ6crHWPuhCQp6bjaj2JJUJ/tVR69Da020QOG19TvW/tLr1PwxPCV v73wE9r12fPvCHpVO30xSrNjO7oYICkvZLdZUvCYutdp71AswL6oT+6xl/pU9PXvH48E Q8kpQKdPgClGMUkcr0LEK8SV/Q5E3M8TbwePRuhr7p11FeGppkwhZ6ZyYG6YbnY44Ro8 ik54s8C+fhnvPe7DPPanqgDZXzHQgalmyWZy+POgiUn+dCzzay1q8XWmof1BlUQQgWVI jrf6B8r30NwTiaV3iHZQ482sORw3zg1sw8CFKwfonNJ5jFALazCjHozuuRNSde3gVN1E VC2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795034035; x=1795638835; 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=y75oxAwlO6c2EjPrPmHn9WTGzz0GY9XzQAVscbqDFeA=; b=05hguL9zvNa9gG/fais7eV1PIYMC+zBdqXcCP7wMCJx1+Gok76OR7rh43knJADu3iE gQDomY5mDyovqAXRgReIMEqrFGP79/mqzPJcf59Dv9InWJhE1M7+GUxzOGSj5RKMt55Z qgOdx0ybiGkOttDg+JLsTlx0MVcnXEW8D+RsKK1Mv+GExs54we9969uKuRNKZoZSUxMY IadcIk7dFclvB6radY1T9vwsbRGU4+kotH4ezDC1EMSV/oqa80bhNXmiG/6OkxvDrGWh WHPhUYrryfXibK+mI1dV7fLnqo7XnJuByMRQ11fKxLtuH+IlsgcW1vmNvesVLSR8pao/ 8M7A== X-Forwarded-Encrypted: i=1; AL+hErHvKsAtqOM3d3WmOYcPqJcWEOlkSihXtrH647iqukarHQg7AGAcVwoIt9RJsljsy09Eydnbg5CVIq6QyemxOGU=@lists.libcamera.org X-Gm-Message-State: APuU4Z9laa1J34JBb+74J/4xhCXrcZBmeCfQY7SiJTtfj14soNV+/YAL 2FaRQ8Y3nvfhVw+Vs4HTDu53mRpCZBcI3/NdvDCkPDQ5fpweHIHCwM6c0yWNaYKz X-Gm-Gg: AZFdTZfXk1+m7B2MnDbmSSSN/6PEjVTCAjPDy4JDisnI9+PiwAlvnR0if4Se+c8YnxE cjED1ny1+9rvsP64eNz9JjbLkkkNckM6r2CKSDzu1Ysk2sVGi5Y/E3v3uaogeSh0I61OcLy2Hvz PWIS9uTZh+VbrTch32hySkB7lxUZSwlSiu7VUuPkmv3Iqr8t2TfIYRcobyCoCTIWj4p12YzLG8j uPB4YinpZy/cJkj6CiM+ZMPRDKotbRKfJrOGhCsq51VtBIzJf1vMU80+VYY6rPkujf+lFqSB4aM wy9G7+5z3QLoXJWsls5UV8A3vJe4xGpfftb+Eh10rp5fDrAzJUNkbgOwMZZDIEbdCJ/dgm530G1 FhzsuvGYCEMgv47OWxekrFcjHcFzo/qwUk4gjh5UKfW0Zh0SE5ZefIQ1Hwairgoz8kwkU44UB9p Q7C6tyUceVHkHwc22VKjhW7KZMCxUwq/sLNu88f2VJ9A5FjsnJ6TxQaniaMpmYAPRQ8e6iDYpU7 nqGVXZU41lVaHL/3IyFK43hDES5hZy89ei4VOAyqaz+VIUkNGL/5ae2yHlnCwYVTjYPaEFwsksv lai7q6ZQ9eki4OBOzDgaHpoPhS/y2oKSOng2Ysyrx2CZjdMzn0gGrBrciCRLukFBBxMWDskyjnZ TiLDz7NU= X-Received: by 2002:a17:903:2b0d:b0:2ef:d8ce:83e6 with SMTP id d9443c01a7336-2eff6f850b2mr56986735ad.0.1795034035036; Wed, 18 Nov 2026 12:33:55 -0800 (PST) Received: from FAIZEL-KB.. ([2001:569:52f5:4b00:cfaf:4885:b023:6316]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-2eff6116331sm19166825ad.22.2026.11.18.12.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2026 12:33:54 -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 v2 2/2] media: rockchip: rkcif: Honour the requested bytesperline Date: Wed, 18 Nov 2026 13:31:34 -0700 Message-ID: <20261118203134.315591-3-faizel.kb@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261118203134.315591-1-faizel.kb@gmail.com> References: <20261118203134.315591-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 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 --- .../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;