From patchwork Mon Mar 25 06:38:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshu Agrawal X-Patchwork-Id: 10868007 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 3FD8F1390 for ; Mon, 25 Mar 2019 06:39:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 213D028F77 for ; Mon, 25 Mar 2019 06:39:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10F5F28F7D; Mon, 25 Mar 2019 06:39:36 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,MISSING_HEADERS,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C6B5A28F77 for ; Mon, 25 Mar 2019 06:39:34 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 23ED4875; Mon, 25 Mar 2019 07:38:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 23ED4875 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1553495972; bh=j6SgIIpvp8gud85D9EX6DSu64wYFvwwyKlvtVcyoHZI=; h=From:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=SrClg1nACktEIKr32cPFpp0FhLhDDagWY85JyqF4XNjw1BCml6FA7o1YF2vEcCsun booxlCw7z9G8GdJrSL/IiihoJfdi5OUgXUq/aHiM54uWWZP24q57JO2vPJZEXJmgPg o5g8BdEmdHOpvWSRgXxpU/FPCwbMNqEjqa73wA7c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 990F7F801D9; Mon, 25 Mar 2019 07:38:41 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 90537F80C15; Mon, 25 Mar 2019 07:38:37 +0100 (CET) Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-eopbgr800042.outbound.protection.outlook.com [40.107.80.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1C1EBF801D9 for ; Mon, 25 Mar 2019 07:38:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1C1EBF801D9 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="OQZIXTX1" 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=XBGy8hQD5aMuQMKN60damyAbgozKfUan923MvIdEV+o=; b=OQZIXTX1omObnwSrvqKd/poimmvdUaEJmXZsXRdOCfCaigLdmXqVgKgE/pQPR+/8wSMCx6DPUIC0AENLNJYAghGX6ek67B+nGT4VLWWTg4h5foWZRaqTWZ9FVnGaBIRW47oei6EcXxT/pg0ye0QGDTya9lkbPzCSRmslWdT6dd4= Received: from MN2PR12MB3088.namprd12.prod.outlook.com (20.178.241.29) by MN2PR12MB3630.namprd12.prod.outlook.com (20.178.243.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.15; Mon, 25 Mar 2019 06:38:28 +0000 Received: from MN2PR12MB3088.namprd12.prod.outlook.com ([fe80::bd70:eab6:121c:d160]) by MN2PR12MB3088.namprd12.prod.outlook.com ([fe80::bd70:eab6:121c:d160%4]) with mapi id 15.20.1730.019; Mon, 25 Mar 2019 06:38:28 +0000 From: "Agrawal, Akshu" Thread-Topic: [v2] ASoC: AMD: Configure wclk and bclk of master codec Thread-Index: AQHU4tVaxqRzJs0jwkWEwXDlOIqfuw== Date: Mon, 25 Mar 2019 06:38:27 +0000 Message-ID: <20190325063759.28300-1-akshu.agrawal@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MAXPR0101CA0012.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::22) To MN2PR12MB3088.namprd12.prod.outlook.com (2603:10b6:208:c4::29) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Akshu.Agrawal@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [165.204.156.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9e5e7988-19dc-42ae-4da7-08d6b0ec7ce2 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:MN2PR12MB3630; x-ms-traffictypediagnostic: MN2PR12MB3630: x-microsoft-antispam-prvs: x-forefront-prvs: 0987ACA2E2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(376002)(346002)(39860400002)(366004)(199004)(189003)(99286004)(316002)(71190400001)(71200400001)(386003)(6506007)(6436002)(1076003)(26005)(7416002)(52116002)(186003)(6486002)(6512007)(4326008)(36756003)(50226002)(97736004)(8936002)(54906003)(1671002)(5660300002)(53936002)(305945005)(7736002)(86362001)(6116002)(25786009)(68736007)(109986005)(3846002)(2616005)(476003)(106356001)(72206003)(66066001)(81166006)(81156014)(486006)(2906002)(478600001)(102836004)(105586002)(256004)(14454004)(8676002)(59246006); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR12MB3630; H:MN2PR12MB3088.namprd12.prod.outlook.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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: soM0a2fv/x2rO7ReBtRuqAD6OTeTjhUovdmkWOqZBD9pr/AVuheP1VjWXV90zx6qVkCHQhCxyQlQ4fN1E8dy5NkeOschbXTWFwFmLJ7iJNNUtdj4v1CsjuIoHdVXkJckVomN4xrIDuathWagrxngc375AVcPyA8+PPR0jMSeCiwi8Z5DRkmF4u6nNUZhd1394hOLqF5R4rx1SQ0ydTRYYSoSyRWLq4Bldu8gB2N3M3JVFC8odRRDt8ZRhbxiDF8PjDfJO5uGW2mVQSa6q7PK1tL89/3fUKjih7rIlqkh7WIr+hH5hmdm4fKOt7+MSQlZfFK3eFgEy49afgdgtS4NSuLgw4VQi7LlqFM4tcxvC0Wk5qeHORJfjWmigX6SzJol5QW8S9OYDwK9InJUKbwBXb8aDx0AII1aGqoNhdTb2r4= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e5e7988-19dc-42ae-4da7-08d6b0ec7ce2 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Mar 2019 06:38:28.1235 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3630 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Kuninori Morimoto , open list , Takashi Iwai , Liam Girdwood , "djkurtz@chromium.org" , "Agrawal, Akshu" , Mark Brown , Wei Yongjun , "Mukunda, Vijendar" , "Deucher, Alexander" , "Adam.Thomson.Opensource@diasemi.com" Subject: [alsa-devel] [v2] ASoC: AMD: Configure wclk and bclk of master codec X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" X-Virus-Scanned: ClamAV using ClamSMTP With CCF support in da7219, we can now set the correct rate of wclk and bclk. Setting bclk at lower rate at 1.53Mhz from its earlier default rate of 3Mhz, also fixes noise issue observed on some dmics. v2: Removed clk set rate and enable/disable from da7219 ops as da7219 codec takes care of them internally. Clock configuration kept for those codecs where da7219 acts as master of clock. As suggested by Adam Thomson. Signed-off-by: Akshu Agrawal --- sound/soc/amd/acp-da7219-max98357a.c | 45 +++++++++++++++++----------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c index 8e2ce369a295..7737c6dc026a 100644 --- a/sound/soc/amd/acp-da7219-max98357a.c +++ b/sound/soc/amd/acp-da7219-max98357a.c @@ -46,7 +46,8 @@ #define DUAL_CHANNEL 2 static struct snd_soc_jack cz_jack; -static struct clk *da7219_dai_clk; +static struct clk *da7219_dai_wclk; +static struct clk *da7219_dai_bclk; extern int bt_uart_enable; static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) @@ -72,7 +73,8 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) return ret; } - da7219_dai_clk = clk_get(component->dev, "da7219-dai-bclk"); + da7219_dai_wclk = clk_get(component->dev, "da7219-dai-wclk"); + da7219_dai_bclk = clk_get(component->dev, "da7219-dai-bclk"); ret = snd_soc_card_jack_new(card, "Headset Jack", SND_JACK_HEADSET | SND_JACK_LINEOUT | @@ -94,12 +96,15 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) return 0; } -static int da7219_clk_enable(struct snd_pcm_substream *substream) +static int da7219_clk_enable(struct snd_pcm_substream *substream, + int wclk_rate, int bclk_rate) { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; - ret = clk_prepare_enable(da7219_dai_clk); + clk_set_rate(da7219_dai_wclk, wclk_rate); + clk_set_rate(da7219_dai_bclk, bclk_rate); + ret = clk_prepare_enable(da7219_dai_bclk); if (ret < 0) { dev_err(rtd->dev, "can't enable master clock %d\n", ret); return ret; @@ -110,7 +115,7 @@ static int da7219_clk_enable(struct snd_pcm_substream *substream) static void da7219_clk_disable(void) { - clk_disable_unprepare(da7219_dai_clk); + clk_disable_unprepare(da7219_dai_bclk); } static const unsigned int channels[] = { @@ -151,7 +156,7 @@ static int cz_da7219_play_startup(struct snd_pcm_substream *substream) &constraints_rates); machine->play_i2s_instance = I2S_SP_INSTANCE; - return da7219_clk_enable(substream); + return 0; } static int cz_da7219_cap_startup(struct snd_pcm_substream *substream) @@ -173,12 +178,7 @@ static int cz_da7219_cap_startup(struct snd_pcm_substream *substream) machine->cap_i2s_instance = I2S_SP_INSTANCE; machine->capture_channel = CAP_CHANNEL1; - return da7219_clk_enable(substream); -} - -static void cz_da7219_shutdown(struct snd_pcm_substream *substream) -{ - da7219_clk_disable(); + return 0; } static int cz_max_startup(struct snd_pcm_substream *substream) @@ -199,7 +199,7 @@ static int cz_max_startup(struct snd_pcm_substream *substream) &constraints_rates); machine->play_i2s_instance = I2S_BT_INSTANCE; - return da7219_clk_enable(substream); + return 0; } static void cz_max_shutdown(struct snd_pcm_substream *substream) @@ -225,7 +225,7 @@ static int cz_dmic0_startup(struct snd_pcm_substream *substream) &constraints_rates); machine->cap_i2s_instance = I2S_BT_INSTANCE; - return da7219_clk_enable(substream); + return 0; } static int cz_dmic1_startup(struct snd_pcm_substream *substream) @@ -247,7 +247,7 @@ static int cz_dmic1_startup(struct snd_pcm_substream *substream) machine->cap_i2s_instance = I2S_SP_INSTANCE; machine->capture_channel = CAP_CHANNEL0; - return da7219_clk_enable(substream); + return 0; } static void cz_dmic_shutdown(struct snd_pcm_substream *substream) @@ -255,29 +255,40 @@ static void cz_dmic_shutdown(struct snd_pcm_substream *substream) da7219_clk_disable(); } +static int cz_da7219_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + int wclk, bclk; + + wclk = params_rate(params); + bclk = wclk * params_channels(params) * + snd_pcm_format_width(params_format(params)); + return da7219_clk_enable(substream, wclk, bclk); +} static const struct snd_soc_ops cz_da7219_play_ops = { .startup = cz_da7219_play_startup, - .shutdown = cz_da7219_shutdown, }; static const struct snd_soc_ops cz_da7219_cap_ops = { .startup = cz_da7219_cap_startup, - .shutdown = cz_da7219_shutdown, }; static const struct snd_soc_ops cz_max_play_ops = { .startup = cz_max_startup, .shutdown = cz_max_shutdown, + .hw_params = cz_da7219_hw_params, }; static const struct snd_soc_ops cz_dmic0_cap_ops = { .startup = cz_dmic0_startup, .shutdown = cz_dmic_shutdown, + .hw_params = cz_da7219_hw_params, }; static const struct snd_soc_ops cz_dmic1_cap_ops = { .startup = cz_dmic1_startup, .shutdown = cz_dmic_shutdown, + .hw_params = cz_da7219_hw_params, }; static struct snd_soc_dai_link cz_dai_7219_98357[] = {