All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [PATCH v2 12/30] drm: omapdrm: dss: Store the registered plls array in struct dss_device
Date: Tue, 13 Feb 2018 14:00:30 +0200	[thread overview]
Message-ID: <20180213120048.21603-13-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20180213120048.21603-1-laurent.pinchart@ideasonboard.com>

As part of an effort to remove the usage of global variables in the
driver, store the registered plls array in the dss_device structure
instead of a global variable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
---
 drivers/gpu/drm/omapdrm/dss/dispc.c     |  4 ++--
 drivers/gpu/drm/omapdrm/dss/dpi.c       | 17 +++++++-------
 drivers/gpu/drm/omapdrm/dss/dsi.c       |  3 +--
 drivers/gpu/drm/omapdrm/dss/dss.h       |  8 ++++---
 drivers/gpu/drm/omapdrm/dss/hdmi_pll.c  |  3 +--
 drivers/gpu/drm/omapdrm/dss/pll.c       | 40 +++++++++++++++++----------------
 drivers/gpu/drm/omapdrm/dss/video-pll.c |  3 +--
 7 files changed, 40 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 3428ffea70ee..285d297db229 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -3123,7 +3123,7 @@ static unsigned long dispc_fclk_rate(void)
 		struct dss_pll *pll;
 		unsigned int clkout_idx;
 
-		pll = dss_pll_find_by_src(src);
+		pll = dss_pll_find_by_src(dispc.dss, src);
 		clkout_idx = dss_pll_get_clkout_idx_for_src(src);
 
 		r = pll->cinfo.clkout[clkout_idx];
@@ -3150,7 +3150,7 @@ static unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
 		struct dss_pll *pll;
 		unsigned int clkout_idx;
 
-		pll = dss_pll_find_by_src(src);
+		pll = dss_pll_find_by_src(dispc.dss, src);
 		clkout_idx = dss_pll_get_clkout_idx_for_src(src);
 
 		r = pll->cinfo.clkout[clkout_idx];
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index ba5adfb7ee70..338ceb1ba61b 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -58,7 +58,8 @@ static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev)
 	return container_of(dssdev, struct dpi_data, output);
 }
 
