drm/msm: fix compilation issues for "msm" on 4.9

The "msm/sde" driver is porting from "4.4" kernel
to "4.9". The "msm/sde" compilation is failing on
on this kernel branch due to upstream changes. This
patch fixes all compilation issues due to upstream
API changes, mdp4/5 driver changes, driver probe
changes, etc.

Change-Id: Id76a31ea9fa7c06c63a5eaa78e69642b938cb4bf
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
diff --git a/drivers/gpu/drm/msm/sde/sde_crtc.c b/drivers/gpu/drm/msm/sde/sde_crtc.c
index 27374ec..35ba699 100644
--- a/drivers/gpu/drm/msm/sde/sde_crtc.c
+++ b/drivers/gpu/drm/msm/sde/sde_crtc.c
@@ -682,7 +682,7 @@
 
 	SDE_DEBUG("crtc%d\n", crtc->base.id);
 
-	__drm_atomic_helper_crtc_destroy_state(crtc, state);
+	__drm_atomic_helper_crtc_destroy_state(state);
 
 	/* destroy value helper */
 	msm_property_destroy_state(&sde_crtc->property_info, cstate,
@@ -855,7 +855,7 @@
 
 struct plane_state {
 	struct sde_plane_state *sde_pstate;
-	struct drm_plane_state *drm_pstate;
+	const struct drm_plane_state *drm_pstate;
 
 	int stage;
 };
@@ -884,7 +884,7 @@
 	struct sde_crtc *sde_crtc;
 	struct plane_state pstates[SDE_STAGE_MAX * 2];
 
-	struct drm_plane_state *pstate;
+	const struct drm_plane_state *pstate;
 	struct drm_plane *plane;
 	struct drm_display_mode *mode;
 
@@ -910,8 +910,7 @@
 	mixer_width = sde_crtc_mixer_width(sde_crtc, mode);
 
 	 /* get plane state for all drm planes associated with crtc state */
-	drm_atomic_crtc_state_for_each_plane(plane, state) {
-		pstate = drm_atomic_get_plane_state(state->state, plane);
+	drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
 		if (IS_ERR_OR_NULL(pstate)) {
 			rc = PTR_ERR(pstate);
 			SDE_ERROR("%s: failed to get plane%d state, %d\n",
@@ -1312,16 +1311,6 @@
 	return single_open(file, _sde_debugfs_status_show, inode->i_private);
 }
 
-static void sde_crtc_suspend(struct drm_crtc *crtc)
-{
-	sde_cp_crtc_suspend(crtc);
-}
-
-static void sde_crtc_resume(struct drm_crtc *crtc)
-{
-	sde_cp_crtc_resume(crtc);
-}
-
 static const struct drm_crtc_funcs sde_crtc_funcs = {
 	.set_config = drm_atomic_helper_set_config,
 	.destroy = sde_crtc_destroy,
@@ -1332,8 +1321,6 @@
 	.reset = sde_crtc_reset,
 	.atomic_duplicate_state = sde_crtc_duplicate_state,
 	.atomic_destroy_state = sde_crtc_destroy_state,
-	.save = sde_crtc_suspend,
-	.restore = sde_crtc_resume,
 };
 
 static const struct drm_crtc_helper_funcs sde_crtc_helper_funcs = {
@@ -1385,7 +1372,8 @@
 	crtc->dev = dev;
 	atomic_set(&sde_crtc->vblank_refcount, 0);
 
-	drm_crtc_init_with_planes(dev, crtc, plane, NULL, &sde_crtc_funcs);
+	drm_crtc_init_with_planes(dev, crtc, plane, NULL, &sde_crtc_funcs,
+				NULL);
 
 	drm_crtc_helper_add(crtc, &sde_crtc_helper_funcs);
 	plane->crtc = crtc;
diff --git a/drivers/gpu/drm/msm/sde/sde_encoder.c b/drivers/gpu/drm/msm/sde/sde_encoder.c
index af5f81d..6ece91d 100644
--- a/drivers/gpu/drm/msm/sde/sde_encoder.c
+++ b/drivers/gpu/drm/msm/sde/sde_encoder.c
@@ -1215,7 +1215,7 @@
 	sde_enc->cur_master = NULL;
 	spin_lock_init(&sde_enc->enc_spinlock);
 	drm_enc = &sde_enc->base;
-	drm_encoder_init(dev, drm_enc, &sde_encoder_funcs, drm_enc_mode);
+	drm_encoder_init(dev, drm_enc, &sde_encoder_funcs, drm_enc_mode, NULL);
 	drm_encoder_helper_add(drm_enc, &sde_encoder_helper_funcs);
 	bs_init(sde_enc);
 
diff --git a/drivers/gpu/drm/msm/sde/sde_kms.c b/drivers/gpu/drm/msm/sde/sde_kms.c
index 716759c..32d55d1 100644
--- a/drivers/gpu/drm/msm/sde/sde_kms.c
+++ b/drivers/gpu/drm/msm/sde/sde_kms.c
@@ -14,6 +14,7 @@
 
 #include <drm/drm_crtc.h>
 #include <linux/debugfs.h>
+#include <linux/of_irq.h>
 
 #include "msm_drv.h"
 #include "msm_mmu.h"
@@ -793,11 +794,6 @@
 
 	dev = sde_kms->dev;
 
-	/*
-	 * Allow vblank interrupt to be disabled by drm vblank timer.
-	 */
-	dev->vblank_disable_allowed = true;
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/msm/sde/sde_kms.h b/drivers/gpu/drm/msm/sde/sde_kms.h
index cd9d103..6990d16 100644
--- a/drivers/gpu/drm/msm/sde/sde_kms.h
+++ b/drivers/gpu/drm/msm/sde/sde_kms.h
@@ -36,7 +36,7 @@
 #define SDE_DEBUG(fmt, ...)                                                \
 	do {                                                               \
 		if (unlikely(drm_debug & DRM_UT_KMS))                      \
-			drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \
+			DRM_DEBUG(fmt, ##__VA_ARGS__); \
 		else                                                       \
 			pr_debug(fmt, ##__VA_ARGS__);                      \
 	} while (0)
@@ -48,7 +48,7 @@
 #define SDE_DEBUG_DRIVER(fmt, ...)                                         \
 	do {                                                               \
 		if (unlikely(drm_debug & DRM_UT_DRIVER))                   \
-			drm_ut_debug_printk(__func__, fmt, ##__VA_ARGS__); \
+			DRM_ERROR(fmt, ##__VA_ARGS__); \
 		else                                                       \
 			pr_debug(fmt, ##__VA_ARGS__);                      \
 	} while (0)
diff --git a/drivers/gpu/drm/msm/sde/sde_plane.c b/drivers/gpu/drm/msm/sde/sde_plane.c
index 8cf15c5..d2884f0 100644
--- a/drivers/gpu/drm/msm/sde/sde_plane.c
+++ b/drivers/gpu/drm/msm/sde/sde_plane.c
@@ -1199,7 +1199,7 @@
 }
 
 static int sde_plane_prepare_fb(struct drm_plane *plane,
-		const struct drm_plane_state *new_state)
+		struct drm_plane_state *new_state)
 {
 	struct drm_framebuffer *fb = new_state->fb;
 	struct sde_plane *psde = to_sde_plane(plane);
@@ -1212,7 +1212,7 @@
 }
 
 static void sde_plane_cleanup_fb(struct drm_plane *plane,
-		const struct drm_plane_state *old_state)
+		struct drm_plane_state *old_state)
 {
 	struct drm_framebuffer *fb = old_state ? old_state->fb : NULL;
 	struct sde_plane *psde = plane ? to_sde_plane(plane) : NULL;
@@ -1616,7 +1616,8 @@
 
 	/* standard properties */
 	msm_property_install_rotation(&psde->property_info,
-		BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y), PLANE_PROP_ROTATION);
+		(unsigned int) (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y)),
+		PLANE_PROP_ROTATION);
 
 	msm_property_install_enum(&psde->property_info, "blend_op", 0x0, 0,
 		e_blend_op, ARRAY_SIZE(e_blend_op), PLANE_PROP_BLEND_OP);
@@ -2356,8 +2357,9 @@
 		type = DRM_PLANE_TYPE_PRIMARY;
 	else
 		type = DRM_PLANE_TYPE_OVERLAY;
-	ret = drm_universal_plane_init(dev, plane, possible_crtcs,
-			&sde_plane_funcs, psde->formats, psde->nformats, type);
+	ret = drm_universal_plane_init(dev, plane, 0xff, &sde_plane_funcs,
+				psde->formats, psde->nformats,
+				type, NULL);
 	if (ret)
 		goto clean_sspp;
 
diff --git a/drivers/gpu/drm/msm/sde/sde_wb.c b/drivers/gpu/drm/msm/sde/sde_wb.c
index 647cb58..ab4497b 100644
--- a/drivers/gpu/drm/msm/sde/sde_wb.c
+++ b/drivers/gpu/drm/msm/sde/sde_wb.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -453,7 +453,7 @@
 
 	priv = drm_dev->dev_private;
 
-	connector = drm_connector_find(drm_dev, connector_id);
+	connector = drm_connector_lookup(drm_dev, connector_id);
 	if (!connector) {
 		SDE_ERROR("failed to find connector\n");
 		rc = -ENOENT;