ia64/xen-unstable

changeset 11570:7706696ff532

[qemu patches] Update patches for changeset 11562:449dcaff2551.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author Christian Limpach <Christian.Limpach@xensource.com>
date Thu Sep 21 19:33:07 2006 +0100 (2006-09-21)
parents 317e8516d464
children 043f8799e68e
files tools/ioemu/patches/series tools/ioemu/patches/vnc-backoff-screen-scan tools/ioemu/patches/vnc-start-vncviewer
line diff
     1.1 --- a/tools/ioemu/patches/series	Thu Sep 21 19:28:35 2006 +0100
     1.2 +++ b/tools/ioemu/patches/series	Thu Sep 21 19:33:07 2006 +0100
     1.3 @@ -36,6 +36,7 @@ vnc-start-vncviewer
     1.4  vnc-title-domain-name
     1.5  vnc-access-monitor-vt
     1.6  vnc-display-find-unused
     1.7 +vnc-backoff-screen-scan
     1.8  xenstore-block-device-config
     1.9  xenstore-write-vnc-port
    1.10  qemu-allow-disable-sdl
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/ioemu/patches/vnc-backoff-screen-scan	Thu Sep 21 19:33:07 2006 +0100
     2.3 @@ -0,0 +1,381 @@
     2.4 +Index: ioemu/vnc.c
     2.5 +===================================================================
     2.6 +--- ioemu.orig/vnc.c	2006-09-21 19:31:03.000000000 +0100
     2.7 ++++ ioemu/vnc.c	2006-09-21 19:32:23.000000000 +0100
     2.8 +@@ -27,7 +27,19 @@
     2.9 + #include "vl.h"
    2.10 + #include "qemu_socket.h"
    2.11 + 
    2.12 +-#define VNC_REFRESH_INTERVAL (1000 / 30)
    2.13 ++/* The refresh interval starts at BASE.  If we scan the buffer and
    2.14 ++   find no change, we increase by INC, up to MAX.  If the mouse moves
    2.15 ++   or we get a keypress, the interval is set back to BASE.  If we find
    2.16 ++   an update, halve the interval.
    2.17 ++
    2.18 ++   All times in milliseconds. */
    2.19 ++#define VNC_REFRESH_INTERVAL_BASE 30
    2.20 ++#define VNC_REFRESH_INTERVAL_INC  50
    2.21 ++#define VNC_REFRESH_INTERVAL_MAX  2000
    2.22 ++
    2.23 ++/* Wait at most one second between updates, so that we can detect a
    2.24 ++   minimised vncviewer reasonably quickly. */
    2.25 ++#define VNC_MAX_UPDATE_INTERVAL   5000
    2.26 + 
    2.27 + #include "vnc_keysym.h"
    2.28 + #include "keymaps.c"
    2.29 +@@ -64,10 +76,11 @@
    2.30 + struct VncState
    2.31 + {
    2.32 +     QEMUTimer *timer;
    2.33 ++    int timer_interval;
    2.34 ++    int64_t last_update_time;
    2.35 +     int lsock;
    2.36 +     int csock;
    2.37 +     DisplayState *ds;
    2.38 +-    int need_update;
    2.39 +     int width;
    2.40 +     int height;
    2.41 +     uint64_t *dirty_row;	/* screen regions which are possibly dirty */
    2.42 +@@ -98,8 +111,6 @@
    2.43 +     int visible_w;
    2.44 +     int visible_h;
    2.45 + 
    2.46 +-    int slow_client;
    2.47 +-
    2.48 +     int ctl_keys;               /* Ctrl+Alt starts calibration */
    2.49 + };
    2.50 + 
    2.51 +@@ -380,7 +391,7 @@
    2.52 +     int y = 0;
    2.53 +     int pitch = ds->linesize;
    2.54 +     VncState *vs = ds->opaque;
    2.55 +-    int updating_client = !vs->slow_client;
    2.56 ++    int updating_client = 1;
    2.57 + 
    2.58 +     if (src_x < vs->visible_x || src_y < vs->visible_y ||
    2.59 + 	dst_x < vs->visible_x || dst_y < vs->visible_y ||
    2.60 +@@ -390,11 +401,6 @@
    2.61 + 	(dst_y + h) > (vs->visible_y + vs->visible_h))
    2.62 + 	updating_client = 0;
    2.63 + 
    2.64 +-    if (updating_client) {
    2.65 +-	vs->need_update = 1;
    2.66 +-	_vnc_update_client(vs);
    2.67 +-    }
    2.68 +-
    2.69 +     if (dst_y > src_y) {
    2.70 + 	y = h - 1;
    2.71 + 	pitch = -pitch;
    2.72 +@@ -445,110 +451,145 @@
    2.73 + static void _vnc_update_client(void *opaque)
    2.74 + {
    2.75 +     VncState *vs = opaque;
    2.76 +-    int64_t now = qemu_get_clock(rt_clock);
    2.77 +-
    2.78 +-    if (vs->need_update && vs->csock != -1) {
    2.79 +-	int y;
    2.80 +-	char *row;
    2.81 +-	char *old_row;
    2.82 +-	uint64_t width_mask;
    2.83 +-	int n_rectangles;
    2.84 +-	int saved_offset;
    2.85 +-	int maxx, maxy;
    2.86 +-	int tile_bytes = vs->depth * DP2X(vs, 1);
    2.87 ++    int64_t now;
    2.88 ++    int y;
    2.89 ++    char *row;
    2.90 ++    char *old_row;
    2.91 ++    uint64_t width_mask;
    2.92 ++    int n_rectangles;
    2.93 ++    int saved_offset;
    2.94 ++    int maxx, maxy;
    2.95 ++    int tile_bytes = vs->depth * DP2X(vs, 1);
    2.96 + 
    2.97 +-	qemu_mod_timer(vs->timer, now + VNC_REFRESH_INTERVAL);
    2.98 ++    if (vs->csock == -1)
    2.99 ++	return;
   2.100 + 
   2.101 +-	if (vs->width != DP2X(vs, DIRTY_PIXEL_BITS))
   2.102 +-	    width_mask = (1ULL << X2DP_UP(vs, vs->ds->width)) - 1;
   2.103 +-	else
   2.104 +-	    width_mask = ~(0ULL);
   2.105 ++    now = qemu_get_clock(rt_clock);
   2.106 + 
   2.107 +-	/* Walk through the dirty map and eliminate tiles that
   2.108 +-	   really aren't dirty */
   2.109 +-	row = vs->ds->data;
   2.110 +-	old_row = vs->old_data;
   2.111 +-
   2.112 +-	for (y = 0; y < vs->ds->height; y++) {
   2.113 +-	    if (vs->dirty_row[y] & width_mask) {
   2.114 +-		int x;
   2.115 +-		char *ptr, *old_ptr;
   2.116 +-
   2.117 +-		ptr = row;
   2.118 +-		old_ptr = old_row;
   2.119 +-
   2.120 +-		for (x = 0; x < X2DP_UP(vs, vs->ds->width); x++) {
   2.121 +-		    if (vs->dirty_row[y] & (1ULL << x)) {
   2.122 +-			if (memcmp(old_ptr, ptr, tile_bytes)) {
   2.123 +-			    vs->has_update = 1;
   2.124 +-			    vs->update_row[y] |= (1ULL << x);
   2.125 +-			    memcpy(old_ptr, ptr, tile_bytes);
   2.126 +-			}
   2.127 +-			vs->dirty_row[y] &= ~(1ULL << x);
   2.128 +-		    }
   2.129 ++    if (vs->width != DP2X(vs, DIRTY_PIXEL_BITS))
   2.130 ++	width_mask = (1ULL << X2DP_UP(vs, vs->ds->width)) - 1;
   2.131 ++    else
   2.132 ++	width_mask = ~(0ULL);
   2.133 + 
   2.134 +-		    ptr += tile_bytes;
   2.135 +-		    old_ptr += tile_bytes;
   2.136 +-		}
   2.137 +-	    }
   2.138 ++    /* Walk through the dirty map and eliminate tiles that really
   2.139 ++       aren't dirty */
   2.140 ++    row = vs->ds->data;
   2.141 ++    old_row = vs->old_data;
   2.142 + 
   2.143 +-	    row += vs->ds->linesize;
   2.144 +-	    old_row += vs->ds->linesize;
   2.145 +-	}
   2.146 ++    for (y = 0; y < vs->ds->height; y++) {
   2.147 ++	if (vs->dirty_row[y] & width_mask) {
   2.148 ++	    int x;
   2.149 ++	    char *ptr, *old_ptr;
   2.150 + 
   2.151 +-	if (!vs->has_update || vs->visible_y >= vs->ds->height ||
   2.152 +-	    vs->visible_x >= vs->ds->width)
   2.153 +-	    return;
   2.154 ++	    ptr = row;
   2.155 ++	    old_ptr = old_row;
   2.156 + 
   2.157 +-	/* Count rectangles */
   2.158 +-	n_rectangles = 0;
   2.159 +-	vnc_write_u8(vs, 0);  /* msg id */
   2.160 +-	vnc_write_u8(vs, 0);
   2.161 +-	saved_offset = vs->output.offset;
   2.162 +-	vnc_write_u16(vs, 0);
   2.163 ++	    for (x = 0; x < X2DP_UP(vs, vs->ds->width); x++) {
   2.164 ++		if (vs->dirty_row[y] & (1ULL << x)) {
   2.165 ++		    if (memcmp(old_ptr, ptr, tile_bytes)) {
   2.166 ++			vs->has_update = 1;
   2.167 ++			vs->update_row[y] |= (1ULL << x);
   2.168 ++			memcpy(old_ptr, ptr, tile_bytes);
   2.169 ++		    }
   2.170 ++		    vs->dirty_row[y] &= ~(1ULL << x);
   2.171 ++		}
   2.172 + 
   2.173 +-	maxy = vs->visible_y + vs->visible_h;
   2.174 +-	if (maxy > vs->ds->height)
   2.175 +-	    maxy = vs->ds->height;
   2.176 +-	maxx = vs->visible_x + vs->visible_w;
   2.177 +-	if (maxx > vs->ds->width)
   2.178 +-	    maxx = vs->ds->width;
   2.179 ++		ptr += tile_bytes;
   2.180 ++		old_ptr += tile_bytes;
   2.181 ++	    }
   2.182 ++	}
   2.183 ++  
   2.184 ++	row += vs->ds->linesize;
   2.185 ++	old_row += vs->ds->linesize;
   2.186 ++    }
   2.187 + 
   2.188 +-	for (y = vs->visible_y; y < maxy; y++) {
   2.189 +-	    int x;
   2.190 +-	    int last_x = -1;
   2.191 +-	    for (x = X2DP_DOWN(vs, vs->visible_x);
   2.192 +-		 x < X2DP_UP(vs, maxx); x++) {
   2.193 +-		if (vs->update_row[y] & (1ULL << x)) {
   2.194 +-		    if (last_x == -1)
   2.195 +-			last_x = x;
   2.196 +-		    vs->update_row[y] &= ~(1ULL << x);
   2.197 +-		} else {
   2.198 +-		    if (last_x != -1) {
   2.199 +-			int h = find_update_height(vs, y, maxy, last_x, x);
   2.200 ++    if (!vs->has_update || vs->visible_y >= vs->ds->height ||
   2.201 ++	vs->visible_x >= vs->ds->width)
   2.202 ++	goto backoff;
   2.203 ++
   2.204 ++    /* Count rectangles */
   2.205 ++    n_rectangles = 0;
   2.206 ++    vnc_write_u8(vs, 0);  /* msg id */
   2.207 ++    vnc_write_u8(vs, 0);
   2.208 ++    saved_offset = vs->output.offset;
   2.209 ++    vnc_write_u16(vs, 0);
   2.210 ++    
   2.211 ++    maxy = vs->visible_y + vs->visible_h;
   2.212 ++    if (maxy > vs->ds->height)
   2.213 ++	maxy = vs->ds->height;
   2.214 ++    maxx = vs->visible_x + vs->visible_w;
   2.215 ++    if (maxx > vs->ds->width)
   2.216 ++	maxx = vs->ds->width;
   2.217 ++
   2.218 ++    for (y = vs->visible_y; y < maxy; y++) {
   2.219 ++	int x;
   2.220 ++	int last_x = -1;
   2.221 ++	for (x = X2DP_DOWN(vs, vs->visible_x);
   2.222 ++	     x < X2DP_UP(vs, maxx); x++) {
   2.223 ++	    if (vs->update_row[y] & (1ULL << x)) {
   2.224 ++		if (last_x == -1)
   2.225 ++		    last_x = x;
   2.226 ++		vs->update_row[y] &= ~(1ULL << x);
   2.227 ++	    } else {
   2.228 ++		if (last_x != -1) {
   2.229 ++		    int h = find_update_height(vs, y, maxy, last_x, x);
   2.230 ++		    if (h != 0) {
   2.231 + 			send_framebuffer_update(vs, DP2X(vs, last_x), y,
   2.232 + 						DP2X(vs, (x - last_x)), h);
   2.233 + 			n_rectangles++;
   2.234 + 		    }
   2.235 +-		    last_x = -1;
   2.236 + 		}
   2.237 ++		last_x = -1;
   2.238 + 	    }
   2.239 +-	    if (last_x != -1) {
   2.240 +-		int h = find_update_height(vs, y, maxy, last_x, x);
   2.241 ++	}
   2.242 ++	if (last_x != -1) {
   2.243 ++	    int h = find_update_height(vs, y, maxy, last_x, x);
   2.244 ++	    if (h != 0) {
   2.245 + 		send_framebuffer_update(vs, DP2X(vs, last_x), y,
   2.246 + 					DP2X(vs, (x - last_x)), h);
   2.247 + 		n_rectangles++;
   2.248 + 	    }
   2.249 + 	}
   2.250 +-	vs->output.buffer[saved_offset] = (n_rectangles >> 8) & 0xFF;
   2.251 +-	vs->output.buffer[saved_offset + 1] = n_rectangles & 0xFF;
   2.252 ++    }
   2.253 ++    vs->output.buffer[saved_offset] = (n_rectangles >> 8) & 0xFF;
   2.254 ++    vs->output.buffer[saved_offset + 1] = n_rectangles & 0xFF;
   2.255 + 
   2.256 +-	vs->has_update = 0;
   2.257 +-	vs->need_update = 0;
   2.258 +-	vnc_flush(vs);
   2.259 +-	vs->slow_client = 0;
   2.260 +-    } else
   2.261 +-	vs->slow_client = 1;
   2.262 ++    if (n_rectangles == 0)
   2.263 ++	goto backoff;
   2.264 ++
   2.265 ++    vs->has_update = 0;
   2.266 ++    vnc_flush(vs);
   2.267 ++    vs->last_update_time = now;
   2.268 ++
   2.269 ++    vs->timer_interval /= 2;
   2.270 ++    if (vs->timer_interval < VNC_REFRESH_INTERVAL_BASE)
   2.271 ++	vs->timer_interval = VNC_REFRESH_INTERVAL_BASE;
   2.272 ++
   2.273 ++    return;
   2.274 ++
   2.275 ++ backoff:
   2.276 ++    /* No update -> back off a bit */
   2.277 ++    vs->timer_interval += VNC_REFRESH_INTERVAL_INC;
   2.278 ++    if (vs->timer_interval > VNC_REFRESH_INTERVAL_MAX) {
   2.279 ++	vs->timer_interval = VNC_REFRESH_INTERVAL_MAX;
   2.280 ++	if (now - vs->last_update_time >= VNC_MAX_UPDATE_INTERVAL) {
   2.281 ++	    /* Send a null update.  If the client is no longer
   2.282 ++	       interested (e.g. minimised) it'll ignore this, and we
   2.283 ++	       can stop scanning the buffer until it sends another
   2.284 ++	       update request. */
   2.285 ++	    /* Note that there are bugs in xvncviewer which prevent
   2.286 ++	       this from actually working.  Leave the code in place
   2.287 ++	       for correct clients. */
   2.288 ++	    vnc_write_u8(vs, 0);
   2.289 ++	    vnc_write_u8(vs, 0);
   2.290 ++	    vnc_write_u16(vs, 0);
   2.291 ++	    vnc_flush(vs);
   2.292 ++	    vs->last_update_time = now;
   2.293 ++	    return;
   2.294 ++	}
   2.295 ++    }
   2.296 ++    qemu_mod_timer(vs->timer, now + vs->timer_interval);
   2.297 ++    return;
   2.298 + }
   2.299 + 
   2.300 + static void vnc_update_client(void *opaque)
   2.301 +@@ -561,8 +602,10 @@
   2.302 + 
   2.303 + static void vnc_timer_init(VncState *vs)
   2.304 + {
   2.305 +-    if (vs->timer == NULL)
   2.306 ++    if (vs->timer == NULL) {
   2.307 + 	vs->timer = qemu_new_timer(rt_clock, vnc_update_client, vs);
   2.308 ++	vs->timer_interval = VNC_REFRESH_INTERVAL_BASE;
   2.309 ++    }
   2.310 + }
   2.311 + 
   2.312 + static void vnc_dpy_refresh(DisplayState *ds)
   2.313 +@@ -622,7 +665,6 @@
   2.314 + 	vs->csock = -1;
   2.315 + 	buffer_reset(&vs->input);
   2.316 + 	buffer_reset(&vs->output);
   2.317 +-	vs->need_update = 0;
   2.318 + 	return 0;
   2.319 +     }
   2.320 +     return ret;
   2.321 +@@ -892,7 +934,6 @@
   2.322 + 				       int x_position, int y_position,
   2.323 + 				       int w, int h)
   2.324 + {
   2.325 +-    vs->need_update = 1;
   2.326 +     if (!incremental)
   2.327 + 	framebuffer_set_updated(vs, x_position, y_position, w, h);
   2.328 +     vs->visible_x = x_position;
   2.329 +@@ -1015,6 +1056,7 @@
   2.330 + {
   2.331 +     int i;
   2.332 +     uint16_t limit;
   2.333 ++    int64_t now;
   2.334 + 
   2.335 +     switch (data[0]) {
   2.336 +     case 0:
   2.337 +@@ -1054,12 +1096,18 @@
   2.338 + 	if (len == 1)
   2.339 + 	    return 8;
   2.340 + 
   2.341 ++	vs->timer_interval = VNC_REFRESH_INTERVAL_BASE;
   2.342 ++	qemu_advance_timer(vs->timer,
   2.343 ++			   qemu_get_clock(rt_clock) + vs->timer_interval);
   2.344 + 	key_event(vs, read_u8(data, 1), read_u32(data, 4));
   2.345 + 	break;
   2.346 +     case 5:
   2.347 + 	if (len == 1)
   2.348 + 	    return 6;
   2.349 + 
   2.350 ++	vs->timer_interval = VNC_REFRESH_INTERVAL_BASE;
   2.351 ++	qemu_advance_timer(vs->timer,
   2.352 ++			   qemu_get_clock(rt_clock) + vs->timer_interval);
   2.353 + 	pointer_event(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4));
   2.354 + 	break;
   2.355 +     case 6:
   2.356 +Index: ioemu/vl.c
   2.357 +===================================================================
   2.358 +--- ioemu.orig/vl.c	2006-09-21 19:31:03.000000000 +0100
   2.359 ++++ ioemu/vl.c	2006-09-21 19:32:23.000000000 +0100
   2.360 +@@ -725,6 +725,12 @@
   2.361 +     }
   2.362 + }
   2.363 + 
   2.364 ++void qemu_advance_timer(QEMUTimer *ts, int64_t expire_time)
   2.365 ++{
   2.366 ++    if (ts->expire_time > expire_time)
   2.367 ++	qemu_mod_timer(ts, expire_time);
   2.368 ++}
   2.369 ++
   2.370 + /* modify the current timer so that it will be fired when current_time
   2.371 +    >= expire_time. The corresponding callback will be called. */
   2.372 + void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time)
   2.373 +Index: ioemu/vl.h
   2.374 +===================================================================
   2.375 +--- ioemu.orig/vl.h	2006-09-21 19:31:03.000000000 +0100
   2.376 ++++ ioemu/vl.h	2006-09-21 19:32:23.000000000 +0100
   2.377 +@@ -405,6 +405,7 @@
   2.378 + void qemu_free_timer(QEMUTimer *ts);
   2.379 + void qemu_del_timer(QEMUTimer *ts);
   2.380 + void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
   2.381 ++void qemu_advance_timer(QEMUTimer *ts, int64_t expire_time);
   2.382 + int qemu_timer_pending(QEMUTimer *ts);
   2.383 + 
   2.384 + extern int64_t ticks_per_sec;
     3.1 --- a/tools/ioemu/patches/vnc-start-vncviewer	Thu Sep 21 19:28:35 2006 +0100
     3.2 +++ b/tools/ioemu/patches/vnc-start-vncviewer	Thu Sep 21 19:33:07 2006 +0100
     3.3 @@ -1,8 +1,8 @@
     3.4  Index: ioemu/vnc.c
     3.5  ===================================================================
     3.6 ---- ioemu.orig/vnc.c	2006-09-21 19:10:45.000000000 +0100
     3.7 -+++ ioemu/vnc.c	2006-09-21 19:10:53.000000000 +0100
     3.8 -@@ -1173,3 +1173,25 @@
     3.9 +--- ioemu.orig/vnc.c	2006-09-21 19:26:38.000000000 +0100
    3.10 ++++ ioemu/vnc.c	2006-09-21 19:29:58.000000000 +0100
    3.11 +@@ -1174,3 +1174,25 @@
    3.12   
    3.13       vnc_dpy_resize(vs->ds, 640, 400);
    3.14   }
    3.15 @@ -20,7 +20,7 @@ Index: ioemu/vnc.c
    3.16  +	exit(1);
    3.17  +
    3.18  +    case 0:	/* child */
    3.19 -+	execlp("vncviewer", "vncviewer", s, 0);
    3.20 ++	execlp("vncviewer", "vncviewer", s, NULL);
    3.21  +	fprintf(stderr, "vncviewer execlp failed\n");
    3.22  +	exit(1);
    3.23  +
    3.24 @@ -30,8 +30,8 @@ Index: ioemu/vnc.c
    3.25  +}
    3.26  Index: ioemu/vl.c
    3.27  ===================================================================
    3.28 ---- ioemu.orig/vl.c	2006-09-21 19:08:38.000000000 +0100
    3.29 -+++ ioemu/vl.c	2006-09-21 19:10:53.000000000 +0100
    3.30 +--- ioemu.orig/vl.c	2006-09-21 19:26:24.000000000 +0100
    3.31 ++++ ioemu/vl.c	2006-09-21 19:29:50.000000000 +0100
    3.32  @@ -120,6 +120,7 @@
    3.33   int bios_size;
    3.34   static DisplayState display_state;
    3.35 @@ -93,8 +93,8 @@ Index: ioemu/vl.c
    3.36           sdl_display_init(ds, full_screen);
    3.37  Index: ioemu/vl.h
    3.38  ===================================================================
    3.39 ---- ioemu.orig/vl.h	2006-09-21 19:08:38.000000000 +0100
    3.40 -+++ ioemu/vl.h	2006-09-21 19:10:53.000000000 +0100
    3.41 +--- ioemu.orig/vl.h	2006-09-21 19:26:24.000000000 +0100
    3.42 ++++ ioemu/vl.h	2006-09-21 19:29:50.000000000 +0100
    3.43  @@ -786,6 +786,7 @@
    3.44   
    3.45   /* vnc.c */