public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Tretter <m.tretter@pengutronix.de>
To: Maxim Schwalm <maxim.schwalm@gmail.com>
Cc: kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, Inki Dae <inki.dae@samsung.com>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>
Subject: Re: [PATCH 5/5] drm/bridge: samsung-dsim: calculate porches in Hz
Date: Fri, 8 Sep 2023 10:20:44 +0200	[thread overview]
Message-ID: <20230908082044.GA767994@pengutronix.de> (raw)
In-Reply-To: <53ee3d14-05f4-981f-26d2-ef9ef6b3a61b@gmail.com>

On Mon, 04 Sep 2023 16:28:37 +0200, Maxim Schwalm wrote:
> On 28.08.23 17:59, Michael Tretter wrote:
> > Calculating the byte_clk in kHz is imprecise for a hs_clock of 55687500
> > Hz, which may be used with a pixel clock of 74.25 MHz with mode
> > 1920x1080-30.
> > 
> > Fix the calculation by using HZ instead of kHZ.
> > 
> > This requires to change the type to u64 to prevent overflows of the
> > integer type.
> > 
> > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> > ---
> >  drivers/gpu/drm/bridge/samsung-dsim.c | 10 ++++++----
> >  1 file changed, 6 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
> > index 459be953be55..eb7aca2b9ab7 100644
> > --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> > +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> > @@ -973,10 +973,12 @@ static void samsung_dsim_set_display_mode(struct samsung_dsim *dsi)
> >  	u32 reg;
> >  
> >  	if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO) {
> > -		int byte_clk_khz = dsi->hs_clock / 1000 / 8;
> > -		int hfp = DIV_ROUND_UP((m->hsync_start - m->hdisplay) * byte_clk_khz, m->clock);
> > -		int hbp = DIV_ROUND_UP((m->htotal - m->hsync_end) * byte_clk_khz, m->clock);
> > -		int hsa = DIV_ROUND_UP((m->hsync_end - m->hsync_start) * byte_clk_khz, m->clock);
> > +		u64 byte_clk = dsi->hs_clock / 8;
> > +		u64 pix_clk = m->clock * 1000;
> > +
> > +		int hfp = DIV64_U64_ROUND_UP((m->hsync_start - m->hdisplay) * byte_clk, pix_clk);
> > +		int hbp = DIV64_U64_ROUND_UP((m->htotal - m->hsync_end) * byte_clk, pix_clk);
> > +		int hsa = DIV64_U64_ROUND_UP((m->hsync_end - m->hsync_start) * byte_clk, pix_clk);
> 
> Wouldn't it make sense to use the videomode structure here?

That would introduce a dependency on VIDEOMODE_HELPERS to avoid four explicit
calculations of the pixel clock in Hz and the porches in pixels. I don't think
that's really worth it.

Michael

> 
> >  
> >  		/* remove packet overhead when possible */
> >  		hfp = max(hfp - 6, 0);
> > 
> 
> Best regards,
> Maxim
> 

  reply	other threads:[~2023-09-08  8:20 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28 15:59 [PATCH 0/5] drm/bridge: samsung-dsim: fix various modes with ADV7535 bridge Michael Tretter
2023-08-28 15:59 ` [PATCH 1/5] drm/bridge: samsung-dsim: add more mipi-dsi device debug information Michael Tretter
2023-08-28 22:37   ` Adam Ford
2023-09-04  1:04     ` Inki Dae
2023-09-27 12:47       ` Adam Ford
2023-10-04 15:22         ` Michael Tretter
2023-08-28 15:59 ` [PATCH 2/5] drm/bridge: samsung-dsim: reread ref clock before configuring PLL Michael Tretter
2023-09-04  4:38   ` Inki Dae
2023-09-04 11:04     ` Michael Tretter
2023-08-28 15:59 ` [PATCH 3/5] drm/bridge: samsung-dsim: update PLL reference clock Michael Tretter
2023-08-28 16:41   ` Marco Felsch
2023-08-28 18:17     ` Adam Ford
2023-08-29  7:49       ` Michael Tretter
2023-09-04  5:44   ` Inki Dae
2023-09-04 11:15     ` Michael Tretter
2023-09-05  9:06       ` 대인기/Tizen Platform Lab(SR)/삼성전자
2023-09-08  9:47         ` Michael Tretter
2023-09-18  8:42           ` 대인기/Tizen Platform Lab(SR)/삼성전자
2023-08-28 15:59 ` [PATCH 4/5] drm/bridge: samsung-dsim: adjust porches by rounding up Michael Tretter
2023-08-28 18:26   ` Fabio Estevam
2023-08-28 22:39     ` Adam Ford
2023-08-29  7:51       ` Michael Tretter
2023-08-28 15:59 ` [PATCH 5/5] drm/bridge: samsung-dsim: calculate porches in Hz Michael Tretter
2023-08-28 22:41   ` Adam Ford
2023-09-04 14:28   ` Maxim Schwalm
2023-09-08  8:20     ` Michael Tretter [this message]
2023-08-28 16:13 ` [PATCH 0/5] drm/bridge: samsung-dsim: fix various modes with ADV7535 bridge Adam Ford
2023-08-28 23:07   ` Adam Ford
2023-08-29  8:03     ` Michael Tretter
2023-08-28 16:42 ` Marco Felsch
2023-09-04 14:02 ` Frieder Schrempf
2023-09-06  9:31   ` Frieder Schrempf
2023-09-06  9:56     ` Michael Tretter
2023-09-07  8:20       ` Frieder Schrempf

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=20230908082044.GA767994@pengutronix.de \
    --to=m.tretter@pengutronix.de \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=jagan@amarulasolutions.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=maxim.schwalm@gmail.com \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    /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