Skip to contentSkip to conversation

xenfb shared memory patch

PATCH Stefano Stabellini 1 participant 1 message Mar 3, 2008

lore
Share & tools
lore
#0 lore raw

Hi all,
I am attaching a simple patch that shares the internal xenfb backend buffer with sdl or vnc.
All the needed functions are already in place because have been implemented for the previous cirrus vga shared memory patch. Best Regards,

Stefano Stabellini

tools/ioemu/hw/xenfb.c +34 -29
diff -r c89f6ed56351 tools/ioemu/hw/xenfb.c
@@ -1112,36 +1112,38 @@ static void xenfb_guest_copy(struct xenf
 {
     int line;
 
-    if (xenfb->depth == xenfb->ds->depth) { /* Perfect match can use fast path */
-        for (line = y ; line < (y+h) ; line++) {
-            memcpy(xenfb->ds->data + (line * xenfb->ds->linesize) + (x * xenfb->ds->depth / 8),
-                   xenfb->pixels + (line * xenfb->row_stride) + (x * xenfb->depth / 8),
-                   w * xenfb->depth / 8);
-        }
-    } else { /* Mismatch requires slow pixel munging */
-        /* 8 bit == r:3 g:3 b:2 */
-        /* 16 bit == r:5 g:6 b:5 */
-        /* 24 bit == r:8 g:8 b:8 */
-        /* 32 bit == r:8 g:8 b:8 (padding:8) */
-        if (xenfb->depth == 8) {
-            if (xenfb->ds->depth == 16) {
-                BLT(uint8_t, uint16_t,   3, 3, 2,   5, 6, 5);
-            } else if (xenfb->ds->depth == 32) {
-                BLT(uint8_t, uint32_t,   3, 3, 2,   8, 8, 8);
+    if (!xenfb->ds->shared_buf) {
+        if (xenfb->depth == xenfb->ds->depth) { /* Perfect match can use fast path */
+            for (line = y ; line < (y+h) ; line++) {
+                memcpy(xenfb->ds->data + (line * xenfb->ds->linesize) + (x * xenfb->ds->depth / 8),
+                        xenfb->pixels + (line * xenfb->row_stride) + (x * xenfb->depth / 8),
+                        w * xenfb->depth / 8);
             }
-        } else if (xenfb->depth == 16) {
-            if (xenfb->ds->depth == 8) {
-                BLT(uint16_t, uint8_t,   5, 6, 5,   3, 3, 2);
-            } else if (xenfb->ds->depth == 32) {
-                BLT(uint16_t, uint32_t,  5, 6, 5,   8, 8, 8);
-            }
-        } else if (xenfb->depth == 24 || xenfb->depth == 32) {
-            if (xenfb->ds->depth == 8) {
-                BLT(uint32_t, uint8_t,   8, 8, 8,   3, 3, 2);
-            } else if (xenfb->ds->depth == 16) {
-                BLT(uint32_t, uint16_t,  8, 8, 8,   5, 6, 5);
-            } else if (xenfb->ds->depth == 32) {
-                BLT(uint32_t, uint32_t,  8, 8, 8,   8, 8, 8);
+        } else { /* Mismatch requires slow pixel munging */
+            /* 8 bit == r:3 g:3 b:2 */
+            /* 16 bit == r:5 g:6 b:5 */
+            /* 24 bit == r:8 g:8 b:8 */
+            /* 32 bit == r:8 g:8 b:8 (padding:8) */
+            if (xenfb->depth == 8) {
+                if (xenfb->ds->depth == 16) {
+                    BLT(uint8_t, uint16_t,   3, 3, 2,   5, 6, 5);
+                } else if (xenfb->ds->depth == 32) {
+                    BLT(uint8_t, uint32_t,   3, 3, 2,   8, 8, 8);
+                }
+            } else if (xenfb->depth == 16) {
+                if (xenfb->ds->depth == 8) {
+                    BLT(uint16_t, uint8_t,   5, 6, 5,   3, 3, 2);
+                } else if (xenfb->ds->depth == 32) {
+                    BLT(uint16_t, uint32_t,  5, 6, 5,   8, 8, 8);
+                }
+            } else if (xenfb->depth == 24 || xenfb->depth == 32) {
+                if (xenfb->ds->depth == 8) {
+                    BLT(uint32_t, uint8_t,   8, 8, 8,   3, 3, 2);
+                } else if (xenfb->ds->depth == 16) {
+                    BLT(uint32_t, uint16_t,  8, 8, 8,   5, 6, 5);
+                } else if (xenfb->ds->depth == 32) {
+                    BLT(uint32_t, uint32_t,  8, 8, 8,   8, 8, 8);
+                }
             }
         }
     }
@@ -1180,7 +1182,10 @@ static int xenfb_register_console(struct
 			     xenfb_invalidate,
 			     xenfb_screen_dump,
 			     xenfb);
+	dpy_colourdepth(xenfb->ds, xenfb->depth);
 	dpy_resize(xenfb->ds, xenfb->width, xenfb->height);
+	if (xenfb->ds->shared_buf)
+	    dpy_setdata(xenfb->ds, xenfb->pixels);
 
 	if (qemu_set_fd_handler2(xc_evtchn_fd(xenfb->evt_xch), NULL, xenfb_dispatch_channel, NULL, xenfb) < 0)
 	        return -1;
tools/ioemu/vl.h +12 -1
diff -r c89f6ed56351 tools/ioemu/vl.h
@@ -942,7 +942,7 @@ struct DisplayState {
     void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
     void (*dpy_resize)(struct DisplayState *s, int w, int h);
     void (*dpy_colourdepth)(struct DisplayState *s, int depth);
-    void (*dpy_setdata)(DisplayState *ds, void *pixels);
+    void (*dpy_setdata)(DisplayState *s, void *pixels);
     void (*dpy_refresh)(struct DisplayState *s);
     void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y, int dst_x, int dst_y, int w, int h);
 };
@@ -956,6 +956,17 @@ static inline void dpy_resize(DisplaySta
 {
     s->dpy_resize(s, w, h);
 }
+
+static inline void dpy_colourdepth(struct DisplayState *s, int depth)
+{
+    s->dpy_colourdepth(s, depth);
+}
+
+static inline void dpy_setdata(DisplayState *s, void *pixels)
+{
+    s->dpy_setdata(s, pixels);
+}
+
 
 int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base, 
                  unsigned long vga_ram_offset, int vga_ram_size);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel