[v2,1/3] media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt
Message ID | 20230418071439.197735-2-alexander.stein@ew.tq-group.com (mailing list archive) |
---|---|
State | Accepted |
Headers |
Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from <linux-media-owner@vger.kernel.org>) id 1pofYG-003ynl-42; Tue, 18 Apr 2023 07:14:56 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231248AbjDRHOy (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Tue, 18 Apr 2023 03:14:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231223AbjDRHOw (ORCPT <rfc822;linux-media@vger.kernel.org>); Tue, 18 Apr 2023 03:14:52 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6477F1BFD for <linux-media@vger.kernel.org>; Tue, 18 Apr 2023 00:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1681802091; x=1713338091; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1LBMrWhnNp6GUM6Z+YxFtJgIM77IK2VB5D8IaBgDDtc=; b=DKNvuHs3yUNBVgXNKfqPmDbHNYL3ooUAFW5tefgDSd0kXD/cpDeOO12Z I5BddM+fDHA7618AWqax567eX65fcrcGhqYQnVIUB8i8rDuXJvdZntWkr lHmGbRFX8FvJiscW7G3Y7KW21jByuLtrOtBfucDbtgzpE4yd7I6xEaeL2 tlOHjw3LuP1xQZmRm0AdCZri3cWN2ONNat9mWWeoDmhj6WGXVsU/eYX94 eURjnfP/1AmGd89xmb0r9JsRqWJimFMaglBMMNM/1felKfa+1CMKBPE44 Bkxh87thVVytZ+XuJhjrNPbpQcNLvpsAo+V/nO9ltn8/0e85O9Xij+wN4 Q==; X-IronPort-AV: E=Sophos;i="5.99,206,1677538800"; d="scan'208";a="30385553" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 18 Apr 2023 09:14:46 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Tue, 18 Apr 2023 09:14:47 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Tue, 18 Apr 2023 09:14:47 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1681802086; x=1713338086; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1LBMrWhnNp6GUM6Z+YxFtJgIM77IK2VB5D8IaBgDDtc=; b=di5EfUCIWmp3wqPRtOdf0ivso9vRA3948K+suBhs+ZgcH2JCTRTx+fEe IdXjtERUMxOdeP/MYgJ3aANIUcSmemXKgKqGXjeTkwlIksc4td3nzNwCb ETbzA0l7mSkkKnel91hckEZhSMSVX0Nd0meODDd9QPbdb3cKEnOQH53vE tmoWdTmAW19OF5/JRjivLt1KIyATa5YFeaGrj4hi7wN8k7zo8B/KwXr/R b71y5SIZ/baOgLQ4nYDTsiqttB8IknckHHEVWW51IMy6eCQ9xxmBCa9uU /JVP+5e0hCqBR3Z48EtTKIatmi/IPXD/QvhxcwZf9Y3Vk7h4Kx93be4zo Q==; X-IronPort-AV: E=Sophos;i="5.99,206,1677538800"; d="scan'208";a="30385551" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 18 Apr 2023 09:14:46 +0200 Received: from steina-w.tq-net.de (unknown [10.123.53.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id 98C66280072; Tue, 18 Apr 2023 09:14:46 +0200 (CEST) From: Alexander Stein <alexander.stein@ew.tq-group.com> To: Rui Miguel Silva <rmfrfs@gmail.com>, Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Shawn Guo <shawnguo@kernel.org>, Sascha Hauer <s.hauer@pengutronix.de>, Fabio Estevam <festevam@gmail.com> Cc: Alexander Stein <alexander.stein@ew.tq-group.com>, Pengutronix Kernel Team <kernel@pengutronix.de>, NXP Linux Team <linux-imx@nxp.com>, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 1/3] media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt Date: Tue, 18 Apr 2023 09:14:37 +0200 Message-Id: <20230418071439.197735-2-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418071439.197735-1-alexander.stein@ew.tq-group.com> References: <20230418071439.197735-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -2.4 (--) X-LSpam-Report: No, score=-2.4 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1 autolearn=ham autolearn_force=no |
Series |
Fix imx7-media-csi format settings
|
|
Commit Message
Alexander Stein
April 18, 2023, 7:14 a.m. UTC
There is no need to convert input pixformat to mbus_framefmt and back
again. Instead apply pixformat width contrains directly.
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
drivers/media/platform/nxp/imx7-media-csi.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
Comments
Hi Alexander, Thank you for the patch. On Tue, Apr 18, 2023 at 09:14:37AM +0200, Alexander Stein wrote: > There is no need to convert input pixformat to mbus_framefmt and back > again. Instead apply pixformat width contrains directly. > > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> > --- > drivers/media/platform/nxp/imx7-media-csi.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c > index b701e823436a8..bd649fd9166fd 100644 > --- a/drivers/media/platform/nxp/imx7-media-csi.c > +++ b/drivers/media/platform/nxp/imx7-media-csi.c > @@ -1145,8 +1145,8 @@ static const struct imx7_csi_pixfmt * > __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, > struct v4l2_rect *compose) > { > - struct v4l2_mbus_framefmt fmt_src; > const struct imx7_csi_pixfmt *cc; > + u32 stride; > > /* > * Find the pixel format, default to the first supported format if not > @@ -1172,12 +1172,16 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, > } > } > > - v4l2_fill_mbus_format(&fmt_src, pixfmt, 0); > - imx7_csi_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc); Could you please keep the comment from imx7_csi_mbus_fmt_to_pix_fmt() here, to indicate where the alignment comes from ? /* Round up width for minimum burst size */ We should likely revisit this in the future, I don't think the alignment is actually needed. This could be recorded already: /* * Round up width for minimum burst size. * * TODO: Implement configurable stride support, and check what the real * hardware alignment constraint on the width is. */ > + v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8, > + &pixfmt->height, 1, 0xffff, 1, 0); > + > + stride = round_up((pixfmt->width * cc->bpp) / 8, 8); You can drop the round_up(), as pixfmt->width is now a multiple of 8, so pixfmt->bytesperline = pixfmt->width * cc->bpp / 8; > + pixfmt->bytesperline = stride; > + pixfmt->sizeimage = stride * pixfmt->height; > > if (compose) { > - compose->width = fmt_src.width; > - compose->height = fmt_src.height; > + compose->width = pixfmt->width; This is a change of behaviour, compose->width used to be set to the unaligned width. > + compose->height = pixfmt->height; > } > > return cc;
Hi Laurent, thanks or your feedback. Am Dienstag, 18. April 2023, 11:27:13 CEST schrieb Laurent Pinchart: > Hi Alexander, > > Thank you for the patch. > > On Tue, Apr 18, 2023 at 09:14:37AM +0200, Alexander Stein wrote: > > There is no need to convert input pixformat to mbus_framefmt and back > > again. Instead apply pixformat width contrains directly. > > > > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> > > --- > > > > drivers/media/platform/nxp/imx7-media-csi.c | 14 +++++++++----- > > 1 file changed, 9 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/media/platform/nxp/imx7-media-csi.c > > b/drivers/media/platform/nxp/imx7-media-csi.c index > > b701e823436a8..bd649fd9166fd 100644 > > --- a/drivers/media/platform/nxp/imx7-media-csi.c > > +++ b/drivers/media/platform/nxp/imx7-media-csi.c > > @@ -1145,8 +1145,8 @@ static const struct imx7_csi_pixfmt * > > > > __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, > > > > struct v4l2_rect *compose) > > > > { > > > > - struct v4l2_mbus_framefmt fmt_src; > > > > const struct imx7_csi_pixfmt *cc; > > > > + u32 stride; > > > > /* > > > > * Find the pixel format, default to the first supported format if not > > > > @@ -1172,12 +1172,16 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format > > *pixfmt,> > > } > > > > } > > > > - v4l2_fill_mbus_format(&fmt_src, pixfmt, 0); > > - imx7_csi_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc); > > Could you please keep the comment from imx7_csi_mbus_fmt_to_pix_fmt() > here, to indicate where the alignment comes from ? Sure, why not. > /* Round up width for minimum burst size */ > > We should likely revisit this in the future, I don't think the alignment > is actually needed. This could be recorded already: > > /* > * Round up width for minimum burst size. > * > * TODO: Implement configurable stride support, and check what the real > * hardware alignment constraint on the width is. > */ Sounds good. I was already suspecting actual stride support is not supported, as FBUF_PARA is set to 0 (in non-interlaced mode). > > + v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8, > > + &pixfmt->height, 1, 0xffff, 1, 0); > > + > > + stride = round_up((pixfmt->width * cc->bpp) / 8, 8); > > You can drop the round_up(), as pixfmt->width is now a multiple of 8, so > > pixfmt->bytesperline = pixfmt->width * cc->bpp / 8; But that is only identical if cc->bpp == 8, or am I missing something here? > > + pixfmt->bytesperline = stride; > > + pixfmt->sizeimage = stride * pixfmt->height; > > > > if (compose) { > > > > - compose->width = fmt_src.width; > > - compose->height = fmt_src.height; > > + compose->width = pixfmt->width; > > This is a change of behaviour, compose->width used to be set to the > unaligned width. Oh, you are right. I'll fix that. Best regards, Alexander > > + compose->height = pixfmt->height; > > > > } > > > > return cc;
Hi Alexander, On Tue, Apr 18, 2023 at 12:00:43PM +0200, Alexander Stein wrote: > Am Dienstag, 18. April 2023, 11:27:13 CEST schrieb Laurent Pinchart: > > On Tue, Apr 18, 2023 at 09:14:37AM +0200, Alexander Stein wrote: > > > There is no need to convert input pixformat to mbus_framefmt and back > > > again. Instead apply pixformat width contrains directly. > > > > > > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> > > > --- > > > > > > drivers/media/platform/nxp/imx7-media-csi.c | 14 +++++++++----- > > > 1 file changed, 9 insertions(+), 5 deletions(-) > > > > > > diff --git a/drivers/media/platform/nxp/imx7-media-csi.c > > > b/drivers/media/platform/nxp/imx7-media-csi.c index > > > b701e823436a8..bd649fd9166fd 100644 > > > --- a/drivers/media/platform/nxp/imx7-media-csi.c > > > +++ b/drivers/media/platform/nxp/imx7-media-csi.c > > > @@ -1145,8 +1145,8 @@ static const struct imx7_csi_pixfmt * > > > __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, > > > struct v4l2_rect *compose) > > > { > > > - struct v4l2_mbus_framefmt fmt_src; > > > const struct imx7_csi_pixfmt *cc; > > > + u32 stride; > > > > > > /* > > > * Find the pixel format, default to the first supported format if not > > > @@ -1172,12 +1172,16 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, > > > } > > > } > > > > > > - v4l2_fill_mbus_format(&fmt_src, pixfmt, 0); > > > - imx7_csi_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc); > > > > Could you please keep the comment from imx7_csi_mbus_fmt_to_pix_fmt() > > here, to indicate where the alignment comes from ? > > Sure, why not. > > > /* Round up width for minimum burst size */ > > > > We should likely revisit this in the future, I don't think the alignment > > is actually needed. This could be recorded already: > > > > /* > > * Round up width for minimum burst size. > > * > > * TODO: Implement configurable stride support, and check what the real > > * hardware alignment constraint on the width is. > > */ > > Sounds good. I was already suspecting actual stride support is not supported, > as FBUF_PARA is set to 0 (in non-interlaced mode). > > > > + v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8, > > > + &pixfmt->height, 1, 0xffff, 1, 0); > > > + > > > + stride = round_up((pixfmt->width * cc->bpp) / 8, 8); > > > > You can drop the round_up(), as pixfmt->width is now a multiple of 8, so > > > > pixfmt->bytesperline = pixfmt->width * cc->bpp / 8; > > But that is only identical if cc->bpp == 8, or am I missing something here? If cc->bpp is equal to 16, you will get pixfmt->bytesperline = pixfmt->width * 2; which will still be a multiple of 8 as width is a multiple of 8. > > > + pixfmt->bytesperline = stride; > > > + pixfmt->sizeimage = stride * pixfmt->height; > > > > > > if (compose) { > > > > > > - compose->width = fmt_src.width; > > > - compose->height = fmt_src.height; > > > + compose->width = pixfmt->width; > > > > This is a change of behaviour, compose->width used to be set to the > > unaligned width. > > Oh, you are right. I'll fix that. > > > > + compose->height = pixfmt->height; > > > > > > } > > > > > > return cc;
Hi Laurent, Am Dienstag, 18. April 2023, 12:05:55 CEST schrieb Laurent Pinchart: > Hi Alexander, > > On Tue, Apr 18, 2023 at 12:00:43PM +0200, Alexander Stein wrote: > > Am Dienstag, 18. April 2023, 11:27:13 CEST schrieb Laurent Pinchart: > > > On Tue, Apr 18, 2023 at 09:14:37AM +0200, Alexander Stein wrote: > > > > There is no need to convert input pixformat to mbus_framefmt and back > > > > again. Instead apply pixformat width contrains directly. > > > > > > > > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> > > > > --- > > > > > > > > drivers/media/platform/nxp/imx7-media-csi.c | 14 +++++++++----- > > > > 1 file changed, 9 insertions(+), 5 deletions(-) > > > > > > > > diff --git a/drivers/media/platform/nxp/imx7-media-csi.c > > > > b/drivers/media/platform/nxp/imx7-media-csi.c index > > > > b701e823436a8..bd649fd9166fd 100644 > > > > --- a/drivers/media/platform/nxp/imx7-media-csi.c > > > > +++ b/drivers/media/platform/nxp/imx7-media-csi.c > > > > @@ -1145,8 +1145,8 @@ static const struct imx7_csi_pixfmt * > > > > > > > > __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, > > > > > > > > struct v4l2_rect *compose) > > > > > > > > { > > > > > > > > - struct v4l2_mbus_framefmt fmt_src; > > > > > > > > const struct imx7_csi_pixfmt *cc; > > > > > > > > + u32 stride; > > > > > > > > /* > > > > > > > > * Find the pixel format, default to the first supported format if > > > > not > > > > > > > > @@ -1172,12 +1172,16 @@ __imx7_csi_video_try_fmt(struct > > > > v4l2_pix_format *pixfmt,> > > > > > > } > > > > > > > > } > > > > > > > > - v4l2_fill_mbus_format(&fmt_src, pixfmt, 0); > > > > - imx7_csi_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc); > > > > > > Could you please keep the comment from imx7_csi_mbus_fmt_to_pix_fmt() > > > here, to indicate where the alignment comes from ? > > > > Sure, why not. > > > > > /* Round up width for minimum burst size */ > > > > > > We should likely revisit this in the future, I don't think the alignment > > > > > > is actually needed. This could be recorded already: > > > /* > > > > > > * Round up width for minimum burst size. > > > * > > > * TODO: Implement configurable stride support, and check what the real > > > * hardware alignment constraint on the width is. > > > */ > > > > Sounds good. I was already suspecting actual stride support is not > > supported, as FBUF_PARA is set to 0 (in non-interlaced mode). > > > > > > + v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8, > > > > + &pixfmt->height, 1, 0xffff, 1, 0); > > > > + > > > > + stride = round_up((pixfmt->width * cc->bpp) / 8, 8); > > > > > > You can drop the round_up(), as pixfmt->width is now a multiple of 8, so > > > > > > pixfmt->bytesperline = pixfmt->width * cc->bpp / 8; > > > > But that is only identical if cc->bpp == 8, or am I missing something > > here? > > If cc->bpp is equal to 16, you will get > > pixfmt->bytesperline = pixfmt->width * 2; > > which will still be a multiple of 8 as width is a multiple of 8. That's true only for 16 bpp. If you are using e.g. 'RG10' this assumption is not guaranteed. Apparently it happens to be the case for 1080p on my imx327 sensor though. Best regards, Alexander > > > > + pixfmt->bytesperline = stride; > > > > + pixfmt->sizeimage = stride * pixfmt->height; > > > > > > > > if (compose) { > > > > > > > > - compose->width = fmt_src.width; > > > > - compose->height = fmt_src.height; > > > > + compose->width = pixfmt->width; > > > > > > This is a change of behaviour, compose->width used to be set to the > > > unaligned width. > > > > Oh, you are right. I'll fix that. > > > > > > + compose->height = pixfmt->height; > > > > > > > > } > > > > > > > > return cc;
Hi Alexander, On Tue, Apr 18, 2023 at 12:08:07PM +0200, Alexander Stein wrote: > Am Dienstag, 18. April 2023, 12:05:55 CEST schrieb Laurent Pinchart: > > On Tue, Apr 18, 2023 at 12:00:43PM +0200, Alexander Stein wrote: > > > Am Dienstag, 18. April 2023, 11:27:13 CEST schrieb Laurent Pinchart: > > > > On Tue, Apr 18, 2023 at 09:14:37AM +0200, Alexander Stein wrote: > > > > > There is no need to convert input pixformat to mbus_framefmt and back > > > > > again. Instead apply pixformat width contrains directly. > > > > > > > > > > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> > > > > > --- > > > > > > > > > > drivers/media/platform/nxp/imx7-media-csi.c | 14 +++++++++----- > > > > > 1 file changed, 9 insertions(+), 5 deletions(-) > > > > > > > > > > diff --git a/drivers/media/platform/nxp/imx7-media-csi.c > > > > > b/drivers/media/platform/nxp/imx7-media-csi.c index > > > > > b701e823436a8..bd649fd9166fd 100644 > > > > > --- a/drivers/media/platform/nxp/imx7-media-csi.c > > > > > +++ b/drivers/media/platform/nxp/imx7-media-csi.c > > > > > @@ -1145,8 +1145,8 @@ static const struct imx7_csi_pixfmt * > > > > > __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, > > > > > struct v4l2_rect *compose) > > > > > { > > > > > - struct v4l2_mbus_framefmt fmt_src; > > > > > const struct imx7_csi_pixfmt *cc; > > > > > + u32 stride; > > > > > > > > > > /* > > > > > * Find the pixel format, default to the first supported format if not > > > > > @@ -1172,12 +1172,16 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, > > > > > } > > > > > } > > > > > > > > > > - v4l2_fill_mbus_format(&fmt_src, pixfmt, 0); > > > > > - imx7_csi_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc); > > > > > > > > Could you please keep the comment from imx7_csi_mbus_fmt_to_pix_fmt() > > > > here, to indicate where the alignment comes from ? > > > > > > Sure, why not. > > > > > > > /* Round up width for minimum burst size */ > > > > > > > > We should likely revisit this in the future, I don't think the alignment > > > > is actually needed. This could be recorded already: > > > > > > > > /* > > > > > > > > * Round up width for minimum burst size. > > > > * > > > > * TODO: Implement configurable stride support, and check what the real > > > > * hardware alignment constraint on the width is. > > > > */ > > > > > > Sounds good. I was already suspecting actual stride support is not > > > supported, as FBUF_PARA is set to 0 (in non-interlaced mode). > > > > > > > > + v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8, > > > > > + &pixfmt->height, 1, 0xffff, 1, 0); > > > > > + > > > > > + stride = round_up((pixfmt->width * cc->bpp) / 8, 8); > > > > > > > > You can drop the round_up(), as pixfmt->width is now a multiple of 8, so > > > > > > > > pixfmt->bytesperline = pixfmt->width * cc->bpp / 8; > > > > > > But that is only identical if cc->bpp == 8, or am I missing something > > > here? > > > > If cc->bpp is equal to 16, you will get > > > > pixfmt->bytesperline = pixfmt->width * 2; > > > > which will still be a multiple of 8 as width is a multiple of 8. > > That's true only for 16 bpp. If you are using e.g. 'RG10' this assumption is > not guaranteed. Apparently it happens to be the case for 1080p on my imx327 > sensor though. For 10-bit bayer formats, cc->bpp is 16. The only bpp values used by the driver are 8 and 16. > > > > > + pixfmt->bytesperline = stride; > > > > > + pixfmt->sizeimage = stride * pixfmt->height; > > > > > > > > > > if (compose) { > > > > > > > > > > - compose->width = fmt_src.width; > > > > > - compose->height = fmt_src.height; > > > > > + compose->width = pixfmt->width; > > > > > > > > This is a change of behaviour, compose->width used to be set to the > > > > unaligned width. > > > > > > Oh, you are right. I'll fix that. > > > > > > > > + compose->height = pixfmt->height; > > > > > > > > > > } > > > > > > > > > > return cc;
diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index b701e823436a8..bd649fd9166fd 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1145,8 +1145,8 @@ static const struct imx7_csi_pixfmt * __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose) { - struct v4l2_mbus_framefmt fmt_src; const struct imx7_csi_pixfmt *cc; + u32 stride; /* * Find the pixel format, default to the first supported format if not @@ -1172,12 +1172,16 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, } } - v4l2_fill_mbus_format(&fmt_src, pixfmt, 0); - imx7_csi_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc); + v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8, + &pixfmt->height, 1, 0xffff, 1, 0); + + stride = round_up((pixfmt->width * cc->bpp) / 8, 8); + pixfmt->bytesperline = stride; + pixfmt->sizeimage = stride * pixfmt->height; if (compose) { - compose->width = fmt_src.width; - compose->height = fmt_src.height; + compose->width = pixfmt->width; + compose->height = pixfmt->height; } return cc;