All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] [RFC] Variable video ram size option
@ 2009-01-09 19:45 Trolle Selander
  2009-01-10  0:02 ` Paul Brook
  2009-01-11  7:53 ` Avi Kivity
  0 siblings, 2 replies; 24+ messages in thread
From: Trolle Selander @ 2009-01-09 19:45 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1307 bytes --]

These patches are "extracted" from a patch-set I made for Xen. Any 
xen-specific parts have been removed. The patches do away with the 
statically defined VGA_RAM_ SIZE and provides a new -videoram option to 
enable setting the amount of video ram available to the VM. Shrinking 
default video ram used to 4 Megs (which is all that the default Cirrus 
card can use, anyway - previously, there's been a "waste" of 4 megs with 
the statically defined 8 Megs), but allowing users to specify up to 16 
Megs of vram, to support the very high resolutions such as 2560x1600x32 
that are available on today's high-end displays.
The vgabios patch is needed for this to work, both for the variable size 
video ram, and to add the new resolutions. The defines for the high 
resolution and wide-screen modes were taken from what is already in 
qemu-kvm, so getting this into qemu mainline should get qemu/kvm & xen 
"in sync" in this regard.

Special thanks to Stefano Stabellini for comments & constructive 
criticism, and some save/restore fixes on the Xen version of this patch-set.

I'll brace myself for reports of how this patch breaks all the non-x86 
architectures that qemu emulates... :)

Regards,
Trolle

Signed-off-by: Trolle Selander <trolle.selander@eu.citrix.com 
<mailto:trolle.selander@eu.citrix.com>>

[-- Attachment #2: vgabios_variable_vram_size.patch --]
[-- Type: text/plain, Size: 8500 bytes --]

diff -uNr vgabios-orig/vbe.c vgabios/vbe.c
--- vgabios-orig/vbe.c	2008-03-02 02:47:21.000000000 -0500
+++ vgabios/vbe.c	2008-12-16 12:43:05.167692121 -0500
@@ -38,8 +38,6 @@
 #include "vbe.h"
 #include "vbetables.h"
 
-#define VBE_TOTAL_VIDEO_MEMORY_DIV_64K (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB*1024/64)
-
 // The current OEM Software Revision of this VBE Bios
 #define VBE_OEM_SOFTWARE_REV 0x0002;
 
@@ -821,7 +819,8 @@
         vbe_info_block.VideoModePtr_Off= DI + 34;
 
         // VBE Total Memory (in 64b blocks)
-        vbe_info_block.TotalMemory = VBE_TOTAL_VIDEO_MEMORY_DIV_64K;
+        outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VIDEO_MEMORY_64K);
+        vbe_info_block.TotalMemory = inw(VBE_DISPI_IOPORT_DATA);
 
         if (vbe2_info)
 	{
@@ -846,7 +845,8 @@
         do
         {
                 if ((cur_info->info.XResolution <= dispi_get_max_xres()) &&
-                    (cur_info->info.BitsPerPixel <= dispi_get_max_bpp())) {
+                    (cur_info->info.BitsPerPixel <= dispi_get_max_bpp()) &&
+                    (cur_info->info.XResolution * cur_info->info.XResolution * cur_info->info.BitsPerPixel <= vbe_info_block.TotalMemory << 19 )) {
 #ifdef DEBUG
                   printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode);
 #endif
@@ -855,7 +855,7 @@
                   cur_ptr+=2;
                 } else {
 #ifdef DEBUG
-                  printf("VBE mode %x (xres=%x / bpp=%02x) not supported by display\n", cur_info->mode,cur_info->info.XResolution,cur_info->info.BitsPerPixel);
+                  printf("VBE mode %x (xres=%x / bpp=%02x) not supported \n", cur_info->mode,cur_info->info.XResolution,cur_info->info.BitsPerPixel);
 #endif
                 }
                 cur_info++;
@@ -913,7 +913,13 @@
                   info.WinFuncPtr = 0xC0000000UL;
                   *(Bit16u *)&(info.WinFuncPtr) = (Bit16u)(dispi_set_bank_farcall);
                 }
-                
+                outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_LFB_ADDRESS_H);
+                info.PhysBasePtr = inw(VBE_DISPI_IOPORT_DATA);
+                info.PhysBasePtr = info.PhysBasePtr << 16;
+#if 0					
+                outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_LFB_ADDRESS_L);
+                info.PhysBasePtr |= inw(VBE_DISPI_IOPORT_DATA);
+#endif 							
                 result = 0x4f;
         }
         else
diff -uNr vgabios-orig/vbe.h vgabios/vbe.h
--- vgabios-orig/vbe.h	2006-08-12 03:47:34.000000000 -0400
+++ vgabios/vbe.h	2008-12-16 12:43:05.168692173 -0500
@@ -275,39 +275,41 @@
 //        like 0xE0000000
 
 
-  #define VBE_DISPI_BANK_ADDRESS          0xA0000
-  #define VBE_DISPI_BANK_SIZE_KB          64
+  #define VBE_DISPI_BANK_ADDRESS           0xA0000
+  #define VBE_DISPI_BANK_SIZE_KB           64
   
-  #define VBE_DISPI_MAX_XRES              1024
-  #define VBE_DISPI_MAX_YRES              768
+  #define VBE_DISPI_MAX_XRES               2560
+  #define VBE_DISPI_MAX_YRES               1600
   
-  #define VBE_DISPI_IOPORT_INDEX          0x01CE
-  #define VBE_DISPI_IOPORT_DATA           0x01CF
+  #define VBE_DISPI_IOPORT_INDEX           0x01CE
+  #define VBE_DISPI_IOPORT_DATA            0x01CF
   
-  #define VBE_DISPI_INDEX_ID              0x0
-  #define VBE_DISPI_INDEX_XRES            0x1
-  #define VBE_DISPI_INDEX_YRES            0x2
-  #define VBE_DISPI_INDEX_BPP             0x3
-  #define VBE_DISPI_INDEX_ENABLE          0x4
-  #define VBE_DISPI_INDEX_BANK            0x5
-  #define VBE_DISPI_INDEX_VIRT_WIDTH      0x6
-  #define VBE_DISPI_INDEX_VIRT_HEIGHT     0x7
-  #define VBE_DISPI_INDEX_X_OFFSET        0x8
-  #define VBE_DISPI_INDEX_Y_OFFSET        0x9
-      
-  #define VBE_DISPI_ID0                   0xB0C0
-  #define VBE_DISPI_ID1                   0xB0C1
-  #define VBE_DISPI_ID2                   0xB0C2
-  #define VBE_DISPI_ID3                   0xB0C3
-  #define VBE_DISPI_ID4                   0xB0C4
-  
-  #define VBE_DISPI_DISABLED              0x00
-  #define VBE_DISPI_ENABLED               0x01
-  #define VBE_DISPI_GETCAPS               0x02
-  #define VBE_DISPI_8BIT_DAC              0x20
-  #define VBE_DISPI_LFB_ENABLED           0x40
-  #define VBE_DISPI_NOCLEARMEM            0x80
-  
-  #define VBE_DISPI_LFB_PHYSICAL_ADDRESS  0xE0000000
+  #define VBE_DISPI_INDEX_ID               0x0
+  #define VBE_DISPI_INDEX_XRES             0x1
+  #define VBE_DISPI_INDEX_YRES             0x2
+  #define VBE_DISPI_INDEX_BPP              0x3
+  #define VBE_DISPI_INDEX_ENABLE           0x4
+  #define VBE_DISPI_INDEX_BANK             0x5
+  #define VBE_DISPI_INDEX_VIRT_WIDTH       0x6
+  #define VBE_DISPI_INDEX_VIRT_HEIGHT      0x7
+  #define VBE_DISPI_INDEX_X_OFFSET         0x8
+  #define VBE_DISPI_INDEX_Y_OFFSET         0x9
+  #define VBE_DISPI_INDEX_VIDEO_MEMORY_64K 0xa
+  #define VBE_DISPI_INDEX_LFB_ADDRESS_H    0xb
+  #define VBE_DISPI_INDEX_LFB_ADDRESS_L    0xc
+
+  #define VBE_DISPI_LFB_PHYSICAL_ADDRESS   0xE0000000
+  #define VBE_DISPI_ID0                    0xB0C0
+  #define VBE_DISPI_ID1                    0xB0C1
+  #define VBE_DISPI_ID2                    0xB0C2
+  #define VBE_DISPI_ID3                    0xB0C3
+  #define VBE_DISPI_ID4                    0xB0C4
+
+  #define VBE_DISPI_DISABLED               0x00
+  #define VBE_DISPI_ENABLED                0x01
+  #define VBE_DISPI_GETCAPS                0x02
+  #define VBE_DISPI_8BIT_DAC               0x20
+  #define VBE_DISPI_LFB_ENABLED            0x40
+  #define VBE_DISPI_NOCLEARMEM             0x80
 
 #endif
diff -uNr vgabios-orig/vbetables-gen.c vgabios/vbetables-gen.c
--- vgabios-orig/vbetables-gen.c	2006-08-15 16:42:14.000000000 -0400
+++ vgabios/vbetables-gen.c	2008-12-30 20:17:22.978504086 -0500
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 8
+#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 16
 
 typedef struct {
     int width;
@@ -42,19 +42,40 @@
 { 1600, 1200, 24                      , 0x11F},
 
       /* BOCHS/PLE, 86 'own' mode numbers */
-{ 320, 200, 32                        , 0x140},
-{ 640, 400, 32                        , 0x141},
-{ 640, 480, 32                        , 0x142},
-{ 800, 600, 32                        , 0x143},
-{ 1024, 768, 32                       , 0x144},
-{ 1280, 1024, 32                      , 0x145},
-{ 320, 200, 8                           , 0x146},
-{ 1600, 1200, 32                      , 0x147},
-{ 1152, 864, 8                      , 0x148},
+{ 320, 200, 32                       , 0x140},
+{ 640, 400, 32                       , 0x141},
+{ 640, 480, 32                       , 0x142},
+{ 800, 600, 32                       , 0x143},
+{ 1024, 768, 32                      , 0x144},
+{ 1280, 1024, 32                     , 0x145},
+{ 320, 200, 8                        , 0x146},
+{ 1600, 1200, 32                     , 0x147},
+{ 1152, 864, 8                       , 0x148},
 { 1152, 864, 15                      , 0x149},
 { 1152, 864, 16                      , 0x14a},
 { 1152, 864, 24                      , 0x14b},
 { 1152, 864, 32                      , 0x14c},
+{ 1280, 800, 16                      , 0x178},
+{ 1280, 800, 24                      , 0x179},
+{ 1280, 800, 32                      , 0x17a},
+{ 1280, 960, 16                      , 0x17b},
+{ 1280, 960, 24                      , 0x17c},
+{ 1280, 960, 32                      , 0x17d},
+{ 1440, 900, 16                      , 0x17e},
+{ 1440, 900, 24                      , 0x17f},
+{ 1440, 900, 32                      , 0x180},
+{ 1400, 1050, 16                     , 0x181},
+{ 1400, 1050, 24                     , 0x182},
+{ 1400, 1050, 32                     , 0x183},
+{ 1680, 1050, 16                     , 0x184},
+{ 1680, 1050, 24                     , 0x185},
+{ 1680, 1050, 32                     , 0x186},
+{ 1920, 1200, 16                     , 0x187},
+{ 1920, 1200, 24                     , 0x188},
+{ 1920, 1200, 32                     , 0x189},
+{ 2560, 1600, 16                     , 0x18a},
+{ 2560, 1600, 24                     , 0x18b},
+{ 2560, 1600, 32                     , 0x18c},
 { 0, },
 };
 
Binary files vgabios-orig/VGABIOS-lgpl-latest.bin and vgabios/VGABIOS-lgpl-latest.bin differ
Binary files vgabios-orig/VGABIOS-lgpl-latest.cirrus.bin and vgabios/VGABIOS-lgpl-latest.cirrus.bin differ
Binary files vgabios-orig/VGABIOS-lgpl-latest.cirrus.debug.bin and vgabios/VGABIOS-lgpl-latest.cirrus.debug.bin differ
Binary files vgabios-orig/VGABIOS-lgpl-latest.debug.bin and vgabios/VGABIOS-lgpl-latest.debug.bin differ

