From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 592C6C77B71 for ; Tue, 18 Apr 2023 10:05:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230086AbjDRKFr (ORCPT ); Tue, 18 Apr 2023 06:05:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229682AbjDRKFq (ORCPT ); Tue, 18 Apr 2023 06:05:46 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56F7246B8 for ; Tue, 18 Apr 2023 03:05:45 -0700 (PDT) Received: from pendragon.ideasonboard.com (133-32-181-51.west.xps.vectant.ne.jp [133.32.181.51]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9AA36F07; Tue, 18 Apr 2023 12:05:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1681812338; bh=9+HFr8ve0irPed9PjVixm9Huig4A9uMc4MBRU6fuuV4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=souxbKFD9WMZXywGYQW+8AfUWXRit+vds0JgAjH8+Sx6V+/KWbax38W5yeKZy2pCi y5N0BV2s3coodG9zv8xQjnDhSUDhbRiOLPGQF6IS1iD9y4ShzivVqDY+RDaaXR2cQ9 8j5NdpyvxODo62NDysbLTfhAykHRco3qAjwZNOlc= Date: Tue, 18 Apr 2023 13:05:55 +0300 From: Laurent Pinchart To: Alexander Stein Cc: Rui Miguel Silva , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Fabio Estevam , Pengutronix Kernel Team , NXP Linux Team , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 1/3] media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt Message-ID: <20230418100555.GC11510@pendragon.ideasonboard.com> References: <20230418071439.197735-1-alexander.stein@ew.tq-group.com> <20230418071439.197735-2-alexander.stein@ew.tq-group.com> <20230418092713.GA26319@pendragon.ideasonboard.com> <6038523.lOV4Wx5bFT@steina-w> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <6038523.lOV4Wx5bFT@steina-w> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 > > > --- > > > > > > 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; -- Regards, Laurent Pinchart