All of lore.kernel.org
 help / color / mirror / Atom feed
* xenfb shared memory patch
@ 2008-03-03 12:33 Stefano Stabellini
  0 siblings, 0 replies; only message in thread
From: Stefano Stabellini @ 2008-03-03 12:33 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 332 bytes --]

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

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

[-- Attachment #2: xenfb-shared.patch --]
[-- Type: text/x-patch, Size: 5045 bytes --]

diff -r c89f6ed56351 tools/ioemu/hw/xenfb.c
--- a/tools/ioemu/hw/xenfb.c	Mon Mar 03 11:47:40 2008 +0000
+++ b/tools/ioemu/hw/xenfb.c	Mon Mar 03 12:26:58 2008 +0000
@@ -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;
diff -r c89f6ed56351 tools/ioemu/vl.h
--- a/tools/ioemu/vl.h	Mon Mar 03 11:47:40 2008 +0000
+++ b/tools/ioemu/vl.h	Mon Mar 03 12:11:41 2008 +0000
@@ -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);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

only message in thread, other threads:[~2008-03-03 12:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-03 12:33 xenfb shared memory patch Stefano Stabellini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.