[-- Attachment #3: qemu_stdvga_variable_vram_size.patch --]
[-- Type: text/plain, Size: 14121 bytes --]

diff -uNr trunk/hw/cirrus_vga.c trunk-patched/hw/cirrus_vga.c
--- trunk/hw/cirrus_vga.c	2009-01-09 12:39:16.354481456 -0500
+++ trunk-patched/hw/cirrus_vga.c	2009-01-09 14:23:32.590514137 -0500
@@ -3310,6 +3310,12 @@
 
     s = qemu_mallocz(sizeof(CirrusVGAState));
 
+    if ( vga_ram_size != 4*1024*1024 )
+    {
+        fprintf(stderr,"The -videoram option does not work with the cirrus vga model. Video ram set to 4M. \n");
+        vga_ram_size=4*1024*1024;
+    }
+
     vga_common_init((VGAState *)s,
                     ds, vga_ram_base, vga_ram_offset, vga_ram_size);
     cirrus_init_common(s, CIRRUS_ID_CLGD5430, 0);
@@ -3337,10 +3343,10 @@
 
     s->map_addr = s->map_end = 0;
     s->lfb_addr = addr & TARGET_PAGE_MASK;
-    s->lfb_end = ((addr + VGA_RAM_SIZE) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
+    s->lfb_end = ((addr + s->vram_size) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
     /* account for overflow */
-    if (s->lfb_end < addr + VGA_RAM_SIZE)
-        s->lfb_end = addr + VGA_RAM_SIZE;
+    if (s->lfb_end < addr + s->vram_size)
+        s->lfb_end = addr + s->vram_size;
 }
 
 static void cirrus_pci_mmio_map(PCIDevice *d, int region_num,
@@ -3378,6 +3384,13 @@
 
     /* setup VGA */
     s = &d->cirrus_vga;
+    
+    if ( vga_ram_size != 4*1024*1024 )
+    {
+        fprintf(stderr,"The -videoram option does not work with the cirrus vga model. Video ram set to 4M. \n");
+        vga_ram_size=4*1024*1024;
+    }
+    
     vga_common_init((VGAState *)s,
                     ds, vga_ram_base, vga_ram_offset, vga_ram_size);
     cirrus_init_common(s, device_id, 1);
diff -uNr trunk/hw/mips_jazz.c trunk-patched/hw/mips_jazz.c
--- trunk/hw/mips_jazz.c	2009-01-05 12:19:53.822918856 -0500
+++ trunk-patched/hw/mips_jazz.c	2009-01-09 14:23:32.591518586 -0500
@@ -292,7 +292,7 @@
     .name = "magnum",
     .desc = "MIPS Magnum",
     .init = mips_magnum_init,
-    .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = MAGNUM_BIOS_SIZE,
     .nodisk_ok = 1,
     .use_scsi = 1,
 };
@@ -301,7 +301,7 @@
     .name = "pica61",
     .desc = "Acer Pica 61",
     .init = mips_pica61_init,
-    .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = MAGNUM_BIOS_SIZE,
     .nodisk_ok = 1,
     .use_scsi = 1,
 };
diff -uNr trunk/hw/mips_malta.c trunk-patched/hw/mips_malta.c
--- trunk/hw/mips_malta.c	2008-12-16 11:57:09.859690422 -0500
+++ trunk-patched/hw/mips_malta.c	2009-01-09 14:23:32.592483085 -0500
@@ -949,6 +949,6 @@
     .name = "malta",
     .desc = "MIPS Malta Core LV",
     .init = mips_malta_init,
-    .ram_require = VGA_RAM_SIZE + BIOS_SIZE,
+    .ram_require = BIOS_SIZE,
     .nodisk_ok = 1,
 };
diff -uNr trunk/hw/mips_mipssim.c trunk-patched/hw/mips_mipssim.c
--- trunk/hw/mips_mipssim.c	2008-11-17 21:59:28.219467005 -0500
+++ trunk-patched/hw/mips_mipssim.c	2009-01-09 14:23:32.592483085 -0500
@@ -194,6 +194,6 @@
     .name = "mipssim",
     .desc = "MIPS MIPSsim platform",
     .init = mips_mipssim_init,
-    .ram_require = BIOS_SIZE + VGA_RAM_SIZE /* unused */,
+    .ram_require = BIOS_SIZE /* unused */,
     .nodisk_ok = 1,
 };
diff -uNr trunk/hw/mips_r4k.c trunk-patched/hw/mips_r4k.c
--- trunk/hw/mips_r4k.c	2009-01-09 12:39:16.387480753 -0500
+++ trunk-patched/hw/mips_r4k.c	2009-01-09 14:23:32.598516270 -0500
@@ -287,6 +287,6 @@
     .name = "mips",
     .desc = "mips r4k platform",
     .init = mips_r4k_init,
-    .ram_require = VGA_RAM_SIZE + BIOS_SIZE,
+    .ram_require = BIOS_SIZE,
     .nodisk_ok = 1,
 };
diff -uNr trunk/hw/pc.c trunk-patched/hw/pc.c
--- trunk/hw/pc.c	2008-12-30 17:10:53.590531452 -0500
+++ trunk-patched/hw/pc.c	2009-01-09 14:23:32.599480979 -0500
@@ -1151,7 +1151,7 @@
     .name = "pc",
     .desc = "Standard PC",
     .init = pc_init_pci,
-    .ram_require = VGA_RAM_SIZE + PC_MAX_BIOS_SIZE,
+    .ram_require = PC_MAX_BIOS_SIZE,
     .max_cpus = 255,
 };
 
@@ -1159,6 +1159,6 @@
     .name = "isapc",
     .desc = "ISA-only PC",
     .init = pc_init_isa,
-    .ram_require = VGA_RAM_SIZE + PC_MAX_BIOS_SIZE,
+    .ram_require = PC_MAX_BIOS_SIZE,
     .max_cpus = 1,
 };
diff -uNr trunk/hw/pc.h trunk-patched/hw/pc.h
--- trunk/hw/pc.h	2008-12-30 17:10:53.605546746 -0500
+++ trunk-patched/hw/pc.h	2009-01-09 14:23:32.599480979 -0500
@@ -124,12 +124,6 @@
 
 extern enum vga_retrace_method vga_retrace_method;
 
-#ifndef TARGET_SPARC
-#define VGA_RAM_SIZE (8192 * 1024)
-#else
-#define VGA_RAM_SIZE (9 * 1024 * 1024)
-#endif
-
 int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
                  unsigned long vga_ram_offset, int vga_ram_size);
 int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
diff -uNr trunk/hw/ppc_chrp.c trunk-patched/hw/ppc_chrp.c
--- trunk/hw/ppc_chrp.c	2008-11-17 21:59:28.121466857 -0500
+++ trunk-patched/hw/ppc_chrp.c	2009-01-09 14:23:32.600515738 -0500
@@ -334,6 +334,6 @@
     .name = "mac99",
     .desc = "Mac99 based PowerMAC",
     .init = ppc_core99_init,
-    .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = BIOS_SIZE,
     .max_cpus = MAX_CPUS,
 };
diff -uNr trunk/hw/ppc_oldworld.c trunk-patched/hw/ppc_oldworld.c
--- trunk/hw/ppc_oldworld.c	2009-01-09 12:39:16.384481865 -0500
+++ trunk-patched/hw/ppc_oldworld.c	2009-01-09 14:23:32.601517323 -0500
@@ -385,6 +385,6 @@
     .name = "g3beige",
     .desc = "Heathrow based PowerMAC",
     .init = ppc_heathrow_init,
-    .ram_require = BIOS_SIZE + VGA_BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = BIOS_SIZE + VGA_BIOS_SIZE,
     .max_cpus = MAX_CPUS,
 };
diff -uNr trunk/hw/ppc_prep.c trunk-patched/hw/ppc_prep.c
--- trunk/hw/ppc_prep.c	2009-01-09 12:39:16.366481689 -0500
+++ trunk-patched/hw/ppc_prep.c	2009-01-09 14:23:32.603514277 -0500
@@ -765,6 +765,6 @@
     .name = "prep",
     .desc = "PowerPC PREP platform",
     .init = ppc_prep_init,
-    .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = BIOS_SIZE,
     .max_cpus = MAX_CPUS,
 };
diff -uNr trunk/hw/sun4u.c trunk-patched/hw/sun4u.c
--- trunk/hw/sun4u.c	2008-12-30 17:10:53.579530173 -0500
+++ trunk-patched/hw/sun4u.c	2009-01-09 14:23:32.604517608 -0500
@@ -600,7 +600,7 @@
     .name = "sun4u",
     .desc = "Sun4u platform",
     .init = sun4u_init,
-    .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
+    .ram_require = PROM_SIZE_MAX,
     .nodisk_ok = 1,
     .max_cpus = 1, // XXX for now
 };
@@ -609,7 +609,7 @@
     .name = "sun4v",
     .desc = "Sun4v platform",
     .init = sun4v_init,
-    .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
+    .ram_require = PROM_SIZE_MAX,
     .nodisk_ok = 1,
     .max_cpus = 1, // XXX for now
 };
@@ -618,7 +618,7 @@
     .name = "Niagara",
     .desc = "Sun4v platform, Niagara",
     .init = niagara_init,
-    .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
+    .ram_require = PROM_SIZE_MAX,
     .nodisk_ok = 1,
     .max_cpus = 1, // XXX for now
 };
diff -uNr trunk/hw/vga.c trunk-patched/hw/vga.c
--- trunk/hw/vga.c	2009-01-09 12:39:16.383481956 -0500
+++ trunk-patched/hw/vga.c	2009-01-09 14:23:32.606480689 -0500
@@ -36,6 +36,11 @@
 
 //#define DEBUG_BOCHS_VBE
 
+// PCI 0x04: command(word), 0x06(word): status
+#define PCI_COMMAND_IOACCESS                0x0001
+#define PCI_COMMAND_MEMACCESS               0x0002
+#define PCI_COMMAND_BUSMASTER               0x0004
+
 /* force some bits to zero */
 const uint8_t sr_mask[8] = {
     (uint8_t)~0xfc,
@@ -2219,10 +2224,20 @@
         cpu_register_physical_memory(addr, s->bios_size, s->bios_offset);
     } else {
         cpu_register_physical_memory(addr, s->vram_size, s->vram_offset);
+        s->lfb_addr = addr;
+        s->lfb_end = addr + size;
+#ifdef CONFIG_BOCHS_VBE
+        s->vbe_regs[VBE_DISPI_INDEX_LFB_ADDRESS_H] = s->lfb_addr >> 16;
+        s->vbe_regs[VBE_DISPI_INDEX_LFB_ADDRESS_L] = s->lfb_addr & 0xFFFF;
+        s->vbe_regs[VBE_DISPI_INDEX_VIDEO_MEMORY_64K] = s->vram_size >> 16;
+#endif
+
+        if (size != s->vram_size)
+            fprintf(stderr, "vga map with size %x != %x\n", size, s->vram_size);
     }
 
     s->map_addr = addr;
-    s->map_end = addr + VGA_RAM_SIZE;
+    s->map_end = addr + s->vram_size;
 
     vga_dirty_log_start(s);
 }
@@ -2469,6 +2484,12 @@
     if (!d)
         return -1;
     s = &d->vga_state;
+    
+    if ( vga_ram_size > 16*1024*1024 )
+    {
+        fprintf(stderr,"The stdvga/VBE device model currently has no use for more than 16 Megs of vram. Video ram reduced to 16M. \n");
+        vga_ram_size = 16*1024*1024;
+    }
 
     vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
     vga_init(s);
@@ -2483,6 +2504,7 @@
     pci_conf[0x01] = 0x12;
     pci_conf[0x02] = 0x11;
     pci_conf[0x03] = 0x11;
+    pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS /* | PCI_COMMAND_BUSMASTER */;
     pci_conf[0x0a] = 0x00; // VGA controller
     pci_conf[0x0b] = 0x03;
     pci_conf[0x0e] = 0x00; // header_type
diff -uNr trunk/hw/vga_int.h trunk-patched/hw/vga_int.h
--- trunk/hw/vga_int.h	2009-01-09 12:39:16.363481753 -0500
+++ trunk-patched/hw/vga_int.h	2009-01-09 14:23:32.606480689 -0500
@@ -30,36 +30,39 @@
 /* bochs VBE support */
 #define CONFIG_BOCHS_VBE
 
