From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LQ5Gk-0001MB-TE for qemu-devel@nongnu.org; Thu, 22 Jan 2009 14:31:14 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LQ5Gh-0001Hr-Vw for qemu-devel@nongnu.org; Thu, 22 Jan 2009 14:31:12 -0500 Received: from [199.232.76.173] (port=38448 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQ5Gh-0001Hc-9z for qemu-devel@nongnu.org; Thu, 22 Jan 2009 14:31:11 -0500 Received: from oxygen.pond.sub.org ([213.239.205.148]:60673) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LQ5Gg-0006Iw-Iw for qemu-devel@nongnu.org; Thu, 22 Jan 2009 14:31:10 -0500 Received: from pike.pond.sub.org (pD9E3B496.dip.t-dialin.net [217.227.180.150]) by oxygen.pond.sub.org (Postfix) with ESMTPA id B5BC9276CAE for ; Thu, 22 Jan 2009 20:31:05 +0100 (CET) From: Markus Armbruster Date: Thu, 22 Jan 2009 20:30:58 +0100 Message-Id: <1232652665-1710-2-git-send-email-armbru@redhat.com> In-Reply-To: <87ocxzrvqb.fsf@pike.pond.sub.org> References: <87ocxzrvqb.fsf@pike.pond.sub.org> Subject: [Qemu-devel] [PATCH 2/9] Clean up handling of name=value, ... part of -vga option argument Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Markus Armbruster Move interpretation of the option argument from select_vgahw() into the device initialization functions. The only one that's currently interested is vga_common_init(). Use get_param_value() there instead of the special purpose code select_vgahw() used to use. The move permits hiding vga_retrace_method & friends in vga.c, so do that. --- hw/pc.h | 7 +------ hw/vga.c | 34 +++++++++++++++++----------------- vl.c | 19 +++++-------------- 3 files changed, 23 insertions(+), 37 deletions(-) diff --git a/hw/pc.h b/hw/pc.h index 1ba3d9e..f43c138 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -119,12 +119,7 @@ extern PCIDevice *piix4_dev; int piix4_init(PCIBus *bus, int devfn); /* vga.c */ -enum vga_retrace_method { - VGA_RETRACE_DUMB, - VGA_RETRACE_PRECISE -}; - -extern enum vga_retrace_method vga_retrace_method; +extern const char *vga_opts; #ifndef TARGET_SPARC #define VGA_RAM_SIZE (8192 * 1024) diff --git a/hw/vga.c b/hw/vga.c index 776ead0..164e652 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -29,6 +29,7 @@ #include "pixel_ops.h" #include "qemu-timer.h" #include "kvm.h" +#include "sysemu.h" //#define DEBUG_VGA //#define DEBUG_VGA_MEM @@ -1922,13 +1923,8 @@ void vga_reset(void *opaque) memset(s->invalidated_y_table, '\0', sizeof(s->invalidated_y_table)); memset(s->last_palette, '\0', sizeof(s->last_palette)); memset(s->last_ch_attr, '\0', sizeof(s->last_ch_attr)); - switch (vga_retrace_method) { - case VGA_RETRACE_DUMB: - break; - case VGA_RETRACE_PRECISE: + if (s->retrace == vga_precise_retrace) memset(&s->retrace_info, 0, sizeof (s->retrace_info)); - break; - } } #define TEXTMODE_X(x) ((x) % width) @@ -2257,7 +2253,8 @@ static void vga_map(PCIDevice *pci_dev, int region_num, void vga_common_init(VGAState *s, uint8_t *vga_ram_base, ram_addr_t vga_ram_offset, int vga_ram_size) { - int i, j, v, b; + int i, j, v, b, precise_retrace; + char buf[32]; for(i = 0;i < 256; i++) { v = 0; @@ -2292,16 +2289,19 @@ void vga_common_init(VGAState *s, uint8_t *vga_ram_base, s->invalidate = vga_invalidate_display; s->screen_dump = vga_screen_dump; s->text_update = vga_update_text; - switch (vga_retrace_method) { - case VGA_RETRACE_DUMB: - s->retrace = vga_dumb_retrace; - s->update_retrace_info = vga_dumb_update_retrace_info; - break; - - case VGA_RETRACE_PRECISE: - s->retrace = vga_precise_retrace; - s->update_retrace_info = vga_precise_update_retrace_info; - break; + precise_retrace = 0; + if (get_param_value(buf, sizeof(buf), "retrace", vga_opts)) { + if (!strcmp(buf, "precise")) + precise_retrace = 1; + else if (strcmp(buf, "dumb")) + fprintf(stderr, "Unknown VGA retrace=%s ignored\n", buf); + } + if (precise_retrace) { + s->retrace = vga_precise_retrace; + s->update_retrace_info = vga_precise_update_retrace_info; + } else { + s->retrace = vga_dumb_retrace; + s->update_retrace_info = vga_dumb_update_retrace_info; } vga_reset(s); } diff --git a/vl.c b/vl.c index 63d954b..4c1045c 100644 --- a/vl.c +++ b/vl.c @@ -186,7 +186,6 @@ static IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS]; DriveInfo drives_table[MAX_DRIVES+1]; int nb_drives; static int vga_ram_size; -enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; static DisplayState *display_state; int nographic; static int curses; @@ -202,6 +201,7 @@ static int rtc_date_offset = -1; /* -1 means no change */ int cirrus_vga_enabled = 1; int std_vga_enabled = 0; int vmsvga_enabled = 0; +const char *vga_opts = ""; #ifdef TARGET_SPARC int graphic_width = 1024; int graphic_height = 768; @@ -4430,19 +4430,10 @@ static void select_vgahw (const char *p) fprintf(stderr, "Unknown vga type: %s\n", p); exit(1); } - while (*opts) { - const char *nextopt; - - if (strstart(opts, ",retrace=", &nextopt)) { - opts = nextopt; - if (strstart(opts, "dumb", &nextopt)) - vga_retrace_method = VGA_RETRACE_DUMB; - else if (strstart(opts, "precise", &nextopt)) - vga_retrace_method = VGA_RETRACE_PRECISE; - else goto invalid_vga; - } else goto invalid_vga; - opts = nextopt; - } + if (opts[0] == ',') + vga_opts = opts + 1; + else if (opts[0]) + goto invalid_vga; } #ifdef _WIN32 -- 1.6.0.6