Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1182152yba; Thu, 9 May 2019 12:07:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7JcKJ5lIIOJeed5cKvI0+hKfC79jKlCZKWsNi3OIzYyAv+dRqzm13EwLIFwOrBToaqFr4 X-Received: by 2002:a17:902:382:: with SMTP id d2mr7503640pld.253.1557428820639; Thu, 09 May 2019 12:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557428820; cv=none; d=google.com; s=arc-20160816; b=PpBNurdc8Ea6MJVRctA10rXp6fkOVg5E84IBicikeNmgJUR9ur6TgdSQUI7NqK50zR woIyu9q8ee3BrTgSsCFAOF2c+BwX6B6V4Zs/nTZ2Xmi4PdPPjN2tYJSfwQ/dakmH0IGk go1+4r/eA8n/lGATyrrdCLCxUFMO+zaFBWhCPdkMCX7V6YbTFFLjHKfoigD+gKzUndiA tgLyRxeEdxNsG770m/6njqhz1RJ3bLCOi2bs5z946pnTyYZMP2CGXRq4fpVzqIREXvHg JsZ1jaKeIDLbT4TYxv7mIiDAeecDkgPOQuLWmx7MiannTP4UoQT5MHbsjMujII3sUOj9 no8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9gF07Y/afvv7yqc+LCQg5mevZ5Qj6hifbE/rsBLz6ww=; b=q60YkqwZWFBLFgXIJ5Ah2BEHT82z29v5DE3J1aeXmpPoOv1agaCQg5HBvNT9zn5AVw AWC4sTDE4yjNxbYBSUGhzVz9w4APbOIumvN0hmM+8It6F4yI8dEui1ck6rIGjT/+Uv6O KvBCKc8Mng93gqhAn0qjAbeeTkfCqEAoT0ZaTDtjinC9z46GRbyJ7JuFleB80mjKDZVZ cHVm/WRYb/K6vqUEsx+Rl9ER6Lfs1nOWz/ShWXPzIoG3nB8Mj6yXS9ms5h5CcMV9lvfy /DsshQvznRdhfUnn9msslxgRsFjNbsEPElHtFCkISrAjRKkQmQ+C6LRux4rTGM2ZRKWD 2AZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BawazgV1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w21si4194269plq.328.2019.05.09.12.06.43; Thu, 09 May 2019 12:07:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BawazgV1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727721AbfEITEj (ORCPT + 99 others); Thu, 9 May 2019 15:04:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:41304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728014AbfEISsY (ORCPT ); Thu, 9 May 2019 14:48:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3408D217F9; Thu, 9 May 2019 18:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557427703; bh=inT9FER4sSnpeDgeUcIZ2sHTDbPIDTss4puXlMKfU9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BawazgV1jQw9KBE+JTxXCk0w+RmRcw8nFHs5G/de78vFQtqJxIUNaPggYVohsXfU+ a/JG6M65J+e0ngTRPaz13KLXMWNM34lF0abDeDQL/zFzGtw11aLrER4/VZMBz4pjLR 5rWEny0xMLiIBTfG47kuJDL8vgok7DkJ8PEyw7CA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rander Wang , Pierre-Louis Bossart , Mark Brown , Sasha Levin Subject: [PATCH 4.19 11/66] ASoC:soc-pcm:fix a codec fixup issue in TDM case Date: Thu, 9 May 2019 20:41:46 +0200 Message-Id: <20190509181303.095144130@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190509181301.719249738@linuxfoundation.org> References: <20190509181301.719249738@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 570f18b6a8d1f0e60e8caf30e66161b6438dcc91 ] On HDaudio platforms, if playback is started when capture is working, there is no audible output. This can be root-caused to the use of the rx|tx_mask to store an HDaudio stream tag. If capture is stared before playback, rx_mask would be non-zero on HDaudio platform, then the channel number of playback, which is in the same codec dai with the capture, would be changed by soc_pcm_codec_params_fixup based on the tx_mask at first, then overwritten by this function based on rx_mask at last. According to the author of tx|rx_mask, tx_mask is for playback and rx_mask is for capture. And stream direction is checked at all other references of tx|rx_mask in ASoC, so here should be an error. This patch checks stream direction for tx|rx_mask for fixup function. This issue would affect not only HDaudio+ASoC, but also I2S codecs if the channel number based on rx_mask is not equal to the one for tx_mask. It could be rarely reproduecd because most drivers in kernel set the same channel number to tx|rx_mask or rx_mask is zero. Tested on all platforms using stream_tag & HDaudio and intel I2S platforms. Signed-off-by: Rander Wang Acked-by: Pierre-Louis Bossart Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/soc-pcm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index e8b98bfd4cf13..33060af18b5a4 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -957,10 +957,13 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, codec_params = *params; /* fixup params based on TDM slot masks */ - if (codec_dai->tx_mask) + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && + codec_dai->tx_mask) soc_pcm_codec_params_fixup(&codec_params, codec_dai->tx_mask); - if (codec_dai->rx_mask) + + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && + codec_dai->rx_mask) soc_pcm_codec_params_fixup(&codec_params, codec_dai->rx_mask); -- 2.20.1