]> xenbits.xensource.com Git - xenclient/ioemu-pq.git/commitdiff
Fix qemu intel driver rebase on xen 3.4.
authorJean Guyader <jean.guyader@eu.citrix.com>
Tue, 2 Jun 2009 13:41:00 +0000 (14:41 +0100)
committerJean Guyader <jean.guyader@eu.citrix.com>
Tue, 2 Jun 2009 13:41:00 +0000 (14:41 +0100)
master/intel

index 8586cbbea85fa85fd83de6f0071060688b362c7c..2b74a3a3aa109090b9c59d787d62b56ff845a7c0 100644 (file)
@@ -5,7 +5,7 @@ index 97214c0..8c9b09b 100644
 @@ -70,6 +70,8 @@ void kbd_put_keysym(int keysym);
  #define QEMU_BIG_ENDIAN_FLAG    0x01
  #define QEMU_ALLOCATED_FLAG     0x02
-
 +#define INTEL_MAPPED_FLAG 0x04
 +
  struct PixelFormat {
@@ -14,7 +14,7 @@ index 97214c0..8c9b09b 100644
 @@ -290,6 +292,11 @@ void vga_hw_update(void);
  void vga_hw_invalidate(void);
  void vga_hw_screen_dump(const char *filename);
-
 +void unset_vga_acc(void);
 +void set_vga_acc(void);
 +extern uint32_t guest_framebuffer;
@@ -26,20 +26,20 @@ index 97214c0..8c9b09b 100644
 @@ -356,4 +363,8 @@ void hid_linux_add_binding(const int *, void (*)(void*), void *);
  void hid_linux_reset_keyboard(void);
  void hid_linux_probe(int grab);
-
 +/* intel.c */
 +int intel_enter(void);
 +int intel_leave(void);
 +void intel_display_init(DisplayState *ds);
  #endif
 diff --git a/hw/vga.c b/hw/vga.c
-index 90bd544..8ba57cb 100644
+index 90bd544..a2b8744 100644
 --- a/hw/vga.c
 +++ b/hw/vga.c
 @@ -161,6 +161,18 @@ static uint8_t expand4to8[16];
  static void vga_bios_init(VGAState *s);
  static void vga_screen_dump(void *opaque, const char *filename);
-
 +static VGAState *xen_vga_state;
 +
 +void set_vga_acc(void)
@@ -55,19 +55,34 @@ index 90bd544..8ba57cb 100644
  static void vga_dumb_update_retrace_info(VGAState *s)
  {
      (void) s;
-@@ -618,7 +630,7 @@ static void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val)
+@@ -618,8 +630,8 @@ static void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val)
              if ((val & VBE_DISPI_ENABLED) &&
                  !(s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED)) {
                  int h, shift_control;
 -                
+-                if (s->vram_gmfn != s->lfb_addr) {
 +
-                 if (s->vram_gmfn != s->lfb_addr) {
++                if (s->vram_gmfn != s->lfb_addr && intel_output != 1) {
                       set_vram_mapping(s, s->lfb_addr, s->lfb_end);
                  }
-@@ -1313,12 +1325,12 @@ static void vga_draw_text(VGAState *s, int full_update)
+@@ -637,12 +649,6 @@ static void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val)
+                         ((s->vbe_regs[VBE_DISPI_INDEX_BPP] + 7) >> 3);
+                 s->vbe_start_addr = 0;
+-                /* clear the screen (should be done in BIOS) */
+-                if (!(val & VBE_DISPI_NOCLEARMEM)) {
+-                    memset(s->vram_ptr, 0,
+-                           s->vbe_regs[VBE_DISPI_INDEX_YRES] * s->vbe_line_offset);
+-                }
+-
+                 /* we initialize the VGA graphic mode (should be done
+                    in BIOS) */
+                 s->gr[0x06] = (s->gr[0x06] & ~0x0c) | 0x05; /* graphic mode + memory map 1 */
+@@ -1313,12 +1319,12 @@ static void vga_draw_text(VGAState *s, int full_update)
          full_update = 1;
      }
-
 -    s->rgb_to_pixel = 
 +    s->rgb_to_pixel =
          rgb_to_pixel_dup_table[get_depth_index(s->ds)];
@@ -79,9 +94,9 @@ index 90bd544..8ba57cb 100644
      cursor_offset = ((s->cr[0x0e] << 8) | s->cr[0x0f]) - s->start_addr;
      if (cursor_offset != s->cursor_offset ||
          s->cr[0xa] != s->cursor_start ||
-@@ -1596,15 +1608,12 @@ static void vga_draw_graphic(VGAState *s, int full_update)
+@@ -1596,15 +1602,12 @@ static void vga_draw_graphic(VGAState *s, int full_update)
      }
-
      depth = s->get_bpp(s);
 -    if (s->line_offset != s->last_line_offset || 
 +    guest_framebuffer = s->lfb_addr + (s->start_addr * 4);
@@ -97,25 +112,28 @@ index 90bd544..8ba57cb 100644
              if (is_graphic_console()) {
                  qemu_free_displaysurface(s->ds);
                  s->ds->surface = qemu_create_displaysurface_from(disp_width, height, depth,
-@@ -1633,7 +1642,7 @@ static void vga_draw_graphic(VGAState *s, int full_update)
+@@ -1633,9 +1636,8 @@ static void vga_draw_graphic(VGAState *s, int full_update)
          dpy_setdata(s->ds);
      }
-
 -    s->rgb_to_pixel = 
 +    s->rgb_to_pixel =
          rgb_to_pixel_dup_table[get_depth_index(s->ds)];
-
+-
      if (shift_control == 0) {
-@@ -1832,6 +1841,8 @@ static void vga_draw_blank(VGAState *s, int full_update)
-     /* Disable dirty bit tracking */
-     xc_hvm_track_dirty_vram(xc_handle, domid, 0, 0, NULL);
-
-+    if (intel_output && is_buffer_shared(s->ds->surface))
+         full_update |= update_palette16(s);
+         if (s->sr[0x01] & 8) {
+@@ -1684,6 +1686,9 @@ static void vga_draw_graphic(VGAState *s, int full_update)
+         }
+     }
++    if (intel_output == 1 && is_buffer_shared(s->ds->surface))
 +        return;
-     s->rgb_to_pixel =
-         rgb_to_pixel_dup_table[get_depth_index(s->ds)];
-     if (ds_get_bits_per_pixel(s->ds) == 8)
-@@ -2008,8 +2019,8 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
++
+     vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(s->ds)];
+     if (!is_buffer_shared(s->ds->surface) && s->cursor_invalidate)
+         s->cursor_invalidate(s);
+@@ -2008,8 +2013,8 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
              /* ugly hack for CGA 160x100x16 - explain me the logic */
              height = 100;
          } else {
@@ -126,7 +144,7 @@ index 90bd544..8ba57cb 100644
                  ((s->cr[0x07] & 0x40) << 3);
              height = (height + 1) / cheight;
          }
-@@ -2304,7 +2315,7 @@ static int vga_load(QEMUFile *f, void *opaque, int version_id)
+@@ -2304,7 +2309,7 @@ static int vga_load(QEMUFile *f, void *opaque, int version_id)
          if (!s->vram_gmfn) {
              xen_vga_populate_vram(VRAM_RESERVED_ADDRESS, s->vram_size);
              s->vram_gmfn = VRAM_RESERVED_ADDRESS;
@@ -134,26 +152,26 @@ index 90bd544..8ba57cb 100644
 +            qemu_get_buffer(f, s->vram_ptr, s->vram_size);
          }
      }