-#define VBE_DISPI_MAX_XRES              1600
-#define VBE_DISPI_MAX_YRES              1200
-#define VBE_DISPI_MAX_BPP               32
-
-#define VBE_DISPI_INDEX_ID              0x0
-#define VBE_DISPI_INDEX_XRES            0x1
-#define VBE_DISPI_INDEX_YRES            0x2
-#define VBE_DISPI_INDEX_BPP             0x3
-#define VBE_DISPI_INDEX_ENABLE          0x4
-#define VBE_DISPI_INDEX_BANK            0x5
-#define VBE_DISPI_INDEX_VIRT_WIDTH      0x6
-#define VBE_DISPI_INDEX_VIRT_HEIGHT     0x7
-#define VBE_DISPI_INDEX_X_OFFSET        0x8
-#define VBE_DISPI_INDEX_Y_OFFSET        0x9
-#define VBE_DISPI_INDEX_NB              0xa
-
-#define VBE_DISPI_ID0                   0xB0C0
-#define VBE_DISPI_ID1                   0xB0C1
-#define VBE_DISPI_ID2                   0xB0C2
-#define VBE_DISPI_ID3                   0xB0C3
-#define VBE_DISPI_ID4                   0xB0C4
-
-#define VBE_DISPI_DISABLED              0x00
-#define VBE_DISPI_ENABLED               0x01
-#define VBE_DISPI_GETCAPS               0x02
-#define VBE_DISPI_8BIT_DAC              0x20
-#define VBE_DISPI_LFB_ENABLED           0x40
-#define VBE_DISPI_NOCLEARMEM            0x80
+#define VBE_DISPI_MAX_XRES               2560
+#define VBE_DISPI_MAX_YRES               1600
+#define VBE_DISPI_MAX_BPP                32
+
+#define VBE_DISPI_INDEX_ID               0x0
+#define VBE_DISPI_INDEX_XRES             0x1
+#define VBE_DISPI_INDEX_YRES             0x2
+#define VBE_DISPI_INDEX_BPP              0x3
+#define VBE_DISPI_INDEX_ENABLE           0x4
+#define VBE_DISPI_INDEX_BANK             0x5
+#define VBE_DISPI_INDEX_VIRT_WIDTH       0x6
+#define VBE_DISPI_INDEX_VIRT_HEIGHT      0x7
+#define VBE_DISPI_INDEX_X_OFFSET         0x8
+#define VBE_DISPI_INDEX_Y_OFFSET         0x9
+#define VBE_DISPI_INDEX_VIDEO_MEMORY_64K 0xa
+#define VBE_DISPI_INDEX_LFB_ADDRESS_H    0xb
+#define VBE_DISPI_INDEX_LFB_ADDRESS_L    0xc
+#define VBE_DISPI_INDEX_NB               0xd
+
+#define VBE_DISPI_ID0                    0xB0C0
+#define VBE_DISPI_ID1                    0xB0C1
+#define VBE_DISPI_ID2                    0xB0C2
+#define VBE_DISPI_ID3                    0xB0C3
+#define VBE_DISPI_ID4                    0xB0C4
+
+#define VBE_DISPI_DISABLED               0x00
+#define VBE_DISPI_ENABLED                0x01
+#define VBE_DISPI_GETCAPS                0x02
+#define VBE_DISPI_8BIT_DAC               0x20
+#define VBE_DISPI_LFB_ENABLED            0x40
+#define VBE_DISPI_NOCLEARMEM             0x80
 
-#define VBE_DISPI_LFB_PHYSICAL_ADDRESS  0xE0000000
+#define VBE_DISPI_LFB_PHYSICAL_ADDRESS   0xE0000000
 
 #ifdef CONFIG_BOCHS_VBE
 
diff -uNr trunk/vl.c trunk-patched/vl.c
--- trunk/vl.c	2009-01-09 12:39:16.740479241 -0500
+++ trunk-patched/vl.c	2009-01-09 14:23:32.608510538 -0500
@@ -178,7 +178,7 @@
    to store the VM snapshots */
 DriveInfo drives_table[MAX_DRIVES+1];
 int nb_drives;
-static int vga_ram_size;
+static int vga_ram_size = 4 * 1024 * 1024;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 DisplayState display_state;
 int nographic;
@@ -3872,6 +3872,7 @@
            "                use -soundhw all to enable all of them\n"
 #endif
            "-vga [std|cirrus|vmware]\n"
+           "-videoram       set amount of memory available to virtual video adapter\n"           
            "                select video card type\n"
            "-localtime      set the real time clock to local time [default=utc]\n"
            "-full-screen    start in full screen\n"
@@ -4058,6 +4059,7 @@
     QEMU_OPTION_localtime,
     QEMU_OPTION_g,
     QEMU_OPTION_vga,
+    QEMU_OPTION_videoram,    
     QEMU_OPTION_echr,
     QEMU_OPTION_monitor,
     QEMU_OPTION_serial,
@@ -4167,6 +4169,7 @@
 #endif
     { "localtime", 0, QEMU_OPTION_localtime },
     { "vga", HAS_ARG, QEMU_OPTION_vga },
+    { "videoram", HAS_ARG, QEMU_OPTION_videoram },    
     { "echr", HAS_ARG, QEMU_OPTION_echr },
     { "monitor", HAS_ARG, QEMU_OPTION_monitor },
     { "serial", HAS_ARG, QEMU_OPTION_serial },
@@ -4551,7 +4554,6 @@
     cpu_model = NULL;
     initrd_filename = NULL;
     ram_size = 0;
-    vga_ram_size = VGA_RAM_SIZE;
 #ifdef CONFIG_GDBSTUB
     use_gdbstub = 0;
     gdbstub_port = DEFAULT_GDBSTUB_PORT;
@@ -4908,6 +4910,13 @@
             case QEMU_OPTION_vga:
                 select_vgahw (optarg);
                 break;
