[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-openchrome: Changes to 'upstream-unstable'



 NEWS                 |   22 +++++
 configure.ac         |   83 ++++---------------
 src/Makefile.am      |   21 ++--
 src/drm_fourcc.h     |  130 ++++++++++++++++++++++++++++++
 src/via_ch7xxx.c     |    2 
 src/via_ch7xxx.h     |    4 
 src/via_display.c    |   61 +++++++++-----
 src/via_dri.c        |    2 
 src/via_driver.c     |  214 +++++++++++++++++++++++++++++++------------------
 src/via_driver.h     |   29 +++---
 src/via_drm.h        |    4 
 src/via_eng_regs.h   |    2 
 src/via_exa.c        |   77 ++++++++++-------
 src/via_exa_h2.c     |   25 ++---
 src/via_exa_h6.c     |   42 ++++++---
 src/via_i2c.c        |    4 
 src/via_id.c         |   24 +++--
 src/via_kms.c        |  221 ++++++++++-----------------------------------------
 src/via_kms.h        |   11 ++
 src/via_lvds.c       |   13 +++
 src/via_memmgr.c     |   48 ++++++++---
 src/via_memmgr.h     |    4 
 src/via_outputs.c    |   73 +++++++++++++++-
 src/via_priv.h       |    2 
 src/via_ums.c        |   66 +++++++--------
 src/via_ums.h        |    5 -
 src/via_vbe.c        |    2 
 src/via_vgahw.c      |    6 -
 src/via_vgahw.h      |    1 
 src/via_vt162x.c     |   50 ++++++++---
 src/via_vt162x.h     |    5 -
 src/via_xv.c         |   33 ++++---
 src/via_xv_overlay.c |   15 +--
 src/via_xvmc.c       |    4 
 src/xvmc/xf86dri.c   |   14 ++-
 tools/registers.c    |   86 ++++++++++++-------
 36 files changed, 831 insertions(+), 574 deletions(-)

New commits:
commit 0c17f81ad43d42958ab3871c9b5c5e9cea402256
Author: Xavier Bachelot <xavier@bachelot.org>
Date:   Wed May 22 18:58:48 2013 +0200

    Bump version to 0.3.3

diff --git a/NEWS b/NEWS
index 917aea0..eb1b8f8 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+openchrome 0.3.3 (23/05/2013)
+-----------------------------
+
+This is a bugfix release.
+- Fix integer overflow in libchromeXvMC (CVE-2013-1994).
+- Various bug fixes and improvements.
+
+
 openchrome 0.3.2 (27/03/2013)
 -----------------------------
 
diff --git a/configure.ac b/configure.ac
index 238e3af..b13cb2c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-openchrome],
-        [0.3.2],
+        [0.3.3],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/openchrome],
         [xf86-video-openchrome])
 

commit db309e3cd87a1279e8b592a692390755c528de4f
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Sat Apr 13 20:57:07 2013 -0700

    integer overflow in uniDRIGetClientDriverName() in libchromeXvMC* [CVE-2013-1994 2/2]
    
    clientDriverNameLength is a CARD32 and needs to be bounds checked before
    adding one to it to come up with the total size to allocate, to avoid
    integer overflow leading to underallocation and writing data from the
    network past the end of the allocated buffer.
    
    Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/src/xvmc/xf86dri.c b/src/xvmc/xf86dri.c
