linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@bootlin.com>
To: Kishon Vijay Abraham I <kishon@ti.com>,
	Boris Brezillon <boris.brezillon@bootlin.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-media@vger.kernel.org,
	Archit Taneja <architt@codeaurora.org>,
	Andrzej Hajda <a.hajda@samsung.com>, Chen-Yu Tsai <wens@csie.org>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org,
	Krzysztof Witos <kwitos@cadence.com>,
	Rafal Ciepiela <rafalc@cadence.com>,
	Maxime Ripard <maxime.ripard@bootlin.com>
Subject: [PATCH 07/10] drm/bridge: cdns: Remove mode_check test
Date: Wed,  5 Sep 2018 11:16:38 +0200	[thread overview]
Message-ID: <62fe67f20c91471d370913910fcd66f6054aec21.1536138624.git-series.maxime.ripard@bootlin.com> (raw)
In-Reply-To: <cover.ee6158898d563fcc01d45c9652501180bccff0f0.1536138624.git-series.maxime.ripard@bootlin.com>
In-Reply-To: <cover.ee6158898d563fcc01d45c9652501180bccff0f0.1536138624.git-series.maxime.ripard@bootlin.com>

The crtc_* variants of the timings are initialised at the same value than
their !crtc counterparts, and can later on be tweaked. This means that we
can always use the crtc variants, instead of trying to figure out which of
these two we should use.

Move to always use the crtc_* variants, and remove the extra parameter to
the mode2cfg function that allows to tell which variant we should use.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 drivers/gpu/drm/bridge/cdns-dsi.c | 51 ++++++++------------------------
 1 file changed, 14 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/bridge/cdns-dsi.c b/drivers/gpu/drm/bridge/cdns-dsi.c
index ce9496d13986..6474e6d999b7 100644
--- a/drivers/gpu/drm/bridge/cdns-dsi.c
+++ b/drivers/gpu/drm/bridge/cdns-dsi.c
@@ -731,8 +731,7 @@ static unsigned int dpi_to_dsi_timing(unsigned int dpi_timing,
 static int cdns_dsi_mode2cfg(struct cdns_dsi *dsi,
 			     const struct drm_display_mode *mode,
 			     struct cdns_dsi_cfg *dsi_cfg,
-			     struct cdns_dphy_cfg *dphy_cfg,
-			     bool mode_valid_check)
+			     struct cdns_dphy_cfg *dphy_cfg)
 {
 	unsigned long dsi_htotal = 0, dsi_hss_hsa_hse_hbp = 0;
 	struct cdns_dsi_output *output = &dsi->output;
@@ -748,23 +747,15 @@ static int cdns_dsi_mode2cfg(struct cdns_dsi *dsi,
 	bpp = mipi_dsi_pixel_format_to_bpp(output->dev->format);
 	nlanes = output->dev->lanes;
 
-	if (mode_valid_check)
-		tmp = mode->htotal -
-		      (sync_pulse ? mode->hsync_end : mode->hsync_start);
-	else
-		tmp = mode->crtc_htotal -
-		      (sync_pulse ?
-		       mode->crtc_hsync_end : mode->crtc_hsync_start);
+	tmp = mode->crtc_htotal -
+		(sync_pulse ? mode->crtc_hsync_end : mode->crtc_hsync_start);
 
 	dsi_cfg->hbp = dpi_to_dsi_timing(tmp, bpp, DSI_HBP_FRAME_OVERHEAD);
 	dsi_htotal += dsi_cfg->hbp + DSI_HBP_FRAME_OVERHEAD;
 	dsi_hss_hsa_hse_hbp += dsi_cfg->hbp + DSI_HBP_FRAME_OVERHEAD;
 
 	if (sync_pulse) {
-		if (mode_valid_check)
-			tmp = mode->hsync_end - mode->hsync_start;
-		else
-			tmp = mode->crtc_hsync_end - mode->crtc_hsync_start;
+		tmp = mode->crtc_hsync_end - mode->crtc_hsync_start;
 
 		dsi_cfg->hsa = dpi_to_dsi_timing(tmp, bpp,
 						 DSI_HSA_FRAME_OVERHEAD);
@@ -772,32 +763,19 @@ static int cdns_dsi_mode2cfg(struct cdns_dsi *dsi,
 		dsi_hss_hsa_hse_hbp += dsi_cfg->hsa + DSI_HSA_FRAME_OVERHEAD;
 	}
 
-	dsi_cfg->hact = dpi_to_dsi_timing(mode_valid_check ?
-					  mode->hdisplay : mode->crtc_hdisplay,
+	dsi_cfg->hact = dpi_to_dsi_timing(mode->crtc_hdisplay,
 					  bpp, 0);
 	dsi_htotal += dsi_cfg->hact;
 
-	if (mode_valid_check)
-		dpi_hfp = mode->hsync_start - mode->hdisplay;
-	else
-		dpi_hfp = mode->crtc_hsync_start - mode->crtc_hdisplay;
-
+	dpi_hfp = mode->crtc_hsync_start - mode->crtc_hdisplay;
 	dsi_cfg->hfp = dpi_to_dsi_timing(dpi_hfp, bpp, DSI_HFP_FRAME_OVERHEAD);
 	dsi_htotal += dsi_cfg->hfp + DSI_HFP_FRAME_OVERHEAD;
 
-	if (mode_valid_check)
-		ret = cdns_dsi_get_dphy_pll_cfg(dsi->dphy, dphy_cfg,
-						mode->htotal, bpp,
-						mode->clock * 1000,
-						dsi_htotal, nlanes,
-						&dsi_hfp_ext);
-	else
-		ret = cdns_dsi_get_dphy_pll_cfg(dsi->dphy, dphy_cfg,
-						mode->crtc_htotal, bpp,
-						mode->crtc_clock * 1000,
-						dsi_htotal, nlanes,
-						&dsi_hfp_ext);
-
+	ret = cdns_dsi_get_dphy_pll_cfg(dsi->dphy, dphy_cfg,
+					mode->crtc_htotal, bpp,
+					mode->crtc_clock * 1000,
+					dsi_htotal, nlanes,
+					&dsi_hfp_ext);
 	if (ret)
 		return ret;
 
@@ -811,8 +789,7 @@ static int cdns_dsi_mode2cfg(struct cdns_dsi *dsi,
 	 * interface.
 	 */
 	if ((u64)dphy_cfg->lane_bps * dpi_hfp * nlanes <
-	    (u64)dsi_hss_hsa_hse_hbp *
-	    (mode_valid_check ? mode->clock : mode->crtc_clock) * 1000)
+	    (u64)dsi_hss_hsa_hse_hbp * mode->crtc_clock * 1000)
 		return -EINVAL;
 
 	return 0;
@@ -862,7 +839,7 @@ cdns_dsi_bridge_mode_valid(struct drm_bridge *bridge,
 
 	nlanes = output->dev->lanes;
 
-	ret = cdns_dsi_mode2cfg(dsi, mode, &dsi_cfg, &dphy_cfg, true);
+	ret = cdns_dsi_mode2cfg(dsi, mode, &dsi_cfg, &dphy_cfg);
 	if (ret)
 		return MODE_CLOCK_RANGE;
 
@@ -990,7 +967,7 @@ static void cdns_dsi_bridge_enable(struct drm_bridge *bridge)
 	bpp = mipi_dsi_pixel_format_to_bpp(output->dev->format);
 	nlanes = output->dev->lanes;
 
-	WARN_ON_ONCE(cdns_dsi_mode2cfg(dsi, mode, &dsi_cfg, &dphy_cfg, false));
+	WARN_ON_ONCE(cdns_dsi_mode2cfg(dsi, mode, &dsi_cfg, &dphy_cfg));
 
 	cdns_dsi_hs_init(dsi, &dphy_cfg);
 	cdns_dsi_init_link(dsi);
-- 
git-series 0.9.1

  parent reply	other threads:[~2018-09-05  9:17 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05  9:16 [PATCH 00/10] phy: Add configuration interface for MIPI D-PHY devices Maxime Ripard
2018-09-05  9:16 ` [PATCH 01/10] phy: Add MIPI D-PHY mode Maxime Ripard
2018-09-05 13:46   ` Laurent Pinchart
2018-09-05  9:16 ` [PATCH 02/10] phy: Add configuration interface Maxime Ripard
2018-09-05 13:39   ` Laurent Pinchart
2018-09-06 14:48     ` Maxime Ripard
2018-09-06 16:24       ` Andrew Lunn
2018-09-07  9:01         ` Maxime Ripard
2018-09-06 16:51       ` Laurent Pinchart
2018-09-07  9:07         ` Maxime Ripard
2018-09-06  9:27   ` Kishon Vijay Abraham I
2018-09-06 14:56     ` Maxime Ripard
2018-09-12  7:42       ` Kishon Vijay Abraham I
2018-09-12  8:42         ` Maxime Ripard
2018-09-14  8:48           ` Kishon Vijay Abraham I
2018-09-19 12:14             ` Maxime Ripard
2018-09-21 14:18               ` Maxime Ripard
2018-09-24  8:48               ` Kishon Vijay Abraham I
2018-09-24  9:54                 ` Maxime Ripard
2018-09-24 11:55                   ` Kishon Vijay Abraham I
2018-09-24 12:19                     ` Maxime Ripard
2018-09-05  9:16 ` [PATCH 03/10] phy: Add MIPI D-PHY configuration options Maxime Ripard
2018-09-05 13:43   ` Laurent Pinchart
2018-09-07  8:56     ` Maxime Ripard
2018-09-07 14:50       ` Laurent Pinchart
2018-09-10 14:18         ` Maxime Ripard
2018-09-05  9:16 ` [PATCH 04/10] phy: dphy: Add configuration helpers Maxime Ripard
2018-09-05 13:46   ` Laurent Pinchart
2018-09-07 13:37     ` Maxime Ripard
2018-09-07 14:26       ` Laurent Pinchart
2018-09-10 14:16         ` Maxime Ripard
2018-09-10 14:28           ` Laurent Pinchart
2018-09-05  9:16 ` [PATCH 05/10] sun6i: dsi: Convert to generic phy handling Maxime Ripard
2018-09-05  9:16 ` [PATCH 06/10] phy: Move Allwinner A31 D-PHY driver to drivers/phy/ Maxime Ripard
2018-09-05  9:16 ` Maxime Ripard [this message]
2018-09-05  9:16 ` [PATCH 08/10] drm/bridge: cdns: Separate DSI and D-PHY configuration Maxime Ripard
2018-09-05  9:16 ` [PATCH 09/10] phy: Add Cadence D-PHY support Maxime Ripard
2018-09-05 13:48   ` Laurent Pinchart
2018-09-07 13:38     ` Maxime Ripard
2018-09-05  9:16 ` [PATCH 10/10] drm/bridge: cdns: Convert to phy framework Maxime Ripard

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=62fe67f20c91471d370913910fcd66f6054aec21.1536138624.git-series.maxime.ripard@bootlin.com \
    --to=maxime.ripard@bootlin.com \
    --cc=a.hajda@samsung.com \
    --cc=architt@codeaurora.org \
    --cc=boris.brezillon@bootlin.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kishon@ti.com \
    --cc=kwitos@cadence.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=rafalc@cadence.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=wens@csie.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;
as well as URLs for NNTP newsgroup(s).