From patchwork Wed Sep 9 14:45:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 33188 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 B2095B7BDF for ; Thu, 10 Sep 2009 01:05:13 +1000 (EST) Received: from localhost ([127.0.0.1]:32787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlOjL-0008N0-1c for incoming@patchwork.ozlabs.org; Wed, 09 Sep 2009 11:05:07 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlOQv-00032R-SI for qemu-devel@nongnu.org; Wed, 09 Sep 2009 10:46:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlOQo-0002y5-Hj for qemu-devel@nongnu.org; Wed, 09 Sep 2009 10:46:02 -0400 Received: from [199.232.76.173] (port=59674 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlOQn-0002xl-V0 for qemu-devel@nongnu.org; Wed, 09 Sep 2009 10:45:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13568) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlOQn-0004fr-EI for qemu-devel@nongnu.org; Wed, 09 Sep 2009 10:45:57 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n89EjuC5029832 for ; Wed, 9 Sep 2009 10:45:56 -0400 Received: from zweiblum.home.kraxel.org (vpn2-9-67.ams2.redhat.com [10.36.9.67]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n89EjrbB016995; Wed, 9 Sep 2009 10:45:54 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 9313B700E6; Wed, 9 Sep 2009 16:45:48 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 9 Sep 2009 16:45:42 +0200 Message-Id: <1252507547-11398-8-git-send-email-kraxel@redhat.com> In-Reply-To: <1252507547-11398-1-git-send-email-kraxel@redhat.com> References: <1252507547-11398-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 07/12] qdev/isa: convert soundblaster 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/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)