From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 720F3C04E84 for ; Wed, 15 May 2019 12:20:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3ADA920578 for ; Wed, 15 May 2019 12:20:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557922814; bh=U6Bp83rZEA3A0LWqKlMu1ABFw8HuaGPcepcGWNLBXRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=hCJxfXKXB7By9cPst7FXGyUBLAK1oyRiuMuxnUlGEbx5SzZ0nN+KUpI9q8jZVbsyx /javV1BF6C16In75kG5fiKGiQOGQdDri5aSUm+n2baZPhw6+FNK1mgDPidIE3FIfn3 UWESDZxOYI89uhZcPv3mjlP0/DIzfQjPh8VGTq3A= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727299AbfEOK75 (ORCPT ); Wed, 15 May 2019 06:59:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:56624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727294AbfEOK74 (ORCPT ); Wed, 15 May 2019 06:59:56 -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 C15AF2084E; Wed, 15 May 2019 10:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557917996; bh=U6Bp83rZEA3A0LWqKlMu1ABFw8HuaGPcepcGWNLBXRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mAV2nCsYM+FIPoPiH90QlOQdAveT1jfcSSpMFTbJghwj8CPZ6XNR2AZGvYt4KAEyi VsCAAoNdNyZ8S1CfO1WDyVTb+BcKYqwL6q0xN2RFBv1kZtdQhURUSImBpBwsfrb4ki LUOJv4TZsptOJ2I5ET4iz+JKBQmZW8gzTLeQL/Fc= 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 3.18 53/86] ASoC:soc-pcm:fix a codec fixup issue in TDM case Date: Wed, 15 May 2019 12:55:30 +0200 Message-Id: <20190515090652.846957745@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090642.339346723@linuxfoundation.org> References: <20190515090642.339346723@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 e2fb859fbbaa1..4323002c67db2 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -847,10 +847,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