Re: [Qemu-devel] [PATCH] Add AACI audio playback support to the ARM Versatile/PB platform

2011-05-12 Thread Paul Brook
 On the other hand the current ac97.c implementation is a closely coupled
 combination of a PCI/ACLink bridge (Intel 82801AA) with a generic AC97
 codec. This has prevent me to easily reuse this code.
 
 The milkymist-ac97 implementation is another case. It looks like a basic
 implementation with the AC97 registers directly mapped on the system bus.
 
 Using the ACLink bus I defined, it could be interesting to implement
 separately the PCI/ACLink bridge from ac97.c.
 
 Is it what you mean by saying this should be shared with the other AC97
 devices ?

Yes. The whole point of AClink is that it separates the host bridge from the 
codec. We now have at least three devices implementing this.  Your aclink 
implementation is only used by one of these, which gives me little confidence 
it actually does what it claims.

Paul



Re: [Qemu-devel] [PATCH] Add AACI audio playback support to the ARM Versatile/PB platform

2011-05-12 Thread Mathieu Sonet

Paul Brook wrote:

On the other hand the current ac97.c implementation is a closely coupled
combination of a PCI/ACLink bridge (Intel 82801AA) with a generic AC97
codec. This has prevent me to easily reuse this code.

The milkymist-ac97 implementation is another case. It looks like a basic
implementation with the AC97 registers directly mapped on the system bus.

Using the ACLink bus I defined, it could be interesting to implement
separately the PCI/ACLink bridge from ac97.c.

Is it what you mean by saying this should be shared with the other AC97
devices ?


Yes. The whole point of AClink is that it separates the host bridge from the 
codec. We now have at least three devices implementing this.  Your aclink 
implementation is only used by one of these, which gives me little confidence 
it actually does what it claims.


Paul


I understand your concern.

In fact after digging the Intel PCI bridge documentation, I see that it 
 offers a mapping of the AC97 registers in the PCI I/O space.


Reusing my current ACLink bus with this bridge would mean to encode 
register accesses into ACLink frames and then to decode them again on 
the codec side. Not very simple just for the sake of device models 
correctness and no added value.


Also QEMU may not need N different re-implemention of an AC97 codec.

So I will ditch ACLink/LM4549 and will instead interface the PL041 
driver with the codec defined in ac97.c.


  PCI---AC97
PL041--/

Thanks for your input
Mathieu





Re: [Qemu-devel] [PATCH] Add AACI audio playback support to the ARM Versatile/PB platform

2011-05-11 Thread Paul Brook
 The PL041 driver provides an interface to an ACLink bus.
 The LM4549 driver emulates a DAC connected on the ACLink bus.
 Only audio playback is implemented.

Shouldn't this be shared with the other AC97 devices?

Paul



Re: [Qemu-devel] [PATCH] Add AACI audio playback support to the ARM Versatile/PB platform

2011-05-11 Thread Mathieu Sonet

Paul Brook wrote:

The PL041 driver provides an interface to an ACLink bus.
The LM4549 driver emulates a DAC connected on the ACLink bus.
Only audio playback is implemented.


Shouldn't this be shared with the other AC97 devices?

Paul


I organized the code in 3 different drivers (PL041 = ACLink = 
LM4549) to decorrelate the codec interface from its implementation. This 
could allow the use of alternative AC97 models with the same PL041 
implementation.


On the other hand the current ac97.c implementation is a closely coupled 
combination of a PCI/ACLink bridge (Intel 82801AA) with a generic AC97 
codec. This has prevent me to easily reuse this code.


The milkymist-ac97 implementation is another case. It looks like a basic 
implementation with the AC97 registers directly mapped on the system bus.


Using the ACLink bus I defined, it could be interesting to implement 
separately the PCI/ACLink bridge from ac97.c.


Is it what you mean by saying this should be shared with the other AC97 
devices ?


Mathieu



[Qemu-devel] [PATCH] Add AACI audio playback support to the ARM Versatile/PB platform

2011-05-10 Thread Mathieu Sonet
The PL041 driver provides an interface to an ACLink bus.
The LM4549 driver emulates a DAC connected on the ACLink bus.
Only audio playback is implemented.

Versatile/PB test build:
linux-2.6.38.5
buildroot-2010.11
alsa-lib-1.0.22
alsa-utils-1.0.22
mpg123-0.66

Qemu host: Ubuntu 10.04 in Vmware/OS X

Playback tested successfully with aplay and mpg123.

Signed-off-by: Mathieu Sonet cont...@elasticsheep.com
---
 Makefile.target  |1 +
 hw/aclink.c  |  121 +++
 hw/aclink.h  |   63 
 hw/lm4549.c  |  368 +
 hw/pl041.c   |  436 ++
 hw/pl041.h   |  126 
 hw/pl041.hx  |   62 
 hw/versatilepb.c |6 +
 8 files changed, 1183 insertions(+), 0 deletions(-)
 create mode 100644 hw/aclink.c
 create mode 100644 hw/aclink.h
 create mode 100644 hw/lm4549.c
 create mode 100644 hw/pl041.c
 create mode 100644 hw/pl041.h
 create mode 100644 hw/pl041.hx

diff --git a/Makefile.target b/Makefile.target
index 21f864a..cdd7b40 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -354,6 +354,7 @@ obj-arm-y += syborg_virtio.o
 obj-arm-y += vexpress.o
 obj-arm-y += strongarm.o
 obj-arm-y += collie.o
+obj-arm-y += pl041.o aclink.o lm4549.o

 obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
 obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o
