[Feature]add MT2731_MP2_MR2_SVN388 baseline version

Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/meta/meta-mediatek/recipes-graphics/libdrm/files/0001-Sync-drm-headfile-with-the-kernel.patch b/meta/meta-mediatek/recipes-graphics/libdrm/files/0001-Sync-drm-headfile-with-the-kernel.patch
new file mode 100644
index 0000000..b5f22e9
--- /dev/null
+++ b/meta/meta-mediatek/recipes-graphics/libdrm/files/0001-Sync-drm-headfile-with-the-kernel.patch
@@ -0,0 +1,131 @@
+From e379c6a137bba5c40d9a126b71a667b4d7f5697a Mon Sep 17 00:00:00 2001
+From: Daniel Stone <daniels@collabora.com>
+Date: Tue, 4 Apr 2017 21:38:56 +0100
+Subject: [PATCH] Headers: Sync drm{,_mode}.h with the kernel
+
+Generated using make headers_install, based on drm-misc-next commit
+5db06a8a98f515f67446a69c57577c4c363ec65d.
+
+This clarifies the comments around modifiers such that they are
+per-framebuffer rather than per-plane, adds the beginnings of aspect
+ratio mode flags, link status properties, and updates the 'reserved'
+field from vblank events to include the CRTC ID.
+
+v2: Split into separate patch, pull in full kernel changes.
+v3: Undo revert of connector-type enums, since it is not actually
+    harmful.
+
+Signed-off-by: Daniel Stone <daniels@collabora.com>
+Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
+---
+ include/drm/drm.h      |  3 ++-
+ include/drm/drm_mode.h | 45 +++++++++++++++++++++++++++++++--------------
+ 2 files changed, 33 insertions(+), 15 deletions(-)
+
+diff --git a/include/drm/drm.h b/include/drm/drm.h
+index f6fd5c2..1e7a4bc 100644
+--- a/include/drm/drm.h
++++ b/include/drm/drm.h
+@@ -641,6 +641,7 @@ struct drm_gem_open {
+ #define DRM_CAP_CURSOR_HEIGHT		0x9
+ #define DRM_CAP_ADDFB2_MODIFIERS	0x10
+ #define DRM_CAP_PAGE_FLIP_TARGET	0x11
++#define DRM_CAP_CRTC_IN_VBLANK_EVENT	0x12
+ 
+ /** DRM_IOCTL_GET_CAP ioctl argument type */
+ struct drm_get_cap {
+@@ -845,7 +846,7 @@ struct drm_event_vblank {
+ 	__u32 tv_sec;
+ 	__u32 tv_usec;
+ 	__u32 sequence;
+-	__u32 reserved;
++	__u32 crtc_id; /* 0 on older kernels that do not support this */
+ };
+ 
+ /* typedef area */
+diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
+index df0e350..70571af 100644
+--- a/include/drm/drm_mode.h
++++ b/include/drm/drm_mode.h
+@@ -47,7 +47,15 @@ extern "C" {
+ #define DRM_MODE_TYPE_DRIVER	(1<<6)
+ 
+ /* Video mode flags */
+-/* bit compatible with the xorg definitions. */
++/* bit compatible with the xrandr RR_ definitions (bits 0-13)
++ *
++ * ABI warning: Existing userspace really expects
++ * the mode flags to match the xrandr definitions. Any
++ * changes that don't match the xrandr definitions will
++ * likely need a new client cap or some other mechanism
++ * to avoid breaking existing userspace. This includes
++ * allocating new flags in the previously unused bits!
++ */
+ #define DRM_MODE_FLAG_PHSYNC			(1<<0)
+ #define DRM_MODE_FLAG_NHSYNC			(1<<1)
+ #define DRM_MODE_FLAG_PVSYNC			(1<<2)
+@@ -107,6 +115,10 @@ extern "C" {
+ #define DRM_MODE_DIRTY_ON       1
+ #define DRM_MODE_DIRTY_ANNOTATE 2
+ 
++/* Link Status options */
++#define DRM_MODE_LINK_STATUS_GOOD	0
++#define DRM_MODE_LINK_STATUS_BAD	1
++
+ struct drm_mode_modeinfo {
+ 	__u32 clock;
+ 	__u16 hdisplay;
+@@ -220,14 +232,16 @@ struct drm_mode_get_encoder {
+ 
+ /* This is for connectors with multiple signal types. */
+ /* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
+-#define DRM_MODE_SUBCONNECTOR_Automatic	0
+-#define DRM_MODE_SUBCONNECTOR_Unknown	0
+-#define DRM_MODE_SUBCONNECTOR_DVID	3
+-#define DRM_MODE_SUBCONNECTOR_DVIA	4
+-#define DRM_MODE_SUBCONNECTOR_Composite	5
+-#define DRM_MODE_SUBCONNECTOR_SVIDEO	6
+-#define DRM_MODE_SUBCONNECTOR_Component	8
+-#define DRM_MODE_SUBCONNECTOR_SCART	9
++enum drm_mode_subconnector {
++	DRM_MODE_SUBCONNECTOR_Automatic = 0,
++	DRM_MODE_SUBCONNECTOR_Unknown = 0,
++	DRM_MODE_SUBCONNECTOR_DVID = 3,
++	DRM_MODE_SUBCONNECTOR_DVIA = 4,
++	DRM_MODE_SUBCONNECTOR_Composite = 5,
++	DRM_MODE_SUBCONNECTOR_SVIDEO = 6,
++	DRM_MODE_SUBCONNECTOR_Component = 8,
++	DRM_MODE_SUBCONNECTOR_SCART = 9,
++};
+ 
+ #define DRM_MODE_CONNECTOR_Unknown	0
+ #define DRM_MODE_CONNECTOR_VGA		1
+@@ -392,17 +406,20 @@ struct drm_mode_fb_cmd2 {
+ 	 * offsets[1].  Note that offsets[0] will generally
+ 	 * be 0 (but this is not required).
+ 	 *
+-	 * To accommodate tiled, compressed, etc formats, a per-plane
++	 * To accommodate tiled, compressed, etc formats, a
+ 	 * modifier can be specified.  The default value of zero
+ 	 * indicates "native" format as specified by the fourcc.
+-	 * Vendor specific modifier token.  This allows, for example,
+-	 * different tiling/swizzling pattern on different planes.
+-	 * See discussion above of DRM_FORMAT_MOD_xxx.
++	 * Vendor specific modifier token.  Note that even though
++	 * it looks like we have a modifier per-plane, we in fact
++	 * do not. The modifier for each plane must be identical.
++	 * Thus all combinations of different data layouts for
++	 * multi plane formats must be enumerated as separate
++	 * modifiers.
+ 	 */
+ 	__u32 handles[4];
+ 	__u32 pitches[4]; /* pitch for each plane */
+ 	__u32 offsets[4]; /* offset of each plane */
+-	__u64 modifier[4]; /* ie, tiling, compressed (per plane) */
++	__u64 modifier[4]; /* ie, tiling, compress */
+ };
+ 
+ #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
+--
+libgit2 0.26.0
+
diff --git a/meta/meta-mediatek/recipes-graphics/libdrm/files/0002-Add-CRTC-ID-to-vblank-event.patch b/meta/meta-mediatek/recipes-graphics/libdrm/files/0002-Add-CRTC-ID-to-vblank-event.patch
new file mode 100644
index 0000000..1519dc2
--- /dev/null
+++ b/meta/meta-mediatek/recipes-graphics/libdrm/files/0002-Add-CRTC-ID-to-vblank-event.patch
@@ -0,0 +1,100 @@
+From 890d43a6a8d091211b82dd432af5e0a38472ffa6 Mon Sep 17 00:00:00 2001
+From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
+Date: Mon, 17 Aug 2015 16:21:24 +0300
+Subject: [PATCH] Add CRTC ID to vblank event
+
+When using the atomic API, one request can span multiple CRTCs, however
+one event is generated per CRTC. As we cannot disambiguate the CRTC with
+user data (since we only have one piece of user data to pass in), newer
+kernels can include the CRTC ID in the page flip event.
+
+Add a new vfunc to dispatch vblank events carrying a CRTC ID to clients
+who negotiate a higher interface version.
+
+[daniels: Rebased, include new cap, call page_flip_handler if it is set
+          but page_flip_handler2 isn't even on newer contexts, write a
+	  commit message.]
+
+v2: Split into separate commit.
+
+Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
+Signed-off-by: Daniel Stone <daniels@collabora.com>
+Reviewed-by: Maarten Lankhorst <maarten.lankhorst@intel.com>
+---
+ xf86drm.h     |  9 ++++++++-
+ xf86drmMode.c | 24 ++++++++++++++++--------
+ 2 files changed, 24 insertions(+), 9 deletions(-)
+
+diff --git a/xf86drm.h b/xf86drm.h
+index 0d92701..d75ca8c 100644
+--- a/xf86drm.h
++++ b/xf86drm.h
+@@ -728,7 +728,7 @@ extern void drmMsg(const char *format, ...) DRM_PRINTFLIKE(1, 2);
+ extern int drmSetMaster(int fd);
+ extern int drmDropMaster(int fd);
+ 
+-#define DRM_EVENT_CONTEXT_VERSION 2
++#define DRM_EVENT_CONTEXT_VERSION 3
+ 
+ typedef struct _drmEventContext {
+ 
+@@ -748,6 +748,13 @@ typedef struct _drmEventContext {
+ 				  unsigned int tv_usec,
+ 				  void *user_data);
+ 
++	void (*page_flip_handler2)(int fd,
++				   unsigned int sequence,
++				   unsigned int tv_sec,
++				   unsigned int tv_usec,
++				   unsigned int crtc_id,
++				   void *user_data);
++
+ } drmEventContext, *drmEventContextPtr;
+ 
+ extern int drmHandleEvent(int fd, drmEventContextPtr evctx);
+diff --git a/xf86drmMode.c b/xf86drmMode.c
+index 0266bc1..d3bc20e 100644
+--- a/xf86drmMode.c
++++ b/xf86drmMode.c
+@@ -889,6 +889,7 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx)
+ 	int len, i;
+ 	struct drm_event *e;
+ 	struct drm_event_vblank *vblank;
++	void *user_data;
+ 
+ 	/* The DRM read semantics guarantees that we always get only
+ 	 * complete events. */
+@@ -915,15 +916,22 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx)
+ 					      U642VOID (vblank->user_data));
+ 			break;
+ 		case DRM_EVENT_FLIP_COMPLETE:
+-			if (evctx->version < 2 ||
+-			    evctx->page_flip_handler == NULL)
+-				break;
+ 			vblank = (struct drm_event_vblank *) e;
+-			evctx->page_flip_handler(fd,
+-						 vblank->sequence,
+-						 vblank->tv_sec,
+-						 vblank->tv_usec,
+-						 U642VOID (vblank->user_data));
++			user_data = U642VOID (vblank->user_data);
++
++			if (evctx->version >= 3 && evctx->page_flip_handler2)
++				evctx->page_flip_handler2(fd,
++							 vblank->sequence,
++							 vblank->tv_sec,
++							 vblank->tv_usec,
++							 vblank->crtc_id,
++							 user_data);
++			else if (evctx->version >= 2 && evctx->page_flip_handler)
++				evctx->page_flip_handler(fd,
++							 vblank->sequence,
++							 vblank->tv_sec,
++							 vblank->tv_usec,
++							 user_data);
+ 			break;
+ 		default:
+ 			break;
+--
+libgit2 0.26.0
+