xserver: Branch 'master' - 3 commits

Keith Packard keithp at kemper.freedesktop.org
Fri Nov 1 02:25:01 CET 2013


 hw/kdrive/ephyr/hostx.c           |   22 +++++++++++++---------
 hw/xfree86/common/xf86Configure.c |    2 ++
 2 files changed, 15 insertions(+), 9 deletions(-)

New commits:
commit 623c4147650d0404cfbea0f9b7df66dc7d928e00
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Mon Oct 21 17:11:56 2013 -0400

    ephyr: Ensure stride of private framebuffer is multiple of 4
    
    The fb layer of X can't deal with strides that are not a multiple of
    4, so when Xephyr allocates its own framebuffer it should make sure to
    align it.
    
    This fixes crashes and rendering corruption when Xephyr runs in a
    depth that is different from the host X server and its screen size is
    not a multiple of 4 / depth. (This is particularly easy to trigger if
    you use the -resizeable option).
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Soren Sandmann <ssp at redhat.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 6020e8d..ee9ae45 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -721,12 +721,14 @@ hostx_screen_init(KdScreenInfo *screen,
         return scrpriv->ximg->data;
     }
     else {
-        *bytes_per_line = width * (scrpriv->server_depth >> 3);
+        int bytes_per_pixel = scrpriv->server_depth >> 3;
+        int stride = (width * bytes_per_pixel + 0x3) & ~0x3;
+
+        *bytes_per_line = stride;
         *bits_per_pixel = scrpriv->server_depth;
 
-        EPHYR_DBG("server bpp %i", scrpriv->server_depth >> 3);
-        scrpriv->fb_data =
-            malloc(width * buffer_height * (scrpriv->server_depth >> 3));
+        EPHYR_DBG("server bpp %i", bytes_per_pixel);
+        scrpriv->fb_data = malloc (stride * buffer_height);
         return scrpriv->fb_data;
     }
 }
@@ -765,15 +767,14 @@ hostx_paint_rect(KdScreenInfo *screen,
 
     if (!host_depth_matches_server(scrpriv)) {
         int x, y, idx, bytes_per_pixel = (scrpriv->server_depth >> 3);
+        int stride = (scrpriv->win_width * bytes_per_pixel + 0x3) & ~0x3;
         unsigned char r, g, b;
         unsigned long host_pixel;
 
         EPHYR_DBG("Unmatched host depth scrpriv=%p\n", scrpriv);
         for (y = sy; y < sy + height; y++)
             for (x = sx; x < sx + width; x++) {
-                idx =
-                    (scrpriv->win_width * y * bytes_per_pixel) +
-                    (x * bytes_per_pixel);
+                idx = y * stride + x * bytes_per_pixel;
 
                 switch (scrpriv->server_depth) {
                 case 16:
commit 97cf53cc2ad7ecfdd495133bad31d0ec7d939326
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Mon Oct 21 16:58:54 2013 -0400

    ephyr: hostx_screen_init(): Fix bits_per_pixel and bytes_per_line
    
    When the depth of the Xephyr server matches that of the host X server,
    Xephyr simply uses the buffer associated with the XImage as its
    framebuffer. In this case, it is correct to get the bits_per_pixel and
    bytes_per_line values returned from hostx_screen_init() from the XImage.
    
    However, when the depth doesn't match the host, Xephyr uses a private
    framebuffer that is periodically copied to the XImage. In this case,
    the returned values of bits_per_pixel and bytes_per_line should be
    those of the private framebuffer, not those of the XImage.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Soren Sandmann <ssp at redhat.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 5fa33b9..6020e8d 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -695,9 +695,6 @@ hostx_screen_init(KdScreenInfo *screen,
             malloc(scrpriv->ximg->stride * buffer_height);
     }
 
-    *bytes_per_line = scrpriv->ximg->stride;
-    *bits_per_pixel = scrpriv->ximg->bpp;
-
     if (scrpriv->win_pre_existing == None && !EphyrWantResize) {
         /* Ask the WM to keep our size static */
         xcb_size_hints_t size_hints = {0};
@@ -717,10 +714,16 @@ hostx_screen_init(KdScreenInfo *screen,
     scrpriv->win_height = height;
 
     if (host_depth_matches_server(scrpriv)) {
+        *bytes_per_line = scrpriv->ximg->stride;
+        *bits_per_pixel = scrpriv->ximg->bpp;
+
         EPHYR_DBG("Host matches server");
         return scrpriv->ximg->data;
     }
     else {
+        *bytes_per_line = width * (scrpriv->server_depth >> 3);
+        *bits_per_pixel = scrpriv->server_depth;
+
         EPHYR_DBG("server bpp %i", scrpriv->server_depth >> 3);
         scrpriv->fb_data =
             malloc(width * buffer_height * (scrpriv->server_depth >> 3));
commit 55246b67b755d4c1039d54971fe3f77ea60d604e
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Tue Oct 8 17:45:40 2013 -0400

    xf86AddBusDeviceToConfigure(): Store device in DevToConfig[i].pVideo
    
    After fc3ab84d the pVideo field in DevToConfig[i] is no longer
    initialized, so it's always NULL. This causes the duplicate finding
    algorithm in the beginning of the function to not work anymore as it
    is based on this field.
    
    The symptom of this bug is that X -configure reports
    
        Number of created screens does not match number of detected devices.
          Configuration failed.
        Server terminated with error (2). Closing log file.
    
    rather than producing a working config file.
    
    This patch fixes that bug by initializing the field before calling
    xf86PciConfigureNewDev().
    
    Cc: tvignatti at gmail.com
    Signed-off-by: Soren Sandmann <ssp at redhat.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 6c5e359..91e8df9 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -123,12 +123,14 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData,
     switch (bus) {
 #ifdef XSERVER_LIBPCIACCESS
     case BUS_PCI:
+	DevToConfig[i].pVideo = busData;
         xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
                                &DevToConfig[i].GDev, &chipset);
         break;
 #endif
 #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
     case BUS_SBUS:
+	DevToConfig[i].sVideo = busData;
         xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
                                 &DevToConfig[i].GDev);
         break;


More information about the xorg-commit mailing list