From patchwork Tue Apr 18 12:20:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13215581 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79A98C6FD18 for ; Tue, 18 Apr 2023 12:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3qODwdHkdDS8278baABRdfYT+AnlkEUTczCIasyNeaI=; b=iQGPpKvytvzCIH g0pV+7BNUaRREMhfWzPgFqQWIAbFHYq4pYA+k8ZWUFSjO1saLJWsGVJdoID7V+JDokfSNIQtc/8q9 sh0CNfODf/tXNDrZERYCo1a7HmHPQV/IDG0q4AXRI/Dx0z3fBZWHWHhMREwFtCkPfXPhVc5GXkfcE dIqEYA3oCDf2HPB99RqrMAXa/nWzLsUuG1ug4bTl0ip5YbdYkKsZfZco7L+oOmbt5P1K/KJ0OaJud GLgGlTODOGQS8vQ0c8VolNm4WphyNP+6XKBzKyYDrF5EIAEwGBOZ2aKC8jxRYiKtyRpqbKLZY4CzR ONBadaLyn64i5vfNCwuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pokKM-0025k1-0Y; Tue, 18 Apr 2023 12:20:54 +0000 Received: from mx1.tq-group.com ([93.104.207.81]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pokKE-0025f9-2i for linux-arm-kernel@lists.infradead.org; Tue, 18 Apr 2023 12:20:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1681820446; x=1713356446; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XGw5xC6Fg4pq6w23AOORh/+eD6UfJOrgZkSlQ/9Kyj8=; b=YfR9LEBRJM2sy/XrqotkhZeFTwdU3uxOu1jET03wrVIhrcWKqlGsPiEA sFoWgE8XKw9KS0cL7Cs/fnI4LJnA0o+SeSpXaswJYdFxYC99sBkg/pgPu KfFjc0fDH/BgNOSoXNT4ZKZYwt018fI/bC7nuodeG4bypyrmug5v8Deaj 3NV/4bRDWUbK3n+TgwcBsbN6WudFf5y3GP/cmIV90g/CEShI5OZV/FQKW TetDaPZWXklLZ8BPg+lhICwBRdeXSdnats24pmIM0gtrURvZXoqmP+YQX VLll6tD2OLTsRKs9jLAcJkU8hL2ZQ9Za0V8IOeiYFxy6VPpCTkFef5ufs A==; X-IronPort-AV: E=Sophos;i="5.99,207,1677538800"; d="scan'208";a="30398472" 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 14:20:44 +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 14:20:44 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Tue, 18 Apr 2023 14:20:44 +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=1681820444; x=1713356444; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XGw5xC6Fg4pq6w23AOORh/+eD6UfJOrgZkSlQ/9Kyj8=; b=KHraa1TEam3bWtBOOirsu9iwl+L5mpvyth/yx5I6adyOEBz9HiPMxsUZ VpgvqszfhFlFpCdfIGD+h2E6FYM+T4qf2OgWe05so01FZzNoYzHrTpvmB an2BbjJuwJO43FZ4JbpivIX5NXUZ4UolsPVcEdAirkkF1xf1WBzsFBX/K D1v+KUk7tpJvEU8iCyRqwtVXTCR5C5X6vDbMN4SCrPuDisaazbJp3Q7hs TZwLC6hV4chCQdih6ufurVpQTXnEfYu9Nl7pk9jF0QvnnMfrm1l2O6DfR 9btnrUXm2Z7m6yKk8oui19h9cGL+t5KiJMuQg2DxPXSzQ/7TwUP+jerPx g==; X-IronPort-AV: E=Sophos;i="5.99,207,1677538800"; d="scan'208";a="30398470" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 18 Apr 2023 14:20:44 +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 A4E2A280072; Tue, 18 Apr 2023 14:20:43 +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 v3 1/4] media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt Date: Tue, 18 Apr 2023 14:20:38 +0200 Message-Id: <20230418122041.1318862-2-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418122041.1318862-1-alexander.stein@ew.tq-group.com> References: <20230418122041.1318862-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230418_052047_187799_EEC854BC X-CRM114-Status: GOOD ( 15.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 v3: * Move compose assignment before width adjustments * Add comments regarding width multiples * Remove unneeded stride rounding 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 Tue Apr 18 12:20:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13215584 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 50B7FC6FD18 for ; Tue, 18 Apr 2023 12:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SP+dVQee4YYRHrX/M79JegWYc9D4nSknyquKrKVXMHY=; b=D1bIISFbZQ9RFV pwL4Ag523bfreWkoQFwUSisM4aQB1rfb7BwPxHvZ7umT7eHUc7xcM5azRrl+mCeK9nYSqEIrtnVyz JVS33HJxMJJHoDsdbYOTWT03pG9veQJ6zGPXJ2NMd3Whytzg/1G7wem0Jo9hW8jNijJm+qkzmKuoM eLKoszIOTcW5cCI83G9GHgS1YphJuqFQyM/aq4kIiWkzXK2YIOam3eS9Pl7S6iA2wpwkdAYsduiuy DlktCfcw9ymnWxu6JqG0YSJBOFi/3MxQM4253LUv73mntlFLfWlCy1Y8xmNaqWysVm4GgR0HPXfAJ MehoavxzlolOcPSA5KsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pokKN-0025kq-0q; Tue, 18 Apr 2023 12:20:55 +0000 Received: from mx1.tq-group.com ([93.104.207.81]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pokKF-0025ez-3A for linux-arm-kernel@lists.infradead.org; Tue, 18 Apr 2023 12:20:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1681820448; x=1713356448; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x9t0YKFE5YdhFDRYs98DQ6cjcsr0r7KP+UROeDikahg=; b=UHAGSNdez/ku9o7dUPDFnnxmpgwwOB+Y62Dl+3ZwBvk7hooQhuIWVrJA g1+HkkPHE86x/EgOyTf3/Wrg5F7D54q4eP7wKYCrF5EY82RENBFO4RSSD V3/30ki9OEVhSRZLE/BNA9PRsRBJNtaFNLZCyugQSA179icmYG+KjQKfE z62XL9Qxe36YfS3LYzAkcrD968J+jjGNtnK1qPjCZ3gLb/tO3/7w114eI /nwjX6QPmpCTjp2ORvDqYphYHWC91SiE57aStbm8GIg7jiQJipVTY3R1t TfllMyWrwscHY3VXos1gKLvwIOL7YBNbaWB4bzsKK9J3z3kpH5R/FUROC w==; X-IronPort-AV: E=Sophos;i="5.99,207,1677538800"; d="scan'208";a="30398475" 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 14:20:45 +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 14:20:45 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Tue, 18 Apr 2023 14:20:45 +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=1681820445; x=1713356445; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x9t0YKFE5YdhFDRYs98DQ6cjcsr0r7KP+UROeDikahg=; b=jDNHH+pOmfjwQPfBiIT9K97+VCjBVtokt18T1neMICFa6uLGsgaFKM4a /c6DXC5/GVkHsB8V3s43SruiC94WmyQd0dEK+4lPot/YzAOX+T4hLri0C S60faKegr8eHOKX592FUceBCkv82rPGt5KGfEVlGLeezJW68t+0oHVVD/ p+NrrmE2fG2peUu/sbxJrrArg/BmO2dz2p966IgJW5hv6O796VJikeEaV dbE20UAL8EcRPE6TtwEp+/BVfbo5v4H3bWnfN4ajRt7Z6qw6JslFr86rm 6Ii/wLgrJ+pTst9vacMxJDkevRlmmKlv8x+7bgsTdnp4ZHgs/+ndwCAa4 w==; X-IronPort-AV: E=Sophos;i="5.99,207,1677538800"; d="scan'208";a="30398473" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 18 Apr 2023 14:20:45 +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 59540280073; Tue, 18 Apr 2023 14:20:44 +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 v3 2/4] media: imx: imx7-media-csi: Remove interlave fields Date: Tue, 18 Apr 2023 14:20:39 +0200 Message-Id: <20230418122041.1318862-3-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418122041.1318862-1-alexander.stein@ew.tq-group.com> References: <20230418122041.1318862-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230418_052048_338121_B16DD5A3 X-CRM114-Status: GOOD ( 12.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Interlaced mode is currently not supported, so disable fields in try_fmt. Signed-off-by: Alexander Stein Reviewed-by: Laurent Pinchart --- Changes in v3: * Remove left-over interlace mode check 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 Tue Apr 18 12:20:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13215582 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5EFB2C6FD18 for ; Tue, 18 Apr 2023 12:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1NkrW5UHim9CvHnHtH8FzH+IgZyMbXIGf4tETBzyc6s=; b=15IRBMyaZuL757 3a0FZVJld6nmPX0o7R6aA+Yyjb0eCnDrAfnkGEJkJ1dV3SnVqH1tPPY+mZShGGLjqIKuhioB6mNYk x9wAgeIh/kwKZO3GFzZrz4e+V1NDIrmYSGFnKPLUPgDesOswVe5OxvGPQML+rrP4e5PqnyzyosA4L p8Pql75hPZUhoiPexC5jux3CnqtbwDbRU3QpY+cf/bgPDbpZcViTx8V6bjufd76xrwjZIqGy7/IWl 2CJs4RFU5g1zJ9RNB0RMjdYLw/oJTC9FksON/KKOrobCo8PPqx3sPexZdAhy8x5R/M2xfJvhGpSZ+ 8Wr6KRmSS2sUEsqE6L7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pokKO-0025lY-2E; Tue, 18 Apr 2023 12:20:56 +0000 Received: from mx1.tq-group.com ([93.104.207.81]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pokKG-0025f9-2n for linux-arm-kernel@lists.infradead.org; Tue, 18 Apr 2023 12:20:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1681820448; x=1713356448; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Tu7ZRmsYDcYoNQeM8pRuPA+VuhlatpH/tZGgviYR1zA=; b=MkfhMtckomYNZxmYr1Jfj6XgJpPEE1K1S6s44zV4peydzqHwipCZo68T A72cX8xZ50Qk4BHErv0a2PSfgRAPUzeCYMj7yugCQp53B5UhArNg7QaPn U0nMjngyCXnLDEYCaDBG0do7Gl/yhHcMEKQjxepITjCpK58r3krEkGIgm lM+PfuaiXNtP3qcEkYkRWOxMjnXS681+r5Dzn47uxxg0WUhe7H5rtv+h3 flLaFJBs0J9PB2vzXNDBneuQhgqZ/yQDn715YY7vp9G1IG7+gLH00G6sR H2cfKfjKPcks6sUDjvcuaYxoE0NeGHue/rcN/sqin3dZKnEYVN9K3Vo1N g==; X-IronPort-AV: E=Sophos;i="5.99,207,1677538800"; d="scan'208";a="30398477" 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 14:20:45 +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 14:20:45 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Tue, 18 Apr 2023 14:20:45 +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=1681820445; x=1713356445; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Tu7ZRmsYDcYoNQeM8pRuPA+VuhlatpH/tZGgviYR1zA=; b=IXoxCfA2b0/TZtgl8SG47HIp3p1r3sf3W7gDPBrEFOKwcazslzyPmvK8 hSXqi4nZgPoUEoDJlQZujNWdlUx7MbjxZFqiuxV5k1UGfup6/iBDsaItl Z2N8rCwqD+oLlnI8LqhmfNrEfdTtuyTKC26b5kfzBso4peFerPApeRirz 0XOFX2ZT3uZl2PAENjmOGE+RDo4kfRHDk9hbv48t8RqetEf17bzjsioFv MQX9Q65y08ikeJY/2ZKUGPXptB1JSdrOhd2hZ6Nvefa6CHOqQFh7Cdq79 8V3fUFBaon8bHDo1EoLPf7x1YfRwshAJN5G6DUuBKXC0ynRW49oE/ba45 A==; X-IronPort-AV: E=Sophos;i="5.99,207,1677538800"; d="scan'208";a="30398474" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 18 Apr 2023 14:20:45 +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 9D1D8280074; Tue, 18 Apr 2023 14:20:44 +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 v3 3/4] media: imx: imx7-media-csi: Lift width constraints for 8bpp formats Date: Tue, 18 Apr 2023 14:20:40 +0200 Message-Id: <20230418122041.1318862-4-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418122041.1318862-1-alexander.stein@ew.tq-group.com> References: <20230418122041.1318862-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230418_052049_211465_C6C8D361 X-CRM114-Status: GOOD ( 15.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org For 8-bit formats the image_width just needs to be a multiple of 8 pixels others just a multiple of 4 pixels. Signed-off-by: Alexander Stein --- Changes in v3: * Fix commit message (Only 8-bit formats needs multiple of 8 pixels) drivers/media/platform/nxp/imx7-media-csi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 1315f5743b76f..730c9c57bf4bc 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; @@ -1162,13 +1163,19 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, cc = imx7_csi_find_pixel_format(pixfmt->pixelformat); } + /* Refer to CSI_IMAG_PARA.IMAGE_WIDTH description */ + if (cc->bpp == 8) + walign = 8; + else + walign = 4; + /* * 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, + v4l_bound_align_image(&pixfmt->width, 1, 0xffff, walign, &pixfmt->height, 1, 0xffff, 1, 0); pixfmt->bytesperline = pixfmt->width * cc->bpp / 8; From patchwork Tue Apr 18 12:20:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13215583 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 066A7C77B75 for ; Tue, 18 Apr 2023 12:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=McL3RBhb7UDyfbuaES2CEpT0u1C47OHczRg5tVpUHVc=; b=4L9QF/Yblgo4L6 yvailp+NXvLdBc5lgGQWWR4bsWUq9XR9YGmYzMgYCbtNysYYHzD1mcWFSQsLJALN0plif0b/QYWR+ 54lc6fkhRSpB4aN8xIMCztKBKWxBJMj0KDPnrOc23jNTQlroU+IhKr9E2sbwziCRD/R6wP0Pi4IVL nYPWAl8CDQ8z5xhHKr13FuYh0PJoci3QFwrbJ1/eSVp3BtLo+xygw6Cdq3k8aS8sPufwc1z4gLIkJ 60NN3i4Pff7drdXzCfu54J/IhhbDZSLIhSoRqgoJkbdmm3c38hqiHOUmTRWtO4AdvMka72FaGjsEz TVo5hkTMtMu0U2Mnf1qw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pokKa-0025pB-12; Tue, 18 Apr 2023 12:21:08 +0000 Received: from mx1.tq-group.com ([93.104.207.81]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pokKH-0025ft-0I for linux-arm-kernel@lists.infradead.org; Tue, 18 Apr 2023 12:20:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1681820449; x=1713356449; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yqtw1gSjX/Af8g3HdWuO5BZ7Xg3V/5xF83DiiRqFiDU=; b=n0PHTpCj7FnoVHLQ3A4hLwruY4pFpeVGFcpmm9VKVtOUagqBCytDt5Eq jqvMZgdxrcyxK3t76oS5BQhfSdMqbVez+DxNvUwolqyzoaw+PvRgSLY88 aZQWsEr0ZNGHE3YviLJ3gPsi8Lg3hlZjLrWJyiq8OYgveRb9YrSAoI1m4 ry9GrliFsSVAI8pNrJIVbjs93jLf5FMW7QA1yv869zF8wc7UHTc6CcWKK he3DXfzrG9Qo6fu6kc+XQpriXHIQBRe3aHJ7asTpwQyjHpAlixJTnMI6V Z8DZHWNAtQSkCaLCm4g/HimgBcI5IefD4SoulVwepDvz+BjWfO1zBfW3E w==; X-IronPort-AV: E=Sophos;i="5.99,207,1677538800"; d="scan'208";a="30398478" 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 14:20:45 +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 14:20:45 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Tue, 18 Apr 2023 14:20:45 +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=1681820445; x=1713356445; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yqtw1gSjX/Af8g3HdWuO5BZ7Xg3V/5xF83DiiRqFiDU=; b=Hyu8E5JsBsewzdvfvhsfeKkU3XcIKeJ248iPeaT0VLw2/fD+vox2Z3OV iKzUodHYrulXA+Je8kjRg8eD/CweP95Xi2jqxw5lmz3OnxbFWRuIyWiJc ZDdcAiEaMcf4fyRh5G8PgCXlrElWrVfuZwQEhAnr23LOI+U6JmTUrcN00 IPCUbqtIiFrt43iTRgGI6YURVYMMkCaosICJEoPv2CDiWHwaJMRDWqTbo z8GmVSg8ZqBxjfj3ZW3nbIpH5iUrTzYXxGbwfhGmvwV+DE5ON58y/NBkE yEsheFnk8PGsOwQI+SdoCO2zlHVyIhiVhZxMPNS0I+4LDu3lD2x4TvEYr Q==; X-IronPort-AV: E=Sophos;i="5.99,207,1677538800"; d="scan'208";a="30398476" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 18 Apr 2023 14:20:45 +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 1564A280075; Tue, 18 Apr 2023 14:20:45 +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 v3 4/4] media: imx: imx7-media-csi: Init default format with __imx7_csi_video_try_fmt() Date: Tue, 18 Apr 2023 14:20:41 +0200 Message-Id: <20230418122041.1318862-5-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418122041.1318862-1-alexander.stein@ew.tq-group.com> References: <20230418122041.1318862-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230418_052049_603513_E732C2B7 X-CRM114-Status: GOOD ( 17.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 v3: * New in v3 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 730c9c57bf4bc..b5c8c951eac49 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 */ @@ -1608,22 +1575,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) @@ -1636,9 +1595,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);