From patchwork Wed Feb 19 06:27:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yu Chao X-Patchwork-Id: 3678711 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 10F0CBF13A for ; Wed, 19 Feb 2014 06:27:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F188520165 for ; Wed, 19 Feb 2014 06:27:32 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D1F3B20142 for ; Wed, 19 Feb 2014 06:27:30 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 31AD626555C; Wed, 19 Feb 2014 07:27:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 3941C2652D1; Wed, 19 Feb 2014 07:27:24 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id F28FD2652DC; Wed, 19 Feb 2014 07:27:22 +0100 (CET) Received: from mail-ig0-f202.google.com (mail-ig0-f202.google.com [209.85.213.202]) by alsa0.perex.cz (Postfix) with ESMTP id 261152652C1 for ; Wed, 19 Feb 2014 07:27:15 +0100 (CET) Received: by mail-ig0-f202.google.com with SMTP id uq10so84734igb.1 for ; Tue, 18 Feb 2014 22:27:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tPHZfAuX6xvcT0gnSLJIoCrdzX9xKy8PmT1Kg6fV6xM=; b=TSxQRYPYyli6xil7V+1+1yNZLvwJkv15EQ++Usw0XUziTaUy+Ztk1OQtqsKD9nS5A5 1EhDjj4BdpGDvJSjV2xa0fqj1iK26kRBBoo7JIrqu/lrhi6TwANcakuEbAv3JG0w6dTE i8iMt4KJXx4QTmpmCoGJQXMPPWvorRMYCZbFPK6ZtmvC53l7jcv7tYLohPxikykDG8w/ rYZxfVUmvyKrTtJZvmIeZgNqpewgDaVcId+ytwJ4ApeN5023Va3Ab7HL6gifkQtOCsxK CG6Pxe1fEkcV4bemDtSXxniAdUaLan01ZA28lP+0SKA6UoA4OZ3Onj+hR2uBnhhguRch x8/Q== X-Gm-Message-State: ALoCoQnXmtHcMmr5n6Z6Rs0h/jDDa1KEeufGhCexHrcSkE1VBdla0p8qunLvS8G1eOs6auS42gh/tOAzVwhYPlB1XKYPdxYVrrq9Kw6v2triEyo8tHLsjmouzSvcI99nBWCVrX6lJ2Ng1HUUurHM9MJ4/qcNECb7O+CxvVUrhHNRa1f79dDPx6Tg8e5zaaym7zaeepDyfuAZpb4UcLmxumf19EpDBVR1tfP0V8X98Zyob6Q6lNDH0+4= X-Received: by 10.182.11.70 with SMTP id o6mr14775503obb.19.1392791234801; Tue, 18 Feb 2014 22:27:14 -0800 (PST) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id g70si3113680yha.7.2014.02.18.22.27.14 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Feb 2014 22:27:14 -0800 (PST) Received: from hychao-z620.tpe.corp.google.com (hychao-z620.tpe.corp.google.com [172.30.210.187]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 4C6C931C230; Tue, 18 Feb 2014 22:27:14 -0800 (PST) Received: by hychao-z620.tpe.corp.google.com (Postfix, from userid 97808) id 6BF8640441; Wed, 19 Feb 2014 14:27:13 +0800 (CST) From: Hsin-Yu Chao To: linux-arm-kernel@lists.infradead.org Date: Wed, 19 Feb 2014 14:27:07 +0800 Message-Id: <1392791227-16810-1-git-send-email-hychao@chromium.org> X-Mailer: git-send-email 1.9.0.rc1.175.g0b1dcb5 In-Reply-To: References: Cc: alsa-devel@alsa-project.org, Ian Minett , Takashi Iwai , Chih-Chung Chang , linux-kernel@vger.kernel.org, Hsin-Yu Chao , Dylan Reid , Xi Wang Subject: [alsa-devel] [PATCH 1/2] ALSA: hda/ca0132 - setup/cleanup streams X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP When a HDMI stream is opened with the same stream tag as a following opened stream to ca0132, audio will be heard from two ports simultaneously. Fix this issue by change to use snd_hda_codec_setup_stream and snd_hda_codec_cleanup_stream instead, so that an inactive stream can be marked as 'dirty' when found with a conflict stream tag, and then get purified. Signed-off-by: Hsin-Yu Chao Reviewed-by: Chih-Chung Chang --- sound/pci/hda/patch_ca0132.c | 66 +++++--------------------------------------- 1 file changed, 7 insertions(+), 59 deletions(-) diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 54d1479..0aa72ee 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -2662,60 +2662,6 @@ static bool dspload_wait_loaded(struct hda_codec *codec) } /* - * PCM stuffs - */ -static void ca0132_setup_stream(struct hda_codec *codec, hda_nid_t nid, - u32 stream_tag, - int channel_id, int format) -{ - unsigned int oldval, newval; - - if (!nid) - return; - - snd_printdd( - "ca0132_setup_stream: NID=0x%x, stream=0x%x, " - "channel=%d, format=0x%x\n", - nid, stream_tag, channel_id, format); - - /* update the format-id if changed */ - oldval = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_STREAM_FORMAT, - 0); - if (oldval != format) { - msleep(20); - snd_hda_codec_write(codec, nid, 0, - AC_VERB_SET_STREAM_FORMAT, - format); - } - - oldval = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0); - newval = (stream_tag << 4) | channel_id; - if (oldval != newval) { - snd_hda_codec_write(codec, nid, 0, - AC_VERB_SET_CHANNEL_STREAMID, - newval); - } -} - -static void ca0132_cleanup_stream(struct hda_codec *codec, hda_nid_t nid) -{ - unsigned int val; - - if (!nid) - return; - - snd_printdd(KERN_INFO "ca0132_cleanup_stream: NID=0x%x\n", nid); - - val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0); - if (!val) - return; - - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0); - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 0); -} - -/* * PCM callbacks */ static int ca0132_playback_pcm_prepare(struct hda_pcm_stream *hinfo, @@ -2726,7 +2672,7 @@ static int ca0132_playback_pcm_prepare(struct hda_pcm_stream *hinfo, { struct ca0132_spec *spec = codec->spec; - ca0132_setup_stream(codec, spec->dacs[0], stream_tag, 0, format); + snd_hda_codec_setup_stream(codec, spec->dacs[0], stream_tag, 0, format); return 0; } @@ -2745,7 +2691,7 @@ static int ca0132_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, if (spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID]) msleep(50); - ca0132_cleanup_stream(codec, spec->dacs[0]); + snd_hda_codec_cleanup_stream(codec, spec->dacs[0]); return 0; } @@ -2824,8 +2770,8 @@ static int ca0132_capture_pcm_prepare(struct hda_pcm_stream *hinfo, { struct ca0132_spec *spec = codec->spec; - ca0132_setup_stream(codec, spec->adcs[substream->number], - stream_tag, 0, format); + snd_hda_codec_setup_stream(codec, spec->adcs[substream->number], + stream_tag, 0, format); return 0; } @@ -2839,7 +2785,7 @@ static int ca0132_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, if (spec->dsp_state == DSP_DOWNLOADING) return 0; - ca0132_cleanup_stream(codec, hinfo->nid); + snd_hda_codec_cleanup_stream(codec, hinfo->nid); return 0; } @@ -4742,6 +4688,8 @@ static int patch_ca0132(struct hda_codec *codec) return err; codec->patch_ops = ca0132_patch_ops; + codec->pcm_format_first = 1; + codec->no_sticky_stream = 1; return 0; }