All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers
@ 2017-01-09 11:25 Shawn Guo
  2017-01-09 11:25 ` [PATCH 1/6] drm: exynos: use crtc helper drm_crtc_from_index() Shawn Guo
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Shawn Guo @ 2017-01-09 11:25 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Xinliang Liu, dri-devel, Ben Skeggs

From: Shawn Guo <shawn.guo@linaro.org>

This is a follow-up series for "[PATCH 0/3] Add CRTC helper
drm_crtc_from_index()" per Daniel's comment [1].

Basically, it changes some drivers to use helper drm_crtc_from_index()
for the vblank code, so that either they do not need to store CRTC
pointers in private struct, or the exactly same code for finding CRTC
can be saved.

Compile tested against the following branch.

 git://anongit.freedesktop.org/drm/drm-misc drm-misc-next

Shawn

[1] http://www.spinics.net/lists/dri-devel/msg128065.html

Shawn Guo (6):
  drm: exynos: use crtc helper drm_crtc_from_index()
  drm: kirin: use crtc helper drm_crtc_from_index()
  drm: mediatek: use crtc helper drm_crtc_from_index()
  drm: nouveau: use crtc helper drm_crtc_from_index()
  drm: tegra: use crtc helper drm_crtc_from_index()
  drm: vc4: use crtc helper drm_crtc_from_index()

 drivers/gpu/drm/exynos/exynos_drm_crtc.c        |  6 -----
 drivers/gpu/drm/exynos/exynos_drm_drv.h         | 10 ++------
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 10 +++-----
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h |  1 -
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c         |  9 +++----
 drivers/gpu/drm/mediatek/mtk_drm_drv.h          |  1 -
 drivers/gpu/drm/nouveau/nouveau_display.c       | 33 ++++++++++++++-----------
 drivers/gpu/drm/tegra/drm.c                     | 19 +++-----------
 drivers/gpu/drm/vc4/vc4_crtc.c                  | 17 ++++++-------
 drivers/gpu/drm/vc4/vc4_drv.h                   |  1 -
 10 files changed, 38 insertions(+), 69 deletions(-)

-- 
1.9.1

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/6] drm: exynos: use crtc helper drm_crtc_from_index()
  2017-01-09 11:25 [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers Shawn Guo
@ 2017-01-09 11:25 ` Shawn Guo
  2017-01-18 15:06   ` Sean Paul
  2017-01-09 11:25 ` [PATCH 2/6] drm: kirin: " Shawn Guo
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Shawn Guo @ 2017-01-09 11:25 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: dri-devel

From: Shawn Guo <shawn.guo@linaro.org>

