All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/16] drm/gma500: Sanity-check pipe index
@ 2015-09-24 16:35 Thierry Reding
  2015-09-24 16:35 ` [PATCH 02/16] drm/bochs: Store correct CRTC index in events Thierry Reding
                   ` (14 more replies)
  0 siblings, 15 replies; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

If the DSI output isn't connected, then mdfld_dsi_encoder_get_pipe()
will return -1. The mdfld_dsi_dp_mode_set() function doesn't properly
check for this condition and causes the following compiler warnings:

	  CC      drivers/gpu/drm/gma500/mdfld_dsi_dpi.o
	drivers/gpu/drm/gma500/mdfld_dsi_dpi.c: In function ‘mdfld_dsi_dpi_mode_set’:
	drivers/gpu/drm/gma500/mdfld_dsi_dpi.c:828:35: warning: array subscript is below array bounds [-Warray-bounds]
	  u32 pipeconf = dev_priv->pipeconf[pipe];
	                                   ^
	drivers/gpu/drm/gma500/mdfld_dsi_dpi.c:829:33: warning: array subscript is below array bounds [-Warray-bounds]
	  u32 dspcntr = dev_priv->dspcntr[pipe];
	                                 ^

Fix this by checking for a valid pipe before indexing the pipeconf and
dspcntr arrays.

Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/gma500/mdfld_dsi_dpi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
index d4813e03f5ee..00275c3856ce 100644
--- a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
+++ b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
@@ -821,14 +821,18 @@ void mdfld_dsi_dpi_mode_set(struct drm_encoder *encoder,
 	struct drm_device *dev = dsi_config->dev;
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	int pipe = mdfld_dsi_encoder_get_pipe(dsi_encoder);
-
 	u32 pipeconf_reg = PIPEACONF;
 	u32 dspcntr_reg = DSPACNTR;
+	u32 pipeconf, dspcntr;
 
-	u32 pipeconf = dev_priv->pipeconf[pipe];
-	u32 dspcntr = dev_priv->dspcntr[pipe];
 	u32 mipi = MIPI_PORT_EN | PASS_FROM_SPHY_TO_AFE | SEL_FLOPPED_HSTX;
 
+	if (WARN_ON(pipe < 0))
+		return;
+
+	pipeconf = dev_priv->pipeconf[pipe];
+	dspcntr = dev_priv->dspcntr[pipe];
+
 	if (pipe) {
 		pipeconf_reg = PIPECCONF;
 		dspcntr_reg = DSPCCNTR;
-- 
2.5.0

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

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

* [PATCH 02/16] drm/bochs: Store correct CRTC index in events
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-24 16:35 ` [PATCH 03/16] drm/imx: Make pipe number unsigned Thierry Reding
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

Previously a negative pipe caused a special case to be triggered for
drivers that didn't have proper VBLANK support. The trigger for this
special case is now independent of the pipe, so the correct CRTC index
can now be stored in events.

v2: convert to use drm_crtc_send_vblank_event()

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/bochs/bochs_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
index 26bcd03a8cb6..3962fc460798 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -119,7 +119,7 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc,
 	bochs_crtc_mode_set_base(crtc, 0, 0, old_fb);
 	if (event) {
 		spin_lock_irqsave(&bochs->dev->event_lock, irqflags);
-		drm_send_vblank_event(bochs->dev, -1, event);
+		drm_crtc_send_vblank_event(crtc, event);
 		spin_unlock_irqrestore(&bochs->dev->event_lock, irqflags);
 	}
 	return 0;
-- 
2.5.0

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

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

* [PATCH 03/16] drm/imx: Make pipe number unsigned
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
  2015-09-24 16:35 ` [PATCH 02/16] drm/bochs: Store correct CRTC index in events Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-24 16:35 ` [PATCH 04/16] drm/imx: Drop pipe field from struct imx_drm_crtc Thierry Reding
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

There's no reason whatsoever why this should ever be negative. The same
goes for the number of pipes added to the DRM device.

Cc: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/imx/imx-drm-core.c | 6 +++---
 drivers/gpu/drm/imx/imx-drm.h      | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index 74f505b0dd02..9ff1b780f453 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -39,20 +39,20 @@ struct imx_drm_component {
 struct imx_drm_device {
 	struct drm_device			*drm;
 	struct imx_drm_crtc			*crtc[MAX_CRTC];
-	int					pipes;
+	unsigned int				pipes;
 	struct drm_fbdev_cma			*fbhelper;
 };
 
 struct imx_drm_crtc {
 	struct drm_crtc				*crtc;
-	int					pipe;
+	unsigned int				pipe;
 	struct imx_drm_crtc_helper_funcs	imx_drm_helper_funcs;
 };
 
 static int legacyfb_depth = 16;
 module_param(legacyfb_depth, int, 0444);
 
-int imx_drm_crtc_id(struct imx_drm_crtc *crtc)
+unsigned int imx_drm_crtc_id(struct imx_drm_crtc *crtc)
 {
 	return crtc->pipe;
 }
diff --git a/drivers/gpu/drm/imx/imx-drm.h b/drivers/gpu/drm/imx/imx-drm.h
index 28e776d8d9d2..eebf0e2fefd0 100644
--- a/drivers/gpu/drm/imx/imx-drm.h
+++ b/drivers/gpu/drm/imx/imx-drm.h
@@ -12,7 +12,7 @@ struct drm_framebuffer;
 struct imx_drm_crtc;
 struct platform_device;
 
-int imx_drm_crtc_id(struct imx_drm_crtc *crtc);
+unsigned int imx_drm_crtc_id(struct imx_drm_crtc *crtc);
 
 struct imx_drm_crtc_helper_funcs {
 	int (*enable_vblank)(struct drm_crtc *crtc);
-- 
2.5.0

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

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

* [PATCH 04/16] drm/imx: Drop pipe field from struct imx_drm_crtc
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
  2015-09-24 16:35 ` [PATCH 02/16] drm/bochs: Store correct CRTC index in events Thierry Reding
  2015-09-24 16:35 ` [PATCH 03/16] drm/imx: Make pipe number unsigned Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-25  7:26   ` Philipp Zabel
  2015-09-24 16:35 ` [PATCH 05/16] drm/imx: Store correct CRTC index in events Thierry Reding
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

Use the drm_crtc_index() helper to determine the pipe number of the CRTC
instead.

Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/imx/imx-drm-core.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index 9ff1b780f453..ad77c9d86409 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -45,7 +45,6 @@ struct imx_drm_device {
 
 struct imx_drm_crtc {
 	struct drm_crtc				*crtc;
-	unsigned int				pipe;
 	struct imx_drm_crtc_helper_funcs	imx_drm_helper_funcs;
 };
 
@@ -54,7 +53,7 @@ module_param(legacyfb_depth, int, 0444);
 
 unsigned int imx_drm_crtc_id(struct imx_drm_crtc *crtc)
 {
-	return crtc->pipe;
+	return drm_crtc_index(crtc->crtc);
 }
 EXPORT_SYMBOL_GPL(imx_drm_crtc_id);
 
@@ -129,19 +128,19 @@ EXPORT_SYMBOL_GPL(imx_drm_set_bus_format);
 
 int imx_drm_crtc_vblank_get(struct imx_drm_crtc *imx_drm_crtc)
 {
-	return drm_vblank_get(imx_drm_crtc->crtc->dev, imx_drm_crtc->pipe);
+	return drm_crtc_vblank_get(imx_drm_crtc->crtc);
 }
 EXPORT_SYMBOL_GPL(imx_drm_crtc_vblank_get);
 
 void imx_drm_crtc_vblank_put(struct imx_drm_crtc *imx_drm_crtc)
 {
-	drm_vblank_put(imx_drm_crtc->crtc->dev, imx_drm_crtc->pipe);
+	drm_crtc_vblank_put(imx_drm_crtc->crtc);
 }
 EXPORT_SYMBOL_GPL(imx_drm_crtc_vblank_put);
 
 void imx_drm_handle_vblank(struct imx_drm_crtc *imx_drm_crtc)
 {
-	drm_handle_vblank(imx_drm_crtc->crtc->dev, imx_drm_crtc->pipe);
+	drm_crtc_handle_vblank(imx_drm_crtc->crtc);
 }
 EXPORT_SYMBOL_GPL(imx_drm_handle_vblank);
 
@@ -363,12 +362,11 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
 		return -ENOMEM;
 
 	imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs;
-	imx_drm_crtc->pipe = imxdrm->pipes++;
 	imx_drm_crtc->crtc = crtc;
 
 	crtc->port = port;
 
-	imxdrm->crtc[imx_drm_crtc->pipe] = imx_drm_crtc;
+	imxdrm->crtc[imxdrm->pipes++] = imx_drm_crtc;
 
 	*new_crtc = imx_drm_crtc;
 
@@ -385,7 +383,7 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
 	return 0;
 
 err_register:
-	imxdrm->crtc[imx_drm_crtc->pipe] = NULL;
+	imxdrm->crtc[--imxdrm->pipes] = NULL;
 	kfree(imx_drm_crtc);
 	return ret;
 }
@@ -397,10 +395,11 @@ EXPORT_SYMBOL_GPL(imx_drm_add_crtc);
 int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc)
 {
 	struct imx_drm_device *imxdrm = imx_drm_crtc->crtc->dev->dev_private;
+	unsigned int pipe = drm_crtc_index(imx_drm_crtc->crtc);
 
 	drm_crtc_cleanup(imx_drm_crtc->crtc);
 
-	imxdrm->crtc[imx_drm_crtc->pipe] = NULL;
+	imxdrm->crtc[pipe] = NULL;
 
 	kfree(imx_drm_crtc);
 
-- 
2.5.0

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

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

* [PATCH 05/16] drm/imx: Store correct CRTC index in events
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
                   ` (2 preceding siblings ...)
  2015-09-24 16:35 ` [PATCH 04/16] drm/imx: Drop pipe field from struct imx_drm_crtc Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-24 16:35 ` [PATCH 06/16] drm/rockchip: " Thierry Reding
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

A negative pipe causes a special case to be triggered for drivers that
don't have proper VBLANK support. i.MX does support VBLANKs, so there is
no need for the fallback code.

Cc: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
index 7bc8301fafff..a10da8e011c2 100644
--- a/drivers/gpu/drm/imx/ipuv3-crtc.c
+++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
@@ -212,7 +212,8 @@ static void ipu_crtc_handle_pageflip(struct ipu_crtc *ipu_crtc)
 
 	spin_lock_irqsave(&drm->event_lock, flags);
 	if (ipu_crtc->page_flip_event)
-		drm_send_vblank_event(drm, -1, ipu_crtc->page_flip_event);
+		drm_send_vblank_event(drm, imx_drm_crtc_id(ipu_crtc->imx_crtc),
+				      ipu_crtc->page_flip_event);
 	ipu_crtc->page_flip_event = NULL;
 	imx_drm_crtc_vblank_put(ipu_crtc->imx_crtc);
 	spin_unlock_irqrestore(&drm->event_lock, flags);
-- 
2.5.0

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

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

* [PATCH 06/16] drm/rockchip: Store correct CRTC index in events
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
                   ` (3 preceding siblings ...)
  2015-09-24 16:35 ` [PATCH 05/16] drm/imx: Store correct CRTC index in events Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-24 16:35 ` [PATCH 07/16] drm/sti: " Thierry Reding
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

A negative pipe causes a special case to be triggered for drivers that
don't have proper VBLANK support. Rockchip does support VBLANKs, so
there is no need for the fallback code.

Cc: Mark Yao <mark.yao@rock-chips.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 5d8ae5e49c44..5f192dda3f48 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1289,7 +1289,7 @@ static void vop_win_state_complete(struct vop_win *vop_win,
 
 	if (state->event) {
 		spin_lock_irqsave(&drm->event_lock, flags);
-		drm_send_vblank_event(drm, -1, state->event);
+		drm_send_vblank_event(drm, vop->pipe, state->event);
 		spin_unlock_irqrestore(&drm->event_lock, flags);
 	}
 
-- 
2.5.0

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

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

* [PATCH 07/16] drm/sti: Store correct CRTC index in events
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
                   ` (4 preceding siblings ...)
  2015-09-24 16:35 ` [PATCH 06/16] drm/rockchip: " Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-10-01 14:06   ` Vincent ABRIOU
  2015-09-24 16:35 ` [PATCH 08/16] drm/irq: Rename drm_crtc -> crtc Thierry Reding
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel; +Cc: Benjamin Gaignard

From: Thierry Reding <treding@nvidia.com>

A negative pipe causes a special case to be triggered for drivers that
don't have proper VBLANK support. STi does support VBLANKs, so there is
no need for the fallback code.

Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Vincent Abriou <vincent.abriou@st.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/sti/sti_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
index 018ffc970e96..81c56ea9d87f 100644
--- a/drivers/gpu/drm/sti/sti_crtc.c
+++ b/drivers/gpu/drm/sti/sti_crtc.c
@@ -274,7 +274,7 @@ int sti_crtc_vblank_cb(struct notifier_block *nb,
 
 	spin_lock_irqsave(&drm_dev->event_lock, flags);
 	if (compo->mixer[*crtc]->pending_event) {
-		drm_send_vblank_event(drm_dev, -1,
+		drm_send_vblank_event(drm_dev, *crtc,
 				      compo->mixer[*crtc]->pending_event);
 		drm_vblank_put(drm_dev, *crtc);
 		compo->mixer[*crtc]->pending_event = NULL;
-- 
2.5.0

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

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

* [PATCH 08/16] drm/irq: Rename drm_crtc -> crtc
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
                   ` (5 preceding siblings ...)
  2015-09-24 16:35 ` [PATCH 07/16] drm/sti: " Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-24 18:17   ` Daniel Vetter
  2015-09-24 16:35 ` [PATCH 09/16] drm/irq: Use unsigned int pipe in public API Thierry Reding
                   ` (7 subsequent siblings)
  14 siblings, 1 reply; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

Since the original crtc parameter was renamed to pipe, there is no
longer a need to artificially prefix the CRTC parameter.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/drm_irq.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 88fbee4cf4b7..29a6dcd674f8 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -1280,7 +1280,7 @@ EXPORT_SYMBOL(drm_crtc_vblank_off);
 
 /**
  * drm_crtc_vblank_reset - reset vblank state to off on a CRTC
- * @drm_crtc: CRTC in question
+ * @crtc: CRTC in question
  *
  * Drivers can use this function to reset the vblank state to off at load time.
  * Drivers should use this together with the drm_crtc_vblank_off() and
@@ -1288,11 +1288,11 @@ EXPORT_SYMBOL(drm_crtc_vblank_off);
  * drm_crtc_vblank_off() is that this function doesn't save the vblank counter
  * and hence doesn't need to call any driver hooks.
  */
-void drm_crtc_vblank_reset(struct drm_crtc *drm_crtc)
+void drm_crtc_vblank_reset(struct drm_crtc *crtc)
 {
-	struct drm_device *dev = drm_crtc->dev;
+	struct drm_device *dev = crtc->dev;
 	unsigned long irqflags;
-	unsigned int pipe = drm_crtc_index(drm_crtc);
+	unsigned int pipe = drm_crtc_index(crtc);
 	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 
 	spin_lock_irqsave(&dev->vbl_lock, irqflags);
-- 
2.5.0

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

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

* [PATCH 09/16] drm/irq: Use unsigned int pipe in public API
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
                   ` (6 preceding siblings ...)
  2015-09-24 16:35 ` [PATCH 08/16] drm/irq: Rename drm_crtc -> crtc Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-24 19:21   ` Russell King - ARM Linux
                     ` (2 more replies)
  2015-09-24 16:35 ` [PATCH 10/16] drm/gma500: Use unsigned int pipe consistently Thierry Reding
                   ` (6 subsequent siblings)
  14 siblings, 3 replies; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel
  Cc: Thomas Hellstrom, Laurent Pinchart, Benjamin Gaignard,
	Alison Wang, Tomi Valkeinen, Daniel Vetter, Alex Deucher,
	Russell King, Christian König, Ben Skeggs

From: Thierry Reding <treding@nvidia.com>

This continues the pattern started in commit cc1ef118fc09 ("drm/irq:
Make pipe unsigned and name consistent"). This is applied to the public
APIs and driver callbacks, so pretty much all drivers need to be updated
to match the new prototypes.

Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Jianwei Wang <jianwei.wang.chn@gmail.com>
Cc: Alison Wang <alison.wang@freescale.com>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Mark Yao <mark.yao@rock-chips.com>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Vincent Abriou <vincent.abriou@st.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h          |  8 +++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c  |  9 ++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c      | 36 +++++++++++++-------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h     |  9 +++----
 drivers/gpu/drm/armada/armada_drv.c          |  8 +++---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  6 +++--
 drivers/gpu/drm/drm_irq.c                    |  2 +-
 drivers/gpu/drm/exynos/exynos_drm_crtc.c     |  4 +--
 drivers/gpu/drm/exynos/exynos_drm_crtc.h     |  4 +--
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  5 ++--
 drivers/gpu/drm/gma500/psb_drv.h             |  6 ++---
 drivers/gpu/drm/gma500/psb_irq.c             |  8 +++---
 drivers/gpu/drm/gma500/psb_irq.h             |  6 ++---
 drivers/gpu/drm/i915/i915_irq.c              | 34 ++++++++++++-------------
 drivers/gpu/drm/imx/imx-drm-core.c           |  8 +++---
 drivers/gpu/drm/mga/mga_drv.h                |  6 ++---
 drivers/gpu/drm/mga/mga_irq.c                | 20 +++++++--------
 drivers/gpu/drm/msm/msm_drv.c                | 12 ++++-----
 drivers/gpu/drm/nouveau/nouveau_display.c    | 23 +++++++++--------
 drivers/gpu/drm/nouveau/nouveau_display.h    | 12 ++++-----
 drivers/gpu/drm/omapdrm/omap_drv.h           |  4 +--
 drivers/gpu/drm/omapdrm/omap_irq.c           | 16 ++++++------
 drivers/gpu/drm/qxl/qxl_drv.c                |  7 ++---
 drivers/gpu/drm/r128/r128_drv.h              |  6 ++---
 drivers/gpu/drm/r128/r128_irq.c              | 16 ++++++------
 drivers/gpu/drm/radeon/radeon_display.c      | 25 +++++++++---------
 drivers/gpu/drm/radeon/radeon_drv.c          | 13 +++++-----
 drivers/gpu/drm/radeon/radeon_drv.h          |  6 ++---
 drivers/gpu/drm/radeon/radeon_irq.c          | 38 ++++++++++++++--------------
 drivers/gpu/drm/radeon/radeon_mode.h         |  5 ++--
 drivers/gpu/drm/rcar-du/rcar_du_drv.c        |  8 +++---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c  |  6 +++--
 drivers/gpu/drm/shmobile/shmob_drm_drv.c     |  4 +--
 drivers/gpu/drm/sti/sti_crtc.c               | 16 ++++++------
 drivers/gpu/drm/sti/sti_crtc.h               |  4 +--
 drivers/gpu/drm/tegra/drm.c                  |  7 ++---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c          |  4 +--
 drivers/gpu/drm/via/via_drv.h                |  6 ++---
 drivers/gpu/drm/via/via_irq.c                | 17 +++++++------
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h          |  6 ++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c          |  6 ++---
 include/drm/drmP.h                           | 25 +++++++++---------
 42 files changed, 239 insertions(+), 232 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 668939a14206..d7b8e4b31d78 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -2348,10 +2348,10 @@ void amdgpu_driver_preclose_kms(struct drm_device *dev,
 				struct drm_file *file_priv);
 int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
 int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
-u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, int crtc);
-int amdgpu_enable_vblank_kms(struct drm_device *dev, int crtc);
-void amdgpu_disable_vblank_kms(struct drm_device *dev, int crtc);
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
+u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
+int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
+void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
+int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 				    int *max_error,
 				    struct timeval *vblank_time,
 				    unsigned flags);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 9b34a3410c32..de116398fa49 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -721,7 +721,7 @@ bool amdgpu_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
  * an optional accurate timestamp of when query happened.
  *
  * \param dev Device to query.
- * \param crtc Crtc to query.
+ * \param pipe Crtc to query.
  * \param flags Flags from caller (DRM_CALLED_FROM_VBLIRQ or 0).
  * \param *vpos Location where vertical scanout position should be stored.
  * \param *hpos Location where horizontal scanout position should go.
@@ -744,8 +744,9 @@ bool amdgpu_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
  * unknown small number of scanlines wrt. real scanout position.
  *
  */
-int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, int crtc, unsigned int flags,
-			       int *vpos, int *hpos, ktime_t *stime, ktime_t *etime,
+int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
+			       unsigned int flags, int *vpos, int *hpos,
+			       ktime_t *stime, ktime_t *etime,
 			       const struct drm_display_mode *mode)
 {
 	u32 vbl = 0, position = 0;
@@ -760,7 +761,7 @@ int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, int crtc, unsigned int fl
 	if (stime)
 		*stime = ktime_get();
 
-	if (amdgpu_display_page_flip_get_scanoutpos(adev, crtc, &vbl, &position) == 0)
+	if (amdgpu_display_page_flip_get_scanoutpos(adev, pipe, &vbl, &position) == 0)
 		ret |= DRM_SCANOUTPOS_VALID;
 
 	/* Get optional system timestamp after query. */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index ecfa703a9e69..0118fd3cda13 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -599,36 +599,36 @@ void amdgpu_driver_preclose_kms(struct drm_device *dev,
  * amdgpu_get_vblank_counter_kms - get frame count
  *
  * @dev: drm dev pointer
- * @crtc: crtc to get the frame count from
+ * @pipe: crtc to get the frame count from
  *
  * Gets the frame count on the requested crtc (all asics).
  * Returns frame count on success, -EINVAL on failure.
  */
-u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, int crtc)
+u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe)
 {
 	struct amdgpu_device *adev = dev->dev_private;
 
-	if (crtc < 0 || crtc >= adev->mode_info.num_crtc) {
-		DRM_ERROR("Invalid crtc %d\n", crtc);
+	if (pipe >= adev->mode_info.num_crtc) {
+		DRM_ERROR("Invalid crtc %u\n", pipe);
 		return -EINVAL;
 	}
 
-	return amdgpu_display_vblank_get_counter(adev, crtc);
+	return amdgpu_display_vblank_get_counter(adev, pipe);
 }
 
 /**
  * amdgpu_enable_vblank_kms - enable vblank interrupt
  *
  * @dev: drm dev pointer
- * @crtc: crtc to enable vblank interrupt for
+ * @pipe: crtc to enable vblank interrupt for
  *
  * Enable the interrupt on the requested crtc (all asics).
  * Returns 0 on success, -EINVAL on failure.
  */
-int amdgpu_enable_vblank_kms(struct drm_device *dev, int crtc)
+int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe)
 {
 	struct amdgpu_device *adev = dev->dev_private;
-	int idx = amdgpu_crtc_idx_to_irq_type(adev, crtc);
+	int idx = amdgpu_crtc_idx_to_irq_type(adev, pipe);
 
 	return amdgpu_irq_get(adev, &adev->crtc_irq, idx);
 }
@@ -637,14 +637,14 @@ int amdgpu_enable_vblank_kms(struct drm_device *dev, int crtc)
  * amdgpu_disable_vblank_kms - disable vblank interrupt
  *
  * @dev: drm dev pointer
- * @crtc: crtc to disable vblank interrupt for
+ * @pipe: crtc to disable vblank interrupt for
  *
  * Disable the interrupt on the requested crtc (all asics).
  */
-void amdgpu_disable_vblank_kms(struct drm_device *dev, int crtc)
+void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
 {
 	struct amdgpu_device *adev = dev->dev_private;
-	int idx = amdgpu_crtc_idx_to_irq_type(adev, crtc);
+	int idx = amdgpu_crtc_idx_to_irq_type(adev, pipe);
 
 	amdgpu_irq_put(adev, &adev->crtc_irq, idx);
 }
@@ -662,26 +662,26 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, int crtc)
  * scanout position.  (all asics).
  * Returns postive status flags on success, negative error on failure.
  */
-int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
+int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 				    int *max_error,
 				    struct timeval *vblank_time,
 				    unsigned flags)
 {
-	struct drm_crtc *drmcrtc;
+	struct drm_crtc *crtc;
 	struct amdgpu_device *adev = dev->dev_private;
 
-	if (crtc < 0 || crtc >= dev->num_crtcs) {
-		DRM_ERROR("Invalid crtc %d\n", crtc);
+	if (pipe >= dev->num_crtcs) {
+		DRM_ERROR("Invalid crtc %u\n", pipe);
 		return -EINVAL;
 	}
 
 	/* Get associated drm_crtc: */
-	drmcrtc = &adev->mode_info.crtcs[crtc]->base;
+	crtc = &adev->mode_info.crtcs[pipe]->base;
 
 	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
+	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
 						     vblank_time, flags,
-						     &drmcrtc->hwmode);
+						     &crtc->hwmode);
 }
 
 const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index 2b03425f9740..f6b02994442b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -540,11 +540,10 @@ bool amdgpu_ddc_probe(struct amdgpu_connector *amdgpu_connector, bool use_aux);
 
 void amdgpu_encoder_set_active_device(struct drm_encoder *encoder);
 
-int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, int crtc,
-				      unsigned int flags,
-				      int *vpos, int *hpos, ktime_t *stime,
-				      ktime_t *etime,
-				      const struct drm_display_mode *mode);
+int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
+			       unsigned int flags, int *vpos, int *hpos,
+			       ktime_t *stime, ktime_t *etime,
+			       const struct drm_display_mode *mode);
 
 int amdgpu_framebuffer_init(struct drm_device *dev,
 			     struct amdgpu_framebuffer *rfb,
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 225034b74cda..a438886fcdb6 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -254,17 +254,17 @@ void armada_drm_vbl_event_remove(struct armada_crtc *dcrtc,
 }
 
 /* These are called under the vbl_lock. */
-static int armada_drm_enable_vblank(struct drm_device *dev, int crtc)
+static int armada_drm_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct armada_private *priv = dev->dev_private;
-	armada_drm_crtc_enable_irq(priv->dcrtc[crtc], VSYNC_IRQ_ENA);
+	armada_drm_crtc_enable_irq(priv->dcrtc[pipe], VSYNC_IRQ_ENA);
 	return 0;
 }
 
-static void armada_drm_disable_vblank(struct drm_device *dev, int crtc)
+static void armada_drm_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct armada_private *priv = dev->dev_private;
-	armada_drm_crtc_disable_irq(priv->dcrtc[crtc], VSYNC_IRQ_ENA);
+	armada_drm_crtc_disable_irq(priv->dcrtc[pipe], VSYNC_IRQ_ENA);
 }
 
 static struct drm_ioctl_desc armada_ioctls[] = {
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 8bc62ec407f9..6dfb63ab54d2 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -656,7 +656,8 @@ static void atmel_hlcdc_dc_irq_uninstall(struct drm_device *dev)
 	regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr);
 }
 
-static int atmel_hlcdc_dc_enable_vblank(struct drm_device *dev, int crtc)
+static int atmel_hlcdc_dc_enable_vblank(struct drm_device *dev,
+					unsigned int pipe)
 {
 	struct atmel_hlcdc_dc *dc = dev->dev_private;
 
@@ -666,7 +667,8 @@ static int atmel_hlcdc_dc_enable_vblank(struct drm_device *dev, int crtc)
 	return 0;
 }
 
-static void atmel_hlcdc_dc_disable_vblank(struct drm_device *dev, int crtc)
+static void atmel_hlcdc_dc_disable_vblank(struct drm_device *dev,
+					  unsigned int pipe)
 {
 	struct atmel_hlcdc_dc *dc = dev->dev_private;
 
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 29a6dcd674f8..4a5dee5cd327 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -876,7 +876,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
  * Returns:
  * The software vblank counter.
  */
-u32 drm_vblank_count(struct drm_device *dev, int pipe)
+u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 0872aa2f450f..f364d694a780 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -167,7 +167,7 @@ err_crtc:
 	return ERR_PTR(ret);
 }
 
-int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe)
+int exynos_drm_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct exynos_drm_private *private = dev->dev_private;
 	struct exynos_drm_crtc *exynos_crtc =
@@ -179,7 +179,7 @@ int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe)
 	return 0;
 }
 
-void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe)
+void exynos_drm_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct exynos_drm_private *private = dev->dev_private;
 	struct exynos_drm_crtc *exynos_crtc =
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
index f87d4abda6f7..f9f365bd0257 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
@@ -23,8 +23,8 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
 					enum exynos_drm_output_type type,
 					const struct exynos_drm_crtc_ops *ops,
 					void *context);
-int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe);
-void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe);
+int exynos_drm_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe);
+void exynos_drm_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe);
 void exynos_drm_crtc_wait_pending_update(struct exynos_drm_crtc *exynos_crtc);
 void exynos_drm_crtc_finish_update(struct exynos_drm_crtc *exynos_crtc,
 				   struct exynos_drm_plane *exynos_plane);
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
index 9a8e2da47158..f1fd986ca332 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
@@ -140,7 +140,7 @@ static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
-static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, int crtc)
+static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
 	unsigned int value;
@@ -156,7 +156,8 @@ static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, int crtc)
 	return 0;
 }
 
-static void fsl_dcu_drm_disable_vblank(struct drm_device *dev, int crtc)
+static void fsl_dcu_drm_disable_vblank(struct drm_device *dev,
+				       unsigned int pipe)
 {
 	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
 	unsigned int value;
diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h
index e38057b91865..e21726ecac32 100644
--- a/drivers/gpu/drm/gma500/psb_drv.h
+++ b/drivers/gpu/drm/gma500/psb_drv.h
@@ -687,15 +687,15 @@ extern void psb_irq_turn_off_dpst(struct drm_device *dev);
 extern void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands);
 extern int psb_vblank_wait2(struct drm_device *dev, unsigned int *sequence);
 extern int psb_vblank_wait(struct drm_device *dev, unsigned int *sequence);
-extern int psb_enable_vblank(struct drm_device *dev, int crtc);
-extern void psb_disable_vblank(struct drm_device *dev, int crtc);
+extern int psb_enable_vblank(struct drm_device *dev, unsigned int pipe);
+extern void psb_disable_vblank(struct drm_device *dev, unsigned int pipe);
 void
 psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
 
 void
 psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
 
-extern u32 psb_get_vblank_counter(struct drm_device *dev, int crtc);
+extern u32 psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
 
 /* framebuffer.c */
 extern int psbfb_probed(struct drm_device *dev);
diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
index 624eb36511c5..78eb10902809 100644
--- a/drivers/gpu/drm/gma500/psb_irq.c
+++ b/drivers/gpu/drm/gma500/psb_irq.c
@@ -510,7 +510,7 @@ int psb_irq_disable_dpst(struct drm_device *dev)
 /*
  * It is used to enable VBLANK interrupt
  */
-int psb_enable_vblank(struct drm_device *dev, int pipe)
+int psb_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
@@ -549,7 +549,7 @@ int psb_enable_vblank(struct drm_device *dev, int pipe)
 /*
  * It is used to disable VBLANK interrupt
  */
-void psb_disable_vblank(struct drm_device *dev, int pipe)
+void psb_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
@@ -622,7 +622,7 @@ void mdfld_disable_te(struct drm_device *dev, int pipe)
 /* Called from drm generic code, passed a 'crtc', which
  * we use as a pipe index
  */
-u32 psb_get_vblank_counter(struct drm_device *dev, int pipe)
+u32 psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
 	uint32_t high_frame = PIPEAFRAMEHIGH;
 	uint32_t low_frame = PIPEAFRAMEPIXEL;
@@ -654,7 +654,7 @@ u32 psb_get_vblank_counter(struct drm_device *dev, int pipe)
 	reg_val = REG_READ(pipeconf_reg);
 
 	if (!(reg_val & PIPEACONF_ENABLE)) {
-		dev_err(dev->dev, "trying to get vblank count for disabled pipe %d\n",
+		dev_err(dev->dev, "trying to get vblank count for disabled pipe %u\n",
 								pipe);
 		goto psb_get_vblank_counter_exit;
 	}
diff --git a/drivers/gpu/drm/gma500/psb_irq.h b/drivers/gpu/drm/gma500/psb_irq.h
index d0b45ffa1126..e6a81a8c9f35 100644
--- a/drivers/gpu/drm/gma500/psb_irq.h
+++ b/drivers/gpu/drm/gma500/psb_irq.h
@@ -38,9 +38,9 @@ int psb_irq_enable_dpst(struct drm_device *dev);
 int psb_irq_disable_dpst(struct drm_device *dev);
 void psb_irq_turn_on_dpst(struct drm_device *dev);
 void psb_irq_turn_off_dpst(struct drm_device *dev);
-int  psb_enable_vblank(struct drm_device *dev, int pipe);
-void psb_disable_vblank(struct drm_device *dev, int pipe);
-u32  psb_get_vblank_counter(struct drm_device *dev, int pipe);
+int  psb_enable_vblank(struct drm_device *dev, unsigned int pipe);
+void psb_disable_vblank(struct drm_device *dev, unsigned int pipe);
+u32  psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
 
 int mdfld_enable_te(struct drm_device *dev, int pipe);
 void mdfld_disable_te(struct drm_device *dev, int pipe);
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 3dc3302d766d..7b3aeb0f8056 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -649,7 +649,7 @@ static void i915_enable_asle_pipestat(struct drm_device *dev)
  *   of horizontal active on the first line of vertical active
  */
 
-static u32 i8xx_get_vblank_counter(struct drm_device *dev, int pipe)
+static u32 i8xx_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
 	/* Gen2 doesn't have a hardware frame counter */
 	return 0;
@@ -658,7 +658,7 @@ static u32 i8xx_get_vblank_counter(struct drm_device *dev, int pipe)
 /* Called from drm generic code, passed a 'crtc', which
  * we use as a pipe index
  */
-static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
+static u32 i915_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned long high_frame;
@@ -706,7 +706,7 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
 	return (((high1 << 8) | low) + (pixel >= vbl_start)) & 0xffffff;
 }
 
-static u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)
+static u32 gm45_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	int reg = PIPE_FRMCOUNT_GM45(pipe);
@@ -767,7 +767,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return (position + crtc->scanline_offset) % vtotal;
 }
 
-static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
+static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
 				    unsigned int flags, int *vpos, int *hpos,
 				    ktime_t *stime, ktime_t *etime,
 				    const struct drm_display_mode *mode)
@@ -904,27 +904,27 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return position;
 }
 
-static int i915_get_vblank_timestamp(struct drm_device *dev, int pipe,
+static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 			      int *max_error,
 			      struct timeval *vblank_time,
 			      unsigned flags)
 {
 	struct drm_crtc *crtc;
 
-	if (pipe < 0 || pipe >= INTEL_INFO(dev)->num_pipes) {
-		DRM_ERROR("Invalid crtc %d\n", pipe);
+	if (pipe >= INTEL_INFO(dev)->num_pipes) {
+		DRM_ERROR("Invalid crtc %u\n", pipe);
 		return -EINVAL;
 	}
 
 	/* Get drm_crtc to timestamp: */
 	crtc = intel_get_crtc_for_pipe(dev, pipe);
 	if (crtc == NULL) {
-		DRM_ERROR("Invalid crtc %d\n", pipe);
+		DRM_ERROR("Invalid crtc %u\n", pipe);
 		return -EINVAL;
 	}
 
 	if (!crtc->hwmode.crtc_clock) {
-		DRM_DEBUG_KMS("crtc %d is disabled\n", pipe);
+		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
 		return -EBUSY;
 	}
 
@@ -2612,7 +2612,7 @@ void i915_handle_error(struct drm_device *dev, bool wedged,
 /* Called from drm generic code, passed 'crtc' which
  * we use as a pipe index
  */
-static int i915_enable_vblank(struct drm_device *dev, int pipe)
+static int i915_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
@@ -2629,7 +2629,7 @@ static int i915_enable_vblank(struct drm_device *dev, int pipe)
 	return 0;
 }
 
-static int ironlake_enable_vblank(struct drm_device *dev, int pipe)
+static int ironlake_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
@@ -2643,7 +2643,7 @@ static int ironlake_enable_vblank(struct drm_device *dev, int pipe)
 	return 0;
 }
 
-static int valleyview_enable_vblank(struct drm_device *dev, int pipe)
+static int valleyview_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
@@ -2656,7 +2656,7 @@ static int valleyview_enable_vblank(struct drm_device *dev, int pipe)
 	return 0;
 }
 
-static int gen8_enable_vblank(struct drm_device *dev, int pipe)
+static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
@@ -2672,7 +2672,7 @@ static int gen8_enable_vblank(struct drm_device *dev, int pipe)
 /* Called from drm generic code, passed 'crtc' which
  * we use as a pipe index
  */
-static void i915_disable_vblank(struct drm_device *dev, int pipe)
+static void i915_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
@@ -2684,7 +2684,7 @@ static void i915_disable_vblank(struct drm_device *dev, int pipe)
 	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
 }
 
-static void ironlake_disable_vblank(struct drm_device *dev, int pipe)
+static void ironlake_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
@@ -2696,7 +2696,7 @@ static void ironlake_disable_vblank(struct drm_device *dev, int pipe)
 	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
 }
 
-static void valleyview_disable_vblank(struct drm_device *dev, int pipe)
+static void valleyview_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
@@ -2707,7 +2707,7 @@ static void valleyview_disable_vblank(struct drm_device *dev, int pipe)
 	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
 }
 
-static void gen8_disable_vblank(struct drm_device *dev, int pipe)
+static void gen8_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index ad77c9d86409..5ac81180a46d 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -144,10 +144,10 @@ void imx_drm_handle_vblank(struct imx_drm_crtc *imx_drm_crtc)
 }
 EXPORT_SYMBOL_GPL(imx_drm_handle_vblank);
 
-static int imx_drm_enable_vblank(struct drm_device *drm, int crtc)
+static int imx_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
 {
 	struct imx_drm_device *imxdrm = drm->dev_private;
-	struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[crtc];
+	struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe];
 	int ret;
 
 	if (!imx_drm_crtc)
@@ -162,10 +162,10 @@ static int imx_drm_enable_vblank(struct drm_device *drm, int crtc)
 	return ret;
 }
 
-static void imx_drm_disable_vblank(struct drm_device *drm, int crtc)
+static void imx_drm_disable_vblank(struct drm_device *drm, unsigned int pipe)
 {
 	struct imx_drm_device *imxdrm = drm->dev_private;
-	struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[crtc];
+	struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe];
 
 	if (!imx_drm_crtc)
 		return;
diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
index b4a2014917e5..bb312339e0b0 100644
--- a/drivers/gpu/drm/mga/mga_drv.h
+++ b/drivers/gpu/drm/mga/mga_drv.h
@@ -183,9 +183,9 @@ extern int mga_warp_install_microcode(drm_mga_private_t *dev_priv);
 extern int mga_warp_init(drm_mga_private_t *dev_priv);
 
 				/* mga_irq.c */
-extern int mga_enable_vblank(struct drm_device *dev, int crtc);
-extern void mga_disable_vblank(struct drm_device *dev, int crtc);
-extern u32 mga_get_vblank_counter(struct drm_device *dev, int crtc);
+extern int mga_enable_vblank(struct drm_device *dev, unsigned int pipe);
+extern void mga_disable_vblank(struct drm_device *dev, unsigned int pipe);
+extern u32 mga_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
 extern int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence);
 extern int mga_driver_vblank_wait(struct drm_device *dev, unsigned int *sequence);
 extern irqreturn_t mga_driver_irq_handler(int irq, void *arg);
diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
index 1b071b8ff9dc..693ba708cfed 100644
--- a/drivers/gpu/drm/mga/mga_irq.c
+++ b/drivers/gpu/drm/mga/mga_irq.c
@@ -35,12 +35,12 @@
 #include <drm/mga_drm.h>
 #include "mga_drv.h"
 
-u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
+u32 mga_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
 	const drm_mga_private_t *const dev_priv =
 		(drm_mga_private_t *) dev->dev_private;
 
-	if (crtc != 0)
+	if (pipe != 0)
 		return 0;
 
 	return atomic_read(&dev_priv->vbl_received);
@@ -88,13 +88,13 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
 	return IRQ_NONE;
 }
 
-int mga_enable_vblank(struct drm_device *dev, int crtc)
+int mga_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
 
-	if (crtc != 0) {
-		DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
-			  crtc);
+	if (pipe != 0) {
+		DRM_ERROR("tried to enable vblank on non-existent crtc %u\n",
+			  pipe);
 		return 0;
 	}
 
@@ -103,11 +103,11 @@ int mga_enable_vblank(struct drm_device *dev, int crtc)
 }
 
 
-void mga_disable_vblank(struct drm_device *dev, int crtc)
+void mga_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
-	if (crtc != 0) {
-		DRM_ERROR("tried to disable vblank on non-existent crtc %d\n",
-			  crtc);
+	if (pipe != 0) {
+		DRM_ERROR("tried to disable vblank on non-existent crtc %u\n",
+			  pipe);
 	}
 
 	/* Do *NOT* disable the vertical refresh interrupt.  MGA doesn't have
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 0339c5d82d37..7e44511d0951 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -531,24 +531,24 @@ static void msm_irq_uninstall(struct drm_device *dev)
 	kms->funcs->irq_uninstall(kms);
 }
 
-static int msm_enable_vblank(struct drm_device *dev, int crtc_id)
+static int msm_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct msm_kms *kms = priv->kms;
 	if (!kms)
 		return -ENXIO;
-	DBG("dev=%p, crtc=%d", dev, crtc_id);
-	return vblank_ctrl_queue_work(priv, crtc_id, true);
+	DBG("dev=%p, crtc=%u", dev, pipe);
+	return vblank_ctrl_queue_work(priv, pipe, true);
 }
 
-static void msm_disable_vblank(struct drm_device *dev, int crtc_id)
+static void msm_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct msm_drm_private *priv = dev->dev_private;
 	struct msm_kms *kms = priv->kms;
 	if (!kms)
 		return;
-	DBG("dev=%p, crtc=%d", dev, crtc_id);
-	vblank_ctrl_queue_work(priv, crtc_id, false);
+	DBG("dev=%p, crtc=%u", dev, pipe);
+	vblank_ctrl_queue_work(priv, pipe, false);
 }
 
 /*
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index a82c3cbe3127..886079dd9baa 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -51,12 +51,12 @@ nouveau_display_vblank_handler(struct nvif_notify *notify)
 }
 
 int
-nouveau_display_vblank_enable(struct drm_device *dev, int head)
+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 == head) {
+		if (nv_crtc->index == pipe) {
 			nvif_notify_get(&nv_crtc->vblank);
 			return 0;
 		}
@@ -65,12 +65,12 @@ nouveau_display_vblank_enable(struct drm_device *dev, int head)
 }
 
 void
-nouveau_display_vblank_disable(struct drm_device *dev, int head)
+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 == head) {
+		if (nv_crtc->index == pipe) {
 			nvif_notify_put(&nv_crtc->vblank);
 			return;
 		}
@@ -132,14 +132,15 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 }
 
 int
-nouveau_display_scanoutpos(struct drm_device *dev, int head, unsigned int flags,
-			   int *vpos, int *hpos, ktime_t *stime, ktime_t *etime,
+nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
+			   unsigned int flags, int *vpos, int *hpos,
+			   ktime_t *stime, ktime_t *etime,
 			   const struct drm_display_mode *mode)
 {
 	struct drm_crtc *crtc;
 
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		if (nouveau_crtc(crtc)->index == head) {
+		if (nouveau_crtc(crtc)->index == pipe) {
 			return nouveau_display_scanoutpos_head(crtc, vpos, hpos,
 							       stime, etime);
 		}
@@ -149,15 +150,15 @@ nouveau_display_scanoutpos(struct drm_device *dev, int head, unsigned int flags,
 }
 
 int
-nouveau_display_vblstamp(struct drm_device *dev, int head, int *max_error,
-			 struct timeval *time, unsigned flags)
+nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
+			 int *max_error, struct timeval *time, unsigned flags)
 {
 	struct drm_crtc *crtc;
 
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		if (nouveau_crtc(crtc)->index == head) {
+		if (nouveau_crtc(crtc)->index == pipe) {
 			return drm_calc_vbltimestamp_from_scanoutpos(dev,
-					head, max_error, time, flags,
+					pipe, max_error, time, flags,
 					&crtc->hwmode);
 		}
 	}
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h b/drivers/gpu/drm/nouveau/nouveau_display.h
index 4182d21538c5..856abe0f070d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.h
+++ b/drivers/gpu/drm/nouveau/nouveau_display.h
@@ -65,12 +65,12 @@ int  nouveau_display_init(struct drm_device *dev);
 void nouveau_display_fini(struct drm_device *dev);
 int  nouveau_display_suspend(struct drm_device *dev, bool runtime);
 void nouveau_display_resume(struct drm_device *dev, bool runtime);
-int  nouveau_display_vblank_enable(struct drm_device *, int);
-void nouveau_display_vblank_disable(struct drm_device *, int);
-int  nouveau_display_scanoutpos(struct drm_device *, int, unsigned int,
-				int *, int *, ktime_t *, ktime_t *,
-				const struct drm_display_mode *);
-int  nouveau_display_vblstamp(struct drm_device *, int, int *,
+int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
+void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
+int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
+				unsigned int, int *, int *, ktime_t *,
+				ktime_t *, const struct drm_display_mode *);
+int  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
 			      struct timeval *, unsigned);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index 12081e61d45a..5c367aad8a6e 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -129,8 +129,8 @@ void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
 int omap_gem_resume(struct device *dev);
 #endif
 
-int omap_irq_enable_vblank(struct drm_device *dev, int crtc_id);
-void omap_irq_disable_vblank(struct drm_device *dev, int crtc_id);
+int omap_irq_enable_vblank(struct drm_device *dev, unsigned int pipe);
+void omap_irq_disable_vblank(struct drm_device *dev, unsigned int pipe);
 void __omap_irq_register(struct drm_device *dev, struct omap_drm_irq *irq);
 void __omap_irq_unregister(struct drm_device *dev, struct omap_drm_irq *irq);
 void omap_irq_register(struct drm_device *dev, struct omap_drm_irq *irq);
diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c b/drivers/gpu/drm/omapdrm/omap_irq.c
index 249c0330d6ce..60e1e8016708 100644
--- a/drivers/gpu/drm/omapdrm/omap_irq.c
+++ b/drivers/gpu/drm/omapdrm/omap_irq.c
@@ -134,7 +134,7 @@ int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait,
 /**
  * enable_vblank - enable vblank interrupt events
  * @dev: DRM device
- * @crtc: which irq to enable
+ * @pipe: which irq to enable
  *
  * Enable vblank interrupts for @crtc.  If the device doesn't have
  * a hardware vblank counter, this routine should be a no-op, since
@@ -144,13 +144,13 @@ int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait,
  * Zero on success, appropriate errno if the given @crtc's vblank
  * interrupt cannot be enabled.
  */
-int omap_irq_enable_vblank(struct drm_device *dev, int crtc_id)
+int omap_irq_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct omap_drm_private *priv = dev->dev_private;
-	struct drm_crtc *crtc = priv->crtcs[crtc_id];
+	struct drm_crtc *crtc = priv->crtcs[pipe];
 	unsigned long flags;
 
-	DBG("dev=%p, crtc=%d", dev, crtc_id);
+	DBG("dev=%p, crtc=%u", dev, pipe);
 
 	spin_lock_irqsave(&list_lock, flags);
 	priv->vblank_mask |= pipe2vbl(crtc);
@@ -163,19 +163,19 @@ int omap_irq_enable_vblank(struct drm_device *dev, int crtc_id)
 /**
  * disable_vblank - disable vblank interrupt events
  * @dev: DRM device
- * @crtc: which irq to enable
+ * @pipe: which irq to enable
  *
  * Disable vblank interrupts for @crtc.  If the device doesn't have
  * a hardware vblank counter, this routine should be a no-op, since
  * interrupts will have to stay on to keep the count accurate.
  */
-void omap_irq_disable_vblank(struct drm_device *dev, int crtc_id)
+void omap_irq_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct omap_drm_private *priv = dev->dev_private;
-	struct drm_crtc *crtc = priv->crtcs[crtc_id];
+	struct drm_crtc *crtc = priv->crtcs[pipe];
 	unsigned long flags;
 
-	DBG("dev=%p, crtc=%d", dev, crtc_id);
+	DBG("dev=%p, crtc=%u", dev, pipe);
 
 	spin_lock_irqsave(&list_lock, flags);
 	priv->vblank_mask &= ~pipe2vbl(crtc);
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 83f6f0b5e9ef..7307b07fe06b 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -196,17 +196,18 @@ static int qxl_pm_restore(struct device *dev)
 	return qxl_drm_resume(drm_dev, false);
 }
 
-static u32 qxl_noop_get_vblank_counter(struct drm_device *dev, int crtc)
+static u32 qxl_noop_get_vblank_counter(struct drm_device *dev,
+				       unsigned int pipe)
 {
 	return 0;
 }
 
-static int qxl_noop_enable_vblank(struct drm_device *dev, int crtc)
+static int qxl_noop_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	return 0;
 }
 
-static void qxl_noop_disable_vblank(struct drm_device *dev, int crtc)
+static void qxl_noop_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 }
 
diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
index 723e5d6f10a4..09143b840482 100644
--- a/drivers/gpu/drm/r128/r128_drv.h
+++ b/drivers/gpu/drm/r128/r128_drv.h
@@ -154,9 +154,9 @@ extern int r128_wait_ring(drm_r128_private_t *dev_priv, int n);
 extern int r128_do_cce_idle(drm_r128_private_t *dev_priv);
 extern int r128_do_cleanup_cce(struct drm_device *dev);
 
-extern int r128_enable_vblank(struct drm_device *dev, int crtc);
-extern void r128_disable_vblank(struct drm_device *dev, int crtc);
-extern u32 r128_get_vblank_counter(struct drm_device *dev, int crtc);
+extern int r128_enable_vblank(struct drm_device *dev, unsigned int pipe);
+extern void r128_disable_vblank(struct drm_device *dev, unsigned int pipe);
+extern u32 r128_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
 extern irqreturn_t r128_driver_irq_handler(int irq, void *arg);
 extern void r128_driver_irq_preinstall(struct drm_device *dev);
 extern int r128_driver_irq_postinstall(struct drm_device *dev);
diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
index c2ae496babb7..9730f4918944 100644
--- a/drivers/gpu/drm/r128/r128_irq.c
+++ b/drivers/gpu/drm/r128/r128_irq.c
@@ -34,11 +34,11 @@
 #include <drm/r128_drm.h>
 #include "r128_drv.h"
 
-u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
+u32 r128_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
 	const drm_r128_private_t *dev_priv = dev->dev_private;
 
-	if (crtc != 0)
+	if (pipe != 0)
 		return 0;
 
 	return atomic_read(&dev_priv->vbl_received);
@@ -62,12 +62,12 @@ irqreturn_t r128_driver_irq_handler(int irq, void *arg)
 	return IRQ_NONE;
 }
 
-int r128_enable_vblank(struct drm_device *dev, int crtc)
+int r128_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	drm_r128_private_t *dev_priv = dev->dev_private;
 
-	if (crtc != 0) {
-		DRM_ERROR("%s:  bad crtc %d\n", __func__, crtc);
+	if (pipe != 0) {
+		DRM_ERROR("%s:  bad crtc %u\n", __func__, pipe);
 		return -EINVAL;
 	}
 
@@ -75,10 +75,10 @@ int r128_enable_vblank(struct drm_device *dev, int crtc)
 	return 0;
 }
 
-void r128_disable_vblank(struct drm_device *dev, int crtc)
+void r128_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
-	if (crtc != 0)
-		DRM_ERROR("%s:  bad crtc %d\n", __func__, crtc);
+	if (pipe != 0)
+		DRM_ERROR("%s:  bad crtc %u\n", __func__, pipe);
 
 	/*
 	 * FIXME: implement proper interrupt disable by using the vblank
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 0503af748d99..a58635c5db3d 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1799,8 +1799,9 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
  * unknown small number of scanlines wrt. real scanout position.
  *
  */
-int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc, unsigned int flags,
-			       int *vpos, int *hpos, ktime_t *stime, ktime_t *etime,
+int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
+			       unsigned int flags, int *vpos, int *hpos,
+			       ktime_t *stime, ktime_t *etime,
 			       const struct drm_display_mode *mode)
 {
 	u32 stat_crtc = 0, vbl = 0, position = 0;
@@ -1816,42 +1817,42 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc, unsigned int fl
 		*stime = ktime_get();
 
 	if (ASIC_IS_DCE4(rdev)) {
-		if (crtc == 0) {
+		if (pipe == 0) {
 			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
 				     EVERGREEN_CRTC0_REGISTER_OFFSET);
 			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
 					  EVERGREEN_CRTC0_REGISTER_OFFSET);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (crtc == 1) {
+		if (pipe == 1) {
 			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
 				     EVERGREEN_CRTC1_REGISTER_OFFSET);
 			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
 					  EVERGREEN_CRTC1_REGISTER_OFFSET);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (crtc == 2) {
+		if (pipe == 2) {
 			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
 				     EVERGREEN_CRTC2_REGISTER_OFFSET);
 			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
 					  EVERGREEN_CRTC2_REGISTER_OFFSET);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (crtc == 3) {
+		if (pipe == 3) {
 			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
 				     EVERGREEN_CRTC3_REGISTER_OFFSET);
 			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
 					  EVERGREEN_CRTC3_REGISTER_OFFSET);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (crtc == 4) {
+		if (pipe == 4) {
 			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
 				     EVERGREEN_CRTC4_REGISTER_OFFSET);
 			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
 					  EVERGREEN_CRTC4_REGISTER_OFFSET);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (crtc == 5) {
+		if (pipe == 5) {
 			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
 				     EVERGREEN_CRTC5_REGISTER_OFFSET);
 			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
@@ -1859,19 +1860,19 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc, unsigned int fl
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
 	} else if (ASIC_IS_AVIVO(rdev)) {
-		if (crtc == 0) {
+		if (pipe == 0) {
 			vbl = RREG32(AVIVO_D1CRTC_V_BLANK_START_END);
 			position = RREG32(AVIVO_D1CRTC_STATUS_POSITION);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (crtc == 1) {
+		if (pipe == 1) {
 			vbl = RREG32(AVIVO_D2CRTC_V_BLANK_START_END);
 			position = RREG32(AVIVO_D2CRTC_STATUS_POSITION);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
 	} else {
 		/* Pre-AVIVO: Different encoding of scanout pos and vblank interval. */
-		if (crtc == 0) {
+		if (pipe == 0) {
 			/* Assume vbl_end == 0, get vbl_start from
 			 * upper 16 bits.
 			 */
@@ -1885,7 +1886,7 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc, unsigned int fl
 
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (crtc == 1) {
+		if (pipe == 1) {
 			vbl = (RREG32(RADEON_CRTC2_V_TOTAL_DISP) &
 				RADEON_CRTC_V_DISP) >> RADEON_CRTC_V_DISP_SHIFT;
 			position = (RREG32(RADEON_CRTC2_VLINE_CRNT_VLINE) >> 16) & RADEON_CRTC_V_TOTAL;
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index e30c1d73b4ca..5b6a6f5b3619 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -105,10 +105,10 @@ void radeon_driver_preclose_kms(struct drm_device *dev,
 				struct drm_file *file_priv);
 int radeon_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
 int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
-u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc);
-int radeon_enable_vblank_kms(struct drm_device *dev, int crtc);
-void radeon_disable_vblank_kms(struct drm_device *dev, int crtc);
-int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
+u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
+int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
+void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
+int radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 				    int *max_error,
 				    struct timeval *vblank_time,
 				    unsigned flags);
@@ -124,9 +124,8 @@ void radeon_gem_object_close(struct drm_gem_object *obj,
 struct dma_buf *radeon_gem_prime_export(struct drm_device *dev,
 					struct drm_gem_object *gobj,
 					int flags);
-extern int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc,
-				      unsigned int flags,
-				      int *vpos, int *hpos,
+extern int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int crtc,
+				      unsigned int flags, int *vpos, int *hpos,
 				      ktime_t *stime, ktime_t *etime,
 				      const struct drm_display_mode *mode);
 extern bool radeon_is_px(struct drm_device *dev);
diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
index 46bd3938282c..0caafc7a6e17 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.h
+++ b/drivers/gpu/drm/radeon/radeon_drv.h
@@ -404,9 +404,9 @@ extern int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *
 extern int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv);
 
 extern void radeon_do_release(struct drm_device * dev);
-extern u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc);
-extern int radeon_enable_vblank(struct drm_device *dev, int crtc);
-extern void radeon_disable_vblank(struct drm_device *dev, int crtc);
+extern u32 radeon_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
+extern int radeon_enable_vblank(struct drm_device *dev, unsigned int pipe);
+extern void radeon_disable_vblank(struct drm_device *dev, unsigned int pipe);
 extern irqreturn_t radeon_driver_irq_handler(int irq, void *arg);
 extern void radeon_driver_irq_preinstall(struct drm_device * dev);
 extern int radeon_driver_irq_postinstall(struct drm_device *dev);
diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
index 244b19bab2e7..688afb62f7c4 100644
--- a/drivers/gpu/drm/radeon/radeon_irq.c
+++ b/drivers/gpu/drm/radeon/radeon_irq.c
@@ -62,12 +62,12 @@ static void r500_vbl_irq_set_state(struct drm_device *dev, u32 mask, int state)
 		RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg);
 }
 
-int radeon_enable_vblank(struct drm_device *dev, int crtc)
+int radeon_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	drm_radeon_private_t *dev_priv = dev->dev_private;
 
 	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) {
-		switch (crtc) {
+		switch (pipe) {
 		case 0:
 			r500_vbl_irq_set_state(dev, R500_D1MODE_INT_MASK, 1);
 			break;
@@ -75,12 +75,12 @@ int radeon_enable_vblank(struct drm_device *dev, int crtc)
 			r500_vbl_irq_set_state(dev, R500_D2MODE_INT_MASK, 1);
 			break;
 		default:
-			DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
-				  crtc);
+			DRM_ERROR("tried to enable vblank on non-existent crtc %u\n",
+				  pipe);
 			return -EINVAL;
 		}
 	} else {
-		switch (crtc) {
+		switch (pipe) {
 		case 0:
 			radeon_irq_set_state(dev, RADEON_CRTC_VBLANK_MASK, 1);
 			break;
@@ -88,8 +88,8 @@ int radeon_enable_vblank(struct drm_device *dev, int crtc)
 			radeon_irq_set_state(dev, RADEON_CRTC2_VBLANK_MASK, 1);
 			break;
 		default:
-			DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
-				  crtc);
+			DRM_ERROR("tried to enable vblank on non-existent crtc %u\n",
+				  pipe);
 			return -EINVAL;
 		}
 	}
@@ -97,12 +97,12 @@ int radeon_enable_vblank(struct drm_device *dev, int crtc)
 	return 0;
 }
 
-void radeon_disable_vblank(struct drm_device *dev, int crtc)
+void radeon_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	drm_radeon_private_t *dev_priv = dev->dev_private;
 
 	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) {
-		switch (crtc) {
+		switch (pipe) {
 		case 0:
 			r500_vbl_irq_set_state(dev, R500_D1MODE_INT_MASK, 0);
 			break;
@@ -110,12 +110,12 @@ void radeon_disable_vblank(struct drm_device *dev, int crtc)
 			r500_vbl_irq_set_state(dev, R500_D2MODE_INT_MASK, 0);
 			break;
 		default:
-			DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
-				  crtc);
+			DRM_ERROR("tried to enable vblank on non-existent crtc %u\n",
+				  pipe);
 			break;
 		}
 	} else {
-		switch (crtc) {
+		switch (pipe) {
 		case 0:
 			radeon_irq_set_state(dev, RADEON_CRTC_VBLANK_MASK, 0);
 			break;
@@ -123,8 +123,8 @@ void radeon_disable_vblank(struct drm_device *dev, int crtc)
 			radeon_irq_set_state(dev, RADEON_CRTC2_VBLANK_MASK, 0);
 			break;
 		default:
-			DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
-				  crtc);
+			DRM_ERROR("tried to enable vblank on non-existent crtc %u\n",
+				  pipe);
 			break;
 		}
 	}
@@ -255,7 +255,7 @@ static int radeon_wait_irq(struct drm_device * dev, int swi_nr)
 	return ret;
 }
 
-u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc)
+u32 radeon_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
 	drm_radeon_private_t *dev_priv = dev->dev_private;
 
@@ -264,18 +264,18 @@ u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc)
 		return -EINVAL;
 	}
 
-	if (crtc < 0 || crtc > 1) {
-		DRM_ERROR("Invalid crtc %d\n", crtc);
+	if (pipe > 1) {
+		DRM_ERROR("Invalid crtc %u\n", pipe);
 		return -EINVAL;
 	}
 
 	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) {
-		if (crtc == 0)
+		if (pipe == 0)
 			return RADEON_READ(R500_D1CRTC_FRAME_COUNT);
 		else
 			return RADEON_READ(R500_D2CRTC_FRAME_COUNT);
 	} else {
-		if (crtc == 0)
+		if (pipe == 0)
 			return RADEON_READ(RADEON_CRTC_CRNT_FRAME);
 		else
 			return RADEON_READ(RADEON_CRTC2_CRNT_FRAME);
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index 2317d04f8a09..de18f0668bea 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -874,9 +874,8 @@ extern int radeon_crtc_cursor_move(struct drm_crtc *crtc,
 				   int x, int y);
 extern void radeon_cursor_reset(struct drm_crtc *crtc);
 
-extern int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc,
-				      unsigned int flags,
-				      int *vpos, int *hpos,
+extern int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
+				      unsigned int flags, int *vpos, int *hpos,
 				      ktime_t *stime, ktime_t *etime,
 				      const struct drm_display_mode *mode);
 
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 780ca11512ba..bb806c4c2e65 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -221,20 +221,20 @@ static void rcar_du_lastclose(struct drm_device *dev)
 	drm_fbdev_cma_restore_mode(rcdu->fbdev);
 }
 
-static int rcar_du_enable_vblank(struct drm_device *dev, int crtc)
+static int rcar_du_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct rcar_du_device *rcdu = dev->dev_private;
 
-	rcar_du_crtc_enable_vblank(&rcdu->crtcs[crtc], true);
+	rcar_du_crtc_enable_vblank(&rcdu->crtcs[pipe], true);
 
 	return 0;
 }
 
-static void rcar_du_disable_vblank(struct drm_device *dev, int crtc)
+static void rcar_du_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct rcar_du_device *rcdu = dev->dev_private;
 
-	rcar_du_crtc_enable_vblank(&rcdu->crtcs[crtc], false);
+	rcar_du_crtc_enable_vblank(&rcdu->crtcs[pipe], false);
 }
 
 static const struct file_operations rcar_du_fops = {
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 9a0c2911272a..32c6098a99d1 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -103,7 +103,8 @@ static struct drm_crtc *rockchip_crtc_from_pipe(struct drm_device *drm,
 	return NULL;
 }
 
-static int rockchip_drm_crtc_enable_vblank(struct drm_device *dev, int pipe)
+static int rockchip_drm_crtc_enable_vblank(struct drm_device *dev,
+					   unsigned int pipe)
 {
 	struct rockchip_drm_private *priv = dev->dev_private;
 	struct drm_crtc *crtc = rockchip_crtc_from_pipe(dev, pipe);
@@ -115,7 +116,8 @@ static int rockchip_drm_crtc_enable_vblank(struct drm_device *dev, int pipe)
 	return 0;
 }
 
-static void rockchip_drm_crtc_disable_vblank(struct drm_device *dev, int pipe)
+static void rockchip_drm_crtc_disable_vblank(struct drm_device *dev,
+					     unsigned int pipe)
 {
 	struct rockchip_drm_private *priv = dev->dev_private;
 	struct drm_crtc *crtc = rockchip_crtc_from_pipe(dev, pipe);
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index 666321de7b99..ca2f918a6587 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -231,7 +231,7 @@ static irqreturn_t shmob_drm_irq(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
-static int shmob_drm_enable_vblank(struct drm_device *dev, int crtc)
+static int shmob_drm_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct shmob_drm_device *sdev = dev->dev_private;
 
@@ -240,7 +240,7 @@ static int shmob_drm_enable_vblank(struct drm_device *dev, int crtc)
 	return 0;
 }
 
-static void shmob_drm_disable_vblank(struct drm_device *dev, int crtc)
+static void shmob_drm_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct shmob_drm_device *sdev = dev->dev_private;
 
diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
index 81c56ea9d87f..c6fb8dee11de 100644
--- a/drivers/gpu/drm/sti/sti_crtc.c
+++ b/drivers/gpu/drm/sti/sti_crtc.c
@@ -299,7 +299,7 @@ int sti_crtc_vblank_cb(struct notifier_block *nb,
 	return 0;
 }
 
-int sti_crtc_enable_vblank(struct drm_device *dev, int crtc)
+int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct sti_private *dev_priv = dev->dev_private;
 	struct sti_compositor *compo = dev_priv->compo;
@@ -307,9 +307,9 @@ int sti_crtc_enable_vblank(struct drm_device *dev, int crtc)
 
 	DRM_DEBUG_DRIVER("\n");
 
-	if (sti_vtg_register_client(crtc == STI_MIXER_MAIN ?
+	if (sti_vtg_register_client(pipe == STI_MIXER_MAIN ?
 			compo->vtg_main : compo->vtg_aux,
-			vtg_vblank_nb, crtc)) {
+			vtg_vblank_nb, pipe)) {
 		DRM_ERROR("Cannot register VTG notifier\n");
 		return -EINVAL;
 	}
@@ -318,7 +318,7 @@ int sti_crtc_enable_vblank(struct drm_device *dev, int crtc)
 }
 EXPORT_SYMBOL(sti_crtc_enable_vblank);
 
-void sti_crtc_disable_vblank(struct drm_device *drm_dev, int crtc)
+void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe)
 {
 	struct sti_private *priv = drm_dev->dev_private;
 	struct sti_compositor *compo = priv->compo;
@@ -326,14 +326,14 @@ void sti_crtc_disable_vblank(struct drm_device *drm_dev, int crtc)
 
 	DRM_DEBUG_DRIVER("\n");
 
-	if (sti_vtg_unregister_client(crtc == STI_MIXER_MAIN ?
+	if (sti_vtg_unregister_client(pipe == STI_MIXER_MAIN ?
 			compo->vtg_main : compo->vtg_aux, vtg_vblank_nb))
 		DRM_DEBUG_DRIVER("Warning: cannot unregister VTG notifier\n");
 
 	/* free the resources of the pending requests */
-	if (compo->mixer[crtc]->pending_event) {
-		drm_vblank_put(drm_dev, crtc);
-		compo->mixer[crtc]->pending_event = NULL;
+	if (compo->mixer[pipe]->pending_event) {
+		drm_vblank_put(drm_dev, pipe);
+		compo->mixer[pipe]->pending_event = NULL;
 	}
 }
 EXPORT_SYMBOL(sti_crtc_disable_vblank);
diff --git a/drivers/gpu/drm/sti/sti_crtc.h b/drivers/gpu/drm/sti/sti_crtc.h
index 51963e6ddbe7..3f2d89a3634d 100644
--- a/drivers/gpu/drm/sti/sti_crtc.h
+++ b/drivers/gpu/drm/sti/sti_crtc.h
@@ -13,8 +13,8 @@ struct sti_mixer;
 
 int sti_crtc_init(struct drm_device *drm_dev, struct sti_mixer *mixer,
 		  struct drm_plane *primary, struct drm_plane *cursor);
-int sti_crtc_enable_vblank(struct drm_device *dev, int crtc);
-void sti_crtc_disable_vblank(struct drm_device *dev, int crtc);
+int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe);
+void sti_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe);
 int sti_crtc_vblank_cb(struct notifier_block *nb,
 		       unsigned long event, void *data);
 bool sti_crtc_is_main(struct drm_crtc *drm_crtc);
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 2486bc24bff6..759e6af91e59 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -822,7 +822,8 @@ static struct drm_crtc *tegra_crtc_from_pipe(struct drm_device *drm,
 	return NULL;
 }
 
-static u32 tegra_drm_get_vblank_counter(struct drm_device *drm, int pipe)
+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 tegra_dc *dc = to_tegra_dc(crtc);
@@ -833,7 +834,7 @@ static u32 tegra_drm_get_vblank_counter(struct drm_device *drm, int pipe)
 	return tegra_dc_get_vblank_counter(dc);
 }
 
-static int tegra_drm_enable_vblank(struct drm_device *drm, int pipe)
+static int tegra_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
 {
 	struct drm_crtc *crtc = tegra_crtc_from_pipe(drm, pipe);
 	struct tegra_dc *dc = to_tegra_dc(crtc);
@@ -846,7 +847,7 @@ static int tegra_drm_enable_vblank(struct drm_device *drm, int pipe)
 	return 0;
 }
 
-static void tegra_drm_disable_vblank(struct drm_device *drm, 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 tegra_dc *dc = to_tegra_dc(crtc);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 0f283a3b932c..a5b8f5d39311 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -425,13 +425,13 @@ static void enable_vblank(struct drm_device *dev, bool enable)
 		tilcdc_clear(dev, reg, mask);
 }
 
-static int tilcdc_enable_vblank(struct drm_device *dev, int crtc)
+static int tilcdc_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	enable_vblank(dev, true);
 	return 0;
 }
 
-static void tilcdc_disable_vblank(struct drm_device *dev, int crtc)
+static void tilcdc_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	enable_vblank(dev, false);
 }
diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
index ef8c500b4a00..644093f5046c 100644
--- a/drivers/gpu/drm/via/via_drv.h
+++ b/drivers/gpu/drm/via/via_drv.h
@@ -136,9 +136,9 @@ extern int via_init_context(struct drm_device *dev, int context);
 extern int via_final_context(struct drm_device *dev, int context);
 
 extern int via_do_cleanup_map(struct drm_device *dev);
-extern u32 via_get_vblank_counter(struct drm_device *dev, int crtc);
-extern int via_enable_vblank(struct drm_device *dev, int crtc);
-extern void via_disable_vblank(struct drm_device *dev, int crtc);
+extern u32 via_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
+extern int via_enable_vblank(struct drm_device *dev, unsigned int pipe);
+extern void via_disable_vblank(struct drm_device *dev, unsigned int pipe);
 
 extern irqreturn_t via_driver_irq_handler(int irq, void *arg);
 extern void via_driver_irq_preinstall(struct drm_device *dev);
diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
index 1319433816d3..ea8172c747a2 100644
--- a/drivers/gpu/drm/via/via_irq.c
+++ b/drivers/gpu/drm/via/via_irq.c
@@ -95,10 +95,11 @@ static unsigned time_diff(struct timeval *now, struct timeval *then)
 		1000000 - (then->tv_usec - now->tv_usec);
 }
 
-u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
+u32 via_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
 	drm_via_private_t *dev_priv = dev->dev_private;
-	if (crtc != 0)
+
+	if (pipe != 0)
 		return 0;
 
 	return atomic_read(&dev_priv->vbl_received);
@@ -170,13 +171,13 @@ static __inline__ void viadrv_acknowledge_irqs(drm_via_private_t *dev_priv)
 	}
 }
 
-int via_enable_vblank(struct drm_device *dev, int crtc)
+int via_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	drm_via_private_t *dev_priv = dev->dev_private;
 	u32 status;
 
-	if (crtc != 0) {
-		DRM_ERROR("%s:  bad crtc %d\n", __func__, crtc);
+	if (pipe != 0) {
+		DRM_ERROR("%s:  bad crtc %u\n", __func__, pipe);
 		return -EINVAL;
 	}
 
@@ -189,7 +190,7 @@ int via_enable_vblank(struct drm_device *dev, int crtc)
 	return 0;
 }
 
-void via_disable_vblank(struct drm_device *dev, int crtc)
+void via_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	drm_via_private_t *dev_priv = dev->dev_private;
 	u32 status;
@@ -200,8 +201,8 @@ void via_disable_vblank(struct drm_device *dev, int crtc)
 	VIA_WRITE8(0x83d4, 0x11);
 	VIA_WRITE8(0x83d5, VIA_READ8(0x83d5) & ~0x30);
 
-	if (crtc != 0)
-		DRM_ERROR("%s:  bad crtc %d\n", __func__, crtc);
+	if (pipe != 0)
+		DRM_ERROR("%s:  bad crtc %u\n", __func__, pipe);
 }
 
 static int
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 6d02de6dc36c..a4a1807a30cc 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -913,9 +913,9 @@ void vmw_kms_idle_workqueues(struct vmw_master *vmaster);
 bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv,
 				uint32_t pitch,
 				uint32_t height);
-u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc);
-int vmw_enable_vblank(struct drm_device *dev, int crtc);
-void vmw_disable_vblank(struct drm_device *dev, int crtc);
+u32 vmw_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
+int vmw_enable_vblank(struct drm_device *dev, unsigned int pipe);
+void vmw_disable_vblank(struct drm_device *dev, unsigned int pipe);
 int vmw_kms_present(struct vmw_private *dev_priv,
 		    struct drm_file *file_priv,
 		    struct vmw_framebuffer *vfb,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 61fb7f3de311..16c4299f2be2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -1263,7 +1263,7 @@ bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv,
 /**
  * Function called by DRM code called with vbl_lock held.
  */
-u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc)
+u32 vmw_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
 	return 0;
 }
@@ -1271,7 +1271,7 @@ u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc)
 /**
  * Function called by DRM code called with vbl_lock held.
  */
-int vmw_enable_vblank(struct drm_device *dev, int crtc)
+int vmw_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	return -ENOSYS;
 }
@@ -1279,7 +1279,7 @@ int vmw_enable_vblank(struct drm_device *dev, int crtc)
 /**
  * Function called by DRM code called with vbl_lock held.
  */
-void vmw_disable_vblank(struct drm_device *dev, int crtc)
+void vmw_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
 }
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index e42e34549da8..a013a0ed8e6a 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -412,7 +412,7 @@ struct drm_driver {
 	/**
 	 * get_vblank_counter - get raw hardware vblank counter
 	 * @dev: DRM device
-	 * @crtc: counter to fetch
+	 * @pipe: counter to fetch
 	 *
 	 * Driver callback for fetching a raw hardware vblank counter for @crtc.
 	 * If a device doesn't have a hardware counter, the driver can simply
@@ -426,12 +426,12 @@ struct drm_driver {
 	 * RETURNS
 	 * Raw vblank counter value.
 	 */
-	u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);
+	u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe);
 
 	/**
 	 * enable_vblank - enable vblank interrupt events
 	 * @dev: DRM device
-	 * @crtc: which irq to enable
+	 * @pipe: which irq to enable
 	 *
 	 * Enable vblank interrupts for @crtc.  If the device doesn't have
 	 * a hardware vblank counter, this routine should be a no-op, since
@@ -441,18 +441,18 @@ struct drm_driver {
 	 * Zero on success, appropriate errno if the given @crtc's vblank
 	 * interrupt cannot be enabled.
 	 */
-	int (*enable_vblank) (struct drm_device *dev, int crtc);
+	int (*enable_vblank) (struct drm_device *dev, unsigned int pipe);
 
 	/**
 	 * disable_vblank - disable vblank interrupt events
 	 * @dev: DRM device
-	 * @crtc: which irq to enable
+	 * @pipe: which irq to enable
 	 *
 	 * Disable vblank interrupts for @crtc.  If the device doesn't have
 	 * a hardware vblank counter, this routine should be a no-op, since
 	 * interrupts will have to stay on to keep the count accurate.
 	 */
-	void (*disable_vblank) (struct drm_device *dev, int crtc);
+	void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);
 
 	/**
 	 * Called by \c drm_device_is_agp.  Typically used to determine if a
@@ -474,7 +474,7 @@ struct drm_driver {
 	 * optional accurate ktime_get timestamp of when position was measured.
 	 *
 	 * \param dev  DRM device.
-	 * \param crtc Id of the crtc to query.
+	 * \param pipe Id of the crtc to query.
 	 * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
 	 * \param *vpos Target location for current vertical scanout position.
 	 * \param *hpos Target location for current horizontal scanout position.
@@ -498,9 +498,8 @@ struct drm_driver {
 	 * but unknown small number of scanlines wrt. real scanout position.
 	 *
 	 */
-	int (*get_scanout_position) (struct drm_device *dev, int crtc,
-				     unsigned int flags,
-				     int *vpos, int *hpos,
+	int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
+				     unsigned int flags, int *vpos, int *hpos,
 				     ktime_t *stime, ktime_t *etime,
 				     const struct drm_display_mode *mode);
 
