ia64/xen-unstable

changeset 17063:c9d9bbf1204c

ioemu: Support the WMVi pseudoencoding in the vnc server.

If the client implements it, it is supposed to be able to change
colour depth when receiving a WMVi message.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 14 10:36:47 2008 +0000 (2008-02-14)
parents 0769835cf50f
children 72f52dd2dba8
files tools/ioemu/vl.c tools/ioemu/vnc.c
line diff
     1.1 --- a/tools/ioemu/vl.c	Thu Feb 14 10:33:12 2008 +0000
     1.2 +++ b/tools/ioemu/vl.c	Thu Feb 14 10:36:47 2008 +0000
     1.3 @@ -154,7 +154,6 @@ static DisplayState display_state;
     1.4  int nographic;
     1.5  int vncviewer;
     1.6  int vncunused;
     1.7 -int vncswitchbpp;
     1.8  const char* keyboard_layout = NULL;
     1.9  int64_t ticks_per_sec;
    1.10  char *boot_device = NULL;
    1.11 @@ -6560,7 +6559,6 @@ void help(void)
    1.12  	   "-vnc display    start a VNC server on display\n"
    1.13             "-vncviewer      start a vncviewer process for this domain\n"
    1.14             "-vncunused      bind the VNC server to an unused port\n"
    1.15 -           "-vnc-switch-bpp VNC server closes connections when the guest OS changes colour depth\n"
    1.16  #ifndef NO_DAEMONIZE
    1.17  	   "-daemonize      daemonize QEMU after initializing\n"
    1.18  #endif
    1.19 @@ -6662,7 +6660,6 @@ enum {
    1.20      QEMU_OPTION_acpi,
    1.21      QEMU_OPTION_vncviewer,
    1.22      QEMU_OPTION_vncunused,
    1.23 -    QEMU_OPTION_vncswitchbpp,
    1.24      QEMU_OPTION_pci,
    1.25  };
    1.26  
    1.27 @@ -6746,7 +6743,6 @@ const QEMUOption qemu_options[] = {
    1.28      { "vnc", HAS_ARG, QEMU_OPTION_vnc },
    1.29      { "vncviewer", 0, QEMU_OPTION_vncviewer },
    1.30      { "vncunused", 0, QEMU_OPTION_vncunused },
    1.31 -    { "vnc-switch-bpp", 0, QEMU_OPTION_vncswitchbpp },
    1.32  
    1.33      /* temporary options */
    1.34      { "usb", 0, QEMU_OPTION_usb },
    1.35 @@ -7164,7 +7160,6 @@ int main(int argc, char **argv)
    1.36      nographic = 0;
    1.37      vncviewer = 0;
    1.38      vncunused = 0;
    1.39 -    vncswitchbpp = 0;
    1.40      kernel_filename = NULL;
    1.41      kernel_cmdline = "";
    1.42  #ifndef CONFIG_DM
    1.43 @@ -7595,9 +7590,6 @@ int main(int argc, char **argv)
    1.44              case QEMU_OPTION_vncunused:
    1.45                  vncunused++;
    1.46                  break;
    1.47 -            case QEMU_OPTION_vncswitchbpp:
    1.48 -                vncswitchbpp++;
    1.49 -                break;
    1.50              case QEMU_OPTION_pci:
    1.51                  direct_pci = optarg;
    1.52                  break;
    1.53 @@ -7830,7 +7822,6 @@ int main(int argc, char **argv)
    1.54      } else if (vnc_display != NULL || vncunused != 0) {
    1.55  	int vnc_display_port;
    1.56  	char password[20];
    1.57 -        ds->switchbpp = vncswitchbpp;
    1.58  	vnc_display_init(ds);
    1.59  	xenstore_read_vncpasswd(domid, password, sizeof(password));
    1.60  	vnc_display_password(ds, password);
     2.1 --- a/tools/ioemu/vnc.c	Thu Feb 14 10:33:12 2008 +0000
     2.2 +++ b/tools/ioemu/vnc.c	Thu Feb 14 10:36:47 2008 +0000
     2.3 @@ -157,6 +157,7 @@ struct VncState
     2.4      int has_resize;
     2.5      int has_hextile;
     2.6      int has_pointer_type_change;
     2.7 +    int has_WMVi;
     2.8      int absolute;
     2.9      int last_x;
    2.10      int last_y;
    2.11 @@ -1310,6 +1311,7 @@ static void set_encodings(VncState *vs, 
    2.12      vs->has_hextile = 0;
    2.13      vs->has_resize = 0;
    2.14      vs->has_pointer_type_change = 0;
    2.15 +    vs->has_WMVi = 0;
    2.16      vs->absolute = -1;
    2.17      vs->ds->dpy_copy = NULL;
    2.18  
    2.19 @@ -1330,6 +1332,8 @@ static void set_encodings(VncState *vs, 
    2.20  	case -257:
    2.21  	    vs->has_pointer_type_change = 1;
    2.22  	    break;
    2.23 +        case 0x574D5669:
    2.24 +            vs->has_WMVi = 1;
    2.25  	default:
    2.26  	    break;
    2.27  	}
    2.28 @@ -1410,6 +1414,57 @@ static void set_pixel_format(VncState *v
    2.29      vga_hw_update();
    2.30  }
    2.31  
    2.32 +static void pixel_format_message (VncState *vs) {
    2.33 +    char pad[3] = { 0, 0, 0 };
    2.34 +
    2.35 +    vnc_write_u8(vs, vs->depth * 8); /* bits-per-pixel */
    2.36 +    if (vs->depth == 4) vnc_write_u8(vs, 24); /* depth */
    2.37 +    else vnc_write_u8(vs, vs->depth * 8); /* depth */
    2.38 +
    2.39 +#ifdef WORDS_BIGENDIAN
    2.40 +    vnc_write_u8(vs, 1);             /* big-endian-flag */
    2.41 +#else
    2.42 +    vnc_write_u8(vs, 0);             /* big-endian-flag */
    2.43 +#endif
    2.44 +    vnc_write_u8(vs, 1);             /* true-color-flag */
    2.45 +    if (vs->depth == 4) {
    2.46 +        vnc_write_u16(vs, 0xFF);     /* red-max */
    2.47 +        vnc_write_u16(vs, 0xFF);     /* green-max */
    2.48 +        vnc_write_u16(vs, 0xFF);     /* blue-max */
    2.49 +        vnc_write_u8(vs, 16);        /* red-shift */
    2.50 +        vnc_write_u8(vs, 8);         /* green-shift */
    2.51 +        vnc_write_u8(vs, 0);         /* blue-shift */
    2.52 +        vs->send_hextile_tile = send_hextile_tile_32;
    2.53 +    } else if (vs->depth == 2) {
    2.54 +        vnc_write_u16(vs, 31);       /* red-max */
    2.55 +        vnc_write_u16(vs, 63);       /* green-max */
    2.56 +        vnc_write_u16(vs, 31);       /* blue-max */
    2.57 +        vnc_write_u8(vs, 11);        /* red-shift */
    2.58 +        vnc_write_u8(vs, 5);         /* green-shift */
    2.59 +        vnc_write_u8(vs, 0);         /* blue-shift */
    2.60 +        vs->send_hextile_tile = send_hextile_tile_16;
    2.61 +    } else if (vs->depth == 1) {
    2.62 +        /* XXX: change QEMU pixel 8 bit pixel format to match the VNC one ? */
    2.63 +        vnc_write_u16(vs, 7);        /* red-max */
    2.64 +        vnc_write_u16(vs, 7);        /* green-max */
    2.65 +        vnc_write_u16(vs, 3);        /* blue-max */
    2.66 +        vnc_write_u8(vs, 5);         /* red-shift */
    2.67 +        vnc_write_u8(vs, 2);         /* green-shift */
    2.68 +        vnc_write_u8(vs, 0);         /* blue-shift */
    2.69 +        vs->send_hextile_tile = send_hextile_tile_8;
    2.70 +    }
    2.71 +    vs->red_max = vs->red_max1;
    2.72 +    vs->green_max = vs->green_max1;
    2.73 +    vs->blue_max = vs->blue_max1;
    2.74 +    vs->red_shift = vs->red_shift1;
    2.75 +    vs->green_shift = vs->green_shift1;
    2.76 +    vs->blue_shift = vs->blue_shift1;
    2.77 +    vs->pix_bpp = vs->depth * 8;
    2.78 +    vs->write_pixels = vnc_write_pixels_copy;
    2.79 +        
    2.80 +    vnc_write(vs, pad, 3);           /* padding */
    2.81 +}
    2.82 +
    2.83  static void vnc_dpy_colourdepth(DisplayState *ds, int depth)
    2.84  {
    2.85      int host_big_endian_flag;
    2.86 @@ -1457,6 +1512,14 @@ static void vnc_dpy_colourdepth(DisplayS
    2.87      }
    2.88      if (ds->switchbpp) {
    2.89          vnc_client_error(vs);
    2.90 +    } else if (vs->csock != -1 && vs->has_WMVi) {
    2.91 +        /* Sending a WMVi message to notify the client*/
    2.92 +        vnc_write_u8(vs, 0);  /* msg id */
    2.93 +        vnc_write_u8(vs, 0);
    2.94 +        vnc_write_u16(vs, 1); /* number of rects */
    2.95 +        vnc_framebuffer_update(vs, 0, 0, ds->width, ds->height, 0x574D5669);
    2.96 +        pixel_format_message(vs);
    2.97 +        vnc_flush(vs);
    2.98      } else {
    2.99          if (vs->pix_bpp == 4 && vs->depth == 4 &&
   2.100              host_big_endian_flag == vs->pix_big_endian &&
   2.101 @@ -1578,7 +1641,6 @@ static int protocol_client_msg(VncState 
   2.102  static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)
   2.103  {
   2.104      size_t l;
   2.105 -    char pad[3] = { 0, 0, 0 };
   2.106  
   2.107      vga_hw_update();
   2.108  
   2.109 @@ -1587,45 +1649,7 @@ static int protocol_client_init(VncState
   2.110      vnc_write_u16(vs, vs->ds->width);
   2.111      vnc_write_u16(vs, vs->ds->height);
   2.112  
   2.113 -    vnc_write_u8(vs, vs->depth * 8); /* bits-per-pixel */
   2.114 -    if (vs->depth == 4) vnc_write_u8(vs, 24); /* depth */
   2.115 -    else vnc_write_u8(vs, vs->depth * 8); /* depth */
   2.116 -
   2.117 -#ifdef WORDS_BIGENDIAN
   2.118 -    vnc_write_u8(vs, 1);             /* big-endian-flag */
   2.119 -#else
   2.120 -    vnc_write_u8(vs, 0);             /* big-endian-flag */
   2.121 -#endif
   2.122 -    vnc_write_u8(vs, 1);             /* true-color-flag */
   2.123 -    if (vs->depth == 4) {
   2.124 -	vnc_write_u16(vs, 0xFF);     /* red-max */
   2.125 -	vnc_write_u16(vs, 0xFF);     /* green-max */
   2.126 -	vnc_write_u16(vs, 0xFF);     /* blue-max */
   2.127 -	vnc_write_u8(vs, 16);        /* red-shift */
   2.128 -	vnc_write_u8(vs, 8);         /* green-shift */
   2.129 -	vnc_write_u8(vs, 0);         /* blue-shift */
   2.130 -        vs->send_hextile_tile = send_hextile_tile_32;
   2.131 -    } else if (vs->depth == 2) {
   2.132 -	vnc_write_u16(vs, 31);       /* red-max */
   2.133 -	vnc_write_u16(vs, 63);       /* green-max */
   2.134 -	vnc_write_u16(vs, 31);       /* blue-max */
   2.135 -	vnc_write_u8(vs, 11);        /* red-shift */
   2.136 -	vnc_write_u8(vs, 5);         /* green-shift */
   2.137 -	vnc_write_u8(vs, 0);         /* blue-shift */
   2.138 -        vs->send_hextile_tile = send_hextile_tile_16;
   2.139 -    } else if (vs->depth == 1) {
   2.140 -        /* XXX: change QEMU pixel 8 bit pixel format to match the VNC one ? */
   2.141 -	vnc_write_u16(vs, 7);        /* red-max */
   2.142 -	vnc_write_u16(vs, 7);        /* green-max */
   2.143 -	vnc_write_u16(vs, 3);        /* blue-max */
   2.144 -	vnc_write_u8(vs, 5);         /* red-shift */
   2.145 -	vnc_write_u8(vs, 2);         /* green-shift */
   2.146 -	vnc_write_u8(vs, 0);         /* blue-shift */
   2.147 -        vs->send_hextile_tile = send_hextile_tile_8;
   2.148 -    }
   2.149 -    vs->write_pixels = vnc_write_pixels_copy;
   2.150 -	
   2.151 -    vnc_write(vs, pad, 3);           /* padding */
   2.152 +    pixel_format_message(vs);
   2.153  
   2.154      l = strlen(domain_name); 
   2.155      vnc_write_u32(vs, l);        
   2.156 @@ -2436,6 +2460,8 @@ int vnc_display_open(DisplayState *ds, c
   2.157  	options++;
   2.158  	if (strncmp(options, "password", 8) == 0) {
   2.159  	    password = 1; /* Require password auth */
   2.160 +        } else if (strncmp(options, "switchbpp", 9) == 0) {
   2.161 +            ds->switchbpp = 1;
   2.162  #if CONFIG_VNC_TLS
   2.163  	} else if (strncmp(options, "tls", 3) == 0) {
   2.164  	    tls = 1; /* Require TLS */