+            case QEMU_OPTION_videoram:
+                {
+                    char *ptr;
+                    vga_ram_size = strtol(optarg,&ptr,10);
+                    vga_ram_size *= 1024 * 1024;
+                }
+                break;
             case QEMU_OPTION_g:
                 {
                     const char *p;
@@ -5320,7 +5329,12 @@
             exit(1);
 
     /* init the memory */
-    phys_ram_size = machine->ram_require & ~RAMSIZE_FIXED;
+    
+#ifdef TARGET_SPARC
+    vga_ram_size += (1024 * 1024);
+#endif
+
+    phys_ram_size = (machine->ram_require + vga_ram_size) & ~RAMSIZE_FIXED;
 
     if (machine->ram_require & RAMSIZE_FIXED) {
         if (ram_size > 0) {

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-09 19:45 [Qemu-devel] [PATCH] [RFC] Variable video ram size option Trolle Selander
@ 2009-01-10  0:02 ` Paul Brook
  2009-01-10  1:26   ` Trolle Selander
       [not found]   ` <4967E7D7.4040605@eu.citrix.com>
  2009-01-11  7:53 ` Avi Kivity
  1 sibling, 2 replies; 24+ messages in thread
From: Paul Brook @ 2009-01-10  0:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Trolle Selander

On Friday 09 January 2009 12:45:47 Trolle Selander wrote:
> +#ifdef TARGET_SPARC
> +    vga_ram_size += (1024 * 1024);
> +#endif

This looks pretty bogus.

> +    if ( vga_ram_size > 16*1024*1024 )
> +    {
> +        fprintf(stderr,"The stdvga/VBE device model currently has no use
> for more than 16 Megs of vram. Video ram reduced to 16M. \n"); +       
> vga_ram_size = 16*1024*1024;

I'm pretty sure this is wrong. VBE alows arbritary sized virtual framebuffers.

Paul

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-10  0:02 ` Paul Brook
@ 2009-01-10  1:26   ` Trolle Selander
  2009-01-10  6:45     ` Blue Swirl
       [not found]   ` <4967E7D7.4040605@eu.citrix.com>
  1 sibling, 1 reply; 24+ messages in thread
From: Trolle Selander @ 2009-01-10  1:26 UTC (permalink / raw)
  To: qemu-devel

Paul Brook wrote:
> On Friday 09 January 2009 12:45:47 Trolle Selander wrote:
>   
>> +#ifdef TARGET_SPARC
>> +    vga_ram_size += (1024 * 1024);
>> +#endif
>>     
>
> This looks pretty bogus.
>
>   
Possibly. The previous static definition added one meg to the default
VGA_RAM_SIZE if TARGET_SPARC was set, and I merely wanted to retain that
behavior. If someone who is familiar with the SPARC target and knows the
reason for the added meg of ram in the previous code can assure that
this won't be needed with the configurabe ram patch, I'll be happy to
drop that bit.

>> +    if ( vga_ram_size > 16*1024*1024 )
>> +    {
>> +        fprintf(stderr,"The stdvga/VBE device model currently has no use
>> for more than 16 Megs of vram. Video ram reduced to 16M. \n"); +       
>> vga_ram_size = 16*1024*1024;
>>     
>
> I'm pretty sure this is wrong. VBE alows arbritary sized virtual framebuffers.
>
> Paul
VBE does, but the stdvga/VBE device model currently cannot _make use_ of 
more, since there highest resolution provided is 2560x1600x32 = 16Megs. 
The features required to make use of VRAM that is not used for the 
framebuffer itself are not there, either, and hence any additional 
memory would just be wasted. Anyone who would want to add features to 
the stdvga device or to the VBE bios can easily remove or change this check.

-- Trolle

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
       [not found]     ` <200901091716.00827.paul@codesourcery.com>
@ 2009-01-10  1:27       ` Trolle Selander
       [not found]       ` <4967ECA7.6040809@eu.citrix.com>
  1 sibling, 0 replies; 24+ messages in thread
From: Trolle Selander @ 2009-01-10  1:27 UTC (permalink / raw)
  To: qemu-devel

Paul Brook wrote:
>>> I'm pretty sure this is wrong. VBE alows arbritary sized virtual
>>> framebuffers.
>>>
>>>       
>> VBE does, but the stdvga/VBE device model currently cannot _make use_ of
>> more, since there highest resolution provided is 2560x1600x32 = 16Megs. The
>> features required to make use of VRAM that is not used for the framebuffer
>> itself are not there, either, and hence any additional memory would just be
>> wasted. Anyone who would want to add features to the stdvga device or to
>> the VBE bios can easily remove or change this check.
>>     
>
> Are you sure? I haven't actually tried it, but it looks like it should all 
> just work.
>
> Paul
>
>   

It's not a matter of it not "working", it's a matter of the extra vram
not being in any way _usable_ to a guest OS or to the emulated device
without additional code in the stdvga device or implentation of VBE/AF
functions in vgabios. Moreover, most of the things that extra
"off-screen" vram would be useful for on real hardware are not helpful
in an emulated device. For example, in a real card you may want to store
pixmaps, fonts, etc in off-screen vram for fast copy to avoid having to
move it over a potentially "slow" bus between system ram and frambuffer
ram, but in an emulated device, vram and system ram are of course all
really system ram, and copies are no faster or slower, although
implementing "emulation" of on-card system ram and mechanisms to copy
and cache over the emulated PCI bus would add additional complexity that
would only make things _slower_.
Trying hard to think up a use for more than 16 Megs in the current case,
I could think of adding horizontally doubled resolutions to provide vm
screens that span Xinerama multi-monitor displays without needing to
emulate multi-display inside the actual VM, but I think such use cases
will be rather rare, and in case someone DOES want it, all that's needed
is to add those resolutions to vbetable-gen and bump the vram limit in
the code to the appropriate number (say 32M for a dual 2560x1600 display).

-- Trolle

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
       [not found]         ` <200901091747.06462.paul@codesourcery.com>
@ 2009-01-10  1:28           ` Trolle Selander
  2009-01-10  1:47             ` Jamie Lokier
  0 siblings, 1 reply; 24+ messages in thread
From: Trolle Selander @ 2009-01-10  1:28 UTC (permalink / raw)
  To: qemu-devel

Paul Brook wrote:
>> Trying hard to think up a use for more than 16 Megs in the current case,
>>     
>
> I'm pretty sure the current device allows the guest to do page flipping (using 
> an oversize virtual framebuffer).
>
> Paul
>   
I could have sworn I checked that at some point and found that it
didn't, but looking at the vgabios code now it looks like it's all
implemented. That definitely bumps the useable limit to 32 Megs even in
the current case. Thanks for catching this, I'll add it to the fix list.

-- Trolle

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-10  1:28           ` Trolle Selander
@ 2009-01-10  1:47             ` Jamie Lokier
  0 siblings, 0 replies; 24+ messages in thread
From: Jamie Lokier @ 2009-01-10  1:47 UTC (permalink / raw)
  To: qemu-devel

Trolle Selander wrote:
> Paul Brook wrote:
> >>Trying hard to think up a use for more than 16 Megs in the current case,
> >>    
> >
> >I'm pretty sure the current device allows the guest to do page flipping 
> >(using an oversize virtual framebuffer).
> >
> >Paul
> >  
> I could have sworn I checked that at some point and found that it
> didn't, but looking at the vgabios code now it looks like it's all
> implemented. That definitely bumps the useable limit to 32 Megs even in
> the current case. Thanks for catching this, I'll add it to the fix list.

For games _triple_ buffering is a common technique when there's enough RAM.

With double buffering, after you flip away from screen 0 to screen 1, you
have to pause until the next vsync before it's safe to draw a new
image on screen 0.

With triple buffering, this pause isn't required which makes games
(etc.) able to run at a higher average frame rate.

(More buffers can smooth the average further, which is more useful
when playing video than games, because it adds latency but hides
individual frame drawing time spikes.  But it's not that useful.
Triple buffering is relatively common though.)

So there's a use for 3 screens in the virtual framebuffer - 48 MB?

-- Jamie

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-10  1:26   ` Trolle Selander
@ 2009-01-10  6:45     ` Blue Swirl
  0 siblings, 0 replies; 24+ messages in thread
From: Blue Swirl @ 2009-01-10  6:45 UTC (permalink / raw)
  To: qemu-devel

On 1/10/09, Trolle Selander <trolle.selander@eu.citrix.com> wrote:
> Paul Brook wrote:
>
> > On Friday 09 January 2009 12:45:47 Trolle Selander wrote:
> >
> >
> > > +#ifdef TARGET_SPARC
> > > +    vga_ram_size += (1024 * 1024);
> > > +#endif
> > >
> > >
> >
> > This looks pretty bogus.
> >
> >
> >
>  Possibly. The previous static definition added one meg to the default
>  VGA_RAM_SIZE if TARGET_SPARC was set, and I merely wanted to retain that
>  behavior. If someone who is familiar with the SPARC target and knows the
>  reason for the added meg of ram in the previous code can assure that
>  this won't be needed with the configurabe ram patch, I'll be happy to
>  drop that bit.

In 24 bit mode, TCX uses a 32 bit framebuffer, 32 bit control plane
(selects whether 24 bit mode or 8 bit mode is used for each pixel) and
there is still the 8 bit framebuffer, all full screen (1024x768) size.
This translates to 4 + 4 + 1 MB.

I think the -videoram switch should be disabled for targets with fixed
framebuffer hardware in machine description or with:
#if !defined(TARGET_SPARC) || defined(TARGET_SPARC64)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-09 19:45 [Qemu-devel] [PATCH] [RFC] Variable video ram size option Trolle Selander
  2009-01-10  0:02 ` Paul Brook
@ 2009-01-11  7:53 ` Avi Kivity
  2009-01-12 17:43   ` Trolle Selander
  2009-01-21 18:07   ` [Qemu-devel] [PATCH] [RFC] Variable video ram size option - revised Trolle Selander
  1 sibling, 2 replies; 24+ messages in thread
From: Avi Kivity @ 2009-01-11  7:53 UTC (permalink / raw)
  To: trolle.selander; +Cc: qemu-devel

Trolle Selander wrote:
> These patches are "extracted" from a patch-set I made for Xen. Any 
> xen-specific parts have been removed. The patches do away with the 
> statically defined VGA_RAM_ SIZE and provides a new -videoram option 
> to enable setting the amount of video ram available to the VM. 
> Shrinking default video ram used to 4 Megs (which is all that the 
> default Cirrus card can use, anyway - previously, there's been a 
> "waste" of 4 megs with the statically defined 8 Megs), but allowing 
> users to specify up to 16 Megs of vram, to support the very high 
> resolutions such as 2560x1600x32 that are available on today's 
> high-end displays.
> The vgabios patch is needed for this to work, both for the variable 
> size video ram, and to add the new resolutions. The defines for the 
> high resolution and wide-screen modes were taken from what is already 
> in qemu-kvm, so getting this into qemu mainline should get qemu/kvm & 
> xen "in sync" in this regard.
>
> Special thanks to Stefano Stabellini for comments & constructive 
> criticism, and some save/restore fixes on the Xen version of this 
> patch-set.
>
> I'll brace myself for reports of how this patch breaks all the non-x86 
> architectures that qemu emulates... :)
> @@ -178,7 +178,7 @@
>     to store the VM snapshots */
>  DriveInfo drives_table[MAX_DRIVES+1];
>  int nb_drives;
> -static int vga_ram_size;
> +static int vga_ram_size = 4 * 1024 * 1024;
>  enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
>  DisplayState display_state;
>  int nographic;

You're changing the default, which will break existing setups.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-11  7:53 ` Avi Kivity
@ 2009-01-12 17:43   ` Trolle Selander
  2009-01-21 18:07   ` [Qemu-devel] [PATCH] [RFC] Variable video ram size option - revised Trolle Selander
  1 sibling, 0 replies; 24+ messages in thread
From: Trolle Selander @ 2009-01-12 17:43 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel

Avi Kivity wrote:
> Trolle Selander wrote:
>> These patches are "extracted" from a patch-set I made for Xen. Any 
>> xen-specific parts have been removed. The patches do away with the 
>> statically defined VGA_RAM_ SIZE and provides a new -videoram option 
>> to enable setting the amount of video ram available to the VM. 
>> Shrinking default video ram used to 4 Megs (which is all that the 
>> default Cirrus card can use, anyway - previously, there's been a 
>> "waste" of 4 megs with the statically defined 8 Megs), but allowing 
>> users to specify up to 16 Megs of vram, to support the very high 
>> resolutions such as 2560x1600x32 that are available on today's 
>> high-end displays.
>> The vgabios patch is needed for this to work, both for the variable 
>> size video ram, and to add the new resolutions. The defines for the 
>> high resolution and wide-screen modes were taken from what is already 
>> in qemu-kvm, so getting this into qemu mainline should get qemu/kvm & 
>> xen "in sync" in this regard.
>>
>> Special thanks to Stefano Stabellini for comments & constructive 
>> criticism, and some save/restore fixes on the Xen version of this 
>> patch-set.
>>
>> I'll brace myself for reports of how this patch breaks all the 
>> non-x86 architectures that qemu emulates... :)
>> @@ -178,7 +178,7 @@
>>     to store the VM snapshots */
>>  DriveInfo drives_table[MAX_DRIVES+1];
>>  int nb_drives;
>> -static int vga_ram_size;
>> +static int vga_ram_size = 4 * 1024 * 1024;
>>  enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
>>  DisplayState display_state;
>>  int nographic;
>
> You're changing the default, which will break existing setups.
>
My bad. That was actually a small xen "leftover", where the previous 
default for stdvga didn't matter, since  VBE had never been enabled and 
the 8 megs allocated for it by default had never actually been used, so 
it was "safe" to break the default there. The probably shouldn't be a 
"global" default now anyway, but a separate default per emulated card - 
current 4 for Cirrus, and 8 for stdvga & vmware. I suppose it would be 
possible to also add the ability to set cirrus down to 2 megs for cirrus 
too - pretty much everything is already in the code to emulate the 2 meg 
model anyway.
All things considered, I consider it rather encouraging that no one has 
found anything other than memory defaults & limits to remark on so far. :)

-- Trolle

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PATCH] [RFC] Variable video ram size option - revised
  2009-01-11  7:53 ` Avi Kivity
  2009-01-12 17:43   ` Trolle Selander
@ 2009-01-21 18:07   ` Trolle Selander
  2009-01-21 18:23     ` Daniel P. Berrange
  2009-01-21 21:21     ` [Qemu-devel] " Trolle Selander
  1 sibling, 2 replies; 24+ messages in thread
From: Trolle Selander @ 2009-01-21 18:07 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

Hi all,

This is an updated version of the patch after the suggestions/discussion 
on the list. It also includes different handling of how the -vga option 
is handled internally, replacing the multiple 
independent-yet-mutually-exclusive xxx_vga_enabled variables with one 
vgahw_model variable, and also includes the -vga none option added by 
Stefano in the time since my last version of this patch. Further 
comments & testing welcome. :)

-- Trolle

Signed-off-by: Trolle Selander <trolle.selander@eu.citrix.com>


[-- Attachment #2: qemu_variable_vram_v2.patch --]
[-- Type: text/plain, Size: 19996 bytes --]

diff -uNr trunk/hw/cirrus_vga.c trunk-patched/hw/cirrus_vga.c
--- trunk/hw/cirrus_vga.c	2009-01-19 18:04:34.402289923 -0500
+++ trunk-patched/hw/cirrus_vga.c	2009-01-19 18:12:25.593320302 -0500
@@ -3297,6 +3297,12 @@
 
     s = qemu_mallocz(sizeof(CirrusVGAState));
 
+    if ( vga_ram_size != 4*1024*1024 )
+    {
+        fprintf(stderr,"The -videoram option does not work with the cirrus vga model. Video ram set to 4M. \n");
+        vga_ram_size=4*1024*1024;
+    }
+
     vga_common_init((VGAState *)s,
                     vga_ram_base, vga_ram_offset, vga_ram_size);
     cirrus_init_common(s, CIRRUS_ID_CLGD5430, 0);
@@ -3324,10 +3330,10 @@
 
     s->map_addr = s->map_end = 0;
     s->lfb_addr = addr & TARGET_PAGE_MASK;
-    s->lfb_end = ((addr + VGA_RAM_SIZE) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
+    s->lfb_end = ((addr + s->vram_size) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
     /* account for overflow */
-    if (s->lfb_end < addr + VGA_RAM_SIZE)
-        s->lfb_end = addr + VGA_RAM_SIZE;
+    if (s->lfb_end < addr + s->vram_size)
+        s->lfb_end = addr + s->vram_size;
 }
 
 static void cirrus_pci_mmio_map(PCIDevice *d, int region_num,
@@ -3365,6 +3371,13 @@
 
     /* setup VGA */
     s = &d->cirrus_vga;
+    
+    if ( vga_ram_size != 4*1024*1024 )
+    {
+        fprintf(stderr,"The -videoram option does not work with the cirrus vga model. Video ram set to 4M. \n");
+        vga_ram_size=4*1024*1024;
+    }
+    
     vga_common_init((VGAState *)s,
                     vga_ram_base, vga_ram_offset, vga_ram_size);
     cirrus_init_common(s, device_id, 1);
diff -uNr trunk/hw/mips_jazz.c trunk-patched/hw/mips_jazz.c
--- trunk/hw/mips_jazz.c	2009-01-19 18:04:34.482293278 -0500
+++ trunk-patched/hw/mips_jazz.c	2009-01-19 18:12:25.594322030 -0500
@@ -293,7 +293,7 @@
     .name = "magnum",
     .desc = "MIPS Magnum",
     .init = mips_magnum_init,
-    .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = MAGNUM_BIOS_SIZE,
     .nodisk_ok = 1,
     .use_scsi = 1,
 };
@@ -302,7 +302,7 @@
     .name = "pica61",
     .desc = "Acer Pica 61",
     .init = mips_pica61_init,
-    .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = MAGNUM_BIOS_SIZE,
     .nodisk_ok = 1,
     .use_scsi = 1,
 };
diff -uNr trunk/hw/mips_malta.c trunk-patched/hw/mips_malta.c
--- trunk/hw/mips_malta.c	2009-01-19 18:04:34.514292790 -0500
+++ trunk-patched/hw/mips_malta.c	2009-01-19 18:12:25.595322502 -0500
@@ -943,6 +943,6 @@
     .name = "malta",
     .desc = "MIPS Malta Core LV",
     .init = mips_malta_init,
-    .ram_require = VGA_RAM_SIZE + BIOS_SIZE,
+    .ram_require = BIOS_SIZE,
     .nodisk_ok = 1,
 };
diff -uNr trunk/hw/mips_mipssim.c trunk-patched/hw/mips_mipssim.c
--- trunk/hw/mips_mipssim.c	2009-01-19 18:04:34.495297312 -0500
+++ trunk-patched/hw/mips_mipssim.c	2009-01-19 18:12:25.596288472 -0500
@@ -184,6 +184,6 @@
     .name = "mipssim",
     .desc = "MIPS MIPSsim platform",
     .init = mips_mipssim_init,
-    .ram_require = BIOS_SIZE + VGA_RAM_SIZE /* unused */,
+    .ram_require = BIOS_SIZE /* unused */,
     .nodisk_ok = 1,
 };
diff -uNr trunk/hw/mips_r4k.c trunk-patched/hw/mips_r4k.c
--- trunk/hw/mips_r4k.c	2009-01-19 18:04:34.523310792 -0500
+++ trunk-patched/hw/mips_r4k.c	2009-01-19 18:12:25.597288246 -0500
@@ -275,6 +275,6 @@
     .name = "mips",
     .desc = "mips r4k platform",
     .init = mips_r4k_init,
-    .ram_require = VGA_RAM_SIZE + BIOS_SIZE,
+    .ram_require = BIOS_SIZE,
     .nodisk_ok = 1,
 };
diff -uNr trunk/hw/pc.c trunk-patched/hw/pc.c
--- trunk/hw/pc.c	2009-01-19 18:04:34.518294675 -0500
+++ trunk-patched/hw/pc.c	2009-01-19 18:12:25.599288142 -0500
@@ -852,29 +852,29 @@
         exit(1);
     }
 
-    if (cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled) {
-        /* VGA BIOS load */
-        if (cirrus_vga_enabled) {
-            snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME);
-        } else {
-            snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
-        }
-        vga_bios_size = get_image_size(buf);
-        if (vga_bios_size <= 0 || vga_bios_size > 65536)
-            goto vga_bios_error;
-        vga_bios_offset = qemu_ram_alloc(65536);
-
-        ret = load_image(buf, phys_ram_base + vga_bios_offset);
-        if (ret != vga_bios_size) {
-vga_bios_error:
-            fprintf(stderr, "qemu: could not load VGA BIOS '%s'\n", buf);
-            exit(1);
-        }
+     if (vgahw_model != VGAHW_NONE) {
+         /* VGA BIOS load */    
+         if (vgahw_model == VGAHW_CIRRUS)
+             snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME);
+         else
+             snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
+ 
+         vga_bios_size = get_image_size(buf);
+         if (vga_bios_size <= 0 || vga_bios_size > 65536)
+             goto vga_bios_error;
+         vga_bios_offset = qemu_ram_alloc(65536);
+ 
+         ret = load_image(buf, phys_ram_base + vga_bios_offset);
+         if (ret != vga_bios_size) {
+         vga_bios_error:
+             fprintf(stderr, "qemu: could not load VGA BIOS '%s'\n", buf);
+             exit(1);
+         }
+    }
 
-        /* setup basic memory access */
-        cpu_register_physical_memory(0xc0000, 0x10000,
+    /* setup basic memory access */
+    cpu_register_physical_memory(0xc0000, 0x10000,
                                      vga_bios_offset | IO_MEM_ROM);
-    }
 
     /* map the last 128KB of the BIOS in ISA space */
     isa_bios_size = bios_size;
@@ -943,29 +943,35 @@
 
     register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
 
-    if (cirrus_vga_enabled) {
-        if (pci_enabled) {
-            pci_cirrus_vga_init(pci_bus,
+    switch(vgahw_model) {
+        case VGAHW_NONE:
+            break;
+        case VGAHW_CIRRUS:
+            if (pci_enabled)
+                pci_cirrus_vga_init(pci_bus,
+                                    phys_ram_base + vga_ram_addr,
+                                    vga_ram_addr, vga_ram_size);
+            else
+                isa_cirrus_vga_init(phys_ram_base + vga_ram_addr,
+                                    vga_ram_addr, vga_ram_size);
+            break;
+        case VGAHW_VMWARE:
+            if (pci_enabled)
+                pci_vmsvga_init(pci_bus,
                                 phys_ram_base + vga_ram_addr,
                                 vga_ram_addr, vga_ram_size);
-        } else {
-            isa_cirrus_vga_init(phys_ram_base + vga_ram_addr,
-                                vga_ram_addr, vga_ram_size);
-        }
-    } else if (vmsvga_enabled) {
-        if (pci_enabled)
-            pci_vmsvga_init(pci_bus, phys_ram_base + vga_ram_addr,
-                            vga_ram_addr, vga_ram_size);
-        else
-            fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
-    } else if (std_vga_enabled) {
-        if (pci_enabled) {
-            pci_vga_init(pci_bus, phys_ram_base + vga_ram_addr,
-                         vga_ram_addr, vga_ram_size, 0, 0);
-        } else {
-            isa_vga_init(phys_ram_base + vga_ram_addr,
-                         vga_ram_addr, vga_ram_size);
-        }
+            else
+                fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
+            break;
+        case VGAHW_STD:
+            if (pci_enabled)
+                pci_vga_init(pci_bus,
+                             phys_ram_base + vga_ram_addr,
+                             vga_ram_addr, vga_ram_size, 0, 0);
+            else
+                isa_vga_init(phys_ram_base + vga_ram_addr,
+                             vga_ram_addr, vga_ram_size); 
+            break;
     }
 
     rtc_state = rtc_init(0x70, i8259[8]);
@@ -1146,7 +1152,7 @@
     .name = "pc",
     .desc = "Standard PC",
     .init = pc_init_pci,
-    .ram_require = VGA_RAM_SIZE + PC_MAX_BIOS_SIZE,
+    .ram_require = PC_MAX_BIOS_SIZE,
     .max_cpus = 255,
 };
 
@@ -1154,6 +1160,6 @@
     .name = "isapc",
     .desc = "ISA-only PC",
     .init = pc_init_isa,
-    .ram_require = VGA_RAM_SIZE + PC_MAX_BIOS_SIZE,
+    .ram_require = PC_MAX_BIOS_SIZE,
     .max_cpus = 1,
 };
diff -uNr trunk/hw/pc.h trunk-patched/hw/pc.h
--- trunk/hw/pc.h	2009-01-19 18:04:34.518294675 -0500
+++ trunk-patched/hw/pc.h	2009-01-19 18:12:25.599288142 -0500
@@ -126,12 +126,6 @@
 
 extern enum vga_retrace_method vga_retrace_method;
 
-#ifndef TARGET_SPARC
-#define VGA_RAM_SIZE (8192 * 1024)
-#else
-#define VGA_RAM_SIZE (9 * 1024 * 1024)
-#endif
-
 int isa_vga_init(uint8_t *vga_ram_base,
                  unsigned long vga_ram_offset, int vga_ram_size);
 int pci_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
diff -uNr trunk/hw/ppc_chrp.c trunk-patched/hw/ppc_chrp.c
--- trunk/hw/ppc_chrp.c	2009-01-19 18:04:34.414289295 -0500
+++ trunk-patched/hw/ppc_chrp.c	2009-01-19 18:12:25.600286867 -0500
@@ -334,6 +334,6 @@
     .name = "mac99",
     .desc = "Mac99 based PowerMAC",
     .init = ppc_core99_init,
-    .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = BIOS_SIZE,
     .max_cpus = MAX_CPUS,
 };
diff -uNr trunk/hw/ppc_oldworld.c trunk-patched/hw/ppc_oldworld.c
--- trunk/hw/ppc_oldworld.c	2009-01-19 18:04:34.505293366 -0500
+++ trunk-patched/hw/ppc_oldworld.c	2009-01-19 18:12:25.601287409 -0500
@@ -383,6 +383,6 @@
     .name = "g3beige",
     .desc = "Heathrow based PowerMAC",
     .init = ppc_heathrow_init,
-    .ram_require = BIOS_SIZE + VGA_BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = BIOS_SIZE + VGA_BIOS_SIZE,
     .max_cpus = MAX_CPUS,
 };
diff -uNr trunk/hw/ppc_prep.c trunk-patched/hw/ppc_prep.c
--- trunk/hw/ppc_prep.c	2009-01-19 18:04:34.430293137 -0500
+++ trunk-patched/hw/ppc_prep.c	2009-01-19 18:12:25.602286553 -0500
@@ -760,6 +760,6 @@
     .name = "prep",
     .desc = "PowerPC PREP platform",
     .init = ppc_prep_init,
-    .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = BIOS_SIZE,
     .max_cpus = MAX_CPUS,
 };
diff -uNr trunk/hw/sun4u.c trunk-patched/hw/sun4u.c
--- trunk/hw/sun4u.c	2009-01-19 18:04:34.486295094 -0500
+++ trunk-patched/hw/sun4u.c	2009-01-19 18:12:25.603302111 -0500
@@ -644,7 +644,7 @@
     .name = "sun4u",
     .desc = "Sun4u platform",
     .init = sun4u_init,
-    .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
+    .ram_require = PROM_SIZE_MAX,
     .nodisk_ok = 1,
     .max_cpus = 1, // XXX for now
 };
@@ -653,7 +653,7 @@
     .name = "sun4v",
     .desc = "Sun4v platform",
     .init = sun4v_init,
-    .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
+    .ram_require = PROM_SIZE_MAX,
     .nodisk_ok = 1,
     .max_cpus = 1, // XXX for now
 };
@@ -662,7 +662,7 @@
     .name = "Niagara",
     .desc = "Sun4v platform, Niagara",
     .init = niagara_init,
-    .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
+    .ram_require = PROM_SIZE_MAX,
     .nodisk_ok = 1,
     .max_cpus = 1, // XXX for now
 };
diff -uNr trunk/hw/vga.c trunk-patched/hw/vga.c
--- trunk/hw/vga.c	2009-01-19 18:04:34.484284722 -0500
+++ trunk-patched/hw/vga.c	2009-01-19 18:12:25.605321282 -0500
@@ -36,6 +36,11 @@
 
 //#define DEBUG_BOCHS_VBE
 
+// PCI 0x04: command(word), 0x06(word): status
+#define PCI_COMMAND_IOACCESS                0x0001
+#define PCI_COMMAND_MEMACCESS               0x0002
+#define PCI_COMMAND_BUSMASTER               0x0004
+
 /* force some bits to zero */
 const uint8_t sr_mask[8] = {
     (uint8_t)~0xfc,
@@ -2246,10 +2251,20 @@
         cpu_register_physical_memory(addr, s->bios_size, s->bios_offset);
     } else {
         cpu_register_physical_memory(addr, s->vram_size, s->vram_offset);
+        s->lfb_addr = addr;
+        s->lfb_end = addr + size;
+#ifdef CONFIG_BOCHS_VBE
+        s->vbe_regs[VBE_DISPI_INDEX_LFB_ADDRESS_H] = s->lfb_addr >> 16;
+        s->vbe_regs[VBE_DISPI_INDEX_LFB_ADDRESS_L] = s->lfb_addr & 0xFFFF;
+        s->vbe_regs[VBE_DISPI_INDEX_VIDEO_MEMORY_64K] = s->vram_size >> 16;
+#endif
+
+        if (size != s->vram_size)
+            fprintf(stderr, "vga map with size %x != %x\n", size, s->vram_size);
     }
 
     s->map_addr = addr;
-    s->map_end = addr + VGA_RAM_SIZE;
+    s->map_end = addr + s->vram_size;
 
     vga_dirty_log_start(s);
 }
@@ -2509,6 +2524,7 @@
     pci_conf[0x01] = 0x12;
     pci_conf[0x02] = 0x11;
     pci_conf[0x03] = 0x11;
+    pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS /* | PCI_COMMAND_BUSMASTER */;
     pci_conf[0x0a] = 0x00; // VGA controller
     pci_conf[0x0b] = 0x03;
     pci_conf[0x0e] = 0x00; // header_type
diff -uNr trunk/hw/vga_int.h trunk-patched/hw/vga_int.h
--- trunk/hw/vga_int.h	2009-01-19 18:04:34.421284633 -0500
+++ trunk-patched/hw/vga_int.h	2009-01-19 18:12:25.606286414 -0500
@@ -30,36 +30,39 @@
 /* bochs VBE support */
 #define CONFIG_BOCHS_VBE
 
-#define VBE_DISPI_MAX_XRES              1600
-#define VBE_DISPI_MAX_YRES              1200
-#define VBE_DISPI_MAX_BPP               32
-
-#define VBE_DISPI_INDEX_ID              0x0
-#define VBE_DISPI_INDEX_XRES            0x1
-#define VBE_DISPI_INDEX_YRES            0x2
-#define VBE_DISPI_INDEX_BPP             0x3
-#define VBE_DISPI_INDEX_ENABLE          0x4
-#define VBE_DISPI_INDEX_BANK            0x5
-#define VBE_DISPI_INDEX_VIRT_WIDTH      0x6
-#define VBE_DISPI_INDEX_VIRT_HEIGHT     0x7
-#define VBE_DISPI_INDEX_X_OFFSET        0x8
-#define VBE_DISPI_INDEX_Y_OFFSET        0x9
-#define VBE_DISPI_INDEX_NB              0xa
-
-#define VBE_DISPI_ID0                   0xB0C0
-#define VBE_DISPI_ID1                   0xB0C1
-#define VBE_DISPI_ID2                   0xB0C2
-#define VBE_DISPI_ID3                   0xB0C3
-#define VBE_DISPI_ID4                   0xB0C4
-
-#define VBE_DISPI_DISABLED              0x00
-#define VBE_DISPI_ENABLED               0x01
-#define VBE_DISPI_GETCAPS               0x02
-#define VBE_DISPI_8BIT_DAC              0x20
-#define VBE_DISPI_LFB_ENABLED           0x40
-#define VBE_DISPI_NOCLEARMEM            0x80
+#define VBE_DISPI_MAX_XRES               2560
+#define VBE_DISPI_MAX_YRES               1600
+#define VBE_DISPI_MAX_BPP                32
+
+#define VBE_DISPI_INDEX_ID               0x0
+#define VBE_DISPI_INDEX_XRES             0x1
+#define VBE_DISPI_INDEX_YRES             0x2
+#define VBE_DISPI_INDEX_BPP              0x3
+#define VBE_DISPI_INDEX_ENABLE           0x4
+#define VBE_DISPI_INDEX_BANK             0x5
+#define VBE_DISPI_INDEX_VIRT_WIDTH       0x6
+#define VBE_DISPI_INDEX_VIRT_HEIGHT      0x7
+#define VBE_DISPI_INDEX_X_OFFSET         0x8
+#define VBE_DISPI_INDEX_Y_OFFSET         0x9
+#define VBE_DISPI_INDEX_VIDEO_MEMORY_64K 0xa
+#define VBE_DISPI_INDEX_LFB_ADDRESS_H    0xb
+#define VBE_DISPI_INDEX_LFB_ADDRESS_L    0xc
+#define VBE_DISPI_INDEX_NB               0xd
+
+#define VBE_DISPI_ID0                    0xB0C0
+#define VBE_DISPI_ID1                    0xB0C1
+#define VBE_DISPI_ID2                    0xB0C2
+#define VBE_DISPI_ID3                    0xB0C3
+#define VBE_DISPI_ID4                    0xB0C4
+
+#define VBE_DISPI_DISABLED               0x00
+#define VBE_DISPI_ENABLED                0x01
+#define VBE_DISPI_GETCAPS                0x02
+#define VBE_DISPI_8BIT_DAC               0x20
+#define VBE_DISPI_LFB_ENABLED            0x40
+#define VBE_DISPI_NOCLEARMEM             0x80
 
-#define VBE_DISPI_LFB_PHYSICAL_ADDRESS  0xE0000000
+#define VBE_DISPI_LFB_PHYSICAL_ADDRESS   0xE0000000
 
 #ifdef CONFIG_BOCHS_VBE
 
diff -uNr trunk/sysemu.h trunk-patched/sysemu.h
--- trunk/sysemu.h	2009-01-19 18:04:55.735316222 -0500
+++ trunk-patched/sysemu.h	2009-01-19 18:12:25.608286519 -0500
@@ -81,10 +81,12 @@
 /* SLIRP */
 void do_info_slirp(void);
 
+typedef enum {
+    VGAHW_NONE, VGAHW_CIRRUS, VGAHW_STD, VGAHW_VMWARE
+} VGAHardwareModel;
+
+extern VGAHardwareModel vgahw_model;
 extern int bios_size;
-extern int cirrus_vga_enabled;
-extern int std_vga_enabled;
-extern int vmsvga_enabled;
 extern int graphic_width;
 extern int graphic_height;
 extern int graphic_depth;
diff -uNr trunk/vl.c trunk-patched/vl.c
--- trunk/vl.c	2009-01-19 18:04:55.701293559 -0500
+++ trunk-patched/vl.c	2009-01-19 18:12:25.613287760 -0500
@@ -185,7 +185,8 @@
    to store the VM snapshots */
 DriveInfo drives_table[MAX_DRIVES+1];
 int nb_drives;
-static int vga_ram_size;
+static int vga_ram_size = 0;
+VGAHardwareModel vgahw_model = VGAHW_CIRRUS;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 static DisplayState *display_state;
 int nographic;
@@ -3874,7 +3875,10 @@
            "                use -soundhw ? to get the list of supported cards\n"
            "                use -soundhw all to enable all of them\n"
 #endif
+#if !defined(TARGET_SPARC) || defined(TARGET_SPARC64)
            "-vga [std|cirrus|vmware|none]\n"
+           "-videoram       set amount of memory available to virtual video adapter\n"
+#endif
            "                select video card type\n"
            "-localtime      set the real time clock to local time [default=utc]\n"
            "-full-screen    start in full screen\n"
@@ -4062,6 +4066,7 @@
     QEMU_OPTION_localtime,
     QEMU_OPTION_g,
     QEMU_OPTION_vga,
+    QEMU_OPTION_videoram,    
     QEMU_OPTION_echr,
     QEMU_OPTION_monitor,
     QEMU_OPTION_serial,
@@ -4174,6 +4179,7 @@
 #endif
     { "localtime", 0, QEMU_OPTION_localtime },
     { "vga", HAS_ARG, QEMU_OPTION_vga },
+    { "videoram", HAS_ARG, QEMU_OPTION_videoram },    
     { "echr", HAS_ARG, QEMU_OPTION_echr },
     { "monitor", HAS_ARG, QEMU_OPTION_monitor },
     { "serial", HAS_ARG, QEMU_OPTION_serial },
@@ -4410,21 +4416,13 @@
     const char *opts;
 
     if (strstart(p, "std", &opts)) {
-        std_vga_enabled = 1;
-        cirrus_vga_enabled = 0;
-        vmsvga_enabled = 0;
+        vgahw_model = VGAHW_STD;
     } else if (strstart(p, "cirrus", &opts)) {
-        cirrus_vga_enabled = 1;
-        std_vga_enabled = 0;
-        vmsvga_enabled = 0;
+        vgahw_model = VGAHW_CIRRUS;
     } else if (strstart(p, "vmware", &opts)) {
-        cirrus_vga_enabled = 0;
-        std_vga_enabled = 0;
-        vmsvga_enabled = 1;
+        vgahw_model = VGAHW_VMWARE;
     } else if (strstart(p, "none", &opts)) {
-        cirrus_vga_enabled = 0;
-        std_vga_enabled = 0;
-        vmsvga_enabled = 0;
+        vgahw_model = VGAHW_NONE;
     } else {
     invalid_vga:
         fprintf(stderr, "Unknown vga type: %s\n", p);
@@ -4571,7 +4569,6 @@
     cpu_model = NULL;
     initrd_filename = NULL;
     ram_size = 0;
-    vga_ram_size = VGA_RAM_SIZE;
 #ifdef CONFIG_GDBSTUB
     use_gdbstub = 0;
     gdbstub_port = DEFAULT_GDBSTUB_PORT;
@@ -4933,6 +4930,13 @@
             case QEMU_OPTION_vga:
                 select_vgahw (optarg);
                 break;
+            case QEMU_OPTION_videoram:
+                {
+                    char *ptr;
+                    vga_ram_size = strtol(optarg,&ptr,10);
+                    vga_ram_size *= 1024 * 1024;
+                }
+                break;
             case QEMU_OPTION_g:
                 {
                     const char *p;
@@ -5361,7 +5365,30 @@
             exit(1);
 
     /* init the memory */
-    phys_ram_size = machine->ram_require & ~RAMSIZE_FIXED;
+    
+    /* Set defaults according to model, if -videoram has not been used. */
+#if !defined(TARGET_SPARC) || defined(TARGET_SPARC64)    
+    if (vga_ram_size && vgahw_model == VGAHW_NONE) {
+        fprintf(stderr, "Nonsensical options: -vga none & -videoram used together. \n");
+        vga_ram_size = 0;
+    } else if (!vga_ram_size && vgahw_model != VGAHW_NONE) {
+        switch(vgahw_model) {
+        case VGAHW_CIRRUS:
+             vga_ram_size=4 * 1024 * 1024;
+             break;
+        case VGAHW_STD:
+             vga_ram_size=8 * 1024 * 1024;
+             break;
+        case VGAHW_VMWARE:
+             vga_ram_size=8 * 1024 * 1024;
+             break;
+        }
+    }
+#else
+    vga_ram_size = 9 * 1024 * 1024;
+#endif
+
+    phys_ram_size = (machine->ram_require + vga_ram_size) & ~RAMSIZE_FIXED;
 
     if (machine->ram_require & RAMSIZE_FIXED) {
         if (ram_size > 0) {

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option - revised
  2009-01-21 18:07   ` [Qemu-devel] [PATCH] [RFC] Variable video ram size option - revised Trolle Selander
@ 2009-01-21 18:23     ` Daniel P. Berrange
  2009-01-21 21:51       ` Anthony Liguori
  2009-01-21 21:21     ` [Qemu-devel] " Trolle Selander
  1 sibling, 1 reply; 24+ messages in thread
From: Daniel P. Berrange @ 2009-01-21 18:23 UTC (permalink / raw)
  To: qemu-devel

On Wed, Jan 21, 2009 at 01:07:51PM -0500, Trolle Selander wrote:
> Hi all,
> 
> This is an updated version of the patch after the suggestions/discussion 
> on the list. It also includes different handling of how the -vga option 
> is handled internally, replacing the multiple 
> independent-yet-mutually-exclusive xxx_vga_enabled variables with one 
> vgahw_model variable, and also includes the -vga none option added by 
> Stefano in the time since my last version of this patch. Further 
> comments & testing welcome. :)



> @@ -4933,6 +4930,13 @@
>              case QEMU_OPTION_vga:
>                  select_vgahw (optarg);
>                  break;
> +            case QEMU_OPTION_videoram:
> +                {
> +                    char *ptr;
> +                    vga_ram_size = strtol(optarg,&ptr,10);
> +                    vga_ram_size *= 1024 * 1024;
> +                }
> +                break;
>              case QEMU_OPTION_g:
>                  {
>                      const char *p;

Rather than adding more add hoc extra parameters for VGA tunables, we 
should just make -vga work like the other generic device args, accepting
a optional list comma separated values following it

eg 

  -vga cirrus,ram=32

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Qemu-devel] Re: [PATCH] [RFC] Variable video ram size option - revised
  2009-01-21 18:07   ` [Qemu-devel] [PATCH] [RFC] Variable video ram size option - revised Trolle Selander
  2009-01-21 18:23     ` Daniel P. Berrange
@ 2009-01-21 21:21     ` Trolle Selander
  1 sibling, 0 replies; 24+ messages in thread
From: Trolle Selander @ 2009-01-21 21:21 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 744 bytes --]

Trolle Selander wrote:
> Hi all,
>
> This is an updated version of the patch after the 
> suggestions/discussion on the list. It also includes different 
> handling of how the -vga option is handled internally, replacing the 
> multiple independent-yet-mutually-exclusive xxx_vga_enabled variables 
> with one vgahw_model variable, and also includes the -vga none option 
> added by Stefano in the time since my last version of this patch. 
> Further comments & testing welcome. :)
>
> -- Trolle
>
> Signed-off-by: Trolle Selander <trolle.selander@eu.citrix.com>
>
Forgot to include the vgabios patch - it remains the same as for the 
previous version of this patch, but I'll attach it to this thread as 
well to make things easier.