-
-@@ -2334,7 +2345,7 @@ static void vga_map(PCIDevice *pci_dev, int region_num,
+@@ -2334,7 +2339,7 @@ static void vga_map(PCIDevice *pci_dev, int region_num,
          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
 -   
 +
          fprintf(stderr, "vga s->lfb_addr = %lx s->lfb_end = %lx \n", (unsigned long) s->lfb_addr,(unsigned long) s->lfb_end);
-
          if (size != s->vram_size)
-@@ -2473,8 +2484,6 @@ static void vga_bios_init(VGAState *s)
+@@ -2473,8 +2478,6 @@ static void vga_bios_init(VGAState *s)
  }
-
-
 -static VGAState *xen_vga_state;
 -
  /* Allocate video memory in the GPFN space */
  void xen_vga_populate_vram(uint64_t vram_addr, uint32_t vga_ram_size)
  {
-@@ -2660,7 +2669,7 @@ int isa_vga_init(uint8_t *vga_ram_base,
+@@ -2660,7 +2663,7 @@ int isa_vga_init(uint8_t *vga_ram_base,
      s = qemu_mallocz(sizeof(VGAState));
      if (!s)
          return -1;
@@ -162,7 +180,7 @@ index 90bd544..8ba57cb 100644
      if (vga_ram_size > 16*1024*1024) {
          fprintf (stderr, "The stdvga/VBE device model has no use for more than 16 Megs of vram. Video ram set to 16M. \n");
          vga_ram_size = 16*1024*1024;
-@@ -2820,7 +2829,7 @@ static void vga_screen_dump(void *opaque, const char *filename)
+@@ -2820,7 +2823,7 @@ static void vga_screen_dump(void *opaque, const char *filename)
      register_displaychangelistener(ds, &dcl);
      ds->allocator = &default_allocator;
      ds->surface = qemu_create_displaysurface(ds, w, h);
@@ -173,10 +191,10 @@ index 90bd544..8ba57cb 100644
      vga_update_display(s);
 diff --git a/intel.c b/intel.c
 new file mode 100644
-index 0000000..8a20756
+index 0000000..eb0b9c0
 --- /dev/null
 +++ b/intel.c
-@@ -0,0 +1,405 @@
+@@ -0,0 +1,448 @@
 +#include <stdio.h>
 +#include <stdlib.h>
 +#include <stdint.h>
@@ -193,7 +211,7 @@ index 0000000..8a20756
 +#include "sysemu.h"
 +
 +#define INTEL_DEBUG(format, args...)                                    \
-+    fprintf (stderr, "intel.c:%d:%s " format , __LINE__, __func__, ## args)
++    fprintf (stderr, "intel.c:%d:%s " format , __LINE__, __func__, ## args);
 +
 +#define TileW           128
 +#define TileH           8
@@ -296,7 +314,7 @@ index 0000000..8a20756
 +        *pipebconf |= pipeb;
 +    }
 +
-+    usleep(20000);
++    usleep(50 * 1000); /* 50 ms */
 +
 +    *pipeaconf &= ~(0x3 << 18);
 +    /* Enable surface linear mode */
@@ -317,7 +335,7 @@ index 0000000..8a20756
 +    }
 +    if (linesize) IntelPitch = linesize;
 +
-+    usleep(20000);
++    usleep(50 * 1000); /* 500 ms */
 +}
 +
 +static void set_fb_mapping(void)
@@ -377,27 +395,66 @@ index 0000000..8a20756
 +static void intel_update(DisplayState *ds, int x, int y, int w, int h)
 +{
 +    /* do nothing */
++    int i, bpp = ds_get_bytes_per_pixel(ds);
++    unsigned char *s, *d;
++
++    if (!intel_have_focus || !is_buffer_shared(ds->surface))
++        return;
++
++    if ((x > IntelX || y > IntelY))
++        return;
++    if ((x + w) > IntelX)
++        w = IntelX - x;
++    if ((y + h) > IntelY)
++        h = IntelY - y;
++
++    s = ds_get_data(ds);
++    d = (unsigned char *)(intel_mem + intel_get_reg(REG_DR_DSPASURF));
++    /* Center the screen */
++    if (ds_get_width(ds) < IntelX && ds_get_height(ds) < IntelY)
++        d += IntelPitch * ((IntelY - ds_get_height(ds)) / 2) +
++            4 * ((IntelX - ds_get_width(ds)) / 2);
++
++    s += (ds_get_linesize(ds) * y) + bpp * x;
++    d += (IntelPitch * y) + bpp * x;
++    for (i = 0; i < h; i++) {
++        memcpy(d, s, w * bpp);
++        s += ds_get_linesize(ds);
++        d += IntelPitch;
++    }
 +}
 +
 +static void intel_resize(DisplayState *ds)
 +{
-+    INTEL_DEBUG("intel_resize: shared=%d\n", is_buffer_shared(ds->surface));
-+    if (intel_have_focus) {
-+        if (!is_buffer_shared(ds->surface) && !is_linear())
-+            intel_force_linear(0);
-+        else if (!is_linear() || IntelPitch != ds_get_linesize(lds))
-+            intel_force_linear(ds_get_linesize(lds));
-+    }
-+    if (!is_buffer_shared(ds->surface))
-+        return;
-+    if (intel_have_focus) {
-+        if (!map_size) {
-+            set_fb_mapping();
++    INTEL_DEBUG("intel_resize: shared=%d, width=%d, height=%d, depth=%d\n",
++            is_buffer_shared(ds->surface),
++            ds_get_width(ds),
++            ds_get_height(ds),
++            ds_get_bytes_per_pixel(ds));
++    if (intel_have_focus)
++    {
++        if (ds_get_width(ds) == IntelX && ds_get_height(ds) == IntelY &&
++                is_buffer_shared(ds->surface))
++        {
++            if (!map_size)
++            {
++                intel_force_linear(ds_get_linesize(ds));
++                set_fb_mapping();
++            }
++            intel_output = 1;
++        }
++        else
++        {
++            if (map_size)
++                unset_fb_mapping();
++            else
++                intel_force_linear(0);
++            intel_output = 2;
 +        }
 +    } else {
-+        if (map_size) {
++        if (map_size)
 +            unset_fb_mapping();
-+        }
++        intel_output = 1;
 +    }
 +}
 +
@@ -479,7 +536,6 @@ index 0000000..8a20756
 +    if (intel_have_focus == focus)
 +        return;
 +
-+    INTEL_DEBUG("intel_focus %d\n", focus);
 +    intel_have_focus = focus;
 +    if (intel_have_focus) {
 +        IntelPitch = intel_get_reg(REG_DR_DSPASTRIDE);
@@ -488,6 +544,9 @@ index 0000000..8a20756
 +    }
 +    vga_hw_invalidate();
 +    vga_hw_update();
++
++    INTEL_DEBUG("intel_focus %d, x=%d, y=%d, stride=%d\n",
++            focus, IntelX, IntelY, IntelPitch);
 +}
 +
 +int intel_enter(void)
@@ -541,6 +600,8 @@ index 0000000..8a20756
 +static DisplaySurface* intel_resize_displaysurface(DisplaySurface *surface, int width, int height)
 +{
 +    intel_free_displaysurface(surface);
++    if (map_size)
++        unset_fb_mapping();
 +    return intel_create_displaysurface(width, height);
 +}
 +
@@ -599,7 +660,7 @@ index 0ffe1ec..97cb5d8 100644
      QEMU_OPTION_vga_passthrough,
      QEMU_OPTION_dom0_input,
 +    QEMU_OPTION_intel,
-
      /* Debug/Expert options: */
      QEMU_OPTION_serial,
 @@ -4468,6 +4470,7 @@ static const QEMUOption qemu_options[] = {
@@ -663,9 +724,9 @@ index 0ffe1ec..97cb5d8 100644
 -            }
      }
      dpy_resize(ds);
-
 diff --git a/xen-hooks.mak b/xen-hooks.mak
-index f243df1..55dd477 100644
+index 15ba4d1..528bb7a 100644
 --- a/xen-hooks.mak
 +++ b/xen-hooks.mak
 @@ -39,6 +39,7 @@ OBJS += xen_acpi_wmi.o
@@ -673,6 +734,6 @@ index f243df1..55dd477 100644
  OBJS += dom0_driver.o
  OBJS += hid-linux.o
 +OBJS += intel.o
-
- ifdef CONFIG_STUBDOM
- CPPFLAGS += $(TARGET_CPPFLAGS) -DNEED_CPU_H \
+ CONFIG_AUDIO=1