[Spice-commits] Branch 'audio.2' - 3 commits - hw/intel-hda.c

Gerd Hoffmann kraxel at kemper.freedesktop.org
Thu Oct 28 05:23:45 PDT 2010


 hw/intel-hda.c |   34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

New commits:
commit d57c2efa9e2b0eb9419f51b750d6a0c6ee51fb1f
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Oct 28 13:38:27 2010 +0200

    intel-hda: handle endianness when accessing guest memory

diff --git a/hw/intel-hda.c b/hw/intel-hda.c
index 7657fce..c9ec826 100644
--- a/hw/intel-hda.c
+++ b/hw/intel-hda.c
@@ -202,6 +202,19 @@ static target_phys_addr_t intel_hda_addr(uint32_t lbase, uint32_t ubase)
     return addr;
 }
 
+static void stl_phys_le(target_phys_addr_t addr, uint32_t value)
+{
+    uint32_t value_le = cpu_to_le32(value);
+    cpu_physical_memory_write(addr, (uint8_t*)(&value_le), sizeof(value_le));
+}
+
+static uint32_t ldl_phys_le(target_phys_addr_t addr)
+{
+    uint32_t value_le;
+    cpu_physical_memory_read(addr, (uint8_t*)(&value_le), sizeof(value_le));
+    return le32_to_cpu(value_le);
+}
+
 static void intel_hda_update_int_sts(IntelHDAState *d)
 {
     uint32_t sts = 0;
@@ -266,7 +279,7 @@ static void intel_hda_corb_run(IntelHDAState *d)
 
         rp = (d->corb_rp + 1) & 0xff;
         addr = intel_hda_addr(d->corb_lbase, d->corb_ubase);
-        verb = ldl_phys(addr + 4*rp);
+        verb = ldl_phys_le(addr + 4*rp);
         d->corb_rp = rp;
 
         cad = (verb >> 28) & 0x0f;
@@ -294,8 +307,8 @@ static void intel_hda_response(HDACodecDevice *dev, bool solicited, uint32_t res
     ex = (solicited ? 0 : (1 << 4)) | dev->cad;
     wp = (d->rirb_wp + 1) & 0xff;
     addr = intel_hda_addr(d->rirb_lbase, d->rirb_ubase);
-    stl_phys(addr + 8*wp, response);
-    stl_phys(addr + 8*wp + 4, ex);
+    stl_phys_le(addr + 8*wp, response);
+    stl_phys_le(addr + 8*wp + 4, ex);
     d->rirb_wp = wp;
 
     dprint(d, 2, "%s: [wp 0x%x] response 0x%x, extra 0x%x\n",
@@ -379,7 +392,7 @@ static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t stnr, bool output,
     }
     if (d->dp_lbase & 0x01) {
         addr = intel_hda_addr(d->dp_lbase & ~0x01, d->dp_ubase);
-        stl_phys(addr + 8*s, st->lpib);
+        stl_phys_le(addr + 8*s, st->lpib);
     }
     /* TODO: update DP */
     dprint(d, 3, "dma: --\n");
@@ -394,16 +407,18 @@ static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t stnr, bool output,
 static void intel_hda_parse_bdl(IntelHDAState *d, IntelHDAStream *st)
 {
     target_phys_addr_t addr;
+    uint8_t *ptr;
     uint32_t i;
 
     addr = intel_hda_addr(st->bdlp_lbase, st->bdlp_ubase);
+    ptr = qemu_get_ram_ptr(addr);
     st->bentries = st->lvi +1;
     qemu_free(st->bpl);
     st->bpl = qemu_malloc(sizeof(bpl) * st->bentries);
-    for (i = 0; i < st->bentries; i++, addr += 16) {
-        st->bpl[i].addr  = ldq_phys(addr);
-        st->bpl[i].len   = ldl_phys(addr + 8);
-        st->bpl[i].flags = ldl_phys(addr + 12);
+    for (i = 0; i < st->bentries; i++, ptr += 16) {
+        st->bpl[i].addr  = le64_to_cpu(*(uint64_t *)ptr);
+        st->bpl[i].len   = le32_to_cpu(*(uint32_t *)(ptr + 8));
+        st->bpl[i].flags = le32_to_cpu(*(uint32_t *)(ptr + 12));
         dprint(d, 1, "bdl/%d: 0x%" PRIx64 " +0x%x, 0x%x\n",
                i, st->bpl[i].addr, st->bpl[i].len, st->bpl[i].flags);
     }
commit bdbcba6050afe7d216d68ea81d4968910152f2ee
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Oct 28 13:19:37 2010 +0200

    intel-hda: update irq status after reset

diff --git a/hw/intel-hda.c b/hw/intel-hda.c
index ffd4d80..7657fce 100644
--- a/hw/intel-hda.c
+++ b/hw/intel-hda.c
@@ -1013,6 +1013,7 @@ static void intel_hda_reset(DeviceState *dev)
             qdev->info->reset(qdev);
         d->state_sts |= (1 << cdev->cad);
     }
+    intel_hda_update_irq(d);
 }
 
 static int intel_hda_init(PCIDevice *pci)
commit f81dfd67d95d290ab344560b23040d6391b19326
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Oct 28 13:17:55 2010 +0200

    intel-hda: fix w1c (write-one-to-clear-bit) logic.

diff --git a/hw/intel-hda.c b/hw/intel-hda.c
index af8909e..ffd4d80 100644
--- a/hw/intel-hda.c
+++ b/hw/intel-hda.c
@@ -854,9 +854,9 @@ static void intel_hda_reg_write(IntelHDAState *d, const IntelHDAReg *reg, uint32
         wmask <<= reg->shift;
     }
     wmask &= reg->wmask;
-    val   ^= reg->wclear;
     *addr &= ~wmask;
     *addr |= wmask & val;
+    *addr &= ~(val & reg->wclear);
 
     if (reg->whandler) {
         reg->whandler(d, reg, old);


More information about the Spice-commits mailing list