index fba7583..c5702ec 100644
--- a/src/xvmc/xf86dri.c
+++ b/src/xvmc/xf86dri.c
@@ -314,8 +314,11 @@ uniDRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion,
     *ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
 
     if (rep.length) {
-	if (!(*clientDriverName =
-		(char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) {
+	if (rep.clientDriverNameLength < INT_MAX)
+	    *clientDriverName = Xcalloc(rep.clientDriverNameLength + 1, 1);
+	else
+	    *clientDriverName = NULL;
+	if (*clientDriverName == NULL) {
 	    _XEatData(dpy, ((rep.clientDriverNameLength + 3) & ~3));
 	    UnlockDisplay(dpy);
 	    SyncHandle();

commit 68bf50ce4903ec93da59cea78e063ed7c3882d3e
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Sat Apr 13 20:49:43 2013 -0700

    integer overflow in uniDRIOpenConnection() in libchromeXvMC* [CVE-2013-1994 1/2]
    
    busIdStringLength is a CARD32 and needs to be bounds checked before adding
    one to it to come up with the total size to allocate, to avoid integer
    overflow leading to underallocation and writing data from the network past
    the end of the allocated buffer.
    
    Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/src/xvmc/xf86dri.c b/src/xvmc/xf86dri.c
index 1feb232..fba7583 100644
--- a/src/xvmc/xf86dri.c
+++ b/src/xvmc/xf86dri.c
@@ -42,6 +42,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <X11/extensions/Xext.h>
 #include <X11/extensions/extutil.h>
 #include "xf86dristr.h"
+#include <limits.h>
 
 static XExtensionInfo _xf86dri_info_data;
 static XExtensionInfo *xf86dri_info = &_xf86dri_info_data;
@@ -203,7 +204,11 @@ uniDRIOpenConnection(dpy, screen, hSAREA, busIdString)
     }
 #endif
     if (rep.length) {
-	if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) {
+	if (rep.busIdStringLength < INT_MAX)
+	    *busIdString = Xcalloc(rep.busIdStringLength + 1, 1);
+	else
+	    *busIdString = NULL;
+	if (*busIdString == NULL) {
 	    _XEatData(dpy, ((rep.busIdStringLength + 3) & ~3));
 	    UnlockDisplay(dpy);
 	    SyncHandle();

commit 50cef9490c6a128613c5b9f3f19ef2e803088983
Author: Xavier Bachelot <xavier@bachelot.org>
Date:   Tue May 21 21:24:41 2013 +0200

    Probe TV encoder on all but the P4M900, unless we know the board has a TV encoder.
    
    Probing the TV encoder on the P4M900 chipset family when there is no such encoder is not safe. It is safe however on all other platforms.

diff --git a/src/via_outputs.c b/src/via_outputs.c
index 7e0c5e4..1271fc8 100644
--- a/src/via_outputs.c
+++ b/src/via_outputs.c
@@ -885,7 +885,7 @@ ViaOutputsDetect(ScrnInfoPtr pScrn)
      * disables the panel on P4M900
      */
     /* TV encoder */
-    if (pVia->ActiveDevice & VIA_DEVICE_TV)
+    if ((pVia->Chipset != VIA_P4M900) || (pVia->ActiveDevice & VIA_DEVICE_TV))
         via_tv_init(pScrn);
 
     if (pVia->ActiveDevice & VIA_DEVICE_DFP) {

commit 79731f58281eb8782f8291a3d9375cb3f7691a13
Author: James Simmons <jsimmons@infradead.org>
Date:   Wed May 22 10:47:25 2013 -0400

    Our xorg driver has moved to using drm_fourcc.h but not all distros have a new enough libdrm so building can fail. We place a copy in our source tree to ensure building and this header doesn't change to often

diff --git a/src/Makefile.am b/src/Makefile.am
index 9bac9e9..7f67bed 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -83,7 +83,8 @@ openchrome_drv_la_SOURCES += \
          via_kms.h \
          via_kms.c \
          via_xvmc.c \
-         via_xvmc.h
+         via_xvmc.h \
+         drm_fourcc.h
 else
 EXTRA_DIST += \
          via_dri.c \
@@ -93,7 +94,8 @@ EXTRA_DIST += \
          via_kms.h \
          via_kms.c \
          via_xvmc.c \
-         via_xvmc.h
+         via_xvmc.h \
+         drm_fourcc.h
 endif
 
 via_driver.lo: version.h
diff --git a/src/drm_fourcc.h b/src/drm_fourcc.h
new file mode 100644
index 0000000..85facb0
--- /dev/null
+++ b/src/drm_fourcc.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2011 Intel Corporation
+ *
+ * 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
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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 DRM_FOURCC_H
+#define DRM_FOURCC_H
+
+#include <inttypes.h>
+
+#define fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
+			      ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
+
+#define DRM_FORMAT_BIG_ENDIAN (1<<31) /* format is big endian instead of little endian */
+
+/* color index */
+#define DRM_FORMAT_C8		fourcc_code('C', '8', ' ', ' ') /* [7:0] C */
+
+/* 8 bpp RGB */
+#define DRM_FORMAT_RGB332	fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */
+#define DRM_FORMAT_BGR233	fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */
+
+/* 16 bpp RGB */
+#define DRM_FORMAT_XRGB4444	fourcc_code('X', 'R', '1', '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */
+#define DRM_FORMAT_XBGR4444	fourcc_code('X', 'B', '1', '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */
+#define DRM_FORMAT_RGBX4444	fourcc_code('R', 'X', '1', '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */
+#define DRM_FORMAT_BGRX4444	fourcc_code('B', 'X', '1', '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */
+
+#define DRM_FORMAT_ARGB4444	fourcc_code('A', 'R', '1', '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */
+#define DRM_FORMAT_ABGR4444	fourcc_code('A', 'B', '1', '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */
+#define DRM_FORMAT_RGBA4444	fourcc_code('R', 'A', '1', '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */
+#define DRM_FORMAT_BGRA4444	fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */
+
+#define DRM_FORMAT_XRGB1555	fourcc_code('X', 'R', '1', '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */
+#define DRM_FORMAT_XBGR1555	fourcc_code('X', 'B', '1', '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */
+#define DRM_FORMAT_RGBX5551	fourcc_code('R', 'X', '1', '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */
+#define DRM_FORMAT_BGRX5551	fourcc_code('B', 'X', '1', '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */
+
+#define DRM_FORMAT_ARGB1555	fourcc_code('A', 'R', '1', '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */
+#define DRM_FORMAT_ABGR1555	fourcc_code('A', 'B', '1', '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */
+#define DRM_FORMAT_RGBA5551	fourcc_code('R', 'A', '1', '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */
+#define DRM_FORMAT_BGRA5551	fourcc_code('B', 'A', '1', '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */
+
+#define DRM_FORMAT_RGB565	fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */
+#define DRM_FORMAT_BGR565	fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */
+
+/* 24 bpp RGB */
+#define DRM_FORMAT_RGB888	fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */
+#define DRM_FORMAT_BGR888	fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */
+
+/* 32 bpp RGB */
+#define DRM_FORMAT_XRGB8888	fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */
+#define DRM_FORMAT_XBGR8888	fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */
+#define DRM_FORMAT_RGBX8888	fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */
+#define DRM_FORMAT_BGRX8888	fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */
+
+#define DRM_FORMAT_ARGB8888	fourcc_code('A', 'R', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */
+#define DRM_FORMAT_ABGR8888	fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */
+#define DRM_FORMAT_RGBA8888	fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */
+#define DRM_FORMAT_BGRA8888	fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */
+
+#define DRM_FORMAT_XRGB2101010	fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */
+#define DRM_FORMAT_XBGR2101010	fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */
+#define DRM_FORMAT_RGBX1010102	fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */
+#define DRM_FORMAT_BGRX1010102	fourcc_code('B', 'X', '3', '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */
+
+#define DRM_FORMAT_ARGB2101010	fourcc_code('A', 'R', '3', '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */
+#define DRM_FORMAT_ABGR2101010	fourcc_code('A', 'B', '3', '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */
+#define DRM_FORMAT_RGBA1010102	fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */
+#define DRM_FORMAT_BGRA1010102	fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */
+
+/* packed YCbCr */
+#define DRM_FORMAT_YUYV		fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */
+#define DRM_FORMAT_YVYU		fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */
+#define DRM_FORMAT_UYVY		fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */
+#define DRM_FORMAT_VYUY		fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */
+
+#define DRM_FORMAT_AYUV		fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
+
+/*
+ * 2 plane YCbCr
+ * index 0 = Y plane, [7:0] Y
+ * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian
+ * or
+ * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian
+ */
+#define DRM_FORMAT_NV12		fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */
+#define DRM_FORMAT_NV21		fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */
+#define DRM_FORMAT_NV16		fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */
+#define DRM_FORMAT_NV61		fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */
+
+/*
+ * 3 plane YCbCr
+ * index 0: Y plane, [7:0] Y
+ * index 1: Cb plane, [7:0] Cb
+ * index 2: Cr plane, [7:0] Cr
+ * or
+ * index 1: Cr plane, [7:0] Cr
+ * index 2: Cb plane, [7:0] Cb
+ */
+#define DRM_FORMAT_YUV410	fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */
+#define DRM_FORMAT_YVU410	fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */
+#define DRM_FORMAT_YUV411	fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */
+#define DRM_FORMAT_YVU411	fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */
+#define DRM_FORMAT_YUV420	fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */
+#define DRM_FORMAT_YVU420	fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */
+#define DRM_FORMAT_YUV422	fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */
+#define DRM_FORMAT_YVU422	fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */
+#define DRM_FORMAT_YUV444	fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */
+#define DRM_FORMAT_YVU444	fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */
+
+#endif /* DRM_FOURCC_H */

commit a013a7deabc63dd76d3ae635e05c9da4a5fc321b
Author: James Simmons <jsimmons@infradead.org>
Date:   Mon May 20 18:13:24 2013 -0400

    Patch from Krummenacher <max.krummenacher@toradex.com>
    to fix via_lvds.c warning, char* compared to string literal
    
    gcc 4.7.2 issues a warning which make 'open suse build system' fail.
    via_lvds.c: In function 'via_lvds_detect':
    via_lvds.c:1305:26: warning: comparison with string literal results in unspecified behavior [-Waddress]

diff --git a/src/via_driver.c b/src/via_driver.c
index 1d3b78e..139a0c3 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -874,18 +874,25 @@ via_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
         ret = xf86CrtcSetMode(crtc, &crtc->mode, crtc->rotation,
 	                          crtc->x, crtc->y);
         if (!ret) {
+            xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                "SetMode !ret so we reset front_bo\n");
             drmmode->front_bo = old_front;
             drmmode->fb_id = old_fb_id;
             break;
 #ifdef HAVE_DRI
         } else {
+            xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                "SetMode ret so we cleanup old front_bo\n");
             if (pVia->KMS && old_fb_id)
                 drmModeRmFB(drmmode->fd, old_fb_id);
 #endif
         }
     }
 
+
     if (ret) {
+        xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                   "More cleanup old front_bo\n");
         drm_bo_unmap(scrn, old_front);
         drm_bo_free(scrn, old_front);
         return ret;
diff --git a/src/via_lvds.c b/src/via_lvds.c
index e4e5cdf..0dcc64a 100644
--- a/src/via_lvds.c
+++ b/src/via_lvds.c
@@ -1295,6 +1295,7 @@ ViaPanelLookUpModeIndex(int width, int height)
 static xf86OutputStatus
 via_lvds_detect(xf86OutputPtr output)
 {
+    static const char xoId[] = "OLPC XO 1.5";
     xf86OutputStatus status = XF86OutputStatusDisconnected;
     ViaPanelInfoPtr panel = output->driver_private;
     ScrnInfoPtr pScrn = output->scrn;
@@ -1302,7 +1303,7 @@ via_lvds_detect(xf86OutputPtr output)
     vgaHWPtr hwp = VGAHWPTR(pScrn);
 
     /* Hardcode panel size for the XO */
-    if (pVia->Id->String == "OLPC XO 1.5") {
+    if(strcmp(pVia->Id->String, xoId) == 0) {
         panel->NativeWidth = 1200;
         panel->NativeHeight = 900;
         status = XF86OutputStatusConnected;

commit cee0a1fab9cade87e6de16c67cd34c84cf697531
Author: James Simmons <jsimmons@infradead.org>
Date:   Sun May 19 17:18:39 2013 -0400

    Fix the problems with UMS multiple screen handling. KMS still has problems

diff --git a/src/via_display.c b/src/via_display.c
index 82cd8b2..d9b6db5 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -470,8 +470,11 @@ ViaFirstCRTCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
 }
 
 void
-ViaFirstCRTCSetStartingAddress(ScrnInfoPtr pScrn, int x, int y)
+ViaFirstCRTCSetStartingAddress(xf86CrtcPtr crtc, int x, int y)
 {
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
+    ScrnInfoPtr pScrn = crtc->scrn;
     VIAPtr pVia = VIAPTR(pScrn);
     vgaHWPtr hwp = VGAHWPTR(pScrn);
     CARD32 Base;
@@ -479,7 +482,7 @@ ViaFirstCRTCSetStartingAddress(ScrnInfoPtr pScrn, int x, int y)
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaFirstCRTCSetStartingAddress\n"));
 
     Base = (y * pScrn->displayWidth + x) * (pScrn->bitsPerPixel / 8);
-    Base = (Base + pVia->drmmode.front_bo->offset) >> 1;
+    Base = (Base + drmmode->front_bo->offset) >> 1;
 
     hwp->writeCrtc(hwp, 0x0C, (Base & 0xFF00) >> 8);
     hwp->writeCrtc(hwp, 0x0D, Base & 0xFF);
@@ -491,14 +494,16 @@ ViaFirstCRTCSetStartingAddress(ScrnInfoPtr pScrn, int x, int y)
 }
 
 void
-ViaSecondCRTCSetStartingAddress(ScrnInfoPtr pScrn, int x, int y)
+ViaSecondCRTCSetStartingAddress(xf86CrtcPtr crtc, int x, int y)
 {
-    VIAPtr pVia = VIAPTR(pScrn);
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
+    ScrnInfoPtr pScrn = crtc->scrn;
     vgaHWPtr hwp = VGAHWPTR(pScrn);
     CARD32 Base, tmp;
 
     Base = (y * pScrn->displayWidth + x) * (pScrn->bitsPerPixel / 8);
-    Base = (Base + pVia->drmmode.front_bo->offset) >> 3;
+    Base = (Base + drmmode->front_bo->offset) >> 3;
 
     tmp = hwp->readCrtc(hwp, 0x62) & 0x01;
     tmp |= (Base & 0x7F) << 1;
@@ -954,7 +959,7 @@ iga1_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
     if (pVia->pVbe) {
         ViaVbeAdjustFrame(pScrn, x, y);
     } else {
-        ViaFirstCRTCSetStartingAddress(pScrn, x, y);
+        ViaFirstCRTCSetStartingAddress(crtc, x, y);
     }
     VIAVidAdjustFrame(pScrn, x, y);
 }
@@ -1365,7 +1370,7 @@ iga2_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
     if (pVia->pVbe) {
         ViaVbeAdjustFrame(pScrn, x, y);
     } else {
-        ViaSecondCRTCSetStartingAddress(pScrn, x, y);
+        ViaSecondCRTCSetStartingAddress(crtc, x, y);
     }
     VIAVidAdjustFrame(pScrn, x, y);
 }
diff --git a/src/via_driver.c b/src/via_driver.c
index 52a5bea..1d3b78e 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -805,54 +805,44 @@ static Bool
 via_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 {
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-    drmmode_crtc_private_ptr drmmode_crtc = xf86_config->crtc[0]->driver_private;
+    struct buffer_object *old_front = NULL, *new_front = NULL;
     int old_width, old_height, old_dwidth, format;
-    drmmode_ptr drmmode = drmmode_crtc->drmmode;
-    int cpp = (scrn->bitsPerPixel + 7) >> 3;
-    struct buffer_object *old_front = NULL;
+    int cpp = (scrn->bitsPerPixel + 7) >> 3, i;
     ScreenPtr screen = scrn->pScreen;
     VIAPtr pVia = VIAPTR(scrn);
     void *new_pixels = NULL;
     uint32_t old_fb_id;
+    Bool ret = FALSE;
     PixmapPtr ppix;
 
     if (scrn->virtualX == width && scrn->virtualY == height)
         return TRUE;
 
-    old_width = scrn->virtualX;
-    old_height = scrn->virtualY;
-    old_dwidth = scrn->displayWidth;
-    old_fb_id = drmmode->fb_id;
-    old_front = drmmode->front_bo;
-
     format = map_legacy_formats(scrn->bitsPerPixel, scrn->depth);
-    drmmode->front_bo = drm_bo_alloc_surface(scrn, width, height, format,
+    new_front = drm_bo_alloc_surface(scrn, width, height, format,
                                             16, TTM_PL_FLAG_VRAM);
-    if (!drmmode->front_bo)
+    if (!new_front)
         goto fail;
 
     xf86DrvMsg(scrn->scrnIndex, X_INFO,
                 "Allocate new frame buffer %dx%d stride %d\n",
-                width, height, drmmode->front_bo->pitch);
+                width, height, new_front->pitch);
 
-    new_pixels = drm_bo_map(scrn, drmmode->front_bo);
+    new_pixels = drm_bo_map(scrn, new_front);
     if (!new_pixels)
         goto fail;
 
     if (pVia->shadowFB) {
-        new_pixels = malloc(height * drmmode->front_bo->pitch);
+        new_pixels = malloc(height * new_front->pitch);
         if (!new_pixels)
             goto fail;
         free(pVia->ShadowPtr);
         pVia->ShadowPtr = new_pixels;
     }
-    scrn->virtualX = width;
-    scrn->virtualY = height;
-    scrn->displayWidth = drmmode->front_bo->pitch / cpp;
 
     ppix = screen->GetScreenPixmap(screen);
     if (!screen->ModifyPixmapHeader(ppix, width, height, -1, -1,
-                                    drmmode->front_bo->pitch,
+                                    new_front->pitch,
                                     new_pixels))
         goto fail;
 
@@ -860,25 +850,52 @@ via_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
     scrn->pixmapPrivate.ptr = ppix->devPrivate.ptr;
 #endif
 
-    if (xf86SetDesiredModes(scrn)) {
-        if (old_front) {
+    scrn->virtualX = width;
+    scrn->virtualY = height;
+    scrn->displayWidth = new_front->pitch / cpp;
+
+    for (i = 0; i < xf86_config->num_crtc; i++) {
+        xf86CrtcPtr crtc = xf86_config->crtc[i];
+        drmmode_crtc_private_ptr drmmode_crtc;
+        drmmode_ptr drmmode;
+
+        if (!crtc->enabled || !crtc->driver_private)
+            continue;
+
+        drmmode_crtc = crtc->driver_private;
+        drmmode = drmmode_crtc->drmmode;
+
+        old_front = drmmode->front_bo;
+        old_fb_id = drmmode->fb_id;
+
+        drmmode->front_bo = new_front;
+        drmmode->fb_id = 0;
+
+        ret = xf86CrtcSetMode(crtc, &crtc->mode, crtc->rotation,
+	                          crtc->x, crtc->y);
+        if (!ret) {
+            drmmode->front_bo = old_front;
+            drmmode->fb_id = old_fb_id;
+            break;
 #ifdef HAVE_DRI
-            if (old_fb_id && pVia->KMS)
+        } else {
+            if (pVia->KMS && old_fb_id)
                 drmModeRmFB(drmmode->fd, old_fb_id);
 #endif
-            drm_bo_unmap(scrn, old_front);
-            drm_bo_free(scrn, old_front);
         }
-        return TRUE;
+    }
+
+    if (ret) {
+        drm_bo_unmap(scrn, old_front);
+        drm_bo_free(scrn, old_front);
+        return ret;
     }
 
 fail:
-    if (drmmode->front_bo) {
-        drm_bo_unmap(scrn, drmmode->front_bo);
-        drm_bo_free(scrn, drmmode->front_bo);
+    if (new_front) {
+        drm_bo_unmap(scrn, new_front);
+        drm_bo_free(scrn, new_front);
     }
-    drmmode->front_bo = old_front;
-    drmmode->fb_id = old_fb_id;
     scrn->virtualY = old_height;
     scrn->virtualX = old_width;
     scrn->displayWidth = old_dwidth;
diff --git a/src/via_ums.h b/src/via_ums.h
index 411d52d..dee43fa 100644
--- a/src/via_ums.h
+++ b/src/via_ums.h
@@ -222,9 +222,9 @@ void ViaSetUseExternalClock(vgaHWPtr hwp);
 /* via_display.c */
 Bool UMSCrtcInit(ScrnInfoPtr pScrn);
 void ViaCRTCInit(ScrnInfoPtr pScrn);
-void ViaFirstCRTCSetStartingAddress(ScrnInfoPtr pSCrn, int x, int y);
+void ViaFirstCRTCSetStartingAddress(xf86CrtcPtr crtc, int x, int y);
 void ViaFirstCRTCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode);
-void ViaSecondCRTCSetStartingAddress(ScrnInfoPtr pScrn, int x, int y);
+void ViaSecondCRTCSetStartingAddress(xf86CrtcPtr crtc, int x, int y);
 void ViaSecondCRTCHorizontalOffset(ScrnInfoPtr pScrn);
 void ViaSecondCRTCHorizontalQWCount(ScrnInfoPtr pScrn, int width);
 void ViaSecondCRTCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode);

commit 42d7ac70e3e9735619690a86482954827936d169
Author: James Simmons <jsimmons@infradead.org>
Date:   Sun May 19 15:13:28 2013 -0400

    In our driver in order to support both KMS and UMS we can't call drmmode_set_mode_major directly but instead
    call xf86CrtcSetMode or alike functions. All those xorg methods are wrappers around xf86CrtcSetModeTransform
    which does the handling of restoring the mode in failure cases. If you look at drmmode_set_mode_major it also
    does the the same error handling because the was copied from drivers that directly called it. Since this is
    not the case for us we can make drmmode_set_mode_major much simpler and depend on xf86CrtcSetModeTransform to
    handle failures for us.

diff --git a/src/via_kms.c b/src/via_kms.c
index c0e8b52..9547d5d 100644
--- a/src/via_kms.c
+++ b/src/via_kms.c
@@ -160,120 +160,79 @@ static Bool
 drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
                         Rotation rotation, int x, int y)
 {
-    ScrnInfoPtr pScrn = crtc->scrn;
-    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
     drmmode_ptr drmmode = drmmode_crtc->drmmode;
-    int saved_x, saved_y;
-    Rotation saved_rotation;
-    DisplayModeRec saved_mode;
-    uint32_t *output_ids;
-    int output_count = 0;
-    Bool ret = TRUE;
-    int i;
-    int fb_id;
+    ScrnInfoPtr pScrn = crtc->scrn;
+    int output_count = 0, ret, i;
+    uint32_t *output_ids = NULL;
     drmModeModeInfo kmode;
-    int height;
 
-    height = pScrn->virtualY;
+    if (!mode || !xf86CrtcRotate(crtc))
+        return FALSE;
+
+    output_ids = calloc(sizeof(uint32_t), xf86_config->num_output);
+    if (!output_ids)
+        return FALSE;
+
+    for (i = 0; i < xf86_config->num_output; i++) {
+        xf86OutputPtr output = xf86_config->output[i];
+        drmmode_output_private_ptr drmmode_output;
+
+        if (output->crtc != crtc)
+            continue;
+
+        drmmode_output = output->driver_private;
+        output_ids[output_count] = drmmode_output->mode_output->connector_id;
+        output_count++;
+    }
+
+    xf86SetModeDefaultName(mode);
+    drmmode_ConvertToKMode(crtc->scrn, &kmode, mode);
 
     if (drmmode->fb_id == 0) {
-        ret = drmModeAddFB(drmmode->fd, pScrn->virtualX, height,
+        ret = drmModeAddFB(drmmode->fd, pScrn->virtualX, pScrn->virtualY,
                             pScrn->depth, pScrn->bitsPerPixel,
                             drmmode->front_bo->pitch,
                             drmmode->front_bo->handle,
                             &drmmode->fb_id);
         if (ret < 0) {
             ErrorF("failed to add fb %d\n", ret);
-            return FALSE;
+            goto done;
         }
     }
 
-    saved_mode = crtc->mode;
-    saved_x = crtc->x;
-    saved_y = crtc->y;
-    saved_rotation = crtc->rotation;
-
-    if (mode) {
-        crtc->mode = *mode;
-        crtc->x = x;
-        crtc->y = y;
-        crtc->rotation = rotation;
-#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,5,99,0,0)
-        crtc->transformPresent = FALSE;
-#endif
-    }
-
-    output_ids = calloc(sizeof(uint32_t), xf86_config->num_output);
-    if (!output_ids) {
-        ret = FALSE;
+    ret = drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+                         drmmode->fb_id, x, y, output_ids, output_count, &kmode);
+    if (ret) {
+        xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR, "failed to set mode: %s",
+                   strerror(-ret));
         goto done;
     }
 
-    if (mode) {
-        for (i = 0; i < xf86_config->num_output; i++) {
-            xf86OutputPtr output = xf86_config->output[i];
-            drmmode_output_private_ptr drmmode_output;
+    if (crtc->scrn->pScreen)
+        xf86CrtcSetScreenSubpixelOrder(crtc->scrn->pScreen);
 
-            if (output->crtc != crtc)
-                continue;
+    /* go through all the outputs and force DPMS them back on? */
+    for (i = 0; i < xf86_config->num_output; i++) {
+        xf86OutputPtr output = xf86_config->output[i];
 
-            drmmode_output = output->driver_private;
-            output_ids[output_count] = drmmode_output->mode_output->connector_id;
-            output_count++;
-        }
+        if (output->crtc != crtc)
+            continue;
 
-        if (!xf86CrtcRotate(crtc)) {
-            goto done;
-        }
+        output->funcs->dpms(output, DPMSModeOn);
+    }
 
 #if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,7,0,0,0)
-        crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
-                                crtc->gamma_blue, crtc->gamma_size);
+    crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
+                           crtc->gamma_blue, crtc->gamma_size);
 #endif
-        drmmode_ConvertToKMode(crtc->scrn, &kmode, mode);
-
-        fb_id = drmmode->fb_id;
-        if (drmmode_crtc->rotate_fb_id) {
-            fb_id = drmmode_crtc->rotate_fb_id;
-            x = y = 0;
-        }
-        ret = drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
-                            fb_id, x, y, output_ids, output_count, &kmode);
-        if (ret)
-            xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR, "failed to set mode: %s",
-                        strerror(-ret));
-        else
-            ret = TRUE;
-
-        if (crtc->scrn->pScreen)
-            xf86CrtcSetScreenSubpixelOrder(crtc->scrn->pScreen);
-
-        /* go through all the outputs and force DPMS them back on? */
-        for (i = 0; i < xf86_config->num_output; i++) {
-            xf86OutputPtr output = xf86_config->output[i];
-
-            if (output->crtc != crtc)
-			    continue;
-
-            output->funcs->dpms(output, DPMSModeOn);
-        }
-    }
 
     if (pScrn->pScreen && drmmode->hwcursor)
         xf86_reload_cursors(pScrn->pScreen);
 done:
-    if (!ret) {
-        crtc->x = saved_x;
-        crtc->y = saved_y;
-        crtc->rotation = saved_rotation;
-        crtc->mode = saved_mode;
-    }
-#if defined(XF86_CRTC_VERSION) && XF86_CRTC_VERSION >= 3
-    else
-        crtc->active = TRUE;
-#endif
-	return ret;
+    free(output_ids);
+    return (ret < 0 ? FALSE : TRUE);
 }
 
 static void

commit 541a3c1765e71af91e1319a3ab165ac37a0fd17d
Author: Xavier Bachelot <xavier@bachelot.org>
Date:   Wed Apr 24 19:38:02 2013 +0200

    make iga[12]_crtc_mode_fixup more verbose when the mode is rejected.

diff --git a/src/via_display.c b/src/via_display.c
index 267a9c1..82cd8b2 100644
--- a/src/via_display.c
+++ b/src/via_display.c
@@ -908,16 +908,26 @@ iga1_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
     ScrnInfoPtr pScrn = crtc->scrn;
     VIAPtr pVia = VIAPTR(pScrn);
     CARD32 temp;
+    ModeStatus modestatus;
 
     if (pVia->pVbe)
         return TRUE;
 
     if ((mode->Clock < pScrn->clockRanges->minClock) ||
-        (mode->Clock > pScrn->clockRanges->maxClock))
+        (mode->Clock > pScrn->clockRanges->maxClock)) {
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                   "Clock for mode \"%s\" outside of allowed range (%u (%u - %u))\n",
+                   mode->name, mode->Clock, pScrn->clockRanges->minClock,
+                   pScrn->clockRanges->maxClock);
         return FALSE;
+    }
 
