From patchwork Tue Mar 27 21:00:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Marinushkin X-Patchwork-Id: 10311651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2761B60386 for ; Tue, 27 Mar 2018 21:00:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BAD229C58 for ; Tue, 27 Mar 2018 21:00:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A22D29C7B; Tue, 27 Mar 2018 21:00:43 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no 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 D384F29D34 for ; Tue, 27 Mar 2018 21:00:33 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 4B344267219; Tue, 27 Mar 2018 23:00:32 +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 7C769267212; Tue, 27 Mar 2018 23:00:29 +0200 (CEST) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by alsa0.perex.cz (Postfix) with ESMTP id 4246F267211 for ; Tue, 27 Mar 2018 23:00:27 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id b127so336826wmf.5 for ; Tue, 27 Mar 2018 14:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cKFV8U95JPzsEZaJG91ZIdQD/scdCSuRwOKM9bTtHUw=; b=p0Pv+H1Y3M7A91cNCS8s1W3Sv69m0kiWZXj3PO1wf8/98MQWJk0xJFi57Cj4LagCFg b1hPXyiUpTDXHsgWutsGCWB1l8iYamtNWzF7jR7rGsHjwostecL+UQVjD5CCr3F/6vRJ IiCgFRiuyeELk5TJQBBIkjatt9wfOcpcxO4iX00I3ShDpRjyFIHsnU3ZEWzcr/xU7W3e YBlLOffUp7784Rq/WQFY0W0wODHKEb1Svo+thXgxgLMlq58ASZvNqTgD4ZKPx9s1VKGU kNhKpFX66HAnDAdAPUQxFi9cffD/aBfvEyPZNu6/WgU+srDvYjwdQpfC9n87z2H97gco qAtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cKFV8U95JPzsEZaJG91ZIdQD/scdCSuRwOKM9bTtHUw=; b=pUeNpKYPGKNflog5ESR76qE0m9e5kG4BPI+GxRQmq6hyAtPYM51fzPJPMGEPI94hq2 LGlPdEqD9wG6pt6yJIzB0s3jP0Ln95RbnS89Ksyoe+4NDpXAqeBAKQUcwwQKrAtwQOtr 6yjKJbNaJR0ZC0fkEC22upekvDcEuGgiPQJg3WDNqc6ULEN0wsXXrBGNevuZFS8mhPNc owo7gxRfKUe21RGYGrzG8YhEwZl70jj3fXQ/BucBnrJ90RokbktQqBc8DbNFV1DZwFmp y3ENxUBYwdX5lojjP52o3LCgZmLlZ0w4Je6dRXolQTIwAQupDG/pg21qFbIvY7Cq7Jtp moDg== X-Gm-Message-State: AElRT7FL0Wr4wGL3p8XgDOleidYkWG1rclH4qKz27kA5O3zy+TJsm3/7 Rh0VzfE1pLLYpXYWbfZ+GZk= X-Google-Smtp-Source: AIpwx48CDdBHrBMupLs92v5W0cWVbppoDseYagZNdVXK6tXAFgNV+/+7sKDWpuT2d8RXfwpO8pEERw== X-Received: by 10.80.153.206 with SMTP id n14mr706404edb.303.1522184426683; Tue, 27 Mar 2018 14:00:26 -0700 (PDT) Received: from gentoo0.localdomain (x4dbab50a.dyn.telefonica.de. [77.186.181.10]) by smtp.gmail.com with ESMTPSA id q29sm1313896edd.25.2018.03.27.14.00.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 14:00:26 -0700 (PDT) From: Kirill Marinushkin To: Jaroslav Kysela , Takashi Iwai , Mark Brown Date: Tue, 27 Mar 2018 23:00:49 +0200 Message-Id: <20180327210050.3728-2-k.marinushkin@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180327210050.3728-1-k.marinushkin@gmail.com> References: <20180327205632.3677-1-k.marinushkin@gmail.com> <20180327210050.3728-1-k.marinushkin@gmail.com> Cc: alsa-devel@alsa-project.org, Pan Xiuli , Pierre-Louis Bossart , linux-kernel@vger.kernel.org, Liam Girdwood , Kirill Marinushkin Subject: [alsa-devel] [PATCH, alsa-lib, v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The values of bclk and fsync are inverted WRT the codec. But the existing solution already works for Broadwell, see the alsa-lib config: `alsa-lib/src/conf/topology/broadwell/broadwell.conf` This commit provides the backwards-compatible solution to fix this misuse. This commit goes in pair with the corresponding patch for linux. Signed-off-by: Kirill Marinushkin Tested-by: Pan Xiuli Tested-by: Pierre-Louis Bossart Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: Mark Brown Cc: Liam Girdwood Cc: linux-kernel@vger.kernel.org Cc: alsa-devel@alsa-project.org --- include/sound/asoc.h | 16 ++++++++++++++-- include/topology.h | 4 ++-- src/conf/topology/broadwell/broadwell.conf | 4 ++-- src/topology/pcm.c | 30 ++++++++++++++++++++++++++---- 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/include/sound/asoc.h b/include/sound/asoc.h index 0f5d9f9a..89b00703 100644 --- a/include/sound/asoc.h +++ b/include/sound/asoc.h @@ -156,6 +156,18 @@ #define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS (1 << 2) #define SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP (1 << 3) +/* DAI topology BCLK parameter + * For the backwards capability, by default codec is bclk master + */ +#define SND_SOC_TPLG_BCLK_CM 0 /* codec is bclk master */ +#define SND_SOC_TPLG_BCLK_CS 1 /* codec is bclk slave */ + +/* DAI topology FSYNC parameter + * For the backwards capability, by default codec is fsync master + */ +#define SND_SOC_TPLG_FSYNC_CM 0 /* codec is fsync master */ +#define SND_SOC_TPLG_FSYNC_CS 1 /* codec is fsync slave */ + /* * Block Header. * This header precedes all object and object arrays below. @@ -311,8 +323,8 @@ struct snd_soc_tplg_hw_config { __u8 clock_gated; /* 1 if clock can be gated to save power */ __u8 invert_bclk; /* 1 for inverted BCLK, 0 for normal */ __u8 invert_fsync; /* 1 for inverted frame clock, 0 for normal */ - __u8 bclk_master; /* 1 for master of BCLK, 0 for slave */ - __u8 fsync_master; /* 1 for master of FSYNC, 0 for slave */ + __u8 bclk_master; /* SND_SOC_TPLG_BCLK_ value */ + __u8 fsync_master; /* SND_SOC_TPLG_FSYNC_ value */ __u8 mclk_direction; /* 0 for input, 1 for output */ __le16 reserved; /* for 32bit alignment */ __le32 mclk_rate; /* MCLK or SYSCLK freqency in Hz */ diff --git a/include/topology.h b/include/topology.h index 8779da4d..5d7b46df 100644 --- a/include/topology.h +++ b/include/topology.h @@ -1000,8 +1000,8 @@ struct snd_tplg_hw_config_template { unsigned char clock_gated; /* 1 if clock can be gated to save power */ unsigned char invert_bclk; /* 1 for inverted BCLK, 0 for normal */ unsigned char invert_fsync; /* 1 for inverted frame clock, 0 for normal */ - unsigned char bclk_master; /* 1 for master of BCLK, 0 for slave */ - unsigned char fsync_master; /* 1 for master of FSYNC, 0 for slave */ + unsigned char bclk_master; /* SND_SOC_TPLG_BCLK_ value */ + unsigned char fsync_master; /* SND_SOC_TPLG_FSYNC_ value */ unsigned char mclk_direction; /* 0 for input, 1 for output */ unsigned short reserved; /* for 32bit alignment */ unsigned int mclk_rate; /* MCLK or SYSCLK freqency in Hz */ diff --git a/src/conf/topology/broadwell/broadwell.conf b/src/conf/topology/broadwell/broadwell.conf index b8405d93..09fc4daa 100644 --- a/src/conf/topology/broadwell/broadwell.conf +++ b/src/conf/topology/broadwell/broadwell.conf @@ -393,8 +393,8 @@ SectionGraph."dsp" { SectionHWConfig."CodecHWConfig" { id "1" format "I2S" # physical audio format. - bclk "master" # Platform is master of bit clock - fsync "master" # platform is master of fsync + bclk "codec_slave" # platform is master of bit clock (codec is slave) + fsync "codec_slave" # platform is master of fsync (codec is slave) } SectionLink."Codec" { diff --git a/src/topology/pcm.c b/src/topology/pcm.c index bb47b9af..d0395182 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -1141,8 +1141,19 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, if (snd_config_get_string(n, &val) < 0) return -EINVAL; - if (!strcmp(val, "master")) - hw_cfg->bclk_master = true; + if (!strcmp(val, "master")) { + /* For backwards capability, + * "master" == "codec is slave" + */ + SNDERR("warning: deprecated bclk value '%s'\n", + val); + + hw_cfg->bclk_master = SND_SOC_TPLG_BCLK_CS; + } else if (!strcmp(val, "codec_slave")) { + hw_cfg->bclk_master = SND_SOC_TPLG_BCLK_CS; + } else if (!strcmp(val, "codec_master")) { + hw_cfg->bclk_master = SND_SOC_TPLG_BCLK_CM; + } continue; } @@ -1167,8 +1178,19 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, if (snd_config_get_string(n, &val) < 0) return -EINVAL; - if (!strcmp(val, "master")) - hw_cfg->fsync_master = true; + if (!strcmp(val, "master")) { + /* For backwards capability, + * "master" == "codec is slave" + */ + SNDERR("warning: deprecated fsync value '%s'\n", + val); + + hw_cfg->fsync_master = SND_SOC_TPLG_FSYNC_CS; + } else if (!strcmp(val, "codec_slave")) { + hw_cfg->fsync_master = SND_SOC_TPLG_FSYNC_CS; + } else if (!strcmp(val, "codec_master")) { + hw_cfg->fsync_master = SND_SOC_TPLG_FSYNC_CM; + } continue; }