ia64/xen-unstable

changeset 17176:38bbaa69c065

ioemu: xenfb shared memory patch

Share 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.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Mar 03 13:19:44 2008 +0000 (2008-03-03)
parents a2359114b6cb
children d0daf11fb35d
files tools/ioemu/hw/xenfb.c tools/ioemu/vl.h
line diff
     1.1 --- a/tools/ioemu/hw/xenfb.c	Mon Mar 03 13:13:55 2008 +0000
     1.2 +++ b/tools/ioemu/hw/xenfb.c	Mon Mar 03 13:19:44 2008 +0000
     1.3 @@ -1112,36 +1112,38 @@ static void xenfb_guest_copy(struct xenf
     1.4  {
     1.5      int line;
     1.6  
     1.7 -    if (xenfb->depth == xenfb->ds->depth) { /* Perfect match can use fast path */
     1.8 -        for (line = y ; line < (y+h) ; line++) {
     1.9 -            memcpy(xenfb->ds->data + (line * xenfb->ds->linesize) + (x * xenfb->ds->depth / 8),
    1.10 -                   xenfb->pixels + (line * xenfb->row_stride) + (x * xenfb->depth / 8),
    1.11 -                   w * xenfb->depth / 8);
    1.12 -        }
    1.13 -    } else { /* Mismatch requires slow pixel munging */
    1.14 -        /* 8 bit == r:3 g:3 b:2 */
    1.15 -        /* 16 bit == r:5 g:6 b:5 */
    1.16 -        /* 24 bit == r:8 g:8 b:8 */
    1.17 -        /* 32 bit == r:8 g:8 b:8 (padding:8) */
    1.18 -        if (xenfb->depth == 8) {
    1.19 -            if (xenfb->ds->depth == 16) {
    1.20 -                BLT(uint8_t, uint16_t,   3, 3, 2,   5, 6, 5);
    1.21 -            } else if (xenfb->ds->depth == 32) {
    1.22 -                BLT(uint8_t, uint32_t,   3, 3, 2,   8, 8, 8);
    1.23 +    if (!xenfb->ds->shared_buf) {
    1.24 +        if (xenfb->depth == xenfb->ds->depth) { /* Perfect match can use fast path */
    1.25 +            for (line = y ; line < (y+h) ; line++) {
    1.26 +                memcpy(xenfb->ds->data + (line * xenfb->ds->linesize) + (x * xenfb->ds->depth / 8),
    1.27 +                        xenfb->pixels + (line * xenfb->row_stride) + (x * xenfb->depth / 8),
    1.28 +                        w * xenfb->depth / 8);
    1.29              }
    1.30 -        } else if (xenfb->depth == 16) {
    1.31 -            if (xenfb->ds->depth == 8) {
    1.32 -                BLT(uint16_t, uint8_t,   5, 6, 5,   3, 3, 2);
    1.33 -            } else if (xenfb->ds->depth == 32) {
    1.34 -                BLT(uint16_t, uint32_t,  5, 6, 5,   8, 8, 8);
    1.35 -            }
    1.36 -        } else if (xenfb->depth == 24 || xenfb->depth == 32) {
    1.37 -            if (xenfb->ds->depth == 8) {
    1.38 -                BLT(uint32_t, uint8_t,   8, 8, 8,   3, 3, 2);
    1.39 -            } else if (xenfb->ds->depth == 16) {
    1.40 -                BLT(uint32_t, uint16_t,  8, 8, 8,   5, 6, 5);
    1.41 -            } else if (xenfb->ds->depth == 32) {
    1.42 -                BLT(uint32_t, uint32_t,  8, 8, 8,   8, 8, 8);
    1.43 +        } else { /* Mismatch requires slow pixel munging */
    1.44 +            /* 8 bit == r:3 g:3 b:2 */
    1.45 +            /* 16 bit == r:5 g:6 b:5 */
    1.46 +            /* 24 bit == r:8 g:8 b:8 */
    1.47 +            /* 32 bit == r:8 g:8 b:8 (padding:8) */
    1.48 +            if (xenfb->depth == 8) {
    1.49 +                if (xenfb->ds->depth == 16) {
    1.50 +                    BLT(uint8_t, uint16_t,   3, 3, 2,   5, 6, 5);
    1.51 +                } else if (xenfb->ds->depth == 32) {
    1.52 +                    BLT(uint8_t, uint32_t,   3, 3, 2,   8, 8, 8);
    1.53 +                }
    1.54 +            } else if (xenfb->depth == 16) {
    1.55 +                if (xenfb->ds->depth == 8) {
    1.56 +                    BLT(uint16_t, uint8_t,   5, 6, 5,   3, 3, 2);
    1.57 +                } else if (xenfb->ds->depth == 32) {
    1.58 +                    BLT(uint16_t, uint32_t,  5, 6, 5,   8, 8, 8);
    1.59 +                }
    1.60 +            } else if (xenfb->depth == 24 || xenfb->depth == 32) {
    1.61 +                if (xenfb->ds->depth == 8) {
    1.62 +                    BLT(uint32_t, uint8_t,   8, 8, 8,   3, 3, 2);
    1.63 +                } else if (xenfb->ds->depth == 16) {
    1.64 +                    BLT(uint32_t, uint16_t,  8, 8, 8,   5, 6, 5);
    1.65 +                } else if (xenfb->ds->depth == 32) {
    1.66 +                    BLT(uint32_t, uint32_t,  8, 8, 8,   8, 8, 8);
    1.67 +                }
    1.68              }
    1.69          }
    1.70      }
    1.71 @@ -1180,7 +1182,10 @@ static int xenfb_register_console(struct
    1.72  			     xenfb_invalidate,
    1.73  			     xenfb_screen_dump,
    1.74  			     xenfb);
    1.75 +	dpy_colourdepth(xenfb->ds, xenfb->depth);
    1.76  	dpy_resize(xenfb->ds, xenfb->width, xenfb->height);
    1.77 +	if (xenfb->ds->shared_buf)
    1.78 +	    dpy_setdata(xenfb->ds, xenfb->pixels);
    1.79  
    1.80  	if (qemu_set_fd_handler2(xc_evtchn_fd(xenfb->evt_xch), NULL, xenfb_dispatch_channel, NULL, xenfb) < 0)
    1.81  	        return -1;
     2.1 --- a/tools/ioemu/vl.h	Mon Mar 03 13:13:55 2008 +0000
     2.2 +++ b/tools/ioemu/vl.h	Mon Mar 03 13:19:44 2008 +0000
     2.3 @@ -942,7 +942,7 @@ struct DisplayState {
     2.4      void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
     2.5      void (*dpy_resize)(struct DisplayState *s, int w, int h);
     2.6      void (*dpy_colourdepth)(struct DisplayState *s, int depth);
     2.7 -    void (*dpy_setdata)(DisplayState *ds, void *pixels);
     2.8 +    void (*dpy_setdata)(DisplayState *s, void *pixels);
     2.9      void (*dpy_refresh)(struct DisplayState *s);
    2.10      void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y, int dst_x, int dst_y, int w, int h);
    2.11  };
    2.12 @@ -957,6 +957,17 @@ static inline void dpy_resize(DisplaySta
    2.13      s->dpy_resize(s, w, h);
    2.14  }
    2.15  
    2.16 +static inline void dpy_colourdepth(struct DisplayState *s, int depth)
    2.17 +{
    2.18 +    s->dpy_colourdepth(s, depth);
    2.19 +}
    2.20 +
    2.21 +static inline void dpy_setdata(DisplayState *s, void *pixels)
    2.22 +{
    2.23 +    s->dpy_setdata(s, pixels);
    2.24 +}
    2.25 +
    2.26 +
    2.27  int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base, 
    2.28                   unsigned long vga_ram_offset, int vga_ram_size);
    2.29  int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,