-    if (ViaFirstCRTCModeValid(pScrn, mode) != MODE_OK)
+    modestatus = ViaFirstCRTCModeValid(pScrn, mode);
+    if (modestatus != MODE_OK) {
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Not using mode \"%s\" : %s.\n",
+                   mode->name, xf86ModeStatusToString(modestatus));
         return FALSE;
+    }
 
     temp = mode->CrtcHDisplay * mode->CrtcVDisplay * mode->VRefresh *
             (pScrn->bitsPerPixel >> 3);
@@ -1309,16 +1319,26 @@ iga2_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
     ScrnInfoPtr pScrn = crtc->scrn;
     VIAPtr pVia = VIAPTR(pScrn);
     CARD32 temp;
+    ModeStatus modestatus;
 
     if (pVia->pVbe)
         return TRUE;
 
     if ((mode->Clock < pScrn->clockRanges->minClock) ||
-        (mode->Clock > pScrn->clockRanges->maxClock))
+        (mode->Clock > pScrn->clockRanges->maxClock)) {
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                   "Clock for mode \"%s\" outside of allowed range (%u (%u - %u))\n",
+                   mode->name, mode->Clock, pScrn->clockRanges->minClock,
+                   pScrn->clockRanges->maxClock);
         return FALSE;
+    }
 
-    if (ViaSecondCRTCModeValid(pScrn, mode) != MODE_OK)
+    modestatus = ViaFirstCRTCModeValid(pScrn, mode);
+    if (modestatus != MODE_OK) {
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Not using mode \"%s\" : %s.\n",
+                   mode->name, xf86ModeStatusToString(modestatus));
         return FALSE;
+    }
 
     temp = mode->CrtcHDisplay * mode->CrtcVDisplay * mode->VRefresh *
             (pScrn->bitsPerPixel >> 3);

commit 3808a3b88e474f9549b06388c8bc323c4cb0b4b9
Author: James Simmons <jsimmons@infradead.org>
Date:   Sun Apr 21 10:19:24 2013 -0400

    Integrate the different formats now supported by libdrm. This makes allocating buffers for KMS planes in the future much easier

diff --git a/src/via_driver.c b/src/via_driver.c
index fd91910..52a5bea 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -772,13 +772,42 @@ VIAGetRec(ScrnInfoPtr pScrn)
     return ret;
 } /* VIAGetRec */
 
+static int
+map_legacy_formats(int bpp, int depth)
+{
+	int fmt = DRM_FORMAT_XRGB8888;
+
+	switch (bpp) {
+	case 8:
+		fmt = DRM_FORMAT_C8;
+		break;
+	case 16:
+		if (depth == 15)
+			fmt = DRM_FORMAT_XRGB1555;
+		else
+			fmt = DRM_FORMAT_RGB565;
+		break;
+	case 24:
+		fmt = DRM_FORMAT_RGB888;
+		break;
+	case 32:
+		if (depth == 24)
+			fmt = DRM_FORMAT_XRGB8888;
+		else if (depth == 30)
+			fmt = DRM_FORMAT_XRGB2101010;
+	default:
+		break;
+	}
+	return fmt;
+}
+
 static Bool
 via_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 {
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     drmmode_crtc_private_ptr drmmode_crtc = xf86_config->crtc[0]->driver_private;
+    int old_width, old_height, old_dwidth, format;
     drmmode_ptr drmmode = drmmode_crtc->drmmode;
-    int old_width, old_height, old_dwidth, pitch;
     int cpp = (scrn->bitsPerPixel + 7) >> 3;
     struct buffer_object *old_front = NULL;
     ScreenPtr screen = scrn->pScreen;
@@ -790,28 +819,28 @@ via_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
     if (scrn->virtualX == width && scrn->virtualY == height)
         return TRUE;
 
-    xf86DrvMsg(scrn->scrnIndex, X_INFO,
-                "Allocate new frame buffer %dx%d stride\n",
-                width, height);
-
     old_width = scrn->virtualX;
     old_height = scrn->virtualY;
     old_dwidth = scrn->displayWidth;
     old_fb_id = drmmode->fb_id;
     old_front = drmmode->front_bo;
 
-    pitch = width * cpp;
-    drmmode->front_bo = drm_bo_alloc_surface(scrn, &pitch, height, 0,
+    format = map_legacy_formats(scrn->bitsPerPixel, scrn->depth);
+    drmmode->front_bo = drm_bo_alloc_surface(scrn, width, height, format,
                                             16, TTM_PL_FLAG_VRAM);
     if (!drmmode->front_bo)
         goto fail;
 
+    xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                "Allocate new frame buffer %dx%d stride %d\n",
+                width, height, drmmode->front_bo->pitch);
+
     new_pixels = drm_bo_map(scrn, drmmode->front_bo);
     if (!new_pixels)
         goto fail;
 
     if (pVia->shadowFB) {
-        new_pixels = malloc(height * pitch);
+        new_pixels = malloc(height * drmmode->front_bo->pitch);
         if (!new_pixels)
             goto fail;
         free(pVia->ShadowPtr);
@@ -819,10 +848,11 @@ via_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
     }
     scrn->virtualX = width;
     scrn->virtualY = height;
-    scrn->displayWidth = pitch / cpp;
+    scrn->displayWidth = drmmode->front_bo->pitch / cpp;
 
     ppix = screen->GetScreenPixmap(screen);
-    if (!screen->ModifyPixmapHeader(ppix, width, height, -1, -1, pitch,
+    if (!screen->ModifyPixmapHeader(ppix, width, height, -1, -1,
+                                    drmmode->front_bo->pitch,
                                     new_pixels))
         goto fail;
 
@@ -1768,7 +1798,7 @@ VIAScreenInit(SCREEN_INIT_ARGS_DECL)
 {
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VIAPtr pVia = VIAPTR(pScrn);
-    int pitch;
+    int format;
 
     pScrn->pScreen = pScreen;
     pScrn->displayWidth = pScrn->virtualX;
@@ -1797,9 +1827,9 @@ VIAScreenInit(SCREEN_INIT_ARGS_DECL)
     if (!drm_bo_manager_init(pScrn))
         return FALSE;
 
-    pitch = pScrn->virtualX * pScrn->bitsPerPixel >> 3;
-    pVia->drmmode.front_bo = drm_bo_alloc_surface(pScrn, &pitch, pScrn->virtualY,
-                                                    0, 16, TTM_PL_FLAG_VRAM);
+    format = map_legacy_formats(pScrn->bitsPerPixel, pScrn->depth);
+    pVia->drmmode.front_bo = drm_bo_alloc_surface(pScrn, pScrn->virtualX, pScrn->virtualY,
+                                                    format, 16, TTM_PL_FLAG_VRAM);
     if (!pVia->drmmode.front_bo)
         return FALSE;
 
diff --git a/src/via_driver.h b/src/via_driver.h
index 80f13fb..f82fdda 100644
--- a/src/via_driver.h
+++ b/src/via_driver.h


Reply to: