All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] weston: Consolidate i.MX GPU patches
@ 2017-01-25 14:57 Tom Hochstein
  0 siblings, 0 replies; only message in thread
From: Tom Hochstein @ 2017-01-25 14:57 UTC (permalink / raw)
  To: meta-freescale

This is a non-functional change with one small exception, an additional
variable initialization that has no known behavioral effect:

diff -wr weston-1.11.1/src/compositor-fbdev.c /home/r60874/tmp/weston/weston-1.11.1-old4/src/compositor-fbdev.c
922d921
<       config->clone_mode = 0;

Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
---
 ...2-ccc-Add-GPU-VIV-support-for-weston-1.11.patch |  135 ++
 ...d-GPU-VIV-suport-for-wayland-and-weston-1.patch | 1708 -----------------
 ...-ccc-Enable-g2d-renderer-for-weston-1.11.patch} | 1956 ++++----------------
 ...GS-1192-xwld-g2d-compositor-dose-not-work.patch |   28 -
 ...d-Add-clone-mode-support-for-multi-displ.patch} |  423 +----
 ...GS-1235-Fix-setenv-and-clear-environments.patch |   41 -
 ...8-xwld-System-can-not-boot-up-to-desktop.patch} |    8 +-
 ...x-for-Qt5_CinematicExperience-will-meet-s.patch |   93 -
 ...d-G2D-compositor-build-failed-in-slevk-b.patch} |  113 +-
 ...egl.patch => 0006-Link-compositor-to-egl.patch} |    0
 ...x6qp-imx6dl-First-frame-distored-when-som.patch |  106 --
 ...imx6qp-imx6dl-First-frame-distored-when-s.patch |   51 -
 ...-Fix-crash-when-run-with-no-input-device.patch} |    0
 ...xwld-Re-implement-weston-2d-renderer-with.patch |   36 -
 ...-Use-common-API-to-support-G2d-compositor.patch |  196 --
 ...014-MGS-1987-Get-stride-from-the-FB-buffe.patch |   76 -
 ...-MGS-2221-imx-171-Fix-weston-build-failed.patch |   62 -
 ...c-XWLD-T3DStressTest_Wayland-displays-abn.patch |   40 -
 ...c-Enable-double-buffer-with-fb_pan_displa.patch |   48 -
 recipes-graphics/wayland/weston_%.bbappend         |   25 +-
 20 files changed, 623 insertions(+), 4522 deletions(-)
 create mode 100644 recipes-graphics/wayland/weston/0001-MGS-2352-ccc-Add-GPU-VIV-support-for-weston-1.11.patch
 delete mode 100644 recipes-graphics/wayland/weston/0002-MGS-1111-Add-GPU-VIV-suport-for-wayland-and-weston-1.patch
 rename recipes-graphics/wayland/weston/{0009-MGS-1284-xwld-Re-implement-weston-2d-renderer-with-p.patch => 0002-MGS-2521-ccc-Enable-g2d-renderer-for-weston-1.11.patch} (42%)
 delete mode 100644 recipes-graphics/wayland/weston/0003-MGS-1192-xwld-g2d-compositor-dose-not-work.patch
 rename recipes-graphics/wayland/weston/{0012-MGS-1783-xwld-Add-clone-mode-support-for-multi-displ.patch => 0003-MGS-1783-xwld-Add-clone-mode-support-for-multi-displ.patch} (13%)
 delete mode 100644 recipes-graphics/wayland/weston/0004-MGS-1235-Fix-setenv-and-clear-environments.patch
 rename recipes-graphics/wayland/weston/{0019-MGS-1668-xwld-System-can-not-boot-up-to-desktop.patch => 0004-MGS-1668-xwld-System-can-not-boot-up-to-desktop.patch} (83%)
 delete mode 100644 recipes-graphics/wayland/weston/0005-MGS-1252-Fix-for-Qt5_CinematicExperience-will-meet-s.patch
 rename recipes-graphics/wayland/weston/{0011-MGS-1724-xwld-G2D-compositor-build-failed-in-slevk-b.patch => 0005-MGS-1724-xwld-G2D-compositor-build-failed-in-slevk-b.patch} (44%)
 rename recipes-graphics/wayland/weston/{0016-Link-compositor-to-egl.patch => 0006-Link-compositor-to-egl.patch} (100%)
 delete mode 100644 recipes-graphics/wayland/weston/0006-MGS-1236-imx6qp-imx6dl-First-frame-distored-when-som.patch
 delete mode 100644 recipes-graphics/wayland/weston/0007-MGS-1236-1-imx6qp-imx6dl-First-frame-distored-when-s.patch
 rename recipes-graphics/wayland/weston/{0020-xwayland-Fix-crash-when-run-with-no-input-device.patch => 0007-xwayland-Fix-crash-when-run-with-no-input-device.patch} (100%)
 delete mode 100644 recipes-graphics/wayland/weston/0010-MGS-1284-1-xwld-Re-implement-weston-2d-renderer-with.patch
 delete mode 100644 recipes-graphics/wayland/weston/0013-MGS-1945-Use-common-API-to-support-G2d-compositor.patch
 delete mode 100644 recipes-graphics/wayland/weston/0014-MGS-1987-Get-stride-from-the-FB-buffe.patch
 delete mode 100644 recipes-graphics/wayland/weston/0015-MGS-2221-imx-171-Fix-weston-build-failed.patch
 delete mode 100644 recipes-graphics/wayland/weston/0017-MGS-2343-ccc-XWLD-T3DStressTest_Wayland-displays-abn.patch
 delete mode 100644 recipes-graphics/wayland/weston/0018-MGS-2397-ccc-Enable-double-buffer-with-fb_pan_displa.patch

diff --git a/recipes-graphics/wayland/weston/0001-MGS-2352-ccc-Add-GPU-VIV-support-for-weston-1.11.patch b/recipes-graphics/wayland/weston/0001-MGS-2352-ccc-Add-GPU-VIV-support-for-weston-1.11.patch
new file mode 100644
index 0000000..37a2d4c
--- /dev/null
+++ b/recipes-graphics/wayland/weston/0001-MGS-2352-ccc-Add-GPU-VIV-support-for-weston-1.11.patch
@@ -0,0 +1,135 @@
+From dfad4d734412e4ec53bfff29c7c503479857f66c Mon Sep 17 00:00:00 2001
+From: Meng Mingming <mingming.meng@nxp.com>
+Date: Mon, 9 Jan 2017 15:04:27 +0800
+Subject: [PATCH 1/5] MGS-2352 [#ccc] Add GPU-VIV support for weston 1.11
+
+Add GPU-VIV support for weston 1.11
+
+Upstream Status: Inappropriate [i.MX specific]
+
+Date: Jan 09, 2017
+Signed-off-by: Meng Mingming <mingming.meng@nxp.com>
+---
+ src/compositor-fbdev.c | 37 ++++++++++++++++++++++++++++---------
+ 1 file changed, 28 insertions(+), 9 deletions(-)
+
+diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
+index ee762e3..06f4696 100644
+--- a/src/compositor-fbdev.c
++++ b/src/compositor-fbdev.c
+@@ -61,6 +61,7 @@ struct fbdev_backend {
+ 	int use_pixman;
+ 	uint32_t output_transform;
+ 	struct wl_listener session_listener;
++	NativeDisplayType display;
+ };
+ 
+ struct fbdev_screeninfo {
+@@ -93,6 +94,9 @@ struct fbdev_output {
+ 	/* pixman details. */
+ 	pixman_image_t *hw_surface;
+ 	uint8_t depth;
++
++	NativeDisplayType display;
++	NativeWindowType  window;
+ };
+ 
+ struct gl_renderer_interface *gl_renderer;
+@@ -443,6 +447,10 @@ fbdev_frame_buffer_destroy(struct fbdev_output *output)
+ 		           strerror(errno));
+ 
+ 	output->fb = NULL;
++	if(output->window)
++		fbDestroyWindow(output->window);
++	if(output->display)
++		fbDestroyDisplay(output->display);
+ }
+ 
+ static void fbdev_output_destroy(struct weston_output *base);
+@@ -450,13 +458,13 @@ static void fbdev_output_disable(struct weston_output *base);
+ 
+ static int
+ fbdev_output_create(struct fbdev_backend *backend,
+-                    const char *device)
++                   int x, int y, const char *device)
+ {
+ 	struct fbdev_output *output;
+ 	int fb_fd;
+ 	struct wl_event_loop *loop;
+ 
+-	weston_log("Creating fbdev output.\n");
++	weston_log("Creating fbdev output. %s x=%d y=%d\n", device, x, y);
+ 
+ 	output = zalloc(sizeof *output);
+ 	if (output == NULL)
+@@ -500,7 +508,7 @@ fbdev_output_create(struct fbdev_backend *backend,
+ 	output->base.name = strdup("fbdev");
+ 
+ 	weston_output_init(&output->base, backend->compositor,
+-	                   0, 0, output->fb_info.width_mm,
++	                   x, y, output->fb_info.width_mm,
+ 	                   output->fb_info.height_mm,
+ 	                   backend->output_transform,
+ 			   1);
+@@ -510,8 +518,13 @@ fbdev_output_create(struct fbdev_backend *backend,
+ 			goto out_hw_surface;
+ 	} else {
+ 		setenv("HYBRIS_EGLPLATFORM", "wayland", 1);
++		output->window = fbCreateWindow(backend->display, -1, -1, 0, 0);
++		if (output->window == NULL) {
++			fprintf(stderr, "failed to create window\n");
++			return 0;
++		}
+ 		if (gl_renderer->output_create(&output->base,
+-					       (EGLNativeWindowType)NULL, NULL,
++					       (EGLNativeWindowType)output->window, NULL,
+ 					       gl_renderer->opaque_attribs,
+ 					       NULL, 0) < 0) {
+ 			weston_log("gl_renderer_output_create failed.\n");
+@@ -622,7 +635,7 @@ fbdev_output_reenable(struct fbdev_backend *backend,
+ 		 * are re-initialised. */
+ 		device = strdup(output->device);
+ 		fbdev_output_destroy(&output->base);
+-		fbdev_output_create(backend, device);
++		fbdev_output_create(backend, 0, 0, device);
+ 		free(device);
+ 
+ 		return 0;
+@@ -785,17 +798,21 @@ fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv
+ 			goto out_launcher;
+ 		}
+ 
++		backend->display = fbGetDisplay(backend->compositor->wl_display);
++		if (backend->display == NULL) {
++			weston_log("fbGetDisplay failed.\n");
++			goto out_launcher;
++		}
+ 		if (gl_renderer->create(compositor, NO_EGL_PLATFORM,
+-					EGL_DEFAULT_DISPLAY,
++					backend->display,
+ 					gl_renderer->opaque_attribs,
+ 					NULL, 0) < 0) {
+ 			weston_log("gl_renderer_create failed.\n");
+ 			goto out_launcher;
+ 		}
+ 	}
+-
+-	if (fbdev_output_create(backend, param->device) < 0)
+-		goto out_launcher;
++	if (fbdev_output_create(backend, 0, 0, param->device) < 0)
++			goto out_launcher;
+ 
+ 	udev_input_init(&backend->input, compositor, backend->udev, seat_id);
+ 
+@@ -844,6 +861,8 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
+ 	config_init_to_defaults(&config);
+ 	memcpy(&config, config_base, config_base->struct_size);
+ 
++	config.use_gl = 1;
++
+ 	b = fbdev_backend_create(compositor, argc, argv, wc, &config);
+ 	if (b == NULL)
+ 		return -1;
+-- 
+2.7.4
+
diff --git a/recipes-graphics/wayland/weston/0002-MGS-1111-Add-GPU-VIV-suport-for-wayland-and-weston-1.patch b/recipes-graphics/wayland/weston/0002-MGS-1111-Add-GPU-VIV-suport-for-wayland-and-weston-1.patch
deleted file mode 100644
index cfe8f60..0000000
--- a/recipes-graphics/wayland/weston/0002-MGS-1111-Add-GPU-VIV-suport-for-wayland-and-weston-1.patch
+++ /dev/null
@@ -1,1708 +0,0 @@
-From e766967ae24d15048c01d03de09fc39757d13ec3 Mon Sep 17 00:00:00 2001
-From: Prabhu <prabhu.sundararaj@freescale.com>
-Date: Sat, 3 Oct 2015 19:44:33 -0500
-Subject: [PATCH] MGS-1111: Add GPU-VIV suport for wayland and weston 1.9
-
-Add support GPU-VIV support for weston 1.9
-
-Signed-off-by: Prabhu <prabhu.sundararaj@freescale.com>
----
- Makefile.am            |   12 +
- src/compositor-fbdev.c |  128 ++++-
- src/gal2d-renderer.c   | 1342 ++++++++++++++++++++++++++++++++++++++++++++++++
- src/gal2d-renderer.h   |   50 ++
- 4 files changed, 1519 insertions(+), 13 deletions(-)
- create mode 100644 src/gal2d-renderer.c
- create mode 100644 src/gal2d-renderer.h
-
-Index: weston-1.11.1/Makefile.am
-===================================================================
---- weston-1.11.1.orig/Makefile.am	2016-09-20 19:35:22.000000000 -0500
-+++ weston-1.11.1/Makefile.am	2017-01-14 08:35:10.000000000 -0600
-@@ -247,6 +247,18 @@
- 	src/vertex-clipping.h			\
- 	shared/helpers.h
- endif
-+module_LTLIBRARIES += gal2d-renderer.la
-+gal2d_renderer_la_LDFLAGS = -module -avoid-version
-+gal2d_renderer_la_LIBADD = $(COMPOSITOR_LIBS) $(EGL_LIBS)
-+gal2d_renderer_la_CFLAGS =			\
-+	$(COMPOSITOR_CFLAGS)			\
-+	$(EGL_CFLAGS)				\
-+	$(GCC_CFLAGS)
-+gal2d_renderer_la_SOURCES =			\
-+	src/gal2d-renderer.h			\
-+	src/gal2d-renderer.c			\
-+	src/vertex-clipping.c			\
-+	src/vertex-clipping.h
- 
- if ENABLE_X11_COMPOSITOR
- module_LTLIBRARIES += x11-backend.la
-Index: weston-1.11.1/src/compositor-fbdev.c
-===================================================================
---- weston-1.11.1.orig/src/compositor-fbdev.c	2016-09-20 19:35:22.000000000 -0500
-+++ weston-1.11.1/src/compositor-fbdev.c	2017-01-14 08:35:11.000000000 -0600
-@@ -50,6 +50,7 @@
- #include "libinput-seat.h"
- #include "gl-renderer.h"
- #include "presentation-time-server-protocol.h"
-+#include "gal2d-renderer.h"
- 
- struct fbdev_backend {
- 	struct weston_backend base;
-@@ -59,8 +60,10 @@
- 	struct udev *udev;
- 	struct udev_input input;
- 	int use_pixman;
-+	int use_gal2d;
- 	uint32_t output_transform;
- 	struct wl_listener session_listener;
-+	NativeDisplayType display;
- };
- 
- struct fbdev_screeninfo {
-@@ -93,9 +96,13 @@
- 	/* pixman details. */
- 	pixman_image_t *hw_surface;
- 	uint8_t depth;
-+
-+	NativeDisplayType display;
-+	NativeWindowType  window;
- };
- 
- struct gl_renderer_interface *gl_renderer;
-+struct gal2d_renderer_interface *gal2d_renderer;
- 
- static const char default_seat[] = "seat0";
- 
-@@ -443,6 +450,10 @@
- 		           strerror(errno));
- 
- 	output->fb = NULL;
-+	if(output->window)
-+		fbDestroyWindow(output->window);
-+	if(output->display)
-+		fbDestroyDisplay(output->display);
- }
- 
- static void fbdev_output_destroy(struct weston_output *base);
-@@ -450,13 +461,13 @@
- 
- static int
- fbdev_output_create(struct fbdev_backend *backend,
--                    const char *device)
-+                   int x, int y, const char *device)
- {
- 	struct fbdev_output *output;
- 	int fb_fd;
- 	struct wl_event_loop *loop;
- 
--	weston_log("Creating fbdev output.\n");
-+	weston_log("Creating fbdev output. %s x=%d y=%d\n", device, x, y);
- 
- 	output = zalloc(sizeof *output);
- 	if (output == NULL)
-@@ -500,7 +511,7 @@
- 	output->base.name = strdup("fbdev");
- 
- 	weston_output_init(&output->base, backend->compositor,
--	                   0, 0, output->fb_info.width_mm,
-+	                   x, y, output->fb_info.width_mm,
- 	                   output->fb_info.height_mm,
- 	                   backend->output_transform,
- 			   1);
-@@ -508,10 +519,39 @@
- 	if (backend->use_pixman) {
- 		if (pixman_renderer_output_create(&output->base) < 0)
- 			goto out_hw_surface;
-+	} else if(backend->use_gal2d) {
-+
-+		char* fbenv = getenv("FB_FRAMEBUFFER_0");
-+		setenv("FB_FRAMEBUFFER_0", device, 1);
-+		output->display = fbGetDisplay(backend->compositor->wl_display);
-+		if (output->display == NULL) {
-+			fprintf(stderr, "failed to get display\n");
-+			return 0;
-+		}
-+
-+		output->window = fbCreateWindow(output->display, -1, -1, 0, 0);
-+		if (output->window == NULL) {
-+			fprintf(stderr, "failed to create window\n");
-+			 return 0;
-+		}
-+		setenv("FB_FRAMEBUFFER_0", fbenv, 1);
-+
-+		if (gal2d_renderer->output_create(&output->base,
-+					output->display,
-+					(NativeWindowType)output->window) < 0) {
-+			weston_log("gal_renderer_output_create failed.\n");
-+			goto out_hw_surface;
-+		}
-+
- 	} else {
- 		setenv("HYBRIS_EGLPLATFORM", "wayland", 1);
-+		output->window = fbCreateWindow(backend->display, -1, -1, 0, 0);
-+		if (output->window == NULL) {
-+			fprintf(stderr, "failed to create window\n");
-+			return 0;
-+		}
- 		if (gl_renderer->output_create(&output->base,
--					       (EGLNativeWindowType)NULL, NULL,
-+					       (EGLNativeWindowType)output->window, NULL,
- 					       gl_renderer->opaque_attribs,
- 					       NULL, 0) < 0) {
- 			weston_log("gl_renderer_output_create failed.\n");
-@@ -558,6 +598,8 @@
- 	if (backend->use_pixman) {
- 		if (base->renderer_state != NULL)
- 			pixman_renderer_output_destroy(base);
-+	} else if (backend->use_gal2d) {
-+		gal2d_renderer->output_destroy(base);
- 	} else {
- 		gl_renderer->output_destroy(base);
- 	}
-@@ -622,7 +664,7 @@
- 		 * are re-initialised. */
- 		device = strdup(output->device);
- 		fbdev_output_destroy(&output->base);
--		fbdev_output_create(backend, device);
-+		fbdev_output_create(backend, 0, 0, device);
- 		free(device);
- 
- 		return 0;
-@@ -777,7 +819,50 @@
- 	if (backend->use_pixman) {
- 		if (pixman_renderer_init(compositor) < 0)
- 			goto out_launcher;
--	} else {
-+	}
-+	else if (backend->use_gal2d) {
-+		int x = 0, y = 0;
-+		int i=0;
-+		int count = 0;
-+		int k=0, dispCount = 0;
-+		char displays[5][32];
-+		gal2d_renderer = weston_load_module("gal2d-renderer.so",
-+						 "gal2d_renderer_interface");
-+		if (!gal2d_renderer) {
-+			weston_log("could not load gal2d renderer\n");
-+			goto out_launcher;
-+		}
-+
-+		if (gal2d_renderer->create(backend->compositor) < 0) {
-+			weston_log("gal2d_renderer_create failed.\n");
-+			goto out_launcher;
-+		}
-+
-+		weston_log("param->device=%s\n",param->device);
-+		count = strlen(param->device);
-+
-+		for(i= 0; i < count; i++) {
-+			if(param->device[i] == ',')	{
-+				displays[dispCount][k] = '\0';
-+				dispCount++;
-+				k = 0;
-+				continue;
-+			}
-+			displays[dispCount][k++] = param->device[i];
-+		}
-+		displays[dispCount][k] = '\0';
-+		dispCount++;
-+
-+		for(i=0; i<dispCount; i++)
-+		{
-+			if (fbdev_output_create(backend, x, y, displays[i]) < 0)
-+				goto out_launcher;
-+			x += container_of(backend->compositor->output_list.prev,
-+								  struct weston_output,
-+								  link)->width;
-+		}
-+	}
-+	 else {
- 		gl_renderer = weston_load_module("gl-renderer.so",
- 						 "gl_renderer_interface");
- 		if (!gl_renderer) {
-@@ -785,17 +870,22 @@
- 			goto out_launcher;
- 		}
- 
-+		backend->display = fbGetDisplay(backend->compositor->wl_display);
-+		if (backend->display == NULL) {
-+			weston_log("fbGetDisplay failed.\n");
-+			goto out_launcher;
-+		}
- 		if (gl_renderer->create(compositor, NO_EGL_PLATFORM,
--					EGL_DEFAULT_DISPLAY,
-+					backend->display,
- 					gl_renderer->opaque_attribs,
- 					NULL, 0) < 0) {
- 			weston_log("gl_renderer_create failed.\n");
- 			goto out_launcher;
- 		}
- 	}
--
--	if (fbdev_output_create(backend, param->device) < 0)
--		goto out_launcher;
-+	if(!backend->use_gal2d)
-+		if (fbdev_output_create(backend, 0, 0, param->device) < 0)
-+			goto out_launcher;
- 
- 	udev_input_init(&backend->input, compositor, backend->udev, seat_id);
- 
-@@ -822,7 +912,13 @@
- 	 * udev, rather than passing a device node in as a parameter. */
- 	config->tty = 0; /* default to current tty */
- 	config->device = "/dev/fb0"; /* default frame buffer */
-+#ifdef ENABLE_EGL
-+	config->use_gl = 1;
-+	config->use_gal2d = 0;
-+#else
- 	config->use_gl = 0;
-+	config->use_gal2d = 1;
-+#endif
- 	config->output_transform = WL_OUTPUT_TRANSFORM_NORMAL;
- }
- 
-Index: weston-1.11.1/src/gal2d-renderer.c
-===================================================================
---- /dev/null	1970-01-01 00:00:00.000000000 +0000
-+++ weston-1.11.1/src/gal2d-renderer.c	2017-01-14 08:35:10.000000000 -0600
-@@ -0,0 +1,1342 @@
-+/*
-+ * Copyright (c) 2015 Freescale Semiconductor, Inc.
-+ * Copyright © 2012 Intel Corporation
-+ * Copyright © 2015 Collabora, Ltd.
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining
-+ * a copy of this software and associated documentation files (the
-+ * "Software"), to deal in the Software without restriction, including
-+ * without limitation the rights to use, copy, modify, merge, publish,
-+ * distribute, sublicense, and/or sell copies of the Software, and to
-+ * permit persons to whom the Software is furnished to do so, subject to
-+ * the following conditions:
-+ *
-+ * The above copyright notice and this permission notice (including the
-+ * next paragraph) shall be included in all copies or substantial
-+ * portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-+ * SOFTWARE.
-+ */
-+
-+#define _GNU_SOURCE
-+
-+#include <stdlib.h>
-+#include <string.h>
-+#include <ctype.h>
-+#include <float.h>
-+#include <assert.h>
-+#include <pthread.h>
-+
-+#include "compositor.h"
-+#include "gal2d-renderer.h"
-+#include "vertex-clipping.h"
-+#include "shared/helpers.h"
-+#include "HAL/gc_hal.h"
-+#include "HAL/gc_hal_raster.h"
-+#include "HAL/gc_hal_eglplatform.h"
-+
-+#define galONERROR(x)  if(status < 0) printf("Error in function %s\n", __func__);
-+
-+struct gal2d_output_state {
-+	
-+	int current_buffer;
-+	pixman_region32_t buffer_damage[2];
-+	NativeDisplayType display;
-+    gcoSURF* renderSurf;
-+	gctUINT32 nNumBuffers;
-+	int activebuffer;
-+	gcoSURF offscreenSurface;
-+	gceSURF_FORMAT format;
-+    pthread_mutex_t workerMutex;
-+    pthread_t workerId;
-+    gctUINT32 exitWorker;
-+    gctSIGNAL signal;
-+    gctSIGNAL busySignal;
-+    gcsHAL_INTERFACE iface;
-+    int directBlit;
-+    gctINT width;
-+    gctINT height;
-+};
-+
-+struct gal2d_surface_state {
-+	float color[4];
-+	struct weston_buffer_reference buffer_ref;
-+	int pitch; /* in pixels */
-+    pixman_region32_t texture_damage;
-+    gcoSURF gco_Surface;
-+
-+    struct weston_surface *surface;
-+    struct wl_listener surface_destroy_listener;
-+    struct wl_listener renderer_destroy_listener;
-+};
-+
-+struct gal2d_renderer {
-+	struct weston_renderer base;
-+    struct wl_signal destroy_signal;
-+    gcoOS gcos;
-+	gcoHAL gcoHal;
-+	gco2D gcoEngine2d;
-+    gctPOINTER  localInfo;
-+};
-+
-+static int
-+gal2d_renderer_create_surface(struct weston_surface *surface);
-+
-+static inline struct gal2d_surface_state *
-+get_surface_state(struct weston_surface *surface)
-+{
-+	if (!surface->renderer_state)
-+		gal2d_renderer_create_surface(surface);
-+	return (struct gal2d_surface_state *)surface->renderer_state;
-+}
-+
-+static inline struct gal2d_renderer *
-+get_renderer(struct weston_compositor *ec)
-+{
-+	return (struct gal2d_renderer *)ec->renderer;
-+}
-+
-+
-+
-+#define max(a, b) (((a) > (b)) ? (a) : (b))
-+#define min(a, b) (((a) > (b)) ? (b) : (a))
-+/*
-+ * Compute the boundary vertices of the intersection of the global coordinate
-+ * aligned rectangle 'rect', and an arbitrary quadrilateral produced from
-+ * 'surf_rect' when transformed from surface coordinates into global coordinates.
-+ * The vertices are written to 'ex' and 'ey', and the return value is the
-+ * number of vertices. Vertices are produced in clockwise winding order.
-+ * Guarantees to produce either zero vertices, or 3-8 vertices with non-zero
-+ * polygon area.
-+ */
-+static int
-+calculate_edges(struct weston_view *ev, pixman_box32_t *rect,
-+		pixman_box32_t *surf_rect, float *ex, float *ey)
-+{
-+
-+	struct clip_context ctx;
-+	int i, n;
-+	float min_x, max_x, min_y, max_y;
-+	struct polygon8 surf = {
-+		{ surf_rect->x1, surf_rect->x2, surf_rect->x2, surf_rect->x1 },
-+		{ surf_rect->y1, surf_rect->y1, surf_rect->y2, surf_rect->y2 },
-+		4
-+	};
-+
-+	ctx.clip.x1 = rect->x1;
-+	ctx.clip.y1 = rect->y1;
-+	ctx.clip.x2 = rect->x2;
-+	ctx.clip.y2 = rect->y2;
-+
-+	/* transform surface to screen space: */
-+	for (i = 0; i < surf.n; i++)
-+		weston_view_to_global_float(ev, surf.x[i], surf.y[i],
-+					    &surf.x[i], &surf.y[i]);
-+
-+	/* find bounding box: */
-+	min_x = max_x = surf.x[0];
-+	min_y = max_y = surf.y[0];
-+
-+	for (i = 1; i < surf.n; i++) {
-+		min_x = min(min_x, surf.x[i]);
-+		max_x = max(max_x, surf.x[i]);
-+		min_y = min(min_y, surf.y[i]);
-+		max_y = max(max_y, surf.y[i]);
-+	}
-+
-+	/* First, simple bounding box check to discard early transformed
-+	 * surface rects that do not intersect with the clip region:
-+	 */
-+	if ((min_x >= ctx.clip.x2) || (max_x <= ctx.clip.x1) ||
-+	    (min_y >= ctx.clip.y2) || (max_y <= ctx.clip.y1))
-+		return 0;
-+
-+	/* Simple case, bounding box edges are parallel to surface edges,
-+	 * there will be only four edges.  We just need to clip the surface
-+	 * vertices to the clip rect bounds:
-+	 */
-+	if (!ev->transform.enabled)
-+		return clip_simple(&ctx, &surf, ex, ey);
-+
-+	/* Transformed case: use a general polygon clipping algorithm to
-+	 * clip the surface rectangle with each side of 'rect'.
-+	 * The algorithm is Sutherland-Hodgman, as explained in
-+	 * http://www.codeguru.com/cpp/misc/misc/graphics/article.php/c8965/Polygon-Clipping.htm
-+	 * but without looking at any of that code.
-+	 */
-+	n = clip_transformed(&ctx, &surf, ex, ey);
-+
-+	if (n < 3)
-+		return 0;
-+
-+	return n;
-+}
-+
-+
-+static inline struct gal2d_output_state *
-+get_output_state(struct weston_output *output)
-+{
-+	return (struct gal2d_output_state *)output->renderer_state;
-+}
-+
-+static gctUINT32
-+galGetStretchFactor(gctINT32 SrcSize, gctINT32 DestSize)
-+{
-+	gctUINT stretchFactor;
-+	if ( (SrcSize > 0) && (DestSize > 1) )
-+	{
-+		stretchFactor = ((SrcSize - 1) << 16) / (DestSize - 1);
-+	}
-+	else
-+	{
-+		stretchFactor = 0;
-+	}
-+	return stretchFactor;
-+}
-+
-+static gceSTATUS
-+galGetStretchFactors(
-+	IN gcsRECT_PTR SrcRect,
-+	IN gcsRECT_PTR DestRect,
-+	OUT gctUINT32 * HorFactor,
-+	OUT gctUINT32 * VerFactor
-+	)
-+{
-+	if (HorFactor != gcvNULL)
-+	{
-+        gctINT32 src, dest;
-+
-+        /* Compute width of rectangles. */
-+        gcmVERIFY_OK(gcsRECT_Width(SrcRect, &src));
-+        gcmVERIFY_OK(gcsRECT_Width(DestRect, &dest));
-+
-+        /* Compute and return horizontal stretch factor. */
-+		*HorFactor = galGetStretchFactor(src, dest);
-+	}
-+
-+	if (VerFactor != gcvNULL)
-+	{
-+		gctINT32 src, dest;
-+
-+		/* Compute height of rectangles. */
-+		gcmVERIFY_OK(gcsRECT_Height(SrcRect, &src));
-+		gcmVERIFY_OK(gcsRECT_Height(DestRect, &dest));
-+
-+		/* Compute and return vertical stretch factor. */
-+		*VerFactor = galGetStretchFactor(src, dest);
-+	}
-+    /* Success. */
-+    return gcvSTATUS_OK;
-+}
-+
-+static gceSTATUS
-+gal2d_getSurfaceFormat(halDISPLAY_INFO info, gceSURF_FORMAT * Format)
-+{
-+	/* Get the color format. */
-+    switch (info.greenLength)
-+    {
-+    case 4:
-+        if (info.blueOffset == 0)
-+        {
-+            *Format = (info.alphaLength == 0) ? gcvSURF_X4R4G4B4 : gcvSURF_A4R4G4B4;
-+        }
-+        else
-+        {
-+            *Format = (info.alphaLength == 0) ? gcvSURF_X4B4G4R4 : gcvSURF_A4B4G4R4;
-+        }
-+        break;
-+
-+    case 5:
-+        if (info.blueOffset == 0)
-+        {
-+            *Format = (info.alphaLength == 0) ? gcvSURF_X1R5G5B5 : gcvSURF_A1R5G5B5;
-+        }
-+        else
-+        {
-+            *Format = (info.alphaLength == 0) ? gcvSURF_X1B5G5R5 : gcvSURF_A1B5G5R5;
-+        }
-+        break;
-+
-+    case 6:
-+        *Format = gcvSURF_R5G6B5;
-+        break;
-+
-+    case 8:
-+        if (info.blueOffset == 0)
-+        {
-+            *Format = (info.alphaLength == 0) ? gcvSURF_X8R8G8B8 : gcvSURF_A8R8G8B8;
-+        }
-+        else
-+        {
-+            *Format = (info.alphaLength == 0) ? gcvSURF_X8B8G8R8 : gcvSURF_A8B8G8R8;
-+        }
-+        break;
-+
-+    default:
-+        /* Unsupported color depth. */
-+        return gcvSTATUS_INVALID_ARGUMENT;
-+    }
-+	/* Success. */
-+    return gcvSTATUS_OK;
-+}
-+
-+static gceSTATUS galIsYUVFormat(IN gceSURF_FORMAT Format)
-+{
-+    switch (Format)
-+    {
-+    case gcvSURF_YUY2:
-+    case gcvSURF_UYVY:
-+    case gcvSURF_I420:
-+    case gcvSURF_YV12:
-+    case gcvSURF_NV16:
-+    case gcvSURF_NV12:
-+    case gcvSURF_NV61:
-+    case gcvSURF_NV21:
-+
-+        return gcvSTATUS_TRUE;
-+
-+    default:
-+        return gcvSTATUS_FALSE;
-+    }
-+}
-+
-+static gceSTATUS galQueryUVStride(
-+    IN gceSURF_FORMAT Format,
-+    IN gctUINT32 yStride,
-+    OUT gctUINT32_PTR uStride,
-+    OUT gctUINT32_PTR vStride
-+    )
-+{
-+    switch (Format)
-+    {
-+    case gcvSURF_YUY2:
-+    case gcvSURF_UYVY:
-+        *uStride = *vStride = 0;
-+        break;
-+
-+    case gcvSURF_I420:
-+    case gcvSURF_YV12:
-+        *uStride = *vStride = yStride / 2;
-+        break;
-+
-+    case gcvSURF_NV16:
-+    case gcvSURF_NV12:
-+    case gcvSURF_NV61:
-+    case gcvSURF_NV21:
-+
-+        *uStride = yStride;
-+        *vStride = 0;
-+        break;
-+
-+    default:
-+        return gcvSTATUS_NOT_SUPPORTED;
-+    }
-+
-+    return gcvSTATUS_OK;
-+}
-+
-+static int
-+make_current(struct gal2d_renderer *gr, gcoSURF surface)
-+{    
-+	gceSTATUS status = gcvSTATUS_OK;
-+	gctUINT width = 0;
-+	gctUINT height = 0;
-+	gctINT stride = 0;
-+	gctUINT32 physical[3];
-+	gctPOINTER va =0;
-+    gceSURF_FORMAT format;
-+
-+	if(!surface)
-+		goto OnError;
-+    
-+
-+	gcmONERROR(gcoSURF_GetAlignedSize(surface, &width, &height, &stride));
-+    gcmONERROR(gcoSURF_GetFormat(surface, gcvNULL, &format));
-+	gcmONERROR(gcoSURF_Lock(surface, &physical[0], (gctPOINTER *)&va));    
-+    gco2D_SetGenericTarget(gr->gcoEngine2d, 
-+                        &physical[0], 1, 
-+                        &stride, 1, 
-+                        gcvLINEAR, format,
-+                        gcvSURF_0_DEGREE, width, height);
-+	
-+	gcmONERROR(gcoSURF_Unlock(surface, (gctPOINTER *)&va));
-+OnError:
-+    galONERROR(status);
-+	return status;
-+}
-+
-+static gceSTATUS
-+gal2d_clear(struct weston_output *base)
-+{
-+    struct gal2d_renderer *gr = get_renderer(base->compositor);
-+	struct gal2d_output_state *go = get_output_state(base);    
-+	gceSTATUS status = gcvSTATUS_OK;
-+	
-+	gctINT stride = 0;
-+	gctUINT width = 0, height = 0;
-+	gcsRECT dstRect = {0};
-+	gcmONERROR(gcoSURF_GetAlignedSize(go->renderSurf[go->activebuffer],
-+					&width, &height, &stride));
-+	dstRect.right = width;
-+	dstRect.bottom = height;
-+	gcmONERROR(gco2D_SetSource(gr->gcoEngine2d, &dstRect));
-+	gcmONERROR(gco2D_SetClipping(gr->gcoEngine2d, &dstRect));
-+	gcmONERROR(gco2D_Clear(gr->gcoEngine2d, 1, &dstRect, 0xff0000ff, 0xCC, 0xCC, go->format));
-+    gcmONERROR(gcoHAL_Commit(gr->gcoHal, gcvTRUE));
-+
-+OnError:
-+	galONERROR(status);
-+    
-+	return status;
-+}
-+
-+static gcoSURF getSurfaceFromShm(struct weston_surface *es, struct weston_buffer *buffer)
-+{	
-+    struct gal2d_renderer *gr = get_renderer(es->compositor);
-+	
-+	gcoSURF surface = 0;
-+	gceSURF_FORMAT format;
-+	gcePOOL pool = gcvPOOL_DEFAULT;
-+
-+	if (wl_shm_buffer_get_format(buffer->shm_buffer) == WL_SHM_FORMAT_XRGB8888)
-+		format = gcvSURF_X8R8G8B8;
-+	else
-+		format = gcvSURF_A8R8G8B8;
-+
-+	if(buffer->width == ((buffer->width + 0x7) & ~0x7))
-+	{
-+		pool = gcvPOOL_USER;
-+	}
-+
-+	gcmVERIFY_OK(gcoSURF_Construct(gr->gcoHal,
-+						  (gctUINT) buffer->width,
-+						  (gctUINT) buffer->height,
-+						  1, gcvSURF_BITMAP,
-+						  format, pool, &surface));
-+
-+	if(pool == gcvPOOL_USER)
-+	{
-+		gcmVERIFY_OK(gcoSURF_MapUserSurface(surface, 1,
-+					(gctPOINTER)wl_shm_buffer_get_data(buffer->shm_buffer), gcvINVALID_ADDRESS));
-+	}
-+
-+	return surface;
-+}
-+
-+static int
-+gal2dBindBuffer(struct weston_surface* es)
-+{
-+    struct gal2d_surface_state *gs = get_surface_state(es);
-+	gceSTATUS status = gcvSTATUS_OK;
-+	gcoSURF surface = gs->gco_Surface;	
-+    struct weston_buffer *buffer = gs->buffer_ref.buffer;
-+	gcePOOL pool = gcvPOOL_DEFAULT;
-+    
-+	gcmVERIFY_OK(gcoSURF_QueryVidMemNode(surface, gcvNULL,
-+						&pool, gcvNULL));
-+
-+	if(pool != gcvPOOL_USER)
-+	{
-+		gctUINT alignedWidth;
-+		gctPOINTER logical = (gctPOINTER)wl_shm_buffer_get_data(buffer->shm_buffer);
-+		gctPOINTER va =0;
-+
-+
-+		gcmVERIFY_OK(gcoSURF_GetAlignedSize(surface, &alignedWidth, gcvNULL, gcvNULL));
-+		gcmVERIFY_OK(gcoSURF_Lock(surface, gcvNULL, (gctPOINTER *)&va));
-+      
-+		if(alignedWidth == (unsigned int)buffer->width)
-+		{
-+			int size = wl_shm_buffer_get_stride(buffer->shm_buffer)*buffer->height;
-+			memcpy(va, logical, size);
-+		}
-+		else
-+		{
-+			int i, j;
-+			for (i = 0; i < buffer->height; i++)
-+			{
-+				for (j = 0; j < buffer->width; j++)
-+				{
-+					gctUINT dstOff = i * alignedWidth + j;
-+					gctUINT srcOff = (i * buffer->width + j);
-+
-+					memcpy(va + dstOff * 4, logical + srcOff * 4, 4);
-+				}
-+			}
-+		}
-+		gcmVERIFY_OK(gcoSURF_Unlock(surface, (gctPOINTER)va));
-+	}
-+
-+	return status;
-+}
-+
-+static void
-+gal2d_flip_surface(struct weston_output *output)
-+{
-+	struct gal2d_output_state *go = get_output_state(output);
-+
-+	if(go->nNumBuffers > 1)
-+	{
-+		gctUINT Offset;
-+		gctINT X;
-+		gctINT Y;
-+
-+		gcmVERIFY_OK(gcoOS_GetDisplayBackbuffer(go->display, gcvNULL,
-+									gcvNULL, gcvNULL, &Offset, &X, &Y));
-+
-+		gcmVERIFY_OK(gcoOS_SetDisplayVirtual(go->display, gcvNULL,
-+									Offset, X, Y));
-+	}
-+}
-+
-+static void *gal2d_output_worker(void *arg)
-+{
-+    struct weston_output *output = (struct weston_output *)arg;
-+    struct gal2d_output_state *go = get_output_state(output);
-+
-+    while(1)
-+    {
-+        if(gcoOS_WaitSignal(gcvNULL, go->signal, gcvINFINITE) == gcvSTATUS_OK )
-+        {
-+            gal2d_flip_surface(output);
-+            gcoOS_Signal(gcvNULL,go->busySignal, gcvTRUE);
-+        }
-+        pthread_mutex_lock(&go->workerMutex);
-+        if(go->exitWorker == 1)
-+        {
-+            pthread_mutex_unlock(&go->workerMutex);
-+            break;
-+        }
-+        pthread_mutex_unlock(&go->workerMutex);
-+    }
-+    return 0;
-+}
-+
-+static int
-+update_surface(struct weston_output *output)
-+{
-+    struct gal2d_renderer *gr = get_renderer(output->compositor);
-+    struct gal2d_output_state *go = get_output_state(output);
-+    gceSTATUS status = gcvSTATUS_OK;
-+
-+    if(go->nNumBuffers == 1)
-+    {
-+        if(!go->directBlit && go->offscreenSurface)
-+        {
-+            make_current(gr, go->renderSurf[go->activebuffer]);
-+
-+            gctUINT srcWidth = 0;
-+            gctUINT srcHeight = 0;
-+            gceSURF_FORMAT srcFormat;;
-+            gcsRECT dstRect = {0};
-+            gcoSURF srcSurface = go->offscreenSurface;
-+            gctUINT32 srcPhyAddr[3];
-+            gctUINT32 srcStride[3];
-+
-+            gctPOINTER va =0;
-+
-+            gcmONERROR(gcoSURF_GetAlignedSize(srcSurface, &srcWidth, &srcHeight, (gctINT *)&srcStride[0]));
-+            gcmONERROR(gcoSURF_GetFormat(srcSurface, gcvNULL, &srcFormat));
-+
-+            gcmONERROR(gcoSURF_Lock(srcSurface, srcPhyAddr, (gctPOINTER *)&va));
-+            gcmONERROR(gco2D_SetCurrentSourceIndex(gr->gcoEngine2d, 0U));
-+
-+            gco2D_SetGenericSource(gr->gcoEngine2d, srcPhyAddr, 1,
-+				        srcStride, 1,
-+				        gcvLINEAR, srcFormat, gcvSURF_0_DEGREE,
-+				        srcWidth, srcHeight);
-+
-+            dstRect.left 	= 0;
-+            dstRect.top		= 0;
-+            dstRect.right 	= srcWidth;
-+            dstRect.bottom 	= srcHeight;
-+
-+            gcmONERROR(gco2D_SetSource(gr->gcoEngine2d, &dstRect));
-+            gcmONERROR(gco2D_SetClipping(gr->gcoEngine2d, &dstRect));
-+            gcmONERROR(gco2D_Blit(gr->gcoEngine2d, 1, &dstRect, 0xCC, 0xCC, go->format));
-+            gcmONERROR(gcoSURF_Unlock(srcSurface, (gctPOINTER *)&va));
-+        }
-+		gcmONERROR(gcoHAL_Commit(gr->gcoHal, gcvFALSE));
-+	}
-+    else if(go->nNumBuffers > 1)
-+    {
-+        gcoHAL_ScheduleEvent(gr->gcoHal, &go->iface);
-+        gcmVERIFY_OK(gcoHAL_Commit(gr->gcoHal, gcvFALSE));
-+    }
-+OnError:
-+    galONERROR(status);
-+    return status;
-+ }
-+
-+static int
-+is_view_visible(struct weston_view *view)
-+{
-+	/* Return false, if surface is guaranteed to be totally obscured. */
-+	int ret;
-+	pixman_region32_t unocc;
-+
-+	pixman_region32_init(&unocc);
-+	pixman_region32_subtract(&unocc, &view->transform.boundingbox,
-+				 &view->clip);
-+	ret = pixman_region32_not_empty(&unocc);
-+	pixman_region32_fini(&unocc);
-+
-+	return ret;
-+}
-+ 
-+static int
-+use_output(struct weston_output *output)
-+{
-+    struct weston_compositor *compositor = output->compositor;
-+	struct weston_view *view;
-+    struct gal2d_output_state *go = get_output_state(output);	
-+	struct gal2d_renderer *gr = get_renderer(output->compositor);    
-+    gceSTATUS status = gcvSTATUS_OK;
-+
-+    gcoSURF surface;
-+    int visibleViews=0;
-+    int fullscreenViews=0;
-+ 
-+    surface = go->renderSurf[go->activebuffer];
-+    if(go->nNumBuffers == 1)
-+    {
-+        wl_list_for_each_reverse(view, &compositor->view_list, link)
-+            if (view->plane == &compositor->primary_plane && is_view_visible(view))
-+            {
-+                visibleViews++;
-+                if(view->surface->width == go->width && view->surface->height == go->height)
-+                {
-+                    pixman_box32_t *bb_rects;
-+                    int nbb=0;
-+                    bb_rects = pixman_region32_rectangles(&view->transform.boundingbox, &nbb);
-+                    if(nbb == 1)
-+                        if(bb_rects[0].x1 == 0 && bb_rects[0].y1 ==0)
-+                            fullscreenViews++;
-+                }
-+            }
-+
-+        go->directBlit = ((visibleViews == 1) || (fullscreenViews > 1));
-+
-+        if(!go->directBlit)
-+        {
-+             surface = go->offscreenSurface;
-+        }
-+    }
-+    make_current(gr, surface);
-+    return status;
-+}
-+
-+static int
-+gal2d_renderer_read_pixels(struct weston_output *output,
-+			       pixman_format_code_t format, void *pixels,
-+			       uint32_t x, uint32_t y,
-+			       uint32_t width, uint32_t height)
-+{
-+	return 0;
-+}
-+
-+static int gal2d_int_from_double(double d)
-+{
-+	return wl_fixed_to_int(wl_fixed_from_double(d));
-+}
-+
-+static void
-+repaint_region(struct weston_view *ev, struct weston_output *output, struct gal2d_output_state *go, pixman_region32_t *region,
-+		pixman_region32_t *surf_region){
-+
-+    struct gal2d_renderer *gr = get_renderer(ev->surface->compositor);
-+    struct gal2d_surface_state *gs = get_surface_state(ev->surface);
-+
-+	pixman_box32_t *rects, *surf_rects, *bb_rects;
-+	int i, j, nrects, nsurf, nbb=0;
-+	gceSTATUS status = gcvSTATUS_OK;
-+	gcoSURF srcSurface = gs->gco_Surface;
-+	gcsRECT srcRect = {0};
-+	gcsRECT dstrect = {0};
-+	gctUINT32 horFactor, verFactor;
-+	int useStretch =1;
-+	int useFilterBlit = 0;
-+	gctUINT srcWidth = 0;
-+	gctUINT srcHeight = 0;
-+	gctUINT32 srcStride[3];
-+	gceSURF_FORMAT srcFormat;;
-+	gctUINT32 srcPhyAddr[3];
-+	gctUINT32 dstPhyAddr[3];
-+	gctUINT dstWidth = 0;
-+	gctUINT dstHeight = 0;
-+	gctUINT32 dstStrides[3];
-+	gcoSURF dstsurface;
-+	int geoWidth = ev->surface->width;
-+	int geoheight = ev->surface->height;
-+    gceTILING tiling;
-+
-+	bb_rects = pixman_region32_rectangles(&ev->transform.boundingbox, &nbb);
-+
-+	if(!srcSurface || nbb <= 0)
-+		goto OnError;
-+	rects = pixman_region32_rectangles(region, &nrects);
-+	surf_rects = pixman_region32_rectangles(surf_region, &nsurf);
-+
-+	gcmVERIFY_OK(gcoSURF_GetAlignedSize(srcSurface, &srcWidth, &srcHeight, (gctINT *)&srcStride[0]));
-+
-+	gcmVERIFY_OK(gcoSURF_GetFormat(srcSurface, gcvNULL, &srcFormat));
-+
-+	if(galIsYUVFormat(srcFormat) == gcvSTATUS_TRUE)
-+	{
-+		useFilterBlit = 1;
-+	}
-+
-+	gcmVERIFY_OK(gcoSURF_Lock(srcSurface, &srcPhyAddr[0], gcvNULL));
-+
-+	gcmVERIFY_OK(gcoSURF_Unlock(srcSurface, gcvNULL));
-+
-+	srcRect.left = ev->geometry.x < 0.0 ? gal2d_int_from_double(fabsf(ev->geometry.x)) : 0;
-+	srcRect.top = 0; /*es->geometry.y < 0.0 ? gal2d_int_from_double(fabsf(es->geometry.y)) : 0;*/
-+	srcRect.right = ev->surface->width;
-+	srcRect.bottom = ev->surface->height;
-+
-+	if(useFilterBlit)
-+	{
-+		dstsurface = go->nNumBuffers > 1 ?
-+						go->renderSurf[go->activebuffer] :
-+						go->offscreenSurface;
-+		gcmVERIFY_OK(gcoSURF_GetAlignedSize(dstsurface, &dstWidth, &dstHeight, (gctINT *)&dstStrides));
-+		gcmVERIFY_OK(gcoSURF_Lock(dstsurface, &dstPhyAddr[0], gcvNULL));
-+		gcmVERIFY_OK(gcoSURF_Unlock(dstsurface, gcvNULL));
-+	}
-+	else
-+	{
-+        gcoSURF_GetTiling(srcSurface, &tiling);
-+        if (gcoHAL_IsFeatureAvailable(gr->gcoHal, gcvFEATURE_2D_TILING) != gcvTRUE && (tiling > gcvLINEAR))
-+        {
-+            weston_log("Tiling not supported \n");
-+            status = gcvSTATUS_NOT_SUPPORTED;
-+            gcmONERROR(status);
-+        }
-+        gco2D_SetGenericSource(gr->gcoEngine2d, srcPhyAddr, 1,
-+				        srcStride, 1,
-+				        tiling, srcFormat, gcvSURF_0_DEGREE,
-+				        srcWidth, srcHeight);
-+         /* Setup mirror. */
-+        gcmONERROR(gco2D_SetBitBlitMirror(gr->gcoEngine2d, gcvFALSE, gcvFALSE));
-+        gcmONERROR(gco2D_SetROP(gr->gcoEngine2d, 0xCC, 0xCC));
-+	}
-+
-+	for (i = 0; i < nrects; i++)
-+	{
-+		pixman_box32_t *rect = &rects[i];
-+		gctFLOAT min_x, max_x, min_y, max_y;
-+
-+		dstrect.left = (bb_rects[0].x1 < 0) ? rect->x1 : bb_rects[0].x1;
-+		dstrect.top = (bb_rects[0].y1 < 0) ? rect->y1 : bb_rects[0].y1;
-+		dstrect.right = bb_rects[0].x2;
-+		dstrect.bottom = bb_rects[0].y2;
-+
-+		if(dstrect.right < 0 || dstrect.bottom < 0)
-+		{
-+			break;
-+		}
-+
-+		for (j = 0; j < nsurf; j++)
-+		{
-+			pixman_box32_t *surf_rect = &surf_rects[j];
-+			gctFLOAT ex[8], ey[8];          /* edge points in screen space */
-+			int n;
-+			gcsRECT clipRect = {0};
-+			int m=0;
-+			n = calculate_edges(ev, rect, surf_rect, ex, ey);
-+			if (n < 3)
-+				continue;
-+
-+			min_x = max_x = ex[0];
-+			min_y = max_y = ey[0];
-+			for (m = 1; m < n; m++)
-+			{
-+				min_x = min(min_x, ex[m]);
-+				max_x = max(max_x, ex[m]);
-+				min_y = min(min_y, ey[m]);
-+				max_y = max(max_y, ey[m]);
-+			}
-+
-+			clipRect.left = gal2d_int_from_double(min_x);
-+			clipRect.top = gal2d_int_from_double(min_y);
-+			clipRect.right = gal2d_int_from_double(max_x);
-+			clipRect.bottom = gal2d_int_from_double(max_y);
-+
-+			if(output->x > 0)
-+			{
-+				dstrect.left = dstrect.left - output->x;
-+				dstrect.right = dstrect.right - output->x;
-+				clipRect.left = clipRect.left - output->x;
-+				clipRect.right = clipRect.right - output->x;
-+			}
-+
-+			dstrect.left = (dstrect.left < 0) ? 0 : dstrect.left;
-+			
-+			status = gco2D_SetClipping(gr->gcoEngine2d, &clipRect);
-+			if(status < 0)
-+			{
-+				weston_log("Error in gco2D_SetClipping %s\n", __func__);
-+				goto OnError;
-+			}
-+
-+			if(useFilterBlit)
-+			{
-+				gctINT          srcStrideNum;
-+				gctINT          srcAddressNum;
-+				gcmVERIFY_OK(galQueryUVStride(srcFormat, srcStride[0],
-+						&srcStride[1], &srcStride[2]));
-+
-+				switch (srcFormat)
-+				{
-+				case gcvSURF_YUY2:
-+				case gcvSURF_UYVY:
-+					srcStrideNum = srcAddressNum = 1;
-+					break;
-+
-+				case gcvSURF_I420:
-+				case gcvSURF_YV12:
-+					srcStrideNum = srcAddressNum = 3;
-+					break;
-+
-+				case gcvSURF_NV16:
-+				case gcvSURF_NV12:
-+				case gcvSURF_NV61:
-+				case gcvSURF_NV21:
-+					srcStrideNum = srcAddressNum = 2;
-+					break;
-+
-+				default:
-+					gcmONERROR(gcvSTATUS_NOT_SUPPORTED);
-+				}
-+				gco2D_FilterBlitEx2(gr->gcoEngine2d,
-+					srcPhyAddr, srcAddressNum,
-+					srcStride, srcStrideNum,
-+					gcvLINEAR, srcFormat, gcvSURF_0_DEGREE,
-+					geoWidth, geoheight, &srcRect,
-+					dstPhyAddr, 1,
-+					dstStrides, 1,
-+					gcvLINEAR, go->format, gcvSURF_0_DEGREE,
-+					dstWidth, dstHeight,
-+					&dstrect, gcvNULL);
-+			}
-+			else
-+			{
-+				if(useStretch)
-+					gcmVERIFY_OK(galGetStretchFactors(&srcRect, &dstrect, &horFactor, &verFactor));
-+
-+				if(verFactor == 65536 && horFactor == 65536)
-+				{
-+					gcmVERIFY_OK(gco2D_Blit(gr->gcoEngine2d, 1, &dstrect,
-+											0xCC, 0xCC, go->format));
-+				}
-+				else
-+				{
-+					/* Program the stretch factors. */
-+					gcmVERIFY_OK(gco2D_SetStretchFactors(gr->gcoEngine2d, horFactor, verFactor));
-+
-+					gcmVERIFY_OK(gco2D_StretchBlit(gr->gcoEngine2d, 1, &dstrect,
-+							0xCC, 0xCC, go->format));
-+				}
-+			}
-+
-+			if(status < 0)
-+			{
-+				printf("cr l=%d r=%d t=%d b=%d w=%d h=%d\n",
-+					clipRect.left, clipRect.right, clipRect.top ,clipRect.bottom,
-+					clipRect.right - clipRect.left, clipRect.bottom -clipRect.top);
-+				printf("dr l=%d r=%d t=%d b=%d w=%d h=%d\n",
-+						dstrect.left, dstrect.right, dstrect.top ,dstrect.bottom,
-+						dstrect.right - dstrect.left, dstrect.bottom -dstrect.top);
-+				printf("horFactor=%d, verFactor=%d\n",horFactor, verFactor);
-+
-+				goto OnError;
-+			}
-+		}
-+	}
-+
-+OnError:
-+	galONERROR(status);
-+}
-+
-+static void
-+draw_view(struct weston_view *ev, struct weston_output *output,
-+	     pixman_region32_t *damage) /* in global coordinates */
-+{
-+	struct weston_compositor *ec = ev->surface->compositor;	
-+	struct gal2d_output_state *go = get_output_state(output);
-+	/* repaint bounding region in global coordinates: */
-+	pixman_region32_t repaint;
-+	/* non-opaque region in surface coordinates: */
-+	pixman_region32_t surface_blend;
-+	pixman_region32_t *buffer_damage;
-+
-+    pixman_region32_init(&repaint);
-+	pixman_region32_intersect(&repaint,
-+				  &ev->transform.boundingbox, damage);
-+	pixman_region32_subtract(&repaint, &repaint, &ev->clip);
-+
-+	if (!pixman_region32_not_empty(&repaint))
-+		goto out;
-+
-+	buffer_damage = &go->buffer_damage[go->current_buffer];
-+	pixman_region32_subtract(buffer_damage, buffer_damage, &repaint);
-+
-+	/* blended region is whole surface minus opaque region: */
-+	pixman_region32_init_rect(&surface_blend, 0, 0,
-+				  ev->surface->width, ev->surface->height);
-+	pixman_region32_subtract(&surface_blend, &surface_blend, &ev->surface->opaque);
-+
-+    struct gal2d_renderer *gr = get_renderer(ec);
-+    gco2D_SetCurrentSourceIndex(gr->gcoEngine2d, 0U);
-+
-+	if (pixman_region32_not_empty(&ev->surface->opaque)) {
-+		repaint_region(ev, output, go, &repaint, &ev->surface->opaque);
-+	}
-+
-+	if (pixman_region32_not_empty(&surface_blend)) {
-+        gco2D_EnableAlphaBlend(gr->gcoEngine2d,
-+            ev->alpha * 0xFF, ev->alpha * 0xFF,
-+            gcvSURF_PIXEL_ALPHA_STRAIGHT, gcvSURF_PIXEL_ALPHA_STRAIGHT,
-+            gcvSURF_GLOBAL_ALPHA_SCALE, gcvSURF_GLOBAL_ALPHA_SCALE,
-+            gcvSURF_BLEND_STRAIGHT, gcvSURF_BLEND_INVERSED,
-+            gcvSURF_COLOR_STRAIGHT, gcvSURF_COLOR_STRAIGHT);
-+            
-+		repaint_region(ev, output, go, &repaint, &surface_blend);
-+	}
-+
-+    gco2D_DisableAlphaBlend(gr->gcoEngine2d);
-+	pixman_region32_fini(&surface_blend);
-+
-+out:
-+	pixman_region32_fini(&repaint);
-+
-+}
-+
-+static void
-+repaint_views(struct weston_output *output, pixman_region32_t *damage)
-+{
-+	struct weston_compositor *compositor = output->compositor;
-+	struct weston_view *view;
-+	struct gal2d_output_state *go = get_output_state(output);
-+
-+    if(go->nNumBuffers > 1)
-+    {
-+        /*500ms is more than enough to process a frame */
-+        gcoOS_WaitSignal(gcvNULL, go->busySignal, 500);
-+    }
-+    go->activebuffer = (go->activebuffer+1) % go->nNumBuffers;
-+
-+	wl_list_for_each_reverse(view, &compositor->view_list, link)
-+		if (view->plane == &compositor->primary_plane)
-+			draw_view(view, output, damage);
-+}
-+
-+static void
-+gal2d_renderer_repaint_output(struct weston_output *output,
-+			     pixman_region32_t *output_damage)
-+{
-+    struct gal2d_output_state *go = get_output_state(output);	
-+ 	gctUINT32 i;
-+
-+	if (use_output(output) < 0)
-+		return;
-+        
-+	for (i = 0; i < 2; i++)
-+		pixman_region32_union(&go->buffer_damage[i],
-+				      &go->buffer_damage[i],
-+				      output_damage);
-+
-+	pixman_region32_union(output_damage, output_damage,
-+			      &go->buffer_damage[go->current_buffer]);
-+
-+	repaint_views(output, output_damage);
-+
-+	pixman_region32_copy(&output->previous_damage, output_damage);
-+	wl_signal_emit(&output->frame_signal, output);
-+    
-+    update_surface(output);
-+
-+	go->current_buffer ^= 1;
-+}
-+
-+static void
-+gal2d_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer)
-+{
-+    gcsWL_VIV_BUFFER *vivBuffer = wl_resource_get_user_data(buffer->resource);
-+    gcoSURF srcSurf = vivBuffer->surface;
-+    gceSTATUS status = gcvSTATUS_OK;
-+    struct gal2d_surface_state *gs = get_surface_state(es);
-+
-+    if(gs->gco_Surface != gcvNULL)
-+    {
-+        gcmONERROR(gcoSURF_Destroy(gs->gco_Surface));
-+    }
-+
-+    gs->gco_Surface = srcSurf;
-+    gcoSURF_ReferenceSurface(srcSurf);
-+    buffer->width = vivBuffer->width;
-+    buffer->height = vivBuffer->height;
-+    
-+  OnError:
-+    galONERROR(status);
-+}
-+
-+static void
-+gal2d_renderer_flush_damage(struct weston_surface *surface)
-+{
-+	struct gal2d_surface_state *gs = get_surface_state(surface);
-+	struct weston_buffer *buffer = gs->buffer_ref.buffer;
-+    struct weston_view *view;
-+	int texture_used;
-+	pixman_region32_union(&gs->texture_damage,
-+			      &gs->texture_damage, &surface->damage);
-+
-+	if (!buffer)
-+		return;
-+
-+	texture_used = 0;
-+	wl_list_for_each(view, &surface->views, surface_link) {
-+		if (view->plane == &surface->compositor->primary_plane) {
-+			texture_used = 1;
-+			break;
-+		}
-+	}
-+	if (!texture_used)
-+		return;
-+
-+	if (!pixman_region32_not_empty(&gs->texture_damage))
-+		goto done;
-+
-+    if(wl_shm_buffer_get(buffer->resource))
-+	{
-+		if(gs->gco_Surface==NULL)
-+		{
-+			gs->gco_Surface = getSurfaceFromShm(surface, buffer);
-+		}
-+		gal2dBindBuffer(surface);
-+	}
-+	else
-+        gal2d_renderer_attach_egl(surface, buffer);
-+
-+done:
-+	pixman_region32_fini(&gs->texture_damage);
-+	pixman_region32_init(&gs->texture_damage);
-+
-+	weston_buffer_reference(&gs->buffer_ref, NULL);
-+}
-+
-+static void
-+gal2d_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
-+{
-+	struct gal2d_surface_state *gs = get_surface_state(es);
-+	struct wl_shm_buffer *shm_buffer;
-+	weston_buffer_reference(&gs->buffer_ref, buffer);
-+
-+	if(buffer==NULL)
-+		return;
-+
-+	shm_buffer = wl_shm_buffer_get(buffer->resource);
-+
-+	if(shm_buffer)
-+	{
-+		buffer->width = wl_shm_buffer_get_width(shm_buffer);
-+		buffer->height = wl_shm_buffer_get_height(shm_buffer);
-+		buffer->shm_buffer = shm_buffer;
-+
-+		if(gs->gco_Surface)
-+		{
-+			gcoSURF_Destroy(gs->gco_Surface);
-+            gs->gco_Surface = getSurfaceFromShm(es, buffer);
-+		}
-+	}
-+	else
-+		gal2d_renderer_attach_egl(es, buffer);
-+}
-+
-+static void
-+surface_state_destroy(struct gal2d_surface_state *gs, struct gal2d_renderer *gr)
-+{
-+	if(gs->gco_Surface)
-+    {
-+        gcoSURF_Destroy(gs->gco_Surface);
-+    }
-+    wl_list_remove(&gs->surface_destroy_listener.link);
-+	wl_list_remove(&gs->renderer_destroy_listener.link);
-+	if(gs->surface)
-+		gs->surface->renderer_state = NULL;
-+
-+	weston_buffer_reference(&gs->buffer_ref, NULL);
-+	free(gs);
-+}
-+
-+static void
-+surface_state_handle_surface_destroy(struct wl_listener *listener, void *data)
-+{
-+	struct gal2d_surface_state *gs;
-+	struct gal2d_renderer *gr;
-+
-+	gs = container_of(listener, struct gal2d_surface_state,
-+			  surface_destroy_listener);
-+
-+	gr = get_renderer(gs->surface->compositor);
-+	surface_state_destroy(gs, gr);
-+}
-+
-+static void
-+surface_state_handle_renderer_destroy(struct wl_listener *listener, void *data)
-+{
-+	struct gal2d_surface_state *gs;
-+	struct gal2d_renderer *gr;
-+
-+	gr = data;
-+
-+	gs = container_of(listener, struct gal2d_surface_state,
-+			  renderer_destroy_listener);
-+
-+	surface_state_destroy(gs, gr);
-+}
-+
-+
-+static int
-+gal2d_renderer_create_surface(struct weston_surface *surface)
-+{
-+    struct gal2d_surface_state *gs;
-+    struct gal2d_renderer *gr = get_renderer(surface->compositor);
-+    
-+	gs = zalloc(sizeof *gs);
-+	if (gs == NULL)
-+		return -1;
-+
-+	/* A buffer is never attached to solid color surfaces, yet
-+	 * they still go through texcoord computations. Do not divide
-+	 * by zero there.
-+	 */
-+	gs->pitch = 1;
-+
-+    gs->surface = surface;
-+    
-+	pixman_region32_init(&gs->texture_damage);
-+	surface->renderer_state = gs;
-+
-+	gs->surface_destroy_listener.notify =
-+		surface_state_handle_surface_destroy;
-+	wl_signal_add(&surface->destroy_signal,
-+		      &gs->surface_destroy_listener);
-+
-+	gs->renderer_destroy_listener.notify =
-+		surface_state_handle_renderer_destroy;
-+	wl_signal_add(&gr->destroy_signal,
-+		      &gs->renderer_destroy_listener);
-+
-+	if (surface->buffer_ref.buffer) {
-+		gal2d_renderer_attach(surface, surface->buffer_ref.buffer);
-+		gal2d_renderer_flush_damage(surface);
-+	}
-+    
-+    return 0;
-+}
-+
-+static void
-+gal2d_renderer_surface_set_color(struct weston_surface *surface,
-+		 float red, float green, float blue, float alpha)
-+{
-+    struct gal2d_surface_state *gs = get_surface_state(surface);
-+
-+	gs->color[0] = red;
-+	gs->color[1] = green;
-+	gs->color[2] = blue;
-+	gs->color[3] = alpha;
-+}
-+
-+
-+static void
-+gal2d_renderer_output_destroy(struct weston_output *output)
-+{
-+    struct gal2d_output_state *go = get_output_state(output);
-+    gctUINT32 i;
-+
-+    for (i = 0; i < 2; i++)
-+    {
-+        pixman_region32_fini(&go->buffer_damage[i]);
-+    }
-+    if(go->nNumBuffers <= 1 )
-+	{
-+		if(go->offscreenSurface)
-+			gcmVERIFY_OK(gcoSURF_Destroy(go->offscreenSurface));
-+	}
-+    else
-+    {
-+        gcoOS_Signal(gcvNULL,go->signal, gcvTRUE);
-+        pthread_mutex_lock(&go->workerMutex);
-+        go->exitWorker = 1;
-+        pthread_mutex_unlock(&go->workerMutex);
-+        pthread_join(go->workerId, NULL);
-+    }
-+
-+	for(i=0; i < go->nNumBuffers; i++)
-+	{
-+		gcmVERIFY_OK(gcoSURF_Destroy(go->renderSurf[i]));
-+	}
-+	free(go->renderSurf);
-+	go->renderSurf = gcvNULL;
-+
-+	free(go);
-+}
-+
-+static void
-+gal2d_renderer_destroy(struct weston_compositor *ec)
-+{
-+    struct gal2d_renderer *gr = get_renderer(ec);
-+
-+    wl_signal_emit(&gr->destroy_signal, gr);
-+	free(ec->renderer);
-+	ec->renderer = NULL;
-+}
-+
-+
-+static int
-+gal2d_renderer_create(struct weston_compositor *ec)
-+{
-+    struct gal2d_renderer *gr;
-+    gceSTATUS status = gcvSTATUS_OK;
-+	gr = malloc(sizeof *gr);
-+	if (gr == NULL)
-+		return -1;
-+
-+	gr->base.read_pixels = gal2d_renderer_read_pixels;
-+	gr->base.repaint_output = gal2d_renderer_repaint_output;
-+	gr->base.flush_damage = gal2d_renderer_flush_damage;
-+	gr->base.attach = gal2d_renderer_attach;
-+	gr->base.surface_set_color = gal2d_renderer_surface_set_color;
-+	gr->base.destroy = gal2d_renderer_destroy;
-+    
-+    /* Construct the gcoOS object. */
-+	gcmONERROR(gcoOS_Construct(gcvNULL, &gr->gcos));
-+
-+	/* Construct the gcoHAL object. */
-+	gcmONERROR(gcoHAL_Construct(gcvNULL, gr->gcos, &gr->gcoHal));
-+	gcmONERROR(gcoHAL_Get2DEngine(gr->gcoHal, &gr->gcoEngine2d));
-+	gcmONERROR(gcoHAL_SetHardwareType(gr->gcoHal, gcvHARDWARE_2D));
-+    
-+	ec->renderer = &gr->base; 
-+        wl_signal_init(&gr->destroy_signal);
-+OnError:
-+    galONERROR(status);
-+    
-+    /* Return the status. */    
-+    return status;
-+	
-+}
-+
-+static int
-+gal2d_renderer_output_create(struct weston_output *output, NativeDisplayType display,
-+				    NativeWindowType window)
-+
-+ {
-+    struct gal2d_renderer *gr = get_renderer(output->compositor);
-+	struct gal2d_output_state *go;
-+    halDISPLAY_INFO info;
-+    gctUINT32 backOffset = 0;
-+    gceSTATUS status = gcvSTATUS_OK;
-+	gctUINT32 i;
-+
-+    go = zalloc(sizeof *go);
-+    if (go == NULL)
-+		return -1;
-+
-+    output->renderer_state = go;
-+    go->display = display;
-+    gcmONERROR(gcoOS_InitLocalDisplayInfo(go->display, &gr->localInfo));
-+
-+    /* Get display information. */
-+	gcmONERROR(gcoOS_GetDisplayInfoEx2(
-+					go->display, gcvNULL, gr->localInfo,
-+					sizeof(info), &info));
-+	go->nNumBuffers = info.multiBuffer;
-+
-+    weston_log("Number of buffers=%d\n",go->nNumBuffers);
-+
-+	gcmONERROR(gal2d_getSurfaceFormat(info, &go->format));    
-+	backOffset = (gctUINT32)(info.stride * info.height );
-+
-+	go->activebuffer = 0;
-+
-+	go->renderSurf = malloc(sizeof(gcoSURF) * go->nNumBuffers);
-+	gcoOS_GetDisplayVirtual(go->display, &go->width, &go->height);
-+    gcoOS_SetSwapInterval(go->display, 1);
-+ 
-+    /*Needed only for multi Buffer  */
-+    if(go->nNumBuffers > 1)
-+    {
-+        gcmVERIFY_OK(gcoOS_CreateSignal(gcvNULL, gcvFALSE,
-+                &go->signal));
-+        gcmVERIFY_OK(gcoOS_CreateSignal(gcvNULL, gcvFALSE,
-+                &go->busySignal));
-+
-+        go->iface.command            = gcvHAL_SIGNAL;
-+        go->iface.u.Signal.signal    = gcmPTR_TO_UINT64(go->signal);
-+        go->iface.u.Signal.auxSignal = 0;
-+        go->iface.u.Signal.process = gcmPTR_TO_UINT64(gcoOS_GetCurrentProcessID());
-+        go->iface.u.Signal.fromWhere = gcvKERNEL_PIXEL;
-+
-+        go->exitWorker = 0;
-+        pthread_create(&go->workerId, NULL, gal2d_output_worker, output);
-+        pthread_mutex_init(&go->workerMutex, gcvNULL);
-+    }
-+	for(i=0; i < go->nNumBuffers; i++)
-+	{
-+        gcmONERROR(gcoSURF_Construct(gr->gcoHal, info.width, info.height, 1, 
-+            gcvSURF_BITMAP, go->format, gcvPOOL_USER, &go->renderSurf[i]));
-+        
-+        gcoSURF_MapUserSurface(go->renderSurf[i], 0,info.logical + (i * backOffset),
-+						info.physical + (i * backOffset));
-+		
-+		//Clear surfaces
-+		make_current(gr, go->renderSurf[go->activebuffer]);
-+		gal2d_clear(output);
-+		gal2d_flip_surface(output);
-+	}
-+	if(go->nNumBuffers <= 1)
-+		go->activebuffer = 0;
-+	else
-+		go->activebuffer = 1;
-+
-+	if(go->nNumBuffers <= 1 )
-+	{
-+		gcmVERIFY_OK(gcoSURF_Construct(gr->gcoHal,
-+							  (gctUINT) info.width,
-+							  (gctUINT) info.height,
-+							  1,
-+							  gcvSURF_BITMAP,
-+							  go->format,
-+							  gcvPOOL_DEFAULT,
-+							  &go->offscreenSurface));
-+		make_current(gr, go->offscreenSurface);
-+		gal2d_clear(output);
-+	}
-+    else
-+    {
-+        gcoOS_Signal(gcvNULL,go->busySignal, gcvTRUE);
-+    }
-+
-+	for (i = 0; i < 2; i++)
-+		pixman_region32_init(&go->buffer_damage[i]);
-+OnError:
-+    galONERROR(status);
-+    /* Return the status. */
-+    return status;  
-+ }
-+
-+ WL_EXPORT struct gal2d_renderer_interface gal2d_renderer_interface = {
-+	.create = gal2d_renderer_create,
-+	.output_create = gal2d_renderer_output_create,
-+	.output_destroy = gal2d_renderer_output_destroy,
-+};
-Index: weston-1.11.1/src/gal2d-renderer.h
-===================================================================
---- /dev/null	1970-01-01 00:00:00.000000000 +0000
-+++ weston-1.11.1/src/gal2d-renderer.h	2017-01-14 08:35:10.000000000 -0600
-@@ -0,0 +1,50 @@
-+/*
-+ * Copyright (c) 2015 Freescale Semiconductor, Inc.
-+ * Copyright © 2013 Vasily Khoruzhick <anarsoul@gmail.com>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining
-+ * a copy of this software and associated documentation files (the
-+ * "Software"), to deal in the Software without restriction, including
-+ * without limitation the rights to use, copy, modify, merge, publish,
-+ * distribute, sublicense, and/or sell copies of the Software, and to
-+ * permit persons to whom the Software is furnished to do so, subject to
-+ * the following conditions:
-+ *
-+ * The above copyright notice and this permission notice (including the
-+ * next paragraph) shall be included in all copies or substantial
-+ * portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-+ * SOFTWARE.
-+ */
-+#ifndef __gal_2d_renderer_h_
-+#define __gal_2d_renderer_h_
-+
-+#include  "compositor.h"
-+#ifdef ENABLE_EGL
-+#include <EGL/egl.h>
-+#else
-+#include <HAL/gc_hal_eglplatform.h>
-+typedef HALNativeDisplayType NativeDisplayType;
-+typedef HALNativeWindowType  NativeWindowType;
-+#endif
-+
-+
-+struct gal2d_renderer_interface {
-+
-+	int (*create)(struct weston_compositor *ec);
-+
-+	int (*output_create)(struct weston_output *output,
-+		         NativeDisplayType display,
-+			     NativeWindowType window);
-+
-+	void (*output_destroy)(struct weston_output *output);
-+};
-+
-+#endif
-Index: weston-1.11.1/src/compositor-fbdev.h
-===================================================================
---- weston-1.11.1.orig/src/compositor-fbdev.h	2016-09-20 19:35:22.000000000 -0500
-+++ weston-1.11.1/src/compositor-fbdev.h	2017-01-14 08:35:10.000000000 -0600
-@@ -40,6 +40,7 @@
- 	int tty;
- 	char *device;
- 	int use_gl;
-+	int use_gal2d;
- 
- 	uint32_t output_transform;
- };
-Index: weston-1.11.1/src/main.c
-===================================================================
---- weston-1.11.1.orig/src/main.c	2017-01-14 08:34:10.030218137 -0600
-+++ weston-1.11.1/src/main.c	2017-01-14 08:54:45.000000000 -0600
-@@ -285,7 +285,13 @@
- 		"Options for fbdev-backend.so:\n\n"
- 		"  --tty=TTY\t\tThe tty to use\n"
- 		"  --device=DEVICE\tThe framebuffer device to use\n"
--		"  --use-gl\t\tUse the GL renderer\n\n");
-+#if defined ENABLE_EGL
-+		"  --use-gl=1\t\tUse the GL renderer (default is 1)\n"
-+		"  --use-gal2d=1\t\tUse the GAL2D renderer (default is 0)\n\n");
-+#else
-+		"  --use-gl=1\t\tUse the GL renderer (default is 0)\n"
-+		"  --use-gal2d=1\t\tUse the GAL2D renderer (default is 1)\n\n");
-+#endif
- #endif
- 
- #if defined(BUILD_HEADLESS_COMPOSITOR)
-@@ -868,7 +874,8 @@
- 	const struct weston_option fbdev_options[] = {
- 		{ WESTON_OPTION_INTEGER, "tty", 0, &config.tty },
- 		{ WESTON_OPTION_STRING, "device", 0, &config.device },
--		{ WESTON_OPTION_BOOLEAN, "use-gl", 0, &config.use_gl },
-+		{ WESTON_OPTION_INTEGER, "use-gl", 0, &config.use_gl },
-+		{ WESTON_OPTION_INTEGER, "use-gal2d", 0, &config.use_gal2d },
- 	};
- 
- 	parse_options(fbdev_options, ARRAY_LENGTH(fbdev_options), argc, argv);
diff --git a/recipes-graphics/wayland/weston/0009-MGS-1284-xwld-Re-implement-weston-2d-renderer-with-p.patch b/recipes-graphics/wayland/weston/0002-MGS-2521-ccc-Enable-g2d-renderer-for-weston-1.11.patch
similarity index 42%
rename from recipes-graphics/wayland/weston/0009-MGS-1284-xwld-Re-implement-weston-2d-renderer-with-p.patch
rename to recipes-graphics/wayland/weston/0002-MGS-2521-ccc-Enable-g2d-renderer-for-weston-1.11.patch
index f48785f..858cb81 100644
--- a/recipes-graphics/wayland/weston/0009-MGS-1284-xwld-Re-implement-weston-2d-renderer-with-p.patch
+++ b/recipes-graphics/wayland/weston/0002-MGS-2521-ccc-Enable-g2d-renderer-for-weston-1.11.patch
@@ -1,211 +1,211 @@
-From 7bcbb14a149d0955176855e8ab6289cf68d099e5 Mon Sep 17 00:00:00 2001
-From: "yong.gan" <yong.gan@nxp.com>
-Date: Fri, 11 Mar 2016 10:55:48 +0800
-Subject: [PATCH 1/3] MGS-1284: xwld: Re-implement weston 2d renderer with
- porting g2d API
+From 1995ec08267c8063ca72590e700c8612b04a63b5 Mon Sep 17 00:00:00 2001
+From: Meng Mingming <mingming.meng@nxp.com>
+Date: Mon, 16 Jan 2017 10:15:02 +0800
+Subject: [PATCH 2/5] MGS-2521 [#ccc] Enable g2d-renderer for weston 1.11
 
-Use G2D API to replace Gal2D API.
-Fix the errors in multi display mode.
-Use the standard FB API to operate the frame buffer.
+Enable g2d-renderer for weston 1.11
+weston-start -- --use-g2d=1(--use-gl=1) $OPTARGS
 
-Date: Feb 22, 2016
 Upstream Status: Inappropriate [i.MX specific]
 
-Signed-off-by: Yong Gan <yong.gan@freescale.com>
+Date: Jan 16, 2017
+Signed-off-by: Meng Mingming <mingming.meng@nxp.com>
 ---
- Makefile.am            |   16 +-
- src/compositor-fbdev.c |   74 +--
- src/g2d-renderer.c     | 1175 +++++++++++++++++++++++++++++++++++++++++++
- src/g2d-renderer.h     |   48 ++
- src/gal2d-renderer.c   | 1307 ------------------------------------------------
- src/gal2d-renderer.h   |   50 --
- 6 files changed, 1255 insertions(+), 1415 deletions(-)
+ Makefile.am            |   16 +
+ src/compositor-fbdev.c |   66 ++-
+ src/compositor-fbdev.h |    1 +
+ src/g2d-renderer.c     | 1317 ++++++++++++++++++++++++++++++++++++++++++++++++
+ src/g2d-renderer.h     |   47 ++
+ src/main.c             |    6 +-
+ 6 files changed, 1448 insertions(+), 5 deletions(-)
  create mode 100644 src/g2d-renderer.c
  create mode 100644 src/g2d-renderer.h
- delete mode 100644 src/gal2d-renderer.c
- delete mode 100644 src/gal2d-renderer.h
 
-Index: weston-1.11.1/Makefile.am
-===================================================================
---- weston-1.11.1.orig/Makefile.am	2017-01-14 08:59:52.293865810 -0600
-+++ weston-1.11.1/Makefile.am	2017-01-14 09:08:38.000000000 -0600
-@@ -247,16 +247,16 @@
- 	src/vertex-clipping.h			\
+diff --git a/Makefile.am b/Makefile.am
+index 00b74e5..a044b64 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -248,6 +248,22 @@ gl_renderer_la_SOURCES =			\
  	shared/helpers.h
  endif
--module_LTLIBRARIES += gal2d-renderer.la
--gal2d_renderer_la_LDFLAGS = -module -avoid-version
--gal2d_renderer_la_LIBADD = $(COMPOSITOR_LIBS) $(EGL_LIBS)
--gal2d_renderer_la_CFLAGS =			\
+ 
 +module_LTLIBRARIES += g2d-renderer.la
 +g2d_renderer_la_LDFLAGS = -module -avoid-version
 +g2d_renderer_la_LIBADD = $(COMPOSITOR_LIBS) $(EGL_LIBS) -lg2d
-+g2d_renderer_la_CFLAGS =			\
- 	$(COMPOSITOR_CFLAGS)			\
- 	$(EGL_CFLAGS)				\
--	$(GCC_CFLAGS)
--gal2d_renderer_la_SOURCES =			\
--	src/gal2d-renderer.h			\
--	src/gal2d-renderer.c			\
-+	$(GCC_CFLAGS) -DHAVE_G2D
-+g2d_renderer_la_SOURCES =			\
-+	src/g2d-renderer.h			\
-+	src/g2d-renderer.c			\
- 	src/vertex-clipping.c			\
- 	src/vertex-clipping.h
- 
-Index: weston-1.11.1/src/compositor-fbdev.c
-===================================================================
---- weston-1.11.1.orig/src/compositor-fbdev.c	2017-01-14 08:59:52.473866702 -0600
-+++ weston-1.11.1/src/compositor-fbdev.c	2017-01-14 09:19:12.000000000 -0600
-@@ -50,7 +50,7 @@
++g2d_renderer_la_CFLAGS =                       \
++       $(COMPOSITOR_CFLAGS)                    \
++       $(EGL_CFLAGS)                           \
++       $(GCC_CFLAGS) -DHAVE_G2D
++g2d_renderer_la_SOURCES =                      \
++       src/g2d-renderer.h                      \
++       src/g2d-renderer.c                      \
++       src/vertex-clipping.c                   \
++       src/vertex-clipping.h
++if ENABLE_EGL
++g2d_renderer_la_CFLAGS += -DENABLE_EGL
++endif
++
+ if ENABLE_X11_COMPOSITOR
+ module_LTLIBRARIES += x11-backend.la
+ x11_backend_la_LDFLAGS = -module -avoid-version
+diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
+index 06f4696..cff9513 100644
+--- a/src/compositor-fbdev.c
++++ b/src/compositor-fbdev.c
+@@ -50,6 +50,7 @@
  #include "libinput-seat.h"
  #include "gl-renderer.h"
  #include "presentation-time-server-protocol.h"
--#include "gal2d-renderer.h"
 +#include "g2d-renderer.h"
  
  struct fbdev_backend {
  	struct weston_backend base;
-@@ -60,7 +60,7 @@
+@@ -59,6 +60,7 @@ struct fbdev_backend {
  	struct udev *udev;
  	struct udev_input input;
  	int use_pixman;
--	int use_gal2d;
 +	int use_g2d;
  	uint32_t output_transform;
  	struct wl_listener session_listener;
  	NativeDisplayType display;
-@@ -102,7 +102,7 @@
+@@ -100,6 +102,7 @@ struct fbdev_output {
  };
  
  struct gl_renderer_interface *gl_renderer;
--struct gal2d_renderer_interface *gal2d_renderer;
 +struct g2d_renderer_interface *g2d_renderer;
  
  static const char default_seat[] = "seat0";
  
-@@ -519,36 +519,10 @@
+@@ -516,6 +519,14 @@ fbdev_output_create(struct fbdev_backend *backend,
  	if (backend->use_pixman) {
  		if (pixman_renderer_output_create(&output->base) < 0)
  			goto out_hw_surface;
--	} else if(backend->use_gal2d) {
--
--		char* fbenv = getenv("FB_FRAMEBUFFER_0");
--		setenv("FB_FRAMEBUFFER_0", device, 1);
--		output->display = fbGetDisplay(backend->compositor->wl_display);
--		if (output->display == NULL) {
--			fprintf(stderr, "failed to get display\n");
--			return 0;
--		}
--
--		output->window = fbCreateWindow(output->display, -1, -1, 0, 0);
--		if (output->window == NULL) {
--			fprintf(stderr, "failed to create window\n");
--			 return 0;
--		}
--		/* restore the previous value*/
--		if(fbenv != NULL)
--		{
--			setenv("FB_FRAMEBUFFER_0", fbenv, 1);
--		}
--		else
--		{
--			unsetenv("FB_FRAMEBUFFER_0");
--		}
--
--
--		if (gal2d_renderer->output_create(&output->base,
--					output->display,
--					(NativeWindowType)output->window) < 0) {
--			weston_log("gal_renderer_output_create failed.\n");
 +	} else if(backend->use_g2d) {
++		const char *g2d_device = device;
++
 +		if (g2d_renderer->output_create(&output->base,
-+					backend->compositor->wl_display, device) < 0) {
-+			weston_log("g2d_renderer_output_create failed.\n");
- 			goto out_hw_surface;
- 		}
- 
-@@ -607,8 +581,8 @@
++							backend->compositor->wl_display, g2d_device) < 0) {
++				weston_log("g2d_renderer_output_create failed.\n");
++				goto out_hw_surface;
++		}
+ 	} else {
+ 		setenv("HYBRIS_EGLPLATFORM", "wayland", 1);
+ 		output->window = fbCreateWindow(backend->display, -1, -1, 0, 0);
+@@ -571,6 +582,8 @@ fbdev_output_destroy(struct weston_output *base)
  	if (backend->use_pixman) {
  		if (base->renderer_state != NULL)
  			pixman_renderer_output_destroy(base);
--	} else if (backend->use_gal2d) {
--		gal2d_renderer->output_destroy(base);
-+	} else if (backend->use_g2d) {
++	} else if(backend->use_g2d) {
 +		g2d_renderer->output_destroy(base);
  	} else {
  		gl_renderer->output_destroy(base);
  	}
-@@ -820,8 +794,8 @@
+@@ -782,7 +795,8 @@ fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv
  	backend->base.restore = fbdev_restore;
  
  	backend->prev_state = WESTON_COMPOSITOR_ACTIVE;
--	backend->use_pixman = !(param->use_gl || param->use_gal2d);
--	backend->use_gal2d = param->use_gal2d;
+-	backend->use_pixman = !param->use_gl;
 +	backend->use_pixman = !(param->use_gl || param->use_g2d);
 +	backend->use_g2d = param->use_g2d;
  	backend->output_transform = param->output_transform;
  
  	weston_setup_vt_switch_bindings(compositor);
-@@ -830,21 +804,21 @@
+@@ -790,6 +804,46 @@ fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv
+ 	if (backend->use_pixman) {
  		if (pixman_renderer_init(compositor) < 0)
  			goto out_launcher;
- 	}
--	else if (backend->use_gal2d) {
-+	else if (backend->use_g2d) {
- 		int x = 0, y = 0;
- 		int i=0;
- 		int count = 0;
- 		int k=0, dispCount = 0;
- 		char displays[5][32];
--		gal2d_renderer = weston_load_module("gal2d-renderer.so",
--						 "gal2d_renderer_interface");
--		if (!gal2d_renderer) {
--			weston_log("could not load gal2d renderer\n");
++	} else if(backend->use_g2d) {
++		int x = 0, y = 0;
++		int i=0;
++		int count = 0;
++		int k=0, dispCount = 0;
++		char displays[5][32];
 +		g2d_renderer = weston_load_module("g2d-renderer.so",
-+						 "g2d_renderer_interface");
++											"g2d_renderer_interface");
 +		if (!g2d_renderer) {
 +			weston_log("could not load g2d renderer\n");
- 			goto out_launcher;
- 		}
- 
--		if (gal2d_renderer->create(backend->compositor) < 0) {
--			weston_log("gal2d_renderer_create failed.\n");
++			goto out_launcher;
++		}
++
 +		if (g2d_renderer->create(backend->compositor) < 0) {
 +			weston_log("g2d_renderer_create failed.\n");
- 			goto out_launcher;
- 		}
- 
-@@ -893,7 +867,7 @@
++			goto out_launcher;
++		}
++
++		weston_log("param->device=%s\n",param->device);
++		count = strlen(param->device);
++
++		for(i= 0; i < count; i++) {
++			if(param->device[i] == ',') {
++				displays[dispCount][k] = '\0';
++				dispCount++;
++				k = 0;
++				continue;
++			}
++			displays[dispCount][k++] = param->device[i];
++		}
++		displays[dispCount][k] = '\0';
++		dispCount++;
++
++		for(i= 0; i < dispCount; i++){
++			if (fbdev_output_create(backend, x, y, displays[i]) < 0)
++				goto out_launcher;
++			x += container_of(backend->compositor->output_list.prev,
++							struct weston_output,
++							link)->width;
++		}
+ 	} else {
+ 		gl_renderer = weston_load_module("gl-renderer.so",
+ 						 "gl_renderer_interface");
+@@ -811,7 +865,8 @@ fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv
  			goto out_launcher;
  		}
  	}
--	if(!backend->use_gal2d)
+-	if (fbdev_output_create(backend, 0, 0, param->device) < 0)
 +	if(!backend->use_g2d)
- 		if (fbdev_output_create(backend, 0, 0, param->device) < 0)
++		if (fbdev_output_create(backend, 0, 0, param->device) < 0)
  			goto out_launcher;
  
-@@ -922,13 +896,8 @@
- 	 * udev, rather than passing a device node in as a parameter. */
+ 	udev_input_init(&backend->input, compositor, backend->udev, seat_id);
+@@ -840,6 +895,7 @@ config_init_to_defaults(struct weston_fbdev_backend_config *config)
  	config->tty = 0; /* default to current tty */
  	config->device = "/dev/fb0"; /* default frame buffer */
--#ifdef ENABLE_EGL
--	config->use_gl = 1;
--	config->use_gal2d = 0;
--#else
  	config->use_gl = 0;
--	config->use_gal2d = 1;
--#endif
 +	config->use_g2d = 0;
  	config->output_transform = WL_OUTPUT_TRANSFORM_NORMAL;
  }
  
-Index: weston-1.11.1/src/g2d-renderer.c
-===================================================================
---- /dev/null	1970-01-01 00:00:00.000000000 +0000
-+++ weston-1.11.1/src/g2d-renderer.c	2017-01-14 09:08:38.000000000 -0600
-@@ -0,0 +1,1175 @@
+@@ -861,7 +917,11 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
+ 	config_init_to_defaults(&config);
+ 	memcpy(&config, config_base, config_base->struct_size);
+ 
+-	config.use_gl = 1;
++	if(config.use_g2d) {
++		config.use_gl = 0;
++	} else {
++		config.use_gl = 1;
++	}
+ 
+ 	b = fbdev_backend_create(compositor, argc, argv, wc, &config);
+ 	if (b == NULL)
+diff --git a/src/compositor-fbdev.h b/src/compositor-fbdev.h
+index bd60bdc..32a8598 100644
+--- a/src/compositor-fbdev.h
++++ b/src/compositor-fbdev.h
+@@ -40,6 +40,7 @@ struct weston_fbdev_backend_config {
+ 	int tty;
+ 	char *device;
+ 	int use_gl;
++	int use_g2d;
+ 
+ 	uint32_t output_transform;
+ };
+diff --git a/src/g2d-renderer.c b/src/g2d-renderer.c
+new file mode 100644
+index 0000000..c30aa62
+--- /dev/null
++++ b/src/g2d-renderer.c
+@@ -0,0 +1,1317 @@
 +/*
 + * Copyright (c) 2016 Freescale Semiconductor, Inc.
 + * Copyright © 2012 Intel Corporation
@@ -245,15 +245,30 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +#include <sys/ioctl.h>
 +#include <fcntl.h>
 +#include <unistd.h>
++#include <g2dExt.h>
++#include <HAL/gc_hal_eglplatform.h>
 +
 +#include "compositor.h"
 +#include "g2d-renderer.h"
 +#include "vertex-clipping.h"
 +#include "shared/helpers.h"
-+#include "HAL/gc_hal_eglplatform.h"
-+#include "g2dExt.h"
 +
 +#define BUFFER_DAMAGE_COUNT 2
++#define ALIGN_WIDTH(a) (((a) + 15) & ~15)
++
++struct wl_viv_buffer
++{
++    struct wl_resource *resource;
++    gcoSURF  surface;
++    gctINT32 width;
++    gctINT32 height;
++    gctINT32 format;
++    gctUINT alignedWidth;
++    gctUINT alignedHeight;
++    gctUINT32 physical[3];
++    gctUINT32 gpuBaseAddr;
++    gceTILING tiling;
++};
 +
 +typedef struct _g2dRECT
 +{
@@ -270,7 +285,10 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +	unsigned int y_resolution;
 +	size_t buffer_length; /* length of frame buffer memory in bytes */
 +	size_t physical;
++	size_t stride;
++	size_t stride_bytes;
 +	enum g2d_format pixel_format; /* frame buffer pixel format */
++	int fb_fd;
 +};
 +
 +struct g2d_output_state {
@@ -282,10 +300,12 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +	struct g2d_surfaceEx offscreenSurface;
 +	struct g2d_buf *offscreen_buf;
 +	struct fb_screeninfo fb_info;
++	struct fb_screeninfo *mirror_fb_info;
++	struct g2d_surfaceEx *mirrorSurf;
 +	int directBlit;
++	int clone_display_num;
 +	int width;
 +	int height;
-+	int fb_fd;
 +};
 +
 +struct g2d_surface_state {
@@ -307,7 +327,11 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +struct g2d_renderer {
 +	struct weston_renderer base;
 +	struct wl_signal destroy_signal;
-+	struct wl_global *viv_global;
++#ifdef ENABLE_EGL
++	NativeDisplayType display;
++	EGLDisplay egl_display;
++	struct wl_display *wl_display;
++#endif
 +	void *handle;
 +};
 +
@@ -500,9 +524,10 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +	}
 +}
 +
-+static void printG2dSurfaceInfo(struct g2d_surfaceEx* g2dSurface)
++static void printG2dSurfaceInfo(struct g2d_surfaceEx* g2dSurface, const char* msg)
 +{
-+	weston_log("physicAddr = %d left = %d right = %d top=%d bottom=%d stride= %d tiling = %d, format=%d \n",
++	weston_log("%s physicAddr = %x left = %d right = %d top=%d bottom=%d stride= %d tiling = %d, format=%d \n",
++				msg,
 +				g2dSurface->base.planes[0],
 +				g2dSurface->base.left,
 +				g2dSurface->base.right,
@@ -514,27 +539,25 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +}
 +
 +static void
-+get_g2dSurface(gcsWL_VIV_BUFFER *buffer, struct g2d_surfaceEx *g2dSurface)
++get_g2dSurface(struct wl_viv_buffer *buffer, struct g2d_surfaceEx *g2dSurface)
 +{
 +	if(buffer->width < 0 || buffer->height < 0)
 +	{
 +		weston_log("invalid EGL buffer in function %s\n", __func__);
 +		return;
 +	}
-+	int width  = buffer->alignedWidth;
-+	int height = buffer->alignedHeight;
 +	g2d_getG2dFormat(buffer->format, &g2dSurface->base.format);
 +	g2d_getG2dTiling(buffer->tiling, &g2dSurface->tiling);
-+	g2dSurface->base.planes[0] = buffer->physical[0];
-+	g2dSurface->base.planes[1] = buffer->physical[1];
-+	g2dSurface->base.planes[2] = buffer->physical[2];
++	g2dSurface->base.planes[0] = buffer->physical[0] + buffer->gpuBaseAddr;
++	g2dSurface->base.planes[1] = buffer->physical[1] + buffer->gpuBaseAddr;
++	g2dSurface->base.planes[2] = buffer->physical[2] + buffer->gpuBaseAddr;
 +	g2dSurface->base.left = 0;
 +	g2dSurface->base.top = 0;
 +	g2dSurface->base.right = buffer->width;
 +	g2dSurface->base.bottom = buffer->height;
-+	g2dSurface->base.stride = width;
-+	g2dSurface->base.width  = width;
-+	g2dSurface->base.height = height;
++	g2dSurface->base.stride = buffer->alignedWidth;
++	g2dSurface->base.width  = buffer->width;
++	g2dSurface->base.height = buffer->height;
 +	g2dSurface->base.rot    = G2D_ROTATION_0;
 +}
 +
@@ -561,8 +584,8 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +
 +	if(g2d_blitEx(handle, srcG2dSurface, dstG2dSurface))
 +	{
-+		printG2dSurfaceInfo(srcG2dSurface);
-+		printG2dSurfaceInfo(dstG2dSurface);
++		printG2dSurfaceInfo(srcG2dSurface, "SRC:");
++		printG2dSurfaceInfo(dstG2dSurface, "DST:");
 +		return -1;
 +	}
 +	return 0;
@@ -574,7 +597,7 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +	struct g2d_output_state *go = get_output_state(output);
 +	go->fb_info.varinfo.yoffset  = go->activebuffer * go->fb_info.y_resolution;
 +
-+	if(ioctl(go->fb_fd, FBIOPAN_DISPLAY, &(go->fb_info.varinfo)) < 0)
++	if(ioctl(go->fb_info.fb_fd, FBIOPAN_DISPLAY, &(go->fb_info.varinfo)) < 0)
 +	{
 +		weston_log("FBIOPAN_DISPLAY Failed\n");
 +	}
@@ -596,6 +619,28 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +			&go->renderSurf[go->activebuffer], &srcRect, &dstrect);
 +	}
 +
++	if(go->clone_display_num)
++	{
++		int i = 0;
++		for(i = 0; i < go->clone_display_num; i++)
++		{
++			g2dRECT srcRect  = {0, 0, go->renderSurf[go->activebuffer].base.width, go->renderSurf[go->activebuffer].base.height};
++			g2dRECT dstrect  = {0, 0, go->mirrorSurf[i].base.width, go->mirrorSurf[i].base.height};
++			g2dRECT clipRect = srcRect;
++			g2d_set_clipping(gr->handle, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
++			if(go->directBlit || go->nNumBuffers > 1)
++			{
++				g2d_blitSurface(gr->handle, &go->renderSurf[go->activebuffer],
++				&go->mirrorSurf[i], &srcRect, &dstrect);
++			}
++			else
++			{
++				g2d_blitSurface(gr->handle, &go->offscreenSurface,
++					&go->mirrorSurf[i], &srcRect, &dstrect);
++			}
++		}
++	}
++
 +	g2d_finish(gr->handle);
 +
 +	if(go->nNumBuffers > 1)
@@ -843,6 +888,8 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +			     pixman_region32_t *output_damage)
 +{
 +	struct g2d_output_state *go = get_output_state(output);
++	struct weston_compositor *compositor = output->compositor;
++	struct g2d_renderer *gr = get_renderer(compositor);
 +	int i;
 +
 +	use_output(output);
@@ -855,6 +902,7 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +			      &go->buffer_damage[go->current_buffer]);
 +
 +	repaint_views(output, output_damage);
++	g2d_finish(gr->handle);
 +
 +	pixman_region32_copy(&output->previous_damage, output_damage);
 +	wl_signal_emit(&output->frame_signal, output);
@@ -865,7 +913,7 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +static void
 +g2d_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer)
 +{
-+	gcsWL_VIV_BUFFER *vivBuffer = wl_resource_get_user_data(buffer->resource);
++	struct wl_viv_buffer *vivBuffer = wl_resource_get_user_data(buffer->resource);
 +	struct g2d_surface_state *gs = get_surface_state(es);
 +	buffer->width = vivBuffer->width;
 +	buffer->height = vivBuffer->height;
@@ -906,7 +954,7 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +		wl_shm_buffer_begin_access(buffer->shm_buffer);
 +		if(gs->shm_buf)
 +		{
-+			int alignedWidth = (buffer->width + 15) & ~15;
++			int alignedWidth = ALIGN_WIDTH(buffer->width);
 +			if(alignedWidth == buffer->width)
 +			{
 +				int size = wl_shm_buffer_get_stride(buffer->shm_buffer)*buffer->height;
@@ -925,7 +973,6 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +					}
 +				}
 +			}
-+			g2d_cache_op(gs->shm_buf, G2D_CACHE_CLEAN);
 +		}
 +		else
 +		{
@@ -950,7 +997,6 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +			struct wl_shm_buffer *shm_buffer)
 +{
 +	struct g2d_surface_state *gs = get_surface_state(es);
-+	int stride = 0;
 +	int buffer_length = 0;
 +	int alloc_new_buff = 1;
 +	int alignedWidth = 0;
@@ -958,17 +1004,15 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +	buffer->shm_buffer = shm_buffer;
 +	buffer->width = wl_shm_buffer_get_width(shm_buffer);
 +	buffer->height = wl_shm_buffer_get_height(shm_buffer);
-+	alignedWidth = (buffer->width + 15) & ~15;
-+	stride = wl_shm_buffer_get_stride(shm_buffer);
-+	buffer_length = stride * buffer->height;
++	alignedWidth = ALIGN_WIDTH(buffer->width);
 +
 +	switch (wl_shm_buffer_get_format(shm_buffer)) {
 +	case WL_SHM_FORMAT_XRGB8888:
-+		g2dFormat = G2D_XRGB8888;
++		g2dFormat = G2D_BGRX8888;
 +		gs->bpp = 4;
 +		break;
 +	case WL_SHM_FORMAT_ARGB8888:
-+		g2dFormat = G2D_ARGB8888;
++		g2dFormat = G2D_BGRA8888;
 +		gs->bpp = 4;
 +		break;
 +	case WL_SHM_FORMAT_RGB565:
@@ -994,7 +1038,7 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +	{
 +		if(gs->shm_buf)
 +			g2d_free(gs->shm_buf);
-+		gs->shm_buf = g2d_alloc(buffer_length, 1);
++		gs->shm_buf = g2d_alloc(buffer_length, 0);
 +		gs->g2d_surface.base.planes[0] = gs->shm_buf->buf_paddr;
 +	}
 +	gs->g2d_surface.base.left = 0;
@@ -1135,7 +1179,7 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +g2d_renderer_output_destroy(struct weston_output *output)
 +{
 +	struct g2d_output_state *go = get_output_state(output);
-+	gctUINT32 i;
++	int i;
 +
 +	for (i = 0; i < 2; i++)
 +	{
@@ -1148,10 +1192,10 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +		go->offscreen_buf = NULL;
 +	}
 +
-+	if(go->fb_fd)
++	if(go->fb_info.fb_fd)
 +	{
-+		close(go->fb_fd);
-+		go->fb_fd = 0;
++		close(go->fb_info.fb_fd);
++		go->fb_info.fb_fd = 0;
 +	}
 +
 +	if(go->renderSurf)
@@ -1159,6 +1203,24 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +		free(go->renderSurf);
 +		go->renderSurf = NULL;
 +	}
++	for (i = 0; i < go->clone_display_num; i++)
++	{
++		if(go->mirror_fb_info[i].fb_fd)
++		{
++			close(go->mirror_fb_info[i].fb_fd);
++			go->mirror_fb_info[i].fb_fd = 0;
++		}
++	}
++	if(go->mirrorSurf)
++	{
++		free(go->mirrorSurf);
++		go->mirrorSurf = NULL;
++	}
++	if(go->mirror_fb_info)
++	{
++		free(go->mirror_fb_info);
++		go->mirror_fb_info = NULL;
++	}
 +
 +	free(go);
 +}
@@ -1169,8 +1231,12 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +	struct g2d_renderer *gr = get_renderer(ec);
 +
 +	wl_signal_emit(&gr->destroy_signal, gr);
-+	wl_global_destroy(gr->viv_global);
 +	g2d_close(gr->handle);
++#ifdef ENABLE_EGL
++	eglUnbindWaylandDisplayWL(gr->egl_display);
++	eglTerminate(gr->egl_display);
++	fbDestroyDisplay(gr->display);
++#endif
 +	free(ec->renderer);
 +	ec->renderer = NULL;
 +}
@@ -1238,7 +1304,7 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +		g2dSurface->base.top  = 0;
 +		g2dSurface->base.right  = info->x_resolution;
 +		g2dSurface->base.bottom = info->y_resolution;
-+		g2dSurface->base.stride = info->x_resolution;
++		g2dSurface->base.stride = info->stride;
 +		g2dSurface->base.width  = info->x_resolution;
 +		g2dSurface->base.height = info->y_resolution;
 +		g2dSurface->base.format = info->pixel_format;
@@ -1278,6 +1344,8 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +	info->y_resolution = varinfo->yres;
 +	info->physical = fixinfo->smem_start;
 +	info->buffer_length = fixinfo->smem_len;
++	info->stride = fixinfo->line_length / (varinfo->bits_per_pixel >> 3);
++	info->stride_bytes = fixinfo->line_length;
 +	calculate_g2d_format(varinfo, &info->pixel_format);
 +
 +	if (info->pixel_format < 0) {
@@ -1293,39 +1361,27 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +                        struct fb_screeninfo *screen_info)
 +{
 +	/* Open the frame buffer device. */
-+	output->fb_fd = open(fb_dev, O_RDWR | O_CLOEXEC);
-+	if (output->fb_fd < 0) {
++	screen_info->fb_fd = open(fb_dev, O_RDWR | O_CLOEXEC);
++	if (screen_info->fb_fd < 0) {
 +		weston_log("Failed to open frame buffer device%s \n", fb_dev);
 +		return -1;
 +	}
 +
 +	/* Grab the screen info. */
-+	if (fb_query_screen_info(output, output->fb_fd, screen_info) < 0) {
++	if (fb_query_screen_info(output, screen_info->fb_fd, screen_info) < 0) {
 +		weston_log("Failed to get frame buffer info \n");
 +
-+		close(output->fb_fd);
++		close(screen_info->fb_fd);
 +		return -1;
 +	}
 +
 +	return 0;
 +}
 +
-+static int
-+g2d_renderer_output_create(struct weston_output *output, struct wl_display *wl_display, const char *device)
-+
-+ {
-+	struct g2d_renderer *gr = get_renderer(output->compositor);
-+	struct g2d_output_state *go;
-+	int i = 0;
-+	int offset = 0;
++static void
++getBufferNumber(struct g2d_output_state *go)
++{
 +	char *p = NULL;
-+	go = zalloc(sizeof *go);
-+	if (go == NULL)
-+		return -1;
-+
-+	output->renderer_state = go;
-+	gr->viv_global = gcoOS_WaylandCreateVivGlobal(wl_display);
-+
 +	p = getenv("FB_MULTI_BUFFER");
 +	if (p == gcvNULL)
 +	{
@@ -1334,7 +1390,7 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +	else
 +	{
 +		go->nNumBuffers = atoi(p);
-+		if (go->nNumBuffers < 1)
++		if (go->nNumBuffers < 2)
 +		{
 +			go->nNumBuffers  = 1;
 +		}
@@ -1345,15 +1401,21 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +		}
 +	}
 +	weston_log("FB_MULTI_BUFFER = %d\n", go->nNumBuffers);
++}
 +
++static int
++g2d_renderer_surface_create(struct g2d_output_state *go, struct g2d_renderer *gr, const char *device)
++{
++	int i = 0;
++	int offset = 0;
++	weston_log("Opend device=%s\n", device);
 +	if(fb_frame_buffer_open(go, device, &go->fb_info) < 0)
 +	{
 +		weston_log("Open frame buffer failed.\n");
 +		return -1;
 +	}
-+
 +	go->renderSurf = zalloc(sizeof(struct g2d_surfaceEx) * go->nNumBuffers);
-+	offset = go->fb_info.buffer_length/go->nNumBuffers;
++	offset = go->fb_info.stride_bytes * go->fb_info.y_resolution;
 +	for(i = 0; i < go->nNumBuffers; i++)
 +	{
 +		get_G2dSurface_from_screeninfo(&go->fb_info, &go->renderSurf[i]);
@@ -1369,9 +1431,89 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +		go->offscreenSurface.base.planes[0] = go->offscreen_buf->buf_paddr;
 +		g2d_clear(gr->handle, &go->offscreenSurface.base);
 +	}
++	return 0;
++}
 +
++static int
++g2d_renderer_output_create(struct weston_output *output, struct wl_display *wl_display, const char *device)
++
++ {
++	struct g2d_renderer *gr = get_renderer(output->compositor);
++	struct g2d_output_state *go;
++	int i;
++	int clone_display_num = 0;
++	int count = 0;
++	int k=0, dispCount = 0;
++	char displays[5][32];
++	weston_log("g2d_renderer_output_create device=%s\n", device);
++	count = strlen(device);
++
++	if(count > 0)
++	{
++		for(i= 0; i < count; i++)
++		{
++			if(device[i] == ',')
++			{
++				displays[dispCount][k] = '\0';
++				dispCount++;
++				k = 0;
++				continue;
++			}
++			else if(device[i] != ' ')
++			{
++				displays[dispCount][k++] = device[i];
++			}
++		}
++		displays[dispCount][k] = '\0';
++		clone_display_num = dispCount++;
++		weston_log("clone_display_num = %d\n", clone_display_num);
++	}
++	else
++	{
++		weston_log("Invalid device name\n");
++		return -1;
++	}
++
++	go = zalloc(sizeof *go);
++	if (go == NULL)
++		return -1;
++	go->clone_display_num  = clone_display_num;
++	output->renderer_state = go;
++#ifdef ENABLE_EGL
++	gr->wl_display = wl_display;
++	gr->display = fbGetDisplay(wl_display);
++	gr->egl_display = eglGetDisplay(gr->display);
++	eglBindWaylandDisplayWL(gr->egl_display, wl_display);
++#endif
++	getBufferNumber(go);
++
++	if(g2d_renderer_surface_create(go, gr, displays[0]) < 0)
++	{
++		weston_log("Create Render surface failed.\n");
++		return -1;
++	}
++
++	if(go->clone_display_num)
++	{
++		go->mirrorSurf = zalloc(sizeof(struct g2d_surfaceEx) * clone_display_num);
++		go->mirror_fb_info = zalloc(sizeof(struct fb_screeninfo) * clone_display_num);
++		if(go->mirrorSurf == NULL || go->mirror_fb_info == NULL)
++			return -1;
++
++		for(i = 0; i < clone_display_num; i++)
++		{
++			if(fb_frame_buffer_open(go, displays[i + 1], &go->mirror_fb_info[i]) < 0)
++			{
++				weston_log("Open frame buffer failed.\n");
++				return -1;
++			}
++			get_G2dSurface_from_screeninfo(&go->mirror_fb_info[i], &go->mirrorSurf[i]);
++			go->mirrorSurf[i].base.planes[0] = go->mirror_fb_info[i].physical;
++			g2d_clear(gr->handle, &go->mirrorSurf[i].base);
++		}
++	}
 +	g2d_finish(gr->handle);
-+	for (i = 0; i < 2; i++)
++	for (i = 0; i < BUFFER_DAMAGE_COUNT; i++)
 +		pixman_region32_init(&go->buffer_damage[i]);
 +    return 0;
 + }
@@ -1381,11 +1523,12 @@ Index: weston-1.11.1/src/g2d-renderer.c
 +	.output_create = g2d_renderer_output_create,
 +	.output_destroy = g2d_renderer_output_destroy,
 +};
-Index: weston-1.11.1/src/g2d-renderer.h
-===================================================================
---- /dev/null	1970-01-01 00:00:00.000000000 +0000
-+++ weston-1.11.1/src/g2d-renderer.h	2017-01-14 09:08:38.000000000 -0600
-@@ -0,0 +1,48 @@
+diff --git a/src/g2d-renderer.h b/src/g2d-renderer.h
+new file mode 100644
+index 0000000..fc4ca49
+--- /dev/null
++++ b/src/g2d-renderer.h
+@@ -0,0 +1,47 @@
 +/*
 + * Copyright (c) 2015 Freescale Semiconductor, Inc.
 + * Copyright © 2013 Vasily Khoruzhick <anarsoul@gmail.com>
@@ -1415,13 +1558,12 @@ Index: weston-1.11.1/src/g2d-renderer.h
 +#define __g2d_renderer_h_
 +
 +#include  "compositor.h"
++
 +#ifdef ENABLE_EGL
 +#include <EGL/egl.h>
-+#else
-+#include <HAL/gc_hal_eglplatform.h>
++#include <EGL/eglext.h>
 +#endif
 +
-+
 +struct g2d_renderer_interface {
 +
 +	int (*create)(struct weston_compositor *ec);
@@ -1434,1410 +1576,30 @@ Index: weston-1.11.1/src/g2d-renderer.h
 +};
 +
 +#endif
-Index: weston-1.11.1/src/gal2d-renderer.c
-===================================================================
---- weston-1.11.1.orig/src/gal2d-renderer.c	2017-01-14 08:59:52.753868091 -0600
-+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
-@@ -1,1307 +0,0 @@
--/*
-- * Copyright (c) 2015 Freescale Semiconductor, Inc.
-- * Copyright © 2012 Intel Corporation
-- * Copyright © 2015 Collabora, Ltd.
-- *
-- * Permission is hereby granted, free of charge, to any person obtaining
-- * a copy of this software and associated documentation files (the
-- * "Software"), to deal in the Software without restriction, including
-- * without limitation the rights to use, copy, modify, merge, publish,
-- * distribute, sublicense, and/or sell copies of the Software, and to
-- * permit persons to whom the Software is furnished to do so, subject to
-- * the following conditions:
-- *
-- * The above copyright notice and this permission notice (including the
-- * next paragraph) shall be included in all copies or substantial
-- * portions of the Software.
-- *
-- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-- * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- * SOFTWARE.
-- */
--
--#define _GNU_SOURCE
--
--#include <stdlib.h>
--#include <string.h>
--#include <ctype.h>
--#include <float.h>
--#include <assert.h>
--#include <pthread.h>
--
--#include "compositor.h"
--#include "gal2d-renderer.h"
--#include "vertex-clipping.h"
--#include "shared/helpers.h"
--#include "HAL/gc_hal.h"
--#include "HAL/gc_hal_raster.h"
--#include "HAL/gc_hal_eglplatform.h"
--
--#define galONERROR(x)  if(status < 0) printf("Error in function %s\n", __func__);
--
--struct gal2d_output_state {
--	
--	int current_buffer;
--	pixman_region32_t buffer_damage[2];
--	NativeDisplayType display;
--    gcoSURF* renderSurf;
--	gctUINT32 nNumBuffers;
--	int activebuffer;
--	gcoSURF offscreenSurface;
--	gceSURF_FORMAT format;
--    pthread_mutex_t workerMutex;
--    pthread_t workerId;
--    gctUINT32 exitWorker;
--    gctSIGNAL signal;
--    gctSIGNAL busySignal;
--    gcsHAL_INTERFACE iface;
--    int directBlit;
--    gctINT width;
--    gctINT height;
--};
--
--struct gal2d_surface_state {
--	float color[4];
--	struct weston_buffer_reference buffer_ref;
--	int pitch; /* in pixels */
--    pixman_region32_t texture_damage;
--    gcoSURF gco_Surface;
--
--    struct weston_surface *surface;
--    struct wl_listener surface_destroy_listener;
--    struct wl_listener renderer_destroy_listener;
--};
--
--struct gal2d_renderer {
--	struct weston_renderer base;
--    struct wl_signal destroy_signal;
--    gcoOS gcos;
--	gcoHAL gcoHal;
--	gco2D gcoEngine2d;
--    gctPOINTER  localInfo;
--};
--
--static int
--gal2d_renderer_create_surface(struct weston_surface *surface);
--
--static inline struct gal2d_surface_state *
--get_surface_state(struct weston_surface *surface)
--{
--	if (!surface->renderer_state)
--		gal2d_renderer_create_surface(surface);
--	return (struct gal2d_surface_state *)surface->renderer_state;
--}
--
--static inline struct gal2d_renderer *
--get_renderer(struct weston_compositor *ec)
--{
--	return (struct gal2d_renderer *)ec->renderer;
--}
--
--
--
--#define max(a, b) (((a) > (b)) ? (a) : (b))
--#define min(a, b) (((a) > (b)) ? (b) : (a))
--/*
-- * Compute the boundary vertices of the intersection of the global coordinate
-- * aligned rectangle 'rect', and an arbitrary quadrilateral produced from
-- * 'surf_rect' when transformed from surface coordinates into global coordinates.
-- * The vertices are written to 'ex' and 'ey', and the return value is the
-- * number of vertices. Vertices are produced in clockwise winding order.
-- * Guarantees to produce either zero vertices, or 3-8 vertices with non-zero
-- * polygon area.
-- */
--static int
--calculate_edges(struct weston_view *ev, pixman_box32_t *rect,
--		pixman_box32_t *surf_rect, float *ex, float *ey)
--{
--
--	struct clip_context ctx;
--	int i, n;
--	float min_x, max_x, min_y, max_y;
--	struct polygon8 surf = {
--		{ surf_rect->x1, surf_rect->x2, surf_rect->x2, surf_rect->x1 },
--		{ surf_rect->y1, surf_rect->y1, surf_rect->y2, surf_rect->y2 },
--		4
--	};
--
--	ctx.clip.x1 = rect->x1;
--	ctx.clip.y1 = rect->y1;
--	ctx.clip.x2 = rect->x2;
--	ctx.clip.y2 = rect->y2;
--
--	/* transform surface to screen space: */
--	for (i = 0; i < surf.n; i++)
--		weston_view_to_global_float(ev, surf.x[i], surf.y[i],
--					    &surf.x[i], &surf.y[i]);
--
--	/* find bounding box: */
--	min_x = max_x = surf.x[0];
--	min_y = max_y = surf.y[0];
--
--	for (i = 1; i < surf.n; i++) {
--		min_x = min(min_x, surf.x[i]);
--		max_x = max(max_x, surf.x[i]);
--		min_y = min(min_y, surf.y[i]);
--		max_y = max(max_y, surf.y[i]);
--	}
--
--	/* First, simple bounding box check to discard early transformed
--	 * surface rects that do not intersect with the clip region:
--	 */
--	if ((min_x >= ctx.clip.x2) || (max_x <= ctx.clip.x1) ||
--	    (min_y >= ctx.clip.y2) || (max_y <= ctx.clip.y1))
--		return 0;
--
--	/* Simple case, bounding box edges are parallel to surface edges,
--	 * there will be only four edges.  We just need to clip the surface
--	 * vertices to the clip rect bounds:
--	 */
--	if (!ev->transform.enabled)
--		return clip_simple(&ctx, &surf, ex, ey);
--
--	/* Transformed case: use a general polygon clipping algorithm to
--	 * clip the surface rectangle with each side of 'rect'.
--	 * The algorithm is Sutherland-Hodgman, as explained in
--	 * http://www.codeguru.com/cpp/misc/misc/graphics/article.php/c8965/Polygon-Clipping.htm
--	 * but without looking at any of that code.
--	 */
--	n = clip_transformed(&ctx, &surf, ex, ey);
--
--	if (n < 3)
--		return 0;
--
--	return n;
--}
--
--
--static inline struct gal2d_output_state *
--get_output_state(struct weston_output *output)
--{
--	return (struct gal2d_output_state *)output->renderer_state;
--}
--
--static gceSTATUS
--gal2d_getSurfaceFormat(halDISPLAY_INFO info, gceSURF_FORMAT * Format)
--{
--	/* Get the color format. */
--    switch (info.greenLength)
--    {
--    case 4:
--        if (info.blueOffset == 0)
--        {
--            *Format = (info.alphaLength == 0) ? gcvSURF_X4R4G4B4 : gcvSURF_A4R4G4B4;
--        }
--        else
--        {
--            *Format = (info.alphaLength == 0) ? gcvSURF_X4B4G4R4 : gcvSURF_A4B4G4R4;
--        }
--        break;
--
--    case 5:
--        if (info.blueOffset == 0)
--        {
--            *Format = (info.alphaLength == 0) ? gcvSURF_X1R5G5B5 : gcvSURF_A1R5G5B5;
--        }
--        else
--        {
--            *Format = (info.alphaLength == 0) ? gcvSURF_X1B5G5R5 : gcvSURF_A1B5G5R5;
--        }
--        break;
--
--    case 6:
--        *Format = gcvSURF_R5G6B5;
--        break;
--
--    case 8:
--        if (info.blueOffset == 0)
--        {
--            *Format = (info.alphaLength == 0) ? gcvSURF_X8R8G8B8 : gcvSURF_A8R8G8B8;
--        }
--        else
--        {
--            *Format = (info.alphaLength == 0) ? gcvSURF_X8B8G8R8 : gcvSURF_A8B8G8R8;
--        }
--        break;
--
--    default:
--        /* Unsupported color depth. */
--        return gcvSTATUS_INVALID_ARGUMENT;
--    }
--	/* Success. */
--    return gcvSTATUS_OK;
--}
--
--static gceSTATUS galIsYUVFormat(IN gceSURF_FORMAT Format)
--{
--    switch (Format)
--    {
--    case gcvSURF_YUY2:
--    case gcvSURF_UYVY:
--    case gcvSURF_I420:
--    case gcvSURF_YV12:
--    case gcvSURF_NV16:
--    case gcvSURF_NV12:
--    case gcvSURF_NV61:
--    case gcvSURF_NV21:
--
--        return gcvSTATUS_TRUE;
--
--    default:
--        return gcvSTATUS_FALSE;
--    }
--}
--
--static gceSTATUS galQueryUVStride(
--    IN gceSURF_FORMAT Format,
--    IN gctUINT32 yStride,
--    OUT gctUINT32_PTR uStride,
--    OUT gctUINT32_PTR vStride
--    )
--{
--    switch (Format)
--    {
--    case gcvSURF_YUY2:
--    case gcvSURF_UYVY:
--        *uStride = *vStride = 0;
--        break;
--
--    case gcvSURF_I420:
--    case gcvSURF_YV12:
--        *uStride = *vStride = yStride / 2;
--        break;
--
--    case gcvSURF_NV16:
--    case gcvSURF_NV12:
--    case gcvSURF_NV61:
--    case gcvSURF_NV21:
--
--        *uStride = yStride;
--        *vStride = 0;
--        break;
--
--    default:
--        return gcvSTATUS_NOT_SUPPORTED;
--    }
--
--    return gcvSTATUS_OK;
--}
--
--static int
--make_current(struct gal2d_renderer *gr, gcoSURF surface)
--{    
--	gceSTATUS status = gcvSTATUS_OK;
--	gctUINT width = 0;
--	gctUINT height = 0;
--	gctINT stride = 0;
--	gctUINT32 physical[3];
--	gctPOINTER va =0;
--    gceSURF_FORMAT format;
--
--	if(!surface)
--		goto OnError;
--    
--
--	gcmONERROR(gcoSURF_GetAlignedSize(surface, &width, &height, &stride));
--    gcmONERROR(gcoSURF_GetFormat(surface, gcvNULL, &format));
--	gcmONERROR(gcoSURF_Lock(surface, &physical[0], (gctPOINTER *)&va));    
--    gco2D_SetGenericTarget(gr->gcoEngine2d, 
--                        &physical[0], 1, 
--                        &stride, 1, 
--                        gcvLINEAR, format,
--                        gcvSURF_0_DEGREE, width, height);
--	
--	gcmONERROR(gcoSURF_Unlock(surface, (gctPOINTER *)&va));
--OnError:
--    galONERROR(status);
--	return status;
--}
--
--static gceSTATUS
--gal2d_clear(struct weston_output *base)
--{
--    struct gal2d_renderer *gr = get_renderer(base->compositor);
--	struct gal2d_output_state *go = get_output_state(base);    
--	gceSTATUS status = gcvSTATUS_OK;
--	
--	gctINT stride = 0;
--	gctUINT width = 0, height = 0;
--	gcsRECT dstRect = {0};
--	gcmONERROR(gcoSURF_GetAlignedSize(go->renderSurf[go->activebuffer],
--					&width, &height, &stride));
--	dstRect.right = width;
--	dstRect.bottom = height;
--	gcmONERROR(gco2D_SetSource(gr->gcoEngine2d, &dstRect));
--	gcmONERROR(gco2D_SetClipping(gr->gcoEngine2d, &dstRect));
--	gcmONERROR(gco2D_Clear(gr->gcoEngine2d, 1, &dstRect, 0xff0000ff, 0xCC, 0xCC, go->format));
--    gcmONERROR(gcoHAL_Commit(gr->gcoHal, gcvTRUE));
--
--OnError:
--	galONERROR(status);
--    
--	return status;
--}
--
--static gcoSURF getSurfaceFromShm(struct weston_surface *es, struct weston_buffer *buffer)
--{	
--    struct gal2d_renderer *gr = get_renderer(es->compositor);
--	
--	gcoSURF surface = 0;
--	gceSURF_FORMAT format;
--	gcePOOL pool = gcvPOOL_DEFAULT;
--
--	if (wl_shm_buffer_get_format(buffer->shm_buffer) == WL_SHM_FORMAT_XRGB8888)
--		format = gcvSURF_X8R8G8B8;
--	else
--		format = gcvSURF_A8R8G8B8;
--
--	if(buffer->width == ((buffer->width + 0x7) & ~0x7))
--	{
--		pool = gcvPOOL_USER;
--	}
--
--	gcmVERIFY_OK(gcoSURF_Construct(gr->gcoHal,
--						  (gctUINT) buffer->width,
--						  (gctUINT) buffer->height,
--						  1, gcvSURF_BITMAP,
--						  format, pool, &surface));
--
--	if(pool == gcvPOOL_USER)
--	{
--		gcmVERIFY_OK(gcoSURF_MapUserSurface(surface, 1,
--					(gctPOINTER)wl_shm_buffer_get_data(buffer->shm_buffer), gcvINVALID_ADDRESS));
--	}
--
--	return surface;
--}
--
--static int
--gal2dBindBuffer(struct weston_surface* es)
--{
--    struct gal2d_surface_state *gs = get_surface_state(es);
--	gceSTATUS status = gcvSTATUS_OK;
--	gcoSURF surface = gs->gco_Surface;	
--    struct weston_buffer *buffer = gs->buffer_ref.buffer;
--	gcePOOL pool = gcvPOOL_DEFAULT;
--    
--	gcmVERIFY_OK(gcoSURF_QueryVidMemNode(surface, gcvNULL,
--						&pool, gcvNULL));
--
--	if(pool != gcvPOOL_USER)
--	{
--		gctUINT alignedWidth;
--		gctPOINTER logical = (gctPOINTER)wl_shm_buffer_get_data(buffer->shm_buffer);
--		gctPOINTER va =0;
--
--
--		gcmVERIFY_OK(gcoSURF_GetAlignedSize(surface, &alignedWidth, gcvNULL, gcvNULL));
--		gcmVERIFY_OK(gcoSURF_Lock(surface, gcvNULL, (gctPOINTER *)&va));
--      
--		if(alignedWidth == (unsigned int)buffer->width)
--		{
--			int size = wl_shm_buffer_get_stride(buffer->shm_buffer)*buffer->height;
--			memcpy(va, logical, size);
--		}
--		else
--		{
--			int i, j;
--			for (i = 0; i < buffer->height; i++)
--			{
--				for (j = 0; j < buffer->width; j++)
--				{
--					gctUINT dstOff = i * alignedWidth + j;
--					gctUINT srcOff = (i * buffer->width + j);
--
--					memcpy(va + dstOff * 4, logical + srcOff * 4, 4);
--				}
--			}
--		}
--		gcmVERIFY_OK(gcoSURF_Unlock(surface, (gctPOINTER)va));
--	}
--
--	return status;
--}
--
--static void
--gal2d_flip_surface(struct weston_output *output)
--{
--	struct gal2d_output_state *go = get_output_state(output);
--
--	if(go->nNumBuffers > 1)
--	{
--		gctUINT Offset;
--		gctINT X;
--		gctINT Y;
--
--		gcmVERIFY_OK(gcoOS_GetDisplayBackbuffer(go->display, gcvNULL,
--									gcvNULL, gcvNULL, &Offset, &X, &Y));
--
--		gcmVERIFY_OK(gcoOS_SetDisplayVirtual(go->display, gcvNULL,
--									Offset, X, Y));
--	}
--}
--
--static void *gal2d_output_worker(void *arg)
--{
--    struct weston_output *output = (struct weston_output *)arg;
--    struct gal2d_output_state *go = get_output_state(output);
--
--    while(1)
--    {
--        if(gcoOS_WaitSignal(gcvNULL, go->signal, gcvINFINITE) == gcvSTATUS_OK )
--        {
--            gal2d_flip_surface(output);
--            gcoOS_Signal(gcvNULL,go->busySignal, gcvTRUE);
--        }
--        pthread_mutex_lock(&go->workerMutex);
--        if(go->exitWorker == 1)
--        {
--            pthread_mutex_unlock(&go->workerMutex);
--            break;
--        }
--        pthread_mutex_unlock(&go->workerMutex);
--    }
--    return 0;
--}
--
--static int
--update_surface(struct weston_output *output)
--{
--    struct gal2d_renderer *gr = get_renderer(output->compositor);
--    struct gal2d_output_state *go = get_output_state(output);
--    gceSTATUS status = gcvSTATUS_OK;
--
--    if(go->nNumBuffers == 1)
--    {
--        if(!go->directBlit && go->offscreenSurface)
--        {
--            make_current(gr, go->renderSurf[go->activebuffer]);
--
--            gctUINT srcWidth = 0;
--            gctUINT srcHeight = 0;
--            gceSURF_FORMAT srcFormat;;
--            gcsRECT dstRect = {0};
--            gcoSURF srcSurface = go->offscreenSurface;
--            gctUINT32 srcPhyAddr[3];
--            gctUINT32 srcStride[3];
--
--            gctPOINTER va =0;
--
--            gcmONERROR(gcoSURF_GetAlignedSize(srcSurface, &srcWidth, &srcHeight, (gctINT *)&srcStride[0]));
--            gcmONERROR(gcoSURF_GetFormat(srcSurface, gcvNULL, &srcFormat));
--
--            gcmONERROR(gcoSURF_Lock(srcSurface, srcPhyAddr, (gctPOINTER *)&va));
--            gcmONERROR(gco2D_SetCurrentSourceIndex(gr->gcoEngine2d, 0U));
--
--            gco2D_SetGenericSource(gr->gcoEngine2d, srcPhyAddr, 1,
--				        srcStride, 1,
--				        gcvLINEAR, srcFormat, gcvSURF_0_DEGREE,
--				        srcWidth, srcHeight);
--
--            dstRect.left 	= 0;
--            dstRect.top		= 0;
--            dstRect.right 	= srcWidth;
--            dstRect.bottom 	= srcHeight;
--
--            gcmONERROR(gco2D_SetSource(gr->gcoEngine2d, &dstRect));
--            gcmONERROR(gco2D_SetClipping(gr->gcoEngine2d, &dstRect));
--            gcmONERROR(gco2D_Blit(gr->gcoEngine2d, 1, &dstRect, 0xCC, 0xCC, go->format));
--            gcmONERROR(gcoSURF_Unlock(srcSurface, (gctPOINTER *)&va));
--        }
--		gcmONERROR(gcoHAL_Commit(gr->gcoHal, gcvFALSE));
--	}
--    else if(go->nNumBuffers > 1)
--    {
--        gcoHAL_ScheduleEvent(gr->gcoHal, &go->iface);
--        gcmVERIFY_OK(gcoHAL_Commit(gr->gcoHal, gcvFALSE));
--    }
--OnError:
--    galONERROR(status);
--    return status;
-- }
--
--static int
--is_view_visible(struct weston_view *view)
--{
--	/* Return false, if surface is guaranteed to be totally obscured. */
--	int ret;
--	pixman_region32_t unocc;
--
--	pixman_region32_init(&unocc);
--	pixman_region32_subtract(&unocc, &view->transform.boundingbox,
--				 &view->clip);
--	ret = pixman_region32_not_empty(&unocc);
--	pixman_region32_fini(&unocc);
--
--	return ret;
--}
-- 
--static int
--use_output(struct weston_output *output)
--{
--    struct weston_compositor *compositor = output->compositor;
--	struct weston_view *view;
--    struct gal2d_output_state *go = get_output_state(output);	
--	struct gal2d_renderer *gr = get_renderer(output->compositor);    
--    gceSTATUS status = gcvSTATUS_OK;
--
--    gcoSURF surface;
--    int visibleViews=0;
--    int fullscreenViews=0;
-- 
--    surface = go->renderSurf[go->activebuffer];
--    if(go->nNumBuffers == 1)
--    {
--        wl_list_for_each_reverse(view, &compositor->view_list, link)
--            if (view->plane == &compositor->primary_plane && is_view_visible(view))
--            {
--                visibleViews++;
--                if(view->surface->width == go->width && view->surface->height == go->height)
--                {
--                    pixman_box32_t *bb_rects;
--                    int nbb=0;
--                    bb_rects = pixman_region32_rectangles(&view->transform.boundingbox, &nbb);
--                    if(nbb == 1)
--                        if(bb_rects[0].x1 == 0 && bb_rects[0].y1 ==0)
--                            fullscreenViews++;
--                }
--            }
--
--        go->directBlit = ((visibleViews == 1) || (fullscreenViews > 1));
--
--        if(!go->directBlit)
--        {
--             surface = go->offscreenSurface;
--        }
--    }
--    make_current(gr, surface);
--    return status;
--}
--
--static int
--gal2d_renderer_read_pixels(struct weston_output *output,
--			       pixman_format_code_t format, void *pixels,
--			       uint32_t x, uint32_t y,
--			       uint32_t width, uint32_t height)
--{
--	return 0;
--}
--
--static int gal2d_int_from_double(double d)
--{
--	return wl_fixed_to_int(wl_fixed_from_double(d));
--}
--
--static void
--repaint_region(struct weston_view *ev, struct weston_output *output, struct gal2d_output_state *go, pixman_region32_t *region,
--		pixman_region32_t *surf_region){
--
--    struct gal2d_renderer *gr = get_renderer(ev->surface->compositor);
--    struct gal2d_surface_state *gs = get_surface_state(ev->surface);
--
--	pixman_box32_t *rects, *surf_rects, *bb_rects;
--	int i, j, nrects, nsurf, nbb=0;
--	gceSTATUS status = gcvSTATUS_OK;
--	gcoSURF srcSurface = gs->gco_Surface;
--	gcsRECT srcRect = {0};
--	gcsRECT dstrect = {0};
--	gctUINT32 horFactor, verFactor;
--	int useFilterBlit = 0;
--	gctUINT srcWidth = 0;
--	gctUINT srcHeight = 0;
--	gctUINT32 srcStride[3];
--	gceSURF_FORMAT srcFormat;
--	gctUINT32 srcPhyAddr[3];
--	gctUINT32 dstPhyAddr[3];
--	gctUINT dstWidth = 0;
--	gctUINT dstHeight = 0;
--	gctUINT32 dstStrides[3];
--	gcoSURF dstsurface;
--	int geoWidth = ev->surface->width;
--	int geoheight = ev->surface->height;
--    gceTILING tiling;
--
--	bb_rects = pixman_region32_rectangles(&ev->transform.boundingbox, &nbb);
--
--	if(!srcSurface || nbb <= 0)
--		goto OnError;
--	rects = pixman_region32_rectangles(region, &nrects);
--	surf_rects = pixman_region32_rectangles(surf_region, &nsurf);
--
--	gcmVERIFY_OK(gcoSURF_GetAlignedSize(srcSurface, &srcWidth, &srcHeight, (gctINT *)&srcStride[0]));
--
--	gcmVERIFY_OK(gcoSURF_GetFormat(srcSurface, gcvNULL, &srcFormat));
--
--	if(galIsYUVFormat(srcFormat) == gcvSTATUS_TRUE)
--	{
--		useFilterBlit = 1;
--	}
--
--	gcmVERIFY_OK(gcoSURF_Lock(srcSurface, &srcPhyAddr[0], gcvNULL));
--
--	gcmVERIFY_OK(gcoSURF_Unlock(srcSurface, gcvNULL));
--
--	srcRect.left = ev->geometry.x < 0.0 ? gal2d_int_from_double(fabsf(ev->geometry.x)) : 0;
--	srcRect.top = 0; /*es->geometry.y < 0.0 ? gal2d_int_from_double(fabsf(es->geometry.y)) : 0;*/
--	srcRect.right = ev->surface->width;
--	srcRect.bottom = ev->surface->height;
--
--	dstsurface = go->nNumBuffers > 1 ?
--					go->renderSurf[go->activebuffer] :
--					go->offscreenSurface;
--	gcmVERIFY_OK(gcoSURF_GetAlignedSize(dstsurface, &dstWidth, &dstHeight, (gctINT *)&dstStrides));
--	gcmVERIFY_OK(gcoSURF_Lock(dstsurface, &dstPhyAddr[0], gcvNULL));
--	gcmVERIFY_OK(gcoSURF_Unlock(dstsurface, gcvNULL));
--
--	if(galIsYUVFormat(srcFormat) == gcvSTATUS_TRUE)
--	{
--		useFilterBlit = 1;
--	}
--	else
--	{
--        gcoSURF_GetTiling(srcSurface, &tiling);
--        if (gcoHAL_IsFeatureAvailable(gr->gcoHal, gcvFEATURE_2D_TILING) != gcvTRUE && (tiling > gcvLINEAR))
--        {
--            weston_log("Tiling not supported \n");
--            status = gcvSTATUS_NOT_SUPPORTED;
--            gcmONERROR(status);
--        }
--        gco2D_SetGenericSource(gr->gcoEngine2d, srcPhyAddr, 1,
--				        srcStride, 1,
--				        tiling, srcFormat, gcvSURF_0_DEGREE,
--				        srcWidth, srcHeight);
--        gcmVERIFY_OK(gco2D_SetSource(gr->gcoEngine2d, &srcRect));
--         /* Setup mirror. */
--        gcmONERROR(gco2D_SetBitBlitMirror(gr->gcoEngine2d, gcvFALSE, gcvFALSE));
--        gcmONERROR(gco2D_SetROP(gr->gcoEngine2d, 0xCC, 0xCC));
--	}
--
--	for (i = 0; i < nrects; i++)
--	{
--		pixman_box32_t *rect = &rects[i];
--		gctFLOAT min_x, max_x, min_y, max_y;
--
--		dstrect.left = (bb_rects[0].x1 < 0) ? rect->x1 : bb_rects[0].x1;
--		dstrect.top = (bb_rects[0].y1 < 0) ? rect->y1 : bb_rects[0].y1;
--		dstrect.right = bb_rects[0].x2;
--		dstrect.bottom = bb_rects[0].y2;
--
--		if(dstrect.right < 0 || dstrect.bottom < 0 || dstrect.left > dstWidth || dstrect.top > dstHeight)
--		{
--			break;
--		}
--
--		for (j = 0; j < nsurf; j++)
--		{
--			pixman_box32_t *surf_rect = &surf_rects[j];
--			gctFLOAT ex[8], ey[8];          /* edge points in screen space */
--			int n;
--			gcsRECT clipRect = {0};
--			int m=0;
--			n = calculate_edges(ev, rect, surf_rect, ex, ey);
--			if (n < 3)
--				continue;
--
--			min_x = max_x = ex[0];
--			min_y = max_y = ey[0];
--			for (m = 1; m < n; m++)
--			{
--				min_x = min(min_x, ex[m]);
--				max_x = max(max_x, ex[m]);
--				min_y = min(min_y, ey[m]);
--				max_y = max(max_y, ey[m]);
--			}
--
--			clipRect.left = gal2d_int_from_double(min_x);
--			clipRect.top = gal2d_int_from_double(min_y);
--			clipRect.right = gal2d_int_from_double(max_x);
--			clipRect.bottom = gal2d_int_from_double(max_y);
--
--			if(output->x > 0)
--			{
--				dstrect.left = dstrect.left - output->x;
--				dstrect.right = dstrect.right - output->x;
--				clipRect.left = clipRect.left - output->x;
--				clipRect.right = clipRect.right - output->x;
--			}
--
--			dstrect.left = (dstrect.left < 0) ? 0 : dstrect.left;
--			
--			status = gco2D_SetClipping(gr->gcoEngine2d, &clipRect);
--			if(status < 0)
--			{
--				weston_log("Error in gco2D_SetClipping %s\n", __func__);
--				goto OnError;
--			}
--
--			if(useFilterBlit)
--			{
--				gctINT          srcStrideNum;
--				gctINT          srcAddressNum;
--				gcmVERIFY_OK(galQueryUVStride(srcFormat, srcStride[0],
--						&srcStride[1], &srcStride[2]));
--
--				switch (srcFormat)
--				{
--				case gcvSURF_YUY2:
--				case gcvSURF_UYVY:
--					srcStrideNum = srcAddressNum = 1;
--					break;
--
--				case gcvSURF_I420:
--				case gcvSURF_YV12:
--					srcStrideNum = srcAddressNum = 3;
--					break;
--
--				case gcvSURF_NV16:
--				case gcvSURF_NV12:
--				case gcvSURF_NV61:
--				case gcvSURF_NV21:
--					srcStrideNum = srcAddressNum = 2;
--					break;
--
--				default:
--					gcmONERROR(gcvSTATUS_NOT_SUPPORTED);
--				}
--				gco2D_FilterBlitEx2(gr->gcoEngine2d,
--					srcPhyAddr, srcAddressNum,
--					srcStride, srcStrideNum,
--					gcvLINEAR, srcFormat, gcvSURF_0_DEGREE,
--					geoWidth, geoheight, &srcRect,
--					dstPhyAddr, 1,
--					dstStrides, 1,
--					gcvLINEAR, go->format, gcvSURF_0_DEGREE,
--					dstWidth, dstHeight,
--					&dstrect, gcvNULL);
--			}
--			else
--			{
--				gcmVERIFY_OK(gco2D_CalcStretchFactor(gr->gcoEngine2d, srcRect.right - srcRect.left,
--						dstrect.right - dstrect.left, &horFactor));
--
--				gcmONERROR(gco2D_CalcStretchFactor(gr->gcoEngine2d, srcRect.bottom - srcRect.top,
--						dstrect.bottom - dstrect.top, &verFactor));
--
--				if(verFactor == 65536 && horFactor == 65536)
--				{
--					gcmVERIFY_OK(gco2D_Blit(gr->gcoEngine2d, 1, &dstrect,
--											0xCC, 0xCC, go->format));
--				}
--				else
--				{
--					dstrect.right = dstrect.right < dstWidth ? dstrect.right : dstWidth;
--					dstrect.bottom = dstrect.bottom < dstHeight ? dstrect.bottom : dstHeight;
--					srcRect.right = srcRect.right < dstWidth ? srcRect.right : dstWidth;
--					srcRect.bottom = srcRect.bottom < dstHeight ? srcRect.bottom : dstHeight;
--
--					gcmVERIFY_OK(gco2D_CalcStretchFactor(gr->gcoEngine2d, srcRect.right - srcRect.left,
--						dstrect.right - dstrect.left, &horFactor));
--
--					gcmONERROR(gco2D_CalcStretchFactor(gr->gcoEngine2d, srcRect.bottom - srcRect.top,
--							dstrect.bottom - dstrect.top, &verFactor));
--					/* Program the stretch factors. */
--					gcmVERIFY_OK(gco2D_SetStretchFactors(gr->gcoEngine2d, horFactor, verFactor));
--
--					gcmVERIFY_OK(gco2D_StretchBlit(gr->gcoEngine2d, 1, &dstrect,
--							0xCC, 0xCC, go->format));
--				}
--			}
--
--			if(status < 0)
--			{
--				printf("cr l=%d r=%d t=%d b=%d w=%d h=%d\n",
--					clipRect.left, clipRect.right, clipRect.top ,clipRect.bottom,
--					clipRect.right - clipRect.left, clipRect.bottom -clipRect.top);
--				printf("dr l=%d r=%d t=%d b=%d w=%d h=%d\n",
--						dstrect.left, dstrect.right, dstrect.top ,dstrect.bottom,
--						dstrect.right - dstrect.left, dstrect.bottom -dstrect.top);
--				printf("horFactor=%d, verFactor=%d\n",horFactor, verFactor);
--
--				goto OnError;
--			}
--		}
--	}
--
--OnError:
--	galONERROR(status);
--}
--
--static void
--draw_view(struct weston_view *ev, struct weston_output *output,
--	     pixman_region32_t *damage) /* in global coordinates */
--{
--	struct weston_compositor *ec = ev->surface->compositor;	
--	struct gal2d_output_state *go = get_output_state(output);
--	/* repaint bounding region in global coordinates: */
--	pixman_region32_t repaint;
--	/* non-opaque region in surface coordinates: */
--	pixman_region32_t surface_blend;
--	pixman_region32_t *buffer_damage;
--
--    pixman_region32_init(&repaint);
--	pixman_region32_intersect(&repaint,
--				  &ev->transform.boundingbox, damage);
--	pixman_region32_subtract(&repaint, &repaint, &ev->clip);
--
--	if (!pixman_region32_not_empty(&repaint))
--		goto out;
--
--	buffer_damage = &go->buffer_damage[go->current_buffer];
--	pixman_region32_subtract(buffer_damage, buffer_damage, &repaint);
--
--	/* blended region is whole surface minus opaque region: */
--	pixman_region32_init_rect(&surface_blend, 0, 0,
--				  ev->surface->width, ev->surface->height);
--	pixman_region32_subtract(&surface_blend, &surface_blend, &ev->surface->opaque);
--
--    struct gal2d_renderer *gr = get_renderer(ec);
--    gco2D_SetCurrentSourceIndex(gr->gcoEngine2d, 0U);
--
--	if (pixman_region32_not_empty(&ev->surface->opaque)) {
--		repaint_region(ev, output, go, &repaint, &ev->surface->opaque);
--	}
--
--	if (pixman_region32_not_empty(&surface_blend)) {
--        gco2D_EnableAlphaBlend(gr->gcoEngine2d,
--            ev->alpha * 0xFF, ev->alpha * 0xFF,
--            gcvSURF_PIXEL_ALPHA_STRAIGHT, gcvSURF_PIXEL_ALPHA_STRAIGHT,
--            gcvSURF_GLOBAL_ALPHA_SCALE, gcvSURF_GLOBAL_ALPHA_SCALE,
--            gcvSURF_BLEND_STRAIGHT, gcvSURF_BLEND_INVERSED,
--            gcvSURF_COLOR_STRAIGHT, gcvSURF_COLOR_STRAIGHT);
--            
--		repaint_region(ev, output, go, &repaint, &surface_blend);
--	}
--
--    gco2D_DisableAlphaBlend(gr->gcoEngine2d);
--	pixman_region32_fini(&surface_blend);
--
--out:
--	pixman_region32_fini(&repaint);
--
--}
--
--static void
--repaint_views(struct weston_output *output, pixman_region32_t *damage)
--{
--	struct weston_compositor *compositor = output->compositor;
--	struct weston_view *view;
--	struct gal2d_output_state *go = get_output_state(output);
--
--    if(go->nNumBuffers > 1)
--    {
--        /*500ms is more than enough to process a frame */
--        gcoOS_WaitSignal(gcvNULL, go->busySignal, 500);
--    }
--    go->activebuffer = (go->activebuffer+1) % go->nNumBuffers;
--
--	wl_list_for_each_reverse(view, &compositor->view_list, link)
--		if (view->plane == &compositor->primary_plane)
--			draw_view(view, output, damage);
--}
--
--static void
--gal2d_renderer_repaint_output(struct weston_output *output,
--			     pixman_region32_t *output_damage)
--{
--    struct gal2d_output_state *go = get_output_state(output);	
-- 	gctUINT32 i;
--
--	if (use_output(output) < 0)
--		return;
--        
--	for (i = 0; i < 2; i++)
--		pixman_region32_union(&go->buffer_damage[i],
--				      &go->buffer_damage[i],
--				      output_damage);
--
--	pixman_region32_union(output_damage, output_damage,
--			      &go->buffer_damage[go->current_buffer]);
--
--	repaint_views(output, output_damage);
--
--	pixman_region32_copy(&output->previous_damage, output_damage);
--	wl_signal_emit(&output->frame_signal, output);
--    
--    update_surface(output);
--
--	go->current_buffer ^= 1;
--}
--
--static void
--gal2d_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer)
--{
--    gcsWL_VIV_BUFFER *vivBuffer = wl_resource_get_user_data(buffer->resource);
--    gcoSURF srcSurf = vivBuffer->surface;
--    gceSTATUS status = gcvSTATUS_OK;
--    struct gal2d_surface_state *gs = get_surface_state(es);
--
--    if(gs->gco_Surface != gcvNULL)
--    {
--        gcmONERROR(gcoSURF_Destroy(gs->gco_Surface));
--    }
--
--    gs->gco_Surface = srcSurf;
--    gcoSURF_ReferenceSurface(srcSurf);
--    buffer->width = vivBuffer->width;
--    buffer->height = vivBuffer->height;
--    
--  OnError:
--    galONERROR(status);
--}
--
--static void
--gal2d_renderer_flush_damage(struct weston_surface *surface)
--{
--	struct gal2d_surface_state *gs = get_surface_state(surface);
--	struct weston_buffer *buffer = gs->buffer_ref.buffer;
--    struct weston_view *view;
--	int texture_used;
--	pixman_region32_union(&gs->texture_damage,
--			      &gs->texture_damage, &surface->damage);
--
--	if (!buffer)
--		return;
--
--	texture_used = 0;
--	wl_list_for_each(view, &surface->views, surface_link) {
--		if (view->plane == &surface->compositor->primary_plane) {
--			texture_used = 1;
--			break;
--		}
--	}
--	if (!texture_used)
--		return;
--
--	if (!pixman_region32_not_empty(&gs->texture_damage))
--		goto done;
--
--    if(wl_shm_buffer_get(buffer->resource))
--	{
--		if(gs->gco_Surface==NULL)
--		{
--			gs->gco_Surface = getSurfaceFromShm(surface, buffer);
--		}
--		gal2dBindBuffer(surface);
--	}
--	else
--        gal2d_renderer_attach_egl(surface, buffer);
--
--done:
--	pixman_region32_fini(&gs->texture_damage);
--	pixman_region32_init(&gs->texture_damage);
--
--	weston_buffer_reference(&gs->buffer_ref, NULL);
--}
--
--static void
--gal2d_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
--{
--	struct gal2d_surface_state *gs = get_surface_state(es);
--	struct wl_shm_buffer *shm_buffer;
--	weston_buffer_reference(&gs->buffer_ref, buffer);
--
--	if(buffer==NULL)
--		return;
--
--	shm_buffer = wl_shm_buffer_get(buffer->resource);
--
--	if(shm_buffer)
--	{
--		buffer->width = wl_shm_buffer_get_width(shm_buffer);
--		buffer->height = wl_shm_buffer_get_height(shm_buffer);
--		buffer->shm_buffer = shm_buffer;
--
--		if(gs->gco_Surface)
--		{
--			gcoSURF_Destroy(gs->gco_Surface);
--            gs->gco_Surface = getSurfaceFromShm(es, buffer);
--		}
--	}
--	else
--		gal2d_renderer_attach_egl(es, buffer);
--}
--
--static void
--surface_state_destroy(struct gal2d_surface_state *gs, struct gal2d_renderer *gr)
--{
--	if(gs->gco_Surface)
--    {
--        gcoSURF_Destroy(gs->gco_Surface);
--    }
--    wl_list_remove(&gs->surface_destroy_listener.link);
--	wl_list_remove(&gs->renderer_destroy_listener.link);
--	if(gs->surface)
--		gs->surface->renderer_state = NULL;
--
--	weston_buffer_reference(&gs->buffer_ref, NULL);
--	free(gs);
--}
--
--static void
--surface_state_handle_surface_destroy(struct wl_listener *listener, void *data)
--{
--	struct gal2d_surface_state *gs;
--	struct gal2d_renderer *gr;
--
--	gs = container_of(listener, struct gal2d_surface_state,
--			  surface_destroy_listener);
--
--	gr = get_renderer(gs->surface->compositor);
--	surface_state_destroy(gs, gr);
--}
--
--static void
--surface_state_handle_renderer_destroy(struct wl_listener *listener, void *data)
--{
--	struct gal2d_surface_state *gs;
--	struct gal2d_renderer *gr;
--
--	gr = data;
--
--	gs = container_of(listener, struct gal2d_surface_state,
--			  renderer_destroy_listener);
--
--	surface_state_destroy(gs, gr);
--}
--
--
--static int
--gal2d_renderer_create_surface(struct weston_surface *surface)
--{
--    struct gal2d_surface_state *gs;
--    struct gal2d_renderer *gr = get_renderer(surface->compositor);
--    
--	gs = zalloc(sizeof *gs);
--	if (gs == NULL)
--		return -1;
--
--	/* A buffer is never attached to solid color surfaces, yet
--	 * they still go through texcoord computations. Do not divide
--	 * by zero there.
--	 */
--	gs->pitch = 1;
--
--    gs->surface = surface;
--    
--	pixman_region32_init(&gs->texture_damage);
--	surface->renderer_state = gs;
--
--	gs->surface_destroy_listener.notify =
--		surface_state_handle_surface_destroy;
--	wl_signal_add(&surface->destroy_signal,
--		      &gs->surface_destroy_listener);
--
--	gs->renderer_destroy_listener.notify =
--		surface_state_handle_renderer_destroy;
--	wl_signal_add(&gr->destroy_signal,
--		      &gs->renderer_destroy_listener);
--
--	if (surface->buffer_ref.buffer) {
--		gal2d_renderer_attach(surface, surface->buffer_ref.buffer);
--		gal2d_renderer_flush_damage(surface);
--	}
--    
--    return 0;
--}
--
--static void
--gal2d_renderer_surface_set_color(struct weston_surface *surface,
--		 float red, float green, float blue, float alpha)
--{
--    struct gal2d_surface_state *gs = get_surface_state(surface);
--
--	gs->color[0] = red;
--	gs->color[1] = green;
--	gs->color[2] = blue;
--	gs->color[3] = alpha;
--}
--
--
--static void
--gal2d_renderer_output_destroy(struct weston_output *output)
--{
--    struct gal2d_output_state *go = get_output_state(output);
--    gctUINT32 i;
--
--    for (i = 0; i < 2; i++)
--    {
--        pixman_region32_fini(&go->buffer_damage[i]);
--    }
--    if(go->nNumBuffers <= 1 )
--	{
--		if(go->offscreenSurface)
--			gcmVERIFY_OK(gcoSURF_Destroy(go->offscreenSurface));
--	}
--    else
--    {
--        gcoOS_Signal(gcvNULL,go->signal, gcvTRUE);
--        pthread_mutex_lock(&go->workerMutex);
--        go->exitWorker = 1;
--        pthread_mutex_unlock(&go->workerMutex);
--        pthread_join(go->workerId, NULL);
--    }
--
--	for(i=0; i < go->nNumBuffers; i++)
--	{
--		gcmVERIFY_OK(gcoSURF_Destroy(go->renderSurf[i]));
--	}
--	free(go->renderSurf);
--	go->renderSurf = gcvNULL;
--
--	free(go);
--}
--
--static void
--gal2d_renderer_destroy(struct weston_compositor *ec)
--{
--    struct gal2d_renderer *gr = get_renderer(ec);
--
--    wl_signal_emit(&gr->destroy_signal, gr);
--	free(ec->renderer);
--	ec->renderer = NULL;
--}
--
--
--static int
--gal2d_renderer_create(struct weston_compositor *ec)
--{
--    struct gal2d_renderer *gr;
--    gceSTATUS status = gcvSTATUS_OK;
--	gr = malloc(sizeof *gr);
--	if (gr == NULL)
--		return -1;
--
--	gr->base.read_pixels = gal2d_renderer_read_pixels;
--	gr->base.repaint_output = gal2d_renderer_repaint_output;
--	gr->base.flush_damage = gal2d_renderer_flush_damage;
--	gr->base.attach = gal2d_renderer_attach;
--	gr->base.surface_set_color = gal2d_renderer_surface_set_color;
--	gr->base.destroy = gal2d_renderer_destroy;
--    
--    /* Construct the gcoOS object. */
--	gcmONERROR(gcoOS_Construct(gcvNULL, &gr->gcos));
--
--	/* Construct the gcoHAL object. */
--	gcmONERROR(gcoHAL_Construct(gcvNULL, gr->gcos, &gr->gcoHal));
--	gcmONERROR(gcoHAL_Get2DEngine(gr->gcoHal, &gr->gcoEngine2d));
--	gcmONERROR(gcoHAL_SetHardwareType(gr->gcoHal, gcvHARDWARE_2D));
--    
--	ec->renderer = &gr->base; 
--        wl_signal_init(&gr->destroy_signal);
--OnError:
--    galONERROR(status);
--    
--    /* Return the status. */    
--    return status;
--	
--}
--
--static int
--gal2d_renderer_output_create(struct weston_output *output, NativeDisplayType display,
--				    NativeWindowType window)
--
-- {
--    struct gal2d_renderer *gr = get_renderer(output->compositor);
--	struct gal2d_output_state *go;
--    halDISPLAY_INFO info;
--    gctUINT32 backOffset = 0;
--    gceSTATUS status = gcvSTATUS_OK;
--	gctUINT32 i;
--
--    go = zalloc(sizeof *go);
--    if (go == NULL)
--		return -1;
--
--    output->renderer_state = go;
--    go->display = display;
--    gcmONERROR(gcoOS_InitLocalDisplayInfo(go->display, &gr->localInfo));
--
--    /* Get display information. */
--	gcmONERROR(gcoOS_GetDisplayInfoEx2(
--					go->display, gcvNULL, gr->localInfo,
--					sizeof(info), &info));
--	go->nNumBuffers = info.multiBuffer;
--
--    weston_log("Number of buffers=%d\n",go->nNumBuffers);
--
--	gcmONERROR(gal2d_getSurfaceFormat(info, &go->format));    
--	backOffset = (gctUINT32)(info.stride * info.height );
--
--	go->activebuffer = 0;
--
--	go->renderSurf = malloc(sizeof(gcoSURF) * go->nNumBuffers);
--	gcoOS_GetDisplayVirtual(go->display, &go->width, &go->height);
--    gcoOS_SetSwapInterval(go->display, 1);
-- 
--    /*Needed only for multi Buffer  */
--    if(go->nNumBuffers > 1)
--    {
--        gcmVERIFY_OK(gcoOS_CreateSignal(gcvNULL, gcvFALSE,
--                &go->signal));
--        gcmVERIFY_OK(gcoOS_CreateSignal(gcvNULL, gcvFALSE,
--                &go->busySignal));
--
--        go->iface.command            = gcvHAL_SIGNAL;
--        go->iface.u.Signal.signal    = gcmPTR_TO_UINT64(go->signal);
--        go->iface.u.Signal.auxSignal = 0;
--        go->iface.u.Signal.process = gcmPTR_TO_UINT64(gcoOS_GetCurrentProcessID());
--        go->iface.u.Signal.fromWhere = gcvKERNEL_PIXEL;
--
--        go->exitWorker = 0;
--        pthread_create(&go->workerId, NULL, gal2d_output_worker, output);
--        pthread_mutex_init(&go->workerMutex, gcvNULL);
--    }
--	for(i=0; i < go->nNumBuffers; i++)
--	{
--        gcmONERROR(gcoSURF_Construct(gr->gcoHal, info.width, info.height, 1, 
--            gcvSURF_BITMAP, go->format, gcvPOOL_USER, &go->renderSurf[i]));
--        
--        gcoSURF_MapUserSurface(go->renderSurf[i], 0,info.logical + (i * backOffset),
--						info.physical + (i * backOffset));
--		
--		//Clear surfaces
--		make_current(gr, go->renderSurf[go->activebuffer]);
--		gal2d_clear(output);
--		gal2d_flip_surface(output);
--	}
--	if(go->nNumBuffers <= 1)
--		go->activebuffer = 0;
--	else
--		go->activebuffer = 1;
--
--	if(go->nNumBuffers <= 1 )
--	{
--		gcmVERIFY_OK(gcoSURF_Construct(gr->gcoHal,
--							  (gctUINT) info.width,
--							  (gctUINT) info.height,
--							  1,
--							  gcvSURF_BITMAP,
--							  go->format,
--							  gcvPOOL_DEFAULT,
--							  &go->offscreenSurface));
--		make_current(gr, go->offscreenSurface);
--		gal2d_clear(output);
--	}
--    else
--    {
--        gcoOS_Signal(gcvNULL,go->busySignal, gcvTRUE);
--    }
--
--	for (i = 0; i < 2; i++)
--		pixman_region32_init(&go->buffer_damage[i]);
--OnError:
--    galONERROR(status);
--    /* Return the status. */
--    return status;  
-- }
--
-- WL_EXPORT struct gal2d_renderer_interface gal2d_renderer_interface = {
--	.create = gal2d_renderer_create,
--	.output_create = gal2d_renderer_output_create,
--	.output_destroy = gal2d_renderer_output_destroy,
--};
-Index: weston-1.11.1/src/gal2d-renderer.h
-===================================================================
---- weston-1.11.1.orig/src/gal2d-renderer.h	2017-01-14 08:59:52.297865829 -0600
-+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
-@@ -1,50 +0,0 @@
--/*
-- * Copyright (c) 2015 Freescale Semiconductor, Inc.
-- * Copyright © 2013 Vasily Khoruzhick <anarsoul@gmail.com>
-- *
-- * Permission is hereby granted, free of charge, to any person obtaining
-- * a copy of this software and associated documentation files (the
-- * "Software"), to deal in the Software without restriction, including
-- * without limitation the rights to use, copy, modify, merge, publish,
-- * distribute, sublicense, and/or sell copies of the Software, and to
-- * permit persons to whom the Software is furnished to do so, subject to
-- * the following conditions:
-- *
-- * The above copyright notice and this permission notice (including the
-- * next paragraph) shall be included in all copies or substantial
-- * portions of the Software.
-- *
-- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-- * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- * SOFTWARE.
-- */
--#ifndef __gal_2d_renderer_h_
--#define __gal_2d_renderer_h_
--
--#include  "compositor.h"
--#ifdef ENABLE_EGL
--#include <EGL/egl.h>
--#else
--#include <HAL/gc_hal_eglplatform.h>
--typedef HALNativeDisplayType NativeDisplayType;
--typedef HALNativeWindowType  NativeWindowType;
--#endif
--
--
--struct gal2d_renderer_interface {
--
--	int (*create)(struct weston_compositor *ec);
--
--	int (*output_create)(struct weston_output *output,
--		         NativeDisplayType display,
--			     NativeWindowType window);
--
--	void (*output_destroy)(struct weston_output *output);
--};
--
--#endif
-Index: weston-1.11.1/src/main.c
-===================================================================
---- weston-1.11.1.orig/src/main.c	2017-01-14 08:59:52.297865829 -0600
-+++ weston-1.11.1/src/main.c	2017-01-14 09:08:38.000000000 -0600
-@@ -287,10 +287,10 @@
+diff --git a/src/main.c b/src/main.c
+index 3279ac6..5d0bdc4 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -285,7 +285,8 @@ usage(int error_code)
+ 		"Options for fbdev-backend.so:\n\n"
+ 		"  --tty=TTY\t\tThe tty to use\n"
  		"  --device=DEVICE\tThe framebuffer device to use\n"
- #if defined ENABLE_EGL
- 		"  --use-gl=1\t\tUse the GL renderer (default is 1)\n"
--		"  --use-gal2d=1\t\tUse the GAL2D renderer (default is 0)\n\n");
-+		"  --use-g2d=1\t\tUse the G2D renderer (default is 0)\n\n");
- #else
- 		"  --use-gl=1\t\tUse the GL renderer (default is 0)\n"
--		"  --use-gal2d=1\t\tUse the GAL2D renderer (default is 1)\n\n");
-+		"  --use-g2d=1\t\tUse the G2D renderer (default is 1)\n\n");
- #endif
+-		"  --use-gl\t\tUse the GL renderer\n\n");
++		"  --use-gl=1\t\tUse the GL renderer\n"
++		"  --use-g2d=1\t\tUse the g2d renderer\n\n");
  #endif
  
-@@ -875,7 +875,7 @@
+ #if defined(BUILD_HEADLESS_COMPOSITOR)
+@@ -868,7 +869,8 @@ load_fbdev_backend(struct weston_compositor *c, char const * backend,
+ 	const struct weston_option fbdev_options[] = {
  		{ WESTON_OPTION_INTEGER, "tty", 0, &config.tty },
  		{ WESTON_OPTION_STRING, "device", 0, &config.device },
- 		{ WESTON_OPTION_INTEGER, "use-gl", 0, &config.use_gl },
--		{ WESTON_OPTION_INTEGER, "use-gal2d", 0, &config.use_gal2d },
+-		{ WESTON_OPTION_BOOLEAN, "use-gl", 0, &config.use_gl },
++		{ WESTON_OPTION_INTEGER, "use-gl", 0, &config.use_gl },
 +		{ WESTON_OPTION_INTEGER, "use-g2d", 0, &config.use_g2d },
  	};
  
  	parse_options(fbdev_options, ARRAY_LENGTH(fbdev_options), argc, argv);
-Index: weston-1.11.1/src/compositor-fbdev.h
-===================================================================
---- weston-1.11.1.orig/src/compositor-fbdev.h	2017-01-14 08:59:52.297865829 -0600
-+++ weston-1.11.1/src/compositor-fbdev.h	2017-01-14 08:59:52.841868527 -0600
-@@ -40,7 +40,8 @@
- 	int tty;
- 	char *device;
- 	int use_gl;
--	int use_gal2d;
-+	int use_g2d;
-+    int clone_mode;
- 
- 	uint32_t output_transform;
- };
+-- 
+2.7.4
+
diff --git a/recipes-graphics/wayland/weston/0003-MGS-1192-xwld-g2d-compositor-dose-not-work.patch b/recipes-graphics/wayland/weston/0003-MGS-1192-xwld-g2d-compositor-dose-not-work.patch
deleted file mode 100644
index 019b710..0000000
--- a/recipes-graphics/wayland/weston/0003-MGS-1192-xwld-g2d-compositor-dose-not-work.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 9de82e2b39f839b5547308bf25d0d71f79936631 Mon Sep 17 00:00:00 2001
-From: Yong Gan <b45748@freescale.com>
-Date: Tue, 27 Oct 2015 15:07:02 +0800
-Subject: [PATCH] MGS-1192: xwld: g2d compositor dose not work
-
-Initial the backend->use_gal2d by input parameters.
-
-Upstream-Status: Inappropriate [i.MX specific]
-
-Signed-off-by: Yong Gan <yong.gan@freescale.com>
----
- src/compositor-fbdev.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-Index: weston-1.11.0/src/compositor-fbdev.c
-===================================================================
---- weston-1.11.0.orig/src/compositor-fbdev.c	2016-08-31 20:23:38.109228731 -0500
-+++ weston-1.11.0/src/compositor-fbdev.c	2016-08-31 20:30:25.000000000 -0500
-@@ -811,7 +811,8 @@
- 	backend->base.restore = fbdev_restore;
- 
- 	backend->prev_state = WESTON_COMPOSITOR_ACTIVE;
--	backend->use_pixman = !param->use_gl;
-+	backend->use_pixman = !(param->use_gl || param->use_gal2d);
-+	backend->use_gal2d = param->use_gal2d;
- 	backend->output_transform = param->output_transform;
- 
- 	weston_setup_vt_switch_bindings(compositor);
diff --git a/recipes-graphics/wayland/weston/0012-MGS-1783-xwld-Add-clone-mode-support-for-multi-displ.patch b/recipes-graphics/wayland/weston/0003-MGS-1783-xwld-Add-clone-mode-support-for-multi-displ.patch
similarity index 13%
rename from recipes-graphics/wayland/weston/0012-MGS-1783-xwld-Add-clone-mode-support-for-multi-displ.patch
rename to recipes-graphics/wayland/weston/0003-MGS-1783-xwld-Add-clone-mode-support-for-multi-displ.patch
index e504d67..328213c 100644
--- a/recipes-graphics/wayland/weston/0012-MGS-1783-xwld-Add-clone-mode-support-for-multi-displ.patch
+++ b/recipes-graphics/wayland/weston/0003-MGS-1783-xwld-Add-clone-mode-support-for-multi-displ.patch
@@ -1,29 +1,25 @@
-From f2025a7e8c178b8c52c2ca553459a7fea6caf5c8 Mon Sep 17 00:00:00 2001
-From: "yong.gan" <yong.gan@nxp.com>
-Date: Tue, 17 May 2016 09:10:50 +0800
-Subject: [PATCH 1/2] MGS-1783: xwld: Add clone mode support for multi display
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
+From d22509cd41f9d44d9e66522307e30ad4ae4bace0 Mon Sep 17 00:00:00 2001
+From: Meng Mingming <mingming.meng@nxp.com>
+Date: Mon, 16 Jan 2017 10:23:13 +0800
+Subject: [PATCH 3/5] MGS-1783: xwld: Add clone mode support for multi display
 
-Support showing the same contents on multiple displays.
-Use the following command to enable multi-display:
-    openvt -v -- weston-launch -- --idle-time=0 --use-g2d=1 --device=/dev/fb0,/dev/fb4 --clone-mode --log=/var/log/weston.log
+Support more than two displays to show the same contents
+
+Upstream Status: Inappropriate [i.MX specific]
 
-Upstream-Status: Inappropriate [i.MX specific]
 Date: May 16, 2016
 Signed-off-by: Yong Gan <yong.gan@nxp.com>
 ---
- src/compositor-fbdev.c |  33 +++++++---
- src/g2d-renderer.c     | 171 ++++++++++++++++++++++++++++++++++++++++---------
- src/g2d-renderer.h     |   4 +-
- 3 files changed, 167 insertions(+), 41 deletions(-)
+ src/compositor-fbdev.c | 18 +++++++++++++++---
+ src/compositor-fbdev.h |  1 +
+ src/main.c             |  1 +
+ 3 files changed, 17 insertions(+), 3 deletions(-)
 
-Index: weston-1.11.1/src/compositor-fbdev.c
-===================================================================
---- weston-1.11.1.orig/src/compositor-fbdev.c	2017-01-16 13:23:48.925264352 -0600
-+++ weston-1.11.1/src/compositor-fbdev.c	2017-01-16 13:23:49.013264789 -0600
-@@ -61,6 +61,8 @@
+diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
+index cff9513..0a05e7d 100644
+--- a/src/compositor-fbdev.c
++++ b/src/compositor-fbdev.c
+@@ -61,6 +61,8 @@ struct fbdev_backend {
  	struct udev_input input;
  	int use_pixman;
  	int use_g2d;
@@ -31,26 +27,17 @@ Index: weston-1.11.1/src/compositor-fbdev.c
 +	char *clone_device;
  	uint32_t output_transform;
  	struct wl_listener session_listener;
- #ifdef ENABLE_EGL
-@@ -525,12 +527,15 @@
- 		if (pixman_renderer_output_create(&output->base) < 0)
+ 	NativeDisplayType display;
+@@ -521,6 +523,8 @@ fbdev_output_create(struct fbdev_backend *backend,
  			goto out_hw_surface;
  	} else if(backend->use_g2d) {
-+		const char *g2d_device = device;
+ 		const char *g2d_device = device;
 +		if (backend->clone_mode)
 +			g2d_device = backend->clone_device;
-+
+ 
  		if (g2d_renderer->output_create(&output->base,
--					backend->compositor->wl_display, device) < 0) {
-+					backend->compositor->wl_display, g2d_device) < 0) {
- 			weston_log("g2d_renderer_output_create failed.\n");
- 			goto out_hw_surface;
- 		}
--
- 	} else {
- #ifdef ENABLE_EGL
- 		setenv("HYBRIS_EGLPLATFORM", "wayland", 1);
-@@ -803,6 +808,8 @@
+ 							backend->compositor->wl_display, g2d_device) < 0) {
+@@ -797,6 +801,8 @@ fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv
  	backend->prev_state = WESTON_COMPOSITOR_ACTIVE;
  	backend->use_pixman = !(param->use_gl || param->use_g2d);
  	backend->use_g2d = param->use_g2d;
@@ -59,359 +46,52 @@ Index: weston-1.11.1/src/compositor-fbdev.c
  	backend->output_transform = param->output_transform;
  
  	weston_setup_vt_switch_bindings(compositor);
-@@ -844,16 +851,21 @@
+@@ -837,12 +843,17 @@ fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv
  		displays[dispCount][k] = '\0';
  		dispCount++;
  
--		for(i=0; i<dispCount; i++)
--		{
+-		for(i= 0; i < dispCount; i++){
 -			if (fbdev_output_create(backend, x, y, displays[i]) < 0)
 +		if(backend->clone_mode){
 +			if (fbdev_output_create(backend, x, y, displays[0]) < 0)
  				goto out_launcher;
 -			x += container_of(backend->compositor->output_list.prev,
--								  struct weston_output,
--								  link)->width;
-+		}
-+		else{
++		} else {
 +			for(i= 0; i < dispCount; i++){
 +				if (fbdev_output_create(backend, x, y, displays[i]) < 0)
 +					goto out_launcher;
 +				x += container_of(backend->compositor->output_list.prev,
-+						struct weston_output,
-+						link)->width;
+ 							struct weston_output,
+ 							link)->width;
 +			}
  		}
- 	}
--	 else {
-+	else {
- #ifdef ENABLE_EGL
+ 	} else {
  		gl_renderer = weston_load_module("gl-renderer.so",
- 						 "gl_renderer_interface");
-Index: weston-1.11.1/src/g2d-renderer.c
-===================================================================
---- weston-1.11.1.orig/src/g2d-renderer.c	2017-01-16 13:23:48.925264352 -0600
-+++ weston-1.11.1/src/g2d-renderer.c	2017-01-16 13:26:17.000000000 -0600
-@@ -37,15 +37,16 @@
- #include <sys/ioctl.h>
- #include <fcntl.h>
- #include <unistd.h>
-+#include <g2dExt.h>
-+#include <HAL/gc_hal_eglplatform.h>
- 
- #include "compositor.h"
- #include "g2d-renderer.h"
- #include "vertex-clipping.h"
- #include "shared/helpers.h"
--#include "HAL/gc_hal_eglplatform.h"
--#include "g2dExt.h"
- 
- #define BUFFER_DAMAGE_COUNT 2
-+extern struct wl_global* gcoOS_WaylandCreateVivGlobal(struct wl_display* display);
- 
- typedef struct _g2dRECT
- {
-@@ -63,6 +64,7 @@
- 	size_t buffer_length; /* length of frame buffer memory in bytes */
- 	size_t physical;
- 	enum g2d_format pixel_format; /* frame buffer pixel format */
-+	int fb_fd;
- };
- 
- struct g2d_output_state {
-@@ -74,10 +76,12 @@
- 	struct g2d_surfaceEx offscreenSurface;
- 	struct g2d_buf *offscreen_buf;
- 	struct fb_screeninfo fb_info;
-+	struct fb_screeninfo *mirror_fb_info;
-+	struct g2d_surfaceEx *mirrorSurf;
- 	int directBlit;
-+	int clone_display_num;
- 	int width;
- 	int height;
--	int fb_fd;
- };
- 
- struct g2d_surface_state {
-@@ -366,7 +370,7 @@
- 	struct g2d_output_state *go = get_output_state(output);
- 	go->fb_info.varinfo.yoffset  = go->activebuffer * go->fb_info.y_resolution;
- 
--	if(ioctl(go->fb_fd, FBIOPAN_DISPLAY, &(go->fb_info.varinfo)) < 0)
-+	if(ioctl(go->fb_info.fb_fd, FBIOPAN_DISPLAY, &(go->fb_info.varinfo)) < 0)
- 	{
- 		weston_log("FBIOPAN_DISPLAY Failed\n");
- 	}
-@@ -388,6 +392,28 @@
- 			&go->renderSurf[go->activebuffer], &srcRect, &dstrect);
- 	}
- 
-+	if(go->clone_display_num)
-+	{
-+		int i = 0;
-+		for(i = 0; i < go->clone_display_num; i++)
-+		{
-+			g2dRECT srcRect  = {0, 0, go->renderSurf[go->activebuffer].base.width, go->renderSurf[go->activebuffer].base.height};
-+			g2dRECT dstrect  = {0, 0, go->mirrorSurf[i].base.width, go->mirrorSurf[i].base.height};
-+			g2dRECT clipRect = srcRect;
-+			g2d_set_clipping(gr->handle, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
-+			if(go->directBlit || go->nNumBuffers > 1)
-+			{
-+				g2d_blitSurface(gr->handle, &go->renderSurf[go->activebuffer],
-+				&go->mirrorSurf[i], &srcRect, &dstrect);
-+			}
-+			else
-+			{
-+				g2d_blitSurface(gr->handle, &go->offscreenSurface,
-+					&go->mirrorSurf[i], &srcRect, &dstrect);
-+			}
-+		}
-+	}
-+
- 	g2d_finish(gr->handle);
- 
- 	if(go->nNumBuffers > 1)
-@@ -940,10 +966,10 @@
- 		go->offscreen_buf = NULL;
- 	}
- 
--	if(go->fb_fd)
-+	if(go->fb_info.fb_fd)
- 	{
--		close(go->fb_fd);
--		go->fb_fd = 0;
-+		close(go->fb_info.fb_fd);
-+		go->fb_info.fb_fd = 0;
- 	}
- 
- 	if(go->renderSurf)
-@@ -951,6 +977,24 @@
- 		free(go->renderSurf);
- 		go->renderSurf = NULL;
- 	}
-+	for (i = 0; i < go->clone_display_num; i++)
-+	{
-+		if(go->mirror_fb_info[i].fb_fd)
-+		{
-+			close(go->mirror_fb_info[i].fb_fd);
-+			go->mirror_fb_info[i].fb_fd = 0;
-+		}
-+	}
-+	if(go->mirrorSurf)
-+	{
-+		free(go->mirrorSurf);
-+		go->mirrorSurf = NULL;
-+	}
-+	if(go->mirror_fb_info)
-+	{
-+		free(go->mirror_fb_info);
-+		go->mirror_fb_info = NULL;
-+	}
- 
- 	free(go);
- }
-@@ -1085,39 +1129,27 @@
-                         struct fb_screeninfo *screen_info)
- {
- 	/* Open the frame buffer device. */
--	output->fb_fd = open(fb_dev, O_RDWR | O_CLOEXEC);
--	if (output->fb_fd < 0) {
-+	screen_info->fb_fd = open(fb_dev, O_RDWR | O_CLOEXEC);
-+	if (screen_info->fb_fd < 0) {
- 		weston_log("Failed to open frame buffer device%s \n", fb_dev);
- 		return -1;
- 	}
- 
- 	/* Grab the screen info. */
--	if (fb_query_screen_info(output, output->fb_fd, screen_info) < 0) {
-+	if (fb_query_screen_info(output, screen_info->fb_fd, screen_info) < 0) {
- 		weston_log("Failed to get frame buffer info \n");
- 
--		close(output->fb_fd);
-+		close(screen_info->fb_fd);
- 		return -1;
- 	}
- 
- 	return 0;
+@@ -896,6 +907,7 @@ config_init_to_defaults(struct weston_fbdev_backend_config *config)
+ 	config->device = "/dev/fb0"; /* default frame buffer */
+ 	config->use_gl = 0;
+ 	config->use_g2d = 0;
++	config->clone_mode = 0;
+ 	config->output_transform = WL_OUTPUT_TRANSFORM_NORMAL;
  }
  
--static int
--g2d_renderer_output_create(struct weston_output *output, struct wl_display *wl_display, const char *device)
--
-- {
--	struct g2d_renderer *gr = get_renderer(output->compositor);
--	struct g2d_output_state *go;
--	int i = 0;
--	int offset = 0;
-+static void
-+getBufferNumber(struct g2d_output_state *go)
-+{
- 	char *p = NULL;
--	go = zalloc(sizeof *go);
--	if (go == NULL)
--		return -1;
--
--	output->renderer_state = go;
--	gr->viv_global = gcoOS_WaylandCreateVivGlobal(wl_display);
--
- 	p = getenv("FB_MULTI_BUFFER");
- 	if (p == gcvNULL)
- 	{
-@@ -1126,7 +1158,7 @@
- 	else
- 	{
- 		go->nNumBuffers = atoi(p);
--		if (go->nNumBuffers < 1)
-+		if (go->nNumBuffers < 2)
- 		{
- 			go->nNumBuffers  = 1;
- 		}
-@@ -1137,13 +1169,19 @@
- 		}
- 	}
- 	weston_log("FB_MULTI_BUFFER = %d\n", go->nNumBuffers);
-+}
- 
-+static int
-+g2d_renderer_surface_create(struct g2d_output_state *go, struct g2d_renderer *gr, const char *device)
-+{
-+	int i = 0;
-+	int offset = 0;
-+	weston_log("Opend device=%s\n", device);
- 	if(fb_frame_buffer_open(go, device, &go->fb_info) < 0)
- 	{
- 		weston_log("Open frame buffer failed.\n");
- 		return -1;
- 	}
--
- 	go->renderSurf = zalloc(sizeof(struct g2d_surfaceEx) * go->nNumBuffers);
- 	offset = go->fb_info.buffer_length/go->nNumBuffers;
- 	for(i = 0; i < go->nNumBuffers; i++)
-@@ -1161,9 +1199,84 @@
- 		go->offscreenSurface.base.planes[0] = go->offscreen_buf->buf_paddr;
- 		g2d_clear(gr->handle, &go->offscreenSurface.base);
- 	}
-+	return 0;
-+}
-+
-+static int
-+g2d_renderer_output_create(struct weston_output *output, struct wl_display *wl_display, const char *device)
- 
-+ {
-+	struct g2d_renderer *gr = get_renderer(output->compositor);
-+	struct g2d_output_state *go;
-+	int i;
-+	int clone_display_num = 0;
-+	int count = 0;
-+	int k=0, dispCount = 0;
-+	char displays[5][32];
-+	weston_log("g2d_renderer_output_create device=%s\n", device);
-+	count = strlen(device);
-+
-+	if(count > 0)
-+	{
-+		for(i= 0; i < count; i++)
-+		{
-+			if(device[i] == ',')
-+			{
-+				displays[dispCount][k] = '\0';
-+				dispCount++;
-+				k = 0;
-+				continue;
-+			}
-+			else if(device[i] != ' ')
-+			{
-+				displays[dispCount][k++] = device[i];
-+			}
-+		}
-+		displays[dispCount][k] = '\0';
-+		clone_display_num = dispCount++;
-+		weston_log("clone_display_num = %d\n", clone_display_num);
-+	}
-+	else
-+	{
-+		weston_log("Invalid device name\n");
-+		return -1;
-+	}
-+
-+	go = zalloc(sizeof *go);
-+	if (go == NULL)
-+		return -1;
-+	go->clone_display_num  = clone_display_num;
-+	output->renderer_state = go;
-+	gr->viv_global = gcoOS_WaylandCreateVivGlobal(wl_display);
-+	getBufferNumber(go);
-+
-+	if(g2d_renderer_surface_create(go, gr, displays[0]) < 0)
-+	{
-+		weston_log("Create Render surface failed.\n");
-+		return -1;
-+	}
-+
-+	if(go->clone_display_num)
-+	{
-+		go->mirrorSurf = zalloc(sizeof(struct g2d_surfaceEx) * clone_display_num);
-+		go->mirror_fb_info = zalloc(sizeof(struct fb_screeninfo) * clone_display_num);
-+		if(go->mirrorSurf == NULL || go->mirror_fb_info == NULL)
-+			return -1;
-+
-+		for(i = 0; i < clone_display_num; i++)
-+		{
-+			if(fb_frame_buffer_open(go, displays[i + 1], &go->mirror_fb_info[i]) < 0)
-+			{
-+				weston_log("Open frame buffer failed.\n");
-+				return -1;
-+			}
-+			get_G2dSurface_from_screeninfo(&go->mirror_fb_info[i], &go->mirrorSurf[i]);
-+			go->mirrorSurf[i].base.planes[0] = go->mirror_fb_info[i].physical;
-+			g2d_clear(gr->handle, &go->mirrorSurf[i].base);
-+		}
-+	}
- 	g2d_finish(gr->handle);
--	for (i = 0; i < 2; i++)
-+	for (i = 0; i < BUFFER_DAMAGE_COUNT; i++)
- 		pixman_region32_init(&go->buffer_damage[i]);
-     return 0;
-  }
-Index: weston-1.11.1/src/g2d-renderer.h
-===================================================================
---- weston-1.11.1.orig/src/g2d-renderer.h	2017-01-16 13:23:48.757263519 -0600
-+++ weston-1.11.1/src/g2d-renderer.h	2017-01-16 13:26:17.000000000 -0600
-@@ -27,13 +27,11 @@
- #define __g2d_renderer_h_
- 
- #include  "compositor.h"
-+
- #ifdef ENABLE_EGL
- #include <EGL/egl.h>
--#else
--#include <HAL/gc_hal_eglplatform.h>
- #endif
- 
--
- struct g2d_renderer_interface {
- 
- 	int (*create)(struct weston_compositor *ec);
-Index: weston-1.11.1/src/main.c
-===================================================================
---- weston-1.11.1.orig/src/main.c	2017-01-16 13:23:48.929264372 -0600
-+++ weston-1.11.1/src/main.c	2017-01-16 13:32:49.000000000 -0600
-@@ -287,11 +287,12 @@
- 		"  --device=DEVICE\tThe framebuffer device to use\n"
- #if defined ENABLE_EGL
- 		"  --use-gl=1\t\tUse the GL renderer (default is 1)\n"
--		"  --use-g2d=1\t\tUse the G2D renderer (default is 0)\n\n");
-+		"  --use-g2d=1\t\tUse the G2D renderer (default is 0)\n"
- #else
- 		"  --use-gl=1\t\tUse the GL renderer (default is 0)\n"
--		"  --use-g2d=1\t\tUse the G2D renderer (default is 1)\n\n");
-+		"  --use-g2d=1\t\tUse the G2D renderer (default is 1)\n"
- #endif
-+		"  --clone-mode\t\tClone display to multiple devices\n\n");
- #endif
+diff --git a/src/compositor-fbdev.h b/src/compositor-fbdev.h
+index 32a8598..a28ef3b 100644
+--- a/src/compositor-fbdev.h
++++ b/src/compositor-fbdev.h
+@@ -41,6 +41,7 @@ struct weston_fbdev_backend_config {
+ 	char *device;
+ 	int use_gl;
+ 	int use_g2d;
++	int clone_mode;
  
- #if defined(BUILD_HEADLESS_COMPOSITOR)
-@@ -886,6 +887,7 @@
+ 	uint32_t output_transform;
+ };
+diff --git a/src/main.c b/src/main.c
+index 5d0bdc4..18fe5e0 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -871,6 +871,7 @@ load_fbdev_backend(struct weston_compositor *c, char const * backend,
  		{ WESTON_OPTION_STRING, "device", 0, &config.device },
  		{ WESTON_OPTION_INTEGER, "use-gl", 0, &config.use_gl },
  		{ WESTON_OPTION_INTEGER, "use-g2d", 0, &config.use_g2d },
@@ -419,3 +99,6 @@ Index: weston-1.11.1/src/main.c
  	};
  
  	parse_options(fbdev_options, ARRAY_LENGTH(fbdev_options), argc, argv);
+-- 
+2.7.4
+
diff --git a/recipes-graphics/wayland/weston/0004-MGS-1235-Fix-setenv-and-clear-environments.patch b/recipes-graphics/wayland/weston/0004-MGS-1235-Fix-setenv-and-clear-environments.patch
deleted file mode 100644
index e4f8cd9..0000000
--- a/recipes-graphics/wayland/weston/0004-MGS-1235-Fix-setenv-and-clear-environments.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From d09d0595b472d6bae35e78272fc670d494f6e408 Mon Sep 17 00:00:00 2001
-From: Prabhu <prabhu.sundararaj@freescale.com>
-Date: Tue, 17 Nov 2015 22:00:42 -0600
-Subject: [PATCH] MGS-1235 : Fix setenv and clear environments
-
-When setenv is set with parameter null causing crash.
-Fixed with unsetenv to restore to previous state
-
-Date: Nov 17, 2015
-Signed-off-by: Prabhu <prabhu.sundararaj@freescale.com>
-
--1235
----
- src/compositor-fbdev.c | 11 ++++++++++-
- 1 file changed, 10 insertions(+), 1 deletion(-)
-
-diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
-index ed25576..c6b8e5a 100644
---- a/src/compositor-fbdev.c
-+++ b/src/compositor-fbdev.c
-@@ -598,7 +598,16 @@ fbdev_output_create(struct fbdev_backend *backend,
- 			fprintf(stderr, "failed to create window\n");
- 			 return 0;
- 		}
--		setenv("FB_FRAMEBUFFER_0", fbenv, 1);
-+		/* restore the previous value*/
-+		if(fbenv != NULL)
-+		{
-+			setenv("FB_FRAMEBUFFER_0", fbenv, 1);
-+		}
-+		else
-+		{
-+			unsetenv("FB_FRAMEBUFFER_0");
-+		}
-+
- 
- 		if (gal2d_renderer->output_create(&output->base,
- 					output->display,
--- 
-2.5.1
-
diff --git a/recipes-graphics/wayland/weston/0019-MGS-1668-xwld-System-can-not-boot-up-to-desktop.patch b/recipes-graphics/wayland/weston/0004-MGS-1668-xwld-System-can-not-boot-up-to-desktop.patch
similarity index 83%
rename from recipes-graphics/wayland/weston/0019-MGS-1668-xwld-System-can-not-boot-up-to-desktop.patch
rename to recipes-graphics/wayland/weston/0004-MGS-1668-xwld-System-can-not-boot-up-to-desktop.patch
index 09404ca..95a88e6 100644
--- a/recipes-graphics/wayland/weston/0019-MGS-1668-xwld-System-can-not-boot-up-to-desktop.patch
+++ b/recipes-graphics/wayland/weston/0004-MGS-1668-xwld-System-can-not-boot-up-to-desktop.patch
@@ -1,12 +1,12 @@
-From d3bc23ef2031e2749362bb0b90e5d164ef5d5942 Mon Sep 17 00:00:00 2001
+From 2e5260168b59c96688b10912cff3d95ec1fbb3d8 Mon Sep 17 00:00:00 2001
 From: Meng Mingming <mingming.meng@nxp.com>
-Date: Mon, 9 Jan 2017 15:08:51 +0800
-Subject: [PATCH 4/6] MGS-1668: xwld: System can not boot up to desktop
+Date: Mon, 16 Jan 2017 10:25:29 +0800
+Subject: [PATCH 4/5] MGS-1668: xwld: System can not boot up to desktop
 
 System can not boot up to desktop if press touch panel continuously during booting up.
 The weston view was not initialed completely, so add a protection to the pointer.
 
-Upstream Status: Inappropriate [i.MX specific]
+Upstream Status: Denied [Could not reproduce]
 
 Date: MAR 08, 2016
 Signed-off-by: Yong Gan <yong.gan@nxp.com>
diff --git a/recipes-graphics/wayland/weston/0005-MGS-1252-Fix-for-Qt5_CinematicExperience-will-meet-s.patch b/recipes-graphics/wayland/weston/0005-MGS-1252-Fix-for-Qt5_CinematicExperience-will-meet-s.patch
deleted file mode 100644
index 82d3798..0000000
--- a/recipes-graphics/wayland/weston/0005-MGS-1252-Fix-for-Qt5_CinematicExperience-will-meet-s.patch
+++ /dev/null
@@ -1,93 +0,0 @@
-From 515b1f1c1902ae22914a93982935e2328d2240d2 Mon Sep 17 00:00:00 2001
-From: Yong Gan <b45748@freescale.com>
-Date: Thu, 19 Nov 2015 15:30:24 +0800
-Subject: [PATCH 2/2] MGS-1252: Fix for Qt5_CinematicExperience will meet
- screen blur
-
-When the Qt5_CinematicExperience is created, window creates with 1920x1080
-and the starting coordiantes more than screen coordinate.
-Ths cause access beyond the surface and system hang on lcd display
-
-Date: Nov 18, 2015
-Signed-off-by: Prabhu <prabhu.sundararaj@freescale.com>
----
- src/gal2d-renderer.c | 30 ++++++++++++++++++------------
- 1 file changed, 18 insertions(+), 12 deletions(-)
-
-diff --git a/src/gal2d-renderer.c b/src/gal2d-renderer.c
-index c68f02c..6e7d640 100644
---- a/src/gal2d-renderer.c
-+++ b/src/gal2d-renderer.c
-@@ -661,12 +661,11 @@ repaint_region(struct weston_view *ev, struct weston_output *output, struct gal2
- 	gcsRECT srcRect = {0};
- 	gcsRECT dstrect = {0};
- 	gctUINT32 horFactor, verFactor;
--	int useStretch =1;
- 	int useFilterBlit = 0;
- 	gctUINT srcWidth = 0;
- 	gctUINT srcHeight = 0;
- 	gctUINT32 srcStride[3];
--	gceSURF_FORMAT srcFormat;;
-+	gceSURF_FORMAT srcFormat;
- 	gctUINT32 srcPhyAddr[3];
- 	gctUINT32 dstPhyAddr[3];
- 	gctUINT dstWidth = 0;
-@@ -702,14 +701,16 @@ repaint_region(struct weston_view *ev, struct weston_output *output, struct gal2
- 	srcRect.right = ev->surface->width;
- 	srcRect.bottom = ev->surface->height;
- 
--	if(useFilterBlit)
-+	dstsurface = go->nNumBuffers > 1 ?
-+					go->renderSurf[go->activebuffer] :
-+					go->offscreenSurface;
-+	gcmVERIFY_OK(gcoSURF_GetAlignedSize(dstsurface, &dstWidth, &dstHeight, (gctINT *)&dstStrides));
-+	gcmVERIFY_OK(gcoSURF_Lock(dstsurface, &dstPhyAddr[0], gcvNULL));
-+	gcmVERIFY_OK(gcoSURF_Unlock(dstsurface, gcvNULL));
-+
-+	if(galIsYUVFormat(srcFormat) == gcvSTATUS_TRUE)
- 	{
--		dstsurface = go->nNumBuffers > 1 ?
--						go->renderSurf[go->activebuffer] :
--						go->offscreenSurface;
--		gcmVERIFY_OK(gcoSURF_GetAlignedSize(dstsurface, &dstWidth, &dstHeight, (gctINT *)&dstStrides));
--		gcmVERIFY_OK(gcoSURF_Lock(dstsurface, &dstPhyAddr[0], gcvNULL));
--		gcmVERIFY_OK(gcoSURF_Unlock(dstsurface, gcvNULL));
-+		useFilterBlit = 1;
- 	}
- 	else
- 	{
-@@ -739,7 +740,7 @@ repaint_region(struct weston_view *ev, struct weston_output *output, struct gal2
- 		dstrect.right = bb_rects[0].x2;
- 		dstrect.bottom = bb_rects[0].y2;
- 
--		if(dstrect.right < 0 || dstrect.bottom < 0)
-+		if(dstrect.right < 0 || dstrect.bottom < 0 || dstrect.left > dstWidth || dstrect.top > dstHeight)
- 		{
- 			break;
- 		}
-@@ -829,8 +830,7 @@ repaint_region(struct weston_view *ev, struct weston_output *output, struct gal2
- 			}
- 			else
- 			{
--				if(useStretch)
--					gcmVERIFY_OK(galGetStretchFactors(&srcRect, &dstrect, &horFactor, &verFactor));
-+				gcmVERIFY_OK(galGetStretchFactors(&srcRect, &dstrect, &horFactor, &verFactor));
- 
- 				if(verFactor == 65536 && horFactor == 65536)
- 				{
-@@ -839,6 +839,12 @@ repaint_region(struct weston_view *ev, struct weston_output *output, struct gal2
- 				}
- 				else
- 				{
-+					dstrect.right = dstrect.right < dstWidth ? dstrect.right : dstWidth;
-+					dstrect.bottom = dstrect.bottom < dstHeight ? dstrect.bottom : dstHeight;
-+					srcRect.right = srcRect.right < dstWidth ? srcRect.right : dstWidth;
-+					srcRect.bottom = srcRect.bottom < dstHeight ? srcRect.bottom : dstHeight;
-+
-+					gcmVERIFY_OK(galGetStretchFactors(&srcRect, &dstrect, &horFactor, &verFactor));
- 					/* Program the stretch factors. */
- 					gcmVERIFY_OK(gco2D_SetStretchFactors(gr->gcoEngine2d, horFactor, verFactor));
- 
--- 
-1.9.1
-
diff --git a/recipes-graphics/wayland/weston/0011-MGS-1724-xwld-G2D-compositor-build-failed-in-slevk-b.patch b/recipes-graphics/wayland/weston/0005-MGS-1724-xwld-G2D-compositor-build-failed-in-slevk-b.patch
similarity index 44%
rename from recipes-graphics/wayland/weston/0011-MGS-1724-xwld-G2D-compositor-build-failed-in-slevk-b.patch
rename to recipes-graphics/wayland/weston/0005-MGS-1724-xwld-G2D-compositor-build-failed-in-slevk-b.patch
index 42a3339..73b298c 100644
--- a/recipes-graphics/wayland/weston/0011-MGS-1724-xwld-G2D-compositor-build-failed-in-slevk-b.patch
+++ b/recipes-graphics/wayland/weston/0005-MGS-1724-xwld-G2D-compositor-build-failed-in-slevk-b.patch
@@ -1,26 +1,26 @@
-From b67a6184ed3b6d728894eba37a554a302c1b0312 Mon Sep 17 00:00:00 2001
-From: "yong.gan" <yong.gan@nxp.com>
-Date: Sat, 2 Apr 2016 09:33:56 +0800
-Subject: [PATCH 3/3] MGS-1724: xwld: G2D compositor build failed in slevk
+From 3c11ac3c4b8416752c0e147ccde067070005597e Mon Sep 17 00:00:00 2001
+From: Meng Mingming <mingming.meng@nxp.com>
+Date: Mon, 16 Jan 2017 10:28:28 +0800
+Subject: [PATCH 5/5] MGS-1724: xwld: G2D compositor build failed in slevk
  board
 
 Add macro ENABLE_EGL to make sure the EGL was not built in slevk board.
-Modify the wrong format for the shm buffer.
 
 Upstream Status: Inappropriate [i.MX specific]
 
-Signed-off-by: Yong Gan <yong.gan@nxp.com>
+Date: Jan 16, 2017
+Signed-off-by: Meng Mingming <mingming.meng@nxp.com>
 ---
- src/compositor-fbdev.c | 11 ++++++++++-
- src/g2d-renderer.c     |  4 ++--
- 2 files changed, 12 insertions(+), 3 deletions(-)
+ src/compositor-fbdev.c | 18 ++++++++++++------
+ src/main.c             | 22 +++++++++++++++++++---
+ 2 files changed, 31 insertions(+), 9 deletions(-)
 
-Index: weston-1.11.1/src/compositor-fbdev.c
-===================================================================
---- weston-1.11.1.orig/src/compositor-fbdev.c	2017-01-14 09:47:24.064006974 -0600
-+++ weston-1.11.1/src/compositor-fbdev.c	2017-01-14 09:55:59.000000000 -0600
-@@ -63,7 +63,9 @@
- 	int use_g2d;
+diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
+index 0a05e7d..22d349b 100644
+--- a/src/compositor-fbdev.c
++++ b/src/compositor-fbdev.c
+@@ -65,7 +65,9 @@ struct fbdev_backend {
+ 	char *clone_device;
  	uint32_t output_transform;
  	struct wl_listener session_listener;
 +#ifdef ENABLE_EGL
@@ -29,11 +29,10 @@ Index: weston-1.11.1/src/compositor-fbdev.c
  };
  
  struct fbdev_screeninfo {
-@@ -96,9 +98,10 @@
- 	/* pixman details. */
+@@ -99,8 +101,10 @@ struct fbdev_output {
  	pixman_image_t *hw_surface;
  	uint8_t depth;
--
+ 
 +#ifdef ENABLE_EGL
  	NativeDisplayType display;
  	NativeWindowType  window;
@@ -41,10 +40,11 @@ Index: weston-1.11.1/src/compositor-fbdev.c
  };
  
  struct gl_renderer_interface *gl_renderer;
-@@ -450,10 +453,12 @@
+@@ -452,10 +456,13 @@ fbdev_frame_buffer_destroy(struct fbdev_output *output)
  		           strerror(errno));
  
  	output->fb = NULL;
++
 +#ifdef ENABLE_EGL
  	if(output->window)
  		fbDestroyWindow(output->window);
@@ -54,15 +54,15 @@ Index: weston-1.11.1/src/compositor-fbdev.c
  }
  
  static void fbdev_output_destroy(struct weston_output *base);
-@@ -527,6 +532,7 @@
+@@ -532,6 +539,7 @@ fbdev_output_create(struct fbdev_backend *backend,
+ 				goto out_hw_surface;
  		}
- 
  	} else {
 +#ifdef ENABLE_EGL
  		setenv("HYBRIS_EGLPLATFORM", "wayland", 1);
  		output->window = fbCreateWindow(backend->display, -1, -1, 0, 0);
  		if (output->window == NULL) {
-@@ -540,6 +546,7 @@
+@@ -545,6 +553,7 @@ fbdev_output_create(struct fbdev_backend *backend,
  			weston_log("gl_renderer_output_create failed.\n");
  			goto out_hw_surface;
  		}
@@ -70,45 +70,59 @@ Index: weston-1.11.1/src/compositor-fbdev.c
  	}
  
  	loop = wl_display_get_event_loop(backend->compositor->wl_display);
-@@ -847,6 +854,7 @@
+@@ -856,6 +865,7 @@ fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv
+ 			}
  		}
- 	}
- 	 else {
+ 	} else {
 +#ifdef ENABLE_EGL
  		gl_renderer = weston_load_module("gl-renderer.so",
  						 "gl_renderer_interface");
  		if (!gl_renderer) {
-@@ -866,6 +874,7 @@
+@@ -875,7 +885,9 @@ fbdev_backend_create(struct weston_compositor *compositor, int *argc, char *argv
  			weston_log("gl_renderer_create failed.\n");
  			goto out_launcher;
  		}
 +#endif
  	}
++
  	if(!backend->use_g2d)
  		if (fbdev_output_create(backend, 0, 0, param->device) < 0)
-Index: weston-1.11.1/src/g2d-renderer.c
-===================================================================
---- weston-1.11.1.orig/src/g2d-renderer.c	2017-01-14 09:47:24.152007410 -0600
-+++ weston-1.11.1/src/g2d-renderer.c	2017-01-14 09:48:56.000000000 -0600
-@@ -756,11 +756,11 @@
+ 			goto out_launcher;
+@@ -929,12 +941,6 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
+ 	config_init_to_defaults(&config);
+ 	memcpy(&config, config_base, config_base->struct_size);
  
- 	switch (wl_shm_buffer_get_format(shm_buffer)) {
- 	case WL_SHM_FORMAT_XRGB8888:
--		g2dFormat = G2D_XRGB8888;
-+		g2dFormat = G2D_BGRX8888;
- 		gs->bpp = 4;
- 		break;
- 	case WL_SHM_FORMAT_ARGB8888:
--		g2dFormat = G2D_ARGB8888;
-+		g2dFormat = G2D_BGRA8888;
- 		gs->bpp = 4;
- 		break;
- 	case WL_SHM_FORMAT_RGB565:
-Index: weston-1.11.1/src/main.c
-===================================================================
---- weston-1.11.1.orig/src/main.c	2017-01-14 10:02:42.000000000 -0600
-+++ weston-1.11.1/src/main.c	2017-01-14 10:02:58.000000000 -0600
-@@ -866,7 +866,17 @@
+-	if(config.use_g2d) {
+-		config.use_gl = 0;
+-	} else {
+-		config.use_gl = 1;
+-	}
+-
+ 	b = fbdev_backend_create(compositor, argc, argv, wc, &config);
+ 	if (b == NULL)
+ 		return -1;
+diff --git a/src/main.c b/src/main.c
+index 18fe5e0..a0a5471 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -285,8 +285,14 @@ usage(int error_code)
+ 		"Options for fbdev-backend.so:\n\n"
+ 		"  --tty=TTY\t\tThe tty to use\n"
+ 		"  --device=DEVICE\tThe framebuffer device to use\n"
+-		"  --use-gl=1\t\tUse the GL renderer\n"
+-		"  --use-g2d=1\t\tUse the g2d renderer\n\n");
++#if defined(ENABLE_EGL)
++		"  --use-gl=1\t\tUse the GL renderer (default is 1)\n"
++		"  --use-g2d=1\t\tUse the G2D renderer (default is 0)\n"
++#else
++		"  --use-gl=1\t\tUse the GL renderer (default is 0)\n"
++		"  --use-g2d=1\t\tUse the G2D renderer (default is 1)\n"
++#endif
++		"  --clone-mode\t\tClone display to multiple devices\n\n");
+ #endif
+ 
+ #if defined(BUILD_HEADLESS_COMPOSITOR)
+@@ -861,7 +867,17 @@ static int
  load_fbdev_backend(struct weston_compositor *c, char const * backend,
  		      int *argc, char **argv, struct weston_config *wc)
  {
@@ -127,3 +141,6 @@ Index: weston-1.11.1/src/main.c
  	struct weston_config_section *section;
  	char *s = NULL;
  	int ret = 0;
+-- 
+2.7.4
+
diff --git a/recipes-graphics/wayland/weston/0016-Link-compositor-to-egl.patch b/recipes-graphics/wayland/weston/0006-Link-compositor-to-egl.patch
similarity index 100%
rename from recipes-graphics/wayland/weston/0016-Link-compositor-to-egl.patch
rename to recipes-graphics/wayland/weston/0006-Link-compositor-to-egl.patch
diff --git a/recipes-graphics/wayland/weston/0006-MGS-1236-imx6qp-imx6dl-First-frame-distored-when-som.patch b/recipes-graphics/wayland/weston/0006-MGS-1236-imx6qp-imx6dl-First-frame-distored-when-som.patch
deleted file mode 100644
index bed6f0c..0000000
--- a/recipes-graphics/wayland/weston/0006-MGS-1236-imx6qp-imx6dl-First-frame-distored-when-som.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-From 2bd1096ac342e251980c639543c0fad2f7173e82 Mon Sep 17 00:00:00 2001
-From: Prabhu Sundararaj <prabhu.sundararaj@freescale.com>
-Date: Wed, 9 Dec 2015 18:20:35 -0600
-Subject: [PATCH] MGS-1236 : [imx6qp/imx6dl] First frame distored when some
- wayland apps run continuously using g2d
-
-gco2D_SetSource was missing when using the blit operations and
-hence causing the issue.
-
-If the weston started without weston.ini, animations will be disabled,
-for xwayland the weston.ini need to be included and hence the error
-was shown.
-
-Also removing util functions reusing from libGAL.so
-
-Date: Dec 10, 2015
-Signed-off-by: Prabhu Sundararaj <prabhu.sundararaj@freescale.com>
----
- src/gal2d-renderer.c | 57 ++++++----------------------------------------------
- 1 file changed, 6 insertions(+), 51 deletions(-)
-
-diff --git a/src/gal2d-renderer.c b/src/gal2d-renderer.c
-index 6e7d640..dbec2d0 100644
---- a/src/gal2d-renderer.c
-+++ b/src/gal2d-renderer.c
-@@ -186,56 +186,6 @@ get_output_state(struct weston_output *output)
- 	return (struct gal2d_output_state *)output->renderer_state;
- }
- 
--static gctUINT32
--galGetStretchFactor(gctINT32 SrcSize, gctINT32 DestSize)
--{
--	gctUINT stretchFactor;
--	if ( (SrcSize > 0) && (DestSize > 1) )
--	{
--		stretchFactor = ((SrcSize - 1) << 16) / (DestSize - 1);
--	}
--	else
--	{
--		stretchFactor = 0;
--	}
--	return stretchFactor;
--}
--
--static gceSTATUS
--galGetStretchFactors(
--	IN gcsRECT_PTR SrcRect,
--	IN gcsRECT_PTR DestRect,
--	OUT gctUINT32 * HorFactor,
--	OUT gctUINT32 * VerFactor
--	)
--{
--	if (HorFactor != gcvNULL)
--	{
--        gctINT32 src, dest;
--
--        /* Compute width of rectangles. */
--        gcmVERIFY_OK(gcsRECT_Width(SrcRect, &src));
--        gcmVERIFY_OK(gcsRECT_Width(DestRect, &dest));
--
--        /* Compute and return horizontal stretch factor. */
--		*HorFactor = galGetStretchFactor(src, dest);
--	}
--
--	if (VerFactor != gcvNULL)
--	{
--		gctINT32 src, dest;
--
--		/* Compute height of rectangles. */
--		gcmVERIFY_OK(gcsRECT_Height(SrcRect, &src));
--		gcmVERIFY_OK(gcsRECT_Height(DestRect, &dest));
--
--		/* Compute and return vertical stretch factor. */
--		*VerFactor = galGetStretchFactor(src, dest);
--	}
--    /* Success. */
--    return gcvSTATUS_OK;
--}
--
- static gceSTATUS
- gal2d_getSurfaceFormat(halDISPLAY_INFO info, gceSURF_FORMAT * Format)
- {
-@@ -725,6 +675,7 @@ repaint_region(struct weston_view *ev, struct weston_output *output, struct gal2
- 				        srcStride, 1,
- 				        tiling, srcFormat, gcvSURF_0_DEGREE,
- 				        srcWidth, srcHeight);
-+        gcmVERIFY_OK(gco2D_SetSource(gr->gcoEngine2d, &srcRect));
-          /* Setup mirror. */
-         gcmONERROR(gco2D_SetBitBlitMirror(gr->gcoEngine2d, gcvFALSE, gcvFALSE));
-         gcmONERROR(gco2D_SetROP(gr->gcoEngine2d, 0xCC, 0xCC));
-@@ -830,7 +781,11 @@ repaint_region(struct weston_view *ev, struct weston_output *output, struct gal2
- 			}
- 			else
- 			{
--				gcmVERIFY_OK(galGetStretchFactors(&srcRect, &dstrect, &horFactor, &verFactor));
-+                               gcmVERIFY_OK(gco2D_CalcStretchFactor(gr->gcoEngine2d, srcRect.right - srcRect.left,
-+                                        dstrect.right - dstrect.left, &horFactor));
-+
-+                               gcmONERROR(gco2D_CalcStretchFactor(gr->gcoEngine2d, srcRect.bottom - srcRect.top,
-+                                        dstrect.bottom - dstrect.top, &verFactor));
- 
- 				if(verFactor == 65536 && horFactor == 65536)
- 				{
--- 
-2.6.2
-
diff --git a/recipes-graphics/wayland/weston/0007-MGS-1236-1-imx6qp-imx6dl-First-frame-distored-when-s.patch b/recipes-graphics/wayland/weston/0007-MGS-1236-1-imx6qp-imx6dl-First-frame-distored-when-s.patch
deleted file mode 100644
index 1c094c4..0000000
--- a/recipes-graphics/wayland/weston/0007-MGS-1236-1-imx6qp-imx6dl-First-frame-distored-when-s.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-From b33d44b736b7b7ae4db31dc32ff9441c753219fb Mon Sep 17 00:00:00 2001
-From: Prabhu Sundararaj <prabhu.sundararaj@freescale.com>
-Date: Mon, 28 Dec 2015 22:15:05 -0600
-Subject: [PATCH] MGS-1236-1 : [imx6qp/imx6dl] First frame distored when some
- wayland apps run continuously using g2d
-
-Remove residual galGetStretchFactors functions. the function is not needed
-any more
-
-Date: Dec 28, 2015
-Signed-off-by: Prabhu Sundararaj <prabhu.sundararaj@freescale.com>
----
- src/gal2d-renderer.c | 14 +++++++++-----
- 1 file changed, 9 insertions(+), 5 deletions(-)
-
-diff --git a/src/gal2d-renderer.c b/src/gal2d-renderer.c
-index dbec2d0..2ecc8ac 100644
---- a/src/gal2d-renderer.c
-+++ b/src/gal2d-renderer.c
-@@ -781,11 +781,11 @@ repaint_region(struct weston_view *ev, struct weston_output *output, struct gal2
- 			}
- 			else
- 			{
--                               gcmVERIFY_OK(gco2D_CalcStretchFactor(gr->gcoEngine2d, srcRect.right - srcRect.left,
--                                        dstrect.right - dstrect.left, &horFactor));
-+				gcmVERIFY_OK(gco2D_CalcStretchFactor(gr->gcoEngine2d, srcRect.right - srcRect.left,
-+						dstrect.right - dstrect.left, &horFactor));
- 
--                               gcmONERROR(gco2D_CalcStretchFactor(gr->gcoEngine2d, srcRect.bottom - srcRect.top,
--                                        dstrect.bottom - dstrect.top, &verFactor));
-+				gcmONERROR(gco2D_CalcStretchFactor(gr->gcoEngine2d, srcRect.bottom - srcRect.top,
-+						dstrect.bottom - dstrect.top, &verFactor));
- 
- 				if(verFactor == 65536 && horFactor == 65536)
- 				{
-@@ -799,7 +799,11 @@ repaint_region(struct weston_view *ev, struct weston_output *output, struct gal2
- 					srcRect.right = srcRect.right < dstWidth ? srcRect.right : dstWidth;
- 					srcRect.bottom = srcRect.bottom < dstHeight ? srcRect.bottom : dstHeight;
- 
--					gcmVERIFY_OK(galGetStretchFactors(&srcRect, &dstrect, &horFactor, &verFactor));
-+					gcmVERIFY_OK(gco2D_CalcStretchFactor(gr->gcoEngine2d, srcRect.right - srcRect.left,
-+						dstrect.right - dstrect.left, &horFactor));
-+
-+					gcmONERROR(gco2D_CalcStretchFactor(gr->gcoEngine2d, srcRect.bottom - srcRect.top,
-+							dstrect.bottom - dstrect.top, &verFactor));
- 					/* Program the stretch factors. */
- 					gcmVERIFY_OK(gco2D_SetStretchFactors(gr->gcoEngine2d, horFactor, verFactor));
- 
--- 
-2.6.2
-
diff --git a/recipes-graphics/wayland/weston/0020-xwayland-Fix-crash-when-run-with-no-input-device.patch b/recipes-graphics/wayland/weston/0007-xwayland-Fix-crash-when-run-with-no-input-device.patch
similarity index 100%
rename from recipes-graphics/wayland/weston/0020-xwayland-Fix-crash-when-run-with-no-input-device.patch
rename to recipes-graphics/wayland/weston/0007-xwayland-Fix-crash-when-run-with-no-input-device.patch
diff --git a/recipes-graphics/wayland/weston/0010-MGS-1284-1-xwld-Re-implement-weston-2d-renderer-with.patch b/recipes-graphics/wayland/weston/0010-MGS-1284-1-xwld-Re-implement-weston-2d-renderer-with.patch
deleted file mode 100644
index 96181ab..0000000
--- a/recipes-graphics/wayland/weston/0010-MGS-1284-1-xwld-Re-implement-weston-2d-renderer-with.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From 9a19dd911fc79fa828b03fce8cdb16c6cfcb25cb Mon Sep 17 00:00:00 2001
-From: "yong.gan" <yong.gan@nxp.com>
-Date: Tue, 22 Mar 2016 10:15:31 +0800
-Subject: [PATCH 2/3] MGS-1284-1: xwld: Re-implement weston 2d renderer with
- porting g2d API
-
-Add gpu address to the buffer physical address, fix the mess in sx board.
-
-Date: Feb 22, 2016
-Upstream Status: Inappropriate [i.MX specific]
-
-Signed-off-by: Yong Gan <yong.gan@freescale.com>
----
- src/g2d-renderer.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/g2d-renderer.c b/src/g2d-renderer.c
-index 756c8f0..19c93a0 100644
---- a/src/g2d-renderer.c
-+++ b/src/g2d-renderer.c
-@@ -317,9 +317,9 @@ get_g2dSurface(gcsWL_VIV_BUFFER *buffer, struct g2d_surfaceEx *g2dSurface)
- 	int height = buffer->alignedHeight;
- 	g2d_getG2dFormat(buffer->format, &g2dSurface->base.format);
- 	g2d_getG2dTiling(buffer->tiling, &g2dSurface->tiling);
--	g2dSurface->base.planes[0] = buffer->physical[0];
--	g2dSurface->base.planes[1] = buffer->physical[1];
--	g2dSurface->base.planes[2] = buffer->physical[2];
-+	g2dSurface->base.planes[0] = buffer->physical[0] + buffer->gpuBaseAddr;
-+	g2dSurface->base.planes[1] = buffer->physical[1] + buffer->gpuBaseAddr;
-+	g2dSurface->base.planes[2] = buffer->physical[2] + buffer->gpuBaseAddr;
- 	g2dSurface->base.left = 0;
- 	g2dSurface->base.top = 0;
- 	g2dSurface->base.right = buffer->width;
--- 
-1.9.1
-
diff --git a/recipes-graphics/wayland/weston/0013-MGS-1945-Use-common-API-to-support-G2d-compositor.patch b/recipes-graphics/wayland/weston/0013-MGS-1945-Use-common-API-to-support-G2d-compositor.patch
deleted file mode 100644
index 4616173..0000000
--- a/recipes-graphics/wayland/weston/0013-MGS-1945-Use-common-API-to-support-G2d-compositor.patch
+++ /dev/null
@@ -1,196 +0,0 @@
-From bdf9a0349f84997397a1c9352ee041e6fa4256a9 Mon Sep 17 00:00:00 2001
-From: "yong.gan" <yong.gan@nxp.com>
-Date: Thu, 23 Jun 2016 09:15:51 +0800
-Subject: [PATCH] MGS-1945: Use common API to support G2d compositor.
-
-Replace gcoOS_WaylandCreateVivGlobal with eglBindWaylandDisplayWL.
-Fix a width set error in g2d_renderer_attach_shm.
-Use noncached buffer in weston shm buffer.
-
-Upstream-Status: Inappropriate [i.MX specific]
-Date: Jun 21, 2016
-Signed-off-by: Yong Gan <yong.gan@nxp.com>
----
- Makefile.am        |  4 ++++
- src/g2d-renderer.c | 44 +++++++++++++++++++++++++++-----------------
- src/g2d-renderer.h |  1 +
- 3 files changed, 32 insertions(+), 17 deletions(-)
-
-diff --git a/Makefile.am b/Makefile.am
-index f62bfc7..207864f 100644
---- a/Makefile.am
-+++ b/Makefile.am
-@@ -214,6 +214,7 @@ gl_renderer_la_SOURCES =			\
- 	src/vertex-clipping.h			\
- 	shared/helpers.h
- endif
-+
- module_LTLIBRARIES += g2d-renderer.la
- g2d_renderer_la_LDFLAGS = -module -avoid-version
- g2d_renderer_la_LIBADD = $(COMPOSITOR_LIBS) $(EGL_LIBS) -lg2d
-@@ -226,6 +227,9 @@ g2d_renderer_la_SOURCES =			\
- 	src/g2d-renderer.c			\
- 	src/vertex-clipping.c			\
- 	src/vertex-clipping.h
-+if ENABLE_EGL
-+g2d_renderer_la_CFLAGS += -DENABLE_EGL
-+endif
- 
- if ENABLE_X11_COMPOSITOR
- module_LTLIBRARIES += x11-backend.la
-diff --git a/src/g2d-renderer.c b/src/g2d-renderer.c
-index 4440fb9..0c26e91 100644
---- a/src/g2d-renderer.c
-+++ b/src/g2d-renderer.c
-@@ -46,7 +46,7 @@
- #include "shared/helpers.h"
- 
- #define BUFFER_DAMAGE_COUNT 2
--extern struct wl_global* gcoOS_WaylandCreateVivGlobal(struct wl_display* display);
-+#define ALIGN_WIDTH(a) (((a) + 15) & ~15)
- 
- typedef struct _g2dRECT
- {
-@@ -103,7 +103,11 @@ struct g2d_surface_state {
- struct g2d_renderer {
- 	struct weston_renderer base;
- 	struct wl_signal destroy_signal;
--	struct wl_global *viv_global;
-+#ifdef ENABLE_EGL
-+	NativeDisplayType display;
-+	EGLDisplay egl_display;
-+	struct wl_display *wl_display;
-+#endif
- 	void *handle;
- };
- 
-@@ -296,9 +300,10 @@ g2d_getG2dFormat(IN gceSURF_FORMAT Format, enum g2d_format* g2dFormat)
- 	}
- }
- 
--static void printG2dSurfaceInfo(struct g2d_surfaceEx* g2dSurface)
-+static void printG2dSurfaceInfo(struct g2d_surfaceEx* g2dSurface, const char* msg)
- {
--	weston_log("physicAddr = %d left = %d right = %d top=%d bottom=%d stride= %d tiling = %d, format=%d \n",
-+	weston_log("%s physicAddr = %x left = %d right = %d top=%d bottom=%d stride= %d tiling = %d, format=%d \n",
-+				msg,
- 				g2dSurface->base.planes[0],
- 				g2dSurface->base.left,
- 				g2dSurface->base.right,
-@@ -357,8 +362,8 @@ g2d_blitSurface(void *handle, struct g2d_surfaceEx * srcG2dSurface, struct g2d_s
- 
- 	if(g2d_blitEx(handle, srcG2dSurface, dstG2dSurface))
- 	{
--		printG2dSurfaceInfo(srcG2dSurface);
--		printG2dSurfaceInfo(dstG2dSurface);
-+		printG2dSurfaceInfo(srcG2dSurface, "SRC:");
-+		printG2dSurfaceInfo(dstG2dSurface, "DST:");
- 		return -1;
- 	}
- 	return 0;
-@@ -724,7 +729,7 @@ g2d_renderer_flush_damage(struct weston_surface *surface)
- 		wl_shm_buffer_begin_access(buffer->shm_buffer);
- 		if(gs->shm_buf)
- 		{
--			int alignedWidth = (buffer->width + 15) & ~15;
-+			int alignedWidth = ALIGN_WIDTH(buffer->width);
- 			if(alignedWidth == buffer->width)
- 			{
- 				int size = wl_shm_buffer_get_stride(buffer->shm_buffer)*buffer->height;
-@@ -743,7 +748,6 @@ g2d_renderer_flush_damage(struct weston_surface *surface)
- 					}
- 				}
- 			}
--			g2d_cache_op(gs->shm_buf, G2D_CACHE_CLEAN);
- 		}
- 		else
- 		{
-@@ -768,7 +772,6 @@ g2d_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer,
- 			struct wl_shm_buffer *shm_buffer)
- {
- 	struct g2d_surface_state *gs = get_surface_state(es);
--	int stride = 0;
- 	int buffer_length = 0;
- 	int alloc_new_buff = 1;
- 	int alignedWidth = 0;
-@@ -776,9 +779,7 @@ g2d_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer,
- 	buffer->shm_buffer = shm_buffer;
- 	buffer->width = wl_shm_buffer_get_width(shm_buffer);
- 	buffer->height = wl_shm_buffer_get_height(shm_buffer);
--	alignedWidth = (buffer->width + 15) & ~15;
--	stride = wl_shm_buffer_get_stride(shm_buffer);
--	buffer_length = stride * buffer->height;
-+	alignedWidth = ALIGN_WIDTH(buffer->width);
- 
- 	switch (wl_shm_buffer_get_format(shm_buffer)) {
- 	case WL_SHM_FORMAT_XRGB8888:
-@@ -812,7 +813,7 @@ g2d_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer,
- 	{
- 		if(gs->shm_buf)
- 			g2d_free(gs->shm_buf);
--		gs->shm_buf = g2d_alloc(buffer_length, 1);
-+		gs->shm_buf = g2d_alloc(buffer_length, 0);
- 		gs->g2d_surface.base.planes[0] = gs->shm_buf->buf_paddr;
- 	}
- 	gs->g2d_surface.base.left = 0;
-@@ -820,7 +821,7 @@ g2d_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer,
- 	gs->g2d_surface.base.right  = buffer->width;
- 	gs->g2d_surface.base.bottom = buffer->height;
- 	gs->g2d_surface.base.stride = alignedWidth;
--	gs->g2d_surface.base.width  = buffer->width;
-+	gs->g2d_surface.base.width  = alignedWidth;
- 	gs->g2d_surface.base.height = buffer->height;
- 	gs->g2d_surface.base.rot    = G2D_ROTATION_0;
- 	gs->g2d_surface.base.clrcolor = 0xFF400000;
-@@ -953,7 +954,7 @@ static void
- g2d_renderer_output_destroy(struct weston_output *output)
- {
- 	struct g2d_output_state *go = get_output_state(output);
--	gctUINT32 i;
-+	int i;
- 
- 	for (i = 0; i < 2; i++)
- 	{
-@@ -1005,8 +1006,12 @@ g2d_renderer_destroy(struct weston_compositor *ec)
- 	struct g2d_renderer *gr = get_renderer(ec);
- 
- 	wl_signal_emit(&gr->destroy_signal, gr);
--	wl_global_destroy(gr->viv_global);
- 	g2d_close(gr->handle);
-+#ifdef ENABLE_EGL
-+	eglUnbindWaylandDisplayWL(gr->egl_display);
-+	eglTerminate(gr->egl_display);
-+	fbDestroyDisplay(gr->display);
-+#endif
- 	free(ec->renderer);
- 	ec->renderer = NULL;
- }
-@@ -1247,7 +1252,12 @@ g2d_renderer_output_create(struct weston_output *output, struct wl_display *wl_d
- 		return -1;
- 	go->clone_display_num  = clone_display_num;
- 	output->renderer_state = go;
--	gr->viv_global = gcoOS_WaylandCreateVivGlobal(wl_display);
-+#ifdef ENABLE_EGL
-+	gr->wl_display = wl_display;
-+	gr->display = fbGetDisplay(wl_display);
-+	gr->egl_display = eglGetDisplay(gr->display);
-+	eglBindWaylandDisplayWL(gr->egl_display, wl_display);
-+#endif
- 	getBufferNumber(go);
- 
- 	if(g2d_renderer_surface_create(go, gr, displays[0]) < 0)
-diff --git a/src/g2d-renderer.h b/src/g2d-renderer.h
-index 45c72de..fc4ca49 100644
---- a/src/g2d-renderer.h
-+++ b/src/g2d-renderer.h
-@@ -30,6 +30,7 @@
- 
- #ifdef ENABLE_EGL
- #include <EGL/egl.h>
-+#include <EGL/eglext.h>
- #endif
- 
- struct g2d_renderer_interface {
--- 
-1.9.1
-
diff --git a/recipes-graphics/wayland/weston/0014-MGS-1987-Get-stride-from-the-FB-buffe.patch b/recipes-graphics/wayland/weston/0014-MGS-1987-Get-stride-from-the-FB-buffe.patch
deleted file mode 100644
index a4658a7..0000000
--- a/recipes-graphics/wayland/weston/0014-MGS-1987-Get-stride-from-the-FB-buffe.patch
+++ /dev/null
@@ -1,76 +0,0 @@
-From 735e58c6066fe1148d803168c6241a4d8cb5c973 Mon Sep 17 00:00:00 2001
-From: "yong.gan" <yong.gan@nxp.com>
-Date: Wed, 6 Jul 2016 08:28:18 +0800
-Subject: [PATCH] MGS-1987: Get stride from the FB buffe.
-
-Fix the stride setting error in the fbinfo.
-
-Date: Jul 6, 2016
-Signed-off-by: Yong Gan <yong.gan@nxp.com>
----
- src/g2d-renderer.c | 14 +++++++-------
- 1 file changed, 7 insertions(+), 7 deletions(-)
-
-diff --git a/src/g2d-renderer.c b/src/g2d-renderer.c
-index 0c26e91..30bf1a5 100644
---- a/src/g2d-renderer.c
-+++ b/src/g2d-renderer.c
-@@ -63,6 +63,7 @@ struct fb_screeninfo {
- 	unsigned int y_resolution;
- 	size_t buffer_length; /* length of frame buffer memory in bytes */
- 	size_t physical;
-+	size_t stride;
- 	enum g2d_format pixel_format; /* frame buffer pixel format */
- 	int fb_fd;
- };
-@@ -322,8 +323,6 @@ get_g2dSurface(gcsWL_VIV_BUFFER *buffer, struct g2d_surfaceEx *g2dSurface)
- 		weston_log("invalid EGL buffer in function %s\n", __func__);
- 		return;
- 	}
--	int width  = buffer->alignedWidth;
--	int height = buffer->alignedHeight;
- 	g2d_getG2dFormat(buffer->format, &g2dSurface->base.format);
- 	g2d_getG2dTiling(buffer->tiling, &g2dSurface->tiling);
- 	g2dSurface->base.planes[0] = buffer->physical[0] + buffer->gpuBaseAddr;
-@@ -333,9 +332,9 @@ get_g2dSurface(gcsWL_VIV_BUFFER *buffer, struct g2d_surfaceEx *g2dSurface)
- 	g2dSurface->base.top = 0;
- 	g2dSurface->base.right = buffer->width;
- 	g2dSurface->base.bottom = buffer->height;
--	g2dSurface->base.stride = width;
--	g2dSurface->base.width  = width;
--	g2dSurface->base.height = height;
-+	g2dSurface->base.stride = buffer->alignedWidth;
-+	g2dSurface->base.width  = buffer->width;
-+	g2dSurface->base.height = buffer->height;
- 	g2dSurface->base.rot    = G2D_ROTATION_0;
- }
- 
-@@ -821,7 +820,7 @@ g2d_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer,
- 	gs->g2d_surface.base.right  = buffer->width;
- 	gs->g2d_surface.base.bottom = buffer->height;
- 	gs->g2d_surface.base.stride = alignedWidth;
--	gs->g2d_surface.base.width  = alignedWidth;
-+	gs->g2d_surface.base.width  = buffer->width;
- 	gs->g2d_surface.base.height = buffer->height;
- 	gs->g2d_surface.base.rot    = G2D_ROTATION_0;
- 	gs->g2d_surface.base.clrcolor = 0xFF400000;
-@@ -1079,7 +1078,7 @@ get_G2dSurface_from_screeninfo(struct fb_screeninfo *info, struct g2d_surfaceEx*
- 		g2dSurface->base.top  = 0;
- 		g2dSurface->base.right  = info->x_resolution;
- 		g2dSurface->base.bottom = info->y_resolution;
--		g2dSurface->base.stride = info->x_resolution;
-+		g2dSurface->base.stride = info->stride;
- 		g2dSurface->base.width  = info->x_resolution;
- 		g2dSurface->base.height = info->y_resolution;
- 		g2dSurface->base.format = info->pixel_format;
-@@ -1119,6 +1118,7 @@ fb_query_screen_info(struct g2d_output_state *output, int fd,
- 	info->y_resolution = varinfo->yres;
- 	info->physical = fixinfo->smem_start;
- 	info->buffer_length = fixinfo->smem_len;
-+	info->stride = fixinfo->line_length / (varinfo->bits_per_pixel >> 3);
- 	calculate_g2d_format(varinfo, &info->pixel_format);
- 
- 	if (info->pixel_format < 0) {
--- 
-1.9.1
-
diff --git a/recipes-graphics/wayland/weston/0015-MGS-2221-imx-171-Fix-weston-build-failed.patch b/recipes-graphics/wayland/weston/0015-MGS-2221-imx-171-Fix-weston-build-failed.patch
deleted file mode 100644
index 3f851ee..0000000
--- a/recipes-graphics/wayland/weston/0015-MGS-2221-imx-171-Fix-weston-build-failed.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-From 66a40759e44998edecf242bc100be0fcdd62937e Mon Sep 17 00:00:00 2001
-From: Yong Gan <yong.gan@nxp.com>
-Date: Thu, 1 Sep 2016 09:36:33 +0800
-Subject: [PATCH] MGS-2221 [#imx-171] Fix weston build failed
-
-Expose more variale to G2d compositor, because it is not easy to get the physical address
-in G2d compositor.
-
-Upstream Status: Inappropriate [i.MX specific]
-
-Date: Aug 31, 2016
-Signed-off-by: Yong Gan <yong.gan@nxp.com>
----
- src/g2d-renderer.c | 18 ++++++++++++++++--
- 1 file changed, 16 insertions(+), 2 deletions(-)
-
-diff --git a/src/g2d-renderer.c b/src/g2d-renderer.c
-index 30bf1a5..1009115 100644
---- a/src/g2d-renderer.c
-+++ b/src/g2d-renderer.c
-@@ -48,6 +48,20 @@
- #define BUFFER_DAMAGE_COUNT 2
- #define ALIGN_WIDTH(a) (((a) + 15) & ~15)
- 
-+struct wl_viv_buffer
-+{
-+    struct wl_resource *resource;
-+    gcoSURF  surface;
-+    gctINT32 width;
-+    gctINT32 height;
-+    gctINT32 format;
-+    gctUINT alignedWidth;
-+    gctUINT alignedHeight;
-+    gctUINT32 physical[3];
-+    gctUINT32 gpuBaseAddr;
-+    gceTILING tiling;
-+};
-+
- typedef struct _g2dRECT
- {
- 	int left;
-@@ -316,7 +330,7 @@ static void printG2dSurfaceInfo(struct g2d_surfaceEx* g2dSurface, const char* ms
- }
- 
- static void
--get_g2dSurface(gcsWL_VIV_BUFFER *buffer, struct g2d_surfaceEx *g2dSurface)
-+get_g2dSurface(struct wl_viv_buffer *buffer, struct g2d_surfaceEx *g2dSurface)
- {
- 	if(buffer->width < 0 || buffer->height < 0)
- 	{
-@@ -687,7 +701,7 @@ g2d_renderer_repaint_output(struct weston_output *output,
- static void
- g2d_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer)
- {
--	gcsWL_VIV_BUFFER *vivBuffer = wl_resource_get_user_data(buffer->resource);
-+	struct wl_viv_buffer *vivBuffer = wl_resource_get_user_data(buffer->resource);
- 	struct g2d_surface_state *gs = get_surface_state(es);
- 	buffer->width = vivBuffer->width;
- 	buffer->height = vivBuffer->height;
--- 
-1.9.1
-
diff --git a/recipes-graphics/wayland/weston/0017-MGS-2343-ccc-XWLD-T3DStressTest_Wayland-displays-abn.patch b/recipes-graphics/wayland/weston/0017-MGS-2343-ccc-XWLD-T3DStressTest_Wayland-displays-abn.patch
deleted file mode 100644
index d0b82aa..0000000
--- a/recipes-graphics/wayland/weston/0017-MGS-2343-ccc-XWLD-T3DStressTest_Wayland-displays-abn.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 0cc335a411127feb05e16cbf2803058b2db1b405 Mon Sep 17 00:00:00 2001
-From: Meng Mingming <mingming.meng@nxp.com>
-Date: Thu, 27 Oct 2016 17:00:24 +0800
-Subject: [PATCH 1/2] MGS-2343 [#ccc] XWLD: T3DStressTest_Wayland displays
- abnormally while using G2D compositor
-
-It need add g2d_finish after repaint_region and before copy to framebuffer.
-Because if using dual dpu cores, the tasks on each core will be executed
-sequently, but it can't ensure one task splited on dual cores can be finished
-synchronously by hardware.
-
-Upstream-Status: Inappropriate [i.MX specific]
-
-Date: Oct 27, 2016
-Signed-off-by: Meng Mingming <mingming.meng@nxp.com>
----
- src/g2d-renderer.c | 1 +
- 1 file changed, 1 insertion(+)
-
-Index: weston-1.11.0/src/g2d-renderer.c
-===================================================================
---- weston-1.11.0.orig/src/g2d-renderer.c	2017-01-12 14:58:11.923607788 -0600
-+++ weston-1.11.0/src/g2d-renderer.c	2017-01-12 18:08:33.328243476 -0600
-@@ -679,6 +679,8 @@
- 			     pixman_region32_t *output_damage)
- {
- 	struct g2d_output_state *go = get_output_state(output);
-+	struct weston_compositor *compositor = output->compositor;
-+	struct g2d_renderer *gr = get_renderer(compositor);
- 	int i;
- 
- 	use_output(output);
-@@ -691,6 +693,7 @@
- 			      &go->buffer_damage[go->current_buffer]);
- 
- 	repaint_views(output, output_damage);
-+	g2d_finish(gr->handle);
- 
- 	pixman_region32_copy(&output->previous_damage, output_damage);
- 	wl_signal_emit(&output->frame_signal, output);
diff --git a/recipes-graphics/wayland/weston/0018-MGS-2397-ccc-Enable-double-buffer-with-fb_pan_displa.patch b/recipes-graphics/wayland/weston/0018-MGS-2397-ccc-Enable-double-buffer-with-fb_pan_displa.patch
deleted file mode 100644
index 4ce1871..0000000
--- a/recipes-graphics/wayland/weston/0018-MGS-2397-ccc-Enable-double-buffer-with-fb_pan_displa.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From 270319565a07f7ceeb12fac1c267d0dd9ebf2d57 Mon Sep 17 00:00:00 2001
-From: Meng Mingming <mingming.meng@nxp.com>
-Date: Wed, 16 Nov 2016 15:05:51 +0800
-Subject: [PATCH 17/17] MGS-2397 [#ccc] Enable double buffer with
- fb_pan_display for weston compositor
-
-Refine offset calculation.
-
-Upstream-Status: Inappropriate [i.MX specific]
-
-Date: Nov 16, 2016
-Signed-off-by: Meng Mingming <mingming.meng@nxp.com>
----
- src/g2d-renderer.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/src/g2d-renderer.c b/src/g2d-renderer.c
-index 41c4d9e..c30aa62 100644
---- a/src/g2d-renderer.c
-+++ b/src/g2d-renderer.c
-@@ -78,6 +78,7 @@ struct fb_screeninfo {
- 	size_t buffer_length; /* length of frame buffer memory in bytes */
- 	size_t physical;
- 	size_t stride;
-+	size_t stride_bytes;
- 	enum g2d_format pixel_format; /* frame buffer pixel format */
- 	int fb_fd;
- };
-@@ -1136,6 +1137,7 @@ fb_query_screen_info(struct g2d_output_state *output, int fd,
- 	info->physical = fixinfo->smem_start;
- 	info->buffer_length = fixinfo->smem_len;
- 	info->stride = fixinfo->line_length / (varinfo->bits_per_pixel >> 3);
-+	info->stride_bytes = fixinfo->line_length;
- 	calculate_g2d_format(varinfo, &info->pixel_format);
- 
- 	if (info->pixel_format < 0) {
-@@ -1205,7 +1207,7 @@ g2d_renderer_surface_create(struct g2d_output_state *go, struct g2d_renderer *gr
- 		return -1;
- 	}
- 	go->renderSurf = zalloc(sizeof(struct g2d_surfaceEx) * go->nNumBuffers);
--	offset = go->fb_info.buffer_length/go->nNumBuffers;
-+	offset = go->fb_info.stride_bytes * go->fb_info.y_resolution;
- 	for(i = 0; i < go->nNumBuffers; i++)
- 	{
- 		get_G2dSurface_from_screeninfo(&go->fb_info, &go->renderSurf[i]);
--- 
-2.7.4
-
diff --git a/recipes-graphics/wayland/weston_%.bbappend b/recipes-graphics/wayland/weston_%.bbappend
index 26b12dc..74d2359 100644
--- a/recipes-graphics/wayland/weston_%.bbappend
+++ b/recipes-graphics/wayland/weston_%.bbappend
@@ -1,27 +1,16 @@
 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
 
 SRC_URI_append_imxgpu3d = " \
-    file://0002-MGS-1111-Add-GPU-VIV-suport-for-wayland-and-weston-1.patch \
-    file://0003-MGS-1192-xwld-g2d-compositor-dose-not-work.patch \
-    file://0004-MGS-1235-Fix-setenv-and-clear-environments.patch \
-    file://0005-MGS-1252-Fix-for-Qt5_CinematicExperience-will-meet-s.patch \
-    file://0006-MGS-1236-imx6qp-imx6dl-First-frame-distored-when-som.patch \
-    file://0007-MGS-1236-1-imx6qp-imx6dl-First-frame-distored-when-s.patch \
-    file://0009-MGS-1284-xwld-Re-implement-weston-2d-renderer-with-p.patch \
-    file://0010-MGS-1284-1-xwld-Re-implement-weston-2d-renderer-with.patch \
-    file://0011-MGS-1724-xwld-G2D-compositor-build-failed-in-slevk-b.patch \
-    file://0012-MGS-1783-xwld-Add-clone-mode-support-for-multi-displ.patch \
-    file://0013-MGS-1945-Use-common-API-to-support-G2d-compositor.patch    \
-    file://0014-MGS-1987-Get-stride-from-the-FB-buffe.patch                \
-    file://0015-MGS-2221-imx-171-Fix-weston-build-failed.patch             \
-    file://0016-Link-compositor-to-egl.patch                               \
-    file://0017-MGS-2343-ccc-XWLD-T3DStressTest_Wayland-displays-abn.patch \
-    file://0018-MGS-2397-ccc-Enable-double-buffer-with-fb_pan_displa.patch \
-    file://0019-MGS-1668-xwld-System-can-not-boot-up-to-desktop.patch      \
+    file://0001-MGS-2352-ccc-Add-GPU-VIV-support-for-weston-1.11.patch     \
+    file://0002-MGS-2521-ccc-Enable-g2d-renderer-for-weston-1.11.patch     \
+    file://0003-MGS-1783-xwld-Add-clone-mode-support-for-multi-displ.patch \
+    file://0004-MGS-1668-xwld-System-can-not-boot-up-to-desktop.patch      \
+    file://0005-MGS-1724-xwld-G2D-compositor-build-failed-in-slevk-b.patch \
+    file://0006-Link-compositor-to-egl.patch                               \
 "
 
 SRC_URI_append = " \
-    file://0020-xwayland-Fix-crash-when-run-with-no-input-device.patch     \
+    file://0007-xwayland-Fix-crash-when-run-with-no-input-device.patch     \
 "
 
 # The 'egl' configuration of weston requires gles support, and consideration
-- 
1.9.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-01-25 15:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-25 14:57 [PATCH] weston: Consolidate i.MX GPU patches Tom Hochstein

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.