qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH v2 09/13] qdev/isa: convert cs4231a sound card
Date: Thu, 10 Sep 2009 11:43:31 +0200	[thread overview]
Message-ID: <1252575815-7824-10-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/cs4231a.c |   46 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 33 insertions(+), 13 deletions(-)

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)
-- 
1.6.2.5

  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 ` [Qemu-devel] [PATCH v2 08/13] qdev/isa: convert soundblaster Gerd Hoffmann
2009-09-10  9:43 ` Gerd Hoffmann [this message]
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-10-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).