From patchwork Wed Apr 19 07:07:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 675472 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 7E8FAC77B73 for ; Wed, 19 Apr 2023 07:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231532AbjDSHHX (ORCPT ); Wed, 19 Apr 2023 03:07:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjDSHHV (ORCPT ); Wed, 19 Apr 2023 03:07:21 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6E9E273C for ; Wed, 19 Apr 2023 00:07:19 -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=1681888039; x=1713424039; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Yy/Kwa6S58Mfw3qjphLXJDSZbTwUl9SOBCoucc3b4vs=; b=ky1J69dvurZ8LDRmVrn8KDMS9p3G+9x7s+9CDH8D6qEYdIww9LC/dGER h+TAeGpt/z5U/XE9T22iGCoWey/fK3nKhVAubsO/583SrMs7d4UojCGKv VQF/sp3/yrgsR9VWIdFRo8a5p+f4pu3OGM/qQCcoVGQ55m5AnZFJBFgRt ekahM3CwaZkG4oEOU5pruX3gxBhuPh9ecViJvmTeziTbwv/YEt7YuzKWA phr7S1yake48z1k6I4iH/7U2Q475+gbMVIV3A0n4OmTk94VAGN+g1NSdK 0vkQrXLELwShKb8S+1D0EsZHRXIzmn2vMdfJgwHZAm+szbHre31dhJ85Q g==; X-IronPort-AV: E=Sophos;i="5.99,208,1677538800"; d="scan'208";a="30415567" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 19 Apr 2023 09:07:16 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Wed, 19 Apr 2023 09:07:16 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Wed, 19 Apr 2023 09:07:16 +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=1681888036; x=1713424036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Yy/Kwa6S58Mfw3qjphLXJDSZbTwUl9SOBCoucc3b4vs=; b=OmT5FVnIohrrtDbzZx6xps+XTxSo7MOeByr84FGnt/dP7FQU+ItKXGX1 hKERLb09n2SseUo1SoJOD47HBmzWe7BXepcN4dx8mShLr/0ZHL/WGirQv lHjay+69WbjqDGgH+hbDTwyoOwC+oMACCUmPRKyAAhfwccZbm/LGVtLBb sYPQE4m0gTe0RIXZxylq+cG1hJ7XpZBtCuNSnsEJD+c4Nri3H1JhUAmsQ 13ESBRCABaGYsKK77EQgjuNiAcn6XRkvDk1z/VZDJvjPyuJG0y2dgwpyC /+RNT9cKHJ7fthJiu8clCIjjl1eA7oH9qHEd2xq3KmA3tJE170z66fxXL Q==; X-IronPort-AV: E=Sophos;i="5.99,208,1677538800"; d="scan'208";a="30415566" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 19 Apr 2023 09:07:16 +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 01D7A280072; Wed, 19 Apr 2023 09:07:15 +0200 (CEST) From: Alexander Stein To: Rui Miguel Silva , Laurent Pinchart , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Fabio Estevam Cc: Alexander Stein , Pengutronix Kernel Team , NXP Linux Team , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 1/4] media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt Date: Wed, 19 Apr 2023 09:07:09 +0200 Message-Id: <20230419070712.1422335-2-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419070712.1422335-1-alexander.stein@ew.tq-group.com> References: <20230419070712.1422335-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There is no need to convert input pixformat to mbus_framefmt and back again. Instead apply pixformat width constrains directly. Assign compose values before adjusting pixformat height/width. Signed-off-by: Alexander Stein Reviewed-by: Laurent Pinchart --- Changes in v4: * Added Laurent's r-b drivers/media/platform/nxp/imx7-media-csi.c | 22 ++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index b701e823436a8..b149374b07ee1 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1145,9 +1145,13 @@ 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; + if (compose) { + compose->width = pixfmt->width; + compose->height = pixfmt->height; + } + /* * Find the pixel format, default to the first supported format if not * found. @@ -1172,13 +1176,17 @@ __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); + /* + * 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); - if (compose) { - compose->width = fmt_src.width; - compose->height = fmt_src.height; - } + pixfmt->bytesperline = pixfmt->width * cc->bpp / 8; + pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; return cc; } From patchwork Wed Apr 19 07:07:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 676465 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 2194EC6FD18 for ; Wed, 19 Apr 2023 07:07:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231584AbjDSHHY (ORCPT ); Wed, 19 Apr 2023 03:07:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231264AbjDSHHW (ORCPT ); Wed, 19 Apr 2023 03:07:22 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC5702710 for ; Wed, 19 Apr 2023 00:07:20 -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=1681888041; x=1713424041; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dmsT6bzUJE5AO5KsR1Jym8hUjW8jCA6HQen9rKtepnU=; b=qdhXXSagp2Tq/CFVXcM3PkhekwjC+hOJPKYTzXf9KmbKsRXs8mBTECRD rFslbGboJ/Vui3/6WQL/ayZ+qg112g/brKbFOmqdqMBgd4Lbuj+DMF0FU u7IRYmjG9C913l3jBVQBiRDbDwqsjluPdmvs9h1ae4DBso/0xq6LD8gPu Nb7+dBDhYhoFL+ydU0NzVd7LuBQlh2W3vfAkN6bmQdysIj5+De6Gi7e6E 5iJ+xA1ssV3mdi7bxB19UDZuFDRPLejd0JMnEOUpN3kzHzQSs/d/EVeG0 6plW7Kz0YR69xR682os9/o0ljPUHYcqHOGofOzR2PAMIJz/v/h1VqFUtz w==; X-IronPort-AV: E=Sophos;i="5.99,208,1677538800"; d="scan'208";a="30415569" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 19 Apr 2023 09:07:16 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Wed, 19 Apr 2023 09:07:16 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Wed, 19 Apr 2023 09:07:16 +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=1681888036; x=1713424036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dmsT6bzUJE5AO5KsR1Jym8hUjW8jCA6HQen9rKtepnU=; b=mMldpGvRGt+jV4WJwoTY7w/e0KMsK6EIEoDWquK0xKFJNoACmFczBXOA QrFZME4GsaQQ38vadNk8WGIiCuhPfVRr/67/2FlK5EPNkn1ibUPV+hVs3 BX+w7d9gJWc/sROLuiIRKhlwJ5CJ6Rx9TjGvVY5GDDRs3uGo7wbGdP+F+ WFmx8+uP2kPH6yj0SBFvFclwtSghqdBbROPgWQhwieJAlwsPhaDNmUjDD QHkRN5uHhQPuIMyyZHwRLgOgbnAmpI3pnQ0/9nHLvJrpI1UWTcTOm3vt9 ewftTi6pyVcCAhEfxJjJeVA4YjxF8ZmFDCr5BiwrQU6zsWNGX8E1KQOVI g==; X-IronPort-AV: E=Sophos;i="5.99,208,1677538800"; d="scan'208";a="30415568" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 19 Apr 2023 09:07:16 +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 32603280056; Wed, 19 Apr 2023 09:07:16 +0200 (CEST) From: Alexander Stein To: Rui Miguel Silva , Laurent Pinchart , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Fabio Estevam Cc: Alexander Stein , Pengutronix Kernel Team , NXP Linux Team , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 2/4] media: imx: imx7-media-csi: Remove incorrect interlacing support Date: Wed, 19 Apr 2023 09:07:10 +0200 Message-Id: <20230419070712.1422335-3-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419070712.1422335-1-alexander.stein@ew.tq-group.com> References: <20230419070712.1422335-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The driver doesn't currently support interlacing, but due to legacy leftovers, it accepts values for the pixel format "field" field other than V4L2_FIELD_NONE. Fix it by hardcoding V4L2_FIELD_NONE. Proper interlacing support can be implemented later if desired. Signed-off-by: Alexander Stein Reviewed-by: Laurent Pinchart --- Changes in v4: * Improve commit message * Added Laurent's r-b drivers/media/platform/nxp/imx7-media-csi.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index b149374b07ee1..1315f5743b76f 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1162,20 +1162,6 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, cc = imx7_csi_find_pixel_format(pixfmt->pixelformat); } - /* Allow IDMAC interweave but enforce field order from source. */ - if (V4L2_FIELD_IS_INTERLACED(pixfmt->field)) { - switch (pixfmt->field) { - case V4L2_FIELD_SEQ_TB: - pixfmt->field = V4L2_FIELD_INTERLACED_TB; - break; - case V4L2_FIELD_SEQ_BT: - pixfmt->field = V4L2_FIELD_INTERLACED_BT; - break; - default: - break; - } - } - /* * Round up width for minimum burst size. * @@ -1187,6 +1173,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, pixfmt->bytesperline = pixfmt->width * cc->bpp / 8; pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; + pixfmt->field = V4L2_FIELD_NONE; return cc; } From patchwork Wed Apr 19 07:07:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 675471 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 AE8BAC77B73 for ; Wed, 19 Apr 2023 07:07:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231628AbjDSHH0 (ORCPT ); Wed, 19 Apr 2023 03:07:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231400AbjDSHHX (ORCPT ); Wed, 19 Apr 2023 03:07:23 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00C5F2D71 for ; Wed, 19 Apr 2023 00:07:21 -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=1681888042; x=1713424042; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fL8PZNABlAgAhG80OdCGVSVIWgAQMIfpGqcXZCETe8g=; b=WkXsLepQRV2aBYORfOsv/0cDxEMolACBi9TtOe+Sz3gvU53ehjwIKT9q PlUPKTAzNx0cHaUEC3VQ9yHdbR/blFV1jnMrUiffmyGtFXSkBw4LJnGeX Vepd9jZK1BNCLbwQsRa/zJ0+DiIPGngrZaLNlAgnyEF6PHGiUAw0wf3oU 1dVKak+gO8eKvhYj2/Py/xUJjM3FR4Ac4cheCdum6wyKo66oU+xh8SEQl ztBlPj9Tad+ivXOHN7lAYg5flC5Ov5AiEiWcH9rDEs74WdExNrMkQ3QTf J6Tbqh5JyboEHif7Q0Zvnu71ThFhVNeY3YmayIDq/7YQ4jV3Aus/RXA7p g==; X-IronPort-AV: E=Sophos;i="5.99,208,1677538800"; d="scan'208";a="30415571" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 19 Apr 2023 09:07:16 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Wed, 19 Apr 2023 09:07:16 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Wed, 19 Apr 2023 09:07:16 +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=1681888036; x=1713424036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fL8PZNABlAgAhG80OdCGVSVIWgAQMIfpGqcXZCETe8g=; b=RjVFZatqBRUG2zsfv+3bxBYq9etL3WfdqccFc+yovnuKT1kAwvZ6BX0G 8sPirsiY7WhR2hfeCYdAjpjzsMiQSwkptNhtVech8FdkoHejKuUBQej83 n5ZE9Qn+S3TX2qdbEMp9LcFCrcIduPr1w+usx40ljua6UwufwS8cLDnVw 4FuJGGbh+i4MqhqILKCKS6ZjZCGRnW8p+QNPmcqdOYNLgenlbtNYvrTrZ rF/DtPamfEPwKDSkuD69REOvCr8jbJMXs6+fwOBTLy+JffQcLAN+6YIax D9gknra4qr0Wdk0ONYJ0hz+ww2cygivXc7SgVasQQIG/lxKS7BC0mEwh5 Q==; X-IronPort-AV: E=Sophos;i="5.99,208,1677538800"; d="scan'208";a="30415570" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 19 Apr 2023 09:07:16 +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 6183E280072; Wed, 19 Apr 2023 09:07:16 +0200 (CEST) From: Alexander Stein To: Rui Miguel Silva , Laurent Pinchart , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Fabio Estevam Cc: Alexander Stein , Pengutronix Kernel Team , NXP Linux Team , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 3/4] media: imx: imx7-media-csi: Relax width constraints for non-8bpp formats Date: Wed, 19 Apr 2023 09:07:11 +0200 Message-Id: <20230419070712.1422335-4-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419070712.1422335-1-alexander.stein@ew.tq-group.com> References: <20230419070712.1422335-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The driver unconditionally aligns the image width to multiples of 8 pixels. The real alignment constraint is 8 bytes, as indicated by the CSI_IMAG_PARA.IMAGE_WIDTH documentation that calls for 8 pixel alignment for 8bpp formats and 4 pixel alignment for other formats. Signed-off-by: Alexander Stein Reviewed-by: Laurent Pinchart --- Changes in v4: * Improve commit message * Simplify walign calculation * Remove comment on hardware alignment constraints drivers/media/platform/nxp/imx7-media-csi.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 1315f5743b76f..e6abbfbc5c129 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1146,6 +1146,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose) { const struct imx7_csi_pixfmt *cc; + u32 walign; if (compose) { compose->width = pixfmt->width; @@ -1163,12 +1164,13 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, } /* - * Round up width for minimum burst size. + * The width alignment is 8 bytes as indicated by the + * CSI_IMAG_PARA.IMAGE_WIDTH documentation. Convert it to pixels. * - * TODO: Implement configurable stride support, and check what the real - * hardware alignment constraint on the width is. + * TODO: Implement configurable stride support. */ - v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8, + walign = 8 * 8 / cc->bpp; + v4l_bound_align_image(&pixfmt->width, 1, 0xffff, walign, &pixfmt->height, 1, 0xffff, 1, 0); pixfmt->bytesperline = pixfmt->width * cc->bpp / 8; From patchwork Wed Apr 19 07:07:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 676464 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 C0434C77B78 for ; Wed, 19 Apr 2023 07:07:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231687AbjDSHH1 (ORCPT ); Wed, 19 Apr 2023 03:07:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231618AbjDSHHY (ORCPT ); Wed, 19 Apr 2023 03:07:24 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19BC82710 for ; Wed, 19 Apr 2023 00:07:22 -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=1681888043; x=1713424043; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3o1/ma89daUDddWkyBxC7A/MJ6L/SjM7+gDduhH0vmE=; b=LAqZoVWrSdemJrQtannnm1tokvVotZoT5epUUPdmwd5NPltuQQrY1qGc jG3KQip3uUUgyqw08lT5oaVOzVmWDWgY+AOIk96or61jmc6M3pn9bT12D RbAd2ZQ4amcy5cLv1vDD8HoqL5Z3x4dzxmun7qwbjGhLE/HpNUBD9xq5K FcorC2BJ3pwah80U+OHJIjTcLNbiEOAG7XkN8GhLdTadYZlbpTj4eop00 FrvA8k+BGxTi/swluXCLfz0gk1U9cqVE6p7bHJfiG4RCCuLnbZ7gL4ank BLo9Ew283sH3gHGNt8iTPFQFik9Ts1cNrKR7XyT2BO8iepStQ5Athzzfe w==; X-IronPort-AV: E=Sophos;i="5.99,208,1677538800"; d="scan'208";a="30415573" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 19 Apr 2023 09:07:16 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Wed, 19 Apr 2023 09:07:16 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Wed, 19 Apr 2023 09:07:16 +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=1681888036; x=1713424036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3o1/ma89daUDddWkyBxC7A/MJ6L/SjM7+gDduhH0vmE=; b=FQUUPwQOskgTmR4wiVAfBrvhPPRuQENWDYswW+PueLgDw8Sqw8Xl21X7 o/DqeeKjVMxkGJwNm7FuDuUhxyTaTqWd/4QUMmHATxuVSm1VksdbfqRBf jVLxhUdyF7xuX/WL5QAOoOU4oS20OUvewQ9KXf8BLLpB2AMUADcdbUPau yZf2dlwmc5Bjd4x4ItmJ3Q75weoyoenfNssDSn90Am+h5PWtbJAnle2Ho /A2V2TFP7V2Ncx6iCyrls+C2nyt8bKFVN9z1mJcSyfrrb0Jnf3bfcEf1c A1qCSxqyOEUym/piZ1ODUyL7zGdWN05cirCrypUv7DbOkXJNCm+vzETkY w==; X-IronPort-AV: E=Sophos;i="5.99,208,1677538800"; d="scan'208";a="30415572" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 19 Apr 2023 09:07:16 +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 92760280056; Wed, 19 Apr 2023 09:07:16 +0200 (CEST) From: Alexander Stein To: Rui Miguel Silva , Laurent Pinchart , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Fabio Estevam Cc: Pengutronix Kernel Team , NXP Linux Team , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alexander Stein Subject: [PATCH v4 4/4] media: imx: imx7-media-csi: Init default format with __imx7_csi_video_try_fmt() Date: Wed, 19 Apr 2023 09:07:12 +0200 Message-Id: <20230419070712.1422335-5-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419070712.1422335-1-alexander.stein@ew.tq-group.com> References: <20230419070712.1422335-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Use the __imx7_csi_video_try_fmt() helper function to initialize the default format at probe time. This improves consistency by using the same code path for both default initialization and validation at runtime, and allows dropping the now unused imx7_csi_find_pixel_format() function. Signed-off-by: Laurent Pinchart Signed-off-by: Alexander Stein --- Changes in v4: * None drivers/media/platform/nxp/imx7-media-csi.c | 55 +++------------------ 1 file changed, 6 insertions(+), 49 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index e6abbfbc5c129..0bd2613b9320f 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1014,39 +1014,6 @@ static int imx7_csi_enum_mbus_formats(u32 *code, u32 index) return -EINVAL; } -static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, - const struct v4l2_mbus_framefmt *mbus, - const struct imx7_csi_pixfmt *cc) -{ - u32 width; - u32 stride; - - if (!cc) { - cc = imx7_csi_find_mbus_format(mbus->code); - if (!cc) - return -EINVAL; - } - - /* Round up width for minimum burst size */ - width = round_up(mbus->width, 8); - - /* Round up stride for IDMAC line start address alignment */ - stride = round_up((width * cc->bpp) >> 3, 8); - - pix->width = width; - pix->height = mbus->height; - pix->pixelformat = cc->fourcc; - pix->colorspace = mbus->colorspace; - pix->xfer_func = mbus->xfer_func; - pix->ycbcr_enc = mbus->ycbcr_enc; - pix->quantization = mbus->quantization; - pix->field = mbus->field; - pix->bytesperline = stride; - pix->sizeimage = stride * pix->height; - - return 0; -} - /* ----------------------------------------------------------------------------- * Video Capture Device - IOCTLs */ @@ -1603,22 +1570,14 @@ static struct imx7_csi_vb2_buffer *imx7_csi_video_next_buf(struct imx7_csi *csi) return buf; } -static int imx7_csi_video_init_format(struct imx7_csi *csi) +static void imx7_csi_video_init_format(struct imx7_csi *csi) { - struct v4l2_mbus_framefmt format = { }; - - format.code = IMX7_CSI_DEF_MBUS_CODE; - format.width = IMX7_CSI_DEF_PIX_WIDTH; - format.height = IMX7_CSI_DEF_PIX_HEIGHT; - format.field = V4L2_FIELD_NONE; + struct v4l2_pix_format *pixfmt = &csi->vdev_fmt; - imx7_csi_mbus_fmt_to_pix_fmt(&csi->vdev_fmt, &format, NULL); - csi->vdev_compose.width = format.width; - csi->vdev_compose.height = format.height; + pixfmt->width = IMX7_CSI_DEF_PIX_WIDTH; + pixfmt->height = IMX7_CSI_DEF_PIX_HEIGHT; - csi->vdev_cc = imx7_csi_find_pixel_format(csi->vdev_fmt.pixelformat); - - return 0; + csi->vdev_cc = __imx7_csi_video_try_fmt(pixfmt, &csi->vdev_compose); } static int imx7_csi_video_register(struct imx7_csi *csi) @@ -1631,9 +1590,7 @@ static int imx7_csi_video_register(struct imx7_csi *csi) vdev->v4l2_dev = v4l2_dev; /* Initialize the default format and compose rectangle. */ - ret = imx7_csi_video_init_format(csi); - if (ret < 0) - return ret; + imx7_csi_video_init_format(csi); /* Register the video device. */ ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);