From patchwork Fri Mar 22 09:06:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshu Agrawal X-Patchwork-Id: 10865291 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 F37FD6C2 for ; Fri, 22 Mar 2019 09:07:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9C342A618 for ; Fri, 22 Mar 2019 09:07:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B98E62A61A; Fri, 22 Mar 2019 09:07:12 +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 D471F2A618 for ; Fri, 22 Mar 2019 09:07:11 +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 C3B141607; Fri, 22 Mar 2019 10:06:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C3B141607 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1553245629; bh=/089k68cvGf+OllLyL/zKoGMvDPeaa4ZtxHnjZGL06o=; h=From:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=AACvyT5KmTTiSwr7SxyKbGIJz2rbZcnIGxUVNWgAgXywFa6CZNtvdR07FWqsg8m0t IJvqNk1UKh8Gc1JHs6ZfZYA6HX+NecOZWNv5E0QP0nY636x5GP0aJNVv/AnyVUWsRq Mcxu/cr6by19N6xFhReh5+DfCM4evF6yqIJIHmW8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5BCECF89670; Fri, 22 Mar 2019 10:06:19 +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 A0F26F89682; Fri, 22 Mar 2019 10:06:17 +0100 (CET) Received: from NAM04-CO1-obe.outbound.protection.outlook.com (mail-eopbgr690083.outbound.protection.outlook.com [40.107.69.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5123DF89674 for ; Fri, 22 Mar 2019 10:06:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5123DF89674 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="U3UdrBYo" 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=gVvIwTP9WSlwvwdRfp/RhQ0o+naAtdzeHNpxFRHIB8I=; b=U3UdrBYo6kNrjs0qyQSxkfGQAvEdV4ZMtANBshG0ZS7TD7JqWzZvC5JUhrrJYVI3NdjrY7tvHBK6rwtO+8h+sRtkD+FYPA52OrLPHQrc/OwpVcD/ArqEe8G4F6cCFQDLz9WU6bCO7u/QzAyc+bybJ5SXSpzLgrFs0nKnfHZ+fFI= Received: from MN2PR12MB3088.namprd12.prod.outlook.com (20.178.241.29) by MN2PR12MB3485.namprd12.prod.outlook.com (20.178.242.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.15; Fri, 22 Mar 2019 09:06:10 +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.1709.015; Fri, 22 Mar 2019 09:06:10 +0000 From: "Agrawal, Akshu" Thread-Topic: [PATCH] ASoC: AMD: Configure wclk and bclk of master codec Thread-Index: AQHU4I59NbQ9pdWrkUeMNi8gY2B36w== Date: Fri, 22 Mar 2019 09:06:10 +0000 Message-ID: <20190322090532.30448-1-akshu.agrawal@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR0101CA0044.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::30) 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: 1d8c0cd4-ba5c-48aa-3f24-08d6aea5a01a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MN2PR12MB3485; x-ms-traffictypediagnostic: MN2PR12MB3485: x-microsoft-antispam-prvs: x-forefront-prvs: 09840A4839 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(366004)(396003)(376002)(136003)(199004)(189003)(486006)(6436002)(186003)(6116002)(81166006)(8676002)(6512007)(2616005)(71190400001)(71200400001)(476003)(478600001)(53936002)(72206003)(2906002)(14454004)(7416002)(256004)(7736002)(5660300002)(25786009)(8936002)(4326008)(106356001)(66066001)(59246006)(26005)(3846002)(6486002)(305945005)(68736007)(54906003)(97736004)(86362001)(109986005)(81156014)(102836004)(1076003)(50226002)(99286004)(386003)(36756003)(52116002)(1671002)(6506007)(316002)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR12MB3485; 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: A+pQBlrsyvRUyxsdsM2Mu+Buq0Bu4BR+J73R2Hp/qTBdZaKQlBfCctAt4gEEY4ZY21Lv3cjaIv+G1H3PQqX75WlmRyMHCqdmQuNIs8x4zjNihBPAcRWlHPli0YwBPPyOY/A19xGovcagv3ICOKDTwLMUXuOkmd2DSAw+TMaFeb29oaKINMnMZi7n8KJU+WgX3k8BJRP4Y9SV/MVNrkx96sIZYkzOkT4irVY4Gf6jP7pN7Tx/qGlmH62kkl9zLJowIzE/XO7XZgpioRETeDG0LepiwzCjRt/JGNd4PFRriklpH16DPonLr6WpakfTj/l8qr7JLoQ4xLddPbufFfR06yjXfcUJdPTySB9lSiywJXelKhBuDbtHIesqu8GzVI0TZTKbCZFB3ki/4LIpZzCHTv3QYzmgOj/qpnrBi7gx2RY= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d8c0cd4-ba5c-48aa-3f24-08d6aea5a01a X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Mar 2019 09:06:10.4119 (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: MN2PR12MB3485 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list , Takashi Iwai , Liam Girdwood , "djkurtz@chromium.org" , "Agrawal, Akshu" , Julia Lawall , Mark Brown , Wei Yongjun , "Mukunda, Vijendar" , "Deucher, Alexander" , "Adam.Thomson.Opensource@diasemi.com" Subject: [alsa-devel] [PATCH] 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. Signed-off-by: Akshu Agrawal --- sound/soc/amd/acp-da7219-max98357a.c | 40 +++++++++++++++++++++------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c index f37a588ba345..1bb5b78b6e10 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,7 +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); + return 0; } static void cz_da7219_shutdown(struct snd_pcm_substream *substream) @@ -199,7 +204,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 +230,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 +252,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 +260,44 @@ 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, + .hw_params = cz_da7219_hw_params, }; static const struct snd_soc_ops cz_da7219_cap_ops = { .startup = cz_da7219_cap_startup, .shutdown = cz_da7219_shutdown, + .hw_params = cz_da7219_hw_params, }; 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[] = {