-- Trolle

[-- Attachment #2: vgabios_variable_vram_size.patch --]
[-- Type: text/plain, Size: 8500 bytes --]

diff -uNr vgabios-orig/vbe.c vgabios/vbe.c
--- vgabios-orig/vbe.c	2008-03-02 02:47:21.000000000 -0500
+++ vgabios/vbe.c	2008-12-16 12:43:05.167692121 -0500
@@ -38,8 +38,6 @@
 #include "vbe.h"
 #include "vbetables.h"
 
-#define VBE_TOTAL_VIDEO_MEMORY_DIV_64K (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB*1024/64)
-
 // The current OEM Software Revision of this VBE Bios
 #define VBE_OEM_SOFTWARE_REV 0x0002;
 
@@ -821,7 +819,8 @@
         vbe_info_block.VideoModePtr_Off= DI + 34;
 
         // VBE Total Memory (in 64b blocks)
-        vbe_info_block.TotalMemory = VBE_TOTAL_VIDEO_MEMORY_DIV_64K;
+        outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VIDEO_MEMORY_64K);
+        vbe_info_block.TotalMemory = inw(VBE_DISPI_IOPORT_DATA);
 
         if (vbe2_info)
 	{
@@ -846,7 +845,8 @@
         do
         {
                 if ((cur_info->info.XResolution <= dispi_get_max_xres()) &&
-                    (cur_info->info.BitsPerPixel <= dispi_get_max_bpp())) {
+                    (cur_info->info.BitsPerPixel <= dispi_get_max_bpp()) &&
+                    (cur_info->info.XResolution * cur_info->info.XResolution * cur_info->info.BitsPerPixel <= vbe_info_block.TotalMemory << 19 )) {
 #ifdef DEBUG
                   printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode);
 #endif
@@ -855,7 +855,7 @@
                   cur_ptr+=2;
                 } else {
 #ifdef DEBUG
-                  printf("VBE mode %x (xres=%x / bpp=%02x) not supported by display\n", cur_info->mode,cur_info->info.XResolution,cur_info->info.BitsPerPixel);
+                  printf("VBE mode %x (xres=%x / bpp=%02x) not supported \n", cur_info->mode,cur_info->info.XResolution,cur_info->info.BitsPerPixel);
 #endif
                 }
                 cur_info++;
@@ -913,7 +913,13 @@
                   info.WinFuncPtr = 0xC0000000UL;
                   *(Bit16u *)&(info.WinFuncPtr) = (Bit16u)(dispi_set_bank_farcall);
                 }
-                
+                outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_LFB_ADDRESS_H);
+                info.PhysBasePtr = inw(VBE_DISPI_IOPORT_DATA);
+                info.PhysBasePtr = info.PhysBasePtr << 16;
+#if 0					
+                outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_LFB_ADDRESS_L);
+                info.PhysBasePtr |= inw(VBE_DISPI_IOPORT_DATA);
+#endif 							
                 result = 0x4f;
         }
         else
diff -uNr vgabios-orig/vbe.h vgabios/vbe.h
--- vgabios-orig/vbe.h	2006-08-12 03:47:34.000000000 -0400
+++ vgabios/vbe.h	2008-12-16 12:43:05.168692173 -0500
@@ -275,39 +275,41 @@
 //        like 0xE0000000
 
 
-  #define VBE_DISPI_BANK_ADDRESS          0xA0000
-  #define VBE_DISPI_BANK_SIZE_KB          64
+  #define VBE_DISPI_BANK_ADDRESS           0xA0000
+  #define VBE_DISPI_BANK_SIZE_KB           64
   
-  #define VBE_DISPI_MAX_XRES              1024
-  #define VBE_DISPI_MAX_YRES              768
+  #define VBE_DISPI_MAX_XRES               2560
+  #define VBE_DISPI_MAX_YRES               1600
   
