From patchwork Tue Apr 2 08:29:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13613554 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 7F5A2C6FD1F for ; Tue, 2 Apr 2024 08:30:07 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ipkW6Xnsq5/117/qTz21bPQa/YY62oiRqM7BffbRnI0=; b=1PSFJvdZA72w5W jIr3zr2NnzDFIgY4C7XgYHh8SawHf3RTz1BRVxrZG42pmsmcU98Rako428YV6jM9VkMGLk8IYEWM/ PJb4DgFbt4FtA5OBSJ7vP1OPwPk57He9/t8dyqPHwOw0EBRRSS0xpWuXjwAvncwse+519uD4FWuY2 XudseWZ0xKusDtfIIBIaQ8XeMLgGugwyRE712dlgHCLr58pE4GdVFVgntdxirFdqJEomdR9z7KNec gEogREXC5xUquGXz3NtMQMdaTZaAa9o32xSLkUDMVRXL8FfpbWSBqPH9oxGdM+AW0iqduUEd3vwlN 11U+3l8D0vLp7w0cxsOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrZWj-0000000AES0-0RYp; Tue, 02 Apr 2024 08:29:53 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrZWc-0000000AENY-24P4 for linux-arm-kernel@lists.infradead.org; Tue, 02 Apr 2024 08:29:49 +0000 Received: from [192.168.1.118] (unknown [103.86.18.232]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AFE6F3A2; Tue, 2 Apr 2024 10:29:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712046548; bh=w5Y4HAhWpPFs303OWWtOgDs1po79LqgdLoTPOFnYzS8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AvmNUIA4nC8tV78ryeJRsGKx9yYGbUtddVBb71TunCHFqoV88GFddPrU48Ew0oF7f /s0U/mxXmEDHaHz27IhcWLHej3ZHwwaAYWh61ZS8ysh/69MtmDP4QKlFsn5dxPOp+C gqt+pJZP47Pdp5XWV4Suh/HhgZZIfXS9RjebXrjk= From: Umang Jain Date: Tue, 02 Apr 2024 13:59:27 +0530 Subject: [PATCH 3/3] fixups MIME-Version: 1.0 Message-Id: <20240402-kernel-name-extraversion-v1-3-57bb38de841b@ideasonboard.com> References: <20240402-kernel-name-extraversion-v1-0-57bb38de841b@ideasonboard.com> In-Reply-To: <20240402-kernel-name-extraversion-v1-0-57bb38de841b@ideasonboard.com> To: Kieran Bingham , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Sakari Ailus Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Umang Jain X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712046569; l=2587; i=umang.jain@ideasonboard.com; s=20240402; h=from:subject:message-id; bh=w5Y4HAhWpPFs303OWWtOgDs1po79LqgdLoTPOFnYzS8=; b=5IBzj1PKxlH3VdAL+w8r6TYuSlgTEiVJsOLgy1YTyK8k6P6fVvCzwHwcwMkYLt2q0To5bP6gz N1CDL8oEBR/DP8Od0JqI1++81Yub8+bS4U9OQl/qIrbvYUJItUnwfa0 X-Developer-Key: i=umang.jain@ideasonboard.com; a=ed25519; pk=8K9qSAtc2dNF4Ax+jYC0w9dlfptU7wxPBQwOy0nxRoc= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240402_012946_798901_A84E3D1D 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 --- drivers/media/i2c/imx283.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c index 81fe2d4fd4d3..ace8f65aa6b3 100644 --- a/drivers/media/i2c/imx283.c +++ b/drivers/media/i2c/imx283.c @@ -450,12 +450,12 @@ static const struct imx283_mode supported_modes_12bit[] = { .bpp = 12, .width = 2736, .height = 1824, - .min_hmax = 1870, /* Pixels (362 * 360/72 + padding) */ + .min_hmax = 2414, /* Pixels (362 * 480MHz/72MHz + padding) */ .min_vmax = 3840, /* Lines */ /* 50.00 FPS */ - .default_hmax = 1870, /* 362 @ 360MHz/72MHz */ - .default_vmax = 3960, + .default_hmax = 2500, /* 375 @ 480MHz/72Mhz */ + .default_vmax = 3840, .veff = 1824, .vst = 0, @@ -483,7 +483,7 @@ static const struct imx283_mode supported_modes_10bit[] = { .min_vmax = 3793, /* 25.00 FPS */ - .default_hmax = 1500, /* 750 @ 576MHz / 72MHz */ + .default_hmax = 6000, /* 750 @ 576MHz / 72MHz */ .default_vmax = 3840, .min_shr = 10, @@ -568,12 +568,15 @@ static inline void get_mode_table(unsigned int code, static u64 imx283_pixel_rate(struct imx283 *imx283, const struct imx283_mode *mode) { + u64 link_frequency = link_frequencies[__ffs(imx283->link_freq_bitmap)]; unsigned int bpp = mode->bpp; const unsigned int ddr = 2; /* Double Data Rate */ const unsigned int lanes = 4; /* Only 4 lane support */ - u64 link_frequency = link_frequencies[__ffs(imx283->link_freq_bitmap)]; + u64 numerator = link_frequency * ddr * lanes; - return link_frequency * ddr * lanes / bpp; + do_div(numerator, bpp); + + return numerator; } /* Convert from a variable pixel_rate to 72 MHz clock cycles */ @@ -588,8 +591,11 @@ static u64 imx283_internal_clock(unsigned int pixel_rate, unsigned int pixels) */ const u32 iclk_pre = 72; const u32 pclk_pre = pixel_rate / HZ_PER_MHZ; + u64 numerator = pixels * iclk_pre; + + do_div(numerator, pclk_pre); - return pixels * iclk_pre / pclk_pre; + return numerator; } /* Internal clock (72MHz) to Pixel Rate clock (Variable) */ @@ -604,8 +610,11 @@ static u64 imx283_iclk_to_pix(unsigned int pixel_rate, unsigned int cycles) */ const u32 iclk_pre = 72; const u32 pclk_pre = pixel_rate / HZ_PER_MHZ; + u64 numerator = cycles * pclk_pre; + + do_div(numerator, iclk_pre); - return cycles * pclk_pre / iclk_pre; + return numerator; } /* Determine the exposure based on current hmax, vmax and a given SHR */