From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH v2 08/13] qdev/isa: convert soundblaster
Date: Thu, 10 Sep 2009 11:43:30 +0200 [thread overview]
Message-ID: <1252575815-7824-9-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1252575815-7824-1-git-send-email-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/sb16.c | 63 +++++++++++++++++++++++++++++++++++++-----------------------
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)
--
1.6.2.5
next prev parent reply other threads:[~2009-09-10 9:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-10 9:43 [Qemu-devel] [PATCH v2 00/13] qdev isa patches Gerd Hoffmann
2009-09-10 9:43 ` [Qemu-devel] [PATCH v2 01/13] isapc: Fix irq routing Gerd Hoffmann
2009-09-10 9:43 ` [Qemu-devel] [PATCH v2 02/13] isapc: pick a more sane default cpu for such old hardware Gerd Hoffmann
2009-09-10 9:43 ` [Qemu-devel] [PATCH v2 03/13] qdev: add property type for 32bit signed integers Gerd Hoffmann
2009-09-10 9:43 ` [Qemu-devel] [PATCH v2 04/13] qdev: drop iobase properties from isa bus Gerd Hoffmann
2009-09-10 9:43 ` [Qemu-devel] [PATCH v2 05/13] qdev: simplify isa irq assignments Gerd Hoffmann
2009-09-10 9:43 ` [Qemu-devel] [PATCH v2 06/13] qdev: tag isabus-bridge as no-user Gerd Hoffmann
2009-09-10 9:43 ` [Qemu-devel] [PATCH v2 07/13] qdev: add isa_create() function Gerd Hoffmann
2009-09-10 9:43 ` Gerd Hoffmann [this message]
2009-09-10 9:43 ` [Qemu-devel] [PATCH v2 09/13] qdev/isa: convert cs4231a sound card Gerd Hoffmann
2009-09-10 9:43 ` [Qemu-devel] [PATCH v2 10/13] qdev/isa: convert gravis ultrasound Gerd Hoffmann
2009-09-10 9:43 ` [Qemu-devel] [PATCH v2 11/13] qdev/isa: convert ne2000 Gerd Hoffmann
2009-09-10 15:53 ` Markus Armbruster
2009-09-10 9:43 ` [Qemu-devel] [PATCH v2 12/13] qdev/isa: finish pckbd conversion Gerd Hoffmann
2009-09-10 9:43 ` [Qemu-devel] [PATCH v2 13/13] qdev/isa: convert real time clock Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1252575815-7824-9-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).