ia64/xen-unstable
changeset 10737:8eb79da98499
[IOEMU] Enable gui_timer unless the display is exported over VNC.
Based on bug report from: Huang2, Wei <Wei.Huang2@amd.com>
Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
Based on bug report from: Huang2, Wei <Wei.Huang2@amd.com>
Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author | chris@kneesaa.uk.xensource.com |
---|---|
date | Thu Jul 13 10:27:08 2006 +0100 (2006-07-13) |
parents | 2937703f0ed0 |
children | 3c841b50afb9 |
files | tools/ioemu/patches/vnc-fixes tools/ioemu/vl.c |
line diff
1.1 --- a/tools/ioemu/patches/vnc-fixes Thu Jul 13 10:13:26 2006 +0100 1.2 +++ b/tools/ioemu/patches/vnc-fixes Thu Jul 13 10:27:08 2006 +0100 1.3 @@ -1,19 +1,24 @@ 1.4 -diff -r 15da4d2106fe vl.c 1.5 ---- a/vl.c Thu Jul 06 14:27:28 2006 +0100 1.6 -+++ b/vl.c Thu Jul 06 20:19:49 2006 +0100 1.7 -@@ -5972,8 +5972,7 @@ int main(int argc, char **argv) 1.8 +Index: ioemu/vl.c 1.9 +=================================================================== 1.10 +--- ioemu.orig/vl.c 2006-07-13 10:09:33.965343475 +0100 1.11 ++++ ioemu/vl.c 2006-07-13 10:10:11.141134364 +0100 1.12 +@@ -5972,8 +5972,10 @@ 1.13 kernel_filename, kernel_cmdline, initrd_filename, 1.14 timeoffset); 1.15 1.16 - gui_timer = qemu_new_timer(rt_clock, gui_update, NULL); 1.17 - qemu_mod_timer(gui_timer, qemu_get_clock(rt_clock)); 1.18 -+ display_state.dpy_refresh(&display_state); 1.19 ++ if (vnc_display == -1) { 1.20 ++ gui_timer = qemu_new_timer(rt_clock, gui_update, NULL); 1.21 ++ qemu_mod_timer(gui_timer, qemu_get_clock(rt_clock)); 1.22 ++ } 1.23 1.24 #ifdef CONFIG_GDBSTUB 1.25 if (use_gdbstub) { 1.26 -diff -r 15da4d2106fe vnc.c 1.27 ---- a/vnc.c Thu Jul 06 14:27:28 2006 +0100 1.28 -+++ b/vnc.c Thu Jul 06 20:19:49 2006 +0100 1.29 +Index: ioemu/vnc.c 1.30 +=================================================================== 1.31 +--- ioemu.orig/vnc.c 2006-07-13 10:09:33.963343701 +0100 1.32 ++++ ioemu/vnc.c 2006-07-13 10:09:34.025336681 +0100 1.33 @@ -3,6 +3,7 @@ 1.34 * 1.35 * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws> 1.36 @@ -22,7 +27,7 @@ diff -r 15da4d2106fe vnc.c 1.37 * 1.38 * Permission is hereby granted, free of charge, to any person obtaining a copy 1.39 * of this software and associated documentation files (the "Software"), to deal 1.40 -@@ -51,7 +52,11 @@ struct VncState 1.41 +@@ -51,7 +52,11 @@ 1.42 int need_update; 1.43 int width; 1.44 int height; 1.45 @@ -35,7 +40,7 @@ diff -r 15da4d2106fe vnc.c 1.46 char *old_data; 1.47 int depth; 1.48 int has_resize; 1.49 -@@ -62,13 +67,25 @@ struct VncState 1.50 +@@ -62,13 +67,25 @@ 1.51 1.52 VncReadEvent *read_handler; 1.53 size_t read_handler_expect; 1.54 @@ -47,13 +52,13 @@ diff -r 15da4d2106fe vnc.c 1.55 + 1.56 + int slow_client; 1.57 }; 1.58 -+ 1.59 + 1.60 +#define DIRTY_PIXEL_BITS 64 1.61 +#define X2DP_DOWN(vs, x) ((x) >> (vs)->dirty_pixel_shift) 1.62 +#define X2DP_UP(vs, x) \ 1.63 + (((x) + (1ULL << (vs)->dirty_pixel_shift) - 1) >> (vs)->dirty_pixel_shift) 1.64 +#define DP2X(vs, x) ((x) << (vs)->dirty_pixel_shift) 1.65 - 1.66 ++ 1.67 /* TODO 1.68 1) Get the queue working for IO. 1.69 2) there is some weirdness when using the -S option (the screen is grey 1.70 @@ -62,22 +67,20 @@ diff -r 15da4d2106fe vnc.c 1.71 */ 1.72 1.73 static void vnc_write(VncState *vs, const void *data, size_t len); 1.74 -@@ -77,22 +94,38 @@ static void vnc_write_u16(VncState *vs, 1.75 +@@ -77,22 +94,38 @@ 1.76 static void vnc_write_u16(VncState *vs, uint16_t value); 1.77 static void vnc_write_u8(VncState *vs, uint8_t value); 1.78 static void vnc_flush(VncState *vs); 1.79 +static void _vnc_update_client(void *opaque); 1.80 static void vnc_update_client(void *opaque); 1.81 static void vnc_client_read(void *opaque); 1.82 -- 1.83 ++static void framebuffer_set_updated(VncState *vs, int x, int y, int w, int h); 1.84 + 1.85 -static void vnc_dpy_update(DisplayState *ds, int x, int y, int w, int h) 1.86 --{ 1.87 -- VncState *vs = ds->opaque; 1.88 -+static void framebuffer_set_updated(VncState *vs, int x, int y, int w, int h); 1.89 -+ 1.90 +static void set_bits_in_row(VncState *vs, uint64_t *row, 1.91 + int x, int y, int w, int h) 1.92 -+{ 1.93 + { 1.94 +- VncState *vs = ds->opaque; 1.95 + int x1, x2; 1.96 uint64_t mask; 1.97 1.98 @@ -109,7 +112,7 @@ diff -r 15da4d2106fe vnc.c 1.99 } 1.100 1.101 static void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h, 1.102 -@@ -109,11 +142,15 @@ static void vnc_dpy_resize(DisplayState 1.103 +@@ -109,11 +142,15 @@ 1.104 static void vnc_dpy_resize(DisplayState *ds, int w, int h) 1.105 { 1.106 VncState *vs = ds->opaque; 1.107 @@ -117,17 +120,16 @@ diff -r 15da4d2106fe vnc.c 1.108 1.109 ds->data = realloc(ds->data, w * h * vs->depth); 1.110 vs->old_data = realloc(vs->old_data, w * h * vs->depth); 1.111 -- 1.112 -- if (ds->data == NULL || vs->old_data == NULL) { 1.113 + vs->dirty_row = realloc(vs->dirty_row, h * sizeof(vs->dirty_row[0])); 1.114 + vs->update_row = realloc(vs->update_row, h * sizeof(vs->dirty_row[0])); 1.115 -+ 1.116 + 1.117 +- if (ds->data == NULL || vs->old_data == NULL) { 1.118 + if (ds->data == NULL || vs->old_data == NULL || 1.119 + vs->dirty_row == NULL || vs->update_row == NULL) { 1.120 fprintf(stderr, "vnc: memory allocation failed\n"); 1.121 exit(1); 1.122 } 1.123 -@@ -131,6 +168,10 @@ static void vnc_dpy_resize(DisplayState 1.124 +@@ -131,6 +168,10 @@ 1.125 vs->width = ds->width; 1.126 vs->height = ds->height; 1.127 } 1.128 @@ -138,14 +140,13 @@ diff -r 15da4d2106fe vnc.c 1.129 } 1.130 1.131 static void send_framebuffer_update_raw(VncState *vs, int x, int y, int w, int h) 1.132 -@@ -215,8 +256,20 @@ static void vnc_copy(DisplayState *ds, i 1.133 +@@ -215,8 +256,20 @@ 1.134 int y = 0; 1.135 int pitch = ds->linesize; 1.136 VncState *vs = ds->opaque; 1.137 -- 1.138 ++ int updating_client = !vs->slow_client; 1.139 + 1.140 - vnc_update_client(vs); 1.141 -+ int updating_client = !vs->slow_client; 1.142 -+ 1.143 + if (src_x < vs->visible_x || src_y < vs->visible_y || 1.144 + dst_x < vs->visible_x || dst_y < vs->visible_y || 1.145 + (src_x + w) > (vs->visible_x + vs->visible_w) || 1.146 @@ -161,7 +162,7 @@ diff -r 15da4d2106fe vnc.c 1.147 1.148 if (dst_y > src_y) { 1.149 y = h - 1; 1.150 -@@ -238,31 +291,34 @@ static void vnc_copy(DisplayState *ds, i 1.151 +@@ -238,31 +291,34 @@ 1.152 old_row += pitch; 1.153 } 1.154 1.155 @@ -172,9 +173,6 @@ diff -r 15da4d2106fe vnc.c 1.156 - vnc_write_u16(vs, src_x); 1.157 - vnc_write_u16(vs, src_y); 1.158 - vnc_flush(vs); 1.159 --} 1.160 -- 1.161 --static int find_dirty_height(VncState *vs, int y, int last_x, int x) 1.162 + if (updating_client && vs->csock != -1 && !vs->has_update) { 1.163 + vnc_write_u8(vs, 0); /* msg id */ 1.164 + vnc_write_u8(vs, 0); 1.165 @@ -185,8 +183,9 @@ diff -r 15da4d2106fe vnc.c 1.166 + vnc_flush(vs); 1.167 + } else 1.168 + framebuffer_set_updated(vs, dst_x, dst_y, w, h); 1.169 -+} 1.170 -+ 1.171 + } 1.172 + 1.173 +-static int find_dirty_height(VncState *vs, int y, int last_x, int x) 1.174 +static int find_update_height(VncState *vs, int y, int maxy, int last_x, int x) 1.175 { 1.176 int h; 1.177 @@ -210,25 +209,24 @@ diff -r 15da4d2106fe vnc.c 1.178 { 1.179 VncState *vs = opaque; 1.180 int64_t now = qemu_get_clock(rt_clock); 1.181 -@@ -274,11 +330,12 @@ static void vnc_update_client(void *opaq 1.182 +@@ -274,11 +330,12 @@ 1.183 uint64_t width_mask; 1.184 int n_rectangles; 1.185 int saved_offset; 1.186 - int has_dirty = 0; 1.187 -- 1.188 ++ int maxx, maxy; 1.189 ++ int tile_bytes = vs->depth * DP2X(vs, 1); 1.190 + 1.191 - width_mask = (1ULL << (vs->width / 16)) - 1; 1.192 - 1.193 - if (vs->width == 1024) 1.194 -+ int maxx, maxy; 1.195 -+ int tile_bytes = vs->depth * DP2X(vs, 1); 1.196 -+ 1.197 + if (vs->width != DP2X(vs, DIRTY_PIXEL_BITS)) 1.198 + width_mask = (1ULL << X2DP_UP(vs, vs->ds->width)) - 1; 1.199 + else 1.200 width_mask = ~(0ULL); 1.201 1.202 /* Walk through the dirty map and eliminate tiles that 1.203 -@@ -294,16 +351,18 @@ static void vnc_update_client(void *opaq 1.204 +@@ -294,16 +351,18 @@ 1.205 ptr = row; 1.206 old_ptr = old_row; 1.207 1.208 @@ -255,7 +253,7 @@ diff -r 15da4d2106fe vnc.c 1.209 } 1.210 } 1.211 1.212 -@@ -311,7 +370,8 @@ static void vnc_update_client(void *opaq 1.213 +@@ -311,7 +370,8 @@ 1.214 old_row += vs->ds->linesize; 1.215 } 1.216 1.217 @@ -265,7 +263,7 @@ diff -r 15da4d2106fe vnc.c 1.218 goto out; 1.219 1.220 /* Count rectangles */ 1.221 -@@ -321,38 +381,59 @@ static void vnc_update_client(void *opaq 1.222 +@@ -321,40 +381,61 @@ 1.223 saved_offset = vs->output.offset; 1.224 vnc_write_u16(vs, 0); 1.225 1.226 @@ -314,30 +312,32 @@ diff -r 15da4d2106fe vnc.c 1.227 } 1.228 vs->output.buffer[saved_offset] = (n_rectangles >> 8) & 0xFF; 1.229 vs->output.buffer[saved_offset + 1] = n_rectangles & 0xFF; 1.230 -+ 1.231 +- vnc_flush(vs); 1.232 + 1.233 +- } 1.234 + vs->has_update = 0; 1.235 + vs->need_update = 0; 1.236 - vnc_flush(vs); 1.237 -- 1.238 -- } 1.239 ++ vnc_flush(vs); 1.240 + vs->slow_client = 0; 1.241 + } else 1.242 + vs->slow_client = 1; 1.243 1.244 out: 1.245 qemu_mod_timer(vs->timer, now + VNC_REFRESH_INTERVAL); 1.246 -+} 1.247 -+ 1.248 + } 1.249 + 1.250 +static void vnc_update_client(void *opaque) 1.251 +{ 1.252 + VncState *vs = opaque; 1.253 + 1.254 + vs->ds->dpy_refresh(vs->ds); 1.255 + _vnc_update_client(vs); 1.256 - } 1.257 - 1.258 ++} 1.259 ++ 1.260 static void vnc_timer_init(VncState *vs) 1.261 -@@ -365,8 +446,6 @@ static void vnc_timer_init(VncState *vs) 1.262 + { 1.263 + if (vs->timer == NULL) { 1.264 +@@ -365,8 +446,6 @@ 1.265 1.266 static void vnc_dpy_refresh(DisplayState *ds) 1.267 { 1.268 @@ -346,7 +346,7 @@ diff -r 15da4d2106fe vnc.c 1.269 vga_hw_update(); 1.270 } 1.271 1.272 -@@ -402,7 +481,7 @@ static char *buffer_end(Buffer *buffer) 1.273 +@@ -402,7 +481,7 @@ 1.274 1.275 static void buffer_reset(Buffer *buffer) 1.276 { 1.277 @@ -355,7 +355,7 @@ diff -r 15da4d2106fe vnc.c 1.278 } 1.279 1.280 static void buffer_append(Buffer *buffer, const void *data, size_t len) 1.281 -@@ -443,12 +522,12 @@ static void vnc_client_write(void *opaqu 1.282 +@@ -443,12 +522,12 @@ 1.283 if (!ret) 1.284 return; 1.285 1.286 @@ -371,7 +371,7 @@ diff -r 15da4d2106fe vnc.c 1.287 } 1.288 1.289 static void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting) 1.290 -@@ -480,11 +559,11 @@ static void vnc_client_read(void *opaque 1.291 +@@ -480,11 +559,11 @@ 1.292 return; 1.293 1.294 if (!ret) { 1.295 @@ -386,7 +386,7 @@ diff -r 15da4d2106fe vnc.c 1.296 } 1.297 } 1.298 1.299 -@@ -492,9 +571,9 @@ static void vnc_write(VncState *vs, cons 1.300 +@@ -492,9 +571,9 @@ 1.301 { 1.302 buffer_reserve(&vs->output, len); 1.303 1.304 @@ -399,7 +399,7 @@ diff -r 15da4d2106fe vnc.c 1.305 1.306 buffer_append(&vs->output, data, len); 1.307 } 1.308 -@@ -616,24 +695,25 @@ static void key_event(VncState *vs, int 1.309 +@@ -616,24 +695,25 @@ 1.310 do_key_event(vs, down, sym); 1.311 } 1.312 1.313 @@ -438,7 +438,7 @@ diff -r 15da4d2106fe vnc.c 1.314 } 1.315 1.316 static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) 1.317 -@@ -690,8 +770,6 @@ static void set_pixel_format(VncState *v 1.318 +@@ -690,8 +770,6 @@ 1.319 vnc_client_error(vs); 1.320 1.321 vnc_dpy_resize(vs->ds, vs->ds->width, vs->ds->height); 1.322 @@ -447,7 +447,7 @@ diff -r 15da4d2106fe vnc.c 1.323 1.324 vga_hw_invalidate(); 1.325 vga_hw_update(); 1.326 -@@ -848,11 +926,11 @@ static void vnc_listen_read(void *opaque 1.327 +@@ -848,11 +926,11 @@ 1.328 vnc_write(vs, "RFB 003.003\n", 12); 1.329 vnc_flush(vs); 1.330 vnc_read_when(vs, protocol_version, 12); 1.331 @@ -461,7 +461,7 @@ diff -r 15da4d2106fe vnc.c 1.332 } 1.333 } 1.334 1.335 -@@ -909,17 +987,15 @@ void vnc_display_init(DisplayState *ds, 1.336 +@@ -909,17 +987,15 @@ 1.337 exit(1); 1.338 } 1.339
2.1 --- a/tools/ioemu/vl.c Thu Jul 13 10:13:26 2006 +0100 2.2 +++ b/tools/ioemu/vl.c Thu Jul 13 10:27:08 2006 +0100 2.3 @@ -5972,7 +5972,10 @@ int main(int argc, char **argv) 2.4 kernel_filename, kernel_cmdline, initrd_filename, 2.5 timeoffset); 2.6 2.7 - display_state.dpy_refresh(&display_state); 2.8 + if (vnc_display == -1) { 2.9 + gui_timer = qemu_new_timer(rt_clock, gui_update, NULL); 2.10 + qemu_mod_timer(gui_timer, qemu_get_clock(rt_clock)); 2.11 + } 2.12 2.13 #ifdef CONFIG_GDBSTUB 2.14 if (use_gdbstub) {