From: Gerd Hoffmann Date: Thu, 10 Sep 2009 09:43:31 +0000 (+0200) Subject: qdev/isa: convert cs4231a sound card X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~10649 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8ba78465749956ee6fc49e7722ae85d173f7252;p=sdk%2Femulator%2Fqemu.git qdev/isa: convert cs4231a sound card Signed-off-by: Gerd Hoffmann --- diff --git a/hw/cs4231a.c b/hw/cs4231a.c index 46c71eb..91ee2aa 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)