From patchwork Tue Oct 4 16:07:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 117657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E79B3B6F6F for ; Wed, 5 Oct 2011 03:07:50 +1100 (EST) Received: from localhost ([::1]:47236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RB7X2-0003G1-ED for incoming@patchwork.ozlabs.org; Tue, 04 Oct 2011 12:07:48 -0400 Received: from eggs.gnu.org ([140.186.70.92]:55243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RB7Wp-0002n7-PQ for qemu-devel@nongnu.org; Tue, 04 Oct 2011 12:07:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RB7Wh-0000FX-Qr for qemu-devel@nongnu.org; Tue, 04 Oct 2011 12:07:35 -0400 Received: from mail-ww0-f53.google.com ([74.125.82.53]:34061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RB7Wh-0000FR-FH for qemu-devel@nongnu.org; Tue, 04 Oct 2011 12:07:27 -0400 Received: by wwg14 with SMTP id 14so903268wwg.10 for ; Tue, 04 Oct 2011 09:07:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=8Ll04b7rur+C3FdiRxI59jUNvOHCNRZOHjgq1LsDTYU=; b=QNYW19aHtrI/fe0/JKlRX19gUw19vtfaQ1uh/yTWJhtIzhtZf/EP2SQNNh87PYwfu7 CQNPrTbbwd3Qsz3g0racCFgwIi7AMdbW6Or0uTlMoku8K3Ew5m3i/cEixnTaRJazzNbR Bv3t6xvcMsaKC/sY2QrSwgoXWhR+G5+z03Q2c= Received: by 10.216.221.81 with SMTP id q59mr1709459wep.19.1317744446262; Tue, 04 Oct 2011 09:07:26 -0700 (PDT) Received: from localhost (154.Red-83-32-170.dynamicIP.rima-tde.net. [83.32.170.154]) by mx.google.com with ESMTPS id n21sm4742615wbp.2.2011.10.04.09.07.24 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 04 Oct 2011 09:07:25 -0700 (PDT) From: "=?UTF-8?q?Marc-Andr=C3=A9=20Lureau?=" To: qemu-devel@nongnu.org Date: Tue, 4 Oct 2011 18:07:12 +0200 Message-Id: <1317744432-1874-3-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 1.7.6.2 In-Reply-To: <1317744432-1874-1-git-send-email-marcandre.lureau@redhat.com> References: <1317744432-1874-1-git-send-email-marcandre.lureau@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.53 Cc: yhalperi@redhat.com, alevy@redhat.com, kraxel@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [Qemu-devel] [PATCH 2/2] hda: do not mix output and input stream states, RHBZ #740493 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Windows 7 may use the same stream number for input and output. Current code will confuse streams. NB: I wonder if this patch breaks migration code because of this change: - VMSTATE_BOOL_ARRAY(running, HDAAudioState, 16), + VMSTATE_BOOL_ARRAY(running, HDAAudioState, 2 * 16), --- hw/hda-audio.c | 15 +++++++++------ hw/intel-hda.c | 9 +++++---- hw/intel-hda.h | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/hw/hda-audio.c b/hw/hda-audio.c index 03c0a24..dacf290 100644 --- a/hw/hda-audio.c +++ b/hw/hda-audio.c @@ -462,7 +462,7 @@ struct HDAAudioState { QEMUSoundCard card; const desc_codec *desc; HDAAudioStream st[4]; - bool running[16]; + bool running[2 * 16]; /* properties */ uint32_t debug; @@ -659,7 +659,7 @@ static void hda_audio_command(HDACodecDevice *hda, uint32_t nid, uint32_t data) st->channel = payload & 0x0f; dprint(a, 2, "%s: stream %d, channel %d\n", st->node->name, st->stream, st->channel); - hda_audio_set_running(st, a->running[st->stream]); + hda_audio_set_running(st, a->running[st->output * 16 + st->stream]); hda_codec_response(hda, true, 0); break; case AC_VERB_GET_CONV: @@ -742,16 +742,19 @@ fail: hda_codec_response(hda, true, 0); } -static void hda_audio_stream(HDACodecDevice *hda, uint32_t stnr, bool running) +static void hda_audio_stream(HDACodecDevice *hda, uint32_t stnr, bool running, bool output) { HDAAudioState *a = DO_UPCAST(HDAAudioState, hda, hda); int s; - a->running[stnr] = running; + a->running[output * 16 + stnr] = running; for (s = 0; s < ARRAY_SIZE(a->st); s++) { if (a->st[s].node == NULL) { continue; } + if (a->st[s].output != output) { + continue; + } if (a->st[s].stream != stnr) { continue; } @@ -840,7 +843,7 @@ static int hda_audio_post_load(void *opaque, int version) hda_codec_parse_fmt(st->format, &st->as); hda_audio_setup(st); hda_audio_set_amp(st); - hda_audio_set_running(st, a->running[st->stream]); + hda_audio_set_running(st, a->running[st->output * 16 + st->stream]); } return 0; } @@ -870,7 +873,7 @@ static const VMStateDescription vmstate_hda_audio = { VMSTATE_STRUCT_ARRAY(st, HDAAudioState, 4, 0, vmstate_hda_audio_stream, HDAAudioStream), - VMSTATE_BOOL_ARRAY(running, HDAAudioState, 16), + VMSTATE_BOOL_ARRAY(running, HDAAudioState, 2 * 16), VMSTATE_END_OF_LIST() } }; diff --git a/hw/intel-hda.c b/hw/intel-hda.c index c6a3fec..f97775c 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -485,7 +485,7 @@ static void intel_hda_parse_bdl(IntelHDAState *d, IntelHDAStream *st) st->bp = 0; } -static void intel_hda_notify_codecs(IntelHDAState *d, uint32_t stream, bool running) +static void intel_hda_notify_codecs(IntelHDAState *d, uint32_t stream, bool running, bool output) { DeviceState *qdev; HDACodecDevice *cdev; @@ -493,7 +493,7 @@ static void intel_hda_notify_codecs(IntelHDAState *d, uint32_t stream, bool runn QLIST_FOREACH(qdev, &d->codecs.qbus.children, sibling) { cdev = DO_UPCAST(HDACodecDevice, qdev, qdev); if (cdev->info->stream) { - cdev->info->stream(cdev, stream, running); + cdev->info->stream(cdev, stream, running, output); } } } @@ -567,6 +567,7 @@ static void intel_hda_set_ics(IntelHDAState *d, const IntelHDAReg *reg, uint32_t static void intel_hda_set_st_ctl(IntelHDAState *d, const IntelHDAReg *reg, uint32_t old) { + bool output = reg->stream >= 4; IntelHDAStream *st = d->st + reg->stream; if (st->ctl & 0x01) { @@ -582,11 +583,11 @@ static void intel_hda_set_st_ctl(IntelHDAState *d, const IntelHDAReg *reg, uint3 dprint(d, 1, "st #%d: start %d (ring buf %d bytes)\n", reg->stream, stnr, st->cbl); intel_hda_parse_bdl(d, st); - intel_hda_notify_codecs(d, stnr, true); + intel_hda_notify_codecs(d, stnr, true, output); } else { /* stop */ dprint(d, 1, "st #%d: stop %d\n", reg->stream, stnr); - intel_hda_notify_codecs(d, stnr, false); + intel_hda_notify_codecs(d, stnr, false, output); } } intel_hda_update_irq(d); diff --git a/hw/intel-hda.h b/hw/intel-hda.h index 4e44e38..65fd2a8 100644 --- a/hw/intel-hda.h +++ b/hw/intel-hda.h @@ -34,7 +34,7 @@ struct HDACodecDeviceInfo { int (*init)(HDACodecDevice *dev); int (*exit)(HDACodecDevice *dev); void (*command)(HDACodecDevice *dev, uint32_t nid, uint32_t data); - void (*stream)(HDACodecDevice *dev, uint32_t stnr, bool running); + void (*stream)(HDACodecDevice *dev, uint32_t stnr, bool running, bool output); }; void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus,