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: 13319952 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 13566EB64DD for ; Thu, 20 Jul 2023 07:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231641AbjGTHlj (ORCPT ); Thu, 20 Jul 2023 03:41:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjGTHli (ORCPT ); Thu, 20 Jul 2023 03:41:38 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EF4D2122 for ; Thu, 20 Jul 2023 00:41:36 -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=1689838896; x=1721374896; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NypF6BjMiKMUosxHTXziAHI4i73qdfEnHzAUvrdx/3s=; b=VrUg6DdRlAWvuvdQ15+RC4KbA6o6ankxFaV3nGqyRM7SCH9JhDOXxp2A bpkb8SV9IHLWSZQf2wAALRGEN+AJx9h8PtDka7i3vFLPYIj2EtmC/vBVR QyDoE/TQWtGtAIEMaFzcEB0HUrx021iRW6ozzZI3KQNgOUNrtgpx0q7mw Fpm/nAx/MLSlGsAg5UYH/w7uH76BQlGIOcdj65AVnt/JSspLxdPq3glH6 nocAv4BfI62XBfEt8/HxV7RLEWq1oMdqXvvpG/H9mQyt+OKbAhsJDIUGx DmI8liHe1fl8w2Tm/WcaVlP5L6BOu8bqf52KsWp3EzmwIjWpSx66b/ePK A==; 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 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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;