From patchwork Thu Jul 20 07:41:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13319953 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 3A325EB64DD for ; Thu, 20 Jul 2023 07:42:02 +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: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:In-Reply-To:References: List-Owner; bh=6y8YJU2t5aSLQspgO+gMQtEHgnvAQ3mhP4bfyD5GIX4=; b=PmrDWTRsmMfqQ5 ZGSWI2YymH659WCjeM08hBASjzEEp+RHb6iqHpTKUl6Kzr2EZCTLyJdpCZus+89q5jSJu5EGJ/Fvp ZAw5NxcMnqZKvpXvwbucyWWnBvru9JOwBxBhLw3NKS+SMfg++mjpX/xlCZGNuwrkJMXYxmKU2eFk3 QlwQ6ITltsTo2A0qCdulg0YZpi3dTkbnXO7nHXjss3vXlyH5NTcCuuAXley0wN3qrea8bRKBeDoiP iG5CLgkAkKcnRXuRGj+iPv8GkrRhBw5zRaMvniBdXsW88bijjQk+vnpRB6WgCzc0FsMwTe5y0pNSR t8snbh+gLcC7EkjtlSYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qMOID-00A9R4-0t; Thu, 20 Jul 2023 07:41:45 +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 1qMOI9-00A9PG-2J for linux-arm-kernel@lists.infradead.org; Thu, 20 Jul 2023 07:41:43 +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=1689838901; x=1721374901; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=cXY/BLZfaDuNi5P3IqCRO4cP4HDGKE/2ag+TBekzt7g=; b=kft+6grxy5w2dVEb2kTg2TjUf1LivJ6fREpDEPlviAhTYecS++jsdrW2 /ck6F9+o70fgx/O0Qy0XCgYERNTu/vaUE0xrDuGvva0U1llIejkiis/M2 8o7YutktD1eHBiINOMvSE24SHYTO8j82G0A5K4Myefr+KNsRvafbalQIb wJqc8jjfAgkWst2I7BoUveITs29Hx1RDZ9QCMmCdoklUqNxpeBj2FCAxW b0TL0D+I2KFDFmgoqzJxxI3jBOy2COyaLURD++Mrdij/NP5P5XGDk4I2V 0Y8aoKwaRFyVXZDPbavkjuBGlhoCEcsD5Bc4UDJg5XxvNQhAdX/Pbvj+t w==; X-IronPort-AV: E=Sophos;i="6.01,218,1684792800"; d="scan'208";a="32025079" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 20 Jul 2023 09:41:32 +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) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id 8C2FA280078; Thu, 20 Jul 2023 09:41:32 +0200 (CEST) From: Alexander Stein To: Rui Miguel Silva , Laurent Pinchart , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Fabio Estevam , Tim Harvey Cc: Alexander Stein , Pengutronix Kernel Team , NXP Linux Team , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] media: imx: imx7-media-csi: Move stepwise framesize into a dedicated struct Date: Thu, 20 Jul 2023 09:41:28 +0200 Message-Id: <20230720074129.3680269-1-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230720_004142_078410_EAF84B7F X-CRM114-Status: GOOD ( 13.09 ) 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 This way these constraints can be reused later on. No functional change intended. Signed-off-by: Alexander Stein --- drivers/media/platform/nxp/imx7-media-csi.c | 26 ++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 2f9302fc7570..73f8f2a35422 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -260,6 +260,20 @@ imx7_csi_notifier_to_dev(struct v4l2_async_notifier *n) return container_of(n, struct imx7_csi, notifier); } +/* + * TODO: The constraints are hardware-specific and may depend on the + * pixel format. This should come from the driver using + * imx_media_capture. + */ +static const struct v4l2_frmsize_stepwise imx7_csi_frmsize_stepwise = { + .min_width = 1, + .min_height = 1, + .max_width = 65535, + .max_height = 65535, + .step_width = 1, + .step_height = 1, +}; + /* ----------------------------------------------------------------------------- * Hardware Configuration */ @@ -1082,18 +1096,8 @@ static int imx7_csi_video_enum_framesizes(struct file *file, void *fh, if (!cc) return -EINVAL; - /* - * TODO: The constraints are hardware-specific and may depend on the - * pixel format. This should come from the driver using - * imx_media_capture. - */ fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS; - fsize->stepwise.min_width = 1; - fsize->stepwise.max_width = 65535; - fsize->stepwise.min_height = 1; - fsize->stepwise.max_height = 65535; - fsize->stepwise.step_width = 1; - fsize->stepwise.step_height = 1; + fsize->stepwise = imx7_csi_frmsize_stepwise; return 0; } From patchwork Thu Jul 20 07:41:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13319954 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 1B918EB64DA for ; Thu, 20 Jul 2023 07:42:08 +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=Kx2cakqAKsDG+En94A1TBUQkKd6MUHF3hdWrgzsnYlY=; b=luDSK+ziS/fOzf WYqUcnfsJdjHf9rhGqgzSkoGDFU8QwWPFAN7Meg69NVXFIPJl73UeMGwRo8OHP/WxJmOu3JJPME9G xZ62McRvzqIhMyMM14hkFFEOJryYDlXw80oeH2dY5gGtxfM6oU6DQ/ZKaQnopXYvUQQRYwT1FjUga MQd+hxDpxsLUdBYEDkWxP4Q1w5gnRqa2GRkT/xcgken0P2ljJZNUR7hEyRv/NDeZ7+wfQl8MOiXMY nU4PVl/GnPeqUg71YjVJKimDEItewME82zR6G5pW0o/mFAIDmSWD0kDqhl+1jqPmo5SgXCIQcGfg8 jBmFAORqixrb7+kHozXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qMOII-00A9Ro-2o; Thu, 20 Jul 2023 07:41:50 +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 1qMOIB-00A9PG-2Y for linux-arm-kernel@lists.infradead.org; Thu, 20 Jul 2023 07:41:45 +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=1689838903; x=1721374903; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NypF6BjMiKMUosxHTXziAHI4i73qdfEnHzAUvrdx/3s=; b=SJfHw9RDfajHcTYrjdl3yjGE430TO9mraK0guVn9BEX12mifFPUc0IUs 5mj73PR6blnilwcUFRQDoZGGGKQWm2aCX+w5gUtY0gBOXONvGzf42nP4t dUDmQkR9tVMSp7IghU+Qmlr2F8WQinAiPp7jvsy/AV5RbPXqy1cZzUbRe j83xiZ6I8/7eqUR5ifD7Vd2uBWaQYh0266VJTFMiVB+O6NpOa4b6q6EIO jA0+Zkl44XPnp1AGvu7hp0dq/jnUri7CYfxvDVRSIzOBx5/GUY8CjR4jp soHgElNTYEqrgHqPTclBUFHtT6CCL/uBq7e3LaDj4VJM8OyM8BLhmn7Sa g==; X-IronPort-AV: E=Sophos;i="6.01,218,1684792800"; d="scan'208";a="32025080" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 20 Jul 2023 09:41:32 +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) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id BEB97280084; Thu, 20 Jul 2023 09:41:32 +0200 (CEST) From: Alexander Stein To: Rui Miguel Silva , Laurent Pinchart , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Fabio Estevam , Tim Harvey Cc: Alexander Stein , Pengutronix Kernel Team , NXP Linux Team , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] media: imx: imx7-media-csi: Fix applying format constraints Date: Thu, 20 Jul 2023 09:41:29 +0200 Message-Id: <20230720074129.3680269-2-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230720074129.3680269-1-alexander.stein@ew.tq-group.com> References: <20230720074129.3680269-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-20230720_004144_134747_1CF2BAA0 X-CRM114-Status: GOOD ( 12.26 ) 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 v4l_bound_align_image aligns to a multiple power of 2 of walign, but the result only needs to be a multiple of walign. Fix this by using v4l2_apply_frmsize_constraints() instead. Reported-by: Tim Harvey Fixes: 6f482c4729d9 ("media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt") Signed-off-by: Alexander Stein --- Tim, can you please test if this fixes your problem? Apparently this issue only arises under specific conditions, e.g. 640/480/8bpp. This issue does not show up for 640/480/10bpp. drivers/media/platform/nxp/imx7-media-csi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 73f8f2a35422..523e5f039a5a 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1141,8 +1141,8 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, * TODO: Implement configurable stride support. */ walign = 8 * 8 / cc->bpp; - v4l_bound_align_image(&pixfmt->width, 1, 0xffff, walign, - &pixfmt->height, 1, 0xffff, 1, 0); + v4l2_apply_frmsize_constraints(&pixfmt->width, &pixfmt->height, + &imx7_csi_frmsize_stepwise); pixfmt->bytesperline = pixfmt->width * cc->bpp / 8; pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;