@@ -518,7 +517,7 @@ struct drm_driver {
 	 * to the OpenML OML_sync_control extension specification.
 	 *
 	 * \param dev dev DRM device handle.
-	 * \param crtc crtc for which timestamp should be returned.
+	 * \param pipe crtc for which timestamp should be returned.
 	 * \param *max_error Maximum allowable timestamp error in nanoseconds.
 	 *                   Implementation should strive to provide timestamp
 	 *                   with an error of at most *max_error nanoseconds.
@@ -534,7 +533,7 @@ struct drm_driver {
 	 * negative number on failure. A positive status code on success,
 	 * which describes how the vblank_time timestamp was computed.
 	 */
-	int (*get_vblank_timestamp) (struct drm_device *dev, int crtc,
+	int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
 				     int *max_error,
 				     struct timeval *vblank_time,
 				     unsigned flags);
@@ -927,7 +926,7 @@ extern int drm_irq_uninstall(struct drm_device *dev);
 extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
 extern int drm_wait_vblank(struct drm_device *dev, void *data,
 			   struct drm_file *filp);
-extern u32 drm_vblank_count(struct drm_device *dev, int pipe);
+extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
 extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
 extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
 				     struct timeval *vblanktime);
-- 
2.5.0

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

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

* [PATCH 10/16] drm/gma500: Use unsigned int pipe consistently
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
                   ` (7 preceding siblings ...)
  2015-09-24 16:35 ` [PATCH 09/16] drm/irq: Use unsigned int pipe in public API Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-24 16:35 ` [PATCH 11/16] drm/imx: Use unsigned int for CRTC index Thierry Reding
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

The pipe number can never be negative, so turn variables referring to it
to unsigned int.

Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/gma500/psb_drv.h |  8 ++++----
 drivers/gpu/drm/gma500/psb_irq.c | 30 ++++++++++++++++--------------
 drivers/gpu/drm/gma500/psb_irq.h |  4 ++--
 3 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h
index e21726ecac32..5920a896da1b 100644
--- a/drivers/gpu/drm/gma500/psb_drv.h
+++ b/drivers/gpu/drm/gma500/psb_drv.h
@@ -689,11 +689,11 @@ extern int psb_vblank_wait2(struct drm_device *dev, unsigned int *sequence);
 extern int psb_vblank_wait(struct drm_device *dev, unsigned int *sequence);
 extern int psb_enable_vblank(struct drm_device *dev, unsigned int pipe);
 extern void psb_disable_vblank(struct drm_device *dev, unsigned int pipe);
-void
-psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
+void psb_enable_pipestat(struct drm_psb_private *dev_priv, unsigned int pipe,
+			 u32 mask);
 
-void
-psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
+void psb_disable_pipestat(struct drm_psb_private *dev_priv, unsigned int pipe,
+			  u32 mask);
 
 extern u32 psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
 
diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
index 78eb10902809..6e383d4d097b 100644
--- a/drivers/gpu/drm/gma500/psb_irq.c
+++ b/drivers/gpu/drm/gma500/psb_irq.c
@@ -35,7 +35,7 @@
  */
 
 static inline u32
-psb_pipestat(int pipe)
+psb_pipestat(unsigned int pipe)
 {
 	if (pipe == 0)
 		return PIPEASTAT;
@@ -47,7 +47,7 @@ psb_pipestat(int pipe)
 }
 
 static inline u32
-mid_pipe_event(int pipe)
+mid_pipe_event(unsigned int pipe)
 {
 	if (pipe == 0)
 		return _PSB_PIPEA_EVENT_FLAG;
@@ -59,7 +59,7 @@ mid_pipe_event(int pipe)
 }
 
 static inline u32
-mid_pipe_vsync(int pipe)
+mid_pipe_vsync(unsigned int pipe)
 {
 	if (pipe == 0)
 		return _PSB_VSYNC_PIPEA_FLAG;
@@ -71,7 +71,7 @@ mid_pipe_vsync(int pipe)
 }
 
 static inline u32
-mid_pipeconf(int pipe)
+mid_pipeconf(unsigned int pipe)
 {
 	if (pipe == 0)
 		return PIPEACONF;
@@ -82,8 +82,8 @@ mid_pipeconf(int pipe)
 	BUG();
 }
 
-void
-psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask)
+void psb_enable_pipestat(struct drm_psb_private *dev_priv, unsigned int pipe,
+			 u32 mask)
 {
 	if ((dev_priv->pipestat[pipe] & mask) != mask) {
 		u32 reg = psb_pipestat(pipe);
@@ -99,8 +99,8 @@ psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask)
 	}
 }
 
-void
-psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask)
+void psb_disable_pipestat(struct drm_psb_private *dev_priv, unsigned int pipe,
+			  u32 mask)
 {
 	if ((dev_priv->pipestat[pipe] & mask) != 0) {
 		u32 reg = psb_pipestat(pipe);
@@ -115,7 +115,8 @@ psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask)
 	}
 }
 
-static void mid_enable_pipe_event(struct drm_psb_private *dev_priv, int pipe)
+static void mid_enable_pipe_event(struct drm_psb_private *dev_priv,
+				  unsigned int pipe)
 {
 	if (gma_power_begin(dev_priv->dev, false)) {
 		u32 pipe_event = mid_pipe_event(pipe);
@@ -126,7 +127,8 @@ static void mid_enable_pipe_event(struct drm_psb_private *dev_priv, int pipe)
 	}
 }
 
-static void mid_disable_pipe_event(struct drm_psb_private *dev_priv, int pipe)
+static void mid_disable_pipe_event(struct drm_psb_private *dev_priv,
+				   unsigned int pipe)
 {
 	if (dev_priv->pipestat[pipe] == 0) {
 		if (gma_power_begin(dev_priv->dev, false)) {
@@ -143,7 +145,7 @@ static void mid_disable_pipe_event(struct drm_psb_private *dev_priv, int pipe)
  * Display controller interrupt handler for pipe event.
  *
  */
-static void mid_pipe_event_handler(struct drm_device *dev, int pipe)
+static void mid_pipe_event_handler(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_psb_private *dev_priv =
 	    (struct drm_psb_private *) dev->dev_private;
@@ -175,7 +177,7 @@ static void mid_pipe_event_handler(struct drm_device *dev, int pipe)
 
 	if (pipe_clear)
 		dev_err(dev->dev,
-		"%s, can't clear status bits for pipe %d, its value = 0x%x.\n",
+		"%s, can't clear status bits for pipe %u, its value = 0x%x.\n",
 		__func__, pipe, PSB_RVDC32(pipe_stat_reg));
 
 	if (pipe_stat_val & PIPE_VBLANK_STATUS)
@@ -573,7 +575,7 @@ void psb_disable_vblank(struct drm_device *dev, unsigned int pipe)
 /*
  * It is used to enable TE interrupt
  */
-int mdfld_enable_te(struct drm_device *dev, int pipe)
+int mdfld_enable_te(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_psb_private *dev_priv =
 		(struct drm_psb_private *) dev->dev_private;
@@ -602,7 +604,7 @@ int mdfld_enable_te(struct drm_device *dev, int pipe)
 /*
  * It is used to disable TE interrupt
  */
-void mdfld_disable_te(struct drm_device *dev, int pipe)
+void mdfld_disable_te(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_psb_private *dev_priv =
 		(struct drm_psb_private *) dev->dev_private;
diff --git a/drivers/gpu/drm/gma500/psb_irq.h b/drivers/gpu/drm/gma500/psb_irq.h
index e6a81a8c9f35..cbf64a10c92d 100644
--- a/drivers/gpu/drm/gma500/psb_irq.h
+++ b/drivers/gpu/drm/gma500/psb_irq.h
@@ -42,6 +42,6 @@ int  psb_enable_vblank(struct drm_device *dev, unsigned int pipe);
 void psb_disable_vblank(struct drm_device *dev, unsigned int pipe);
 u32  psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
 
-int mdfld_enable_te(struct drm_device *dev, int pipe);
-void mdfld_disable_te(struct drm_device *dev, int pipe);
+int mdfld_enable_te(struct drm_device *dev, unsigned int pipe);
+void mdfld_disable_te(struct drm_device *dev, unsigned int pipe);
 #endif /* _PSB_IRQ_H_ */
-- 
2.5.0

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

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

* [PATCH 11/16] drm/imx: Use unsigned int for CRTC index
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
                   ` (8 preceding siblings ...)
  2015-09-24 16:35 ` [PATCH 10/16] drm/gma500: Use unsigned int pipe consistently Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-24 16:35 ` [PATCH 12/16] drm/msm: Use unsigned int pipe consistently Thierry Reding
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

The CRTC index can never be negative, so use an unsigned rather than a
signed integer for the loop variable.

Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/imx/imx-drm-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index 5ac81180a46d..40950e15b759 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -179,7 +179,7 @@ static void imx_drm_disable_vblank(struct drm_device *drm, unsigned int pipe)
 static void imx_drm_driver_preclose(struct drm_device *drm,
 		struct drm_file *file)
 {
-	int i;
+	unsigned int i;
 
 	if (!file->is_master)
 		return;
-- 
2.5.0

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

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

* [PATCH 12/16] drm/msm: Use unsigned int pipe consistently
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
                   ` (9 preceding siblings ...)
  2015-09-24 16:35 ` [PATCH 11/16] drm/imx: Use unsigned int for CRTC index Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-24 16:35 ` [PATCH 13/16] drm: Move ->get_scanout_position() to struct drm_crtc_funcs Thierry Reding
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

Use unsigned int pipe consistently to denote the CRTC index.

Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/msm/msm_drv.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 7e44511d0951..6efce13acefd 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -118,7 +118,7 @@ u32 msm_readl(const void __iomem *addr)
 
 struct vblank_event {
 	struct list_head node;
-	int crtc_id;
+	unsigned int pipe;
 	bool enable;
 };
 
@@ -139,10 +139,10 @@ static void vblank_ctrl_worker(struct work_struct *work)
 
 		if (vbl_ev->enable)
 			kms->funcs->enable_vblank(kms,
-						priv->crtcs[vbl_ev->crtc_id]);
+						priv->crtcs[vbl_ev->pipe]);
 		else
 			kms->funcs->disable_vblank(kms,
-						priv->crtcs[vbl_ev->crtc_id]);
+						priv->crtcs[vbl_ev->pipe]);
 
 		kfree(vbl_ev);
 
@@ -153,7 +153,7 @@ static void vblank_ctrl_worker(struct work_struct *work)
 }
 
 static int vblank_ctrl_queue_work(struct msm_drm_private *priv,
-					int crtc_id, bool enable)
+				  unsigned int pipe, bool enable)
 {
 	struct msm_vblank_ctrl *vbl_ctrl = &priv->vblank_ctrl;
 	struct vblank_event *vbl_ev;
@@ -163,7 +163,7 @@ static int vblank_ctrl_queue_work(struct msm_drm_private *priv,
 	if (!vbl_ev)
 		return -ENOMEM;
 
-	vbl_ev->crtc_id = crtc_id;
+	vbl_ev->pipe = pipe;
 	vbl_ev->enable = enable;
 
 	spin_lock_irqsave(&vbl_ctrl->lock, flags);
-- 
2.5.0

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

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

* [PATCH 13/16] drm: Move ->get_scanout_position() to struct drm_crtc_funcs
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
                   ` (10 preceding siblings ...)
  2015-09-24 16:35 ` [PATCH 12/16] drm/msm: Use unsigned int pipe consistently Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-24 18:22   ` Daniel Vetter
  2015-09-24 16:35 ` [PATCH 14/16] drm/irq: Add drm_crtc_vblank_count_and_time() Thierry Reding
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Daniel Vetter, Ben Skeggs, Christian König

From: Thierry Reding <treding@nvidia.com>

None of the drivers use this in legacy mode, so it can be converted to
use struct drm_crtc * directly. While at it, also make the sole user of
the callback, drm_calc_vbltimestamp_from_scanoutpos(), pass through the
CRTC directly.

v2: use standard [CRTC:%u] format

Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 13 ++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c     |  1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c     |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h    |  6 ++--
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c      |  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c      |  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c       |  1 +
 drivers/gpu/drm/drm_irq.c                   | 40 ++++++++++---------------
 drivers/gpu/drm/i915/i915_irq.c             | 14 ++++-----
 drivers/gpu/drm/i915/intel_display.c        |  1 +
 drivers/gpu/drm/i915/intel_drv.h            |  4 +++
 drivers/gpu/drm/nouveau/dispnv04/crtc.c     |  1 +
 drivers/gpu/drm/nouveau/nouveau_display.c   | 28 ++++--------------
 drivers/gpu/drm/nouveau/nouveau_display.h   | 12 ++++----
 drivers/gpu/drm/nouveau/nouveau_drm.c       |  1 -
 drivers/gpu/drm/nouveau/nv50_display.c      |  1 +
 drivers/gpu/drm/radeon/radeon_display.c     | 37 ++++++++++++-----------
 drivers/gpu/drm/radeon/radeon_drv.c         |  1 -
 drivers/gpu/drm/radeon/radeon_kms.c         |  2 +-
 drivers/gpu/drm/radeon/radeon_mode.h        |  6 ++--
 drivers/gpu/drm/radeon/radeon_pm.c          |  6 ++--
 include/drm/drmP.h                          | 46 -----------------------------
 include/drm/drm_crtc.h                      | 46 +++++++++++++++++++++++++++++
 23 files changed, 127 insertions(+), 144 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index de116398fa49..ef2a32854fac 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -720,8 +720,7 @@ bool amdgpu_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
  * Retrieve current video scanout position of crtc on a given gpu, and
  * an optional accurate timestamp of when query happened.
  *
- * \param dev Device to query.
- * \param pipe Crtc to query.
+ * \param crtc CRTC to query.
  * \param flags Flags from caller (DRM_CALLED_FROM_VBLIRQ or 0).
  * \param *vpos Location where vertical scanout position should be stored.
  * \param *hpos Location where horizontal scanout position should go.
@@ -744,17 +743,17 @@ bool amdgpu_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
  * unknown small number of scanlines wrt. real scanout position.
  *
  */
-int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
-			       unsigned int flags, int *vpos, int *hpos,
-			       ktime_t *stime, ktime_t *etime,
+int amdgpu_get_crtc_scanoutpos(struct drm_crtc *crtc, unsigned int flags,
+			       int *vpos, int *hpos, ktime_t *stime,
+			       ktime_t *etime,
 			       const struct drm_display_mode *mode)
 {
+	struct amdgpu_device *adev = crtc->dev->dev_private;
+	unsigned int pipe = drm_crtc_index(crtc);
 	u32 vbl = 0, position = 0;
 	int vbl_start, vbl_end, vtotal, ret = 0;
 	bool in_vbl = true;
 
-	struct amdgpu_device *adev = dev->dev_private;
-
 	/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
 
 	/* Get optional system timestamp before query. */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 0fcc0bd1622c..b44f0bd9edfc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -480,7 +480,6 @@ static struct drm_driver kms_driver = {
 	.enable_vblank = amdgpu_enable_vblank_kms,
 	.disable_vblank = amdgpu_disable_vblank_kms,
 	.get_vblank_timestamp = amdgpu_get_vblank_timestamp_kms,
-	.get_scanout_position = amdgpu_get_crtc_scanoutpos,
 #if defined(CONFIG_DEBUG_FS)
 	.debugfs_init = amdgpu_debugfs_init,
 	.debugfs_cleanup = amdgpu_debugfs_cleanup,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 0118fd3cda13..231b7a4c1391 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -679,7 +679,7 @@ int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 	crtc = &adev->mode_info.crtcs[pipe]->base;
 
 	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
+	return drm_calc_vbltimestamp_from_scanoutpos(crtc, max_error,
 						     vblank_time, flags,
 						     &crtc->hwmode);
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index f6b02994442b..4e0c66adfaf8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -540,9 +540,9 @@ bool amdgpu_ddc_probe(struct amdgpu_connector *amdgpu_connector, bool use_aux);
 
 void amdgpu_encoder_set_active_device(struct drm_encoder *encoder);
 
-int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
-			       unsigned int flags, int *vpos, int *hpos,
-			       ktime_t *stime, ktime_t *etime,
+int amdgpu_get_crtc_scanoutpos(struct drm_crtc *crtc, unsigned int flags,
+			       int *vpos, int *hpos, ktime_t *stime,
+			       ktime_t *etime,
 			       const struct drm_display_mode *mode);
 
 int amdgpu_framebuffer_init(struct drm_device *dev,
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index e4d101b1252a..1932f41b610d 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2647,6 +2647,7 @@ static const struct drm_crtc_funcs dce_v10_0_crtc_funcs = {
 	.set_config = amdgpu_crtc_set_config,
 	.destroy = dce_v10_0_crtc_destroy,
 	.page_flip = amdgpu_crtc_page_flip,
+	.get_scanout_position = amdgpu_get_crtc_scanoutpos,
 };
 
 static void dce_v10_0_crtc_dpms(struct drm_crtc *crtc, int mode)
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 6411e8244671..e89bce0aabca 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -2624,6 +2624,7 @@ static const struct drm_crtc_funcs dce_v11_0_crtc_funcs = {
 	.set_config = amdgpu_crtc_set_config,
 	.destroy = dce_v11_0_crtc_destroy,
 	.page_flip = amdgpu_crtc_page_flip,
+	.get_scanout_position = amdgpu_get_crtc_scanoutpos,
 };
 
 static void dce_v11_0_crtc_dpms(struct drm_crtc *crtc, int mode)
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index c86911c2ea2a..f6ab329b2e2f 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -2559,6 +2559,7 @@ static const struct drm_crtc_funcs dce_v8_0_crtc_funcs = {
 	.set_config = amdgpu_crtc_set_config,
 	.destroy = dce_v8_0_crtc_destroy,
 	.page_flip = amdgpu_crtc_page_flip,
+	.get_scanout_position = amdgpu_get_crtc_scanoutpos,
 };
 
 static void dce_v8_0_crtc_dpms(struct drm_crtc *crtc, int mode)
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 4a5dee5cd327..525bd82ab514 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -653,8 +653,7 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
 
 /**
  * drm_calc_vbltimestamp_from_scanoutpos - precise vblank timestamp helper
- * @dev: DRM device
- * @pipe: index of CRTC whose vblank timestamp to retrieve
+ * @crtc: CRTC whose vblank timestamp to retrieve
  * @max_error: Desired maximum allowable error in timestamps (nanosecs)
  *             On return contains true maximum error of timestamp
  * @vblank_time: Pointer to struct timeval which should receive the timestamp
@@ -696,13 +695,13 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * DRM_VBLANKTIME_INVBL - Timestamp taken while scanout was in vblank interval.
  *
  */
-int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-					  unsigned int pipe,
+int drm_calc_vbltimestamp_from_scanoutpos(struct drm_crtc *crtc,
 					  int *max_error,
 					  struct timeval *vblank_time,
 					  unsigned flags,
 					  const struct drm_display_mode *mode)
 {
+	const struct drm_crtc_funcs *funcs = crtc->funcs;
 	struct timeval tv_etime;
 	ktime_t stime, etime;
 	unsigned int vbl_status;
@@ -710,22 +709,16 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 	int vpos, hpos, i;
 	int delta_ns, duration_ns;
 
-	if (pipe >= dev->num_crtcs) {
-		DRM_ERROR("Invalid crtc %u\n", pipe);
-		return -EINVAL;
-	}
-
 	/* Scanout position query not supported? Should not happen. */
-	if (!dev->driver->get_scanout_position) {
-		DRM_ERROR("Called from driver w/o get_scanout_position()!?\n");
-		return -EIO;
-	}
+	if (WARN_ON(funcs->get_scanout_position == NULL))
+		return -ENOSYS;
 
 	/* If mode timing undefined, just return as no-op:
 	 * Happens during initial modesetting of a crtc.
 	 */
 	if (mode->crtc_clock == 0) {
-		DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
+		DRM_DEBUG("[CRTC:%u] Noop due to uninitialized mode.\n",
+			  crtc->base.id);
 		return -EAGAIN;
 	}
 
@@ -741,15 +734,14 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		 * Get vertical and horizontal scanout position vpos, hpos,
 		 * and bounding timestamps stime, etime, pre/post query.
 		 */
-		vbl_status = dev->driver->get_scanout_position(dev, pipe, flags,
-							       &vpos, &hpos,
-							       &stime, &etime,
-							       mode);
+		vbl_status = funcs->get_scanout_position(crtc, flags, &vpos,
+							 &hpos, &stime, &etime,
+							 mode);
 
 		/* Return as no-op if scanout query unsupported or failed. */
 		if (!(vbl_status & DRM_SCANOUTPOS_VALID)) {
-			DRM_DEBUG("crtc %u : scanoutpos query failed [0x%x].\n",
-				  pipe, vbl_status);
+			DRM_DEBUG("[CRTC:%u] scanoutpos query failed [%d].\n",
+				  crtc->base.id, vbl_status);
 			return -EIO;
 		}
 
@@ -763,8 +755,8 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 
 	/* Noisy system timing? */
 	if (i == DRM_TIMESTAMP_MAXRETRIES) {
-		DRM_DEBUG("crtc %u: Noisy timestamp %d us > %d us [%d reps].\n",
-			  pipe, duration_ns/1000, *max_error/1000, i);
+		DRM_DEBUG("[CRTC:%u] Noisy timestamp %d us > %d us [%d reps].\n",
+			  crtc->base.id, duration_ns/1000, *max_error/1000, i);
 	}
 
 	/* Return upper bound of timestamp precision error. */
@@ -799,8 +791,8 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
 		etime = ktime_sub_ns(etime, delta_ns);
 	*vblank_time = ktime_to_timeval(etime);
 
-	DRM_DEBUG("crtc %u : v 0x%x p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n",
-		  pipe, vbl_status, hpos, vpos,
+	DRM_DEBUG("[CRTC:%u] v 0x%x p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n",
+		  crtc->base.id, vbl_status, hpos, vpos,
 		  (long)tv_etime.tv_sec, (long)tv_etime.tv_usec,
 		  (long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
 		  duration_ns/1000, i);
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 7b3aeb0f8056..6eec529b3a5b 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -767,14 +767,15 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
 	return (position + crtc->scanline_offset) % vtotal;
 }
 
-static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
-				    unsigned int flags, int *vpos, int *hpos,
-				    ktime_t *stime, ktime_t *etime,
-				    const struct drm_display_mode *mode)
+int i915_get_crtc_scanoutpos(struct drm_crtc *crtc, unsigned int flags,
+			     int *vpos, int *hpos, ktime_t *stime,
+			     ktime_t *etime,
+			     const struct drm_display_mode *mode)
 {
+	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	enum pipe pipe = intel_crtc->pipe;
 	int position;
 	int vbl_start, vbl_end, hsync_start, htotal, vtotal;
 	bool in_vbl = true;
@@ -929,7 +930,7 @@ static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
 	}
 
 	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
+	return drm_calc_vbltimestamp_from_scanoutpos(crtc, max_error,
 						     vblank_time, flags,
 						     &crtc->hwmode);
 }
@@ -4387,7 +4388,6 @@ void intel_irq_init(struct drm_i915_private *dev_priv)
 		dev->vblank_disable_immediate = true;
 
 	dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp;
-	dev->driver->get_scanout_position = i915_get_crtc_scanoutpos;
 
 	if (IS_CHERRYVIEW(dev_priv)) {
 		dev->driver->irq_handler = cherryview_irq_handler;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 2a1fab3eb285..48965f206fda 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13203,6 +13203,7 @@ static const struct drm_crtc_funcs intel_crtc_funcs = {
 	.page_flip = intel_crtc_page_flip,
 	.atomic_duplicate_state = intel_crtc_duplicate_state,
 	.atomic_destroy_state = intel_crtc_destroy_state,
+	.get_scanout_position = i915_get_crtc_scanoutpos,
 };
 
 static bool ibx_pch_dpll_get_hw_state(struct drm_i915_private *dev_priv,
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index f4242d23f63f..bc86ae28d455 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -955,6 +955,10 @@ static inline bool intel_irqs_enabled(struct drm_i915_private *dev_priv)
 	return dev_priv->pm.irqs_enabled;
 }
 
+int i915_get_crtc_scanoutpos(struct drm_crtc *crtc, unsigned int flags,
+			     int *vpos, int *hpos, ktime_t *stime,
+			     ktime_t *etime,
+			     const struct drm_display_mode *mode);
 int intel_get_crtc_scanline(struct intel_crtc *crtc);
 void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv,
 				     unsigned int pipe_mask);
diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 3d96b49fe662..1a1f9dec1572 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -1089,6 +1089,7 @@ static const struct drm_crtc_funcs nv04_crtc_funcs = {
 	.set_config = nouveau_crtc_set_config,
 	.page_flip = nouveau_crtc_page_flip,
 	.destroy = nv_crtc_destroy,
+	.get_scanout_position = nouveau_display_scanoutpos,
 };
 
 static const struct drm_crtc_helper_funcs nv04_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 886079dd9baa..8bd8421ce63c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -92,8 +92,9 @@ calc(int blanks, int blanke, int total, int line)
 }
 
 int
-nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
-				ktime_t *stime, ktime_t *etime)
+nouveau_display_scanoutpos(struct drm_crtc *crtc, unsigned int flags,
+			   int *vpos, int *hpos, ktime_t *stime,
+			   ktime_t *etime, const struct drm_display_mode *mode)
 {
 	struct {
 		struct nv04_disp_mthd_v0 base;
@@ -132,24 +133,6 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 }
 
 int
-nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
-			   unsigned int flags, int *vpos, int *hpos,
-			   ktime_t *stime, ktime_t *etime,
-			   const struct drm_display_mode *mode)
-{
-	struct drm_crtc *crtc;
-
-	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		if (nouveau_crtc(crtc)->index == pipe) {
-			return nouveau_display_scanoutpos_head(crtc, vpos, hpos,
-							       stime, etime);
-		}
-	}
-
-	return 0;
-}
-
-int
 nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 			 int *max_error, struct timeval *time, unsigned flags)
 {
@@ -157,9 +140,8 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
 
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
 		if (nouveau_crtc(crtc)->index == pipe) {
-			return drm_calc_vbltimestamp_from_scanoutpos(dev,
-					pipe, max_error, time, flags,
-					&crtc->hwmode);
+			return drm_calc_vbltimestamp_from_scanoutpos(crtc,
+					max_error, time, flags, &crtc->hwmode);
 		}
 	}
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h b/drivers/gpu/drm/nouveau/nouveau_display.h
index 856abe0f070d..e8b40117cb04 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.h
+++ b/drivers/gpu/drm/nouveau/nouveau_display.h
@@ -65,12 +65,12 @@ int  nouveau_display_init(struct drm_device *dev);
 void nouveau_display_fini(struct drm_device *dev);
 int  nouveau_display_suspend(struct drm_device *dev, bool runtime);
 void nouveau_display_resume(struct drm_device *dev, bool runtime);
-int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
-void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
-int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
-				unsigned int, int *, int *, ktime_t *,
-				ktime_t *, const struct drm_display_mode *);
-int  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
+int  nouveau_display_vblank_enable(struct drm_device *, unsigned int pipe);
+void nouveau_display_vblank_disable(struct drm_device *, unsigned int pipe);
+int  nouveau_display_scanoutpos(struct drm_crtc *, unsigned int, int *, int *,
+				ktime_t *, ktime_t *,
+				const struct drm_display_mode *);
+int  nouveau_display_vblstamp(struct drm_device *, unsigned int pipe, int *,
 			      struct timeval *, unsigned);
 
 int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index ccefb645fd55..55eac5310449 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -937,7 +937,6 @@ driver_stub = {
 	.get_vblank_counter = drm_vblank_count,
 	.enable_vblank = nouveau_display_vblank_enable,
 	.disable_vblank = nouveau_display_vblank_disable,
-	.get_scanout_position = nouveau_display_scanoutpos,
 	.get_vblank_timestamp = nouveau_display_vblstamp,
 
 	.ioctls = nouveau_ioctls,
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 4ae87aed4505..0cd1826c20e4 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -1423,6 +1423,7 @@ static const struct drm_crtc_funcs nv50_crtc_func = {
 	.set_config = nouveau_crtc_set_config,
 	.destroy = nv50_crtc_destroy,
 	.page_flip = nouveau_crtc_page_flip,
+	.get_scanout_position = nouveau_display_scanoutpos,
 };
 
 static int
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index a58635c5db3d..8dd7ffebef7f 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -322,10 +322,10 @@ void radeon_crtc_handle_vblank(struct radeon_device *rdev, int crtc_id)
 	 * to complete in this vblank?
 	 */
 	if (update_pending &&
-	    (DRM_SCANOUTPOS_VALID & radeon_get_crtc_scanoutpos(rdev->ddev, crtc_id, 0,
+	    (DRM_SCANOUTPOS_VALID & radeon_crtc_get_scanoutpos(&radeon_crtc->base, 0,
 							       &vpos, &hpos, NULL, NULL,
-							       &rdev->mode_info.crtcs[crtc_id]->base.hwmode)) &&
-	    ((vpos >= (99 * rdev->mode_info.crtcs[crtc_id]->base.hwmode.crtc_vdisplay)/100) ||
+							       &radeon_crtc->base.hwmode)) &&
+	    ((vpos >= (99 * radeon_crtc->base.hwmode.crtc_vdisplay)/100) ||
 	     (vpos < 0 && !ASIC_IS_AVIVO(rdev)))) {
 		/* crtc didn't flip in this target vblank interval,
 		 * but flip is pending in crtc. Based on the current
@@ -642,6 +642,7 @@ static const struct drm_crtc_funcs radeon_crtc_funcs = {
 	.set_config = radeon_crtc_set_config,
 	.destroy = radeon_crtc_destroy,
 	.page_flip = radeon_crtc_page_flip,
+	.get_scanout_position = radeon_crtc_get_scanoutpos,
 };
 
 static void radeon_crtc_init(struct drm_device *dev, int index)
@@ -1775,7 +1776,6 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
  * Retrieve current video scanout position of crtc on a given gpu, and
  * an optional accurate timestamp of when query happened.
  *
- * \param dev Device to query.
  * \param crtc Crtc to query.
  * \param flags Flags from caller (DRM_CALLED_FROM_VBLIRQ or 0).
  * \param *vpos Location where vertical scanout position should be stored.
@@ -1799,16 +1799,17 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
  * unknown small number of scanlines wrt. real scanout position.
  *
  */
-int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
-			       unsigned int flags, int *vpos, int *hpos,
-			       ktime_t *stime, ktime_t *etime,
+int radeon_crtc_get_scanoutpos(struct drm_crtc *crtc, unsigned int flags,
+			       int *vpos, int *hpos, ktime_t *stime,
+			       ktime_t *etime,
 			       const struct drm_display_mode *mode)
 {
+	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
 	u32 stat_crtc = 0, vbl = 0, position = 0;
 	int vbl_start, vbl_end, vtotal, ret = 0;
 	bool in_vbl = true;
 
-	struct radeon_device *rdev = dev->dev_private;
+	struct radeon_device *rdev = crtc->dev->dev_private;
 
 	/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
 
@@ -1817,42 +1818,42 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
 		*stime = ktime_get();
 
 	if (ASIC_IS_DCE4(rdev)) {
-		if (pipe == 0) {
+		if (radeon_crtc->crtc_id == 0) {
 			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
 				     EVERGREEN_CRTC0_REGISTER_OFFSET);
 			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
 					  EVERGREEN_CRTC0_REGISTER_OFFSET);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (pipe == 1) {
+		if (radeon_crtc->crtc_id == 1) {
 			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
 				     EVERGREEN_CRTC1_REGISTER_OFFSET);
 			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
 					  EVERGREEN_CRTC1_REGISTER_OFFSET);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (pipe == 2) {
+		if (radeon_crtc->crtc_id == 2) {
 			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
 				     EVERGREEN_CRTC2_REGISTER_OFFSET);
 			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
 					  EVERGREEN_CRTC2_REGISTER_OFFSET);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (pipe == 3) {
+		if (radeon_crtc->crtc_id == 3) {
 			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
 				     EVERGREEN_CRTC3_REGISTER_OFFSET);
 			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
 					  EVERGREEN_CRTC3_REGISTER_OFFSET);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (pipe == 4) {
+		if (radeon_crtc->crtc_id == 4) {
 			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
 				     EVERGREEN_CRTC4_REGISTER_OFFSET);
 			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
 					  EVERGREEN_CRTC4_REGISTER_OFFSET);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (pipe == 5) {
+		if (radeon_crtc->crtc_id == 5) {
 			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
 				     EVERGREEN_CRTC5_REGISTER_OFFSET);
 			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
@@ -1860,19 +1861,19 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
 	} else if (ASIC_IS_AVIVO(rdev)) {
-		if (pipe == 0) {
+		if (radeon_crtc->crtc_id == 0) {
 			vbl = RREG32(AVIVO_D1CRTC_V_BLANK_START_END);
 			position = RREG32(AVIVO_D1CRTC_STATUS_POSITION);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (pipe == 1) {
+		if (radeon_crtc->crtc_id == 1) {
 			vbl = RREG32(AVIVO_D2CRTC_V_BLANK_START_END);
 			position = RREG32(AVIVO_D2CRTC_STATUS_POSITION);
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
 	} else {
 		/* Pre-AVIVO: Different encoding of scanout pos and vblank interval. */
-		if (pipe == 0) {
+		if (radeon_crtc->crtc_id == 0) {
 			/* Assume vbl_end == 0, get vbl_start from
 			 * upper 16 bits.
 			 */
@@ -1886,7 +1887,7 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
 
 			ret |= DRM_SCANOUTPOS_VALID;
 		}
-		if (pipe == 1) {
+		if (radeon_crtc->crtc_id == 1) {
 			vbl = (RREG32(RADEON_CRTC2_V_TOTAL_DISP) &
 				RADEON_CRTC_V_DISP) >> RADEON_CRTC_V_DISP_SHIFT;
 			position = (RREG32(RADEON_CRTC2_VLINE_CRNT_VLINE) >> 16) & RADEON_CRTC_V_TOTAL;
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 5b6a6f5b3619..30ef157f02b5 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -578,7 +578,6 @@ static struct drm_driver kms_driver = {
 	.enable_vblank = radeon_enable_vblank_kms,
 	.disable_vblank = radeon_disable_vblank_kms,
 	.get_vblank_timestamp = radeon_get_vblank_timestamp_kms,
-	.get_scanout_position = radeon_get_crtc_scanoutpos,
 #if defined(CONFIG_DEBUG_FS)
 	.debugfs_init = radeon_debugfs_init,
 	.debugfs_cleanup = radeon_debugfs_cleanup,
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index fd9da282b29c..f3bcf925c3ba 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -839,7 +839,7 @@ int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
 		return -EINVAL;
 
 	/* Helper routine in DRM core does all the work: */
-	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
+	return drm_calc_vbltimestamp_from_scanoutpos(drmcrtc, max_error,
 						     vblank_time, flags,
 						     &drmcrtc->hwmode);
 }
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index de18f0668bea..4e11f1e40cef 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -874,9 +874,9 @@ extern int radeon_crtc_cursor_move(struct drm_crtc *crtc,
 				   int x, int y);
 extern void radeon_cursor_reset(struct drm_crtc *crtc);
 
-extern int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
-				      unsigned int flags, int *vpos, int *hpos,
-				      ktime_t *stime, ktime_t *etime,
+extern int radeon_crtc_get_scanoutpos(struct drm_crtc *crtc, unsigned int flags,
+				      int *vpos, int *hpos, ktime_t *stime,
+				      ktime_t *etime,
 				      const struct drm_display_mode *mode);
 
 extern bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev);
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index 10f4c12e439e..dc4c29938cd1 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -1732,10 +1732,12 @@ static bool radeon_pm_in_vbl(struct radeon_device *rdev)
 	 * otherwise return in_vbl == false.
 	 */
 	for (crtc = 0; (crtc < rdev->num_crtc) && in_vbl; crtc++) {
+		struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc];
+
 		if (rdev->pm.active_crtcs & (1 << crtc)) {
-			vbl_status = radeon_get_crtc_scanoutpos(rdev->ddev, crtc, 0,
+			vbl_status = radeon_crtc_get_scanoutpos(&radeon_crtc->base, 0,
 								&vpos, &hpos, NULL, NULL,
-								&rdev->mode_info.crtcs[crtc]->base.hwmode);
+								&radeon_crtc->base.hwmode);
 			if ((vbl_status & DRM_SCANOUTPOS_VALID) &&
 			    !(vbl_status & DRM_SCANOUTPOS_IN_VBLANK))
 				in_vbl = false;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index a013a0ed8e6a..ce693a1366c1 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -384,11 +384,6 @@ struct drm_master {
 #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
 #define DRM_VBLANKTIME_IN_VBLANK         (1 << 1)
 
-/* get_scanout_position() return flags */
-#define DRM_SCANOUTPOS_VALID        (1 << 0)
-#define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
-#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
-
 /**
  * DRM driver structure. This structure represent the common code for
  * a family of cards. There will one drm_device for each card present
@@ -468,42 +463,6 @@ struct drm_driver {
 	int (*device_is_agp) (struct drm_device *dev);
 
 	/**
-	 * Called by vblank timestamping code.
-	 *
-	 * Return the current display scanout position from a crtc, and an
-	 * optional accurate ktime_get timestamp of when position was measured.
-	 *
-	 * \param dev  DRM device.
-	 * \param pipe Id of the crtc to query.
-	 * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
-	 * \param *vpos Target location for current vertical scanout position.
-	 * \param *hpos Target location for current horizontal scanout position.
-	 * \param *stime Target location for timestamp taken immediately before
-	 *               scanout position query. Can be NULL to skip timestamp.
-	 * \param *etime Target location for timestamp taken immediately after
-	 *               scanout position query. Can be NULL to skip timestamp.
-	 * \param mode Current display timings.
-	 *
-	 * Returns vpos as a positive number while in active scanout area.
-	 * Returns vpos as a negative number inside vblank, counting the number
-	 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
-	 * until start of active scanout / end of vblank."
-	 *
-	 * \return Flags, or'ed together as follows:
-	 *
-	 * DRM_SCANOUTPOS_VALID = Query successful.
-	 * DRM_SCANOUTPOS_INVBL = Inside vblank.
-	 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
-	 * this flag means that returned position may be offset by a constant
-	 * but unknown small number of scanlines wrt. real scanout position.
-	 *
-	 */
-	int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
-				     unsigned int flags, int *vpos, int *hpos,
-				     ktime_t *stime, ktime_t *etime,
-				     const struct drm_display_mode *mode);
-
-	/**
 	 * Called by \c drm_get_last_vbltimestamp. Should return a precise
 	 * timestamp when the most recent VBLANK interval ended or will end.
 	 *
@@ -949,11 +908,6 @@ extern void drm_crtc_vblank_reset(struct drm_crtc *crtc);
 extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
 extern void drm_vblank_cleanup(struct drm_device *dev);
 
-extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-						 unsigned int pipe, int *max_error,
-						 struct timeval *vblank_time,
-						 unsigned flags,
-						 const struct drm_display_mode *mode);
 extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 					    const struct drm_display_mode *mode);
 
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 683f1421a825..c5c9e316251a 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -307,6 +307,11 @@ struct drm_crtc_state {
 	struct drm_atomic_state *state;
 };
 
+/* get_scanout_position() return flags */
+#define DRM_SCANOUTPOS_VALID        (1 << 0)
+#define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
+#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
+
 /**
  * struct drm_crtc_funcs - control CRTCs for a given device
  * @save: save CRTC state
@@ -326,6 +331,7 @@ struct drm_crtc_state {
  *    (do not call directly, use drm_atomic_crtc_set_property())
  * @atomic_get_property: get a property on an atomic state for this CRTC
  *    (do not call directly, use drm_atomic_crtc_get_property())
+ * @get_scanout_position: return the current scanout position
  *
  * The drm_crtc_funcs structure is the central CRTC management structure
  * in the DRM.  Each CRTC controls one or more connectors (note that the name
@@ -389,6 +395,40 @@ struct drm_crtc_funcs {
 				   const struct drm_crtc_state *state,
 				   struct drm_property *property,
 				   uint64_t *val);
+
+	/**
+	 * Called by vblank timestamping code.
+	 *
+	 * Return the current display scanout position from a crtc, and an
+	 * optional accurate ktime_get timestamp of when position was measured.
+	 *
+	 * \param crtc CRTC to query.
+	 * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
+	 * \param *vpos Target location for current vertical scanout position.
+	 * \param *hpos Target location for current horizontal scanout position.
+	 * \param *stime Target location for timestamp taken immediately before
+	 *               scanout position query. Can be NULL to skip timestamp.
+	 * \param *etime Target location for timestamp taken immediately after
+	 *               scanout position query. Can be NULL to skip timestamp.
+	 * \param mode Current display timings.
+	 *
+	 * Returns vpos as a positive number while in active scanout area.
+	 * Returns vpos as a negative number inside vblank, counting the number
+	 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
+	 * until start of active scanout / end of vblank."
+	 *
+	 * \return Flags, or'ed together as follows:
+	 *
+	 * DRM_SCANOUTPOS_VALID = Query successful.
+	 * DRM_SCANOUTPOS_INVBL = Inside vblank.
+	 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
+	 * this flag means that returned position may be offset by a constant
+	 * but unknown small number of scanlines wrt. real scanout position.
+	 */
+	int (*get_scanout_position)(struct drm_crtc *crtc, unsigned int flags,
+				    int *vpos, int *hpos, ktime_t *stime,
+				    ktime_t *etime,
+				    const struct drm_display_mode *mode);
 };
 
 /**
@@ -1194,6 +1234,12 @@ extern int drm_crtc_init_with_planes(struct drm_device *dev,
 extern void drm_crtc_cleanup(struct drm_crtc *crtc);
 extern unsigned int drm_crtc_index(struct drm_crtc *crtc);
 
+extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_crtc *crtc,
+						 int *max_error,
+						 struct timeval *vblank_time,
+						 unsigned flags,
+						 const struct drm_display_mode *mode);
+
 /**
  * drm_crtc_mask - find the mask of a registered CRTC
  * @crtc: CRTC to find mask for
-- 
2.5.0

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

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

* [PATCH 14/16] drm/irq: Add drm_crtc_vblank_count_and_time()
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
                   ` (11 preceding siblings ...)
  2015-09-24 16:35 ` [PATCH 13/16] drm: Move ->get_scanout_position() to struct drm_crtc_funcs Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-24 18:27   ` Daniel Vetter
  2015-09-24 16:35 ` [PATCH 15/16] drm/armada: Use drm_crtc_vblank_*() API Thierry Reding
  2015-09-24 16:35 ` [PATCH 16/16] drm/sti: " Thierry Reding
  14 siblings, 1 reply; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

This function is the KMS native variant of drm_vblank_count_and_time().
It takes a struct drm_crtc * instead of a struct drm_device * and an
index of the CRTC.

Eventually the goal is to access vblank data through the CRTC only so
that the per-CRTC data can be moved to struct drm_crtc.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/drm_irq.c | 23 +++++++++++++++++++++++
 include/drm/drmP.h        |  2 ++
 2 files changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 525bd82ab514..d81e3724cca3 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -909,6 +909,8 @@ EXPORT_SYMBOL(drm_crtc_vblank_count);
  * vblank events since the system was booted, including lost events due to
  * modesetting activity. Returns corresponding system timestamp of the time
  * of the vblank interval that corresponds to the current vblank counter value.
+ *
+ * This is the legacy version of drm_crtc_vblank_count_and_time().
  */
 u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
 			      struct timeval *vblanktime)
@@ -936,6 +938,27 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
 }
 EXPORT_SYMBOL(drm_vblank_count_and_time);
 
+/**
+ * drm_crtc_vblank_count_and_time - retrieve "cooked" vblank counter value
+ *     and the system timestamp corresponding to that vblank counter value
+ * @crtc: which counter to retrieve
+ * @vblanktime: Pointer to struct timeval to receive the vblank timestamp.
+ *
+ * Fetches the "cooked" vblank count value that represents the number of
+ * vblank events since the system was booted, including lost events due to
+ * modesetting activity. Returns corresponding system timestamp of the time
+ * of the vblank interval that corresponds to the current vblank counter value.
+ *
+ * This is the native KMS version of drm_vblank_count_and_time().
+ */
+u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
+				   struct timeval *vblanktime)
+{
+	return drm_vblank_count_and_time(crtc->dev, drm_crtc_index(crtc),
+					 vblanktime);
+}
+EXPORT_SYMBOL(drm_crtc_vblank_count_and_time);
+
 static void send_vblank_event(struct drm_device *dev,
 		struct drm_pending_vblank_event *e,
 		unsigned long seq, struct timeval *now)
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index ce693a1366c1..53960444a423 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -889,6 +889,8 @@ extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
 extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
 extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
 				     struct timeval *vblanktime);
+extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
+					  struct timeval *vblanktime);
 extern void drm_send_vblank_event(struct drm_device *dev, unsigned int pipe,
 				  struct drm_pending_vblank_event *e);
 extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
-- 
2.5.0

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

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

* [PATCH 15/16] drm/armada: Use drm_crtc_vblank_*() API
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
                   ` (12 preceding siblings ...)
  2015-09-24 16:35 ` [PATCH 14/16] drm/irq: Add drm_crtc_vblank_count_and_time() Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-09-24 16:35 ` [PATCH 16/16] drm/sti: " Thierry Reding
  14 siblings, 0 replies; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel; +Cc: Russell King

From: Thierry Reding <treding@nvidia.com>

Non-legacy drivers should only use this API to allow per-CRTC data to be
eventually moved into struct drm_crtc.

Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/armada/armada_crtc.c | 17 ++++++++---------
 drivers/gpu/drm/armada/armada_drv.c  |  4 ++--
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 01ffe9bffe38..f15efaaff572 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -180,7 +180,7 @@ static int armada_drm_crtc_queue_frame_work(struct armada_crtc *dcrtc,
 	unsigned long flags;
 	int ret;
 
-	ret = drm_vblank_get(dev, dcrtc->num);
+	ret = drm_crtc_vblank_get(&dcrtc->crtc);
 	if (ret) {
 		DRM_ERROR("failed to acquire vblank counter\n");
 		return ret;
@@ -194,14 +194,13 @@ static int armada_drm_crtc_queue_frame_work(struct armada_crtc *dcrtc,
 	spin_unlock_irqrestore(&dev->event_lock, flags);
 
 	if (ret)
-		drm_vblank_put(dev, dcrtc->num);
+		drm_crtc_vblank_put(&dcrtc->crtc);
 
 	return ret;
 }
 
 static void armada_drm_crtc_complete_frame_work(struct armada_crtc *dcrtc)
 {
-	struct drm_device *dev = dcrtc->crtc.dev;
 	struct armada_frame_work *work = dcrtc->frame_work;
 
 	dcrtc->frame_work = NULL;
@@ -209,9 +208,9 @@ static void armada_drm_crtc_complete_frame_work(struct armada_crtc *dcrtc)
 	armada_drm_crtc_update_regs(dcrtc, work->regs);
 
 	if (work->event)
-		drm_send_vblank_event(dev, dcrtc->num, work->event);
+		drm_crtc_send_vblank_event(&dcrtc->crtc, work->event);
 
-	drm_vblank_put(dev, dcrtc->num);
+	drm_crtc_vblank_put(&dcrtc->crtc);
 
 	/* Finally, queue the process-half of the cleanup. */
 	__armada_drm_queue_unref_work(dcrtc->crtc.dev, work->old_fb);
@@ -365,13 +364,13 @@ static void armada_drm_crtc_irq(struct armada_crtc *dcrtc, u32 stat)
 		DRM_ERROR("graphics underflow on crtc %u\n", dcrtc->num);
 
 	if (stat & VSYNC_IRQ)
-		drm_handle_vblank(dcrtc->crtc.dev, dcrtc->num);
+		drm_crtc_handle_vblank(&dcrtc->crtc);
 
 	spin_lock(&dcrtc->irq_lock);
 
 	list_for_each_entry_safe(e, n, &dcrtc->vbl_list, node) {
 		list_del_init(&e->node);
-		drm_vblank_put(dcrtc->crtc.dev, dcrtc->num);
+		drm_crtc_vblank_put(&dcrtc->crtc);
 		e->fn(dcrtc, e->data);
 	}
 
@@ -546,9 +545,9 @@ static int armada_drm_crtc_mode_set(struct drm_crtc *crtc,
 
 	if (interlaced ^ dcrtc->interlaced) {
 		if (adj->flags & DRM_MODE_FLAG_INTERLACE)
-			drm_vblank_get(dcrtc->crtc.dev, dcrtc->num);
+			drm_crtc_vblank_get(&dcrtc->crtc);
 		else
-			drm_vblank_put(dcrtc->crtc.dev, dcrtc->num);
+			drm_crtc_vblank_put(&dcrtc->crtc);
 		dcrtc->interlaced = interlaced;
 	}
 
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index a438886fcdb6..01a861e3f605 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -239,7 +239,7 @@ void armada_drm_vbl_event_add(struct armada_crtc *dcrtc,
 	if (list_empty(&evt->node)) {
 		list_add_tail(&evt->node, &dcrtc->vbl_list);
 
-		drm_vblank_get(dcrtc->crtc.dev, dcrtc->num);
+		drm_crtc_vblank_get(&dcrtc->crtc);
 	}
 	spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
 }
@@ -249,7 +249,7 @@ void armada_drm_vbl_event_remove(struct armada_crtc *dcrtc,
 {
 	if (!list_empty(&evt->node)) {
 		list_del_init(&evt->node);
-		drm_vblank_put(dcrtc->crtc.dev, dcrtc->num);
+		drm_crtc_vblank_put(&dcrtc->crtc);
 	}
 }
 
-- 
2.5.0

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

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

* [PATCH 16/16] drm/sti: Use drm_crtc_vblank_*() API
  2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
                   ` (13 preceding siblings ...)
  2015-09-24 16:35 ` [PATCH 15/16] drm/armada: Use drm_crtc_vblank_*() API Thierry Reding
@ 2015-09-24 16:35 ` Thierry Reding
  2015-10-01 14:49   ` Vincent ABRIOU
  14 siblings, 1 reply; 28+ messages in thread
From: Thierry Reding @ 2015-09-24 16:35 UTC (permalink / raw)
  To: dri-devel; +Cc: Benjamin Gaignard

From: Thierry Reding <treding@nvidia.com>

Non-legacy drivers should only use this API to allow per-CRTC data to be
eventually moved into struct drm_crtc.

Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Vincent Abriou <vincent.abriou@st.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/sti/sti_crtc.c  | 37 ++++++++++++++++++++-----------------
 drivers/gpu/drm/sti/sti_gdp.c   |  2 +-
 drivers/gpu/drm/sti/sti_hqvdp.c |  2 +-
 drivers/gpu/drm/sti/sti_vtg.c   | 14 +++++++-------
 drivers/gpu/drm/sti/sti_vtg.h   |  4 ++--
 5 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
index c6fb8dee11de..87bb4096b9d7 100644
--- a/drivers/gpu/drm/sti/sti_crtc.c
+++ b/drivers/gpu/drm/sti/sti_crtc.c
@@ -254,15 +254,17 @@ static int sti_crtc_set_property(struct drm_crtc *crtc,
 int sti_crtc_vblank_cb(struct notifier_block *nb,
 		       unsigned long event, void *data)
 {
-	struct drm_device *drm_dev;
 	struct sti_compositor *compo =
 		container_of(nb, struct sti_compositor, vtg_vblank_nb);
-	int *crtc = data;
+	struct drm_crtc *crtc = data;
+	struct sti_mixer *mixer;
 	unsigned long flags;
 	struct sti_private *priv;
+	unsigned int pipe;
 
-	drm_dev = compo->mixer[*crtc]->drm_crtc.dev;
-	priv = drm_dev->dev_private;
+	priv = crtc->dev->dev_private;
+	pipe = drm_crtc_index(crtc);
+	mixer = compo->mixer[pipe];
 
 	if ((event != VTG_TOP_FIELD_EVENT) &&
 	    (event != VTG_BOTTOM_FIELD_EVENT)) {
@@ -270,30 +272,29 @@ int sti_crtc_vblank_cb(struct notifier_block *nb,
 		return -EINVAL;
 	}
 
-	drm_handle_vblank(drm_dev, *crtc);
+	drm_crtc_handle_vblank(crtc);
 
-	spin_lock_irqsave(&drm_dev->event_lock, flags);
-	if (compo->mixer[*crtc]->pending_event) {
-		drm_send_vblank_event(drm_dev, *crtc,
-				      compo->mixer[*crtc]->pending_event);
-		drm_vblank_put(drm_dev, *crtc);
-		compo->mixer[*crtc]->pending_event = NULL;
+	spin_lock_irqsave(&crtc->dev->event_lock, flags);
+	if (mixer->pending_event) {
+		drm_crtc_send_vblank_event(crtc, mixer->pending_event);
+		drm_crtc_vblank_put(crtc);
+		mixer->pending_event = NULL;
 	}
-	spin_unlock_irqrestore(&drm_dev->event_lock, flags);
+	spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
 
-	if (compo->mixer[*crtc]->status == STI_MIXER_DISABLING) {
+	if (mixer->status == STI_MIXER_DISABLING) {
 		struct drm_plane *p;
 
 		/* Disable mixer only if all overlay planes (GDP and VDP)
 		 * are disabled */
-		list_for_each_entry(p, &drm_dev->mode_config.plane_list, head) {
+		list_for_each_entry(p, &crtc->dev->mode_config.plane_list, head) {
 			struct sti_plane *plane = to_sti_plane(p);
 
 			if ((plane->desc & STI_PLANE_TYPE_MASK) <= STI_VDP)
 				if (plane->status != STI_PLANE_DISABLED)
 					return 0;
 		}
-		sti_crtc_disable(&compo->mixer[*crtc]->drm_crtc);
+		sti_crtc_disable(crtc);
 	}
 
 	return 0;
@@ -304,12 +305,13 @@ int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
 	struct sti_private *dev_priv = dev->dev_private;
 	struct sti_compositor *compo = dev_priv->compo;
 	struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb;
+	struct drm_crtc *crtc = &compo->mixer[pipe]->drm_crtc;
 
 	DRM_DEBUG_DRIVER("\n");
 
 	if (sti_vtg_register_client(pipe == STI_MIXER_MAIN ?
 			compo->vtg_main : compo->vtg_aux,
-			vtg_vblank_nb, pipe)) {
+			vtg_vblank_nb, crtc)) {
 		DRM_ERROR("Cannot register VTG notifier\n");
 		return -EINVAL;
 	}
@@ -323,6 +325,7 @@ void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe)
 	struct sti_private *priv = drm_dev->dev_private;
 	struct sti_compositor *compo = priv->compo;
 	struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb;
+	struct drm_crtc *crtc = &compo->mixer[pipe]->drm_crtc;
 
 	DRM_DEBUG_DRIVER("\n");
 
@@ -332,7 +335,7 @@ void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe)
 
 	/* free the resources of the pending requests */
 	if (compo->mixer[pipe]->pending_event) {
-		drm_vblank_put(drm_dev, pipe);
+		drm_crtc_vblank_put(crtc);
 		compo->mixer[pipe]->pending_event = NULL;
 	}
 }
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
index 9365670427ad..c85dc7d6b005 100644
--- a/drivers/gpu/drm/sti/sti_gdp.c
+++ b/drivers/gpu/drm/sti/sti_gdp.c
@@ -492,7 +492,7 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
 		/* Register gdp callback */
 		if (sti_vtg_register_client(mixer->id == STI_MIXER_MAIN ?
 				compo->vtg_main : compo->vtg_aux,
-				&gdp->vtg_field_nb, mixer->id)) {
+				&gdp->vtg_field_nb, crtc)) {
 			DRM_ERROR("Cannot register VTG notifier\n");
 			return;
 		}
diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
index 7c8f9b8bfae1..09d86be4f73f 100644
--- a/drivers/gpu/drm/sti/sti_hqvdp.c
+++ b/drivers/gpu/drm/sti/sti_hqvdp.c
@@ -763,7 +763,7 @@ static void sti_hqvdp_atomic_update(struct drm_plane *drm_plane,
 		/* Register VTG Vsync callback to handle bottom fields */
 		if (sti_vtg_register_client(hqvdp->vtg,
 					    &hqvdp->vtg_nb,
-					    mixer->id)) {
+					    crtc)) {
 			DRM_ERROR("Cannot register VTG notifier\n");
 			return;
 		}
diff --git a/drivers/gpu/drm/sti/sti_vtg.c b/drivers/gpu/drm/sti/sti_vtg.c
index aa8097137701..4d8a918db6f5 100644
--- a/drivers/gpu/drm/sti/sti_vtg.c
+++ b/drivers/gpu/drm/sti/sti_vtg.c
@@ -79,7 +79,7 @@ LIST_HEAD(vtg_lookup);
  * @irq: VTG irq
  * @type: VTG type (main or aux)
  * @notifier_list: notifier callback
- * @crtc_id: the crtc id for vblank event
+ * @crtc: the CRTC for vblank event
  * @slave: slave vtg
  * @link: List node to link the structure in lookup list
  */
@@ -90,7 +90,7 @@ struct sti_vtg {
 	int irq;
 	u32 irq_status;
 	struct raw_notifier_head notifier_list;
-	int crtc_id;
+	struct drm_crtc *crtc;
 	struct sti_vtg *slave;
 	struct list_head link;
 };
@@ -283,13 +283,13 @@ u32 sti_vtg_get_pixel_number(struct drm_display_mode mode, int x)
 }
 EXPORT_SYMBOL(sti_vtg_get_pixel_number);
 
-int sti_vtg_register_client(struct sti_vtg *vtg,
-		struct notifier_block *nb, int crtc_id)
+int sti_vtg_register_client(struct sti_vtg *vtg, struct notifier_block *nb,
+			    struct drm_crtc *crtc)
 {
 	if (vtg->slave)
-		return sti_vtg_register_client(vtg->slave, nb, crtc_id);
+		return sti_vtg_register_client(vtg->slave, nb, crtc);
 
-	vtg->crtc_id = crtc_id;
+	vtg->crtc = crtc;
 	return raw_notifier_chain_register(&vtg->notifier_list, nb);
 }
 EXPORT_SYMBOL(sti_vtg_register_client);
@@ -311,7 +311,7 @@ static irqreturn_t vtg_irq_thread(int irq, void *arg)
 	event = (vtg->irq_status & VTG_IRQ_TOP) ?
 		VTG_TOP_FIELD_EVENT : VTG_BOTTOM_FIELD_EVENT;
 
-	raw_notifier_call_chain(&vtg->notifier_list, event, &vtg->crtc_id);
+	raw_notifier_call_chain(&vtg->notifier_list, event, vtg->crtc);
 
 	return IRQ_HANDLED;
 }
diff --git a/drivers/gpu/drm/sti/sti_vtg.h b/drivers/gpu/drm/sti/sti_vtg.h
index e84d23f1f57f..cd2439f89d05 100644
--- a/drivers/gpu/drm/sti/sti_vtg.h
+++ b/drivers/gpu/drm/sti/sti_vtg.h
@@ -17,8 +17,8 @@ struct notifier_block;
 struct sti_vtg *of_vtg_find(struct device_node *np);
 void sti_vtg_set_config(struct sti_vtg *vtg,
 		const struct drm_display_mode *mode);
-int sti_vtg_register_client(struct sti_vtg *vtg,
-		struct notifier_block *nb, int crtc_id);
+int sti_vtg_register_client(struct sti_vtg *vtg, struct notifier_block *nb,
+			    struct drm_crtc *crtc);
 int sti_vtg_unregister_client(struct sti_vtg *vtg,
 		struct notifier_block *nb);
 
-- 
2.5.0

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

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

* Re: [PATCH 08/16] drm/irq: Rename drm_crtc -> crtc
  2015-09-24 16:35 ` [PATCH 08/16] drm/irq: Rename drm_crtc -> crtc Thierry Reding
@ 2015-09-24 18:17   ` Daniel Vetter
  0 siblings, 0 replies; 28+ messages in thread
From: Daniel Vetter @ 2015-09-24 18:17 UTC (permalink / raw)
  To: Thierry Reding; +Cc: dri-devel

On Thu, Sep 24, 2015 at 06:35:30PM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Since the original crtc parameter was renamed to pipe, there is no
> longer a need to artificially prefix the CRTC parameter.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>

Applied to drm-misc, thanks.
-Daniel

> ---
>  drivers/gpu/drm/drm_irq.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 88fbee4cf4b7..29a6dcd674f8 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -1280,7 +1280,7 @@ EXPORT_SYMBOL(drm_crtc_vblank_off);
>  
>  /**
>   * drm_crtc_vblank_reset - reset vblank state to off on a CRTC
> - * @drm_crtc: CRTC in question
> + * @crtc: CRTC in question
>   *
>   * Drivers can use this function to reset the vblank state to off at load time.
>   * Drivers should use this together with the drm_crtc_vblank_off() and
> @@ -1288,11 +1288,11 @@ EXPORT_SYMBOL(drm_crtc_vblank_off);
>   * drm_crtc_vblank_off() is that this function doesn't save the vblank counter
>   * and hence doesn't need to call any driver hooks.
>   */
> -void drm_crtc_vblank_reset(struct drm_crtc *drm_crtc)
> +void drm_crtc_vblank_reset(struct drm_crtc *crtc)
>  {
> -	struct drm_device *dev = drm_crtc->dev;
> +	struct drm_device *dev = crtc->dev;
>  	unsigned long irqflags;
> -	unsigned int pipe = drm_crtc_index(drm_crtc);
> +	unsigned int pipe = drm_crtc_index(crtc);
>  	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
>  
>  	spin_lock_irqsave(&dev->vbl_lock, irqflags);
> -- 
> 2.5.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 13/16] drm: Move ->get_scanout_position() to struct drm_crtc_funcs
  2015-09-24 16:35 ` [PATCH 13/16] drm: Move ->get_scanout_position() to struct drm_crtc_funcs Thierry Reding
@ 2015-09-24 18:22   ` Daniel Vetter
  0 siblings, 0 replies; 28+ messages in thread
From: Daniel Vetter @ 2015-09-24 18:22 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Alex Deucher, Daniel Vetter, Ben Skeggs, dri-devel, Christian König

On Thu, Sep 24, 2015 at 06:35:35PM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> None of the drivers use this in legacy mode, so it can be converted to
> use struct drm_crtc * directly. While at it, also make the sole user of
> the callback, drm_calc_vbltimestamp_from_scanoutpos(), pass through the
> CRTC directly.
> 
> v2: use standard [CRTC:%u] format

I very much like this as a first small step towards untangling drm_irq.c.
Two comments below.

> 
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>


> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 4a5dee5cd327..525bd82ab514 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -653,8 +653,7 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
>  
>  /**
>   * drm_calc_vbltimestamp_from_scanoutpos - precise vblank timestamp helper
> - * @dev: DRM device
> - * @pipe: index of CRTC whose vblank timestamp to retrieve
> + * @crtc: CRTC whose vblank timestamp to retrieve
>   * @max_error: Desired maximum allowable error in timestamps (nanosecs)
>   *             On return contains true maximum error of timestamp
>   * @vblank_time: Pointer to struct timeval which should receive the timestamp
> @@ -696,13 +695,13 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
>   * DRM_VBLANKTIME_INVBL - Timestamp taken while scanout was in vblank interval.
>   *
>   */
> -int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
> -					  unsigned int pipe,
> +int drm_calc_vbltimestamp_from_scanoutpos(struct drm_crtc *crtc,
>  					  int *max_error,
>  					  struct timeval *vblank_time,
>  					  unsigned flags,
>  					  const struct drm_display_mode *mode)

This function is actually more a helper, since if you use some hardware
vblank timestamp register you don't really need it at all. Hence I think
we should fix this properly and instead move this function into a new
drm_irq_helper.c (part of drm_kms_helper.ko) - there will be more once
drm_irq.c is untangled. And also push the callback into the corresponding
helper funcs sturctures.

>  {
> +	const struct drm_crtc_funcs *funcs = crtc->funcs;
>  	struct timeval tv_etime;
>  	ktime_t stime, etime;
>  	unsigned int vbl_status;
> @@ -710,22 +709,16 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
>  	int vpos, hpos, i;
>  	int delta_ns, duration_ns;
>  
> -	if (pipe >= dev->num_crtcs) {
> -		DRM_ERROR("Invalid crtc %u\n", pipe);
> -		return -EINVAL;
> -	}
> -
>  	/* Scanout position query not supported? Should not happen. */
> -	if (!dev->driver->get_scanout_position) {
> -		DRM_ERROR("Called from driver w/o get_scanout_position()!?\n");
> -		return -EIO;
> -	}
> +	if (WARN_ON(funcs->get_scanout_position == NULL))
> +		return -ENOSYS;
>  
>  	/* If mode timing undefined, just return as no-op:
>  	 * Happens during initial modesetting of a crtc.
>  	 */
>  	if (mode->crtc_clock == 0) {
> -		DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
> +		DRM_DEBUG("[CRTC:%u] Noop due to uninitialized mode.\n",
> +			  crtc->base.id);
>  		return -EAGAIN;
>  	}
>  
> @@ -741,15 +734,14 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
>  		 * Get vertical and horizontal scanout position vpos, hpos,
>  		 * and bounding timestamps stime, etime, pre/post query.
>  		 */
> -		vbl_status = dev->driver->get_scanout_position(dev, pipe, flags,
> -							       &vpos, &hpos,
> -							       &stime, &etime,
> -							       mode);
> +		vbl_status = funcs->get_scanout_position(crtc, flags, &vpos,
> +							 &hpos, &stime, &etime,
> +							 mode);
>  
>  		/* Return as no-op if scanout query unsupported or failed. */
>  		if (!(vbl_status & DRM_SCANOUTPOS_VALID)) {
> -			DRM_DEBUG("crtc %u : scanoutpos query failed [0x%x].\n",
> -				  pipe, vbl_status);
> +			DRM_DEBUG("[CRTC:%u] scanoutpos query failed [%d].\n",
> +				  crtc->base.id, vbl_status);
>  			return -EIO;
>  		}
>  
> @@ -763,8 +755,8 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
>  
>  	/* Noisy system timing? */
>  	if (i == DRM_TIMESTAMP_MAXRETRIES) {
> -		DRM_DEBUG("crtc %u: Noisy timestamp %d us > %d us [%d reps].\n",
> -			  pipe, duration_ns/1000, *max_error/1000, i);
> +		DRM_DEBUG("[CRTC:%u] Noisy timestamp %d us > %d us [%d reps].\n",
> +			  crtc->base.id, duration_ns/1000, *max_error/1000, i);
>  	}
>  
>  	/* Return upper bound of timestamp precision error. */
> @@ -799,8 +791,8 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
>  		etime = ktime_sub_ns(etime, delta_ns);
>  	*vblank_time = ktime_to_timeval(etime);
>  
> -	DRM_DEBUG("crtc %u : v 0x%x p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n",
> -		  pipe, vbl_status, hpos, vpos,
> +	DRM_DEBUG("[CRTC:%u] v 0x%x p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n",
> +		  crtc->base.id, vbl_status, hpos, vpos,
>  		  (long)tv_etime.tv_sec, (long)tv_etime.tv_usec,
>  		  (long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
>  		  duration_ns/1000, i);
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 7b3aeb0f8056..6eec529b3a5b 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -767,14 +767,15 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
>  	return (position + crtc->scanline_offset) % vtotal;
>  }
>  
> -static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
> -				    unsigned int flags, int *vpos, int *hpos,
> -				    ktime_t *stime, ktime_t *etime,
> -				    const struct drm_display_mode *mode)
> +int i915_get_crtc_scanoutpos(struct drm_crtc *crtc, unsigned int flags,
> +			     int *vpos, int *hpos, ktime_t *stime,
> +			     ktime_t *etime,
> +			     const struct drm_display_mode *mode)
>  {
> +	struct drm_device *dev = crtc->dev;
>  	struct drm_i915_private *dev_priv = dev->dev_private;
> -	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> +	enum pipe pipe = intel_crtc->pipe;
>  	int position;
>  	int vbl_start, vbl_end, hsync_start, htotal, vtotal;
>  	bool in_vbl = true;
> @@ -929,7 +930,7 @@ static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
>  	}
>  
>  	/* Helper routine in DRM core does all the work: */
> -	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
> +	return drm_calc_vbltimestamp_from_scanoutpos(crtc, max_error,
>  						     vblank_time, flags,
>  						     &crtc->hwmode);
>  }
> @@ -4387,7 +4388,6 @@ void intel_irq_init(struct drm_i915_private *dev_priv)
>  		dev->vblank_disable_immediate = true;
>  
>  	dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp;
> -	dev->driver->get_scanout_position = i915_get_crtc_scanoutpos;
>  
>  	if (IS_CHERRYVIEW(dev_priv)) {
>  		dev->driver->irq_handler = cherryview_irq_handler;

> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 683f1421a825..c5c9e316251a 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -307,6 +307,11 @@ struct drm_crtc_state {
>  	struct drm_atomic_state *state;
>  };
>  
> +/* get_scanout_position() return flags */
> +#define DRM_SCANOUTPOS_VALID        (1 << 0)
> +#define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
> +#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
> +
>  /**
>   * struct drm_crtc_funcs - control CRTCs for a given device
>   * @save: save CRTC state
> @@ -326,6 +331,7 @@ struct drm_crtc_state {
>   *    (do not call directly, use drm_atomic_crtc_set_property())
>   * @atomic_get_property: get a property on an atomic state for this CRTC
>   *    (do not call directly, use drm_atomic_crtc_get_property())
> + * @get_scanout_position: return the current scanout position
>   *
>   * The drm_crtc_funcs structure is the central CRTC management structure
>   * in the DRM.  Each CRTC controls one or more connectors (note that the name
> @@ -389,6 +395,40 @@ struct drm_crtc_funcs {
>  				   const struct drm_crtc_state *state,
>  				   struct drm_property *property,
>  				   uint64_t *val);
> +
> +	/**

Please use the new inline structure documentation layout for this (merged
into 4.3): Just drop the @get_scanout_position: from the top-level comment
and add that here.
-Daniel

> +	 * Called by vblank timestamping code.
> +	 *
> +	 * Return the current display scanout position from a crtc, and an
> +	 * optional accurate ktime_get timestamp of when position was measured.
> +	 *
> +	 * \param crtc CRTC to query.
> +	 * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
> +	 * \param *vpos Target location for current vertical scanout position.
> +	 * \param *hpos Target location for current horizontal scanout position.
> +	 * \param *stime Target location for timestamp taken immediately before
> +	 *               scanout position query. Can be NULL to skip timestamp.
> +	 * \param *etime Target location for timestamp taken immediately after
> +	 *               scanout position query. Can be NULL to skip timestamp.
> +	 * \param mode Current display timings.
> +	 *
> +	 * Returns vpos as a positive number while in active scanout area.
> +	 * Returns vpos as a negative number inside vblank, counting the number
> +	 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
> +	 * until start of active scanout / end of vblank."
> +	 *
> +	 * \return Flags, or'ed together as follows:
> +	 *
> +	 * DRM_SCANOUTPOS_VALID = Query successful.
> +	 * DRM_SCANOUTPOS_INVBL = Inside vblank.
> +	 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
> +	 * this flag means that returned position may be offset by a constant
> +	 * but unknown small number of scanlines wrt. real scanout position.
> +	 */
> +	int (*get_scanout_position)(struct drm_crtc *crtc, unsigned int flags,
> +				    int *vpos, int *hpos, ktime_t *stime,
> +				    ktime_t *etime,
> +				    const struct drm_display_mode *mode);
>  };
>  
>  /**
> @@ -1194,6 +1234,12 @@ extern int drm_crtc_init_with_planes(struct drm_device *dev,
>  extern void drm_crtc_cleanup(struct drm_crtc *crtc);
>  extern unsigned int drm_crtc_index(struct drm_crtc *crtc);
>  
> +extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_crtc *crtc,
> +						 int *max_error,
> +						 struct timeval *vblank_time,
> +						 unsigned flags,
> +						 const struct drm_display_mode *mode);
> +
>  /**
>   * drm_crtc_mask - find the mask of a registered CRTC
>   * @crtc: CRTC to find mask for
> -- 
> 2.5.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 14/16] drm/irq: Add drm_crtc_vblank_count_and_time()
  2015-09-24 16:35 ` [PATCH 14/16] drm/irq: Add drm_crtc_vblank_count_and_time() Thierry Reding
@ 2015-09-24 18:27   ` Daniel Vetter
  0 siblings, 0 replies; 28+ messages in thread
From: Daniel Vetter @ 2015-09-24 18:27 UTC (permalink / raw)
  To: Thierry Reding; +Cc: dri-devel

On Thu, Sep 24, 2015 at 06:35:36PM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> This function is the KMS native variant of drm_vblank_count_and_time().
> It takes a struct drm_crtc * instead of a struct drm_device * and an
> index of the CRTC.
> 
> Eventually the goal is to access vblank data through the CRTC only so
> that the per-CRTC data can be moved to struct drm_crtc.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>

Applied to drm-misc, thanks.
-Daniel

> ---
>  drivers/gpu/drm/drm_irq.c | 23 +++++++++++++++++++++++
>  include/drm/drmP.h        |  2 ++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 525bd82ab514..d81e3724cca3 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -909,6 +909,8 @@ EXPORT_SYMBOL(drm_crtc_vblank_count);
>   * vblank events since the system was booted, including lost events due to
>   * modesetting activity. Returns corresponding system timestamp of the time
>   * of the vblank interval that corresponds to the current vblank counter value.
> + *
> + * This is the legacy version of drm_crtc_vblank_count_and_time().
>   */
>  u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
>  			      struct timeval *vblanktime)
> @@ -936,6 +938,27 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
>  }
>  EXPORT_SYMBOL(drm_vblank_count_and_time);
>  
> +/**
> + * drm_crtc_vblank_count_and_time - retrieve "cooked" vblank counter value
> + *     and the system timestamp corresponding to that vblank counter value
> + * @crtc: which counter to retrieve
> + * @vblanktime: Pointer to struct timeval to receive the vblank timestamp.
> + *
> + * Fetches the "cooked" vblank count value that represents the number of
> + * vblank events since the system was booted, including lost events due to
> + * modesetting activity. Returns corresponding system timestamp of the time
> + * of the vblank interval that corresponds to the current vblank counter value.
> + *
> + * This is the native KMS version of drm_vblank_count_and_time().
> + */
> +u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
> +				   struct timeval *vblanktime)
> +{
> +	return drm_vblank_count_and_time(crtc->dev, drm_crtc_index(crtc),
> +					 vblanktime);
> +}
> +EXPORT_SYMBOL(drm_crtc_vblank_count_and_time);
> +
>  static void send_vblank_event(struct drm_device *dev,
>  		struct drm_pending_vblank_event *e,
>  		unsigned long seq, struct timeval *now)
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index ce693a1366c1..53960444a423 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -889,6 +889,8 @@ extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
>  extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
>  extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
>  				     struct timeval *vblanktime);
> +extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
> +					  struct timeval *vblanktime);
>  extern void drm_send_vblank_event(struct drm_device *dev, unsigned int pipe,
>  				  struct drm_pending_vblank_event *e);
>  extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
> -- 
> 2.5.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 09/16] drm/irq: Use unsigned int pipe in public API
  2015-09-24 16:35 ` [PATCH 09/16] drm/irq: Use unsigned int pipe in public API Thierry Reding
