From patchwork Mon Jul 2 08:20:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 168503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id ECE902C01BE for ; Mon, 2 Jul 2012 18:20:25 +1000 (EST) Received: from localhost ([::1]:55548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Slbrr-0001Nt-Ks for incoming@patchwork.ozlabs.org; Mon, 02 Jul 2012 04:20:23 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Slbrh-0001NY-La for qemu-devel@nongnu.org; Mon, 02 Jul 2012 04:20:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Slbrc-0000WZ-Ii for qemu-devel@nongnu.org; Mon, 02 Jul 2012 04:20:13 -0400 Received: from david.siemens.de ([192.35.17.14]:15381) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Slbrc-0000VT-9H for qemu-devel@nongnu.org; Mon, 02 Jul 2012 04:20:08 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.13.6/8.13.6) with ESMTP id q628K4gH032501; Mon, 2 Jul 2012 10:20:04 +0200 Received: from mchn199C.mchp.siemens.de ([139.22.107.245]) by mail1.siemens.de (8.13.6/8.13.6) with SMTP id q628K3HJ012490; Mon, 2 Jul 2012 10:20:03 +0200 Message-ID: <4FF159B2.4010405@siemens.com> Date: Mon, 02 Jul 2012 10:20:02 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: qemu-devel , Anthony Liguori X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.14 Cc: Javier Donoso Subject: [Qemu-devel] [PATCH] vga: Implement blinking of text cursor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Let the text cursor blink at 5 Hz. No timer is used, instead we rely on the fact that the display is updated periodically. Signed-off-by: Jan Kiszka --- hw/vga.c | 14 +++++++++++++- hw/vga_int.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletions(-) diff --git a/hw/vga.c b/hw/vga.c index acb3f7d..f22c4d9 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -38,6 +38,8 @@ //#define DEBUG_BOCHS_VBE +#define VGA_TEXT_CURSOR_PERIOD 200 + /* * Video Graphics Array (VGA) * @@ -1300,6 +1302,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 +1373,11 @@ 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; + s->cursor_blink_state ^= 1; + full_update = 1; + } depth_index = get_depth_index(s->ds); if (cw == 16) @@ -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_blink_state != 0) { int line_start, line_last, h; /* draw the cursor */ line_start = s->cr[VGA_CRTC_CURSOR_START] & 0x1f; @@ -1884,6 +1893,9 @@ 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) + VGA_TEXT_CURSOR_PERIOD; + s->cursor_blink_state = 1; full_update = 1; } switch(graphic_mode) { diff --git a/hw/vga_int.h b/hw/vga_int.h index 3b38764..c374474 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; + int cursor_blink_state; + int64_t cursor_blink_time; uint32_t cursor_offset; unsigned int (*rgb_to_pixel)(unsigned int r, unsigned int g, unsigned b);