From: Jayesh Choudhary <j-choudhary@ti.com>
To: <dianders@chromium.org>, <andrzej.hajda@intel.com>,
<neil.armstrong@linaro.org>, <rfoss@kernel.org>,
<Laurent.pinchart@ideasonboard.com>, <mripard@kernel.org>,
<j-choudhary@ti.com>
Cc: <linux-kernel@vger.kernel.org>, <jonas@kwiboo.se>,
<jernej.skrabec@gmail.com>, <maarten.lankhorst@linux.intel.com>,
<tzimmermann@suse.de>, <airlied@gmail.com>, <daniel@ffwll.ch>,
<spanda@codeaurora.org>, <a-bhatia1@ti.com>,
<dri-devel@lists.freedesktop.org>
Subject: [PATCH v2 2/2] drm/bridge: ti-sn65dsi86: Fix ti_sn_bridge_set_dsi_rate function
Date: Tue, 18 Jun 2024 13:44:18 +0530 [thread overview]
Message-ID: <20240618081418.250953-3-j-choudhary@ti.com> (raw)
In-Reply-To: <20240618081418.250953-1-j-choudhary@ti.com>
During code inspection, it was found that due to integer calculations,
the rounding off can cause errors in the final value propagated in the
registers.
Considering the example of 1080p (very common resolution), the mode->clock
is 148500, dsi->lanes = 4, and bpp = 24, with the previous logic, the DSI
clock frequency would come as 444 when we are expecting the value 445.5
which would reflect in SN_DSIA_CLK_FREQ_REG.
So move the division to be the last operation where rounding off will not
impact the register value.
Fixes: a095f15c00e2 ("drm/bridge: add support for sn65dsi86 bridge driver")
Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com>
---
drivers/gpu/drm/bridge/ti-sn65dsi86.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
index d13b42d7c512..5bf12af6b657 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
@@ -111,8 +111,6 @@
#define AUX_IRQ_STATUS_AUX_SHORT BIT(5)
#define AUX_IRQ_STATUS_NAT_I2C_FAIL BIT(6)
-#define MIN_DSI_CLK_FREQ_MHZ 40
-
/*
* NOTE: DSI clock frequency range: [40MHz,755MHz)
* DSI clock frequency range is in 5-MHz increments
@@ -1219,19 +1217,21 @@ static int ti_sn_bridge_atomic_check(struct drm_bridge *bridge,
{
struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
struct drm_display_mode *mode = &crtc_state->mode;
- unsigned int bit_rate_mhz, clk_freq_mhz;
+ unsigned int bit_rate_khz;
/* Pixel clock check */
if (mode->clock > SN65DSI86_MAX_PIXEL_CLOCK_KHZ)
return -EINVAL;
- bit_rate_mhz = (mode->clock / 1000) *
+ bit_rate_khz = mode->clock *
mipi_dsi_pixel_format_to_bpp(pdata->dsi->format);
- clk_freq_mhz = bit_rate_mhz / (pdata->dsi->lanes * 2);
- /* for each increment in dsi_clk_range, frequency increases by 5MHz */
- pdata->dsi_clk_range = (MIN_DSI_CLK_FREQ_MHZ / 5) +
- (((clk_freq_mhz - MIN_DSI_CLK_FREQ_MHZ) / 5) & 0xFF);
+ /*
+ * For each increment in dsi_clk_range, frequency increases by 5MHz
+ * and the factor of 1000 comes from kHz to MHz conversion
+ */
+ pdata->dsi_clk_range = (bit_rate_khz /
+ (pdata->dsi->lanes * 2 * 1000 * 5)) & 0xFF;
/* SN_DSIA_CLK_FREQ_REG check */
if (pdata->dsi_clk_range > MAX_DSI_CLK_RANGE ||
--
2.25.1
next prev parent reply other threads:[~2024-06-18 8:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 8:14 [PATCH v2 0/2] SN65DSI86 minor fixes Jayesh Choudhary
2024-06-18 8:14 ` [PATCH v2 1/2] drm/bridge: ti-sn65dsi86: Add atomic_check hook for the bridge Jayesh Choudhary
2024-06-18 8:59 ` Dmitry Baryshkov
2024-06-18 9:55 ` Jayesh Choudhary
2024-06-18 10:15 ` Dmitry Baryshkov
2024-06-27 10:17 ` Jayesh Choudhary
2024-06-18 8:14 ` Jayesh Choudhary [this message]
2024-06-18 9:03 ` [PATCH v2 2/2] drm/bridge: ti-sn65dsi86: Fix ti_sn_bridge_set_dsi_rate function Dmitry Baryshkov
2024-06-18 10:04 ` Jayesh Choudhary
2024-06-18 10:09 ` Dmitry Baryshkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240618081418.250953-3-j-choudhary@ti.com \
--to=j-choudhary@ti.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=a-bhatia1@ti.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=daniel@ffwll.ch \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=spanda@codeaurora.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®