Skip to contentSkip to conversation

Use crtc helper drm_crtc_from_index() for more drivers

PATCH Applied Shawn Guo 3 participants 16 messages Jan 9, 2017 – Jan 18, 2017

Subsystems (11)
lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

cover Use crtc helper drm_crtc_from_index() for more drivers

From: Shawn Guo <[email protected]>

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(-)
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#1 lore raw

PATCH 1/6 drm: exynos: use crtc helper drm_crtc_from_index()

From: Shawn Guo <[email protected]>

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.

---
 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(-)
drivers/gpu/drm/exynos/exynos_drm_crtc.c +0 -6
index 2530bf57716a..309c8ee52524 100644
@@ -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)
drivers/gpu/drm/exynos/exynos_drm_drv.h +2 -8
index 80c4d5b81689..cf6e08cb35a7 100644
@@ -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)
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Applied
#2 lore raw

Re: [PATCH 1/6] drm: exynos: use crtc helper drm_crtc_from_index()

Quoted 6 lines · Shawn Guo

From: Shawn Guo <[email protected]>

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.

Applied to drm-misc-next

Thanks!

Sean

Quoted 69 lines
Cc Inki Dae <[email protected]>
---
 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(-)
drivers/gpu/drm/exynos/exynos_drm_crtc.c +0 -6
index 2530bf57716a..309c8ee52524 100644
@@ -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)
drivers/gpu/drm/exynos/exynos_drm_drv.h +2 -9
index 80c4d5b81689..cf6e08cb35a7 100644
@@ -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

Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#3 lore raw

PATCH 2/6 drm: kirin: use crtc helper drm_crtc_from_index()

In reply to Shawn Guo

From: Shawn Guo <[email protected]>

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.

Cc Xinliang Liu <[email protected]>
---
 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(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +4 -6
index afc2b5d2d5f0..29d8d1cf109d 100644
@@ -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;
 }
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +0 -1
index 1a07caf8e7f4..c6453b24d612 100644
@@ -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
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Applied
#5 lore raw

Re: [PATCH 2/6] drm: kirin: use crtc helper drm_crtc_from_index()

Quoted 11 lines · liuxinliang
Quoted 3 lines · Shawn Guo

Thanks Shawn Guo,

Applied to drm-misc-next

Thanks!

Sean

Quoted 6 lines

-xinliang

Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#6 lore raw

PATCH 3/6 drm: mediatek: use crtc helper drm_crtc_from_index()

In reply to Shawn Guo

From: Shawn Guo <[email protected]>

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.

---
 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(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +4 -5
index 01a21dd835b5..a73de1e669c2 100644
@@ -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;
drivers/gpu/drm/mediatek/mtk_drm_drv.h +0 -1
index aa9389446785..df322a7a5fcb 100644
@@ -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;
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Applied
#7 lore raw

Re: [PATCH 3/6] drm: mediatek: use crtc helper drm_crtc_from_index()

Quoted 7 lines · Shawn Guo

From: Shawn Guo <[email protected]>

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.

Applied to drm-misc-next

Thanks!

Sean

Quoted 54 lines
---
 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(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +4 -5
index 01a21dd835b5..a73de1e669c2 100644
@@ -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;
drivers/gpu/drm/mediatek/mtk_drm_drv.h +0 -2
index aa9389446785..df322a7a5fcb 100644
@@ -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

Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#8 lore raw

PATCH 4/6 drm: nouveau: use crtc helper drm_crtc_from_index()

In reply to Shawn Guo

From: Shawn Guo <[email protected]>

Use drm_crtc_from_index() to find drm_crtc for given index.

---
 drivers/gpu/drm/nouveau/nouveau_display.c | 33 +++++++++++++++++--------------
 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/gpu/drm/nouveau/nouveau_display.c +18 -15
index cef08da1da4e..a0e7221d6568 100644
@@ -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
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Applied
#9 lore raw

Re: [PATCH 4/6] drm: nouveau: use crtc helper drm_crtc_from_index()

Quoted 6 lines · Shawn Guo

From: Shawn Guo <[email protected]>

Use drm_crtc_from_index() to find drm_crtc for given index.

Applied to drm-misc-next

Thanks!

Sean

Quoted 57 lines
---
 drivers/gpu/drm/nouveau/nouveau_display.c | 33 +++++++++++++++++--------------
 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/gpu/drm/nouveau/nouveau_display.c +18 -16
index cef08da1da4e..a0e7221d6568 100644
@@ -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

Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#10 lore raw

PATCH 5/6 drm: tegra: use crtc helper drm_crtc_from_index()

In reply to Shawn Guo

From: Shawn Guo <[email protected]>

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.

Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/tegra/drm.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/gpu/drm/tegra/drm.c +3 -16
index b8be3ee4d3b8..e8ad2c1bfc76 100644
@@ -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)
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Applied
#11 lore raw

Re: [PATCH 5/6] drm: tegra: use crtc helper drm_crtc_from_index()

Quoted 8 lines · Shawn Guo

From: Shawn Guo <[email protected]>

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.

Cc Thierry Reding <[email protected]>

Applied to drm-misc-next

Thanks!

Sean

Quoted 54 lines
---
 drivers/gpu/drm/tegra/drm.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/gpu/drm/tegra/drm.c +3 -17
index b8be3ee4d3b8..e8ad2c1bfc76 100644
@@ -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

Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#12 lore raw

PATCH 6/6 drm: vc4: use crtc helper drm_crtc_from_index()

In reply to Shawn Guo

From: Shawn Guo <[email protected]>

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.

---
 drivers/gpu/drm/vc4/vc4_crtc.c | 17 +++++++----------
 drivers/gpu/drm/vc4/vc4_drv.h  |  1 -
 2 files changed, 7 insertions(+), 11 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +7 -10
index a0fd3e66bc4b..75b708b36890 100644
@@ -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));
 
drivers/gpu/drm/vc4/vc4_drv.h +0 -1
index b5c4bb14d0d1..5d8486cbd574 100644
@@ -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;
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Applied
#13 lore raw

Re: [PATCH 6/6] drm: vc4: use crtc helper drm_crtc_from_index()

Quoted 7 lines · Shawn Guo

From: Shawn Guo <[email protected]>

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.

Applied to drm-misc-next

Thanks!

Sean

Quoted 83 lines
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 17 +++++++----------
 drivers/gpu/drm/vc4/vc4_drv.h  |  1 -
 2 files changed, 7 insertions(+), 11 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +7 -10
index a0fd3e66bc4b..75b708b36890 100644
@@ -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));
 
drivers/gpu/drm/vc4/vc4_drv.h +0 -2
index b5c4bb14d0d1..5d8486cbd574 100644
@@ -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

Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on the v1 series
#14 lore raw
In reply to Shawn Guo
Quoted 5 lines · Shawn Guo

From: Shawn Guo <[email protected]>

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

Quoted 9 lines

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

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

Sean

Quoted 27 lines

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

Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#15 lore raw
Quoted 13 lines · Sean Paul
Quoted 12 lines · Shawn Guo

From: Shawn Guo <[email protected]>

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.

Quoted 9 lines
Quoted 2 lines

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

Thanks for the patches, Shawn. The entire series is

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

Quoted 35 lines

Sean

Quoted 24 lines

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(-)
Quoted 3 lines

--
1.9.1

--
Sean Paul, Software Engineer, Google / Chromium OS

Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel