Update to 5.0.0-3

Update for Day release

Bug: 148944691
Change-Id: I1a3d9195f944980acfd73b88488aacc3a00e0f83
diff --git a/debian/changelog b/debian/changelog
index 24715bd..2439bf3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+weston-mtk (5.0.0-3+mtk) mendel-day; urgency=medium
+
+  * Update to 5.0.0-3 for Day release
+  * Apply MTK patches
+
+ -- Coral Team <coral-support@google.com>  Fri, 07 Feb 2020 11:14:58 -0800
+
 weston-mtk (2.0.0-1) mendel-chef; urgency=medium
 
   * Initial release
diff --git a/debian/control b/debian/control
index d2a22cf..75c4778 100644
--- a/debian/control
+++ b/debian/control
@@ -1,17 +1,21 @@
 Source: weston-mtk
 Section: x11
 Priority: optional
-Maintainer: Coral <coral-support@google.com>
+Maintainer: Debian X Strike Force <debian-x@lists.debian.org>
+Uploaders:
+ Mike Gabriel <sunweaver@debian.org>,
+ Héctor Orón Martínez <zumbi@debian.org>,
+ Emilio Pozuelo Monfort <pochu@debian.org>,
 Build-Depends:
  debhelper (>= 10),
  quilt,
  pkg-config,
+ libdbus-1-dev,
  libpixman-1-dev (>= 0.25.2),
  libpng-dev,
  libjpeg-dev,
- libdrm2,
- libdrm-dev,
  libcolord-dev (>= 0.1.27),
+ liblcms2-dev,
  mesa-common-dev,
  libglu1-mesa-dev,
  libegl1-mesa-dev (>= 9.0~),
@@ -19,30 +23,38 @@
  libwayland-dev (>= 1.11.91),
  libxcb1-dev,
  libxcb-composite0-dev,
+ libxcb-shape0-dev,
  libxcb-xfixes0-dev,
  libxcb-xkb-dev,
  libx11-xcb-dev,
  libx11-dev,
  libudev-dev (>= 136),
- libgbm-dev (>= 10.2),
+ libdrm-dev (>= 2.4.83),
+ libgbm-dev (>= 17.2),
  libxkbcommon-dev (>= 0.3.0),
  libcairo2-dev (>= 1.10.0),
  libpango1.0-dev,
  libgdk-pixbuf2.0-dev,
  libxcursor-dev,
- libmtdev-dev,
  libpam0g-dev,
  libvpx-dev,
  libsystemd-dev,
  libinput-dev (>= 0.8.0),
- wayland-protocols (>= 1.7),
-Standards-Version: 4.1.1
+ wayland-protocols (>= 1.13),
+Standards-Version: 3.9.8
+Homepage: http://wayland.freedesktop.org/
+Vcs-Git: https://salsa.debian.org/xorg-team/wayland/weston.git
+Vcs-Browser: https://salsa.debian.org/xorg-team/wayland/weston
 
 Package: weston-mtk
 Section: libdevel
 Architecture: any
-Priority: extra
+Priority: optional
 Depends:
+ adduser,
+ libegl1-mesa (>= 8.0-2) | libegl1-x11,
+ libwayland-egl1-mesa (>= 10.1.0-2) | libwayland-egl1,
+ libgles2-mesa (>= 8.0-2) | libgles2,
  libinput10,
  libxcb-shape0,
  libxcb-composite0,
diff --git a/debian/copyright b/debian/copyright
index ff62785..6f9276e 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,43 +1,466 @@
-Upstream-Name: weston-mtk
-Upstream-Contact: wayland-devel@lists.freedesktop.org
-Source: https://wayland.freedesktop.org/releases/
-
-Files: debian/*
-Copyright: © 2016 Héctor Orón Martínez <zumbi@debian.org>
-License: Expat
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Source: http://wayland.freedesktop.org/
 
 Files: *
-Copyright: © 2008-2013 Kristian Høgsberg
-		   © 2010-2013 Intel Corporation
-		   © 2013      Rafael Antognolli
-		   © 2013      Jasper St. Pierre
-		   © 2014      Jonas Ådahl
-		   © 2014      Jason Ekstrand
-		   © 2014-2015 Collabora, Ltd.
-		   © 2015      Red Hat Inc.
-License: Expat
+Copyright: © 2016 Armin Krezović
+           © 2010-2012 Benjamin Franzke
+           © 2016 Benoit Gschwind
+           © 2013 BMW Car IT GmbH
+           © 2009 Chris Wilson
+           © 2011-2018 Collabora, Ltd.
+           © 2013 David Herrmann
+           © 2013-2016 DENSO CORPORATION
+           © 2015-2018 General Electric Company
+           © 2015-2016 Giulio Camuffo
+           © 2013 Hardening
+           © 2009-2013 Intel Corporation
+           © 2013-2014 Jason Ekstrand
+           © 2015 Jasper St. Pierre
+           © 2012 John Kåre Alsaker
+           © 2012-2013 Jonas Ådahl
+           © 1988-2004 Keith Packard and Bart Massey.
+           © 2008-2012 Kristian Høgsberg
+           © 2012 Martin Minarik
+           © 2016 NVIDIA Corporation
+           © 2012 Openismus GmbH
+           © 2014 Pekka Paalanen
+           © 2012 Philipp Brüschweiler
+           © 2013 Philip Withnall
+           © 2016 Quentin "Sardem FF7" Glidic
+           © 2012-2013 Raspberry Pi Foundation
+           © 2010-2015 Red Hat, Inc.
+           © 2013 Richard Hughes
+           © 2012 Rob Clark
+           © 2013 Sam Spilsbury
+           © 2015-2016 Samsung Electronics Co., Ltd
+           © 2012 Scott Moreau
+           © 2011 Tim Wiederhake
+           © 2008 Tungsten Graphics, Inc
+           © 2013 Vasily Khoruzhick
+License: X11
+ Permission to use, copy, modify, distribute, and sell this software and
+ its documentation for any purpose is hereby granted without fee, provided
+ that the above copyright notice appear in all copies and that both that
+ copyright notice and this permission notice appear in supporting
+ documentation, and that the name of the copyright holders not be used in
+ advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission.  The copyright holders make
+ no representations about the suitability of this software for any
+ purpose.  It is provided "as is" without express or implied warranty.
+ .
+ THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-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:
+Files: data/*
+Copyright: © 2007-2010 Novell, Inc.
+License: CC-BY-SA-3.0
 
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
+Files: data/terminal.png
+Copyright: @ 2002-2008 GNOME Project
+License: CC-BY-SA-3.0
 
-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.
+Files: src/hash.*
+Copyright: © 2009 Intel Corporation
+           © 1988-2004 Keith Packard and Bart Massey.
+License: MIT
+ 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.
+ .
+ Except as contained in this notice, the names of the authors
+ or their institutions shall not be used in advertising or
+ otherwise to promote the sale, use or other dealings in this
+ Software without prior written authorization from the
+ authors.
+ .
+ Authors:
+    Eric Anholt <eric@anholt.net>
+    Keith Packard <keithp@keithp.com>
 
----
 
-The above is the version of the MIT "Expat" License used by X.org:
-
-    http://cgit.freedesktop.org/xorg/xserver/tree/COPYING
+License: CC-BY-SA-3.0
+ THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS
+ CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS
+ PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE
+ WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS
+ PROHIBITED.
+ .
+ BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND
+ AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS
+ LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU
+ THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH
+ TERMS AND CONDITIONS.
+ .
+ .
+ 1. Definitions
+ .
+ "Adaptation" means a work based upon the Work, or upon the Work and
+ other pre-existing works, such as a translation, adaptation,
+ derivative work, arrangement of music or other alterations of a
+ literary or artistic work, or phonogram or performance and includes
+ cinematographic adaptations or any other form in which the Work may be
+ recast, transformed, or adapted including in any form recognizably
+ derived from the original, except that a work that constitutes a
+ Collection will not be considered an Adaptation for the purpose of
+ this License. For the avoidance of doubt, where the Work is a musical
+ work, performance or phonogram, the synchronization of the Work in
+ timed-relation with a moving image ("synching") will be considered an
+ Adaptation for the purpose of this License.
+ .
+ "Collection" means a collection of literary or artistic works, such as
+ encyclopedias and anthologies, or performances, phonograms or
+ broadcasts, or other works or subject matter other than works listed
+ in Section 1(f) below, which, by reason of the selection and
+ arrangement of their contents, constitute intellectual creations, in
+ which the Work is included in its entirety in unmodified form along
+ with one or more other contributions, each constituting separate and
+ independent works in themselves, which together are assembled into a
+ collective whole. A work that constitutes a Collection will not be
+ considered an Adaptation (as defined below) for the purposes of this
+ License.
+ .
+ "Creative Commons Compatible License" means a license that is listed
+ at http://creativecommons.org/compatiblelicenses that has been
+ approved by Creative Commons as being essentially equivalent to this
+ License, including, at a minimum, because that license: (i) contains
+ terms that have the same purpose, meaning and effect as the License
+ Elements of this License; and, (ii) explicitly permits the relicensing
+ of adaptations of works made available under that license under this
+ License or a Creative Commons jurisdiction license with the same
+ License Elements as this License.
+ .
+ "Distribute" means to make available to the public the original and
+ copies of the Work or Adaptation, as appropriate, through sale or
+ other transfer of ownership.
+ .
+ "License Elements" means the following high-level license attributes
+ as selected by Licensor and indicated in the title of this License:
+ Attribution, ShareAlike.
+ .
+ "Licensor" means the individual, individuals, entity or entities that
+ offer(s) the Work under the terms of this License.
+ .
+ "Original Author" means, in the case of a literary or artistic work,
+ the individual, individuals, entity or entities who created the Work
+ or if no individual or entity can be identified, the publisher; and in
+ addition (i) in the case of a performance the actors, singers,
+ musicians, dancers, and other persons who act, sing, deliver, declaim,
+ play in, interpret or otherwise perform literary or artistic works or
+ expressions of folklore; (ii) in the case of a phonogram the producer
+ being the person or legal entity who first fixes the sounds of a
+ performance or other sounds; and, (iii) in the case of broadcasts, the
+ organization that transmits the broadcast.
+ .
+ "Work" means the literary and/or artistic work offered under the terms
+ of this License including without limitation any production in the
+ literary, scientific and artistic domain, whatever may be the mode or
+ form of its expression including digital form, such as a book,
+ pamphlet and other writing; a lecture, address, sermon or other work
+ of the same nature; a dramatic or dramatico-musical work; a
+ choreographic work or entertainment in dumb show; a musical
+ composition with or without words; a cinematographic work to which are
+ assimilated works expressed by a process analogous to cinematography;
+ a work of drawing, painting, architecture, sculpture, engraving or
+ lithography; a photographic work to which are assimilated works
+ expressed by a process analogous to photography; a work of applied
+ art; an illustration, map, plan, sketch or three-dimensional work
+ relative to geography, topography, architecture or science; a
+ performance; a broadcast; a phonogram; a compilation of data to the
+ extent it is protected as a copyrightable work; or a work performed by
+ a variety or circus performer to the extent it is not otherwise
+ considered a literary or artistic work.
+ .
+ "You" means an individual or entity exercising rights under this
+ License who has not previously violated the terms of this License with
+ respect to the Work, or who has received express permission from the
+ Licensor to exercise rights under this License despite a previous
+ violation.
+ .
+ "Publicly Perform" means to perform public recitations of the Work and
+ to communicate to the public those public recitations, by any means or
+ process, including by wire or wireless means or public digital
+ performances; to make available to the public Works in such a way that
+ members of the public may access these Works from a place and at a
+ place individually chosen by them; to perform the Work to the public
+ by any means or process and the communication to the public of the
+ performances of the Work, including by public digital performance; to
+ broadcast and rebroadcast the Work by any means including signs,
+ sounds or images.
+ .
+ "Reproduce" means to make copies of the Work by any means including
+ without limitation by sound or visual recordings and the right of
+ fixation and reproducing fixations of the Work, including storage of a
+ protected performance or phonogram in digital form or other electronic
+ medium.
+ .
+ .
+ 2. Fair Dealing Rights. Nothing in this License is intended to reduce,
+ limit, or restrict any uses free from copyright or rights arising from
+ limitations or exceptions that are provided for in connection with the
+ copyright protection under copyright law or other applicable laws.
+ .
+ .
+ 3. License Grant. Subject to the terms and conditions of this License,
+ Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
+ perpetual (for the duration of the applicable copyright) license to
+ exercise the rights in the Work as stated below:
+ .
+  - to Reproduce the Work, to incorporate the Work into one or more
+    Collections, and to Reproduce the Work as incorporated in the
+    Collections;
+ .
+  - to create and Reproduce Adaptations provided that any such
+    Adaptation, including any translation in any medium, takes
+    reasonable steps to clearly label, demarcate or otherwise identify
+    that changes were made to the original Work. For example, a
+    translation could be marked "The original work was translated from
+    English to Spanish," or a modification could indicate "The original
+    work has been modified.";
+ .
+  - to Distribute and Publicly Perform the Work including as
+    incorporated in Collections; and,
+ .
+  - to Distribute and Publicly Perform Adaptations.
+ .
+  - For the avoidance of doubt:
+     - Non-waivable Compulsory License Schemes. In those jurisdictions
+       in which the right to collect royalties through any statutory or
+       compulsory licensing scheme cannot be waived, the Licensor
+       reserves the exclusive right to collect such royalties for any
+       exercise by You of the rights granted under this License;
+     - Waivable Compulsory License Schemes. In those jurisdictions in
+       which the right to collect royalties through any statutory or
+       compulsory licensing scheme can be waived, the Licensor waives
+       the exclusive right to collect such royalties for any exercise
+       by You of the rights granted under this License; and,
+     - Voluntary License Schemes. The Licensor waives the right to
+       collect royalties, whether individually or, in the event that
+       the Licensor is a member of a collecting society that
+       administers voluntary licensing schemes, via that society, from
+       any exercise by You of the rights granted under this License.
+ .
+ The above rights may be exercised in all media and formats whether now
+ known or hereafter devised. The above rights include the right to make
+ such modifications as are technically necessary to exercise the rights
+ in other media and formats. Subject to Section 8(f), all rights not
+ expressly granted by Licensor are hereby reserved.
+ .
+ .
+ 4. Restrictions. The license granted in Section 3 above is expressly
+ made subject to and limited by the following restrictions:
+ .
+  - You may Distribute or Publicly Perform the Work only under the
+    terms of this License. You must include a copy of, or the Uniform
+    Resource Identifier (URI) for, this License with every copy of the
+    Work You Distribute or Publicly Perform. You may not offer or
+    impose any terms on the Work that restrict the terms of this
+    License or the ability of the recipient of the Work to exercise the
+    rights granted to that recipient under the terms of the
+    License. You may not sublicense the Work. You must keep intact all
+    notices that refer to this License and to the disclaimer of
+    warranties with every copy of the Work You Distribute or Publicly
+    Perform. When You Distribute or Publicly Perform the Work, You may
+    not impose any effective technological measures on the Work that
+    restrict the ability of a recipient of the Work from You to
+    exercise the rights granted to that recipient under the terms of
+    the License. This Section 4(a) applies to the Work as incorporated
+    in a Collection, but this does not require the Collection apart
+    from the Work itself to be made subject to the terms of this
+    License. If You create a Collection, upon notice from any Licensor
+    You must, to the extent practicable, remove from the Collection any
+    credit as required by Section 4(c), as requested. If You create an
+    Adaptation, upon notice from any Licensor You must, to the extent
+    practicable, remove from the Adaptation any credit as required by
+    Section 4(c), as requested.
+ .
+  - You may Distribute or Publicly Perform an Adaptation only under the
+    terms of: (i) this License; (ii) a later version of this License
+    with the same License Elements as this License; (iii) a Creative
+    Commons jurisdiction license (either this or a later license
+    version) that contains the same License Elements as this License
+    (e.g., Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons
+    Compatible License. If you license the Adaptation under one of the
+    licenses mentioned in (iv), you must comply with the terms of that
+    license. If you license the Adaptation under the terms of any of
+    the licenses mentioned in (i), (ii) or (iii) (the "Applicable
+    License"), you must comply with the terms of the Applicable License
+    generally and the following provisions: (I) You must include a copy
+    of, or the URI for, the Applicable License with every copy of each
+    Adaptation You Distribute or Publicly Perform; (II) You may not
+    offer or impose any terms on the Adaptation that restrict the terms
+    of the Applicable License or the ability of the recipient of the
+    Adaptation to exercise the rights granted to that recipient under
+    the terms of the Applicable License; (III) You must keep intact all
+    notices that refer to the Applicable License and to the disclaimer
+    of warranties with every copy of the Work as included in the
+    Adaptation You Distribute or Publicly Perform; (IV) when You
+    Distribute or Publicly Perform the Adaptation, You may not impose
+    any effective technological measures on the Adaptation that
+    restrict the ability of a recipient of the Adaptation from You to
+    exercise the rights granted to that recipient under the terms of
+    the Applicable License. This Section 4(b) applies to the Adaptation
+    as incorporated in a Collection, but this does not require the
+    Collection apart from the Adaptation itself to be made subject to
+    the terms of the Applicable License.
+ .
+  - If You Distribute, or Publicly Perform the Work or any Adaptations
+    or Collections, You must, unless a request has been made pursuant
+    to Section 4(a), keep intact all copyright notices for the Work and
+    provide, reasonable to the medium or means You are utilizing: (i)
+    the name of the Original Author (or pseudonym, if applicable) if
+    supplied, and/or if the Original Author and/or Licensor designate
+    another party or parties (e.g., a sponsor institute, publishing
+    entity, journal) for attribution ("Attribution Parties") in
+    Licensor's copyright notice, terms of service or by other
+    reasonable means, the name of such party or parties; (ii) the title
+    of the Work if supplied; (iii) to the extent reasonably
+    practicable, the URI, if any, that Licensor specifies to be
+    associated with the Work, unless such URI does not refer to the
+    copyright notice or licensing information for the Work; and (iv) ,
+    consistent with Ssection 3(b), in the case of an Adaptation, a
+    credit identifying the use of the Work in the Adaptation (e.g.,
+    "French translation of the Work by Original Author," or "Screenplay
+    based on original Work by Original Author"). The credit required by
+    this Section 4(c) may be implemented in any reasonable manner;
+    provided, however, that in the case of a Adaptation or Collection,
+    at a minimum such credit will appear, if a credit for all
+    contributing authors of the Adaptation or Collection appears, then
+    as part of these credits and in a manner at least as prominent as
+    the credits for the other contributing authors. For the avoidance
+    of doubt, You may only use the credit required by this Section for
+    the purpose of attribution in the manner set out above and, by
+    exercising Your rights under this License, You may not implicitly
+    or explicitly assert or imply any connection with, sponsorship or
+    endorsement by the Original Author, Licensor and/or Attribution
+    Parties, as appropriate, of You or Your use of the Work, without
+    the separate, express prior written permission of the Original
+    Author, Licensor and/or Attribution Parties.
+ .
+  - Except as otherwise agreed in writing by the Licensor or as may be
+    otherwise permitted by applicable law, if You Reproduce, Distribute
+    or Publicly Perform the Work either by itself or as part of any
+    Adaptations or Collections, You must not distort, mutilate, modify
+    or take other derogatory action in relation to the Work which would
+    be prejudicial to the Original Author's honor or
+    reputation. Licensor agrees that in those jurisdictions
+    (e.g. Japan), in which any exercise of the right granted in Section
+    3(b) of this License (the right to make Adaptations) would be
+    deemed to be a distortion, mutilation, modification or other
+    derogatory action prejudicial to the Original Author's honor and
+    reputation, the Licensor will waive or not assert, as appropriate,
+    this Section, to the fullest extent permitted by the applicable
+    national law, to enable You to reasonably exercise Your right under
+    Section 3(b) of this License (right to make Adaptations) but not
+    otherwise.
+ .
+ .
+ 5. Representations, Warranties and Disclaimer
+ .
+ UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING,
+ LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR
+ WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED,
+ STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF
+ TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE,
+ NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY,
+ OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT
+ DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED
+ WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
+ .
+ .
+ 6. Limitation on Liability.
+ .
+ EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL
+ LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL,
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT
+ OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ .
+ .
+ 7. Termination
+ .
+  - This License and the rights granted hereunder will terminate
+    automatically upon any breach by You of the terms of this
+    License. Individuals or entities who have received Adaptations or
+    Collections from You under this License, however, will not have
+    their licenses terminated provided such individuals or entities
+    remain in full compliance with those licenses. Sections 1, 2, 5, 6,
+    7, and 8 will survive any termination of this License.
+ .
+  - Subject to the above terms and conditions, the license granted here
+    is perpetual (for the duration of the applicable copyright in the
+    Work). Notwithstanding the above, Licensor reserves the right to
+    release the Work under different license terms or to stop
+    distributing the Work at any time; provided, however that any such
+    election will not serve to withdraw this License (or any other
+    license that has been, or is required to be, granted under the
+    terms of this License), and this License will continue in full
+    force and effect unless terminated as stated above.
+ .
+ .
+ 8. Miscellaneous
+ .
+  - Each time You Distribute or Publicly Perform the Work or a
+    Collection, the Licensor offers to the recipient a license to the
+    Work on the same terms and conditions as the license granted to You
+    under this License.
+ .
+  - Each time You Distribute or Publicly Perform an Adaptation,
+    Licensor offers to the recipient a license to the original Work on
+    the same terms and conditions as the license granted to You under
+    this License.
+ .
+  - If any provision of this License is invalid or unenforceable under
+    applicable law, it shall not affect the validity or enforceability
+    of the remainder of the terms of this License, and without further
+    action by the parties to this agreement, such provision shall be
+    reformed to the minimum extent necessary to make such provision
+    valid and enforceable.
+ .
+  - No term or provision of this License shall be deemed waived and no
+    breach consented to unless such waiver or consent shall be in
+    writing and signed by the party to be charged with such waiver or
+    consent.
+ .
+  - This License constitutes the entire agreement between the parties
+    with respect to the Work licensed here. There are no
+    understandings, agreements or representations with respect to the
+    Work not specified here. Licensor shall not be bound by any
+    additional provisions that may appear in any communication from
+    You. This License may not be modified without the mutual written
+    agreement of the Licensor and You.
+ .
+  - The rights granted under, and the subject matter referenced, in
+    this License were drafted utilizing the terminology of the Berne
+    Convention for the Protection of Literary and Artistic Works (as
+    amended on September 28, 1979), the Rome Convention of 1961, the
+    WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms
+    Treaty of 1996 and the Universal Copyright Convention (as revised
+    on July 24, 1971). These rights and subject matter take effect in
+    the relevant jurisdiction in which the License terms are sought to
+    be enforced according to the corresponding provisions of the
+    implementation of those treaty provisions in the applicable
+    national law. If the standard suite of rights granted under
+    applicable copyright law includes additional rights not granted
+    under this License, such additional rights are deemed to be
+    included in the License; this License is not intended to restrict
+    the license of any rights under applicable law.
diff --git a/debian/lintian-overrides b/debian/lintian-overrides
index 39364ff..d838026 100644
--- a/debian/lintian-overrides
+++ b/debian/lintian-overrides
@@ -1,5 +1,6 @@
-weston-mtk: package-name-doesnt-match-sonames libweston-2-0 libweston-desktop-2-0
+weston-mtk: package-name-doesnt-match-sonames libweston-5-0 libweston-desktop-5-0
 weston-mtk: non-empty-dependency_libs-in-la-file *
 weston-mtk: non-dev-pkg-with-shlib-symlink *
 weston-mtk: shlib-in-multi-arch-foreign-package *
+weston-mtk: multiarch-foreign-pkgconfig *
 
diff --git a/debian/patches/0001-PATCH-1-9-hmi-controller-use-output_w-h-instead-of-c.patch b/debian/patches/0001-PATCH-1-9-hmi-controller-use-output_w-h-instead-of-c.patch
new file mode 100644
index 0000000..1a241ee
--- /dev/null
+++ b/debian/patches/0001-PATCH-1-9-hmi-controller-use-output_w-h-instead-of-c.patch
@@ -0,0 +1,55 @@
+From c9120f0c15f901f507c0c626b7225f4e93fca700 Mon Sep 17 00:00:00 2001
+From: Qian Hu <Qian.Hu@mediatek.com>
+Date: Tue, 24 Sep 2019 11:21:23 +0800
+Subject: [PATCH 1/8] [[PATCH 1/9] hmi-controller: use output_w/h instead of
+ current_mode_w/h
+
+make use of output->w/h instead of output->current_mode->w/h,
+	 output->w/h have involve factor of transform and scale
+
+Signed-off-by: Qian Hu <Qian.Hu@mediatek.com>
+---
+ ivi-shell/hmi-controller.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
+index a0e49ba..c4f106d 100644
+--- a/ivi-shell/hmi-controller.c
++++ b/ivi-shell/hmi-controller.c
+@@ -804,8 +804,8 @@ hmi_controller_create(struct weston_compositor *ec)
+ 		base_layer = MEM_ALLOC(1 * sizeof(struct hmi_controller_layer));
+ 		base_layer->x = 0;
+ 		base_layer->y = 0;
+-		base_layer->width = output->current_mode->width;
+-		base_layer->height = output->current_mode->height;
++		base_layer->width = output->width;
++		base_layer->height = output->height;
+ 		base_layer->id_layer =
+ 			hmi_ctrl->hmi_setting->base_layer_id +
+ 						(i * hmi_ctrl->hmi_setting->base_layer_id_offset);
+@@ -824,8 +824,8 @@ hmi_controller_create(struct weston_compositor *ec)
+ 		application_layer = MEM_ALLOC(1 * sizeof(struct hmi_controller_layer));
+ 		application_layer->x = 0;
+ 		application_layer->y = 0;
+-		application_layer->width = output->current_mode->width;
+-		application_layer->height = output->current_mode->height - panel_height;
++		application_layer->width = output->width;
++		application_layer->height = output->height - panel_height;
+ 		application_layer->id_layer =
+ 			hmi_ctrl->hmi_setting->application_layer_id +
+ 						(i * hmi_ctrl->hmi_setting->base_layer_id_offset);
+@@ -841,9 +841,9 @@ hmi_controller_create(struct weston_compositor *ec)
+ 	hmi_ctrl->workspace_background_layer.x = 0;
+ 	hmi_ctrl->workspace_background_layer.y = 0;
+ 	hmi_ctrl->workspace_background_layer.width =
+-		output->current_mode->width;
++		output->width;
+ 	hmi_ctrl->workspace_background_layer.height =
+-		output->current_mode->height - panel_height;
++		output->height - panel_height;
+ 
+ 	hmi_ctrl->workspace_background_layer.id_layer =
+ 		hmi_ctrl->hmi_setting->workspace_background_layer_id;
+-- 
+2.6.4
+
diff --git a/debian/patches/0001-add-switch_config.patch b/debian/patches/0001-add-switch_config.patch
new file mode 100644
index 0000000..3d011d6
--- /dev/null
+++ b/debian/patches/0001-add-switch_config.patch
@@ -0,0 +1,31 @@
+From 08f1aa62f0a5faa0dc8aaf082264b77d37f0610d Mon Sep 17 00:00:00 2001
+From: Qian Hu <Qian.Hu@mediatek.com>
+Date: Wed, 25 Sep 2019 19:14:50 +0800
+Subject: [PATCH] add switch_config
+
+Signed-off-by: Qian Hu <Qian.Hu@mediatek.com>
+---
+ compositor/main.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/compositor/main.c b/compositor/main.c
+index 21c501c..64e4e30 100644
+--- a/compositor/main.c
++++ b/compositor/main.c
+@@ -2499,6 +2499,13 @@ int main(int argc, char *argv[])
+ 		goto out;
+ 	}
+ 
++
++	if (config_switch_global_create(wet.compositor) < 0) {
++	    weston_log("fatal: failed to config_switch_global_create\n");
++	    goto out;
++	}
++
++	
+ 	weston_compositor_flush_heads_changed(wet.compositor);
+ 	if (wet.init_failed)
+ 		goto out;
+-- 
+2.6.4
+
diff --git a/debian/patches/0001-mtk-make-error-portable.patch b/debian/patches/0001-mtk-make-error-portable.patch
new file mode 100644
index 0000000..a9ddd47
--- /dev/null
+++ b/debian/patches/0001-mtk-make-error-portable.patch
@@ -0,0 +1,58 @@
+diff --git a/configure.ac b/configure.ac
+index 50f8e013..d61ca8f4 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -109,6 +109,8 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,[],
+ 	      [[#include <time.h>]])
+ AC_CHECK_HEADERS([execinfo.h])
+ 
++AC_CHECK_HEADERS([error.h])
++
+ AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
+ 
+ # check for libdrm as a build-time dependency only
+diff --git a/libweston/weston-error.h b/libweston/weston-error.h
+new file mode 100644
+index 0000000..2089d02
+--- /dev/null
++++ b/libweston/weston-error.h
+@@ -0,0 +1,19 @@
++#ifndef _WESTON_ERROR_H
++#define _WESTON_ERROR_H
++
++#if defined(HAVE_ERROR_H)
++#include <error.h>
++#else
++#include <err.h>
++#include <string.h>
++#define _weston_error(S, E, F, ...) do { \
++	if (E) \
++		err(S, F ": %s", ##__VA_ARGS__, strerror(E)); \
++	else \
++		err(S, F, ##__VA_ARGS__); \
++} while(0)
++
++#define error _weston_error
++#endif
++
++#endif
+diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c
+index bf73e0d6..90644394 100644
+--- a/libweston/weston-launch.c
++++ b/libweston/weston-launch.c
+@@ -33,7 +33,6 @@
+ #include <poll.h>
+ #include <errno.h>
+ 
+-#include <error.h>
+ #include <getopt.h>
+ 
+ #include <sys/types.h>
+@@ -59,6 +58,7 @@
+ #endif
+ 
+ #include "weston-launch.h"
++#include "weston-error.h"
+ 
+ #define DRM_MAJOR 226
+ 
diff --git a/debian/patches/0002-PATCH-2-9-libinput-fix-issue-for-touch_event-cause-w.patch b/debian/patches/0002-PATCH-2-9-libinput-fix-issue-for-touch_event-cause-w.patch
new file mode 100644
index 0000000..cf86044
--- /dev/null
+++ b/debian/patches/0002-PATCH-2-9-libinput-fix-issue-for-touch_event-cause-w.patch
@@ -0,0 +1,40 @@
+From 4ba125216b900fc57c63a915fb194c48f4b516c4 Mon Sep 17 00:00:00 2001
+From: Qian Hu <Qian.Hu@mediatek.com>
+Date: Tue, 24 Sep 2019 11:26:20 +0800
+Subject: [PATCH 2/8] [PATCH 2/9] libinput: fix issue for touch_event cause
+ weston crash
+
+1.fix touch_event cause weston crash
+
+Signed-off-by: Qian Hu <Qian.Hu@mediatek.com>
+---
+ libweston/libinput-device.c | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/libweston/libinput-device.c b/libweston/libinput-device.c
+index e25df14..18a3032 100644
+--- a/libweston/libinput-device.c
++++ b/libweston/libinput-device.c
+@@ -436,6 +436,19 @@ handle_touch_with_coords(struct libinput_device *libinput_device,
+ 	x =  libinput_event_touch_get_x_transformed(touch_event, width);
+ 	y =  libinput_event_touch_get_y_transformed(touch_event, height);
+ 
++	if (x == 0)
++		x = x + 1;
++
++	if (y == 0)
++		y = y + 1;
++
++	if (x == wl_fixed_from_int(width))
++		x = x - 1;
++
++	if (y == wl_fixed_from_int(height))
++		y = y - 1;
++
++
+ 	weston_output_transform_coordinate(device->output,
+ 					   x, y, &x, &y);
+ 
+-- 
+2.6.4
+
diff --git a/debian/patches/0003-PATCH-3-9-compose-engine-turn-to-pixman-if-gl-init-f.patch b/debian/patches/0003-PATCH-3-9-compose-engine-turn-to-pixman-if-gl-init-f.patch
new file mode 100644
index 0000000..13d3edb
--- /dev/null
+++ b/debian/patches/0003-PATCH-3-9-compose-engine-turn-to-pixman-if-gl-init-f.patch
@@ -0,0 +1,43 @@
+From 621569253b34788e096adda8132010d0a17d0844 Mon Sep 17 00:00:00 2001
+From: Qian Hu <Qian.Hu@mediatek.com>
+Date: Tue, 24 Sep 2019 11:31:09 +0800
+Subject: [PATCH 3/8] [PATCH 3/9] compose-engine: turn to pixman if gl init
+ fail
+
+if init_gl fail then turn to pixman to compose buffer
+
+Signed-off-by: Qian Hu <Qian.Hu@mediatek.com>
+---
+ libweston/compositor-drm.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
+index 3891176..ef38a64 100644
+--- a/libweston/compositor-drm.c
++++ b/libweston/compositor-drm.c
+@@ -3921,6 +3921,7 @@ init_egl(struct drm_backend *b)
+ 
+ 	if (drm_backend_create_gl_renderer(b) < 0) {
+ 		gbm_device_destroy(b->gbm);
++		b->gbm = NULL;
+ 		return -1;
+ 	}
+ 
+@@ -6766,8 +6767,12 @@ drm_backend_create(struct weston_compositor *compositor,
+ 		}
+ 	} else {
+ 		if (init_egl(b) < 0) {
+-			weston_log("failed to initialize egl\n");
+-			goto err_udev_dev;
++			weston_log("failed to initialize egl, use pixman\n");
++			if (init_pixman(b) < 0) {
++				weston_log("failed to initialize pixman renderer\n");
++				goto err_udev_dev;
++			}
++			b->use_pixman = 1;
+ 		}
+ 	}
+ 
+-- 
+2.6.4
+
diff --git a/debian/patches/0004-PATCH-4-9-weston-do-not-check-master-fd-for-DRM-driv.patch b/debian/patches/0004-PATCH-4-9-weston-do-not-check-master-fd-for-DRM-driv.patch
new file mode 100644
index 0000000..22093bb
--- /dev/null
+++ b/debian/patches/0004-PATCH-4-9-weston-do-not-check-master-fd-for-DRM-driv.patch
@@ -0,0 +1,31 @@
+From 264cd761cc03e2dd85e57a1162db73c4beec0d07 Mon Sep 17 00:00:00 2001
+From: Qian Hu <Qian.Hu@mediatek.com>
+Date: Tue, 24 Sep 2019 11:33:56 +0800
+Subject: [PATCH 4/8] [PATCH 4/9] weston: do not check master fd for DRM driver
+
+give access to other module to use drm.
+
+Signed-off-by: Qian Hu <Qian.Hu@mediatek.com>
+---
+ libweston/launcher-direct.c | 5 -----
+ 1 file changed, 5 deletions(-)
+
+diff --git a/libweston/launcher-direct.c b/libweston/launcher-direct.c
+index e0ce6d6..fe76f51 100644
+--- a/libweston/launcher-direct.c
++++ b/libweston/launcher-direct.c
+@@ -231,11 +231,6 @@ launcher_direct_open(struct weston_launcher *launcher_base, const char *path, in
+ 
+ 	if (major(s.st_rdev) == DRM_MAJOR) {
+ 		launcher->drm_fd = fd;
+-		if (!is_drm_master(fd)) {
+-			weston_log("drm fd not master\n");
+-			close(fd);
+-			return -1;
+-		}
+ 	}
+ 
+ 	return fd;
+-- 
+2.6.4
+
diff --git a/debian/patches/0005-PATCH-5-9-weston-install-client-protocol-to-sysroot-.patch b/debian/patches/0005-PATCH-5-9-weston-install-client-protocol-to-sysroot-.patch
new file mode 100644
index 0000000..4fd683d
--- /dev/null
+++ b/debian/patches/0005-PATCH-5-9-weston-install-client-protocol-to-sysroot-.patch
@@ -0,0 +1,31 @@
+From 21f5f1844e02a50a8b1c2f9ddb39d01b34c92b0a Mon Sep 17 00:00:00 2001
+From: Qian Hu <Qian.Hu@mediatek.com>
+Date: Tue, 24 Sep 2019 11:37:19 +0800
+Subject: [PATCH 5/8] [PATCH 5/9] weston: install client-protocol to sysroot
+ for other
+
+install *-protocol.c and *-client-protocol.h to sysroot.
+
+Signed-off-by: Qian Hu <Qian.Hu@mediatek.com>
+---
+ Makefile.am | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 83bb253..769e103 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -292,7 +292,9 @@ libwestoninclude_HEADERS =			\
+ 	libweston/timeline-object.h		\
+ 	shared/matrix.h				\
+ 	shared/config-parser.h			\
+-	shared/zalloc.h
++	shared/zalloc.h			\
++	protocol/*-protocol.c			\
++	protocol/*-client-protocol.h
+ 
+ libwestoninclude_HEADERS +=			\
+ 	libweston-desktop/libweston-desktop.h
+-- 
+2.6.4
+
diff --git a/debian/patches/0006-PATCH-7-9-weston-screen-shot-add-screen-shot.patch b/debian/patches/0006-PATCH-7-9-weston-screen-shot-add-screen-shot.patch
new file mode 100644
index 0000000..912fb87
--- /dev/null
+++ b/debian/patches/0006-PATCH-7-9-weston-screen-shot-add-screen-shot.patch
@@ -0,0 +1,602 @@
+From 79d48c68d79e7436a045bb875e18f7e8c6829392 Mon Sep 17 00:00:00 2001
+From: Qian Hu <Qian.Hu@mediatek.com>
+Date: Tue, 24 Sep 2019 14:25:47 +0800
+Subject: [PATCH 6/8] [PATCH 7/9] weston-screen-shot: add screen shot
+
+add screen shot
+
+Signed-off-by: Qian Hu <Qian.Hu@mediatek.com>
+---
+ Makefile.am                          |  26 +++-
+ clients/simple-screenshooter-mtk.c   | 259 +++++++++++++++++++++++++++++++++++
+ libweston/compositor.c               |   3 +
+ libweston/compositor.h               |   3 +
+ libweston/pixel-formats.c            |   2 +
+ libweston/weston-screenshooter-mtk.c | 129 +++++++++++++++++
+ protocol/weston-configure-mtk.xml    |  67 +++++++++
+ 7 files changed, 486 insertions(+), 3 deletions(-)
+ create mode 100644 clients/simple-screenshooter-mtk.c
+ create mode 100644 libweston/weston-screenshooter-mtk.c
+ create mode 100644 protocol/weston-configure-mtk.xml
+
+diff --git a/Makefile.am b/Makefile.am
+index 769e103..a9e48f8 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -96,6 +96,7 @@ libweston_@LIBWESTON_MAJOR@_la_SOURCES =			\
+ 	libweston/linux-dmabuf.h			\
+ 	libweston/pixel-formats.c			\
+ 	libweston/pixel-formats.h			\
++	libweston/weston-screenshooter-mtk.c \
+ 	shared/helpers.h				\
+ 	shared/matrix.c					\
+ 	shared/matrix.h					\
+@@ -169,7 +170,10 @@ nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES =				\
+ 	protocol/input-timestamps-unstable-v1-protocol.c		\
+ 	protocol/input-timestamps-unstable-v1-server-protocol.h		\
+ 	protocol/weston-touch-calibration-protocol.c			\
+-	protocol/weston-touch-calibration-server-protocol.h
++	protocol/weston-touch-calibration-server-protocol.h  \
++	protocol/pointer-constraints-unstable-v1-server-protocol.h	\
++	protocol/weston-configure-mtk-protocol.c	\
++	protocol/weston-configure-mtk-server-protocol.h
+ 
+ BUILT_SOURCES += $(nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES)
+ 
+@@ -652,6 +656,19 @@ weston_simple_dmabuf_v4l_CFLAGS = $(AM_CFLAGS) $(SIMPLE_DMABUF_V4L_CLIENT_CFLAGS
+ weston_simple_dmabuf_v4l_LDADD = $(SIMPLE_DMABUF_V4L_CLIENT_LIBS) libshared.la
+ endif
+ 
++demo_clients += weston-simple-screenshooter-mtk
++weston_simple_screenshooter_mtk_SOURCES = clients/simple-screenshooter-mtk.c
++nodist_weston_simple_screenshooter_mtk_SOURCES =               \
++        protocol/xdg-shell-unstable-v6-protocol.c               \
++        protocol/xdg-shell-unstable-v6-client-protocol.h        \
++        protocol/fullscreen-shell-unstable-v1-protocol.c        \
++        protocol/fullscreen-shell-unstable-v1-client-protocol.h \
++        protocol/weston-configure-mtk-protocol.c               \
++        protocol/weston-configure-mtk-client-protocol.h
++weston_simple_screenshooter_mtk_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
++weston_simple_screenshooter_mtk_LDADD =  $(EGL_LIBS) $(LIBDRM_LIBS) libtoytoolkit.la
++
++
+ noinst_LTLIBRARIES += libtoytoolkit.la
+ 
+ libtoytoolkit_la_SOURCES =				\
+@@ -911,7 +928,9 @@ BUILT_SOURCES +=					\
+ 	protocol/tablet-unstable-v2-protocol.c		\
+ 	protocol/tablet-unstable-v2-client-protocol.h			\
+ 	protocol/input-timestamps-unstable-v1-protocol.c		\
+-	protocol/input-timestamps-unstable-v1-client-protocol.h
++	protocol/input-timestamps-unstable-v1-client-protocol.h \
++	protocol/weston-configure-mtk-protocol.c		\
++	protocol/weston-configure-mtk-client-protocol.h
+ 
+ westondatadir = $(datadir)/weston
+ dist_westondata_DATA =				\
+@@ -1564,7 +1583,8 @@ EXTRA_DIST +=					\
+ 	protocol/weston-test.xml		\
+ 	protocol/weston-touch-calibration.xml	\
+ 	protocol/ivi-application.xml		\
+-	protocol/ivi-hmi-controller.xml
++	protocol/ivi-hmi-controller.xml  \
++	protocol/weston-configure-mtk.xml
+ 
+ #
+ # manual test modules in tests subdirectory
+diff --git a/clients/simple-screenshooter-mtk.c b/clients/simple-screenshooter-mtk.c
+new file mode 100644
+index 0000000..cbca18b
+--- /dev/null
++++ b/clients/simple-screenshooter-mtk.c
+@@ -0,0 +1,259 @@
++/*
++ * Copyright © 2008 Kristian Høgsberg
++ *
++ * 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.
++ */
++
++#include "config.h"
++
++#include <stdint.h>
++#include <errno.h>
++#include <stdlib.h>
++#include <stdio.h>
++#include <string.h>
++#include <fcntl.h>
++#include <unistd.h>
++#include <limits.h>
++#include <sys/param.h>
++#include <sys/mman.h>
++#include <cairo.h>
++
++#include <wayland-client.h>
++#include "weston-configure-mtk-client-protocol.h"
++#include "shared/os-compatibility.h"
++#include "shared/xalloc.h"
++
++/* The screenshooter is a good example of a custom object exposed by
++ * the compositor and serves as a test bed for implementing client
++ * side marshalling outside libwayland.so */
++
++static struct wl_shm *shm;
++static struct weston_screenshooter_mtk *mtk_screenshooter;
++static struct wl_list output_list;
++int min_x, min_y, max_x, max_y;
++int buffer_copy_done;
++
++struct screenshooter_output {
++	struct wl_output *output;
++	struct wl_buffer *buffer;
++	int width, height, offset_x, offset_y;
++	void *data;
++	struct wl_list link;
++};
++
++static void
++display_handle_geometry(void *data,
++			struct wl_output *wl_output,
++			int x,
++			int y,
++			int physical_width,
++			int physical_height,
++			int subpixel,
++			const char *make,
++			const char *model,
++			int transform)
++{
++	struct screenshooter_output *output;
++
++	output = wl_output_get_user_data(wl_output);
++
++	if (wl_output == output->output) {
++		output->offset_x = x;
++		output->offset_y = y;
++	}
++}
++
++static void
++display_handle_mode(void *data,
++		    struct wl_output *wl_output,
++		    uint32_t flags,
++		    int width,
++		    int height,
++		    int refresh)
++{
++	struct screenshooter_output *output;
++
++	output = wl_output_get_user_data(wl_output);
++
++	if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT)) {
++		output->width = width;
++		output->height = height;
++	}
++}
++
++static const struct wl_output_listener output_listener = {
++	display_handle_geometry,
++	display_handle_mode
++};
++
++static void
++screenshooter_done(void *data, struct weston_screenshooter_mtk *mtk_screenshooter)
++{
++	fprintf(stderr, "screenshooter_done\n");
++	buffer_copy_done = 1;
++}
++
++static const struct weston_screenshooter_mtk_listener screenshooter_mtk_listener =
++{
++	screenshooter_done
++};
++
++static void
++handle_global(void *data, struct wl_registry *registry,
++	      uint32_t name, const char *interface, uint32_t version)
++{
++	static struct screenshooter_output *output;
++
++	if (strcmp(interface, "wl_output") == 0) {
++		output = xmalloc(sizeof *output);
++		output->output = wl_registry_bind(registry, name,
++						  &wl_output_interface, 1);
++		wl_list_insert(&output_list, &output->link);
++		wl_output_add_listener(output->output, &output_listener, output);
++	} else if (strcmp(interface, "wl_shm") == 0) {
++		shm = wl_registry_bind(registry, name, &wl_shm_interface, 1);
++	} else if (strcmp(interface, "weston_screenshooter_mtk") == 0) {
++		mtk_screenshooter = wl_registry_bind(registry, name,
++						 &weston_screenshooter_mtk_interface,
++						 1);
++	}
++}
++
++static void
++handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
++{
++	/* XXX: unimplemented */
++}
++
++static const struct wl_registry_listener registry_listener = {
++	handle_global,
++	handle_global_remove
++};
++
++static struct wl_buffer *
++create_shm_buffer(int width, int height, void **data_out)
++{
++	struct wl_shm_pool *pool;
++	struct wl_buffer *buffer;
++	int fd, size, stride;
++	void *data;
++
++	stride = width * 4;
++	size = stride * height;
++
++	fd = os_create_anonymous_file(size);
++	if (fd < 0) {
++		fprintf(stderr, "creating a buffer file for %d B failed: %m\n",
++			size);
++		return NULL;
++	}
++
++	data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
++	if (data == MAP_FAILED) {
++		fprintf(stderr, "mmap failed: %m\n");
++		close(fd);
++		return NULL;
++	}
++
++	pool = wl_shm_create_pool(shm, fd, size);
++	close(fd);
++	buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride,
++					   WL_SHM_FORMAT_XRGB8888);
++	wl_shm_pool_destroy(pool);
++
++	*data_out = data;
++	fprintf(stderr,"create_shm_buffer\n");
++	return buffer;
++}
++
++static void
++usage(int error_code)
++{
++	fprintf(stderr, "Usage: simple-screenshooter-mtk [OPTIONS]\n\n"
++		"  -m        dump mainscreen\n"
++		"  -s        dump subscreen\n"
++		"  -h        This help text! default dump all screens\n\n");
++
++	exit(error_code);
++}
++
++int main(int argc, char *argv[])
++{
++	struct wl_display *display;
++	struct wl_registry *registry;
++	struct screenshooter_output *output;
++	int i, width, height;
++	int mainscreen=0;
++	int subscreen=0;
++	for (i = 1; i < argc; i++) {
++		if (strcmp("-m", argv[i]) == 0)
++			mainscreen = 1;
++		else if (strcmp("-s", argv[i]) == 0)
++			subscreen = 1;
++		else if (strcmp("-h", argv[i]) == 0)
++			usage(EXIT_SUCCESS);
++		else
++			usage(EXIT_SUCCESS);
++	}
++
++	display = wl_display_connect(NULL);
++	if (display == NULL) {
++		fprintf(stderr, "failed to create display: %m\n");
++		return -1;
++	}
++
++	wl_list_init(&output_list);
++	registry = wl_display_get_registry(display);
++	wl_registry_add_listener(registry, &registry_listener, NULL);
++	wl_display_dispatch(display);
++	wl_display_roundtrip(display);
++	if (mtk_screenshooter == NULL) {
++		fprintf(stderr, "display doesn't support screenshooter\n");
++		return -1;
++	}
++
++	weston_screenshooter_mtk_add_listener(mtk_screenshooter,
++					  &screenshooter_mtk_listener,
++					  NULL);
++
++	wl_list_for_each_reverse(output, &output_list, link) {
++		if(mainscreen == 1) {
++			output->buffer = create_shm_buffer(1920, 1080, &output->data);
++			weston_screenshooter_mtk_shoot(mtk_screenshooter,output->output,output->buffer);
++			buffer_copy_done = 0;
++			while (!buffer_copy_done)
++				wl_display_roundtrip(display);
++
++			break;
++		}
++		else if(subscreen == 1) {
++			subscreen = 0;
++		}
++		else {
++			output->buffer = create_shm_buffer(1920, 1080, &output->data);
++			weston_screenshooter_mtk_shoot(mtk_screenshooter,output->output,output->buffer);
++			buffer_copy_done = 0;
++			while (!buffer_copy_done)
++				wl_display_roundtrip(display);
++		}
++	}
++	fprintf(stderr,"end!!!!!\n");
++	return 0;
++}
+diff --git a/libweston/compositor.c b/libweston/compositor.c
+index 9deb781..fdf5d25 100644
+--- a/libweston/compositor.c
++++ b/libweston/compositor.c
+@@ -2756,6 +2756,9 @@ weston_output_schedule_repaint(struct weston_output *output)
+ 	    compositor->state == WESTON_COMPOSITOR_OFFSCREEN)
+ 		return;
+ 
++	if(output->screenshoot_needed)
++		output->screenshoot_dump = 1;
++
+ 	if (!output->repaint_needed)
+ 		TL_POINT("core_repaint_req", TLP_OUTPUT(output), TLP_END);
+ 
+diff --git a/libweston/compositor.h b/libweston/compositor.h
+index 8b7a102..8736691 100644
+--- a/libweston/compositor.h
++++ b/libweston/compositor.h
+@@ -238,6 +238,9 @@ struct weston_output {
+ 		REPAINT_AWAITING_COMPLETION, /**< last repaint not yet finished */
+ 	} repaint_status;
+ 
++	int screenshoot_needed;
++	int screenshoot_dump;
++
+ 	/** If repaint_status is REPAINT_SCHEDULED, contains the time the
+ 	 *  next repaint should be run */
+ 	struct timespec next_repaint;
+diff --git a/libweston/pixel-formats.c b/libweston/pixel-formats.c
+index df84a9f..b45db93 100644
+--- a/libweston/pixel-formats.c
++++ b/libweston/pixel-formats.c
+@@ -145,6 +145,8 @@ static const struct pixel_format_info pixel_format_table[] = {
+ 	},
+ 	{
+ 		.format = DRM_FORMAT_RGB888,
++		.depth = 24,
++		.bpp = 24,
+ 	},
+ 	{
+ 		.format = DRM_FORMAT_BGR888,
+diff --git a/libweston/weston-screenshooter-mtk.c b/libweston/weston-screenshooter-mtk.c
+new file mode 100644
+index 0000000..7ad8f97
+--- /dev/null
++++ b/libweston/weston-screenshooter-mtk.c
+@@ -0,0 +1,129 @@
++/*
++ * Copyright © 2008-2011 Kristian Høgsberg
++ *
++ * 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.
++ */
++
++#include "config.h"
++
++#include <stdlib.h>
++#include <stdio.h>
++#include <string.h>
++#include <linux/input.h>
++#include <fcntl.h>
++#include <unistd.h>
++#include <sys/uio.h>
++
++#include "compositor.h"
++#include "weston-configure-mtk-server-protocol.h"
++#include "shared/helpers.h"
++
++#include "wcap/wcap-decode.h"
++
++struct screenshooter {
++	struct weston_compositor *ec;
++	struct wl_global *global;
++	struct wl_client *client;
++	//struct weston_process process;
++	struct wl_listener destroy_listener;
++};
++
++struct screenshooter_frame_listener {
++	struct wl_listener listener;
++	struct weston_buffer *buffer;
++	weston_screenshooter_done_func_t done;
++	void *data;
++};
++
++static void
++weston_screenshooter_mtk_shoot(struct wl_client *client,
++		    struct wl_resource *resource,
++		    struct wl_resource *output_resource,
++		    struct wl_resource *buffer_resource)
++{
++	struct weston_output *output =
++		wl_resource_get_user_data(output_resource);
++	struct weston_buffer *buffer =
++		weston_buffer_from_resource(buffer_resource);
++	weston_log("weston_screenshooter_mtk_shoot.\n");
++	output->screenshoot_needed = 1;
++	weston_output_schedule_repaint(output);
++	if (buffer == NULL) {
++		wl_resource_post_no_memory(resource);
++		return;
++	}
++
++	weston_screenshooter_mtk_send_done(resource);
++}
++
++static const struct weston_screenshooter_mtk_interface screenshooter_mtk_implementation = {
++	weston_screenshooter_mtk_shoot
++};
++
++static void
++bind_screenshooter_mtk(struct wl_client *client,
++	     void *data, uint32_t version, uint32_t id)
++{
++	struct screenshooter *shooter = data;
++	struct wl_resource *resource;
++
++	resource = wl_resource_create(client,
++				      &weston_screenshooter_mtk_interface, 1, id);
++
++	if (resource == NULL) {
++		wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
++			       "screenshooter failed: permission denied");
++		wl_client_post_no_memory(client);
++		return;
++	}
++
++	wl_resource_set_implementation(resource, &screenshooter_mtk_implementation,
++				       data, NULL);
++}
++
++static void
++screenshooter_destroy(struct wl_listener *listener, void *data)
++{
++	struct screenshooter *shooter =
++		container_of(listener, struct screenshooter, destroy_listener);
++
++	wl_global_destroy(shooter->global);
++	free(shooter);
++}
++
++WL_EXPORT void
++screenshooter_mtk_create(struct weston_compositor *ec)
++{
++	struct screenshooter *shooter;
++
++	shooter = malloc(sizeof *shooter);
++	if (shooter == NULL)
++		return;
++
++	shooter->ec = ec;
++	shooter->global = wl_global_create(ec->wl_display,
++					   &weston_screenshooter_mtk_interface, 1,
++					   shooter, bind_screenshooter_mtk);
++
++	shooter->destroy_listener.notify = screenshooter_destroy;
++	wl_signal_add(&ec->destroy_signal, &shooter->destroy_listener);
++}
+diff --git a/protocol/weston-configure-mtk.xml b/protocol/weston-configure-mtk.xml
+new file mode 100644
+index 0000000..120e904
+--- /dev/null
++++ b/protocol/weston-configure-mtk.xml
+@@ -0,0 +1,66 @@
++<?xml version="1.0" encoding="UTF-8"?>
++<protocol name="weston_configure_mtk">
++
++  <copyright>
++    Copyright (C) 2016 MediaTek
++
++    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.
++  </copyright>
++
++  <interface name="weston_screenshooter_mtk" version="1">
++    <request name="shoot">
++      <arg name="output" type="object" interface="wl_output"/>
++      <arg name="buffer" type="object" interface="wl_buffer"/>
++    </request>
++    <event name="done">
++    </event>
++  </interface>
++
++  <interface name="config_switch_set" version="1">
++    <description summary="app interface for setting configure for the surface"/>
++
++    <request name="sprite_switch">
++      <description summary="setting the surface configure">
++       This set view matched with the surface to show in overlay plane if
++       overlay planes are available.Otherwise, it walk primary plane to
++       render, and then send to drm to show.
++      </description>
++	  <arg name="sprite_switch" type="int"/>
++    </request>
++  </interface>
++
++  <interface name="config_switch" version="1">
++    <description summary="create app configure path for setting parameter">
++      This interface is exposed as a global singleton.
++      This interface is implemented by server, it mainly provide channel to allow
++      client to control some properties.
++    </description>
++
++    <request name="connect">
++      <description summary="connect to server for setting parameter">
++        This request gives client way to connect server.In fact, parameters set by
++        app all through wl_surface because this is only way can be transmit by app.
++      </description>
++      <arg name="surface" type="object" interface="wl_surface" allow-null="true"/>
++      <arg name="id" type="new_id" interface="config_switch_set"/>
++    </request>
++  </interface>
++
++</protocol>
+-- 
+2.6.4
+
diff --git a/debian/patches/0007-PATCH-weston-add-mtk-test-client.patch b/debian/patches/0007-PATCH-weston-add-mtk-test-client.patch
new file mode 100644
index 0000000..35ec67a
--- /dev/null
+++ b/debian/patches/0007-PATCH-weston-add-mtk-test-client.patch
@@ -0,0 +1,1306 @@
+From 62628502047672c190fadc3f98caf427df25dfe6 Mon Sep 17 00:00:00 2001
+From: Qian Hu <Qian.Hu@mediatek.com>
+Date: Tue, 24 Sep 2019 14:31:26 +0800
+Subject: [PATCH 7/8] [PATCH] weston: add mtk test client
+
+add mtk test client
+
+Signed-off-by: Qian Hu <Qian.Hu@mediatek.com>
+---
+ Makefile.am                    |   14 +
+ clients/simple-configure-mtk.c | 1247 ++++++++++++++++++++++++++++++++++++++++
+ configure.ac                   |    1 +
+ 3 files changed, 1262 insertions(+)
+ create mode 100644 clients/simple-configure-mtk.c
+
+diff --git a/Makefile.am b/Makefile.am
+index a9e48f8..7efa5a0 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -668,6 +668,20 @@ nodist_weston_simple_screenshooter_mtk_SOURCES =               \
+ weston_simple_screenshooter_mtk_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
+ weston_simple_screenshooter_mtk_LDADD =  $(EGL_LIBS) $(LIBDRM_LIBS) libtoytoolkit.la
+ 
++if BUILD_SIMPLE_CONFIGURE_MTK_CLIENT
++demo_clients += weston-simple-configure-mtk
++weston_simple_configure_mtk_SOURCES = clients/simple-configure-mtk.c
++nodist_weston_simple_configure_mtk_SOURCES =               \
++        protocol/xdg-shell-unstable-v6-protocol.c               \
++        protocol/xdg-shell-unstable-v6-client-protocol.h        \
++        protocol/fullscreen-shell-unstable-v1-protocol.c        \
++        protocol/fullscreen-shell-unstable-v1-client-protocol.h \
++        protocol/linux-dmabuf-unstable-v1-protocol.c		\
++        protocol/linux-dmabuf-unstable-v1-client-protocol.h
++weston_simple_configure_mtk_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
++weston_simple_configure_mtk_LDADD =  $(EGL_LIBS) $(LIBDRM_LIBS) libtoytoolkit.la
++BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
++endif
+ 
+ noinst_LTLIBRARIES += libtoytoolkit.la
+ 
+diff --git a/clients/simple-configure-mtk.c b/clients/simple-configure-mtk.c
+new file mode 100644
+index 0000000..8b146ff
+--- /dev/null
++++ b/clients/simple-configure-mtk.c
+@@ -0,0 +1,1245 @@
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <stdbool.h>
++#include <math.h>
++#include <assert.h>
++#include <sys/mman.h>
++#include <signal.h>
++#include <fcntl.h>
++#include <errno.h>
++#include <linux/input.h>
++
++#include <wayland-client.h>
++#include <wayland-cursor.h>
++
++#include <drm_fourcc.h>
++#include <xf86drm.h>
++#include <xf86drmMode.h>
++
++#include <sys/types.h>
++#include <unistd.h>
++
++//#include "ivi-application-client-protocol.h"
++#include "xdg-shell-unstable-v6-client-protocol.h"
++#include "linux-dmabuf-unstable-v1-client-protocol.h"
++#include "fullscreen-shell-unstable-v1-client-protocol.h"
++#include "weston-configure-mtk-client-protocol.h"
++
++#include <shared/platform.h>
++
++//#define IVI_SURFACE_ID 9000
++#define MAX_IMAGE 16
++#define ALIGN(X,bit) ((X + bit-1) & (~(bit-1)))
++#define MAX_DMABUF_PLANES 4
++#define RES_NUM 4
++#define MAX_LEN 60
++
++struct window;
++struct seat;
++
++struct display {
++	struct wl_display *display;
++	struct wl_registry *registry;
++	struct wl_compositor *compositor;
++	struct zxdg_shell_v6 *shell;
++	struct zwp_fullscreen_shell_v1 *fshell;
++	//struct ivi_application *ivi_application;
++	struct wl_seat *seat;
++	struct wl_pointer *pointer;
++	struct wl_touch *touch;
++	struct wl_keyboard *keyboard;
++	struct wl_shm *shm;
++	struct zwp_linux_dmabuf_v1 *dmabuf;
++	struct wl_list output_list; /* struct output_unit::link */
++	struct wl_cursor_theme *cursor_theme;
++	struct wl_cursor *default_cursor;
++	struct wl_surface *cursor_surface;
++	struct window *window;
++	struct config_switch *config_switch;
++};
++
++struct geometry {
++	int width, height;
++};
++
++struct buffer {
++	struct wl_buffer *buffer;
++	void *dma_map;
++	int busy;
++};
++
++struct file_arg{
++	char filename[MAX_LEN];
++	int width;
++	int height;
++	int format;
++};
++
++struct window {
++	struct display *display;
++	struct geometry geometry, window_size;
++   bool wait_for_configure;
++	struct {
++		struct file_arg fProp;
++		struct buffer out_bufs[RES_NUM];
++	} image;
++	struct img_texture *tex;
++	uint32_t benchmark_time, frames;
++	struct wl_surface *surface;
++	struct zxdg_surface_v6 *xdg_surface;
++	struct zxdg_toplevel_v6 *xdg_toplevel;
++	//struct ivi_surface *ivi_surface;
++	struct wl_callback *callback;
++	int fullscreen, opaque, buffer_size, overlay, format;
++	enum wl_output_transform transform;
++	int drm_card_fd;
++	struct config_switch_set *switch_set;
++};
++
++struct img_texture {
++	struct context *ctx;
++
++	/* input */
++	int width;
++	int height;
++	int drm_format;
++	int bpp;
++	int plane_nums;
++
++	int pitch[MAX_DMABUF_PLANES];
++	int offset[MAX_DMABUF_PLANES];
++	int fds[MAX_DMABUF_PLANES];
++	int handle[MAX_DMABUF_PLANES];
++
++	void *texbuf;
++	int size;
++};
++
++typedef enum _IMG_FORMAT_E {
++	IMG_FORMAT_RGB565 = 0,
++	IMG_FORMAT_XRGB8888,
++	IMG_FORMAT_ARGB8888,
++	IMG_FORMAT_YUYV,
++	IMG_FORMAT_NV12,
++	IMG_FORMAT_NV16,
++	IMG_FORMAT_YUV420,
++	IMG_FORMAT_YVU420,
++	IMG_FORMAT_LAST,
++} IMG_FORMAT_T;
++
++struct drm_fourcc_info {
++	unsigned int drm_format;
++	int plane_cnt;
++	int bpp;
++};
++
++static struct drm_fourcc_info fourcc_tbl[] = {
++	{DRM_FORMAT_RGB565, 1, 16},
++	{DRM_FORMAT_RGBA5551, 1, 16},
++	{DRM_FORMAT_RGBA4444, 1, 16},
++	{DRM_FORMAT_XRGB8888, 1, 32},
++	{DRM_FORMAT_XBGR8888, 1, 32},
++	{DRM_FORMAT_RGBX8888, 1, 32},
++	{DRM_FORMAT_BGRX8888, 1, 32},
++	{DRM_FORMAT_ARGB8888, 1, 32},
++	{DRM_FORMAT_ABGR8888, 1, 32},
++	{DRM_FORMAT_RGBA8888, 1, 32},
++	{DRM_FORMAT_BGRA8888, 1, 32},
++	{DRM_FORMAT_YUYV, 1, 16},
++	{DRM_FORMAT_VYUY, 1, 16},
++	{DRM_FORMAT_NV12, 2, 12},
++	{DRM_FORMAT_NV21, 2, 12},
++	{DRM_FORMAT_NV16, 2, 16},
++	{DRM_FORMAT_NV61, 2, 16},
++	{DRM_FORMAT_YUV420, 3, 12},
++	{DRM_FORMAT_YVU420, 3, 12},
++	{0, 0, 0},
++};
++
++static int running = 1;
++static int debug = 0;
++
++static void
++redraw(void *data, struct wl_callback *callback, uint32_t time);
++
++static int _format_transfer(int format, int *drm_format)
++{
++	int new_format;
++
++	if (!drm_format)
++		return -1;
++
++	switch (format) {
++		case IMG_FORMAT_RGB565:
++			new_format = DRM_FORMAT_RGB565;
++			break;
++		case IMG_FORMAT_XRGB8888:
++			new_format = DRM_FORMAT_XRGB8888;
++			break;
++		case IMG_FORMAT_ARGB8888:
++			new_format = DRM_FORMAT_ARGB8888;
++			break;
++		case IMG_FORMAT_YUYV:
++			new_format = DRM_FORMAT_YUYV;
++			break;
++		case IMG_FORMAT_NV12:
++			new_format = DRM_FORMAT_NV12;
++			break;
++		case IMG_FORMAT_NV16:
++			new_format = DRM_FORMAT_NV16;
++			break;
++		case IMG_FORMAT_YUV420:
++			new_format = DRM_FORMAT_YUV420;
++			break;
++		case IMG_FORMAT_YVU420:
++			new_format = DRM_FORMAT_YVU420;
++			break;
++		default:
++			return -2;
++	}
++	*drm_format = new_format;
++
++	return 0;
++}
++
++static struct drm_fourcc_info *
++get_drm_format_info(unsigned int format)
++{
++	int i;
++
++	for (i = 0; ; i++) {
++		if ( format == fourcc_tbl[i].drm_format){
++			return &fourcc_tbl[i];
++		}
++		if ( fourcc_tbl[i].drm_format == 0)
++			break;
++	}
++	return NULL;
++}
++
++static char *
++_get_tex_resource(int drifd, struct img_texture *tex)
++{
++    void *map = NULL;
++    struct drm_mode_create_dumb create_arg;
++    struct drm_mode_map_dumb map_arg;
++    struct drm_prime_handle prime_arg;
++    struct drm_fourcc_info *format_info;
++    int i, ret;
++    unsigned int alloc_size;
++
++    memset(&create_arg, 0, sizeof(create_arg));
++    memset(&map_arg, 0, sizeof(map_arg));
++    memset(&prime_arg, 0, sizeof(prime_arg));
++
++	for(i = 0; i < MAX_DMABUF_PLANES; i ++ )
++	    tex->fds[i] = -1;
++
++	format_info = get_drm_format_info(tex->drm_format);
++	if (format_info == NULL)
++		return NULL;
++
++	tex->bpp = format_info->bpp;
++	if (format_info->plane_cnt == 3) {
++		if (format_info->bpp == 12) {
++			tex->pitch[0] = ALIGN(tex->width, 16);
++			tex->pitch[1] = tex->pitch[0] / 2;
++			tex->pitch[2] = tex->pitch[0] / 2;
++			tex->offset[0] = 0;
++			tex->offset[1] = tex->pitch[0] * tex->height;
++			tex->offset[2] = tex->offset[1] + tex->pitch[1] * tex->height / 2;
++			alloc_size = tex->offset[2] + tex->pitch[2] * tex->height / 2;
++		} else {
++			fprintf(stderr,"debug: please add new format 0x%x\n", tex->drm_format);
++			return NULL;
++		}
++	} else if (format_info->plane_cnt == 2) {
++		tex->pitch[0] = ALIGN(tex->width, 16);
++		tex->offset[0] = 0;
++		if (format_info->bpp == 16) {
++			tex->pitch[1] = tex->pitch[0];
++			tex->offset[1] = tex->pitch[0] * tex->height;
++			alloc_size = tex->offset[1] + tex->pitch[1] * tex->height;
++			fprintf(stderr,"debug:  %s %d alloc_size = %d o/p [%d %d]\n",
++				__FUNCTION__, __LINE__, alloc_size, tex->offset[1], tex->pitch[1]);
++		}
++		else if (format_info->bpp == 12) {
++			tex->pitch[1] = tex->pitch[0] / 2;
++			tex->offset[1] = tex->pitch[0] * tex->height;
++			alloc_size = tex->offset[1] + tex->pitch[1] * tex->height;
++		} else {
++			fprintf(stderr,"debug: please add new format 0x%x\n", tex->drm_format);
++			return NULL;
++		}
++	} else {
++		tex->pitch[0] = ALIGN(tex->width * tex->bpp / 8, 16);
++		tex->offset[0] = 0;
++		alloc_size = tex->pitch[0] * tex->height;
++	}
++
++	create_arg.bpp = 8;
++	create_arg.width = alloc_size;
++	create_arg.height = 1;
++
++    ret = drmIoctl(drifd, DRM_IOCTL_MODE_CREATE_DUMB, &create_arg);
++    if (ret) {
++            fprintf(stderr,"error: drmIoctl %d DRM_IOCTL_MODE_CREATE_DUMB fail %d\n", drifd, ret);
++            return NULL;
++    }
++
++    map_arg.handle = create_arg.handle;
++
++    ret = drmIoctl(drifd, DRM_IOCTL_MODE_MAP_DUMB, &map_arg);
++    if (ret) {
++            fprintf(stderr,"error: drmIoctl DRM_IOCTL_MODE_MAP_DUMB fail %d\n", ret);
++            return NULL;
++    }
++
++    map = mmap(0, create_arg.size, PROT_WRITE|PROT_READ , MAP_SHARED, drifd, map_arg.offset);
++    if (map == MAP_FAILED) {
++            fprintf(stderr,"error: mmap fail : %p\n", map);
++            return NULL;
++    }
++
++    prime_arg.handle = create_arg.handle;
++    prime_arg.flags = DRM_CLOEXEC;
++    ret = drmIoctl(drifd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &prime_arg);
++    if (ret || prime_arg.fd == -1) {
++            fprintf(stderr,"error: drmIoctl DRM_IOCTL_PRIME_HANDLE_TO_FD fail %d fd=%d\n",ret,prime_arg.fd);
++            return NULL;
++    }
++
++	for (i = 0; i < format_info->plane_cnt; i++) {
++		tex->fds[i] = prime_arg.fd;
++		tex->handle[i] = create_arg.handle;
++	}
++	tex->plane_nums = format_info->plane_cnt;
++	tex->texbuf = map;
++	tex->size = create_arg.size;
++
++	return map;
++}
++
++static int
++init_img_texture(struct window *window)
++{
++	int ret;
++	struct img_texture *tex;
++	tex = malloc(sizeof *tex);
++	if (tex == NULL)
++		return -1;
++
++	ret = _format_transfer(window->image.fProp.format, &(tex->drm_format));
++	if (ret < 0)
++		return -1;
++
++	tex->width = window->image.fProp.width;
++	tex->height= window->image.fProp.height;
++
++	window->tex = tex;
++	return 0;
++}
++
++static void
++buffer_release(void *data, struct wl_buffer *buffer)
++{
++	struct buffer *mybuf = data;
++
++	mybuf->busy = 0;
++}
++
++static const struct wl_buffer_listener buffer_listener = {
++	buffer_release
++};
++
++static void
++create_succeeded(void *data,
++		 struct zwp_linux_buffer_params_v1 *params,
++		 struct wl_buffer *new_buffer)
++{
++	struct buffer *buffer = data;
++
++	buffer->buffer = new_buffer;
++	wl_buffer_add_listener(buffer->buffer, &buffer_listener, buffer);
++
++	zwp_linux_buffer_params_v1_destroy(params);
++}
++
++static void
++create_failed(void *data, struct zwp_linux_buffer_params_v1 *params)
++{
++	struct buffer *buffer = data;
++
++	buffer->buffer = NULL;
++
++	zwp_linux_buffer_params_v1_destroy(params);
++
++	running = false;
++
++	fprintf(stderr, "Error: zwp_linux_buffer_params.create failed.\n");
++}
++
++static const struct zwp_linux_buffer_params_v1_listener params_listener = {
++	create_succeeded,
++	create_failed
++};
++
++static int
++create_dmabuf_buffer(struct display *display, struct buffer *buffer)
++{
++	struct zwp_linux_buffer_params_v1 *params;
++	struct img_texture *cbtex = display->window->tex;
++	uint64_t modifier;
++	uint32_t flags;
++	int i;
++	/* output */
++	buffer->dma_map = _get_tex_resource(display->window->drm_card_fd, cbtex);
++
++	if (buffer->dma_map == NULL) {
++		fprintf(stderr, "error: _get_tex_resource failed\n");
++		return -1;
++	}
++
++	modifier = 0;
++	params = zwp_linux_dmabuf_v1_create_params(display->dmabuf);
++
++	for(i = 0; i < cbtex->plane_nums; i ++)
++	{
++		zwp_linux_buffer_params_v1_add(params,
++				cbtex->fds[i],
++				i, /* plane_idx */
++				cbtex->offset[i],/* offset */
++				cbtex->pitch[i],
++				modifier >> 32,
++				modifier & 0xffffffff);
++	}
++	zwp_linux_buffer_params_v1_add_listener(params, &params_listener, buffer);
++	zwp_linux_buffer_params_v1_create(params,
++				    cbtex->width,
++				    cbtex->height,
++				    cbtex->drm_format,
++				    flags);
++
++	/* params is destroyed by the event handlers */
++	wl_display_roundtrip(display->display);
++	if (buffer->buffer == NULL) {
++		return -1;
++	}
++
++	return 0;
++}
++
++static int
++_load_file(void *buf, int len, const char *file_name)
++{
++    int ret, nread = 0;
++
++    FILE *fp = fopen(file_name, "rb");
++    if (!fp)
++    {
++        fprintf(stderr,"debug: file %s open failed\n", file_name);
++        return -1;
++    }
++
++    while (nread < len) {
++        ret = fread(buf + nread, 1, len - nread, fp);
++        if (!ret)
++                break;
++        nread += ret;
++    }
++
++    fclose(fp);
++    return 0;
++}
++
++static int
++_kms_device_fd(void)
++{
++    int i;
++    bool has_conn = false;
++    for (i = 0; i < 8; ++i) {
++        char path[99];
++        sprintf(path, "/dev/dri/card%d", i);
++        fprintf(stderr, "debug: trying %s\n", path);
++        int fd = open(path, O_RDWR | O_CLOEXEC);
++        if (fd >= 0) {
++            drmModeResPtr mr = drmModeGetResources(fd);
++            if (mr) {
++                has_conn = mr->count_connectors > 0;
++                drmModeFreeResources(mr);
++            }
++            if (has_conn) {
++                fprintf(stderr, "debug: using %s\n", path);
++                return fd;
++            }
++            close(fd);
++        }
++    }
++    return -1;
++}
++
++static void
++handle_xdg_surface_configure(void *data, struct zxdg_surface_v6 *surface,
++			     uint32_t serial)
++{
++	struct window *window = data;
++	fprintf(stderr, "handle_xdg_surface_configure\n");
++
++	zxdg_surface_v6_ack_configure(surface, serial);
++
++	if (window->wait_for_configure) {
++		redraw(window, NULL, 0);
++		window->wait_for_configure = false;
++	}
++}
++
++static const struct zxdg_surface_v6_listener xdg_surface_listener = {
++	handle_xdg_surface_configure,
++};
++
++
++static void
++handle_toplevel_configure(void *data, struct zxdg_toplevel_v6 *toplevel,
++			  int32_t width, int32_t height,
++			  struct wl_array *states)
++{
++	struct window *window = data;
++	uint32_t *p;
++
++	window->fullscreen = 0;
++	wl_array_for_each(p, states) {
++		uint32_t state = *p;
++		switch (state) {
++		case ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN:
++			window->fullscreen = 1;
++			break;
++		}
++	}
++
++	if (width > 0 && height > 0) {
++		if (!window->fullscreen) {
++			window->window_size.width = width;
++			window->window_size.height = height;
++		}
++		window->geometry.width = width;
++		window->geometry.height = height;
++	} else if (!window->fullscreen) {
++		window->geometry = window->window_size;
++	}
++
++	/*if (window->native)
++		wl_egl_window_resize(window->native,
++				     window->geometry.width,
++				     window->geometry.height, 0, 0);*/
++}
++
++static void
++handle_toplevel_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel)
++{
++	running = 0;
++}
++
++static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
++	handle_toplevel_configure,
++	handle_toplevel_close,
++};
++/*
++static void
++handle_ivi_surface_configure(void *data, struct ivi_surface *ivi_surface,
++                             int32_t width, int32_t height)
++{
++
++}
++
++static const struct ivi_surface_listener ivi_surface_listener = {
++	handle_ivi_surface_configure,
++};
++*/
++static struct buffer *
++window_next_buffer(struct window *window)
++{
++	struct buffer *buffer = NULL;
++	int i, ret = 0;
++
++	for(i = 0; i < RES_NUM; i++) {
++		if (!window->image.out_bufs[i].busy) {
++			buffer = &window->image.out_bufs[i];
++			break;
++		}
++	}
++
++	if (!buffer)
++		return NULL;
++
++	if (!buffer->buffer) {
++		ret = create_dmabuf_buffer(window->display, buffer);
++		if (ret < 0)
++			return NULL;
++		if(i%2)
++			_load_file(buffer->dma_map, window->tex->size, window->image.fProp.filename);
++		else
++			memset(buffer->dma_map, 0, window->tex->size);
++	}
++
++	return buffer;
++}
++
++static void
++create_surface(struct window *window)
++{
++	struct display *display = window->display;
++
++	window->surface = wl_compositor_create_surface(display->compositor);
++	display->cursor_surface =
++		wl_compositor_create_surface(display->compositor);
++
++	window->switch_set = config_switch_connect(display->config_switch, window->surface);
++
++	if (display->shell) {
++		window->xdg_surface =
++			zxdg_shell_v6_get_xdg_surface(display->shell,
++			                          window->surface);
++
++		assert(window->xdg_surface);
++
++		zxdg_surface_v6_add_listener(window->xdg_surface,
++		                         &xdg_surface_listener, window);
++
++		window->xdg_toplevel =
++			zxdg_surface_v6_get_toplevel(window->xdg_surface);
++			zxdg_toplevel_v6_add_listener(window->xdg_toplevel,
++				      &xdg_toplevel_listener, window);
++
++		zxdg_toplevel_v6_set_title(window->xdg_toplevel, "simple-configure-mtk");
++		window->wait_for_configure = true;
++		wl_surface_commit(window->surface);
++	} else if (display->fshell) {
++		zwp_fullscreen_shell_v1_present_surface(display->fshell,
++		                                        window->surface,
++		                                        ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_DEFAULT,
++		                                        NULL);
++	//} else if (display->ivi_application ) {
++	//	uint32_t id_ivisurf = IVI_SURFACE_ID + (uint32_t)getpid();
++	//	window->ivi_surface =
++	//		ivi_application_surface_create(display->ivi_application,
++	//					       id_ivisurf, window->surface);
++	//	if (window->ivi_surface == NULL) {
++	//		fprintf(stderr, "Failed to create ivi_client_surface\n");
++	//		abort();
++	//	}
++//
++	//	ivi_surface_add_listener(window->ivi_surface,
++	//				 &ivi_surface_listener, window);
++
++	} else {
++		assert(0);
++	}
++
++}
++
++static void
++destroy_surface(struct window *window)
++{
++	if (window->xdg_toplevel)
++		zxdg_toplevel_v6_destroy(window->xdg_toplevel);
++	if (window->xdg_surface)
++		zxdg_surface_v6_destroy(window->xdg_surface);
++	//if (window->display->ivi_application)
++	//	ivi_surface_destroy(window->ivi_surface);
++	if (window->display->fshell)
++		zwp_fullscreen_shell_v1_release(window->display->fshell);
++	wl_surface_destroy(window->surface);
++
++	if (window->callback)
++		wl_callback_destroy(window->callback);
++
++	if (window->image.out_bufs[0].buffer)
++		wl_buffer_destroy(window->image.out_bufs[0].buffer);
++	if (window->image.out_bufs[1].buffer)
++		wl_buffer_destroy(window->image.out_bufs[1].buffer);
++	if (window->image.out_bufs[2].buffer)
++		wl_buffer_destroy(window->image.out_bufs[2].buffer);
++}
++
++static const struct wl_callback_listener frame_listener;
++
++static void
++redraw(void *data, struct wl_callback *callback, uint32_t time)
++{
++	struct window *window = data;
++	struct buffer *buffer;
++	char filename[MAX_LEN] = {0};
++	static const uint32_t benchmark_interval = 5;
++	struct wl_region *region;
++	struct timeval tv;
++	int tmp;
++
++	buffer = window_next_buffer(window);
++	if (!buffer) {
++		fprintf(stderr,
++			!callback ? "error: Failed to create the first buffer.\n" :
++			"error: Both buffers busy at redraw(). Server bug?\n");
++		abort();
++	}
++
++	gettimeofday(&tv, NULL);
++	time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
++	if (window->frames == 0)
++		window->benchmark_time = time;
++	if (time - window->benchmark_time > (benchmark_interval * 1000)) {
++		printf("debug: %d frames in %d seconds: %f fps\n",
++		       window->frames,
++		       benchmark_interval,
++		       (float) window->frames / benchmark_interval);
++		window->benchmark_time = time;
++		window->frames = 0;
++	}
++
++	if (window->opaque || window->fullscreen) {
++		region = wl_compositor_create_region(window->display->compositor);
++		wl_region_add(region, 0, 0,
++			      window->geometry.width,
++			      window->geometry.height);
++		wl_surface_set_opaque_region(window->surface, region);
++		wl_region_destroy(region);
++	} else {
++		wl_surface_set_opaque_region(window->surface, NULL);
++	}
++
++	wl_surface_attach(window->surface, buffer->buffer, 0, 0);
++	wl_surface_set_buffer_transform(window->surface,
++					window->transform);
++	wl_surface_damage(window->surface,
++			  0, 0, window->geometry.width, window->geometry.height);
++
++	if (callback)
++		wl_callback_destroy(callback);
++
++	window->callback = wl_surface_frame(window->surface);
++	wl_callback_add_listener(window->callback, &frame_listener, window);
++	wl_surface_commit(window->surface);
++	buffer->busy = 1;
++
++	window->frames++;
++}
++
++static const struct wl_callback_listener frame_listener = {
++	redraw
++};
++
++static void
++pointer_handle_enter(void *data, struct wl_pointer *pointer,
++		     uint32_t serial, struct wl_surface *surface,
++		     wl_fixed_t sx, wl_fixed_t sy)
++{
++	struct display *display = data;
++	struct wl_buffer *buffer;
++	struct wl_cursor *cursor = display->default_cursor;
++	struct wl_cursor_image *image;
++
++	if (display->window->fullscreen)
++		wl_pointer_set_cursor(pointer, serial, NULL, 0, 0);
++	else if (cursor) {
++		image = display->default_cursor->images[0];
++		buffer = wl_cursor_image_get_buffer(image);
++		if (!buffer)
++			return;
++		wl_pointer_set_cursor(pointer, serial,
++				      display->cursor_surface,
++				      image->hotspot_x,
++				      image->hotspot_y);
++		wl_surface_attach(display->cursor_surface, buffer, 0, 0);
++		wl_surface_damage(display->cursor_surface, 0, 0,
++				  image->width, image->height);
++		wl_surface_commit(display->cursor_surface);
++	}
++
++}
++
++static void
++pointer_handle_leave(void *data, struct wl_pointer *pointer,
++		     uint32_t serial, struct wl_surface *surface)
++{
++}
++
++static void
++pointer_handle_motion(void *data, struct wl_pointer *pointer,
++		      uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
++{
++
++}
++
++static void
++pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
++		      uint32_t serial, uint32_t time, uint32_t button,
++		      uint32_t state)
++{
++	struct display *display = data;
++
++	if (!display->window->xdg_surface)
++		return;
++
++	if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED)
++		zxdg_toplevel_v6_move(display->window->xdg_toplevel,
++						 display->seat, serial);
++}
++
++static void
++pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
++		    uint32_t time, uint32_t axis, wl_fixed_t value)
++{
++}
++
++static const struct wl_pointer_listener pointer_listener = {
++	pointer_handle_enter,
++	pointer_handle_leave,
++	pointer_handle_motion,
++	pointer_handle_button,
++	pointer_handle_axis,
++};
++
++static void
++touch_handle_down(void *data, struct wl_touch *wl_touch,
++		  uint32_t serial, uint32_t time, struct wl_surface *surface,
++		  int32_t id, wl_fixed_t x_w, wl_fixed_t y_w)
++{
++	struct display *d = (struct display *)data;
++
++	if (!d->shell)
++		return;
++
++	zxdg_toplevel_v6_move(d->window->xdg_toplevel, d->seat, serial);
++}
++
++static void
++touch_handle_up(void *data, struct wl_touch *wl_touch,
++		uint32_t serial, uint32_t time, int32_t id)
++{
++}
++
++static void
++touch_handle_motion(void *data, struct wl_touch *wl_touch,
++		    uint32_t time, int32_t id, wl_fixed_t x_w, wl_fixed_t y_w)
++{
++}
++
++static void
++touch_handle_frame(void *data, struct wl_touch *wl_touch)
++{
++}
++
++static void
++touch_handle_cancel(void *data, struct wl_touch *wl_touch)
++{
++}
++
++static const struct wl_touch_listener touch_listener = {
++	touch_handle_down,
++	touch_handle_up,
++	touch_handle_motion,
++	touch_handle_frame,
++	touch_handle_cancel,
++};
++
++static void
++keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
++		       uint32_t format, int fd, uint32_t size)
++{
++}
++
++static void
++keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
++		      uint32_t serial, struct wl_surface *surface,
++		      struct wl_array *keys)
++{
++}
++
++static void
++keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
++		      uint32_t serial, struct wl_surface *surface)
++{
++}
++
++static void
++keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
++		    uint32_t serial, uint32_t time, uint32_t key,
++		    uint32_t state)
++{
++	struct display *d = data;
++
++	if (!d->shell)
++		return;
++
++	if (key == KEY_F11 && state) {
++		if (d->window->fullscreen)
++			zxdg_toplevel_v6_unset_fullscreen(d->window->xdg_toplevel);
++		else
++			zxdg_toplevel_v6_set_fullscreen(d->window->xdg_toplevel, NULL);
++	} else if (key == KEY_ESC && state)
++		running = 0;
++}
++
++static void
++keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
++			  uint32_t serial, uint32_t mods_depressed,
++			  uint32_t mods_latched, uint32_t mods_locked,
++			  uint32_t group)
++{
++}
++
++static const struct wl_keyboard_listener keyboard_listener = {
++	keyboard_handle_keymap,
++	keyboard_handle_enter,
++	keyboard_handle_leave,
++	keyboard_handle_key,
++	keyboard_handle_modifiers,
++};
++
++static void
++seat_handle_capabilities(void *data, struct wl_seat *seat,
++			 enum wl_seat_capability caps)
++{
++	struct display *d = data;
++
++	if ((caps & WL_SEAT_CAPABILITY_POINTER) && !d->pointer) {
++		d->pointer = wl_seat_get_pointer(seat);
++		wl_pointer_add_listener(d->pointer, &pointer_listener, d);
++	} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && d->pointer) {
++		wl_pointer_destroy(d->pointer);
++		d->pointer = NULL;
++	}
++
++	if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !d->keyboard) {
++		d->keyboard = wl_seat_get_keyboard(seat);
++		wl_keyboard_add_listener(d->keyboard, &keyboard_listener, d);
++	} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && d->keyboard) {
++		wl_keyboard_destroy(d->keyboard);
++		d->keyboard = NULL;
++	}
++
++	if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !d->touch) {
++		d->touch = wl_seat_get_touch(seat);
++		wl_touch_set_user_data(d->touch, d);
++		wl_touch_add_listener(d->touch, &touch_listener, d);
++	} else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && d->touch) {
++		wl_touch_destroy(d->touch);
++		d->touch = NULL;
++	}
++}
++
++static const struct wl_seat_listener seat_listener = {
++	seat_handle_capabilities,
++};
++
++
++static void
++xdg_shell_ping(void *data, struct zxdg_shell_v6 *shell, uint32_t serial)
++{
++	zxdg_shell_v6_pong(shell, serial);
++}
++
++static const struct zxdg_shell_v6_listener xdg_shell_listener = {
++	xdg_shell_ping,
++};
++
++static void
++dmabuf_format(void *data, struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf, uint32_t format)
++{
++	fprintf(stderr, "debug: Support drm_format 0x%x \n", format);
++}
++
++static const struct zwp_linux_dmabuf_v1_listener dmabuf_listener = {
++	dmabuf_format
++};
++
++static void
++registry_handle_global(void *data, struct wl_registry *registry,
++		       uint32_t name, const char *interface, uint32_t version)
++{
++	struct display *d = data;
++
++	if (strcmp(interface, "wl_compositor") == 0) {
++		d->compositor =
++			wl_registry_bind(registry, name,
++					 &wl_compositor_interface, 2);
++	} else if (strcmp(interface, "zxdg_shell_v6") == 0) {
++		d->shell = wl_registry_bind(registry, name,
++					    &zxdg_shell_v6_interface, 1);
++		zxdg_shell_v6_add_listener(d->shell, &xdg_shell_listener, d);
++	} else if (strcmp(interface, "wl_seat") == 0) {
++		d->seat = wl_registry_bind(registry, name,
++					   &wl_seat_interface, 1);
++		wl_seat_add_listener(d->seat, &seat_listener, d);
++	} else if (strcmp(interface, "zwp_fullscreen_shell_v1") == 0) {
++		d->fshell = wl_registry_bind(registry, name,
++					   &zwp_fullscreen_shell_v1_interface, 1);
++	} else if (strcmp(interface, "wl_shm") == 0) {
++		d->shm = wl_registry_bind(registry, name,
++					  &wl_shm_interface, 1);
++		d->cursor_theme = wl_cursor_theme_load(NULL, 32, d->shm);
++		if (!d->cursor_theme) {
++			fprintf(stderr, "unable to load default theme\n");
++			return;
++		}
++		d->default_cursor =
++			wl_cursor_theme_get_cursor(d->cursor_theme, "grabbing");
++		if (!d->default_cursor) {
++			fprintf(stderr, "unable to load default grabbing pointer\n");
++			// TODO: abort ?
++		}
++	//} else if (strcmp(interface, "ivi_application") == 0) {
++	//	d->ivi_application =
++	//		wl_registry_bind(registry, name,
++	//				 &ivi_application_interface, 1);
++	} else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0) {
++		d->dmabuf = wl_registry_bind(registry, name,
++						&zwp_linux_dmabuf_v1_interface, 1);
++		zwp_linux_dmabuf_v1_add_listener(d->dmabuf, &dmabuf_listener, d);
++	} else if (strcmp(interface, "config_switch") == 0) {
++		d->config_switch =
++			wl_registry_bind(registry, name,
++					 &config_switch_interface, 1);
++	}
++}
++
++static void
++registry_handle_global_remove(void *data, struct wl_registry *registry,
++			      uint32_t name)
++{
++}
++
++static const struct wl_registry_listener registry_listener = {
++	registry_handle_global,
++	registry_handle_global_remove
++};
++
++static void
++destroy_display(struct display *display)
++{
++	if (display->dmabuf)
++		zwp_linux_dmabuf_v1_destroy(display->dmabuf);
++
++	if (display->shell)
++		zxdg_shell_v6_destroy(display->shell);
++
++	if (display->fshell)
++		zwp_fullscreen_shell_v1_release(display->fshell);
++
++	if (display->compositor)
++		wl_compositor_destroy(display->compositor);
++
++	wl_surface_destroy(display->cursor_surface);
++	if (display->cursor_theme)
++		wl_cursor_theme_destroy(display->cursor_theme);
++
++	//if (display->ivi_application)
++	//	ivi_application_destroy(display->ivi_application);
++
++	wl_registry_destroy(display->registry);
++	wl_display_flush(display->display);
++	wl_display_disconnect(display->display);
++	free(display);
++}
++
++static struct display *
++create_display(struct window *window)
++{
++	struct display *display;
++
++	display = malloc(sizeof *display);
++	if (display == NULL) {
++		fprintf(stderr, "out of memory\n");
++		exit(1);
++	}
++	display->display = wl_display_connect(NULL);
++	assert(display->display);
++	display->window = window;
++
++	display->registry = wl_display_get_registry(display->display);
++	wl_registry_add_listener(display->registry,
++				 &registry_listener, display);
++	wl_display_roundtrip(display->display);
++	if (display->dmabuf == NULL) {
++		fprintf(stderr, "No zwp_linux_dmabuf_v1 global found\n");
++		exit(1);
++	}
++	wl_display_roundtrip(display->display);
++
++	return display;
++}
++
++static void
++signal_int(int signum)
++{
++	running = 0;
++}
++
++/*
++ * parse the message inputed for rawdata
++ * egg: -F /usr/share/weston/rawdata.nv16:720x480@5
++ * filename:widthxheight@format
++*/
++static int parse_file(struct file_arg *file, char *p)
++{
++	char *end;
++	char *pPos = p;
++	int len, i;
++
++	len = strlen(pPos) + 1;
++	for (i = 0; i < len; i++)
++		if(pPos[i] == ':')
++			pPos[i] = '\0';
++
++	memcpy(file->filename, pPos, strlen(pPos) + 1);
++	pPos = pPos + strlen(pPos) + 1;
++	file->width = strtoul(pPos, &end, 10);
++	if (*end != 'x')
++		return -EINVAL;
++	pPos = end + 1;
++	file->height = strtoul(pPos, &end, 10);
++	if (*end != '@')
++		return -EINVAL;
++	pPos = end + 1;
++	file->format = strtoul(pPos, &end, 10);
++	if (*end != '\0')
++		return -EINVAL;
++	return 0;
++}
++
++static void init_window(struct window *window)
++{
++	window->geometry.width  = 0;
++	window->geometry.height = 0;
++	window->buffer_size = 32;
++	window->transform = WL_OUTPUT_TRANSFORM_NORMAL;
++	window->opaque = 1;
++	window->overlay = 0;
++	window->format = 0;
++	window->drm_card_fd = -1;
++}
++
++static void
++usage(int error_code)
++{
++	fprintf(stderr, "Usage: mtkdraw-dma [OPTIONS]\n\n"
++		"  -f           Run in fullscreen mode(only desktop-shell valid)\n"
++		"  -o           Create an opaque surface\n"
++		"  -s           Use a 16 bpp EGL config\n"
++		"  -t           Set display buffer transform(0~7)\n"
++		"  -F           rawdata message(rawdata size provided is 320x480)\n"
++		"               eg:-F /usr/share/weston/rawdata.nv16:320x480@5\n"
++		"               @14 stand for nv16 format, formats supported as follows\n"
++		"               now only support 8 formats\n"
++		"                   0 --> IMG_FORMAT_RGB565\n"
++		"                   1 --> IMG_FORMAT_XRGB8888\n"
++		"                   2 --> IMG_FORMAT_ARGB8888\n"
++		"                   3 --> IMG_FORMAT_YUYV\n"
++		"                   4 --> IMG_FORMAT_NV12\n"
++		"                   5 --> IMG_FORMAT_NV16\n"
++		"                   6 --> IMG_FORMAT_YUV420\n"
++		"                   7 --> IMG_FORMAT_YVU420\n"
++		"  -d           Enable debug output\n"
++		"  -overlay     Enable overlay switch\n"
++		"  -h           This help text\n\n");
++
++	exit(error_code);
++}
++
++int
++main(int argc, char **argv)
++{
++	struct sigaction sigint;
++	struct display *display;
++	struct window  window  = { 0 };
++	int i, ret = 0;
++	struct file_arg *file;
++
++	init_window(&window);
++
++	for (i = 1; i < argc; i++) {
++		if (strcmp("-f", argv[i]) == 0)
++			window.fullscreen = 1;
++		else if (strcmp("-o", argv[i]) == 0)
++			window.opaque = 0;
++		else if (strcmp("-s", argv[i]) == 0)
++			window.buffer_size = 16;
++		else if (strcmp("-t", argv[i]) == 0)
++			window.transform = atoi(argv[++i]);
++		else if (strcmp("-F", argv[i]) == 0){
++			ret = parse_file(&window.image.fProp, argv[++i]);
++			if (ret < 0)
++				fprintf(stderr, "error: input error, like: -F "
++					"/usr/share/weston/rawdata.nv16:320x480@5\n");
++		}
++		else if (strcmp("-d", argv[i]) == 0)
++			debug = 1;
++		else if (strcmp("-overlay", argv[i]) == 0)
++			window.overlay = 1;
++		else if (strcmp("-h", argv[i]) == 0)
++			usage(EXIT_SUCCESS);
++		else
++			usage(EXIT_FAILURE);
++	}
++
++	file = &window.image.fProp;
++	if((file->width == 0) || (file->height ==0) || (file->filename == 0))
++	{
++		/*default sample*/
++		file->width = 320;
++		file->height = 480;
++		file->format = IMG_FORMAT_NV16;
++		snprintf(file->filename, MAX_LEN, "/usr/share/weston/rawdata.nv16");
++		fprintf(stderr, "debug: You have choose the default example!\n");
++	}
++
++	fprintf(stderr, "debug: The file is %s width/height/format[%d %d %d]\n",
++		file->filename, file->width, file->height, file->format);
++
++	window.geometry.width  = file->width;
++	window.geometry.height = file->height;
++	window.window_size = window.geometry;
++
++	display = create_display(&window);
++	window.display = display;
++	//display->window = &window;
++
++	create_surface(&window);
++
++	ret = init_img_texture(&window);
++	if (ret < 0){
++		fprintf(stderr, "error: init_img_texture failed\n");
++		return -1;
++	}
++
++	window.drm_card_fd = _kms_device_fd();
++	if (window.drm_card_fd < 0) {
++		fprintf(stderr, "error: fail to get drm_card_fd !\n");
++		return -1;
++	}
++	/*
++	  * setting sprite_switch = 0, indicate not walk overlay
++	  * setting sprite_switch = 1, indicate walk overlay
++	*/
++	if(window.overlay)
++		config_switch_set_sprite_switch(window.switch_set, 1);
++	else
++		config_switch_set_sprite_switch(window.switch_set, 0);
++
++	sigint.sa_handler = signal_int;
++	sigemptyset(&sigint.sa_mask);
++	sigint.sa_flags = SA_RESETHAND;
++	sigaction(SIGINT, &sigint, NULL);
++
++	if (!window.wait_for_configure)
++		redraw(&window, NULL, 0);
++
++	while (running && ret != -1)
++		ret = wl_display_dispatch(display->display);
++
++	fprintf(stderr, "debug: simple-configure-mtk exiting\n");
++	destroy_surface(&window);
++	destroy_display(display);
++
++	return 0;
++}
+diff --git a/configure.ac b/configure.ac
+index 96acf75..e91261d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -440,6 +440,7 @@ if ! test "x$enable_simple_dmabuf_v4l_client" = "xno"; then
+   enable_simple_dmabuf_v4l_client="$have_simple_dmabuf_v4l_client"
+ fi
+ AM_CONDITIONAL(BUILD_SIMPLE_DMABUF_V4L_CLIENT, test "x$enable_simple_dmabuf_v4l_client" = "xyes")
++AM_CONDITIONAL(BUILD_SIMPLE_CONFIGURE_MTK_CLIENT, test "x$enable_simple_dmabuf_v4l_client" = "xyes")
+ 
+ AC_ARG_ENABLE(clients, [  --enable-clients],, enable_clients=yes)
+ AM_CONDITIONAL(BUILD_CLIENTS, test x$enable_clients = xyes)
+-- 
+2.6.4
+
diff --git a/debian/patches/0008-PATCH-weston-add-surface-overlay-assignment-interfac.patch b/debian/patches/0008-PATCH-weston-add-surface-overlay-assignment-interfac.patch
new file mode 100644
index 0000000..ad8562c
--- /dev/null
+++ b/debian/patches/0008-PATCH-weston-add-surface-overlay-assignment-interfac.patch
@@ -0,0 +1,276 @@
+From 949565b2683a3a67060698132a52ea26c75d9952 Mon Sep 17 00:00:00 2001
+From: Qian Hu <Qian.Hu@mediatek.com>
+Date: Tue, 24 Sep 2019 15:01:45 +0800
+Subject: [PATCH 8/8] [PATCH] weston: add surface overlay assignment interface
+
+add surface overlay assignment interface
+
+Signed-off-by: Qian Hu <Qian.Hu@mediatek.com>
+---
+ Makefile.am                      |   6 +-
+ compositor/main.c                |   1 +
+ libweston/compositor.h           |  11 ++++
+ libweston/weston-configure-mtk.c | 126 +++++++++++++++++++++++++++++++++++++++
+ libweston/weston-configure-mtk.h |  54 +++++++++++++++++
+ 5 files changed, 197 insertions(+), 1 deletion(-)
+ create mode 100644 libweston/weston-configure-mtk.c
+ create mode 100644 libweston/weston-configure-mtk.h
+
+diff --git a/Makefile.am b/Makefile.am
+index 7efa5a0..008bdfe 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -97,6 +97,8 @@ libweston_@LIBWESTON_MAJOR@_la_SOURCES =			\
+ 	libweston/pixel-formats.c			\
+ 	libweston/pixel-formats.h			\
+ 	libweston/weston-screenshooter-mtk.c \
++	libweston/weston-configure-mtk.c	\
++	libweston/weston-configure-mtk.h	\
+ 	shared/helpers.h				\
+ 	shared/matrix.c					\
+ 	shared/matrix.h					\
+@@ -677,7 +679,9 @@ nodist_weston_simple_configure_mtk_SOURCES =               \
+         protocol/fullscreen-shell-unstable-v1-protocol.c        \
+         protocol/fullscreen-shell-unstable-v1-client-protocol.h \
+         protocol/linux-dmabuf-unstable-v1-protocol.c		\
+-        protocol/linux-dmabuf-unstable-v1-client-protocol.h
++        protocol/linux-dmabuf-unstable-v1-client-protocol.h  \
++        protocol/weston-configure-mtk-protocol.c		\
++        protocol/weston-configure-mtk-client-protocol.h
+ weston_simple_configure_mtk_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
+ weston_simple_configure_mtk_LDADD =  $(EGL_LIBS) $(LIBDRM_LIBS) libtoytoolkit.la
+ BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
+diff --git a/compositor/main.c b/compositor/main.c
+index b5b4fc5..21c501c 100644
+--- a/compositor/main.c
++++ b/compositor/main.c
+@@ -52,6 +52,7 @@
+ #include "git-version.h"
+ #include "version.h"
+ #include "weston.h"
++#include "../libweston/weston-configure-mtk.h"
+ 
+ #include "compositor-drm.h"
+ #include "compositor-headless.h"
+diff --git a/libweston/compositor.h b/libweston/compositor.h
+index 8736691..ba577b7 100644
+--- a/libweston/compositor.h
++++ b/libweston/compositor.h
+@@ -1362,6 +1362,16 @@ struct weston_surface_state {
+ 	struct weston_buffer_viewport buffer_viewport;
+ };
+ 
++/*
++ * For setting whether the views on this surface walk
++ * overlay path; on==>1, off==>0
++*/
++struct config_switch{
++	struct wl_resource *resource;
++	void *private;
++	int sprites_switch;
++};
++
+ struct weston_surface_activation_data {
+ 	struct weston_surface *surface;
+ 	struct weston_seat *seat;
+@@ -1483,6 +1493,7 @@ struct weston_surface {
+ 
+ 	/* An list of per seat pointer constraints. */
+ 	struct wl_list pointer_constraints;
++	struct config_switch *config_switch;
+ };
+ 
+ struct weston_subsurface {
+diff --git a/libweston/weston-configure-mtk.c b/libweston/weston-configure-mtk.c
+new file mode 100644
+index 0000000..185f91c
+--- /dev/null
++++ b/libweston/weston-configure-mtk.c
+@@ -0,0 +1,125 @@
++#include "config.h"
++#include <fcntl.h>
++#include <stdio.h>
++#include <string.h>
++#include <stdlib.h>
++#include <stdint.h>
++#include <limits.h>
++#include <stdarg.h>
++#include <assert.h>
++#include <sys/ioctl.h>
++#include <sys/mman.h>
++#include <sys/wait.h>
++#include <sys/socket.h>
++#include <sys/utsname.h>
++#include <sys/stat.h>
++#include <unistd.h>
++#include <math.h>
++#include <linux/input.h>
++#include <dlfcn.h>
++#include <signal.h>
++#include <setjmp.h>
++#include <sys/time.h>
++#include <time.h>
++#include <errno.h>
++
++#include "timeline.h"
++
++#include "compositor.h"
++//#include "scaler-server-protocol.h"
++#include "shared/helpers.h"
++#include "shared/os-compatibility.h"
++#include "shared/timespec-util.h"
++#include "git-version.h"
++#include "version.h"
++
++#include "weston-configure-mtk.h"
++#include "weston-configure-mtk-server-protocol.h"
++
++static void
++config_set_sprite_switch(struct wl_client *client,
++	       struct wl_resource *resource,
++	       int32_t spr_switch)
++{
++	struct config_switch *configure = wl_resource_get_user_data(resource);
++
++	configure->sprites_switch = spr_switch;
++}
++
++static const struct config_switch_set_interface switch_set_interface = {
++	config_set_sprite_switch,
++};
++
++static struct config_switch *
++config_interface_create(struct weston_surface *surface)
++{
++	struct config_switch *config_switch;
++
++	config_switch = zalloc(sizeof *config_switch);
++	if (config_switch == NULL)
++		return NULL;
++
++	config_switch->private = (void *)surface;
++	surface->config_switch = config_switch;
++
++	return config_switch;
++}
++
++static void
++config_switch_connect(struct wl_client *client, struct wl_resource *resource,
++	struct wl_resource *wl_surface, uint32_t id)
++{
++	struct config_switch *config_switch = wl_resource_get_user_data(resource);
++	struct weston_surface *surface = wl_resource_get_user_data(wl_surface);
++
++	config_switch = config_interface_create(surface);
++	if (config_switch == NULL) {
++		wl_resource_post_no_memory(resource);
++		return;
++	}
++
++	config_switch->resource =
++		wl_resource_create(client, &config_switch_set_interface,
++				   wl_resource_get_version(resource), id);
++	if (config_switch->resource == NULL) {
++		wl_resource_post_no_memory(resource);
++		return;
++	}
++	wl_resource_set_implementation(config_switch->resource, &switch_set_interface,
++				       config_switch, NULL);
++}
++
++static const struct config_switch_interface switch_interface = {
++	config_switch_connect,
++};
++
++static void
++bind_config_switch(struct wl_client *client,
++		void *data, uint32_t version, uint32_t id)
++{
++	struct weston_compositor *compositor = data;
++	struct wl_resource *resource;
++
++	resource = wl_resource_create(client, &config_switch_interface,
++				      MIN(version, 1), id);
++	if (resource == NULL) {
++		wl_client_post_no_memory(client);
++		return;
++	}
++
++	wl_resource_set_implementation(resource, &switch_interface,
++				       compositor, NULL);
++}
++
++WL_EXPORT int
++config_switch_global_create(struct weston_compositor *ec)
++{
++	if(!ec)
++		return -1;
++	if (!wl_global_create(ec->wl_display, &config_switch_interface, 1,
++			  ec, bind_config_switch)){
++		fprintf(stderr, "error: failed to config_switch_global_create: %s\n", dlerror());
++		return -1;
++	}
++	return 0;
++}
+diff --git a/libweston/weston-configure-mtk.h b/libweston/weston-configure-mtk.h
+new file mode 100644
+index 0000000..0f093fe
+--- /dev/null
++++ b/libweston/weston-configure-mtk.h
+@@ -0,0 +1,53 @@
++/*
++ * Copyright © 2008-2011 Kristian Høgsberg
++ * Copyright © 2012 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.
++ */
++
++#ifndef _APP_CONFIGURE_EXTENSION_H_
++#define _APP_CONFIGURE_EXTENSION_H_
++
++#ifdef  __cplusplus
++extern "C" {
++#endif
++
++#include <stdbool.h>
++#include <time.h>
++#include <pixman.h>
++#include <xkbcommon/xkbcommon.h>
++
++#include <wayland-server.h>
++
++#include "version.h"
++#include "matrix.h"
++#include "config-parser.h"
++#include "zalloc.h"
++#include "timeline-object.h"
++
++int config_switch_global_create(struct weston_compositor *ec);
++
++#ifdef  __cplusplus
++}
++#endif
++
++#endif
+-- 
+2.6.4
+
diff --git a/debian/patches/0009-force-weston-to-use-card0.patch b/debian/patches/0009-force-weston-to-use-card0.patch
new file mode 100644
index 0000000..087f29f
--- /dev/null
+++ b/debian/patches/0009-force-weston-to-use-card0.patch
@@ -0,0 +1,21 @@
+diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
+index 38911763..e4d06806 100644
+--- a/libweston/compositor-drm.c
++++ b/libweston/compositor-drm.c
+@@ -6405,7 +6405,7 @@ find_primary_gpu(struct drm_backend *b, const char *seat)
+ 
+ 	e = udev_enumerate_new(b->udev);
+ 	udev_enumerate_add_match_subsystem(e, "drm");
+-	udev_enumerate_add_match_sysname(e, "card[0-9]*");
++	udev_enumerate_add_match_sysname(e, "card0");
+ 
+ 	udev_enumerate_scan_devices(e);
+ 	drm_device = NULL;
+@@ -6786,7 +6786,6 @@ drm_backend_create(struct weston_compositor *compositor,
+ 			    compositor, b->udev, seat_id,
+ 			    config->configure_device) < 0) {
+ 		weston_log("failed to create input devices\n");
+-		goto err_sprite;
+ 	}
+ 
+ 	if (drm_backend_create_heads(b, drm_device) < 0) {
diff --git a/debian/patches/reproducible-build-899358.patch b/debian/patches/reproducible-build-899358.patch
new file mode 100644
index 0000000..642c9df
--- /dev/null
+++ b/debian/patches/reproducible-build-899358.patch
@@ -0,0 +1,14 @@
+https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=899358
+Index: weston/weston.ini.in
+===================================================================
+--- weston.orig/weston.ini.in	2019-03-28 12:55:11.730324981 +0100
++++ weston/weston.ini.in	2019-03-28 12:58:53.029372855 +0100
+@@ -38,7 +38,7 @@
+ 
+ [launcher]
+ icon=/usr/share/icons/gnome/24x24/apps/arts.png
+-path=@abs_top_builddir@/weston-flower
++path=@libexecdir@/weston-flower
+ 
+ [input-method]
+ path=@libexecdir@/weston-keyboard
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..1bab16b
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,12 @@
+reproducible-build-899358.patch
+0001-mtk-make-error-portable.patch
+0001-PATCH-1-9-hmi-controller-use-output_w-h-instead-of-c.patch
+0002-PATCH-2-9-libinput-fix-issue-for-touch_event-cause-w.patch
+0003-PATCH-3-9-compose-engine-turn-to-pixman-if-gl-init-f.patch
+0004-PATCH-4-9-weston-do-not-check-master-fd-for-DRM-driv.patch
+0005-PATCH-5-9-weston-install-client-protocol-to-sysroot-.patch
+0006-PATCH-7-9-weston-screen-shot-add-screen-shot.patch
+0007-PATCH-weston-add-mtk-test-client.patch
+0008-PATCH-weston-add-surface-overlay-assignment-interfac.patch
+0009-force-weston-to-use-card0.patch
+0001-add-switch_config.patch