-  #define VBE_DISPI_IOPORT_INDEX          0x01CE
-  #define VBE_DISPI_IOPORT_DATA           0x01CF
+  #define VBE_DISPI_IOPORT_INDEX           0x01CE
+  #define VBE_DISPI_IOPORT_DATA            0x01CF
   
-  #define VBE_DISPI_INDEX_ID              0x0
-  #define VBE_DISPI_INDEX_XRES            0x1
-  #define VBE_DISPI_INDEX_YRES            0x2
-  #define VBE_DISPI_INDEX_BPP             0x3
-  #define VBE_DISPI_INDEX_ENABLE          0x4
-  #define VBE_DISPI_INDEX_BANK            0x5
-  #define VBE_DISPI_INDEX_VIRT_WIDTH      0x6
-  #define VBE_DISPI_INDEX_VIRT_HEIGHT     0x7
-  #define VBE_DISPI_INDEX_X_OFFSET        0x8
-  #define VBE_DISPI_INDEX_Y_OFFSET        0x9
-      
-  #define VBE_DISPI_ID0                   0xB0C0
-  #define VBE_DISPI_ID1                   0xB0C1
-  #define VBE_DISPI_ID2                   0xB0C2
-  #define VBE_DISPI_ID3                   0xB0C3
-  #define VBE_DISPI_ID4                   0xB0C4
-  
-  #define VBE_DISPI_DISABLED              0x00
-  #define VBE_DISPI_ENABLED               0x01
-  #define VBE_DISPI_GETCAPS               0x02
-  #define VBE_DISPI_8BIT_DAC              0x20
-  #define VBE_DISPI_LFB_ENABLED           0x40
-  #define VBE_DISPI_NOCLEARMEM            0x80
-  
-  #define VBE_DISPI_LFB_PHYSICAL_ADDRESS  0xE0000000
+  #define VBE_DISPI_INDEX_ID               0x0
+  #define VBE_DISPI_INDEX_XRES             0x1
+  #define VBE_DISPI_INDEX_YRES             0x2
+  #define VBE_DISPI_INDEX_BPP              0x3
+  #define VBE_DISPI_INDEX_ENABLE           0x4
+  #define VBE_DISPI_INDEX_BANK             0x5
+  #define VBE_DISPI_INDEX_VIRT_WIDTH       0x6
+  #define VBE_DISPI_INDEX_VIRT_HEIGHT      0x7
+  #define VBE_DISPI_INDEX_X_OFFSET         0x8
+  #define VBE_DISPI_INDEX_Y_OFFSET         0x9
+  #define VBE_DISPI_INDEX_VIDEO_MEMORY_64K 0xa
+  #define VBE_DISPI_INDEX_LFB_ADDRESS_H    0xb
+  #define VBE_DISPI_INDEX_LFB_ADDRESS_L    0xc
+
+  #define VBE_DISPI_LFB_PHYSICAL_ADDRESS   0xE0000000
+  #define VBE_DISPI_ID0                    0xB0C0
+  #define VBE_DISPI_ID1                    0xB0C1
+  #define VBE_DISPI_ID2                    0xB0C2
+  #define VBE_DISPI_ID3                    0xB0C3
+  #define VBE_DISPI_ID4                    0xB0C4
+
+  #define VBE_DISPI_DISABLED               0x00
+  #define VBE_DISPI_ENABLED                0x01
+  #define VBE_DISPI_GETCAPS                0x02
+  #define VBE_DISPI_8BIT_DAC               0x20
+  #define VBE_DISPI_LFB_ENABLED            0x40
+  #define VBE_DISPI_NOCLEARMEM             0x80
 
 #endif
diff -uNr vgabios-orig/vbetables-gen.c vgabios/vbetables-gen.c
--- vgabios-orig/vbetables-gen.c	2006-08-15 16:42:14.000000000 -0400
+++ vgabios/vbetables-gen.c	2008-12-30 20:17:22.978504086 -0500
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 8
+#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 16
 
 typedef struct {
     int width;
@@ -42,19 +42,40 @@
 { 1600, 1200, 24                      , 0x11F},
 
       /* BOCHS/PLE, 86 'own' mode numbers */
-{ 320, 200, 32                        , 0x140},
-{ 640, 400, 32                        , 0x141},
-{ 640, 480, 32                        , 0x142},
-{ 800, 600, 32                        , 0x143},
-{ 1024, 768, 32                       , 0x144},
-{ 1280, 1024, 32                      , 0x145},
-{ 320, 200, 8                           , 0x146},
-{ 1600, 1200, 32                      , 0x147},
-{ 1152, 864, 8                      , 0x148},
+{ 320, 200, 32                       , 0x140},
+{ 640, 400, 32                       , 0x141},
+{ 640, 480, 32                       , 0x142},
+{ 800, 600, 32                       , 0x143},
+{ 1024, 768, 32                      , 0x144},
+{ 1280, 1024, 32                     , 0x145},
+{ 320, 200, 8                        , 0x146},
+{ 1600, 1200, 32                     , 0x147},
+{ 1152, 864, 8                       , 0x148},
 { 1152, 864, 15                      , 0x149},
 { 1152, 864, 16                      , 0x14a},
 { 1152, 864, 24                      , 0x14b},
 { 1152, 864, 32                      , 0x14c},
+{ 1280, 800, 16                      , 0x178},
+{ 1280, 800, 24                      , 0x179},
+{ 1280, 800, 32                      , 0x17a},
+{ 1280, 960, 16                      , 0x17b},
+{ 1280, 960, 24                      , 0x17c},
+{ 1280, 960, 32                      , 0x17d},
+{ 1440, 900, 16                      , 0x17e},
+{ 1440, 900, 24                      , 0x17f},
+{ 1440, 900, 32                      , 0x180},
+{ 1400, 1050, 16                     , 0x181},
+{ 1400, 1050, 24                     , 0x182},
+{ 1400, 1050, 32                     , 0x183},
+{ 1680, 1050, 16                     , 0x184},
+{ 1680, 1050, 24                     , 0x185},
+{ 1680, 1050, 32                     , 0x186},
+{ 1920, 1200, 16                     , 0x187},
+{ 1920, 1200, 24                     , 0x188},
+{ 1920, 1200, 32                     , 0x189},
+{ 2560, 1600, 16                     , 0x18a},
+{ 2560, 1600, 24                     , 0x18b},
+{ 2560, 1600, 32                     , 0x18c},
 { 0, },
 };
 
Binary files vgabios-orig/VGABIOS-lgpl-latest.bin and vgabios/VGABIOS-lgpl-latest.bin differ
Binary files vgabios-orig/VGABIOS-lgpl-latest.cirrus.bin and vgabios/VGABIOS-lgpl-latest.cirrus.bin differ
Binary files vgabios-orig/VGABIOS-lgpl-latest.cirrus.debug.bin and vgabios/VGABIOS-lgpl-latest.cirrus.debug.bin differ
Binary files vgabios-orig/VGABIOS-lgpl-latest.debug.bin and vgabios/VGABIOS-lgpl-latest.debug.bin differ

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option - revised
  2009-01-21 18:23     ` Daniel P. Berrange
@ 2009-01-21 21:51       ` Anthony Liguori
  0 siblings, 0 replies; 24+ messages in thread
From: Anthony Liguori @ 2009-01-21 21:51 UTC (permalink / raw)
  To: Daniel P. Berrange, qemu-devel

Daniel P. Berrange wrote:
> On Wed, Jan 21, 2009 at 01:07:51PM -0500, Trolle Selander wrote:
>   
>> Hi all,
>>
>> This is an updated version of the patch after the suggestions/discussion 
>> on the list. It also includes different handling of how the -vga option 
>> is handled internally, replacing the multiple 
>> independent-yet-mutually-exclusive xxx_vga_enabled variables with one 
>> vgahw_model variable, and also includes the -vga none option added by 
>> Stefano in the time since my last version of this patch. Further 
>> comments & testing welcome. :)
>>     
>
>
>
>   
>> @@ -4933,6 +4930,13 @@
>>              case QEMU_OPTION_vga:
>>                  select_vgahw (optarg);
>>                  break;
>> +            case QEMU_OPTION_videoram:
>> +                {
>> +                    char *ptr;
>> +                    vga_ram_size = strtol(optarg,&ptr,10);
>> +                    vga_ram_size *= 1024 * 1024;
>> +                }
>> +                break;
>>              case QEMU_OPTION_g:
>>                  {
>>                      const char *p;
>>     
>
> Rather than adding more add hoc extra parameters for VGA tunables, we 
> should just make -vga work like the other generic device args, accepting
> a optional list comma separated values following it
>
> eg 
>
>   -vga cirrus,ram=32
>   

Agreed.

Regards,

Anthony Liguori

> Regards,
> Daniel
>   

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-15 20:57                 ` Jamie Lokier
@ 2009-01-15 21:41                   ` Gerd Hoffmann
  0 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-01-15 21:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Brook

Jamie Lokier wrote:
> Gerd Hoffmann wrote:
>> Jamie Lokier wrote:
>>> I don't know why "ypan" is off by default;
>> Performance.  When reaching the end of video memory ypan does a memcpy
>> on the framebuffer.  ywrap doesn't need the memcpy, but doesn't work on
>> all hardware.  The memcpy is painful slow because framebuffer *read*
>> access isn't something gfx cards are optimized for.
> 
> Why read the framebuffer at all?

Has been quite a while that I looked closer at the fb code and followed
fb development.

IIRC it has  to do something with the scrollback (Shift-PgUp/Down)
implementation:  The video memory is used as scrollback buffer.  Thus
some information is kept in the video memory *only*.

> My experience with real hardware is it makes scrolling noticably faster.

Well, maybe it has been changed then.  I remember having seen some
discussion on changing the scrollback implementation to not depend on
video memory, which could have fixed this too.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-15 17:36               ` Gerd Hoffmann
@ 2009-01-15 20:57                 ` Jamie Lokier
  2009-01-15 21:41                   ` Gerd Hoffmann
  0 siblings, 1 reply; 24+ messages in thread
From: Jamie Lokier @ 2009-01-15 20:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Brook

Gerd Hoffmann wrote:
> Jamie Lokier wrote:
> > I don't know why "ypan" is off by default;
> 
> Performance.  When reaching the end of video memory ypan does a memcpy
> on the framebuffer.  ywrap doesn't need the memcpy, but doesn't work on
> all hardware.  The memcpy is painful slow because framebuffer *read*
> access isn't something gfx cards are optimized for.

Why read the framebuffer at all?  In fact why even redraw everything,
when you can redraw only the text which changes during scroll, which
is what vesafb does by default for normal scrolling?

> > If you're using Linux guest with VESA framebuffer console, rather than
> > a text-mode console, I'd recommend kernel boot option "video=vesafb:ypan",
> > to save considerable CPU when scrolling the console.
> 
> Should work inside qemu because you should not face the slow-reads issue
> then.  On real hardware it very likely makes scrolling noticeable slower.

My experience with real hardware is it makes scrolling noticably faster.

-- Jamie

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-15 16:23             ` Jamie Lokier
@ 2009-01-15 17:36               ` Gerd Hoffmann
  2009-01-15 20:57                 ` Jamie Lokier
  0 siblings, 1 reply; 24+ messages in thread
From: Gerd Hoffmann @ 2009-01-15 17:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Brook

Jamie Lokier wrote:
> I don't know why "ypan" is off by default;

Performance.  When reaching the end of video memory ypan does a memcpy
on the framebuffer.  ywrap doesn't need the memcpy, but doesn't work on
all hardware.  The memcpy is painful slow because framebuffer *read*
access isn't something gfx cards are optimized for.

> If you're using Linux guest with VESA framebuffer console, rather than
> a text-mode console, I'd recommend kernel boot option "video=vesafb:ypan",
> to save considerable CPU when scrolling the console.

Should work inside qemu because you should not face the slow-reads issue
then.  On real hardware it very likely makes scrolling noticeable slower.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-15 15:37           ` Rene Rebe
@ 2009-01-15 16:23             ` Jamie Lokier
  2009-01-15 17:36               ` Gerd Hoffmann
  0 siblings, 1 reply; 24+ messages in thread
From: Jamie Lokier @ 2009-01-15 16:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Brook

Rene Rebe wrote:
> >I think the Linux "vesafb" driver uses all available VRAM for
> >scrolling in draws-text-on-graphic-framebuffer mode.
> 
> But only with ypan enabled, which wasn't the default when I took a  
> look the last time.

That's right.

I don't know why "ypan" is off by default; it's hard to imagine it not
working on anything vaguely VBE-like, or even VESA (pre-VBE), since a
lot of DOS games need the panning feature to work for double/triple
buffering.

If you're using Linux guest with VESA framebuffer console, rather than
a text-mode console, I'd recommend kernel boot option "video=vesafb:ypan",
to save considerable CPU when scrolling the console.

I don't know if "video=vesafb:ywrap" works on the QEMU VBE emulation.
That'd be better.

-- Jamie





>  -- René Rebe - ExactCODE GmbH - Europe, Germany, Berlin
> http://exactcode.de | http://t2-project.org | http://rene.rebe.name

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-15 13:08         ` Jamie Lokier
@ 2009-01-15 15:37           ` Rene Rebe
  2009-01-15 16:23             ` Jamie Lokier
  0 siblings, 1 reply; 24+ messages in thread
From: Rene Rebe @ 2009-01-15 15:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Brook

On 15.01.2009, at 14:08, Jamie Lokier wrote:

> Trolle Selander wrote:
>> Maybe "application that uses VBE" was a bad way to put it. If I
>> re-phrase the question as "Does anyone know whether there's any
>> application running under the X "vesa" driver or the Windows "Generic
>> VGA" or similar  unaccellerated driver that makes use of a larger  
>> than
>> triple-buffered (xres * yres * 4) linear framebuffer, or whether the
>> unaccellerated drivers themselves do so in any way?" it will yield  
>> more
>> interesting answers. :)
>
> I think the Linux "vesafb" driver uses all available VRAM for
> scrolling in draws-text-on-graphic-framebuffer mode.


But only with ypan enabled, which wasn't the default when I took a  
look the
last time.

-- 
   René Rebe - ExactCODE GmbH - Europe, Germany, Berlin
   http://exactcode.de | http://t2-project.org | http://rene.rebe.name

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-14 22:47       ` Trolle Selander
@ 2009-01-15 13:08         ` Jamie Lokier
  2009-01-15 15:37           ` Rene Rebe
  0 siblings, 1 reply; 24+ messages in thread
From: Jamie Lokier @ 2009-01-15 13:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Brook

Trolle Selander wrote:
> Maybe "application that uses VBE" was a bad way to put it. If I 
> re-phrase the question as "Does anyone know whether there's any 
> application running under the X "vesa" driver or the Windows "Generic 
> VGA" or similar  unaccellerated driver that makes use of a larger than 
> triple-buffered (xres * yres * 4) linear framebuffer, or whether the 
> unaccellerated drivers themselves do so in any way?" it will yield more 
> interesting answers. :)

I think the Linux "vesafb" driver uses all available VRAM for
scrolling in draws-text-on-graphic-framebuffer mode.

-- Jamie

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-14 21:30     ` Paul Brook
@ 2009-01-14 22:47       ` Trolle Selander
  2009-01-15 13:08         ` Jamie Lokier
  0 siblings, 1 reply; 24+ messages in thread
From: Trolle Selander @ 2009-01-14 22:47 UTC (permalink / raw)
  To: Paul Brook, qemu-devel

Paul Brook wrote:
>> Just out of curiosity, does anyone have any example of an existing
>> application using VBE that makes use of more than triple-buffered (xres
>> * yres * 4) RAM?
>>     
>
> I suspect you'll struggle to find *any* serious application that uses VBE 
> nowadays.
>
> Paul
>
>   
Maybe "application that uses VBE" was a bad way to put it. If I 
re-phrase the question as "Does anyone know whether there's any 
application running under the X "vesa" driver or the Windows "Generic 
VGA" or similar  unaccellerated driver that makes use of a larger than 
triple-buffered (xres * yres * 4) linear framebuffer, or whether the 
unaccellerated drivers themselves do so in any way?" it will yield more 
interesting answers. :)

-- Trolle

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-14 20:41   ` Trolle Selander
@ 2009-01-14 21:30     ` Paul Brook
  2009-01-14 22:47       ` Trolle Selander
  0 siblings, 1 reply; 24+ messages in thread
From: Paul Brook @ 2009-01-14 21:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Trolle Selander

> Just out of curiosity, does anyone have any example of an existing
> application using VBE that makes use of more than triple-buffered (xres
> * yres * 4) RAM?

I suspect you'll struggle to find *any* serious application that uses VBE 
nowadays.

Paul

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-14 20:07 ` Paul Brook
@ 2009-01-14 20:41   ` Trolle Selander
  2009-01-14 21:30     ` Paul Brook
  0 siblings, 1 reply; 24+ messages in thread
From: Trolle Selander @ 2009-01-14 20:41 UTC (permalink / raw)
  To: Paul Brook; +Cc: qemu-devel

Paul Brook wrote:
>> While I have my doubts about there being any applications or games using
>> VBE & triple buffering that will actually run at 2560x1600 with any kind
>> of decent performance , I also see no reason to set this limit any lower
>> than the theoretically usable max, so 48 Megs it is.
>>     
>
> You're missing the point. There is no "usable max". The only limits are those 
> implied by 16-bit coordinates, address space, and the imagination of the 
> programmer.
>
> Paul
>
>   
True, but my thought was mainly that most of these "vram tricks" are 
very unlikely to be used by any software run in the VM and thus ending 
up going to waste and moreover  (probably) pointless in a virtual 
architecture where there is no slow bus between videocard ram and system 
ram.
In any case, the discussion here has made me reconsider whether we 
should not enforce any "artificial" limit, and just put recommendations 
for "sane" in the manpage, since ultimately, my reason for putting the 
limit in was mostly to prevent users from naively allocationg 
"pointless" amounts of vram that will almost certainly be wasted. The 
amounts of "graphic card ram" common today might easily cause new users 
to make this mistake. What's everyone else's thoughts on this? I'm 
preparing a slightly updated version of the patch, and I'd like to hear 
whether everyone agrees there should be no artificial limit enforced.

Just out of curiosity, does anyone have any example of an existing 
application using VBE that makes use of more than triple-buffered (xres 
* yres * 4) RAM?

-- Trolle

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
  2009-01-12 19:13 [Qemu-devel] [PATCH] [RFC] Variable video ram size option Trolle Selander
@ 2009-01-14 20:07 ` Paul Brook
  2009-01-14 20:41   ` Trolle Selander
  0 siblings, 1 reply; 24+ messages in thread
From: Paul Brook @ 2009-01-14 20:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Trolle Selander

> While I have my doubts about there being any applications or games using
> VBE & triple buffering that will actually run at 2560x1600 with any kind
> of decent performance , I also see no reason to set this limit any lower
> than the theoretically usable max, so 48 Megs it is.

You're missing the point. There is no "usable max". The only limits are those 
implied by 16-bit coordinates, address space, and the imagination of the 
programmer.

Paul

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option
@ 2009-01-12 19:13 Trolle Selander
  2009-01-14 20:07 ` Paul Brook
  0 siblings, 1 reply; 24+ messages in thread
From: Trolle Selander @ 2009-01-12 19:13 UTC (permalink / raw)
  To: qemu-devel

>
> Trolle Selander wrote:
> >/ Paul Brook wrote:/
> >/ >>Trying hard to think up a use for more than 16 Megs in the current case,/
> >/ >>    /
> >/ >/
> >/ >I'm pretty sure the current device allows the guest to do page flipping /
> >/ >(using an oversize virtual framebuffer)./
> >/ >/
> >/ >Paul/
> >/ >  /
> >/ I could have sworn I checked that at some point and found that it/
> >/ didn't, but looking at the vgabios code now it looks like it's all/
> >/ implemented. That definitely bumps the useable limit to 32 Megs even in/
> >/ the current case. Thanks for catching this, I'll add it to the fix list./
>
> For games _triple_ buffering is a common technique when there's enough RAM.
>
> With double buffering, after you flip away from screen 0 to screen 1, you
> have to pause until the next vsync before it's safe to draw a new
> image on screen 0.
>
> With triple buffering, this pause isn't required which makes games
> (etc.) able to run at a higher average frame rate.
>
> (More buffers can smooth the average further, which is more useful
> when playing video than games, because it adds latency but hides
> individual frame drawing time spikes.  But it's not that useful.
> Triple buffering is relatively common though.)
>
> So there's a use for 3 screens in the virtual framebuffer - 48 MB?
>
> -- Jamie
>   
While I have my doubts about there being any applications or games using 
VBE & triple buffering that will actually run at 2560x1600 with any kind 
of decent performance , I also see no reason to set this limit any lower 
than the theoretically usable max, so 48 Megs it is.

-- Trolle

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2009-01-21 21:51 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-09 19:45 [Qemu-devel] [PATCH] [RFC] Variable video ram size option Trolle Selander
2009-01-10  0:02 ` Paul Brook
2009-01-10  1:26   ` Trolle Selander
2009-01-10  6:45     ` Blue Swirl
     [not found]   ` <4967E7D7.4040605@eu.citrix.com>
     [not found]     ` <200901091716.00827.paul@codesourcery.com>
2009-01-10  1:27       ` Trolle Selander
     [not found]       ` <4967ECA7.6040809@eu.citrix.com>
     [not found]         ` <200901091747.06462.paul@codesourcery.com>
2009-01-10  1:28           ` Trolle Selander
2009-01-10  1:47             ` Jamie Lokier
2009-01-11  7:53 ` Avi Kivity
2009-01-12 17:43   ` Trolle Selander
2009-01-21 18:07   ` [Qemu-devel] [PATCH] [RFC] Variable video ram size option - revised Trolle Selander
2009-01-21 18:23     ` Daniel P. Berrange
2009-01-21 21:51       ` Anthony Liguori
2009-01-21 21:21     ` [Qemu-devel] " Trolle Selander
2009-01-12 19:13 [Qemu-devel] [PATCH] [RFC] Variable video ram size option Trolle Selander
2009-01-14 20:07 ` Paul Brook
2009-01-14 20:41   ` Trolle Selander
2009-01-14 21:30     ` Paul Brook
2009-01-14 22:47       ` Trolle Selander
2009-01-15 13:08         ` Jamie Lokier
2009-01-15 15:37           ` Rene Rebe
2009-01-15 16:23             ` Jamie Lokier
2009-01-15 17:36               ` Gerd Hoffmann
2009-01-15 20:57                 ` Jamie Lokier
2009-01-15 21:41                   ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.