From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmTif-0006sE-Ps for qemu-devel@nongnu.org; Wed, 04 Jul 2012 13:50:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SmTiD-0003Bi-0Z for qemu-devel@nongnu.org; Wed, 04 Jul 2012 13:50:29 -0400 Received: from goliath.siemens.de ([192.35.17.28]:20209) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmTiC-0003Be-Ne for qemu-devel@nongnu.org; Wed, 04 Jul 2012 13:50:00 -0400 Message-ID: <4FF48242.4060108@siemens.com> Date: Wed, 04 Jul 2012 19:49:54 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <4FF159B2.4010405@siemens.com> <4FF447B9.2010103@siemens.com> <4FF46EBA.3000105@weilnetz.de> <4FF4811F.4000104@siemens.com> In-Reply-To: <4FF4811F.4000104@siemens.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH v3] vga: Implement blinking of text cursor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel , Anthony Liguori Cc: Blue Swirl , Javier Donoso , Stefan Weil Let the text cursor blink at 1.875 Hz, the original VGA cursor frequency. No timer is used, instead we rely on the fact that the display is updated periodically. Signed-off-by: Jan Kiszka --- Changes in v3: - adjusted frequency to original value - fixed semantic of VGA_TEXT_CURSOR_PERIOD_MS hw/vga.c | 14 ++++++++++++-- hw/vga_int.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/vga.c b/hw/vga.c index acb3f7d..f82ced8 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -38,6 +38,9 @@ //#define DEBUG_BOCHS_VBE +/* 16 state changes per vertical frame @60 Hz */ +#define VGA_TEXT_CURSOR_PERIOD_MS (1000 * 2 * 16 / 60) + /* * Video Graphics Array (VGA) * @@ -1300,6 +1303,7 @@ static void vga_draw_text(VGACommonState *s, int full_update) uint32_t *ch_attr_ptr; vga_draw_glyph8_func *vga_draw_glyph8; vga_draw_glyph9_func *vga_draw_glyph9; + int64_t now = qemu_get_clock_ms(vm_clock); /* compute font data address (in plane 2) */ v = s->sr[VGA_SEQ_CHARACTER_MAP]; @@ -1370,6 +1374,10 @@ static void vga_draw_text(VGACommonState *s, int full_update) s->cursor_end = s->cr[VGA_CRTC_CURSOR_END]; } cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) * 4; + if (now >= s->cursor_blink_time) { + s->cursor_blink_time = now + VGA_TEXT_CURSOR_PERIOD_MS / 2; + s->cursor_visible_phase = !s->cursor_visible_phase; + } depth_index = get_depth_index(s->ds); if (cw == 16) @@ -1390,7 +1398,7 @@ static void vga_draw_text(VGACommonState *s, int full_update) cx_max = -1; for(cx = 0; cx < width; cx++) { ch_attr = *(uint16_t *)src; - if (full_update || ch_attr != *ch_attr_ptr) { + if (full_update || ch_attr != *ch_attr_ptr || src == cursor_ptr) { if (cx < cx_min) cx_min = cx; if (cx > cx_max) @@ -1420,7 +1428,8 @@ static void vga_draw_text(VGACommonState *s, int full_update) font_ptr, cheight, fgcol, bgcol, dup9); } if (src == cursor_ptr && - !(s->cr[VGA_CRTC_CURSOR_START] & 0x20)) { + !(s->cr[VGA_CRTC_CURSOR_START] & 0x20) && + s->cursor_visible_phase) { int line_start, line_last, h; /* draw the cursor */ line_start = s->cr[VGA_CRTC_CURSOR_START] & 0x1f; @@ -1884,6 +1893,7 @@ static void vga_update_display(void *opaque) } if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; + s->cursor_blink_time = qemu_get_clock_ms(vm_clock); full_update = 1; } switch(graphic_mode) { diff --git a/hw/vga_int.h b/hw/vga_int.h index 3b38764..8938093 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -156,6 +156,8 @@ typedef struct VGACommonState { uint32_t last_scr_width, last_scr_height; /* in pixels */ uint32_t last_depth; /* in bits */ uint8_t cursor_start, cursor_end; + bool cursor_visible_phase; + int64_t cursor_blink_time; uint32_t cursor_offset; unsigned int (*rgb_to_pixel)(unsigned int r, unsigned int g, unsigned b); -- 1.7.3.4