From patchwork Mon Sep 10 08:06:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshu Agrawal X-Patchwork-Id: 10593671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E3E8921 for ; Mon, 10 Sep 2018 08:07:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77E8128CE2 for ; Mon, 10 Sep 2018 08:07:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B4B328DF1; Mon, 10 Sep 2018 08:07:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F215828CE2 for ; Mon, 10 Sep 2018 08:07:41 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 7207E2676ED; Mon, 10 Sep 2018 10:07:39 +0200 (CEST) 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 B68D92677FD; Mon, 10 Sep 2018 10:07:37 +0200 (CEST) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0084.outbound.protection.outlook.com [104.47.34.84]) by alsa0.perex.cz (Postfix) with ESMTP id D8A9C266E0E for ; Mon, 10 Sep 2018 10:07:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VpWmop25eAnOGPlR4KgSZ9hnWAYXewNbq6OF0RH1WZ8=; b=40rLNYGUVMegMmFak3q749c6/01oWdgjOsFc2xMS7geJwppepsagtVaG8u9EP9oHlHpl/OQwwdX3WzspZSKsZVInpp0cFViEXvu6oG3Pv7WZWKM2QWYNdEOMvWSsMA6WbACIcC6+AYfioq11suiMYUrRWOBYKMWd3tNmjqC2Klw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Akshu.Agrawal@amd.com; Received: from akshu-HP-EliteBook-745-G2.amd.com (165.204.156.251) by BL0PR12MB2355.namprd12.prod.outlook.com (2603:10b6:207:4c::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.15; Mon, 10 Sep 2018 08:07:24 +0000 From: Akshu Agrawal To: Date: Mon, 10 Sep 2018 13:36:29 +0530 Message-Id: <1536566815-3271-1-git-send-email-akshu.agrawal@amd.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [165.204.156.251] X-ClientProxiedBy: PN1PR0101CA0039.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::25) To BL0PR12MB2355.namprd12.prod.outlook.com (2603:10b6:207:4c::33) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 85ddcce6-b2c8-4c77-eb32-08d616f473b5 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:BL0PR12MB2355; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2355; 3:0lLNU0ous8T/JJ19PuDdbCQ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cUHuIw998n4m3d9J3y4cKiZI8ahauh7VtpJLZ/O2wKPZvLIAN+ekdsTVDkW0+qghuR4dspRTnj5o9m5VdOC42p2E5hcpu0X8qDpKf88A6FSxsFQKHuUEZ01YL9pmpvb4+MIMrCWI3xXqMRrdkqai1v15fvaqVdvufAKZcDySjCvYMoHQrcHiEZ4cAJTig+m+RJPf5kfUqwXJA0iHuRoTD9KcwvV6sJ9+1BG9l7BfsRZPKDizYwy6hQ2INqOQMcd/sS2BCWXhr4wh/gkUHJNDb/KWNDyCeGCJZXI+eVeqjaP8rQ/txAvu3Rg30MLTSkh; 4:kNsY+U5pKjg25C98btbRsBBMJwRXo6YGS9FwDP8culP7QOYPAL94R/eGJTRA7VV67rYboF8ckrhBQHnmKu832zpFnmQPXQN1q1JbSjx+qL2SyTk00xVbjIVV9lkRzD0z5R2ntvUfqxr3QCxgw/YhVrBb+ha6+8/No2pPyvhP98+fkXAEqSjYmc0qvkj8KU01TcrdQPkJYHBBwGwD4tYu7nsNaI+C2vcbPvQMD1c0/RsiaOdsWLVsXklQTVaB40LE0DEJQXbRNZJlwMmz32W0mbgLkNnboh658YFzWQrGPXdvUk+jrJgsjmnVt7aXXhGO X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201708071742011)(7699050); SRVR:BL0PR12MB2355; BCL:0; PCL:0; RULEID:; SRVR:BL0PR12MB2355; X-Forefront-PRVS: 07915F544A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(396003)(136003)(366004)(346002)(199004)(189003)(50226002)(81156014)(86362001)(81166006)(54906003)(109986005)(36756003)(476003)(105586002)(39060400002)(2616005)(26005)(51416003)(956004)(53416004)(386003)(1671002)(66066001)(53936002)(7696005)(52116002)(3846002)(6116002)(47776003)(8676002)(68736007)(6486002)(16526019)(486006)(186003)(478600001)(2906002)(48376002)(316002)(4326008)(97736004)(5660300001)(7736002)(305945005)(25786009)(16586007)(14444005)(8936002)(72206003)(44832011)(50466002)(106356001)(266003); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR12MB2355; H:akshu-HP-EliteBook-745-G2.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL0PR12MB2355; 23:PffBFd05xioe6c9riEAEGPDu3SjTyOHVMs2mIZDfA?= sw8IpPnuI8cQPPo11yioxo03aCxBN08PvzjVg3VvyBFTFuPf4J+P/iuXbKxUhp0mjWdpK9PvFKo1bib/VLcN6zbpbDZesGaS3SUdZNApvMNmfWa4VaF3RUIxcf9zEWfmNcBEkVjv/2gOAjni1kuTTtM/touHP41Ibe4Pp9Nl+psnI2NE1IPJhZ9NswMaCMeQbIE3fVzbM4U00NRvPRieGVAKA502sDAmummLIZHHaJIxz+MnnoL4kULYXI8UhVuv+/JfNNkaP6GmU+v6e+Du9HNpElILpLSLpvVr8U2qA71ONS7VKsygDnxHMFQ2snwhroVgs1grHGT4UUeW1PgvOgpS46GRH60wTh6R634gjq2fl8JO4rAYv6gXc6mxq/6+O/rnayaV6c+nX+ffSvNrfTr3tKe9wxrS1WCLuSjjWGGTgfy63inPZUYs8Ww8efU3wYfmngyDlwiRAlU9GhKRGeYtLVzIYmqFBcBqFxgknjZaHM1wOUc1l9wDNoTHCyrqsJke7fvNcLuwKiirXs1Iybc57w7hJBbrt4UovyjRXzTJUKso1LhQBuxEC6c+jHHWZ3A2Uk3Au9sNrPAqlGxRs6Ivc+/TNUpNjOySmopyS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XErbn/hGjeaFMM+yhf6BDjaSwLpjVyTaLhx8rBp+aLKK/zRrklFAspnShPK+2c/vJTjNWpRbHhtEyTrCsDT69vPBcT X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2018 08:07:24.9105 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85ddcce6-b2c8-4c77-eb32-08d616f473b5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB2355 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Kuninori Morimoto , open list , Takashi Iwai , Liam Girdwood , djkurtz@chromium.org, Mark Brown , Wei Yongjun , "Mukunda, Vijendar" , Alexander.Deucher@amd.com, akshu.agrawal@amd.com Subject: [alsa-devel] [PATCH 1/2] ASoC: AMD: Fix simultaneous playback and capture on different channel 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP If capture and playback are started on different channel (I2S/BT) there is a possibilty that channel information passed from machine driver is overwritten before the configuration is done in dma driver. Example: 113.597588: cz_max_startup: ---playback sets BT channel 113.597694: cz_dmic1_startup: ---capture sets I2S channel 113.597979: acp_dma_hw_params: ---configures capture for I2S channel 113.598114: acp_dma_hw_params: ---configures playback for I2S channel This is fixed by having lock between startup and prepare. This ensures no other codec startup gets called between a codec's startup(where channel info is set) and hw_params(where channel info is read). Signed-off-by: Akshu Agrawal --- sound/soc/amd/acp-da7219-max98357a.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c index 3879ccc..b98ffbc 100644 --- a/sound/soc/amd/acp-da7219-max98357a.c +++ b/sound/soc/amd/acp-da7219-max98357a.c @@ -47,6 +47,7 @@ static struct snd_soc_jack cz_jack; static struct clk *da7219_dai_clk; +static struct mutex instance_lock; extern int bt_uart_enable; static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) @@ -150,6 +151,7 @@ static int cz_da7219_startup(struct snd_pcm_substream *substream) snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); + mutex_lock(&instance_lock); machine->i2s_instance = I2S_SP_INSTANCE; machine->capture_channel = CAP_CHANNEL1; return da7219_clk_enable(substream); @@ -160,6 +162,12 @@ static void cz_da7219_shutdown(struct snd_pcm_substream *substream) da7219_clk_disable(); } +static int cz_da7219_prepare(struct snd_pcm_substream *substream) +{ + mutex_unlock(&instance_lock); + return 0; +} + static int cz_max_startup(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -177,6 +185,7 @@ static int cz_max_startup(struct snd_pcm_substream *substream) snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); + mutex_lock(&instance_lock); machine->i2s_instance = I2S_BT_INSTANCE; return da7219_clk_enable(substream); } @@ -186,6 +195,12 @@ static void cz_max_shutdown(struct snd_pcm_substream *substream) da7219_clk_disable(); } +static int cz_max_prepare(struct snd_pcm_substream *substream) +{ + mutex_unlock(&instance_lock); + return 0; +} + static int cz_dmic0_startup(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -203,6 +218,7 @@ static int cz_dmic0_startup(struct snd_pcm_substream *substream) snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); + mutex_lock(&instance_lock); machine->i2s_instance = I2S_BT_INSTANCE; return da7219_clk_enable(substream); } @@ -224,6 +240,7 @@ static int cz_dmic1_startup(struct snd_pcm_substream *substream) snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); + mutex_lock(&instance_lock); machine->i2s_instance = I2S_SP_INSTANCE; machine->capture_channel = CAP_CHANNEL0; return da7219_clk_enable(substream); @@ -234,24 +251,34 @@ static void cz_dmic_shutdown(struct snd_pcm_substream *substream) da7219_clk_disable(); } +static int cz_dmic_prepare(struct snd_pcm_substream *substream) +{ + mutex_unlock(&instance_lock); + return 0; +} + static const struct snd_soc_ops cz_da7219_cap_ops = { .startup = cz_da7219_startup, .shutdown = cz_da7219_shutdown, + .prepare = cz_da7219_prepare, }; static const struct snd_soc_ops cz_max_play_ops = { .startup = cz_max_startup, .shutdown = cz_max_shutdown, + .prepare = cz_max_prepare, }; static const struct snd_soc_ops cz_dmic0_cap_ops = { .startup = cz_dmic0_startup, .shutdown = cz_dmic_shutdown, + .prepare = cz_dmic_prepare, }; static const struct snd_soc_ops cz_dmic1_cap_ops = { .startup = cz_dmic1_startup, .shutdown = cz_dmic_shutdown, + .prepare = cz_dmic_prepare, }; static struct snd_soc_dai_link cz_dai_7219_98357[] = { @@ -409,6 +436,7 @@ static int cz_probe(struct platform_device *pdev) card = &cz_card; cz_card.dev = &pdev->dev; platform_set_drvdata(pdev, card); + mutex_init(&instance_lock); snd_soc_card_set_drvdata(card, machine); ret = devm_snd_soc_register_card(&pdev->dev, &cz_card); if (ret) {