From patchwork Thu Sep 10 09:43:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 33303 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 400C0B6F34 for ; Thu, 10 Sep 2009 20:44:31 +1000 (EST) Received: from localhost ([127.0.0.1]:45365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mlh8d-00077S-VH for incoming@patchwork.ozlabs.org; Thu, 10 Sep 2009 06:44:28 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlgC0-0008Vt-MD for qemu-devel@nongnu.org; Thu, 10 Sep 2009 05:43:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlgBu-0008SV-3c for qemu-devel@nongnu.org; Thu, 10 Sep 2009 05:43:50 -0400 Received: from [199.232.76.173] (port=39544 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlgBt-0008SS-W0 for qemu-devel@nongnu.org; Thu, 10 Sep 2009 05:43:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59717) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlgBt-0005Vj-J7 for qemu-devel@nongnu.org; Thu, 10 Sep 2009 05:43:45 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8A9hire032744 for ; Thu, 10 Sep 2009 05:43:44 -0400 Received: from zweiblum.home.kraxel.org (vpn2-9-74.ams2.redhat.com [10.36.9.74]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n8A9hf7V030525; Thu, 10 Sep 2009 05:43:42 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id D8E82700E8; Thu, 10 Sep 2009 11:43:35 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2009 11:43:31 +0200 Message-Id: <1252575815-7824-10-git-send-email-kraxel@redhat.com> In-Reply-To: <1252575815-7824-1-git-send-email-kraxel@redhat.com> References: <1252575815-7824-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH v2 09/13] qdev/isa: convert cs4231a sound card X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Gerd Hoffmann --- 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)