From patchwork Wed Oct 28 12:29:26 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 37098 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 ozlabs.org (Postfix) with ESMTPS id AFBD8B7BEE for ; Wed, 28 Oct 2009 23:42:14 +1100 (EST) Received: from localhost ([127.0.0.1]:53772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N37qt-0000PM-Ak for incoming@patchwork.ozlabs.org; Wed, 28 Oct 2009 08:42:11 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N37f7-0004HS-5u for qemu-devel@nongnu.org; Wed, 28 Oct 2009 08:30:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N37f1-0004CO-3F for qemu-devel@nongnu.org; Wed, 28 Oct 2009 08:29:59 -0400 Received: from [199.232.76.173] (port=45175 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N37ez-0004Bg-UL for qemu-devel@nongnu.org; Wed, 28 Oct 2009 08:29:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18699) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N37ez-0004tK-3P for qemu-devel@nongnu.org; Wed, 28 Oct 2009 08:29:53 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9SCTh4f015085; Wed, 28 Oct 2009 08:29:43 -0400 Received: from localhost.localdomain (vpn1-5-215.ams2.redhat.com [10.36.5.215]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9SCTYGV005218; Wed, 28 Oct 2009 08:29:42 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Oct 2009 13:29:26 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH 05/10] c4231a: port to vmstate 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: Juan Quintela --- hw/cs4231a.c | 58 ++++++++++++++++++++++++++++++---------------------------- 1 files changed, 30 insertions(+), 28 deletions(-) diff --git a/hw/cs4231a.c b/hw/cs4231a.c index e03c5d2..7c29aa8 100644 --- a/hw/cs4231a.c +++ b/hw/cs4231a.c @@ -596,45 +596,47 @@ static int cs_dma_read (void *opaque, int nchan, int dma_pos, int dma_len) return dma_pos; } -static void cs_save (QEMUFile *f, void *opaque) +static int cs4231a_pre_load (void *opaque) { CSState *s = opaque; - unsigned int i; - uint32_t val; - for (i = 0; i < CS_REGS; i++) - qemu_put_be32s (f, &s->regs[i]); - - qemu_put_buffer (f, s->dregs, CS_DREGS); - val = s->dma_running; qemu_put_be32s (f, &val); - val = s->audio_free; qemu_put_be32s (f, &val); - val = s->transferred; qemu_put_be32s (f, &val); - val = s->aci_counter; qemu_put_be32s (f, &val); + if (s->dma_running) { + DMA_release_DREQ (s->dma); + AUD_set_active_out (s->voice, 0); + } + s->dma_running = 0; + return 0; } -static int cs_load (QEMUFile *f, void *opaque, int version_id) +static int cs4231a_post_load (void *opaque, int version_id) { CSState *s = opaque; - unsigned int i; - uint32_t val, dma_running; - - if (version_id > 1) - return -EINVAL; - for (i = 0; i < CS_REGS; i++) - qemu_get_be32s (f, &s->regs[i]); - - qemu_get_buffer (f, s->dregs, CS_DREGS); - - qemu_get_be32s (f, &dma_running); - qemu_get_be32s (f, &val); s->audio_free = val; - qemu_get_be32s (f, &val); s->transferred = val; - qemu_get_be32s (f, &val); s->aci_counter = val; - if (dma_running && (s->dregs[Interface_Configuration] & PEN)) + if (s->dma_running && (s->dregs[Interface_Configuration] & PEN)) { + s->dma_running = 0; cs_reset_voices (s, s->dregs[FS_And_Playback_Data_Format]); + } return 0; } +static const VMStateDescription vmstate_cs4231a = { + .name = "cs4231a", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .pre_load = cs4231a_pre_load, + .post_load = cs4231a_post_load, + .fields = (VMStateField []) { + VMSTATE_UINT32_ARRAY(regs, CSState, CS_REGS), + VMSTATE_BUFFER(dregs, CSState), + VMSTATE_INT32(dma_running, CSState), + VMSTATE_INT32(audio_free, CSState), + VMSTATE_INT32(transferred, CSState), + VMSTATE_INT32(aci_counter, CSState), + VMSTATE_END_OF_LIST() + } +}; + static int cs4231a_initfn (ISADevice *dev) { CSState *s = DO_UPCAST (CSState, dev, dev); @@ -649,7 +651,7 @@ static int cs4231a_initfn (ISADevice *dev) DMA_register_channel (s->dma, cs_dma_read, s); - register_savevm ("cs4231a", 0, 1, cs_save, cs_load, s); + vmstate_register (0, &vmstate_cs4231a, s); qemu_register_reset (cs_reset, s); cs_reset (s);