aboutsummaryrefslogtreecommitdiff
path: root/hw/sb16.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-09-10 11:43:30 +0200
committermalc <av1474@comtv.ru>2009-09-10 19:48:00 +0400
commitf7b4f61f63fdc108250dc8573b723430293a19da (patch)
treea8637d00d99f146aed29759ca7289516d908c8b0 /hw/sb16.c
parent924f6d72d3787e56961498f8c97d13bf87c84a36 (diff)
downloadqemu-f7b4f61f63fdc108250dc8573b723430293a19da.zip
qemu-f7b4f61f63fdc108250dc8573b723430293a19da.tar.gz
qemu-f7b4f61f63fdc108250dc8573b723430293a19da.tar.bz2
qdev/isa: convert soundblaster
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/sb16.c')
-rw-r--r--hw/sb16.c63
1 files changed, 39 insertions, 24 deletions
diff --git a/hw/sb16.c b/hw/sb16.c
index ac41a13..4105579 100644
--- a/hw/sb16.c
+++ b/hw/sb16.c
@@ -25,6 +25,7 @@
#include "audiodev.h"
#include "audio/audio.h"
#include "isa.h"
+#include "qdev.h"
#include "qemu-timer.h"
#define dolog(...) AUD_log ("sb16", __VA_ARGS__)
@@ -45,23 +46,15 @@
static const char e3[] = "COPYRIGHT (C) CREATIVE TECHNOLOGY LTD, 1992.";
-static struct {
- int ver_lo;
- int ver_hi;
- int irq;
- int dma;
- int hdma;
- int port;
-} conf = {5, 4, 5, 1, 5, 0x220};
-
typedef struct SB16State {
+ ISADevice dev;
QEMUSoundCard card;
qemu_irq pic;
- int irq;
- int dma;
- int hdma;
- int port;
- int ver;
+ uint32_t irq;
+ uint32_t dma;
+ uint32_t hdma;
+ uint32_t port;
+ uint32_t ver;
int in_index;
int out_data_len;
@@ -1398,22 +1391,17 @@ static int SB_load (QEMUFile *f, void *opaque, int version_id)
return 0;
}
-int SB16_init (qemu_irq *pic)
+static int sb16_initfn (ISADevice *dev)
{
- SB16State *s;
- int i;
static const uint8_t dsp_write_ports[] = {0x6, 0xc};
static const uint8_t dsp_read_ports[] = {0x6, 0xa, 0xc, 0xd, 0xe, 0xf};
+ SB16State *s;
+ int i;
- s = qemu_mallocz (sizeof (*s));
+ s = DO_UPCAST (SB16State, dev, dev);
s->cmd = -1;
- s->pic = isa_reserve_irq (conf.irq);
- s->irq = conf.irq;
- s->dma = conf.dma;
- s->hdma = conf.hdma;
- s->port = conf.port;
- s->ver = conf.ver_lo | (conf.ver_hi << 8);
+ isa_init_irq (dev, &s->pic, s->irq);
s->mixer_regs[0x80] = magic_of_irq (s->irq);
s->mixer_regs[0x81] = (1 << s->dma) | (1 << s->hdma);
@@ -1449,3 +1437,30 @@ int SB16_init (qemu_irq *pic)
AUD_register_card ("sb16", &s->card);
return 0;
}
+
+int SB16_init (qemu_irq *pic)
+{
+ isa_create_simple("sb16");
+ return 0;
+}
+
+static ISADeviceInfo sb16_info = {
+ .qdev.name = "sb16",
+ .qdev.desc = "Creative Sound Blaster 16",
+ .qdev.size = sizeof (SB16State),
+ .init = sb16_initfn,
+ .qdev.props = (Property[]) {
+ DEFINE_PROP_HEX32 ("version", SB16State, ver, 0x0405), /* 4.5 */
+ DEFINE_PROP_HEX32 ("iobase", SB16State, port, 0x220),
+ DEFINE_PROP_UINT32 ("irq", SB16State, irq, 5),
+ DEFINE_PROP_UINT32 ("dma", SB16State, dma, 1),
+ DEFINE_PROP_UINT32 ("dma16", SB16State, hdma, 5),
+ DEFINE_PROP_END_OF_LIST (),
+ },
+};
+
+static void sb16_register(void)
+{
+ isa_qdev_register(&sb16_info);
+}
+device_init(sb16_register)