diff --git a/hw/aclink.c b/hw/aclink.c
new file mode 100644
index 000..c335f60
--- /dev/null
+++ b/hw/aclink.c
@@ -0,0 +1,121 @@
+/*
+ * ACLink Interface
+ *
+ * Copyright (c) 2011
+ * Written by Mathieu Sonet - www.elasticsheep.com
+ *
+ * This code is licenced under the GPL.
+ *
+ * *
+ *
+ * This file defines the ACLink bus interface to exchange data
+ * between an host and a codec.
+ *
+ */
+
+#include aclink.h
+
+/*** Types ***/
+
+struct ACLinkBus {
+BusState qbus;
+ACLinkControllerInfo *controller_info;
+uint32_t bitclk;
+};
+
+struct BusInfo aclink_bus_info = {
+.name = aclink,
+.size = sizeof(ACLinkBus),
+};
+
+/*** Functions ***/
+
+ACLinkBus *aclink_create_bus(DeviceState *parent, const char *name)
+{
+BusState *bus;
+bus = qbus_create(aclink_bus_info, parent, name);
+return FROM_QBUS(ACLinkBus, bus);
+}
+
+void aclink_set_controller_info(ACLinkBus *bus, ACLinkControllerInfo *info)
+{
+bus-controller_info = info;
+}
+
+static int aclink_device_init(DeviceState *dev, DeviceInfo *base_info)
+{
+ACLinkDeviceInfo *info = container_of(base_info, ACLinkDeviceInfo, qdev);
+ACLinkDevice *s = ACLINK_DEVICE_FROM_QDEV(dev);
+ACLinkBus *bus;
+
+bus = FROM_QBUS(ACLinkBus, qdev_get_parent_bus(dev));
+if (QLIST_FIRST(bus-qbus.children) != dev
+|| QLIST_NEXT(dev, sibling) != NULL) {
+hw_error(Too many devices on the ACLINK bus);
+}
+
+s-info = info;
+return info-init(s);
+}
+
+void aclink_register_device(ACLinkDeviceInfo *info)
+{
+assert(info-qdev.size = sizeof(ACLinkDevice));
+info-qdev.init = aclink_device_init;
+info-qdev.bus_info = aclink_bus_info;
+qdev_register(info-qdev);
+}
+
+DeviceState *aclink_create_device(ACLinkBus *bus, const char *name)
+{
+DeviceState *dev;
+dev = qdev_create(bus-qbus, name);
+qdev_init_nofail(dev);
+return dev;
+}
+
+static ACLinkDevice *aclink_get_device(ACLinkBus *bus)
+{
+DeviceState *dev = QLIST_FIRST(bus-qbus.children);
+if (!dev) {
+return NULL;
+}
+return ACLINK_DEVICE_FROM_QDEV(dev);
+}
+
+void aclink_bitclk_enable(ACLinkDevice *dev, uint32_t on)
+{
+ACLinkBus *bus = FROM_QBUS(ACLinkBus, qdev_get_parent_bus(dev-qdev));
+uint32_t has_changed;
+
+on = (on  0) ? 1 : 0;
+has_changed = (bus-bitclk != on) ? 1 : 0;
+
+bus-bitclk = on;
+if (has_changed) {
+bus-controller_info-bitclk_state_changed(bus-qbus.parent);
+}
+}
+
+uint32_t aclink_bitclk_is_enabled(ACLinkBus *bus)
+{
+return bus-bitclk;
+}
+
+void aclink_sdataout_slot12(ACLinkBus *bus, uint32_t slot1, uint32_t slot2)
+{
+ACLinkDevice *device = aclink_get_device(bus);
+device-info-sdataout_slot12(device, slot1, slot2);
+}
+
+void aclink_sdataout_slot34(ACLinkBus *bus, uint32_t slot3, uint32_t slot4)
+{
+ACLinkDevice *device = aclink_get_device(bus);
+device-info-sdataout_slot34(device, slot3, slot4);
+}
+
+void aclink_sdatain_slot12(ACLinkDevice *dev, uint32_t slot1, uint32_t slot2)
+{
+ACLinkBus *bus = FROM_QBUS(ACLinkBus, qdev_get_parent_bus(dev-qdev));
+bus-controller_info-sdatain_slot12(bus-qbus.parent, slot1, slot2);
+}
diff --git a/hw/aclink.h b/hw/aclink.h
new file mode 100644
index 000..d360d4b
--- /dev/null
+++ b/hw/aclink.h
@@ -0,0 +1,63 @@
+/*
+ * ACLink Interface
+ *
+ * Copyright (c) 2011
+ * Written by Mathieu Sonet - www.elasticsheep.com
+ *
+ * This code is licenced under the GPL.
+ *
+ * 

Re: [Qemu-devel] [PATCH] Add AACI audio playback support to the ARM Versatile/PB platform

2011-05-10 Thread malc
On Tue, 10 May 2011, Mathieu Sonet wrote:

 The PL041 driver provides an interface to an ACLink bus.
 The LM4549 driver emulates a DAC connected on the ACLink bus.
 Only audio playback is implemented.
 
 Versatile/PB test build:
 linux-2.6.38.5
 buildroot-2010.11
 alsa-lib-1.0.22
 alsa-utils-1.0.22
 mpg123-0.66
 
 Qemu host: Ubuntu 10.04 in Vmware/OS X
 
 Playback tested successfully with aplay and mpg123.
 
 Signed-off-by: Mathieu Sonet cont...@elasticsheep.com

Looks fine to me.

-- 
mailto:av1...@comtv.ru