@ 2015-09-24 19:21   ` Russell King - ARM Linux
  2015-09-24 20:20     ` Ville Syrjälä
  2015-10-01 14:46   ` Vincent ABRIOU
  2015-10-06 10:52   ` Ville Syrjälä
  2 siblings, 1 reply; 28+ messages in thread
From: Russell King - ARM Linux @ 2015-09-24 19:21 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Thomas Hellstrom, Laurent Pinchart, Benjamin Gaignard,
	Alison Wang, dri-devel, Tomi Valkeinen, Alex Deucher,
	Daniel Vetter, Christian König, Ben Skeggs

On Thu, Sep 24, 2015 at 06:35:31PM +0200, Thierry Reding wrote:
> This continues the pattern started in commit cc1ef118fc09 ("drm/irq:
> Make pipe unsigned and name consistent"). This is applied to the public
> APIs and driver callbacks, so pretty much all drivers need to be updated
> to match the new prototypes.

I don't like being forced to use the "pipe" naming in all drivers; I
found that really confusing when I first looked at DRM, and it took
a long time to work out that "pipe" basically means "crtc" or "gpu".

What's wrong with keeping "crtc" as the index terminology for crtc
things?  Surely that's more descriptive of what's going on here?

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 09/16] drm/irq: Use unsigned int pipe in public API
  2015-09-24 19:21   ` Russell King - ARM Linux
@ 2015-09-24 20:20     ` Ville Syrjälä
  2015-09-25  7:39       ` Laurent Pinchart
  2015-09-25 12:26       ` Thierry Reding
  0 siblings, 2 replies; 28+ messages in thread
From: Ville Syrjälä @ 2015-09-24 20:20 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Thomas Hellstrom, Alison Wang, Tomi Valkeinen, dri-devel,
	Laurent Pinchart, Benjamin Gaignard, Alex Deucher, Daniel Vetter,
	Christian König, Ben Skeggs

On Thu, Sep 24, 2015 at 08:21:53PM +0100, Russell King - ARM Linux wrote:
> On Thu, Sep 24, 2015 at 06:35:31PM +0200, Thierry Reding wrote:
> > This continues the pattern started in commit cc1ef118fc09 ("drm/irq:
> > Make pipe unsigned and name consistent"). This is applied to the public
> > APIs and driver callbacks, so pretty much all drivers need to be updated
> > to match the new prototypes.
> 
> I don't like being forced to use the "pipe" naming in all drivers; I
> found that really confusing when I first looked at DRM, and it took
> a long time to work out that "pipe" basically means "crtc" or "gpu".

crtc mean "cathode ray tube controller". If you weren't used to it,
it would be pretty much impossible to guess what piece of modern
hardware that means. So I think it's more a case of "a lot of this
junk used to be in what people called the crtc, so we'll call
this modern thing a crtc too". Although I think most of the
hardware people moved on from using that name quite a long time ago.

"gpu" can mean either just the part that does the rendering and 
whatnot, or it can mean the entire graphics "card". But calling
a display pipeline a "gpu" is not done. Now _that_ would be
confusing.

"pipe" is fairly nice term, meaning "pipeline". That describes the
thing quite nicely. Stuff comes in from one end, flows through the
pipe, and goes out the other end.

At least both Intel and OMAP used the term pipe or pipeline in the
hardware docs. Can't really say aything about other brands, at least
if I discount the more ancient junk I'm familiar with.

> What's wrong with keeping "crtc" as the index terminology for crtc
> things?  Surely that's more descriptive of what's going on here?

I can't speak for Thierry, but I assume the real motivation for this
renaming was to make it clear which is the "index", and which is the
crtc object. "pipe" for one, "crtc" for the other. Avoids having
to call the object "dcrtc", "drm_crtc" or something else entirely.
And since the object is called "crtc" everywhere else, it's nice not
to have to make an exception in the vblank code.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 04/16] drm/imx: Drop pipe field from struct imx_drm_crtc
  2015-09-24 16:35 ` [PATCH 04/16] drm/imx: Drop pipe field from struct imx_drm_crtc Thierry Reding
@ 2015-09-25  7:26   ` Philipp Zabel
  0 siblings, 0 replies; 28+ messages in thread
From: Philipp Zabel @ 2015-09-25  7:26 UTC (permalink / raw)
  To: Thierry Reding; +Cc: dri-devel

Am Donnerstag, den 24.09.2015, 18:35 +0200 schrieb Thierry Reding:
> From: Thierry Reding <treding@nvidia.com>
> 
> Use the drm_crtc_index() helper to determine the pipe number of the CRTC
> instead.
> 
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Thierry Reding <treding@nvidia.com>

Acked-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

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

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

* Re: [PATCH 09/16] drm/irq: Use unsigned int pipe in public API
  2015-09-24 20:20     ` Ville Syrjälä
@ 2015-09-25  7:39       ` Laurent Pinchart
  2015-09-25 12:26       ` Thierry Reding
  1 sibling, 0 replies; 28+ messages in thread
From: Laurent Pinchart @ 2015-09-25  7:39 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Thomas Hellstrom, Russell King - ARM Linux, Alison Wang,
	Tomi Valkeinen, dri-devel, Ben Skeggs, Benjamin Gaignard,
	Alex Deucher, Daniel Vetter, Christian König

On Thursday 24 September 2015 23:20:54 Ville Syrjälä wrote:
> On Thu, Sep 24, 2015 at 08:21:53PM +0100, Russell King - ARM Linux wrote:
> > On Thu, Sep 24, 2015 at 06:35:31PM +0200, Thierry Reding wrote:
> > > This continues the pattern started in commit cc1ef118fc09 ("drm/irq:
> > > Make pipe unsigned and name consistent"). This is applied to the public
> > > APIs and driver callbacks, so pretty much all drivers need to be updated
> > > to match the new prototypes.
> > 
> > I don't like being forced to use the "pipe" naming in all drivers; I
> > found that really confusing when I first looked at DRM, and it took
> > a long time to work out that "pipe" basically means "crtc" or "gpu".
> 
> crtc mean "cathode ray tube controller". If you weren't used to it,
> it would be pretty much impossible to guess what piece of modern
> hardware that means. So I think it's more a case of "a lot of this
> junk used to be in what people called the crtc, so we'll call
> this modern thing a crtc too". Although I think most of the
> hardware people moved on from using that name quite a long time ago.
> 
> "gpu" can mean either just the part that does the rendering and
> whatnot, or it can mean the entire graphics "card". But calling
> a display pipeline a "gpu" is not done. Now _that_ would be
> confusing.
> 
> "pipe" is fairly nice term, meaning "pipeline". That describes the
> thing quite nicely. Stuff comes in from one end, flows through the
> pipe, and goes out the other end.

To be pedantic the object we call CRTC today is a subset of the pipeline, not 
the full pipeline. Given that the full pipelines can more complex than a 
single chain (think about one CRTC cloned on two encoders and two connectors), 
I can see why the "pipe" name could sound confusing.

> At least both Intel and OMAP used the term pipe or pipeline in the
> hardware docs. Can't really say aything about other brands, at least
> if I discount the more ancient junk I'm familiar with.
> 
> > What's wrong with keeping "crtc" as the index terminology for crtc
> > things?  Surely that's more descriptive of what's going on here?
> 
> I can't speak for Thierry, but I assume the real motivation for this
> renaming was to make it clear which is the "index", and which is the
> crtc object. "pipe" for one, "crtc" for the other. Avoids having
> to call the object "dcrtc", "drm_crtc" or something else entirely.
> And since the object is called "crtc" everywhere else, it's nice not
> to have to make an exception in the vblank code.

-- 
Regards,

Laurent Pinchart

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

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

* Re: [PATCH 09/16] drm/irq: Use unsigned int pipe in public API
  2015-09-24 20:20     ` Ville Syrjälä
  2015-09-25  7:39       ` Laurent Pinchart
@ 2015-09-25 12:26       ` Thierry Reding
  1 sibling, 0 replies; 28+ messages in thread
From: Thierry Reding @ 2015-09-25 12:26 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Thomas Hellstrom, Russell King - ARM Linux, Alison Wang,
	dri-devel, Tomi Valkeinen, Laurent Pinchart, Benjamin Gaignard,
	Alex Deucher, Daniel Vetter, Christian König, Ben Skeggs


[-- Attachment #1.1: Type: text/plain, Size: 3051 bytes --]

On Thu, Sep 24, 2015 at 11:20:54PM +0300, Ville Syrjälä wrote:
> On Thu, Sep 24, 2015 at 08:21:53PM +0100, Russell King - ARM Linux wrote:
> > On Thu, Sep 24, 2015 at 06:35:31PM +0200, Thierry Reding wrote:
> > > This continues the pattern started in commit cc1ef118fc09 ("drm/irq:
> > > Make pipe unsigned and name consistent"). This is applied to the public
> > > APIs and driver callbacks, so pretty much all drivers need to be updated
> > > to match the new prototypes.
> > 
> > I don't like being forced to use the "pipe" naming in all drivers; I
> > found that really confusing when I first looked at DRM, and it took
> > a long time to work out that "pipe" basically means "crtc" or "gpu".
> 
> crtc mean "cathode ray tube controller". If you weren't used to it,
> it would be pretty much impossible to guess what piece of modern
> hardware that means. So I think it's more a case of "a lot of this
> junk used to be in what people called the crtc, so we'll call
> this modern thing a crtc too". Although I think most of the
> hardware people moved on from using that name quite a long time ago.
> 
> "gpu" can mean either just the part that does the rendering and 
> whatnot, or it can mean the entire graphics "card". But calling
> a display pipeline a "gpu" is not done. Now _that_ would be
> confusing.
> 
> "pipe" is fairly nice term, meaning "pipeline". That describes the
> thing quite nicely. Stuff comes in from one end, flows through the
> pipe, and goes out the other end.
> 
> At least both Intel and OMAP used the term pipe or pipeline in the
> hardware docs. Can't really say aything about other brands, at least
> if I discount the more ancient junk I'm familiar with.
> 
> > What's wrong with keeping "crtc" as the index terminology for crtc
> > things?  Surely that's more descriptive of what's going on here?
> 
> I can't speak for Thierry, but I assume the real motivation for this
> renaming was to make it clear which is the "index", and which is the
> crtc object. "pipe" for one, "crtc" for the other. Avoids having
> to call the object "dcrtc", "drm_crtc" or something else entirely.
> And since the object is called "crtc" everywhere else, it's nice not
> to have to make an exception in the vblank code.

Exactly this. I find it to be very confusing to read through drivers and
see completely inconsistent naming for what's really the same thing. The
list isn't limited to "pipe", "crtc" or "index". There are others that
use "head" or "crtc_id". The latter in particular is very confusing
because, at least in most of the cases I've seen, it refers to the pipe
rather than the CRTC object ID.

That said this is all only temporary, though it may take us a while to
get rid of it. The ultimate goal is to convert all drivers over to using
struct drm_crtc * everywhere, at which point we don't have to bother
with what to call the CRTC index. As a preliminary step, having drivers
use consistent naming is hopefully going to make it easier to replace.

Thierry

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

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

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

* Re: [PATCH 07/16] drm/sti: Store correct CRTC index in events
  2015-09-24 16:35 ` [PATCH 07/16] drm/sti: " Thierry Reding
@ 2015-10-01 14:06   ` Vincent ABRIOU
  0 siblings, 0 replies; 28+ messages in thread
From: Vincent ABRIOU @ 2015-10-01 14:06 UTC (permalink / raw)
  To: Thierry Reding, dri-devel; +Cc: Benjamin Gaignard


On 09/24/2015 06:35 PM, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> A negative pipe causes a special case to be triggered for drivers that
> don't have proper VBLANK support. STi does support VBLANKs, so there is
> no need for the fallback code.
>
> Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> Cc: Vincent Abriou <vincent.abriou@st.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>   drivers/gpu/drm/sti/sti_crtc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
> index 018ffc970e96..81c56ea9d87f 100644
> --- a/drivers/gpu/drm/sti/sti_crtc.c
> +++ b/drivers/gpu/drm/sti/sti_crtc.c
> @@ -274,7 +274,7 @@ int sti_crtc_vblank_cb(struct notifier_block *nb,
>
>   	spin_lock_irqsave(&drm_dev->event_lock, flags);
>   	if (compo->mixer[*crtc]->pending_event) {
> -		drm_send_vblank_event(drm_dev, -1,
> +		drm_send_vblank_event(drm_dev, *crtc,
>   				      compo->mixer[*crtc]->pending_event);
>   		drm_vblank_put(drm_dev, *crtc);
>   		compo->mixer[*crtc]->pending_event = NULL;
>

Successfully tested on next-20151001
Ack-by: Vincent Abriou <vincent.abriou@st.com>

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

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

* Re: [PATCH 09/16] drm/irq: Use unsigned int pipe in public API
  2015-09-24 16:35 ` [PATCH 09/16] drm/irq: Use unsigned int pipe in public API Thierry Reding
  2015-09-24 19:21   ` Russell King - ARM Linux
@ 2015-10-01 14:46   ` Vincent ABRIOU
  2015-10-06 10:52   ` Ville Syrjälä
  2 siblings, 0 replies; 28+ messages in thread
From: Vincent ABRIOU @ 2015-10-01 14:46 UTC (permalink / raw)
  To: Thierry Reding, dri-devel; +Cc: Benjamin Gaignard



On 09/24/2015 06:35 PM, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> This continues the pattern started in commit cc1ef118fc09 ("drm/irq:
> Make pipe unsigned and name consistent"). This is applied to the public
> APIs and driver callbacks, so pretty much all drivers need to be updated
> to match the new prototypes.
>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Russell King <rmk+kernel@arm.linux.org.uk>
> Cc: Inki Dae <inki.dae@samsung.com>
> Cc: Jianwei Wang <jianwei.wang.chn@gmail.com>
> Cc: Alison Wang <alison.wang@freescale.com>
> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Mark Yao <mark.yao@rock-chips.com>
> Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> Cc: Vincent Abriou <vincent.abriou@st.com>
> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---

[...]

>   drivers/gpu/drm/sti/sti_crtc.c               | 16 ++++++------
>   drivers/gpu/drm/sti/sti_crtc.h               |  4 +--

[...]

> diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
> index 81c56ea9d87f..c6fb8dee11de 100644
> --- a/drivers/gpu/drm/sti/sti_crtc.c
> +++ b/drivers/gpu/drm/sti/sti_crtc.c
> @@ -299,7 +299,7 @@ int sti_crtc_vblank_cb(struct notifier_block *nb,
>          return 0;
>   }
>
> -int sti_crtc_enable_vblank(struct drm_device *dev, int crtc)
> +int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
>   {
>          struct sti_private *dev_priv = dev->dev_private;
>          struct sti_compositor *compo = dev_priv->compo;
> @@ -307,9 +307,9 @@ int sti_crtc_enable_vblank(struct drm_device *dev, int crtc)
>
>          DRM_DEBUG_DRIVER("\n");
>
> -       if (sti_vtg_register_client(crtc == STI_MIXER_MAIN ?
> +       if (sti_vtg_register_client(pipe == STI_MIXER_MAIN ?
>                          compo->vtg_main : compo->vtg_aux,
> -                       vtg_vblank_nb, crtc)) {
> +                       vtg_vblank_nb, pipe)) {
>                  DRM_ERROR("Cannot register VTG notifier\n");
>                  return -EINVAL;
>          }
> @@ -318,7 +318,7 @@ int sti_crtc_enable_vblank(struct drm_device *dev, int crtc)
>   }
>   EXPORT_SYMBOL(sti_crtc_enable_vblank);
>
> -void sti_crtc_disable_vblank(struct drm_device *drm_dev, int crtc)
> +void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe)
>   {
>          struct sti_private *priv = drm_dev->dev_private;
>          struct sti_compositor *compo = priv->compo;
> @@ -326,14 +326,14 @@ void sti_crtc_disable_vblank(struct drm_device *drm_dev, int crtc)
>
>          DRM_DEBUG_DRIVER("\n");
>
> -       if (sti_vtg_unregister_client(crtc == STI_MIXER_MAIN ?
> +       if (sti_vtg_unregister_client(pipe == STI_MIXER_MAIN ?
>                          compo->vtg_main : compo->vtg_aux, vtg_vblank_nb))
>                  DRM_DEBUG_DRIVER("Warning: cannot unregister VTG notifier\n");
>
>          /* free the resources of the pending requests */
> -       if (compo->mixer[crtc]->pending_event) {
> -               drm_vblank_put(drm_dev, crtc);
> -               compo->mixer[crtc]->pending_event = NULL;
> +       if (compo->mixer[pipe]->pending_event) {
> +               drm_vblank_put(drm_dev, pipe);
> +               compo->mixer[pipe]->pending_event = NULL;
>          }
>   }
>   EXPORT_SYMBOL(sti_crtc_disable_vblank);
> diff --git a/drivers/gpu/drm/sti/sti_crtc.h b/drivers/gpu/drm/sti/sti_crtc.h
> index 51963e6ddbe7..3f2d89a3634d 100644
> --- a/drivers/gpu/drm/sti/sti_crtc.h
> +++ b/drivers/gpu/drm/sti/sti_crtc.h
> @@ -13,8 +13,8 @@ struct sti_mixer;
>
>   int sti_crtc_init(struct drm_device *drm_dev, struct sti_mixer *mixer,
>                    struct drm_plane *primary, struct drm_plane *cursor);
> -int sti_crtc_enable_vblank(struct drm_device *dev, int crtc);
> -void sti_crtc_disable_vblank(struct drm_device *dev, int crtc);
> +int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe);
> +void sti_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe);
>   int sti_crtc_vblank_cb(struct notifier_block *nb,
>                         unsigned long event, void *data);
>   bool sti_crtc_is_main(struct drm_crtc *drm_crtc);

Tested on top of next-20151001.
You can add my Ack-by on this patch
Ack-by: Vincent Abriou <vincent.abriou@st.com>

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

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

* Re: [PATCH 16/16] drm/sti: Use drm_crtc_vblank_*() API
  2015-09-24 16:35 ` [PATCH 16/16] drm/sti: " Thierry Reding
@ 2015-10-01 14:49   ` Vincent ABRIOU
  0 siblings, 0 replies; 28+ messages in thread
From: Vincent ABRIOU @ 2015-10-01 14:49 UTC (permalink / raw)
  To: Thierry Reding, dri-devel; +Cc: Benjamin Gaignard



On 09/24/2015 06:35 PM, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Non-legacy drivers should only use this API to allow per-CRTC data to be
> eventually moved into struct drm_crtc.
>
> Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> Cc: Vincent Abriou <vincent.abriou@st.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>   drivers/gpu/drm/sti/sti_crtc.c  | 37 ++++++++++++++++++++-----------------
>   drivers/gpu/drm/sti/sti_gdp.c   |  2 +-
>   drivers/gpu/drm/sti/sti_hqvdp.c |  2 +-
>   drivers/gpu/drm/sti/sti_vtg.c   | 14 +++++++-------
>   drivers/gpu/drm/sti/sti_vtg.h   |  4 ++--
>   5 files changed, 31 insertions(+), 28 deletions(-)
>

Tested on top of next-20151001.
You can add my Ack-by on this patch
Ack-by: Vincent Abriou <vincent.abriou@st.com>

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

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

* Re: [PATCH 09/16] drm/irq: Use unsigned int pipe in public API
  2015-09-24 16:35 ` [PATCH 09/16] drm/irq: Use unsigned int pipe in public API Thierry Reding
  2015-09-24 19:21   ` Russell King - ARM Linux
  2015-10-01 14:46   ` Vincent ABRIOU
@ 2015-10-06 10:52   ` Ville Syrjälä
  2 siblings, 0 replies; 28+ messages in thread
From: Ville Syrjälä @ 2015-10-06 10:52 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Thomas Hellstrom, Alison Wang, dri-devel, Tomi Valkeinen,
	Laurent Pinchart, Benjamin Gaignard, Russell King, Alex Deucher,
	Daniel Vetter, Christian König, Ben Skeggs

On Thu, Sep 24, 2015 at 06:35:31PM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> This continues the pattern started in commit cc1ef118fc09 ("drm/irq:
> Make pipe unsigned and name consistent"). This is applied to the public
> APIs and driver callbacks, so pretty much all drivers need to be updated
> to match the new prototypes.

Quickly scanned through this one, didn't spot anything alarming.
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> 
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Russell King <rmk+kernel@arm.linux.org.uk>
> Cc: Inki Dae <inki.dae@samsung.com>
> Cc: Jianwei Wang <jianwei.wang.chn@gmail.com>
> Cc: Alison Wang <alison.wang@freescale.com>
> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Mark Yao <mark.yao@rock-chips.com>
> Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> Cc: Vincent Abriou <vincent.abriou@st.com>
> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h          |  8 +++---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c  |  9 ++++---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c      | 36 +++++++++++++-------------
>  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h     |  9 +++----
>  drivers/gpu/drm/armada/armada_drv.c          |  8 +++---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c |  6 +++--
>  drivers/gpu/drm/drm_irq.c                    |  2 +-
>  drivers/gpu/drm/exynos/exynos_drm_crtc.c     |  4 +--
>  drivers/gpu/drm/exynos/exynos_drm_crtc.h     |  4 +--
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c    |  5 ++--
>  drivers/gpu/drm/gma500/psb_drv.h             |  6 ++---
>  drivers/gpu/drm/gma500/psb_irq.c             |  8 +++---
>  drivers/gpu/drm/gma500/psb_irq.h             |  6 ++---
>  drivers/gpu/drm/i915/i915_irq.c              | 34 ++++++++++++-------------
>  drivers/gpu/drm/imx/imx-drm-core.c           |  8 +++---
>  drivers/gpu/drm/mga/mga_drv.h                |  6 ++---
>  drivers/gpu/drm/mga/mga_irq.c                | 20 +++++++--------
>  drivers/gpu/drm/msm/msm_drv.c                | 12 ++++-----
>  drivers/gpu/drm/nouveau/nouveau_display.c    | 23 +++++++++--------
>  drivers/gpu/drm/nouveau/nouveau_display.h    | 12 ++++-----
>  drivers/gpu/drm/omapdrm/omap_drv.h           |  4 +--
>  drivers/gpu/drm/omapdrm/omap_irq.c           | 16 ++++++------
>  drivers/gpu/drm/qxl/qxl_drv.c                |  7 ++---
>  drivers/gpu/drm/r128/r128_drv.h              |  6 ++---
>  drivers/gpu/drm/r128/r128_irq.c              | 16 ++++++------
>  drivers/gpu/drm/radeon/radeon_display.c      | 25 +++++++++---------
>  drivers/gpu/drm/radeon/radeon_drv.c          | 13 +++++-----
>  drivers/gpu/drm/radeon/radeon_drv.h          |  6 ++---
>  drivers/gpu/drm/radeon/radeon_irq.c          | 38 ++++++++++++++--------------
>  drivers/gpu/drm/radeon/radeon_mode.h         |  5 ++--
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c        |  8 +++---
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c  |  6 +++--
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c     |  4 +--
>  drivers/gpu/drm/sti/sti_crtc.c               | 16 ++++++------
>  drivers/gpu/drm/sti/sti_crtc.h               |  4 +--
>  drivers/gpu/drm/tegra/drm.c                  |  7 ++---
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c          |  4 +--
>  drivers/gpu/drm/via/via_drv.h                |  6 ++---
>  drivers/gpu/drm/via/via_irq.c                | 17 +++++++------
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h          |  6 ++---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c          |  6 ++---
>  include/drm/drmP.h                           | 25 +++++++++---------
>  42 files changed, 239 insertions(+), 232 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 668939a14206..d7b8e4b31d78 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -2348,10 +2348,10 @@ void amdgpu_driver_preclose_kms(struct drm_device *dev,
>  				struct drm_file *file_priv);
>  int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
>  int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
> -u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, int crtc);
> -int amdgpu_enable_vblank_kms(struct drm_device *dev, int crtc);
> -void amdgpu_disable_vblank_kms(struct drm_device *dev, int crtc);
> -int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
> +u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
> +int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
> +void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
> +int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
>  				    int *max_error,
>  				    struct timeval *vblank_time,
>  				    unsigned flags);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index 9b34a3410c32..de116398fa49 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -721,7 +721,7 @@ bool amdgpu_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
>   * an optional accurate timestamp of when query happened.
>   *
>   * \param dev Device to query.
> - * \param crtc Crtc to query.
> + * \param pipe Crtc to query.
>   * \param flags Flags from caller (DRM_CALLED_FROM_VBLIRQ or 0).
>   * \param *vpos Location where vertical scanout position should be stored.
>   * \param *hpos Location where horizontal scanout position should go.
> @@ -744,8 +744,9 @@ bool amdgpu_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
>   * unknown small number of scanlines wrt. real scanout position.
>   *
>   */
> -int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, int crtc, unsigned int flags,
> -			       int *vpos, int *hpos, ktime_t *stime, ktime_t *etime,
> +int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
> +			       unsigned int flags, int *vpos, int *hpos,
> +			       ktime_t *stime, ktime_t *etime,
>  			       const struct drm_display_mode *mode)
>  {
>  	u32 vbl = 0, position = 0;
> @@ -760,7 +761,7 @@ int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, int crtc, unsigned int fl
>  	if (stime)
>  		*stime = ktime_get();
>  
> -	if (amdgpu_display_page_flip_get_scanoutpos(adev, crtc, &vbl, &position) == 0)
> +	if (amdgpu_display_page_flip_get_scanoutpos(adev, pipe, &vbl, &position) == 0)
>  		ret |= DRM_SCANOUTPOS_VALID;
>  
>  	/* Get optional system timestamp after query. */
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index ecfa703a9e69..0118fd3cda13 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -599,36 +599,36 @@ void amdgpu_driver_preclose_kms(struct drm_device *dev,
>   * amdgpu_get_vblank_counter_kms - get frame count
>   *
>   * @dev: drm dev pointer
> - * @crtc: crtc to get the frame count from
> + * @pipe: crtc to get the frame count from
>   *
>   * Gets the frame count on the requested crtc (all asics).
>   * Returns frame count on success, -EINVAL on failure.
>   */
> -u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, int crtc)
> +u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct amdgpu_device *adev = dev->dev_private;
>  
> -	if (crtc < 0 || crtc >= adev->mode_info.num_crtc) {
> -		DRM_ERROR("Invalid crtc %d\n", crtc);
> +	if (pipe >= adev->mode_info.num_crtc) {
> +		DRM_ERROR("Invalid crtc %u\n", pipe);
>  		return -EINVAL;
>  	}
>  
> -	return amdgpu_display_vblank_get_counter(adev, crtc);
> +	return amdgpu_display_vblank_get_counter(adev, pipe);
>  }
>  
>  /**
>   * amdgpu_enable_vblank_kms - enable vblank interrupt
>   *
>   * @dev: drm dev pointer
> - * @crtc: crtc to enable vblank interrupt for
> + * @pipe: crtc to enable vblank interrupt for
>   *
>   * Enable the interrupt on the requested crtc (all asics).
>   * Returns 0 on success, -EINVAL on failure.
>   */
> -int amdgpu_enable_vblank_kms(struct drm_device *dev, int crtc)
> +int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct amdgpu_device *adev = dev->dev_private;
> -	int idx = amdgpu_crtc_idx_to_irq_type(adev, crtc);
> +	int idx = amdgpu_crtc_idx_to_irq_type(adev, pipe);
>  
>  	return amdgpu_irq_get(adev, &adev->crtc_irq, idx);
>  }
> @@ -637,14 +637,14 @@ int amdgpu_enable_vblank_kms(struct drm_device *dev, int crtc)
>   * amdgpu_disable_vblank_kms - disable vblank interrupt
>   *
>   * @dev: drm dev pointer
> - * @crtc: crtc to disable vblank interrupt for
> + * @pipe: crtc to disable vblank interrupt for
>   *
>   * Disable the interrupt on the requested crtc (all asics).
>   */
> -void amdgpu_disable_vblank_kms(struct drm_device *dev, int crtc)
> +void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct amdgpu_device *adev = dev->dev_private;
> -	int idx = amdgpu_crtc_idx_to_irq_type(adev, crtc);
> +	int idx = amdgpu_crtc_idx_to_irq_type(adev, pipe);
>  
>  	amdgpu_irq_put(adev, &adev->crtc_irq, idx);
>  }
> @@ -662,26 +662,26 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, int crtc)
>   * scanout position.  (all asics).
>   * Returns postive status flags on success, negative error on failure.
>   */
> -int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
> +int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
>  				    int *max_error,
>  				    struct timeval *vblank_time,
>  				    unsigned flags)
>  {
> -	struct drm_crtc *drmcrtc;
> +	struct drm_crtc *crtc;
>  	struct amdgpu_device *adev = dev->dev_private;
>  
> -	if (crtc < 0 || crtc >= dev->num_crtcs) {
> -		DRM_ERROR("Invalid crtc %d\n", crtc);
> +	if (pipe >= dev->num_crtcs) {
> +		DRM_ERROR("Invalid crtc %u\n", pipe);
>  		return -EINVAL;
>  	}
>  
>  	/* Get associated drm_crtc: */
> -	drmcrtc = &adev->mode_info.crtcs[crtc]->base;
> +	crtc = &adev->mode_info.crtcs[pipe]->base;
>  
>  	/* Helper routine in DRM core does all the work: */
> -	return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
> +	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
>  						     vblank_time, flags,
> -						     &drmcrtc->hwmode);
> +						     &crtc->hwmode);
>  }
>  
>  const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> index 2b03425f9740..f6b02994442b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> @@ -540,11 +540,10 @@ bool amdgpu_ddc_probe(struct amdgpu_connector *amdgpu_connector, bool use_aux);
>  
>  void amdgpu_encoder_set_active_device(struct drm_encoder *encoder);
>  
> -int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, int crtc,
> -				      unsigned int flags,
> -				      int *vpos, int *hpos, ktime_t *stime,
> -				      ktime_t *etime,
> -				      const struct drm_display_mode *mode);
> +int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
> +			       unsigned int flags, int *vpos, int *hpos,
> +			       ktime_t *stime, ktime_t *etime,
> +			       const struct drm_display_mode *mode);
>  
>  int amdgpu_framebuffer_init(struct drm_device *dev,
>  			     struct amdgpu_framebuffer *rfb,
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 225034b74cda..a438886fcdb6 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -254,17 +254,17 @@ void armada_drm_vbl_event_remove(struct armada_crtc *dcrtc,
>  }
>  
>  /* These are called under the vbl_lock. */
> -static int armada_drm_enable_vblank(struct drm_device *dev, int crtc)
> +static int armada_drm_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct armada_private *priv = dev->dev_private;
> -	armada_drm_crtc_enable_irq(priv->dcrtc[crtc], VSYNC_IRQ_ENA);
> +	armada_drm_crtc_enable_irq(priv->dcrtc[pipe], VSYNC_IRQ_ENA);
>  	return 0;
>  }
>  
> -static void armada_drm_disable_vblank(struct drm_device *dev, int crtc)
> +static void armada_drm_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct armada_private *priv = dev->dev_private;
> -	armada_drm_crtc_disable_irq(priv->dcrtc[crtc], VSYNC_IRQ_ENA);
> +	armada_drm_crtc_disable_irq(priv->dcrtc[pipe], VSYNC_IRQ_ENA);
>  }
>  
>  static struct drm_ioctl_desc armada_ioctls[] = {
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> index 8bc62ec407f9..6dfb63ab54d2 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> @@ -656,7 +656,8 @@ static void atmel_hlcdc_dc_irq_uninstall(struct drm_device *dev)
>  	regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr);
>  }
>  
> -static int atmel_hlcdc_dc_enable_vblank(struct drm_device *dev, int crtc)
> +static int atmel_hlcdc_dc_enable_vblank(struct drm_device *dev,
> +					unsigned int pipe)
>  {
>  	struct atmel_hlcdc_dc *dc = dev->dev_private;
>  
> @@ -666,7 +667,8 @@ static int atmel_hlcdc_dc_enable_vblank(struct drm_device *dev, int crtc)
>  	return 0;
>  }
>  
> -static void atmel_hlcdc_dc_disable_vblank(struct drm_device *dev, int crtc)
> +static void atmel_hlcdc_dc_disable_vblank(struct drm_device *dev,
> +					  unsigned int pipe)
>  {
>  	struct atmel_hlcdc_dc *dc = dev->dev_private;
>  
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 29a6dcd674f8..4a5dee5cd327 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -876,7 +876,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
>   * Returns:
>   * The software vblank counter.
>   */
> -u32 drm_vblank_count(struct drm_device *dev, int pipe)
> +u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
>  
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> index 0872aa2f450f..f364d694a780 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> @@ -167,7 +167,7 @@ err_crtc:
>  	return ERR_PTR(ret);
>  }
>  
> -int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe)
> +int exynos_drm_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct exynos_drm_private *private = dev->dev_private;
>  	struct exynos_drm_crtc *exynos_crtc =
> @@ -179,7 +179,7 @@ int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe)
>  	return 0;
>  }
>  
> -void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe)
> +void exynos_drm_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct exynos_drm_private *private = dev->dev_private;
>  	struct exynos_drm_crtc *exynos_crtc =
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
> index f87d4abda6f7..f9f365bd0257 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h
> +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
> @@ -23,8 +23,8 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
>  					enum exynos_drm_output_type type,
>  					const struct exynos_drm_crtc_ops *ops,
>  					void *context);
> -int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe);
> -void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe);
> +int exynos_drm_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe);
> +void exynos_drm_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe);
>  void exynos_drm_crtc_wait_pending_update(struct exynos_drm_crtc *exynos_crtc);
>  void exynos_drm_crtc_finish_update(struct exynos_drm_crtc *exynos_crtc,
>  				   struct exynos_drm_plane *exynos_plane);
> diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> index 9a8e2da47158..f1fd986ca332 100644
> --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
> @@ -140,7 +140,7 @@ static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> -static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, int crtc)
> +static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
>  	unsigned int value;
> @@ -156,7 +156,8 @@ static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, int crtc)
>  	return 0;
>  }
>  
> -static void fsl_dcu_drm_disable_vblank(struct drm_device *dev, int crtc)
> +static void fsl_dcu_drm_disable_vblank(struct drm_device *dev,
> +				       unsigned int pipe)
>  {
>  	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
>  	unsigned int value;
> diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h
> index e38057b91865..e21726ecac32 100644
> --- a/drivers/gpu/drm/gma500/psb_drv.h
> +++ b/drivers/gpu/drm/gma500/psb_drv.h
> @@ -687,15 +687,15 @@ extern void psb_irq_turn_off_dpst(struct drm_device *dev);
>  extern void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands);
>  extern int psb_vblank_wait2(struct drm_device *dev, unsigned int *sequence);
>  extern int psb_vblank_wait(struct drm_device *dev, unsigned int *sequence);
> -extern int psb_enable_vblank(struct drm_device *dev, int crtc);
> -extern void psb_disable_vblank(struct drm_device *dev, int crtc);
> +extern int psb_enable_vblank(struct drm_device *dev, unsigned int pipe);
> +extern void psb_disable_vblank(struct drm_device *dev, unsigned int pipe);
>  void
>  psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
>  
>  void
>  psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
>  
> -extern u32 psb_get_vblank_counter(struct drm_device *dev, int crtc);
> +extern u32 psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
>  
>  /* framebuffer.c */
>  extern int psbfb_probed(struct drm_device *dev);
> diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
> index 624eb36511c5..78eb10902809 100644
> --- a/drivers/gpu/drm/gma500/psb_irq.c
> +++ b/drivers/gpu/drm/gma500/psb_irq.c
> @@ -510,7 +510,7 @@ int psb_irq_disable_dpst(struct drm_device *dev)
>  /*
>   * It is used to enable VBLANK interrupt
>   */
> -int psb_enable_vblank(struct drm_device *dev, int pipe)
> +int psb_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_psb_private *dev_priv = dev->dev_private;
>  	unsigned long irqflags;
> @@ -549,7 +549,7 @@ int psb_enable_vblank(struct drm_device *dev, int pipe)
>  /*
>   * It is used to disable VBLANK interrupt
>   */
> -void psb_disable_vblank(struct drm_device *dev, int pipe)
> +void psb_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_psb_private *dev_priv = dev->dev_private;
>  	unsigned long irqflags;
> @@ -622,7 +622,7 @@ void mdfld_disable_te(struct drm_device *dev, int pipe)
>  /* Called from drm generic code, passed a 'crtc', which
>   * we use as a pipe index
>   */
> -u32 psb_get_vblank_counter(struct drm_device *dev, int pipe)
> +u32 psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
>  {
>  	uint32_t high_frame = PIPEAFRAMEHIGH;
>  	uint32_t low_frame = PIPEAFRAMEPIXEL;
> @@ -654,7 +654,7 @@ u32 psb_get_vblank_counter(struct drm_device *dev, int pipe)
>  	reg_val = REG_READ(pipeconf_reg);
>  
>  	if (!(reg_val & PIPEACONF_ENABLE)) {
> -		dev_err(dev->dev, "trying to get vblank count for disabled pipe %d\n",
> +		dev_err(dev->dev, "trying to get vblank count for disabled pipe %u\n",
>  								pipe);
>  		goto psb_get_vblank_counter_exit;
>  	}
> diff --git a/drivers/gpu/drm/gma500/psb_irq.h b/drivers/gpu/drm/gma500/psb_irq.h
> index d0b45ffa1126..e6a81a8c9f35 100644
> --- a/drivers/gpu/drm/gma500/psb_irq.h
> +++ b/drivers/gpu/drm/gma500/psb_irq.h
> @@ -38,9 +38,9 @@ int psb_irq_enable_dpst(struct drm_device *dev);
>  int psb_irq_disable_dpst(struct drm_device *dev);
>  void psb_irq_turn_on_dpst(struct drm_device *dev);
>  void psb_irq_turn_off_dpst(struct drm_device *dev);
> -int  psb_enable_vblank(struct drm_device *dev, int pipe);
> -void psb_disable_vblank(struct drm_device *dev, int pipe);
> -u32  psb_get_vblank_counter(struct drm_device *dev, int pipe);
> +int  psb_enable_vblank(struct drm_device *dev, unsigned int pipe);
> +void psb_disable_vblank(struct drm_device *dev, unsigned int pipe);
> +u32  psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
>  
>  int mdfld_enable_te(struct drm_device *dev, int pipe);
>  void mdfld_disable_te(struct drm_device *dev, int pipe);
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 3dc3302d766d..7b3aeb0f8056 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -649,7 +649,7 @@ static void i915_enable_asle_pipestat(struct drm_device *dev)
>   *   of horizontal active on the first line of vertical active
>   */
>  
> -static u32 i8xx_get_vblank_counter(struct drm_device *dev, int pipe)
> +static u32 i8xx_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
>  {
>  	/* Gen2 doesn't have a hardware frame counter */
>  	return 0;
> @@ -658,7 +658,7 @@ static u32 i8xx_get_vblank_counter(struct drm_device *dev, int pipe)
>  /* Called from drm generic code, passed a 'crtc', which
>   * we use as a pipe index
>   */
> -static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
> +static u32 i915_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	unsigned long high_frame;
> @@ -706,7 +706,7 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
>  	return (((high1 << 8) | low) + (pixel >= vbl_start)) & 0xffffff;
>  }
>  
> -static u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)
> +static u32 gm45_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	int reg = PIPE_FRMCOUNT_GM45(pipe);
> @@ -767,7 +767,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
>  	return (position + crtc->scanline_offset) % vtotal;
>  }
>  
> -static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
> +static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
>  				    unsigned int flags, int *vpos, int *hpos,
>  				    ktime_t *stime, ktime_t *etime,
>  				    const struct drm_display_mode *mode)
> @@ -904,27 +904,27 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
>  	return position;
>  }
>  
> -static int i915_get_vblank_timestamp(struct drm_device *dev, int pipe,
> +static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
>  			      int *max_error,
>  			      struct timeval *vblank_time,
>  			      unsigned flags)
>  {
>  	struct drm_crtc *crtc;
>  
> -	if (pipe < 0 || pipe >= INTEL_INFO(dev)->num_pipes) {
> -		DRM_ERROR("Invalid crtc %d\n", pipe);
> +	if (pipe >= INTEL_INFO(dev)->num_pipes) {
> +		DRM_ERROR("Invalid crtc %u\n", pipe);
>  		return -EINVAL;
>  	}
>  
>  	/* Get drm_crtc to timestamp: */
>  	crtc = intel_get_crtc_for_pipe(dev, pipe);
>  	if (crtc == NULL) {
> -		DRM_ERROR("Invalid crtc %d\n", pipe);
> +		DRM_ERROR("Invalid crtc %u\n", pipe);
>  		return -EINVAL;
>  	}
>  
>  	if (!crtc->hwmode.crtc_clock) {
> -		DRM_DEBUG_KMS("crtc %d is disabled\n", pipe);
> +		DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
>  		return -EBUSY;
>  	}
>  
> @@ -2612,7 +2612,7 @@ void i915_handle_error(struct drm_device *dev, bool wedged,
>  /* Called from drm generic code, passed 'crtc' which
>   * we use as a pipe index
>   */
> -static int i915_enable_vblank(struct drm_device *dev, int pipe)
> +static int i915_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	unsigned long irqflags;
> @@ -2629,7 +2629,7 @@ static int i915_enable_vblank(struct drm_device *dev, int pipe)
>  	return 0;
>  }
>  
> -static int ironlake_enable_vblank(struct drm_device *dev, int pipe)
> +static int ironlake_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	unsigned long irqflags;
> @@ -2643,7 +2643,7 @@ static int ironlake_enable_vblank(struct drm_device *dev, int pipe)
>  	return 0;
>  }
>  
> -static int valleyview_enable_vblank(struct drm_device *dev, int pipe)
> +static int valleyview_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	unsigned long irqflags;
> @@ -2656,7 +2656,7 @@ static int valleyview_enable_vblank(struct drm_device *dev, int pipe)
>  	return 0;
>  }
>  
> -static int gen8_enable_vblank(struct drm_device *dev, int pipe)
> +static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	unsigned long irqflags;
> @@ -2672,7 +2672,7 @@ static int gen8_enable_vblank(struct drm_device *dev, int pipe)
>  /* Called from drm generic code, passed 'crtc' which
>   * we use as a pipe index
>   */
> -static void i915_disable_vblank(struct drm_device *dev, int pipe)
> +static void i915_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	unsigned long irqflags;
> @@ -2684,7 +2684,7 @@ static void i915_disable_vblank(struct drm_device *dev, int pipe)
>  	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
>  }
>  
> -static void ironlake_disable_vblank(struct drm_device *dev, int pipe)
> +static void ironlake_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	unsigned long irqflags;
> @@ -2696,7 +2696,7 @@ static void ironlake_disable_vblank(struct drm_device *dev, int pipe)
>  	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
>  }
>  
> -static void valleyview_disable_vblank(struct drm_device *dev, int pipe)
> +static void valleyview_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	unsigned long irqflags;
> @@ -2707,7 +2707,7 @@ static void valleyview_disable_vblank(struct drm_device *dev, int pipe)
>  	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
>  }
>  
> -static void gen8_disable_vblank(struct drm_device *dev, int pipe)
> +static void gen8_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	unsigned long irqflags;
> diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
> index ad77c9d86409..5ac81180a46d 100644
> --- a/drivers/gpu/drm/imx/imx-drm-core.c
> +++ b/drivers/gpu/drm/imx/imx-drm-core.c
> @@ -144,10 +144,10 @@ void imx_drm_handle_vblank(struct imx_drm_crtc *imx_drm_crtc)
>  }
>  EXPORT_SYMBOL_GPL(imx_drm_handle_vblank);
>  
> -static int imx_drm_enable_vblank(struct drm_device *drm, int crtc)
> +static int imx_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
>  {
>  	struct imx_drm_device *imxdrm = drm->dev_private;
> -	struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[crtc];
> +	struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe];
>  	int ret;
>  
>  	if (!imx_drm_crtc)
> @@ -162,10 +162,10 @@ static int imx_drm_enable_vblank(struct drm_device *drm, int crtc)
>  	return ret;
>  }
>  
> -static void imx_drm_disable_vblank(struct drm_device *drm, int crtc)
> +static void imx_drm_disable_vblank(struct drm_device *drm, unsigned int pipe)
>  {
>  	struct imx_drm_device *imxdrm = drm->dev_private;
> -	struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[crtc];
> +	struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe];
>  
>  	if (!imx_drm_crtc)
>  		return;
> diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
> index b4a2014917e5..bb312339e0b0 100644
> --- a/drivers/gpu/drm/mga/mga_drv.h
> +++ b/drivers/gpu/drm/mga/mga_drv.h
> @@ -183,9 +183,9 @@ extern int mga_warp_install_microcode(drm_mga_private_t *dev_priv);
>  extern int mga_warp_init(drm_mga_private_t *dev_priv);
>  
>  				/* mga_irq.c */
> -extern int mga_enable_vblank(struct drm_device *dev, int crtc);
> -extern void mga_disable_vblank(struct drm_device *dev, int crtc);
> -extern u32 mga_get_vblank_counter(struct drm_device *dev, int crtc);
> +extern int mga_enable_vblank(struct drm_device *dev, unsigned int pipe);
> +extern void mga_disable_vblank(struct drm_device *dev, unsigned int pipe);
> +extern u32 mga_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
>  extern int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence);
>  extern int mga_driver_vblank_wait(struct drm_device *dev, unsigned int *sequence);
>  extern irqreturn_t mga_driver_irq_handler(int irq, void *arg);
> diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
> index 1b071b8ff9dc..693ba708cfed 100644
> --- a/drivers/gpu/drm/mga/mga_irq.c
> +++ b/drivers/gpu/drm/mga/mga_irq.c
> @@ -35,12 +35,12 @@
>  #include <drm/mga_drm.h>
>  #include "mga_drv.h"
>  
> -u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
> +u32 mga_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
>  {
>  	const drm_mga_private_t *const dev_priv =
>  		(drm_mga_private_t *) dev->dev_private;
>  
> -	if (crtc != 0)
> +	if (pipe != 0)
>  		return 0;
>  
>  	return atomic_read(&dev_priv->vbl_received);
> @@ -88,13 +88,13 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
>  	return IRQ_NONE;
>  }
>  
> -int mga_enable_vblank(struct drm_device *dev, int crtc)
> +int mga_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
>  
> -	if (crtc != 0) {
> -		DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
> -			  crtc);
> +	if (pipe != 0) {
> +		DRM_ERROR("tried to enable vblank on non-existent crtc %u\n",
> +			  pipe);
>  		return 0;
>  	}
>  
> @@ -103,11 +103,11 @@ int mga_enable_vblank(struct drm_device *dev, int crtc)
>  }
>  
>  
> -void mga_disable_vblank(struct drm_device *dev, int crtc)
> +void mga_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
> -	if (crtc != 0) {
> -		DRM_ERROR("tried to disable vblank on non-existent crtc %d\n",
> -			  crtc);
> +	if (pipe != 0) {
> +		DRM_ERROR("tried to disable vblank on non-existent crtc %u\n",
> +			  pipe);
>  	}
>  
>  	/* Do *NOT* disable the vertical refresh interrupt.  MGA doesn't have
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 0339c5d82d37..7e44511d0951 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -531,24 +531,24 @@ static void msm_irq_uninstall(struct drm_device *dev)
>  	kms->funcs->irq_uninstall(kms);
>  }
>  
> -static int msm_enable_vblank(struct drm_device *dev, int crtc_id)
> +static int msm_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct msm_drm_private *priv = dev->dev_private;
>  	struct msm_kms *kms = priv->kms;
>  	if (!kms)
>  		return -ENXIO;
> -	DBG("dev=%p, crtc=%d", dev, crtc_id);
> -	return vblank_ctrl_queue_work(priv, crtc_id, true);
> +	DBG("dev=%p, crtc=%u", dev, pipe);
> +	return vblank_ctrl_queue_work(priv, pipe, true);
>  }
>  
> -static void msm_disable_vblank(struct drm_device *dev, int crtc_id)
> +static void msm_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct msm_drm_private *priv = dev->dev_private;
>  	struct msm_kms *kms = priv->kms;
>  	if (!kms)
>  		return;
> -	DBG("dev=%p, crtc=%d", dev, crtc_id);
> -	vblank_ctrl_queue_work(priv, crtc_id, false);
> +	DBG("dev=%p, crtc=%u", dev, pipe);
> +	vblank_ctrl_queue_work(priv, pipe, false);
>  }
>  
>  /*
> diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
> index a82c3cbe3127..886079dd9baa 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_display.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
> @@ -51,12 +51,12 @@ nouveau_display_vblank_handler(struct nvif_notify *notify)
>  }
>  
>  int
> -nouveau_display_vblank_enable(struct drm_device *dev, int head)
> +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 == head) {
> +		if (nv_crtc->index == pipe) {
>  			nvif_notify_get(&nv_crtc->vblank);
>  			return 0;
>  		}
> @@ -65,12 +65,12 @@ nouveau_display_vblank_enable(struct drm_device *dev, int head)
>  }
>  
>  void
> -nouveau_display_vblank_disable(struct drm_device *dev, int head)
> +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 == head) {
> +		if (nv_crtc->index == pipe) {
>  			nvif_notify_put(&nv_crtc->vblank);
>  			return;
>  		}
> @@ -132,14 +132,15 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
>  }
>  
>  int
> -nouveau_display_scanoutpos(struct drm_device *dev, int head, unsigned int flags,
> -			   int *vpos, int *hpos, ktime_t *stime, ktime_t *etime,
> +nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
> +			   unsigned int flags, int *vpos, int *hpos,
> +			   ktime_t *stime, ktime_t *etime,
>  			   const struct drm_display_mode *mode)
>  {
>  	struct drm_crtc *crtc;
>  
>  	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
> -		if (nouveau_crtc(crtc)->index == head) {
> +		if (nouveau_crtc(crtc)->index == pipe) {
>  			return nouveau_display_scanoutpos_head(crtc, vpos, hpos,
>  							       stime, etime);
>  		}
> @@ -149,15 +150,15 @@ nouveau_display_scanoutpos(struct drm_device *dev, int head, unsigned int flags,
>  }
>  
>  int
> -nouveau_display_vblstamp(struct drm_device *dev, int head, int *max_error,
> -			 struct timeval *time, unsigned flags)
> +nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
> +			 int *max_error, struct timeval *time, unsigned flags)
>  {
>  	struct drm_crtc *crtc;
>  
>  	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
> -		if (nouveau_crtc(crtc)->index == head) {
> +		if (nouveau_crtc(crtc)->index == pipe) {
>  			return drm_calc_vbltimestamp_from_scanoutpos(dev,
> -					head, max_error, time, flags,
> +					pipe, max_error, time, flags,
>  					&crtc->hwmode);
>  		}
>  	}
> diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h b/drivers/gpu/drm/nouveau/nouveau_display.h
> index 4182d21538c5..856abe0f070d 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_display.h
> +++ b/drivers/gpu/drm/nouveau/nouveau_display.h
> @@ -65,12 +65,12 @@ int  nouveau_display_init(struct drm_device *dev);
>  void nouveau_display_fini(struct drm_device *dev);
>  int  nouveau_display_suspend(struct drm_device *dev, bool runtime);
>  void nouveau_display_resume(struct drm_device *dev, bool runtime);
> -int  nouveau_display_vblank_enable(struct drm_device *, int);
> -void nouveau_display_vblank_disable(struct drm_device *, int);
> -int  nouveau_display_scanoutpos(struct drm_device *, int, unsigned int,
> -				int *, int *, ktime_t *, ktime_t *,
> -				const struct drm_display_mode *);
> -int  nouveau_display_vblstamp(struct drm_device *, int, int *,
> +int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
> +void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
> +int  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
> +				unsigned int, int *, int *, ktime_t *,
> +				ktime_t *, const struct drm_display_mode *);
> +int  nouveau_display_vblstamp(struct drm_device *, unsigned int, int *,
>  			      struct timeval *, unsigned);
>  
>  int  nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
> index 12081e61d45a..5c367aad8a6e 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.h
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.h
> @@ -129,8 +129,8 @@ void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
>  int omap_gem_resume(struct device *dev);
>  #endif
>  
> -int omap_irq_enable_vblank(struct drm_device *dev, int crtc_id);
> -void omap_irq_disable_vblank(struct drm_device *dev, int crtc_id);
> +int omap_irq_enable_vblank(struct drm_device *dev, unsigned int pipe);
> +void omap_irq_disable_vblank(struct drm_device *dev, unsigned int pipe);
>  void __omap_irq_register(struct drm_device *dev, struct omap_drm_irq *irq);
>  void __omap_irq_unregister(struct drm_device *dev, struct omap_drm_irq *irq);
>  void omap_irq_register(struct drm_device *dev, struct omap_drm_irq *irq);
> diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c b/drivers/gpu/drm/omapdrm/omap_irq.c
> index 249c0330d6ce..60e1e8016708 100644
> --- a/drivers/gpu/drm/omapdrm/omap_irq.c
> +++ b/drivers/gpu/drm/omapdrm/omap_irq.c
> @@ -134,7 +134,7 @@ int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait,
>  /**
>   * enable_vblank - enable vblank interrupt events
>   * @dev: DRM device
> - * @crtc: which irq to enable
> + * @pipe: which irq to enable
>   *
>   * Enable vblank interrupts for @crtc.  If the device doesn't have
>   * a hardware vblank counter, this routine should be a no-op, since
> @@ -144,13 +144,13 @@ int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait,
>   * Zero on success, appropriate errno if the given @crtc's vblank
>   * interrupt cannot be enabled.
>   */
> -int omap_irq_enable_vblank(struct drm_device *dev, int crtc_id)
> +int omap_irq_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
> -	struct drm_crtc *crtc = priv->crtcs[crtc_id];
> +	struct drm_crtc *crtc = priv->crtcs[pipe];
>  	unsigned long flags;
>  
> -	DBG("dev=%p, crtc=%d", dev, crtc_id);
> +	DBG("dev=%p, crtc=%u", dev, pipe);
>  
>  	spin_lock_irqsave(&list_lock, flags);
>  	priv->vblank_mask |= pipe2vbl(crtc);
> @@ -163,19 +163,19 @@ int omap_irq_enable_vblank(struct drm_device *dev, int crtc_id)
>  /**
>   * disable_vblank - disable vblank interrupt events
>   * @dev: DRM device
> - * @crtc: which irq to enable
> + * @pipe: which irq to enable
>   *
>   * Disable vblank interrupts for @crtc.  If the device doesn't have
>   * a hardware vblank counter, this routine should be a no-op, since
>   * interrupts will have to stay on to keep the count accurate.
>   */
> -void omap_irq_disable_vblank(struct drm_device *dev, int crtc_id)
> +void omap_irq_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
> -	struct drm_crtc *crtc = priv->crtcs[crtc_id];
> +	struct drm_crtc *crtc = priv->crtcs[pipe];
>  	unsigned long flags;
>  
> -	DBG("dev=%p, crtc=%d", dev, crtc_id);
> +	DBG("dev=%p, crtc=%u", dev, pipe);
>  
>  	spin_lock_irqsave(&list_lock, flags);
>  	priv->vblank_mask &= ~pipe2vbl(crtc);
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index 83f6f0b5e9ef..7307b07fe06b 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -196,17 +196,18 @@ static int qxl_pm_restore(struct device *dev)
>  	return qxl_drm_resume(drm_dev, false);
>  }
>  
> -static u32 qxl_noop_get_vblank_counter(struct drm_device *dev, int crtc)
> +static u32 qxl_noop_get_vblank_counter(struct drm_device *dev,
> +				       unsigned int pipe)
>  {
>  	return 0;
>  }
>  
> -static int qxl_noop_enable_vblank(struct drm_device *dev, int crtc)
> +static int qxl_noop_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	return 0;
>  }
>  
> -static void qxl_noop_disable_vblank(struct drm_device *dev, int crtc)
> +static void qxl_noop_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  }
>  
> diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
> index 723e5d6f10a4..09143b840482 100644
> --- a/drivers/gpu/drm/r128/r128_drv.h
> +++ b/drivers/gpu/drm/r128/r128_drv.h
> @@ -154,9 +154,9 @@ extern int r128_wait_ring(drm_r128_private_t *dev_priv, int n);
>  extern int r128_do_cce_idle(drm_r128_private_t *dev_priv);
>  extern int r128_do_cleanup_cce(struct drm_device *dev);
>  
> -extern int r128_enable_vblank(struct drm_device *dev, int crtc);
> -extern void r128_disable_vblank(struct drm_device *dev, int crtc);
> -extern u32 r128_get_vblank_counter(struct drm_device *dev, int crtc);
> +extern int r128_enable_vblank(struct drm_device *dev, unsigned int pipe);
> +extern void r128_disable_vblank(struct drm_device *dev, unsigned int pipe);
> +extern u32 r128_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
>  extern irqreturn_t r128_driver_irq_handler(int irq, void *arg);
>  extern void r128_driver_irq_preinstall(struct drm_device *dev);
>  extern int r128_driver_irq_postinstall(struct drm_device *dev);
> diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
> index c2ae496babb7..9730f4918944 100644
> --- a/drivers/gpu/drm/r128/r128_irq.c
> +++ b/drivers/gpu/drm/r128/r128_irq.c
> @@ -34,11 +34,11 @@
>  #include <drm/r128_drm.h>
>  #include "r128_drv.h"
>  
> -u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
> +u32 r128_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
>  {
>  	const drm_r128_private_t *dev_priv = dev->dev_private;
>  
> -	if (crtc != 0)
> +	if (pipe != 0)
>  		return 0;
>  
>  	return atomic_read(&dev_priv->vbl_received);
> @@ -62,12 +62,12 @@ irqreturn_t r128_driver_irq_handler(int irq, void *arg)
>  	return IRQ_NONE;
>  }
>  
> -int r128_enable_vblank(struct drm_device *dev, int crtc)
> +int r128_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	drm_r128_private_t *dev_priv = dev->dev_private;
>  
> -	if (crtc != 0) {
> -		DRM_ERROR("%s:  bad crtc %d\n", __func__, crtc);
> +	if (pipe != 0) {
> +		DRM_ERROR("%s:  bad crtc %u\n", __func__, pipe);
>  		return -EINVAL;
>  	}
>  
> @@ -75,10 +75,10 @@ int r128_enable_vblank(struct drm_device *dev, int crtc)
>  	return 0;
>  }
>  
> -void r128_disable_vblank(struct drm_device *dev, int crtc)
> +void r128_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
> -	if (crtc != 0)
> -		DRM_ERROR("%s:  bad crtc %d\n", __func__, crtc);
> +	if (pipe != 0)
> +		DRM_ERROR("%s:  bad crtc %u\n", __func__, pipe);
>  
>  	/*
>  	 * FIXME: implement proper interrupt disable by using the vblank
> diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
> index 0503af748d99..a58635c5db3d 100644
> --- a/drivers/gpu/drm/radeon/radeon_display.c
> +++ b/drivers/gpu/drm/radeon/radeon_display.c
> @@ -1799,8 +1799,9 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
>   * unknown small number of scanlines wrt. real scanout position.
>   *
>   */
> -int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc, unsigned int flags,
> -			       int *vpos, int *hpos, ktime_t *stime, ktime_t *etime,
> +int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
> +			       unsigned int flags, int *vpos, int *hpos,
> +			       ktime_t *stime, ktime_t *etime,
>  			       const struct drm_display_mode *mode)
>  {
>  	u32 stat_crtc = 0, vbl = 0, position = 0;
> @@ -1816,42 +1817,42 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc, unsigned int fl
>  		*stime = ktime_get();
>  
>  	if (ASIC_IS_DCE4(rdev)) {
> -		if (crtc == 0) {
> +		if (pipe == 0) {
>  			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
>  				     EVERGREEN_CRTC0_REGISTER_OFFSET);
>  			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
>  					  EVERGREEN_CRTC0_REGISTER_OFFSET);
>  			ret |= DRM_SCANOUTPOS_VALID;
>  		}
> -		if (crtc == 1) {
> +		if (pipe == 1) {
>  			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
>  				     EVERGREEN_CRTC1_REGISTER_OFFSET);
>  			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
>  					  EVERGREEN_CRTC1_REGISTER_OFFSET);
>  			ret |= DRM_SCANOUTPOS_VALID;
>  		}
> -		if (crtc == 2) {
> +		if (pipe == 2) {
>  			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
>  				     EVERGREEN_CRTC2_REGISTER_OFFSET);
>  			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
>  					  EVERGREEN_CRTC2_REGISTER_OFFSET);
>  			ret |= DRM_SCANOUTPOS_VALID;
>  		}
> -		if (crtc == 3) {
> +		if (pipe == 3) {
>  			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
>  				     EVERGREEN_CRTC3_REGISTER_OFFSET);
>  			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
>  					  EVERGREEN_CRTC3_REGISTER_OFFSET);
>  			ret |= DRM_SCANOUTPOS_VALID;
>  		}
> -		if (crtc == 4) {
> +		if (pipe == 4) {
>  			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
>  				     EVERGREEN_CRTC4_REGISTER_OFFSET);
>  			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
>  					  EVERGREEN_CRTC4_REGISTER_OFFSET);
>  			ret |= DRM_SCANOUTPOS_VALID;
>  		}
> -		if (crtc == 5) {
> +		if (pipe == 5) {
>  			vbl = RREG32(EVERGREEN_CRTC_V_BLANK_START_END +
>  				     EVERGREEN_CRTC5_REGISTER_OFFSET);
>  			position = RREG32(EVERGREEN_CRTC_STATUS_POSITION +
> @@ -1859,19 +1860,19 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc, unsigned int fl
>  			ret |= DRM_SCANOUTPOS_VALID;
>  		}
>  	} else if (ASIC_IS_AVIVO(rdev)) {
> -		if (crtc == 0) {
> +		if (pipe == 0) {
>  			vbl = RREG32(AVIVO_D1CRTC_V_BLANK_START_END);
>  			position = RREG32(AVIVO_D1CRTC_STATUS_POSITION);
>  			ret |= DRM_SCANOUTPOS_VALID;
>  		}
> -		if (crtc == 1) {
> +		if (pipe == 1) {
>  			vbl = RREG32(AVIVO_D2CRTC_V_BLANK_START_END);
>  			position = RREG32(AVIVO_D2CRTC_STATUS_POSITION);
>  			ret |= DRM_SCANOUTPOS_VALID;
>  		}
>  	} else {
>  		/* Pre-AVIVO: Different encoding of scanout pos and vblank interval. */
> -		if (crtc == 0) {
> +		if (pipe == 0) {
>  			/* Assume vbl_end == 0, get vbl_start from
>  			 * upper 16 bits.
>  			 */
> @@ -1885,7 +1886,7 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc, unsigned int fl
>  
>  			ret |= DRM_SCANOUTPOS_VALID;
>  		}
> -		if (crtc == 1) {
> +		if (pipe == 1) {
>  			vbl = (RREG32(RADEON_CRTC2_V_TOTAL_DISP) &
>  				RADEON_CRTC_V_DISP) >> RADEON_CRTC_V_DISP_SHIFT;
>  			position = (RREG32(RADEON_CRTC2_VLINE_CRNT_VLINE) >> 16) & RADEON_CRTC_V_TOTAL;
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
> index e30c1d73b4ca..5b6a6f5b3619 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -105,10 +105,10 @@ void radeon_driver_preclose_kms(struct drm_device *dev,
>  				struct drm_file *file_priv);
>  int radeon_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
>  int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
> -u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc);
> -int radeon_enable_vblank_kms(struct drm_device *dev, int crtc);
> -void radeon_disable_vblank_kms(struct drm_device *dev, int crtc);
> -int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
> +u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
> +int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
> +void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
> +int radeon_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
>  				    int *max_error,
>  				    struct timeval *vblank_time,
>  				    unsigned flags);
> @@ -124,9 +124,8 @@ void radeon_gem_object_close(struct drm_gem_object *obj,
>  struct dma_buf *radeon_gem_prime_export(struct drm_device *dev,
>  					struct drm_gem_object *gobj,
>  					int flags);
> -extern int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc,
> -				      unsigned int flags,
> -				      int *vpos, int *hpos,
> +extern int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int crtc,
> +				      unsigned int flags, int *vpos, int *hpos,
>  				      ktime_t *stime, ktime_t *etime,
>  				      const struct drm_display_mode *mode);
>  extern bool radeon_is_px(struct drm_device *dev);
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
> index 46bd3938282c..0caafc7a6e17 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.h
> +++ b/drivers/gpu/drm/radeon/radeon_drv.h
> @@ -404,9 +404,9 @@ extern int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *
>  extern int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv);
>  
>  extern void radeon_do_release(struct drm_device * dev);
> -extern u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc);
> -extern int radeon_enable_vblank(struct drm_device *dev, int crtc);
> -extern void radeon_disable_vblank(struct drm_device *dev, int crtc);
> +extern u32 radeon_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
> +extern int radeon_enable_vblank(struct drm_device *dev, unsigned int pipe);
> +extern void radeon_disable_vblank(struct drm_device *dev, unsigned int pipe);
>  extern irqreturn_t radeon_driver_irq_handler(int irq, void *arg);
>  extern void radeon_driver_irq_preinstall(struct drm_device * dev);
>  extern int radeon_driver_irq_postinstall(struct drm_device *dev);
> diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
> index 244b19bab2e7..688afb62f7c4 100644
> --- a/drivers/gpu/drm/radeon/radeon_irq.c
> +++ b/drivers/gpu/drm/radeon/radeon_irq.c
> @@ -62,12 +62,12 @@ static void r500_vbl_irq_set_state(struct drm_device *dev, u32 mask, int state)
>  		RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg);
>  }
>  
> -int radeon_enable_vblank(struct drm_device *dev, int crtc)
> +int radeon_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	drm_radeon_private_t *dev_priv = dev->dev_private;
>  
>  	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) {
> -		switch (crtc) {
> +		switch (pipe) {
>  		case 0:
>  			r500_vbl_irq_set_state(dev, R500_D1MODE_INT_MASK, 1);
>  			break;
> @@ -75,12 +75,12 @@ int radeon_enable_vblank(struct drm_device *dev, int crtc)
>  			r500_vbl_irq_set_state(dev, R500_D2MODE_INT_MASK, 1);
>  			break;
>  		default:
> -			DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
> -				  crtc);
> +			DRM_ERROR("tried to enable vblank on non-existent crtc %u\n",
> +				  pipe);
>  			return -EINVAL;
>  		}
>  	} else {
> -		switch (crtc) {
> +		switch (pipe) {
>  		case 0:
>  			radeon_irq_set_state(dev, RADEON_CRTC_VBLANK_MASK, 1);
>  			break;
> @@ -88,8 +88,8 @@ int radeon_enable_vblank(struct drm_device *dev, int crtc)
>  			radeon_irq_set_state(dev, RADEON_CRTC2_VBLANK_MASK, 1);
>  			break;
>  		default:
> -			DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
> -				  crtc);
> +			DRM_ERROR("tried to enable vblank on non-existent crtc %u\n",
> +				  pipe);
>  			return -EINVAL;
>  		}
>  	}
> @@ -97,12 +97,12 @@ int radeon_enable_vblank(struct drm_device *dev, int crtc)
>  	return 0;
>  }
>  
> -void radeon_disable_vblank(struct drm_device *dev, int crtc)
> +void radeon_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	drm_radeon_private_t *dev_priv = dev->dev_private;
>  
>  	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) {
> -		switch (crtc) {
> +		switch (pipe) {
>  		case 0:
>  			r500_vbl_irq_set_state(dev, R500_D1MODE_INT_MASK, 0);
>  			break;
> @@ -110,12 +110,12 @@ void radeon_disable_vblank(struct drm_device *dev, int crtc)
>  			r500_vbl_irq_set_state(dev, R500_D2MODE_INT_MASK, 0);
>  			break;
>  		default:
> -			DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
> -				  crtc);
> +			DRM_ERROR("tried to enable vblank on non-existent crtc %u\n",
> +				  pipe);
>  			break;
>  		}
>  	} else {
> -		switch (crtc) {
> +		switch (pipe) {
>  		case 0:
>  			radeon_irq_set_state(dev, RADEON_CRTC_VBLANK_MASK, 0);
>  			break;
> @@ -123,8 +123,8 @@ void radeon_disable_vblank(struct drm_device *dev, int crtc)
>  			radeon_irq_set_state(dev, RADEON_CRTC2_VBLANK_MASK, 0);
>  			break;
>  		default:
> -			DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
> -				  crtc);
> +			DRM_ERROR("tried to enable vblank on non-existent crtc %u\n",
> +				  pipe);
>  			break;
>  		}
>  	}
> @@ -255,7 +255,7 @@ static int radeon_wait_irq(struct drm_device * dev, int swi_nr)
>  	return ret;
>  }
>  
> -u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc)
> +u32 radeon_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
>  {
>  	drm_radeon_private_t *dev_priv = dev->dev_private;
>  
> @@ -264,18 +264,18 @@ u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc)
>  		return -EINVAL;
>  	}
>  
> -	if (crtc < 0 || crtc > 1) {
> -		DRM_ERROR("Invalid crtc %d\n", crtc);
> +	if (pipe > 1) {
> +		DRM_ERROR("Invalid crtc %u\n", pipe);
>  		return -EINVAL;
>  	}
>  
>  	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) {
> -		if (crtc == 0)
> +		if (pipe == 0)
>  			return RADEON_READ(R500_D1CRTC_FRAME_COUNT);
>  		else
>  			return RADEON_READ(R500_D2CRTC_FRAME_COUNT);
>  	} else {
> -		if (crtc == 0)
> +		if (pipe == 0)
>  			return RADEON_READ(RADEON_CRTC_CRNT_FRAME);
>  		else
>  			return RADEON_READ(RADEON_CRTC2_CRNT_FRAME);
> diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
> index 2317d04f8a09..de18f0668bea 100644
> --- a/drivers/gpu/drm/radeon/radeon_mode.h
> +++ b/drivers/gpu/drm/radeon/radeon_mode.h
> @@ -874,9 +874,8 @@ extern int radeon_crtc_cursor_move(struct drm_crtc *crtc,
>  				   int x, int y);
>  extern void radeon_cursor_reset(struct drm_crtc *crtc);
>  
> -extern int radeon_get_crtc_scanoutpos(struct drm_device *dev, int crtc,
> -				      unsigned int flags,
> -				      int *vpos, int *hpos,
> +extern int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
> +				      unsigned int flags, int *vpos, int *hpos,
>  				      ktime_t *stime, ktime_t *etime,
>  				      const struct drm_display_mode *mode);
>  
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> index 780ca11512ba..bb806c4c2e65 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> @@ -221,20 +221,20 @@ static void rcar_du_lastclose(struct drm_device *dev)
>  	drm_fbdev_cma_restore_mode(rcdu->fbdev);
>  }
>  
> -static int rcar_du_enable_vblank(struct drm_device *dev, int crtc)
> +static int rcar_du_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct rcar_du_device *rcdu = dev->dev_private;
>  
> -	rcar_du_crtc_enable_vblank(&rcdu->crtcs[crtc], true);
> +	rcar_du_crtc_enable_vblank(&rcdu->crtcs[pipe], true);
>  
>  	return 0;
>  }
>  
> -static void rcar_du_disable_vblank(struct drm_device *dev, int crtc)
> +static void rcar_du_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct rcar_du_device *rcdu = dev->dev_private;
>  
> -	rcar_du_crtc_enable_vblank(&rcdu->crtcs[crtc], false);
> +	rcar_du_crtc_enable_vblank(&rcdu->crtcs[pipe], false);
>  }
>  
>  static const struct file_operations rcar_du_fops = {
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 9a0c2911272a..32c6098a99d1 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -103,7 +103,8 @@ static struct drm_crtc *rockchip_crtc_from_pipe(struct drm_device *drm,
>  	return NULL;
>  }
>  
> -static int rockchip_drm_crtc_enable_vblank(struct drm_device *dev, int pipe)
> +static int rockchip_drm_crtc_enable_vblank(struct drm_device *dev,
> +					   unsigned int pipe)
>  {
>  	struct rockchip_drm_private *priv = dev->dev_private;
>  	struct drm_crtc *crtc = rockchip_crtc_from_pipe(dev, pipe);
> @@ -115,7 +116,8 @@ static int rockchip_drm_crtc_enable_vblank(struct drm_device *dev, int pipe)
>  	return 0;
>  }
>  
> -static void rockchip_drm_crtc_disable_vblank(struct drm_device *dev, int pipe)
> +static void rockchip_drm_crtc_disable_vblank(struct drm_device *dev,
> +					     unsigned int pipe)
>  {
>  	struct rockchip_drm_private *priv = dev->dev_private;
>  	struct drm_crtc *crtc = rockchip_crtc_from_pipe(dev, pipe);
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> index 666321de7b99..ca2f918a6587 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> @@ -231,7 +231,7 @@ static irqreturn_t shmob_drm_irq(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> -static int shmob_drm_enable_vblank(struct drm_device *dev, int crtc)
> +static int shmob_drm_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct shmob_drm_device *sdev = dev->dev_private;
>  
> @@ -240,7 +240,7 @@ static int shmob_drm_enable_vblank(struct drm_device *dev, int crtc)
>  	return 0;
>  }
>  
> -static void shmob_drm_disable_vblank(struct drm_device *dev, int crtc)
> +static void shmob_drm_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct shmob_drm_device *sdev = dev->dev_private;
>  
> diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
> index 81c56ea9d87f..c6fb8dee11de 100644
> --- a/drivers/gpu/drm/sti/sti_crtc.c
> +++ b/drivers/gpu/drm/sti/sti_crtc.c
> @@ -299,7 +299,7 @@ int sti_crtc_vblank_cb(struct notifier_block *nb,
>  	return 0;
>  }
>  
> -int sti_crtc_enable_vblank(struct drm_device *dev, int crtc)
> +int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	struct sti_private *dev_priv = dev->dev_private;
>  	struct sti_compositor *compo = dev_priv->compo;
> @@ -307,9 +307,9 @@ int sti_crtc_enable_vblank(struct drm_device *dev, int crtc)
>  
>  	DRM_DEBUG_DRIVER("\n");
>  
> -	if (sti_vtg_register_client(crtc == STI_MIXER_MAIN ?
> +	if (sti_vtg_register_client(pipe == STI_MIXER_MAIN ?
>  			compo->vtg_main : compo->vtg_aux,
> -			vtg_vblank_nb, crtc)) {
> +			vtg_vblank_nb, pipe)) {
>  		DRM_ERROR("Cannot register VTG notifier\n");
>  		return -EINVAL;
>  	}
> @@ -318,7 +318,7 @@ int sti_crtc_enable_vblank(struct drm_device *dev, int crtc)
>  }
>  EXPORT_SYMBOL(sti_crtc_enable_vblank);
>  
> -void sti_crtc_disable_vblank(struct drm_device *drm_dev, int crtc)
> +void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe)
>  {
>  	struct sti_private *priv = drm_dev->dev_private;
>  	struct sti_compositor *compo = priv->compo;
> @@ -326,14 +326,14 @@ void sti_crtc_disable_vblank(struct drm_device *drm_dev, int crtc)
>  
>  	DRM_DEBUG_DRIVER("\n");
>  
> -	if (sti_vtg_unregister_client(crtc == STI_MIXER_MAIN ?
> +	if (sti_vtg_unregister_client(pipe == STI_MIXER_MAIN ?
>  			compo->vtg_main : compo->vtg_aux, vtg_vblank_nb))
>  		DRM_DEBUG_DRIVER("Warning: cannot unregister VTG notifier\n");
>  
>  	/* free the resources of the pending requests */
> -	if (compo->mixer[crtc]->pending_event) {
> -		drm_vblank_put(drm_dev, crtc);
> -		compo->mixer[crtc]->pending_event = NULL;
> +	if (compo->mixer[pipe]->pending_event) {
> +		drm_vblank_put(drm_dev, pipe);
> +		compo->mixer[pipe]->pending_event = NULL;
>  	}
>  }
>  EXPORT_SYMBOL(sti_crtc_disable_vblank);
> diff --git a/drivers/gpu/drm/sti/sti_crtc.h b/drivers/gpu/drm/sti/sti_crtc.h
> index 51963e6ddbe7..3f2d89a3634d 100644
> --- a/drivers/gpu/drm/sti/sti_crtc.h
> +++ b/drivers/gpu/drm/sti/sti_crtc.h
> @@ -13,8 +13,8 @@ struct sti_mixer;
>  
>  int sti_crtc_init(struct drm_device *drm_dev, struct sti_mixer *mixer,
>  		  struct drm_plane *primary, struct drm_plane *cursor);
> -int sti_crtc_enable_vblank(struct drm_device *dev, int crtc);
> -void sti_crtc_disable_vblank(struct drm_device *dev, int crtc);
> +int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe);
> +void sti_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe);
>  int sti_crtc_vblank_cb(struct notifier_block *nb,
>  		       unsigned long event, void *data);
>  bool sti_crtc_is_main(struct drm_crtc *drm_crtc);
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index 2486bc24bff6..759e6af91e59 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -822,7 +822,8 @@ static struct drm_crtc *tegra_crtc_from_pipe(struct drm_device *drm,
>  	return NULL;
>  }
>  
> -static u32 tegra_drm_get_vblank_counter(struct drm_device *drm, int pipe)
> +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 tegra_dc *dc = to_tegra_dc(crtc);
> @@ -833,7 +834,7 @@ static u32 tegra_drm_get_vblank_counter(struct drm_device *drm, int pipe)
>  	return tegra_dc_get_vblank_counter(dc);
>  }
>  
> -static int tegra_drm_enable_vblank(struct drm_device *drm, int pipe)
> +static int tegra_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
>  {
>  	struct drm_crtc *crtc = tegra_crtc_from_pipe(drm, pipe);
>  	struct tegra_dc *dc = to_tegra_dc(crtc);
> @@ -846,7 +847,7 @@ static int tegra_drm_enable_vblank(struct drm_device *drm, int pipe)
>  	return 0;
>  }
>  
> -static void tegra_drm_disable_vblank(struct drm_device *drm, 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 tegra_dc *dc = to_tegra_dc(crtc);
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 0f283a3b932c..a5b8f5d39311 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -425,13 +425,13 @@ static void enable_vblank(struct drm_device *dev, bool enable)
>  		tilcdc_clear(dev, reg, mask);
>  }
>  
> -static int tilcdc_enable_vblank(struct drm_device *dev, int crtc)
> +static int tilcdc_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	enable_vblank(dev, true);
>  	return 0;
>  }
>  
> -static void tilcdc_disable_vblank(struct drm_device *dev, int crtc)
> +static void tilcdc_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	enable_vblank(dev, false);
>  }
> diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
> index ef8c500b4a00..644093f5046c 100644
> --- a/drivers/gpu/drm/via/via_drv.h
> +++ b/drivers/gpu/drm/via/via_drv.h
> @@ -136,9 +136,9 @@ extern int via_init_context(struct drm_device *dev, int context);
>  extern int via_final_context(struct drm_device *dev, int context);
>  
>  extern int via_do_cleanup_map(struct drm_device *dev);
> -extern u32 via_get_vblank_counter(struct drm_device *dev, int crtc);
> -extern int via_enable_vblank(struct drm_device *dev, int crtc);
> -extern void via_disable_vblank(struct drm_device *dev, int crtc);
> +extern u32 via_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
> +extern int via_enable_vblank(struct drm_device *dev, unsigned int pipe);
> +extern void via_disable_vblank(struct drm_device *dev, unsigned int pipe);
>  
>  extern irqreturn_t via_driver_irq_handler(int irq, void *arg);
>  extern void via_driver_irq_preinstall(struct drm_device *dev);
> diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
> index 1319433816d3..ea8172c747a2 100644
> --- a/drivers/gpu/drm/via/via_irq.c
> +++ b/drivers/gpu/drm/via/via_irq.c
> @@ -95,10 +95,11 @@ static unsigned time_diff(struct timeval *now, struct timeval *then)
>  		1000000 - (then->tv_usec - now->tv_usec);
>  }
>  
> -u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
> +u32 via_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
>  {
>  	drm_via_private_t *dev_priv = dev->dev_private;
> -	if (crtc != 0)
> +
> +	if (pipe != 0)
>  		return 0;
>  
>  	return atomic_read(&dev_priv->vbl_received);
> @@ -170,13 +171,13 @@ static __inline__ void viadrv_acknowledge_irqs(drm_via_private_t *dev_priv)
>  	}
>  }
>  
> -int via_enable_vblank(struct drm_device *dev, int crtc)
> +int via_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	drm_via_private_t *dev_priv = dev->dev_private;
>  	u32 status;
>  
> -	if (crtc != 0) {
> -		DRM_ERROR("%s:  bad crtc %d\n", __func__, crtc);
> +	if (pipe != 0) {
> +		DRM_ERROR("%s:  bad crtc %u\n", __func__, pipe);
>  		return -EINVAL;
>  	}
>  
> @@ -189,7 +190,7 @@ int via_enable_vblank(struct drm_device *dev, int crtc)
>  	return 0;
>  }
>  
> -void via_disable_vblank(struct drm_device *dev, int crtc)
> +void via_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	drm_via_private_t *dev_priv = dev->dev_private;
>  	u32 status;
> @@ -200,8 +201,8 @@ void via_disable_vblank(struct drm_device *dev, int crtc)
>  	VIA_WRITE8(0x83d4, 0x11);
>  	VIA_WRITE8(0x83d5, VIA_READ8(0x83d5) & ~0x30);
>  
> -	if (crtc != 0)
> -		DRM_ERROR("%s:  bad crtc %d\n", __func__, crtc);
> +	if (pipe != 0)
> +		DRM_ERROR("%s:  bad crtc %u\n", __func__, pipe);
>  }
>  
>  static int
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> index 6d02de6dc36c..a4a1807a30cc 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> @@ -913,9 +913,9 @@ void vmw_kms_idle_workqueues(struct vmw_master *vmaster);
>  bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv,
>  				uint32_t pitch,
>  				uint32_t height);
> -u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc);
> -int vmw_enable_vblank(struct drm_device *dev, int crtc);
> -void vmw_disable_vblank(struct drm_device *dev, int crtc);
> +u32 vmw_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
> +int vmw_enable_vblank(struct drm_device *dev, unsigned int pipe);
> +void vmw_disable_vblank(struct drm_device *dev, unsigned int pipe);
>  int vmw_kms_present(struct vmw_private *dev_priv,
>  		    struct drm_file *file_priv,
>  		    struct vmw_framebuffer *vfb,
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 61fb7f3de311..16c4299f2be2 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -1263,7 +1263,7 @@ bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv,
>  /**
>   * Function called by DRM code called with vbl_lock held.
>   */
> -u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc)
> +u32 vmw_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
>  {
>  	return 0;
>  }
> @@ -1271,7 +1271,7 @@ u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc)
>  /**
>   * Function called by DRM code called with vbl_lock held.
>   */
> -int vmw_enable_vblank(struct drm_device *dev, int crtc)
> +int vmw_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  	return -ENOSYS;
>  }
> @@ -1279,7 +1279,7 @@ int vmw_enable_vblank(struct drm_device *dev, int crtc)
>  /**
>   * Function called by DRM code called with vbl_lock held.
>   */
> -void vmw_disable_vblank(struct drm_device *dev, int crtc)
> +void vmw_disable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
>  }
>  
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index e42e34549da8..a013a0ed8e6a 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -412,7 +412,7 @@ struct drm_driver {
>  	/**
>  	 * get_vblank_counter - get raw hardware vblank counter
>  	 * @dev: DRM device
> -	 * @crtc: counter to fetch
> +	 * @pipe: counter to fetch
>  	 *
>  	 * Driver callback for fetching a raw hardware vblank counter for @crtc.
>  	 * If a device doesn't have a hardware counter, the driver can simply
> @@ -426,12 +426,12 @@ struct drm_driver {
>  	 * RETURNS
>  	 * Raw vblank counter value.
>  	 */
> -	u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);
> +	u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe);
>  
>  	/**
>  	 * enable_vblank - enable vblank interrupt events
>  	 * @dev: DRM device
> -	 * @crtc: which irq to enable
> +	 * @pipe: which irq to enable
>  	 *
>  	 * Enable vblank interrupts for @crtc.  If the device doesn't have
>  	 * a hardware vblank counter, this routine should be a no-op, since
> @@ -441,18 +441,18 @@ struct drm_driver {
>  	 * Zero on success, appropriate errno if the given @crtc's vblank
>  	 * interrupt cannot be enabled.
>  	 */
> -	int (*enable_vblank) (struct drm_device *dev, int crtc);
> +	int (*enable_vblank) (struct drm_device *dev, unsigned int pipe);
>  
>  	/**
>  	 * disable_vblank - disable vblank interrupt events
>  	 * @dev: DRM device
> -	 * @crtc: which irq to enable
> +	 * @pipe: which irq to enable
>  	 *
>  	 * Disable vblank interrupts for @crtc.  If the device doesn't have
>  	 * a hardware vblank counter, this routine should be a no-op, since
>  	 * interrupts will have to stay on to keep the count accurate.
>  	 */
> -	void (*disable_vblank) (struct drm_device *dev, int crtc);
> +	void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);
>  
>  	/**
>  	 * Called by \c drm_device_is_agp.  Typically used to determine if a
> @@ -474,7 +474,7 @@ struct drm_driver {
>  	 * optional accurate ktime_get timestamp of when position was measured.
>  	 *
>  	 * \param dev  DRM device.
> -	 * \param crtc Id of the crtc to query.
> +	 * \param pipe Id of the crtc to query.
>  	 * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
>  	 * \param *vpos Target location for current vertical scanout position.
>  	 * \param *hpos Target location for current horizontal scanout position.
> @@ -498,9 +498,8 @@ struct drm_driver {
>  	 * but unknown small number of scanlines wrt. real scanout position.
>  	 *
>  	 */
> -	int (*get_scanout_position) (struct drm_device *dev, int crtc,
> -				     unsigned int flags,
> -				     int *vpos, int *hpos,
> +	int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
> +				     unsigned int flags, int *vpos, int *hpos,
>  				     ktime_t *stime, ktime_t *etime,
>  				     const struct drm_display_mode *mode);
>  
> @@ -518,7 +517,7 @@ struct drm_driver {
>  	 * to the OpenML OML_sync_control extension specification.
>  	 *
>  	 * \param dev dev DRM device handle.
> -	 * \param crtc crtc for which timestamp should be returned.
> +	 * \param pipe crtc for which timestamp should be returned.
>  	 * \param *max_error Maximum allowable timestamp error in nanoseconds.
>  	 *                   Implementation should strive to provide timestamp
>  	 *                   with an error of at most *max_error nanoseconds.
> @@ -534,7 +533,7 @@ struct drm_driver {
>  	 * negative number on failure. A positive status code on success,
>  	 * which describes how the vblank_time timestamp was computed.
>  	 */
> -	int (*get_vblank_timestamp) (struct drm_device *dev, int crtc,
> +	int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
>  				     int *max_error,
>  				     struct timeval *vblank_time,
>  				     unsigned flags);
> @@ -927,7 +926,7 @@ extern int drm_irq_uninstall(struct drm_device *dev);
>  extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
>  extern int drm_wait_vblank(struct drm_device *dev, void *data,
>  			   struct drm_file *filp);
> -extern u32 drm_vblank_count(struct drm_device *dev, int pipe);
> +extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
>  extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
>  extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
>  				     struct timeval *vblanktime);
> -- 
> 2.5.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2015-10-06 10:52 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-24 16:35 [PATCH 01/16] drm/gma500: Sanity-check pipe index Thierry Reding
2015-09-24 16:35 ` [PATCH 02/16] drm/bochs: Store correct CRTC index in events Thierry Reding
2015-09-24 16:35 ` [PATCH 03/16] drm/imx: Make pipe number unsigned Thierry Reding
2015-09-24 16:35 ` [PATCH 04/16] drm/imx: Drop pipe field from struct imx_drm_crtc Thierry Reding
2015-09-25  7:26   ` Philipp Zabel
2015-09-24 16:35 ` [PATCH 05/16] drm/imx: Store correct CRTC index in events Thierry Reding
2015-09-24 16:35 ` [PATCH 06/16] drm/rockchip: " Thierry Reding
2015-09-24 16:35 ` [PATCH 07/16] drm/sti: " Thierry Reding
2015-10-01 14:06   ` Vincent ABRIOU
2015-09-24 16:35 ` [PATCH 08/16] drm/irq: Rename drm_crtc -> crtc Thierry Reding
2015-09-24 18:17   ` Daniel Vetter
2015-09-24 16:35 ` [PATCH 09/16] drm/irq: Use unsigned int pipe in public API Thierry Reding
2015-09-24 19:21   ` Russell King - ARM Linux
2015-09-24 20:20     ` Ville Syrjälä
2015-09-25  7:39       ` Laurent Pinchart
2015-09-25 12:26       ` Thierry Reding
2015-10-01 14:46   ` Vincent ABRIOU
2015-10-06 10:52   ` Ville Syrjälä
2015-09-24 16:35 ` [PATCH 10/16] drm/gma500: Use unsigned int pipe consistently Thierry Reding
2015-09-24 16:35 ` [PATCH 11/16] drm/imx: Use unsigned int for CRTC index Thierry Reding
2015-09-24 16:35 ` [PATCH 12/16] drm/msm: Use unsigned int pipe consistently Thierry Reding
2015-09-24 16:35 ` [PATCH 13/16] drm: Move ->get_scanout_position() to struct drm_crtc_funcs Thierry Reding
2015-09-24 18:22   ` Daniel Vetter
2015-09-24 16:35 ` [PATCH 14/16] drm/irq: Add drm_crtc_vblank_count_and_time() Thierry Reding
2015-09-24 18:27   ` Daniel Vetter
2015-09-24 16:35 ` [PATCH 15/16] drm/armada: Use drm_crtc_vblank_*() API Thierry Reding
2015-09-24 16:35 ` [PATCH 16/16] drm/sti: " Thierry Reding
2015-10-01 14:49   ` Vincent ABRIOU

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.