diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2009-09-10 11:43:31 +0200 |
---|---|---|
committer | malc <av1474@comtv.ru> | 2009-09-10 19:48:00 +0400 |
commit | f8ba78465749956ee6fc49e7722ae85d173f7252 (patch) | |
tree | a108fe1cc500146899dc461ed68c5f9b1293f34d /hw | |
parent | f7b4f61f63fdc108250dc8573b723430293a19da (diff) |
qdev/isa: convert cs4231a sound card
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/cs4231a.c | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/hw/cs4231a.c b/hw/cs4231a.c index 46c71eb083..91ee2aa2ce 100644 --- a/hw/cs4231a.c +++ b/hw/cs4231a.c @@ -25,6 +25,7 @@ #include "audiodev.h" #include "audio/audio.h" #include "isa.h" +#include "qdev.h" #include "qemu-timer.h" /* @@ -40,11 +41,8 @@ /* #define DEBUG_XLAW */ static struct { - int irq; - int dma; - int port; int aci_counter; -} conf = {9, 3, 0x534, 1}; +} conf = {1}; #ifdef DEBUG #define dolog(...) AUD_log ("cs4231a", __VA_ARGS__) @@ -59,12 +57,14 @@ static struct { #define CS_DREGS 32 typedef struct CSState { + ISADevice dev; QEMUSoundCard card; qemu_irq pic; uint32_t regs[CS_REGS]; uint8_t dregs[CS_DREGS]; - int dma; - int port; + uint32_t irq; + uint32_t dma; + uint32_t port; int shift; int dma_running; int audio_free; @@ -635,16 +635,12 @@ static int cs_load (QEMUFile *f, void *opaque, int version_id) return 0; } -int cs4231a_init (qemu_irq *pic) +static int cs4231a_initfn (ISADevice *dev) { + CSState *s = DO_UPCAST (CSState, dev, dev); int i; - CSState *s; - - s = qemu_mallocz (sizeof (*s)); - s->pic = isa_reserve_irq (conf.irq); - s->dma = conf.dma; - s->port = conf.port; + isa_init_irq (dev, &s->pic, s->irq); for (i = 0; i < 4; i++) { register_ioport_write (s->port + i, 1, 1, cs_write, s); @@ -660,3 +656,27 @@ int cs4231a_init (qemu_irq *pic) AUD_register_card ("cs4231a", &s->card); return 0; } + +int cs4231a_init (qemu_irq *pic) +{ + isa_create_simple("cs4231a"); + return 0; +} + +static ISADeviceInfo cs4231a_info = { + .qdev.name = "cs4231a", + .qdev.size = sizeof (CSState), + .init = cs4231a_initfn, + .qdev.props = (Property[]) { + DEFINE_PROP_HEX32 ("iobase", CSState, port, 0x534), + DEFINE_PROP_UINT32 ("irq", CSState, irq, 9), + DEFINE_PROP_UINT32 ("dma", CSState, dma, 3), + DEFINE_PROP_END_OF_LIST (), + }, +}; + +static void cs4231a_register(void) +{ + isa_qdev_register(&cs4231a_info); +} +device_init(cs4231a_register) |