Use drm_crtc_from_index() to find drm_crtc for given index, so that we
do not need to maintain a pointer array in struct exynos_drm_private.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Inki Dae <inki.dae@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_crtc.c |  6 ------
 drivers/gpu/drm/exynos/exynos_drm_drv.h  | 10 ++--------
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 2530bf57716a..309c8ee52524 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -109,9 +109,6 @@ static void exynos_crtc_atomic_flush(struct drm_crtc *crtc,
 static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
 {
 	struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
-	struct exynos_drm_private *private = crtc->dev->dev_private;
-
-	private->crtc[exynos_crtc->pipe] = NULL;
 
 	drm_crtc_cleanup(crtc);
 	kfree(exynos_crtc);
@@ -134,7 +131,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
 					void *ctx)
 {
 	struct exynos_drm_crtc *exynos_crtc;
-	struct exynos_drm_private *private = drm_dev->dev_private;
 	struct drm_crtc *crtc;
 	int ret;
 
@@ -149,8 +145,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
 
 	crtc = &exynos_crtc->base;
 
-	private->crtc[pipe] = crtc;
-
 	ret = drm_crtc_init_with_planes(drm_dev, crtc, plane, NULL,
 					&exynos_crtc_funcs, NULL);
 	if (ret < 0)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 80c4d5b81689..cf6e08cb35a7 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -211,12 +211,6 @@ struct drm_exynos_file_private {
 struct exynos_drm_private {
 	struct drm_fb_helper *fb_helper;
 
-	/*
-	 * created crtc object would be contained at this array and
-	 * this array is used to be aware of which crtc did it request vblank.
-	 */
-	struct drm_crtc *crtc[MAX_CRTC];
-
 	struct device *dma_dev;
 	void *mapping;
 
@@ -231,9 +225,9 @@ struct exynos_drm_private {
 static inline struct exynos_drm_crtc *
 exynos_drm_crtc_from_pipe(struct drm_device *dev, int pipe)
 {
-	struct exynos_drm_private *private = dev->dev_private;
+	struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
 
-	return to_exynos_crtc(private->crtc[pipe]);
+	return to_exynos_crtc(crtc);
 }
 
 static inline struct device *to_dma_dev(struct drm_device *dev)
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/6] drm: kirin: use crtc helper drm_crtc_from_index()
  2017-01-09 11:25 [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers Shawn Guo
  2017-01-09 11:25 ` [PATCH 1/6] drm: exynos: use crtc helper drm_crtc_from_index() Shawn Guo
@ 2017-01-09 11:25 ` Shawn Guo
  2017-01-10  1:21   ` liuxinliang
  2017-01-09 11:25 ` [PATCH 3/6] drm: mediatek: " Shawn Guo
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Shawn Guo @ 2017-01-09 11:25 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Xinliang Liu, dri-devel

From: Shawn Guo <shawn.guo@linaro.org>

Use drm_crtc_from_index() to find drm_crtc for given index, so that we
do not need to maintain a pointer array in struct kirin_drm_private.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Xinliang Liu <z.liuxinliang@hisilicon.com>
---
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 10 ++++------
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h |  1 -
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
index afc2b5d2d5f0..29d8d1cf109d 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
@@ -304,8 +304,8 @@ static void ade_set_medianoc_qos(struct ade_crtc *acrtc)
 
 static int ade_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
-	struct kirin_drm_private *priv = dev->dev_private;
-	struct ade_crtc *acrtc = to_ade_crtc(priv->crtc[pipe]);
+	struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
+	struct ade_crtc *acrtc = to_ade_crtc(crtc);
 	struct ade_hw_ctx *ctx = acrtc->ctx;
 	void __iomem *base = ctx->base;
 
@@ -320,8 +320,8 @@ static int ade_enable_vblank(struct drm_device *dev, unsigned int pipe)
 
 static void ade_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
-	struct kirin_drm_private *priv = dev->dev_private;
-	struct ade_crtc *acrtc = to_ade_crtc(priv->crtc[pipe]);
+	struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
+	struct ade_crtc *acrtc = to_ade_crtc(crtc);
 	struct ade_hw_ctx *ctx = acrtc->ctx;
 	void __iomem *base = ctx->base;
 
@@ -575,7 +575,6 @@ static void ade_crtc_atomic_flush(struct drm_crtc *crtc,
 static int ade_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
 			 struct drm_plane *plane)
 {
-	struct kirin_drm_private *priv = dev->dev_private;
 	struct device_node *port;
 	int ret;
 
@@ -599,7 +598,6 @@ static int ade_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
 	}
 
 	drm_crtc_helper_add(crtc, &ade_crtc_helper_funcs);
-	priv->crtc[drm_crtc_index(crtc)] = crtc;
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h
index 1a07caf8e7f4..c6453b24d612 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h
@@ -20,7 +20,6 @@ struct kirin_dc_ops {
 };
 
 struct kirin_drm_private {
-	struct drm_crtc *crtc[MAX_CRTC];
 #ifdef CONFIG_DRM_FBDEV_EMULATION
 	struct drm_fbdev_cma *fbdev;
 #endif
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/6] drm: mediatek: use crtc helper drm_crtc_from_index()
  2017-01-09 11:25 [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers Shawn Guo
  2017-01-09 11:25 ` [PATCH 1/6] drm: exynos: use crtc helper drm_crtc_from_index() Shawn Guo
  2017-01-09 11:25 ` [PATCH 2/6] drm: kirin: " Shawn Guo
@ 2017-01-09 11:25 ` Shawn Guo
  2017-01-18 15:06   ` Sean Paul
  2017-01-09 11:25 ` [PATCH 4/6] drm: nouveau: " Shawn Guo
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Shawn Guo @ 2017-01-09 11:25 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: dri-devel

From: Shawn Guo <shawn.guo@linaro.org>

Use drm_crtc_from_index() to find drm_crtc for given index, so that we
do not need to maintain a pointer array in struct mtk_drm_private.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: CK Hu <ck.hu@mediatek.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 9 ++++-----
 drivers/gpu/drm/mediatek/mtk_drm_drv.h  | 1 -
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 01a21dd835b5..a73de1e669c2 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -170,8 +170,8 @@ static void mtk_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
 
 int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe)
 {
-	struct mtk_drm_private *priv = drm->dev_private;
-	struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(priv->crtc[pipe]);
+	struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
+	struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
 	struct mtk_ddp_comp *ovl = mtk_crtc->ddp_comp[0];
 
 	mtk_ddp_comp_enable_vblank(ovl, &mtk_crtc->base);
@@ -181,8 +181,8 @@ int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe)
 
 void mtk_drm_crtc_disable_vblank(struct drm_device *drm, unsigned int pipe)
 {
-	struct mtk_drm_private *priv = drm->dev_private;
-	struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(priv->crtc[pipe]);
+	struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
+	struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
 	struct mtk_ddp_comp *ovl = mtk_crtc->ddp_comp[0];
 
 	mtk_ddp_comp_disable_vblank(ovl);
@@ -588,7 +588,6 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
 		goto unprepare;
 	drm_mode_crtc_set_gamma_size(&mtk_crtc->base, MTK_LUT_SIZE);
 	drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, false, MTK_LUT_SIZE);
-	priv->crtc[pipe] = &mtk_crtc->base;
 	priv->num_pipes++;
 
 	return 0;
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
index aa9389446785..df322a7a5fcb 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
@@ -32,7 +32,6 @@ struct mtk_drm_private {
 	struct drm_device *drm;
 	struct device *dma_dev;
 
-	struct drm_crtc *crtc[MAX_CRTC];
 	unsigned int num_pipes;
 
 	struct device_node *mutex_node;
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/6] drm: nouveau: use crtc helper drm_crtc_from_index()
  2017-01-09 11:25 [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers Shawn Guo
                   ` (2 preceding siblings ...)
  2017-01-09 11:25 ` [PATCH 3/6] drm: mediatek: " Shawn Guo
@ 2017-01-09 11:25 ` Shawn Guo
  2017-01-18 15:07   ` Sean Paul
  2017-01-09 11:25 ` [PATCH 5/6] drm: tegra: " Shawn Guo
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Shawn Guo @ 2017-01-09 11:25 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Ben Skeggs, dri-devel

From: Shawn Guo <shawn.guo@linaro.org>

Use drm_crtc_from_index() to find drm_crtc for given index.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Ben Skeggs <bskeggs@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_display.c | 33 +++++++++++++++++--------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index cef08da1da4e..a0e7221d6568 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -58,27 +58,30 @@
 nouveau_display_vblank_enable(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_crtc *crtc;
-	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-		if (nv_crtc->index == pipe) {
-			nvif_notify_get(&nv_crtc->vblank);
-			return 0;
-		}
-	}
-	return -EINVAL;
+	struct nouveau_crtc *nv_crtc;
+
+	crtc = drm_crtc_from_index(dev, pipe);
+	if (!crtc)
+		return -EINVAL;
+
+	nv_crtc = nouveau_crtc(crtc);
+	nvif_notify_get(&nv_crtc->vblank);
+
+	return 0;
 }
 
 void
 nouveau_display_vblank_disable(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_crtc *crtc;
-	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-		if (nv_crtc->index == pipe) {
-			nvif_notify_put(&nv_crtc->vblank);
-			return;
-		}
-	}
+	struct nouveau_crtc *nv_crtc;
+
+	crtc = drm_crtc_from_index(dev, pipe);
+	if (!crtc)
+		return;
+
+	nv_crtc = nouveau_crtc(crtc);
+	nvif_notify_put(&nv_crtc->vblank);
 }
 
 static inline int
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/6] drm: tegra: use crtc helper drm_crtc_from_index()
  2017-01-09 11:25 [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers Shawn Guo
                   ` (3 preceding siblings ...)
  2017-01-09 11:25 ` [PATCH 4/6] drm: nouveau: " Shawn Guo
@ 2017-01-09 11:25 ` Shawn Guo
  2017-01-18 15:07   ` Sean Paul
  2017-01-09 11:25 ` [PATCH 6/6] drm: vc4: " Shawn Guo
  2017-01-09 16:11 ` [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers Sean Paul
  6 siblings, 1 reply; 16+ messages in thread
From: Shawn Guo @ 2017-01-09 11:25 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: dri-devel

From: Shawn Guo <shawn.guo@linaro.org>

Function tegra_crtc_from_pipe() does the exactly same thing as what
crtc helper drm_crtc_from_index() provides.  Use the helper to save
some code.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
---
 drivers/gpu/drm/tegra/drm.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index b8be3ee4d3b8..e8ad2c1bfc76 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -806,23 +806,10 @@ static int tegra_gem_get_flags(struct drm_device *drm, void *data,
 	.llseek = noop_llseek,
 };
 
-static struct drm_crtc *tegra_crtc_from_pipe(struct drm_device *drm,
-					     unsigned int pipe)
-{
-	struct drm_crtc *crtc;
-
-	list_for_each_entry(crtc, &drm->mode_config.crtc_list, head) {
-		if (pipe == drm_crtc_index(crtc))
-			return crtc;
-	}
-
-	return NULL;
-}
-
 static u32 tegra_drm_get_vblank_counter(struct drm_device *drm,
 					unsigned int pipe)
 {
-	struct drm_crtc *crtc = tegra_crtc_from_pipe(drm, pipe);
+	struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
 	struct tegra_dc *dc = to_tegra_dc(crtc);
 
 	if (!crtc)
@@ -833,7 +820,7 @@ static u32 tegra_drm_get_vblank_counter(struct drm_device *drm,
 
 static int tegra_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
 {
-	struct drm_crtc *crtc = tegra_crtc_from_pipe(drm, pipe);
+	struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
 	struct tegra_dc *dc = to_tegra_dc(crtc);
 
 	if (!crtc)
@@ -846,7 +833,7 @@ static int tegra_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
 
 static void tegra_drm_disable_vblank(struct drm_device *drm, unsigned int pipe)
 {
-	struct drm_crtc *crtc = tegra_crtc_from_pipe(drm, pipe);
+	struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
 	struct tegra_dc *dc = to_tegra_dc(crtc);
 
 	if (crtc)
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 6/6] drm: vc4: use crtc helper drm_crtc_from_index()
  2017-01-09 11:25 [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers Shawn Guo
                   ` (4 preceding siblings ...)
  2017-01-09 11:25 ` [PATCH 5/6] drm: tegra: " Shawn Guo
@ 2017-01-09 11:25 ` Shawn Guo
  2017-01-18 15:07   ` Sean Paul
  2017-01-09 16:11 ` [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers Sean Paul
  6 siblings, 1 reply; 16+ messages in thread
From: Shawn Guo @ 2017-01-09 11:25 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: dri-devel

From: Shawn Guo <shawn.guo@linaro.org>

Use drm_crtc_from_index() to find drm_crtc for given index, so that we
do not need to maintain a pointer array in struct vc4_dev.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 17 +++++++----------
 drivers/gpu/drm/vc4/vc4_drv.h  |  1 -
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index a0fd3e66bc4b..75b708b36890 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -156,7 +156,8 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			    const struct drm_display_mode *mode)
 {
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
-	struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
+	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
+	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 	u32 val;
 	int fifo_lines;
 	int vblank_lines;
@@ -272,9 +273,7 @@ int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
 				  int *max_error, struct timeval *vblank_time,
 				  unsigned flags)
 {
-	struct vc4_dev *vc4 = to_vc4_dev(dev);
-	struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
-	struct drm_crtc *crtc = &vc4_crtc->base;
+	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
 	struct drm_crtc_state *state = crtc->state;
 
 	/* Helper routine in DRM core does all the work: */
@@ -652,8 +651,8 @@ static void vc4_crtc_atomic_flush(struct drm_crtc *crtc,
 
 int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id)
 {
-	struct vc4_dev *vc4 = to_vc4_dev(dev);
-	struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
+	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
+	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 
 	CRTC_WRITE(PV_INTEN, PV_INT_VFP_START);
 
@@ -662,8 +661,8 @@ int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id)
 
 void vc4_disable_vblank(struct drm_device *dev, unsigned int crtc_id)
 {
-	struct vc4_dev *vc4 = to_vc4_dev(dev);
-	struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
+	struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
+	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 
 	CRTC_WRITE(PV_INTEN, 0);
 }
@@ -937,7 +936,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct drm_device *drm = dev_get_drvdata(master);
-	struct vc4_dev *vc4 = to_vc4_dev(drm);
 	struct vc4_crtc *vc4_crtc;
 	struct drm_crtc *crtc;
 	struct drm_plane *primary_plane, *cursor_plane, *destroy_plane, *temp;
@@ -975,7 +973,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
 				  &vc4_crtc_funcs, NULL);
 	drm_crtc_helper_add(crtc, &vc4_crtc_helper_funcs);
 	primary_plane->crtc = crtc;
-	vc4->crtc[drm_crtc_index(crtc)] = vc4_crtc;
 	vc4_crtc->channel = vc4_crtc->data->hvs_channel;
 	drm_mode_crtc_set_gamma_size(crtc, ARRAY_SIZE(vc4_crtc->lut_r));
 
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index b5c4bb14d0d1..5d8486cbd574 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -14,7 +14,6 @@ struct vc4_dev {
 
 	struct vc4_hdmi *hdmi;
 	struct vc4_hvs *hvs;
-	struct vc4_crtc *crtc[3];
 	struct vc4_v3d *v3d;
 	struct vc4_dpi *dpi;
 	struct vc4_vec *vec;
-- 
1.9.1

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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers
  2017-01-09 11:25 [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers Shawn Guo
                   ` (5 preceding siblings ...)
  2017-01-09 11:25 ` [PATCH 6/6] drm: vc4: " Shawn Guo
@ 2017-01-09 16:11 ` Sean Paul
  2017-01-18 15:08   ` Sean Paul
  6 siblings, 1 reply; 16+ messages in thread
From: Sean Paul @ 2017-01-09 16:11 UTC (permalink / raw)
  To: Shawn Guo; +Cc: Xinliang Liu, dri-devel, Ben Skeggs

On Mon, Jan 9, 2017 at 6:25 AM, Shawn Guo <shawnguo@kernel.org> wrote:
> From: Shawn Guo <shawn.guo@linaro.org>
>
> This is a follow-up series for "[PATCH 0/3] Add CRTC helper
> drm_crtc_from_index()" per Daniel's comment [1].
>
> Basically, it changes some drivers to use helper drm_crtc_from_index()
> for the vblank code, so that either they do not need to store CRTC
> pointers in private struct, or the exactly same code for finding CRTC
> can be saved.
>
> Compile tested against the following branch.
>
>  git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
>

Thanks for the patches, Shawn. The entire series is

Reviewed-by: Sean Paul <seanpaul@chromium.org>

I'll apply it to -misc in a week if there are no objections between now and then

Sean


> Shawn
>
> [1] http://www.spinics.net/lists/dri-devel/msg128065.html
>
> Shawn Guo (6):
>   drm: exynos: use crtc helper drm_crtc_from_index()
>   drm: kirin: use crtc helper drm_crtc_from_index()
>   drm: mediatek: use crtc helper drm_crtc_from_index()
>   drm: nouveau: use crtc helper drm_crtc_from_index()
>   drm: tegra: use crtc helper drm_crtc_from_index()
>   drm: vc4: use crtc helper drm_crtc_from_index()
>
>  drivers/gpu/drm/exynos/exynos_drm_crtc.c        |  6 -----
>  drivers/gpu/drm/exynos/exynos_drm_drv.h         | 10 ++------
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 10 +++-----
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h |  1 -
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c         |  9 +++----
>  drivers/gpu/drm/mediatek/mtk_drm_drv.h          |  1 -
>  drivers/gpu/drm/nouveau/nouveau_display.c       | 33 ++++++++++++++-----------
>  drivers/gpu/drm/tegra/drm.c                     | 19 +++-----------
>  drivers/gpu/drm/vc4/vc4_crtc.c                  | 17 ++++++-------
>  drivers/gpu/drm/vc4/vc4_drv.h                   |  1 -
>  10 files changed, 38 insertions(+), 69 deletions(-)
>
> --
> 1.9.1
>



-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/6] drm: kirin: use crtc helper drm_crtc_from_index()
  2017-01-09 11:25 ` [PATCH 2/6] drm: kirin: " Shawn Guo
@ 2017-01-10  1:21   ` liuxinliang
  2017-01-18 15:06     ` Sean Paul
  0 siblings, 1 reply; 16+ messages in thread
From: liuxinliang @ 2017-01-10  1:21 UTC (permalink / raw)
  To: Shawn Guo, Daniel Vetter; +Cc: dri-devel



On 2017/1/9 19:25, Shawn Guo wrote:
> Signed-off-by: Shawn Guo<shawn.guo@linaro.org>
> Cc: Xinliang Liu<z.liuxinliang@hisilicon.com>
Thanks Shawn Guo,

Reviewed-by: Xinliang Liu<z.liuxinliang@hisilicon.com>


-xinliang




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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/6] drm: exynos: use crtc helper drm_crtc_from_index()
  2017-01-09 11:25 ` [PATCH 1/6] drm: exynos: use crtc helper drm_crtc_from_index() Shawn Guo
@ 2017-01-18 15:06   ` Sean Paul
  0 siblings, 0 replies; 16+ messages in thread
From: Sean Paul @ 2017-01-18 15:06 UTC (permalink / raw)
  To: Shawn Guo; +Cc: dri-devel

On Mon, Jan 9, 2017 at 6:25 AM, Shawn Guo <shawnguo@kernel.org> wrote:
> From: Shawn Guo <shawn.guo@linaro.org>
>
> Use drm_crtc_from_index() to find drm_crtc for given index, so that we
> do not need to maintain a pointer array in struct exynos_drm_private.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Applied to drm-misc-next

Thanks!

Sean


> Cc: Inki Dae <inki.dae@samsung.com>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_crtc.c |  6 ------
>  drivers/gpu/drm/exynos/exynos_drm_drv.h  | 10 ++--------
>  2 files changed, 2 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> index 2530bf57716a..309c8ee52524 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> @@ -109,9 +109,6 @@ static void exynos_crtc_atomic_flush(struct drm_crtc *crtc,
>  static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
>  {
>         struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
> -       struct exynos_drm_private *private = crtc->dev->dev_private;
> -
> -       private->crtc[exynos_crtc->pipe] = NULL;
>
>         drm_crtc_cleanup(crtc);
>         kfree(exynos_crtc);
> @@ -134,7 +131,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
>                                         void *ctx)
>  {
>         struct exynos_drm_crtc *exynos_crtc;
> -       struct exynos_drm_private *private = drm_dev->dev_private;
>         struct drm_crtc *crtc;
>         int ret;
>
> @@ -149,8 +145,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
>
>         crtc = &exynos_crtc->base;
>
> -       private->crtc[pipe] = crtc;
> -
>         ret = drm_crtc_init_with_planes(drm_dev, crtc, plane, NULL,
>                                         &exynos_crtc_funcs, NULL);
>         if (ret < 0)
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> index 80c4d5b81689..cf6e08cb35a7 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> @@ -211,12 +211,6 @@ struct drm_exynos_file_private {
>  struct exynos_drm_private {
>         struct drm_fb_helper *fb_helper;
>
> -       /*
> -        * created crtc object would be contained at this array and
> -        * this array is used to be aware of which crtc did it request vblank.
> -        */
> -       struct drm_crtc *crtc[MAX_CRTC];
> -
>         struct device *dma_dev;
>         void *mapping;
>
> @@ -231,9 +225,9 @@ struct exynos_drm_private {
>  static inline struct exynos_drm_crtc *
>  exynos_drm_crtc_from_pipe(struct drm_device *dev, int pipe)
>  {
> -       struct exynos_drm_private *private = dev->dev_private;
> +       struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
>
> -       return to_exynos_crtc(private->crtc[pipe]);
> +       return to_exynos_crtc(crtc);
>  }
>
>  static inline struct device *to_dma_dev(struct drm_device *dev)
> --
> 1.9.1
>



-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/6] drm: kirin: use crtc helper drm_crtc_from_index()
  2017-01-10  1:21   ` liuxinliang
@ 2017-01-18 15:06     ` Sean Paul
  0 siblings, 0 replies; 16+ messages in thread
From: Sean Paul @ 2017-01-18 15:06 UTC (permalink / raw)
  To: liuxinliang; +Cc: Shawn Guo, dri-devel

On Mon, Jan 9, 2017 at 8:21 PM, liuxinliang <z.liuxinliang@hisilicon.com> wrote:
>
>
> On 2017/1/9 19:25, Shawn Guo wrote:
>>
>> Signed-off-by: Shawn Guo<shawn.guo@linaro.org>
>> Cc: Xinliang Liu<z.liuxinliang@hisilicon.com>
>
> Thanks Shawn Guo,
>
> Reviewed-by: Xinliang Liu<z.liuxinliang@hisilicon.com>
>


Applied to drm-misc-next

Thanks!

Sean

>
> -xinliang
>
>
>
>



-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/6] drm: mediatek: use crtc helper drm_crtc_from_index()
  2017-01-09 11:25 ` [PATCH 3/6] drm: mediatek: " Shawn Guo
@ 2017-01-18 15:06   ` Sean Paul
  0 siblings, 0 replies; 16+ messages in thread
From: Sean Paul @ 2017-01-18 15:06 UTC (permalink / raw)
  To: Shawn Guo; +Cc: dri-devel

On Mon, Jan 9, 2017 at 6:25 AM, Shawn Guo <shawnguo@kernel.org> wrote:
> From: Shawn Guo <shawn.guo@linaro.org>
>
> Use drm_crtc_from_index() to find drm_crtc for given index, so that we
> do not need to maintain a pointer array in struct mtk_drm_private.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: CK Hu <ck.hu@mediatek.com>


Applied to drm-misc-next

Thanks!

Sean

> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 9 ++++-----
>  drivers/gpu/drm/mediatek/mtk_drm_drv.h  | 1 -
>  2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 01a21dd835b5..a73de1e669c2 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -170,8 +170,8 @@ static void mtk_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
>
>  int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe)
>  {
> -       struct mtk_drm_private *priv = drm->dev_private;
> -       struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(priv->crtc[pipe]);
> +       struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
> +       struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
>         struct mtk_ddp_comp *ovl = mtk_crtc->ddp_comp[0];
>
>         mtk_ddp_comp_enable_vblank(ovl, &mtk_crtc->base);
> @@ -181,8 +181,8 @@ int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe)
>
>  void mtk_drm_crtc_disable_vblank(struct drm_device *drm, unsigned int pipe)
>  {
> -       struct mtk_drm_private *priv = drm->dev_private;
> -       struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(priv->crtc[pipe]);
> +       struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
> +       struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
>         struct mtk_ddp_comp *ovl = mtk_crtc->ddp_comp[0];
>
>         mtk_ddp_comp_disable_vblank(ovl);
> @@ -588,7 +588,6 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
>                 goto unprepare;
>         drm_mode_crtc_set_gamma_size(&mtk_crtc->base, MTK_LUT_SIZE);
>         drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, false, MTK_LUT_SIZE);
> -       priv->crtc[pipe] = &mtk_crtc->base;
>         priv->num_pipes++;
>
>         return 0;
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> index aa9389446785..df322a7a5fcb 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> @@ -32,7 +32,6 @@ struct mtk_drm_private {
>         struct drm_device *drm;
>         struct device *dma_dev;
>
> -       struct drm_crtc *crtc[MAX_CRTC];
>         unsigned int num_pipes;
>
>         struct device_node *mutex_node;
> --
> 1.9.1
>



-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 4/6] drm: nouveau: use crtc helper drm_crtc_from_index()
  2017-01-09 11:25 ` [PATCH 4/6] drm: nouveau: " Shawn Guo
@ 2017-01-18 15:07   ` Sean Paul
  0 siblings, 0 replies; 16+ messages in thread
From: Sean Paul @ 2017-01-18 15:07 UTC (permalink / raw)
  To: Shawn Guo; +Cc: dri-devel, Ben Skeggs

On Mon, Jan 9, 2017 at 6:25 AM, Shawn Guo <shawnguo@kernel.org> wrote:
> From: Shawn Guo <shawn.guo@linaro.org>
>
> Use drm_crtc_from_index() to find drm_crtc for given index.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: Ben Skeggs <bskeggs@redhat.com>


Applied to drm-misc-next

Thanks!

Sean

> ---
>  drivers/gpu/drm/nouveau/nouveau_display.c | 33 +++++++++++++++++--------------
>  1 file changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
> index cef08da1da4e..a0e7221d6568 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_display.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
> @@ -58,27 +58,30 @@
>  nouveau_display_vblank_enable(struct drm_device *dev, unsigned int pipe)
>  {
>         struct drm_crtc *crtc;
> -       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
> -               struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
> -               if (nv_crtc->index == pipe) {
> -                       nvif_notify_get(&nv_crtc->vblank);
> -                       return 0;
> -               }
> -       }
> -       return -EINVAL;
> +       struct nouveau_crtc *nv_crtc;
> +
> +       crtc = drm_crtc_from_index(dev, pipe);
> +       if (!crtc)
> +               return -EINVAL;
> +
> +       nv_crtc = nouveau_crtc(crtc);
> +       nvif_notify_get(&nv_crtc->vblank);
> +
> +       return 0;
>  }
>
>  void
>  nouveau_display_vblank_disable(struct drm_device *dev, unsigned int pipe)
>  {
>         struct drm_crtc *crtc;
> -       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
> -               struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
> -               if (nv_crtc->index == pipe) {
> -                       nvif_notify_put(&nv_crtc->vblank);
> -                       return;
> -               }
> -       }
> +       struct nouveau_crtc *nv_crtc;
> +
> +       crtc = drm_crtc_from_index(dev, pipe);
> +       if (!crtc)
> +               return;
> +
> +       nv_crtc = nouveau_crtc(crtc);
> +       nvif_notify_put(&nv_crtc->vblank);
>  }
>
>  static inline int
> --
> 1.9.1
>



-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 5/6] drm: tegra: use crtc helper drm_crtc_from_index()
  2017-01-09 11:25 ` [PATCH 5/6] drm: tegra: " Shawn Guo
@ 2017-01-18 15:07   ` Sean Paul
  0 siblings, 0 replies; 16+ messages in thread
From: Sean Paul @ 2017-01-18 15:07 UTC (permalink / raw)
  To: Shawn Guo; +Cc: dri-devel

On Mon, Jan 9, 2017 at 6:25 AM, Shawn Guo <shawnguo@kernel.org> wrote:
> From: Shawn Guo <shawn.guo@linaro.org>
>
> Function tegra_crtc_from_pipe() does the exactly same thing as what
> crtc helper drm_crtc_from_index() provides.  Use the helper to save
> some code.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: Thierry Reding <thierry.reding@gmail.com>


Applied to drm-misc-next

Thanks!

Sean

> ---
>  drivers/gpu/drm/tegra/drm.c | 19 +++----------------
>  1 file changed, 3 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index b8be3ee4d3b8..e8ad2c1bfc76 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -806,23 +806,10 @@ static int tegra_gem_get_flags(struct drm_device *drm, void *data,
>         .llseek = noop_llseek,
>  };
>
> -static struct drm_crtc *tegra_crtc_from_pipe(struct drm_device *drm,
> -                                            unsigned int pipe)
> -{
> -       struct drm_crtc *crtc;
> -
> -       list_for_each_entry(crtc, &drm->mode_config.crtc_list, head) {
> -               if (pipe == drm_crtc_index(crtc))
> -                       return crtc;
> -       }
> -
> -       return NULL;
> -}
> -
>  static u32 tegra_drm_get_vblank_counter(struct drm_device *drm,
>                                         unsigned int pipe)
>  {
> -       struct drm_crtc *crtc = tegra_crtc_from_pipe(drm, pipe);
> +       struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
>         struct tegra_dc *dc = to_tegra_dc(crtc);
>
>         if (!crtc)
> @@ -833,7 +820,7 @@ static u32 tegra_drm_get_vblank_counter(struct drm_device *drm,
>
>  static int tegra_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
>  {
> -       struct drm_crtc *crtc = tegra_crtc_from_pipe(drm, pipe);
> +       struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
>         struct tegra_dc *dc = to_tegra_dc(crtc);
>
>         if (!crtc)
> @@ -846,7 +833,7 @@ static int tegra_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
>
>  static void tegra_drm_disable_vblank(struct drm_device *drm, unsigned int pipe)
>  {
> -       struct drm_crtc *crtc = tegra_crtc_from_pipe(drm, pipe);
> +       struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
>         struct tegra_dc *dc = to_tegra_dc(crtc);
>
>         if (crtc)
> --
> 1.9.1
>



-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 6/6] drm: vc4: use crtc helper drm_crtc_from_index()
  2017-01-09 11:25 ` [PATCH 6/6] drm: vc4: " Shawn Guo
@ 2017-01-18 15:07   ` Sean Paul
  0 siblings, 0 replies; 16+ messages in thread
From: Sean Paul @ 2017-01-18 15:07 UTC (permalink / raw)
  To: Shawn Guo; +Cc: dri-devel

On Mon, Jan 9, 2017 at 6:25 AM, Shawn Guo <shawnguo@kernel.org> wrote:
> From: Shawn Guo <shawn.guo@linaro.org>
>
> Use drm_crtc_from_index() to find drm_crtc for given index, so that we
> do not need to maintain a pointer array in struct vc4_dev.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: Eric Anholt <eric@anholt.net>


Applied to drm-misc-next

Thanks!

Sean

> ---
>  drivers/gpu/drm/vc4/vc4_crtc.c | 17 +++++++----------
>  drivers/gpu/drm/vc4/vc4_drv.h  |  1 -
>  2 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
> index a0fd3e66bc4b..75b708b36890 100644
> --- a/drivers/gpu/drm/vc4/vc4_crtc.c
> +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
> @@ -156,7 +156,8 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
>                             const struct drm_display_mode *mode)
>  {
>         struct vc4_dev *vc4 = to_vc4_dev(dev);
> -       struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
> +       struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
> +       struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
>         u32 val;
>         int fifo_lines;
>         int vblank_lines;
> @@ -272,9 +273,7 @@ int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
>                                   int *max_error, struct timeval *vblank_time,
>                                   unsigned flags)
>  {
> -       struct vc4_dev *vc4 = to_vc4_dev(dev);
> -       struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
> -       struct drm_crtc *crtc = &vc4_crtc->base;
> +       struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
>         struct drm_crtc_state *state = crtc->state;
>
>         /* Helper routine in DRM core does all the work: */
> @@ -652,8 +651,8 @@ static void vc4_crtc_atomic_flush(struct drm_crtc *crtc,
>
>  int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id)
>  {
> -       struct vc4_dev *vc4 = to_vc4_dev(dev);
> -       struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
> +       struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
> +       struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
>
>         CRTC_WRITE(PV_INTEN, PV_INT_VFP_START);
>
> @@ -662,8 +661,8 @@ int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id)
>
>  void vc4_disable_vblank(struct drm_device *dev, unsigned int crtc_id)
>  {
> -       struct vc4_dev *vc4 = to_vc4_dev(dev);
> -       struct vc4_crtc *vc4_crtc = vc4->crtc[crtc_id];
> +       struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
> +       struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
>
>         CRTC_WRITE(PV_INTEN, 0);
>  }
> @@ -937,7 +936,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
>  {
>         struct platform_device *pdev = to_platform_device(dev);
>         struct drm_device *drm = dev_get_drvdata(master);
> -       struct vc4_dev *vc4 = to_vc4_dev(drm);
>         struct vc4_crtc *vc4_crtc;
>         struct drm_crtc *crtc;
>         struct drm_plane *primary_plane, *cursor_plane, *destroy_plane, *temp;
> @@ -975,7 +973,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
>                                   &vc4_crtc_funcs, NULL);
>         drm_crtc_helper_add(crtc, &vc4_crtc_helper_funcs);
>         primary_plane->crtc = crtc;
> -       vc4->crtc[drm_crtc_index(crtc)] = vc4_crtc;
>         vc4_crtc->channel = vc4_crtc->data->hvs_channel;
>         drm_mode_crtc_set_gamma_size(crtc, ARRAY_SIZE(vc4_crtc->lut_r));
>
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
> index b5c4bb14d0d1..5d8486cbd574 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.h
> +++ b/drivers/gpu/drm/vc4/vc4_drv.h
> @@ -14,7 +14,6 @@ struct vc4_dev {
>
>         struct vc4_hdmi *hdmi;
>         struct vc4_hvs *hvs;
> -       struct vc4_crtc *crtc[3];
>         struct vc4_v3d *v3d;
>         struct vc4_dpi *dpi;
>         struct vc4_vec *vec;
> --
> 1.9.1
>



-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers
  2017-01-09 16:11 ` [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers Sean Paul
@ 2017-01-18 15:08   ` Sean Paul
  0 siblings, 0 replies; 16+ messages in thread
From: Sean Paul @ 2017-01-18 15:08 UTC (permalink / raw)
  To: Shawn Guo; +Cc: Xinliang Liu, dri-devel, Ben Skeggs

On Mon, Jan 9, 2017 at 11:11 AM, Sean Paul <seanpaul@chromium.org> wrote:
> On Mon, Jan 9, 2017 at 6:25 AM, Shawn Guo <shawnguo@kernel.org> wrote:
>> From: Shawn Guo <shawn.guo@linaro.org>
>>
>> This is a follow-up series for "[PATCH 0/3] Add CRTC helper
>> drm_crtc_from_index()" per Daniel's comment [1].
>>
>> Basically, it changes some drivers to use helper drm_crtc_from_index()
>> for the vblank code, so that either they do not need to store CRTC
>> pointers in private struct, or the exactly same code for finding CRTC
>> can be saved.
>>
>> Compile tested against the following branch.
>>
>>  git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
>>
>
> Thanks for the patches, Shawn. The entire series is
>
> Reviewed-by: Sean Paul <seanpaul@chromium.org>
>
> I'll apply it to -misc in a week if there are no objections between now and then
>

Didn't see any objections, so the series has been merged.

Sean


> Sean
>
>
>> Shawn
>>
>> [1] http://www.spinics.net/lists/dri-devel/msg128065.html
>>
>> Shawn Guo (6):
>>   drm: exynos: use crtc helper drm_crtc_from_index()
>>   drm: kirin: use crtc helper drm_crtc_from_index()
>>   drm: mediatek: use crtc helper drm_crtc_from_index()
>>   drm: nouveau: use crtc helper drm_crtc_from_index()
>>   drm: tegra: use crtc helper drm_crtc_from_index()
>>   drm: vc4: use crtc helper drm_crtc_from_index()
>>
>>  drivers/gpu/drm/exynos/exynos_drm_crtc.c        |  6 -----
>>  drivers/gpu/drm/exynos/exynos_drm_drv.h         | 10 ++------
>>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 10 +++-----
>>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h |  1 -
>>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c         |  9 +++----
>>  drivers/gpu/drm/mediatek/mtk_drm_drv.h          |  1 -
>>  drivers/gpu/drm/nouveau/nouveau_display.c       | 33 ++++++++++++++-----------
>>  drivers/gpu/drm/tegra/drm.c                     | 19 +++-----------
>>  drivers/gpu/drm/vc4/vc4_crtc.c                  | 17 ++++++-------
>>  drivers/gpu/drm/vc4/vc4_drv.h                   |  1 -
>>  10 files changed, 38 insertions(+), 69 deletions(-)
>>
>> --
>> 1.9.1
>>
>
>
>
> --
> Sean Paul, Software Engineer, Google / Chromium OS



-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-01-18 15:08 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-09 11:25 [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers Shawn Guo
2017-01-09 11:25 ` [PATCH 1/6] drm: exynos: use crtc helper drm_crtc_from_index() Shawn Guo
2017-01-18 15:06   ` Sean Paul
2017-01-09 11:25 ` [PATCH 2/6] drm: kirin: " Shawn Guo
2017-01-10  1:21   ` liuxinliang
2017-01-18 15:06     ` Sean Paul
2017-01-09 11:25 ` [PATCH 3/6] drm: mediatek: " Shawn Guo
2017-01-18 15:06   ` Sean Paul
2017-01-09 11:25 ` [PATCH 4/6] drm: nouveau: " Shawn Guo
2017-01-18 15:07   ` Sean Paul
2017-01-09 11:25 ` [PATCH 5/6] drm: tegra: " Shawn Guo
2017-01-18 15:07   ` Sean Paul
2017-01-09 11:25 ` [PATCH 6/6] drm: vc4: " Shawn Guo
2017-01-18 15:07   ` Sean Paul
2017-01-09 16:11 ` [PATCH 0/6] Use crtc helper drm_crtc_from_index() for more drivers Sean Paul
2017-01-18 15:08   ` Sean Paul

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.