-static enum dss_clk_source dpi_get_clk_src_dra7xx(enum omap_channel channel)
+static enum dss_clk_source dpi_get_clk_src_dra7xx(struct dpi_data *dpi,
+						  enum omap_channel channel)
 {
 	/*
 	 * Possible clock sources:
@@ -70,23 +71,23 @@ static enum dss_clk_source dpi_get_clk_src_dra7xx(enum omap_channel channel)
 	switch (channel) {
 	case OMAP_DSS_CHANNEL_LCD:
 	{
-		if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_1))
+		if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_1))
 			return DSS_CLK_SRC_PLL1_1;
 		break;
 	}
 	case OMAP_DSS_CHANNEL_LCD2:
 	{
-		if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_3))
+		if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_3))
 			return DSS_CLK_SRC_PLL1_3;
-		if (dss_pll_find_by_src(DSS_CLK_SRC_PLL2_3))
+		if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL2_3))
 			return DSS_CLK_SRC_PLL2_3;
 		break;
 	}
 	case OMAP_DSS_CHANNEL_LCD3:
 	{
-		if (dss_pll_find_by_src(DSS_CLK_SRC_PLL2_1))
+		if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL2_1))
 			return DSS_CLK_SRC_PLL2_1;
-		if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_3))
+		if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_3))
 			return DSS_CLK_SRC_PLL1_3;
 		break;
 	}
@@ -133,7 +134,7 @@ static enum dss_clk_source dpi_get_clk_src(struct dpi_data *dpi)
 		}
 
 	case DSS_MODEL_DRA7:
-		return dpi_get_clk_src_dra7xx(channel);
+		return dpi_get_clk_src_dra7xx(dpi, channel);
 
 	default:
 		return DSS_CLK_SRC_FCK;
@@ -605,7 +606,7 @@ static void dpi_init_pll(struct dpi_data *dpi)
 
 	dpi->clk_src = dpi_get_clk_src(dpi);
 
-	pll = dss_pll_find_by_src(dpi->clk_src);
+	pll = dss_pll_find_by_src(dpi->dss, dpi->clk_src);
 	if (!pll)
 		return;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index a676d27dd479..448986031a6a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5353,9 +5353,8 @@ static int dsi_init_pll_data(struct dss_device *dss,
 	pll->base = dsi->pll_base;
 	pll->hw = dsi->data->pll_hw;
 	pll->ops = &dsi_pll_ops;
-	pll->dss = dss;
 
-	r = dss_pll_register(pll);
+	r = dss_pll_register(dss, pll);
 	if (r)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index ec8e40e09141..8cc4b6ca203e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -267,6 +267,7 @@ struct dss_device {
 		struct dss_debugfs_entry *dss;
 	} debugfs;
 
+	struct dss_pll *plls[4];
 	struct dss_pll	*video1_pll;
 	struct dss_pll	*video2_pll;
 };
@@ -458,10 +459,11 @@ typedef bool (*dss_pll_calc_func)(int n, int m, unsigned long fint,
 typedef bool (*dss_hsdiv_calc_func)(int m_dispc, unsigned long dispc,
 		void *data);
 
-int dss_pll_register(struct dss_pll *pll);
+int dss_pll_register(struct dss_device *dss, struct dss_pll *pll);
 void dss_pll_unregister(struct dss_pll *pll);
-struct dss_pll *dss_pll_find(const char *name);
-struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src);
+struct dss_pll *dss_pll_find(struct dss_device *dss, const char *name);
+struct dss_pll *dss_pll_find_by_src(struct dss_device *dss,
+				    enum dss_clk_source src);
 unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src);
 int dss_pll_enable(struct dss_pll *pll);
 void dss_pll_disable(struct dss_pll *pll);
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
index 4fb97cd0cc8d..e7be3707d147 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
@@ -146,7 +146,6 @@ static int hdmi_init_pll_data(struct dss_device *dss,
 	pll->id = DSS_PLL_HDMI;
 	pll->base = hpll->base;
 	pll->clkin = clk;
-	pll->dss = dss;
 
 	if (hpll->wp->version == 4)
 		pll->hw = &dss_omap4_hdmi_pll_hw;
@@ -155,7 +154,7 @@ static int hdmi_init_pll_data(struct dss_device *dss,
 
 	pll->ops = &hdmi_pll_ops;
 
-	r = dss_pll_register(pll);
+	r = dss_pll_register(dss, pll);
 	if (r)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c
index ecb03277d831..078b0e8216c3 100644
--- a/drivers/gpu/drm/omapdrm/dss/pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/pll.c
@@ -35,15 +35,14 @@
 #define PLL_SSC_CONFIGURATION2		0x001C
 #define PLL_CONFIGURATION4		0x0020
 
-static struct dss_pll *dss_plls[4];
-
-int dss_pll_register(struct dss_pll *pll)
+int dss_pll_register(struct dss_device *dss, struct dss_pll *pll)
 {
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(dss_plls); ++i) {
-		if (!dss_plls[i]) {
-			dss_plls[i] = pll;
+	for (i = 0; i < ARRAY_SIZE(dss->plls); ++i) {
+		if (!dss->plls[i]) {
+			dss->plls[i] = pll;
+			pll->dss = dss;
 			return 0;
 		}
 	}
@@ -53,29 +52,32 @@ int dss_pll_register(struct dss_pll *pll)
 
 void dss_pll_unregister(struct dss_pll *pll)
 {
+	struct dss_device *dss = pll->dss;
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(dss_plls); ++i) {
-		if (dss_plls[i] == pll) {
-			dss_plls[i] = NULL;
+	for (i = 0; i < ARRAY_SIZE(dss->plls); ++i) {
+		if (dss->plls[i] == pll) {
+			dss->plls[i] = NULL;
+			pll->dss = NULL;
 			return;
 		}
 	}
 }
 
-struct dss_pll *dss_pll_find(const char *name)
+struct dss_pll *dss_pll_find(struct dss_device *dss, const char *name)
 {
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(dss_plls); ++i) {
-		if (dss_plls[i] && strcmp(dss_plls[i]->name, name) == 0)
-			return dss_plls[i];
+	for (i = 0; i < ARRAY_SIZE(dss->plls); ++i) {
+		if (dss->plls[i] && strcmp(dss->plls[i]->name, name) == 0)
+			return dss->plls[i];
 	}
 
 	return NULL;
 }
 
-struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src)
+struct dss_pll *dss_pll_find_by_src(struct dss_device *dss,
+				    enum dss_clk_source src)
 {
 	struct dss_pll *pll;
 
@@ -85,22 +87,22 @@ struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src)
 		return NULL;
 
 	case DSS_CLK_SRC_HDMI_PLL:
-		return dss_pll_find("hdmi");
+		return dss_pll_find(dss, "hdmi");
 
 	case DSS_CLK_SRC_PLL1_1:
 	case DSS_CLK_SRC_PLL1_2:
 	case DSS_CLK_SRC_PLL1_3:
-		pll = dss_pll_find("dsi0");
+		pll = dss_pll_find(dss, "dsi0");
 		if (!pll)
-			pll = dss_pll_find("video0");
+			pll = dss_pll_find(dss, "video0");
 		return pll;
 
 	case DSS_CLK_SRC_PLL2_1:
 	case DSS_CLK_SRC_PLL2_2:
 	case DSS_CLK_SRC_PLL2_3:
-		pll = dss_pll_find("dsi1");
+		pll = dss_pll_find(dss, "dsi1");
 		if (!pll)
-			pll = dss_pll_find("video1");
+			pll = dss_pll_find(dss, "video1");
 		return pll;
 	}
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c b/drivers/gpu/drm/omapdrm/dss/video-pll.c
index 344e7e0bbc4e..585ed94ccf17 100644
--- a/drivers/gpu/drm/omapdrm/dss/video-pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c
@@ -190,9 +190,8 @@ struct dss_pll *dss_video_pll_init(struct dss_device *dss,
 	pll->base = pll_base;
 	pll->hw = &dss_dra7_video_pll_hw;
 	pll->ops = &dss_pll_ops;
-	pll->dss = dss;
 
-	r = dss_pll_register(pll);
+	r = dss_pll_register(dss, pll);
 	if (r)
 		return ERR_PTR(r);
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-02-13 12:00 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-13 12:00 [PATCH v2 00/30] omapdrm: Allocate objects dynamically Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 01/30] drm: omapdrm: Split init and cleanup from probe and remove functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 02/30] drm: omapdrm: dss: Expose DSS data in a dss_device structure Laurent Pinchart
2018-02-13 20:05   ` Sebastian Reichel
2018-02-13 12:00 ` [PATCH v2 03/30] drm: omapdrm: dss: Pass DSS private structure to runtime PM functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 04/30] drm: omapdrm: dss: Pass PLL pointer to dss_ctrl_pll_enable() Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 05/30] drm: omapdrm: dss: Pass DSS pointer to dss_sdi_*() functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 06/30] drm: omapdrm: dss: Pass DSS pointer to dss_ops operations Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 07/30] drm: omapdrm: dss: Pass DSS pointer to dss_get_*_clk_source() Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 08/30] drm: omapdrm: dss: Pass DSS pointer to dss clock functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 09/30] drm: omapdrm: dss: Pass DSS pointer to remaining dss functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 10/30] drm: omapdrm: dss: Allocate the DSS private data structure dynamically Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 11/30] drm: omapdrm: dss: Support passing private data to debugfs show handlers Laurent Pinchart
2018-02-13 12:00 ` Laurent Pinchart [this message]
2018-02-13 12:00 ` [PATCH v2 13/30] drm: omapdrm: dss: Store the debugfs root directory in struct dss_device Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 14/30] drm: omapdrm: dss: Don't unnecessarily cast to dev to pdev and back Laurent Pinchart
2018-02-13 20:23   ` Sebastian Reichel
2018-02-13 12:00 ` [PATCH v2 15/30] drm: omapdrm: dsi: Pass the dsi_data pointer to internal functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 16/30] drm: omapdrm: dsi: Combine two commonly used inline functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 17/30] drm: omapdrm: dsi: Use dev pointer directly in dsi_bind() function Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 18/30] drm: omapdrm: dsi: Store the struct device pointer in struct dsi_data Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 19/30] drm: omapdrm: dsi: Don't pass channel to dispc init/uninit functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 20/30] drm: omapdrm: dss: Pass omap_dss_device pointer to dss_mgr_*() functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 21/30] drm: omapdrm: dss: Pass omap_drm_private pointer to dss_mgr_ops Laurent Pinchart
2018-02-13 20:58   ` Sebastian Reichel
2018-02-13 12:00 ` [PATCH v2 22/30] drm: omapdrm: dss: Store DSS device pointer in the omapdrm private data Laurent Pinchart
2018-02-13 21:25   ` Sebastian Reichel
2018-02-14  8:31   ` Tomi Valkeinen
2018-02-14 15:34     ` Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 23/30] drm: omapdrm: dss: Store dispc ops in dss_device structure Laurent Pinchart
2018-02-13 21:32   ` Sebastian Reichel
2018-02-13 12:00 ` [PATCH v2 24/30] drm: omapdrm: dispc: Pass DISPC pointer to dispc_ops operations Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 25/30] drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 26/30] drm: omapdrm: dispc: Allocate the dispc private data structure dynamically Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 27/30] drm: omapdrm: hdmi4: Allocate the omap_hdmi " Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 28/30] drm: omapdrm: hdmi5: " Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 29/30] drm: omapdrm: sdi: Allocate the sdi private " Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 30/30] drm: omapdrm: venc: Allocate the venc " Laurent Pinchart
2018-02-14 13:24 ` [PATCH v2 00/30] omapdrm: Allocate objects dynamically Tomi Valkeinen
2018-02-14 15:39   ` Laurent Pinchart
2018-02-14 15:52     ` Tomi Valkeinen
2018-02-28  8:35 ` Tomi Valkeinen

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=20180213120048.21603-13-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tomi.valkeinen@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.