From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Stabellini Subject: xenfb shared memory patch Date: Mon, 03 Mar 2008 12:33:58 +0000 Message-ID: <47CBF036.4030006@eu.citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060708020002050501030505" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------060708020002050501030505 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 --------------060708020002050501030505 Content-Type: text/x-patch; name="xenfb-shared.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="xenfb-shared.patch" 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); --------------060708020002050501030505 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------060708020002050501030505--