From patchwork Wed Apr 4 04:19:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Marinushkin X-Patchwork-Id: 10322045 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 EBA7A60318 for ; Wed, 4 Apr 2018 04:19:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D959B28DC6 for ; Wed, 4 Apr 2018 04:19:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBB8528DCE; Wed, 4 Apr 2018 04:19:33 +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 7FFDF28DC6 for ; Wed, 4 Apr 2018 04:19:32 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id EAC1826762C; Wed, 4 Apr 2018 06:19:30 +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 2382B26762F; Wed, 4 Apr 2018 06:19:28 +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 2FCDE26762C for ; Wed, 4 Apr 2018 06:19:23 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id r191so6821808wmg.4 for ; Tue, 03 Apr 2018 21:19:23 -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=bF+btP9JA4OdYzZv25baCXmy6KNt/wVy8eOljuNAF50=; b=rvi5s97nNGVODgljbHvWlOBQ0wN2U75yyY9mdj3exFA5JRFsddf0WB1/AFSOkkTEuY gaA0SSD7Fko4C0tiTgzxnVo2Dju0xkmpLNGv6LZodSj45C5WUr9Ca26WaNlvsi9UciJh CaTo8kV4tuCn6nI9PT/5VSx1TWPg4UsNWbytedh4OlQG1XMCxVaaGU7TElgFsnJzD/U/ KhkZ3xqMn4Q3SfC76BRL4XOSKlR+Rwv+Gb1z8L9nuk2aUsHuBcy+TpJQkiYEWcdBptQG QZS2XrcBH7MAuurh0MwriKHIZTUBiW+X0JQng64+SMKn+yN7Yqe4gIkBOuyFCvhogkJ1 97Kw== 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=bF+btP9JA4OdYzZv25baCXmy6KNt/wVy8eOljuNAF50=; b=RLONy6dtUOT4AIg3WxhHkGkgv2pJEgjqiT6LLe+WQwcXg9BIG3tpQ3rMiK5kRqa78r +Yf4rQdScZt3LFDKHMIscnKhVQK2sk7ZhLyMOmbdsv4PRDa06GH5V9/b2PHugIhIgTSP aKBmYex9NO9MfQuq2G8zXzkvuyMRMZibquvxjLRZBqJFubnfqNHfu/8cKYY8QGADIG/e ou1eMQylu1ywqZIbB2YJvmnyxq17tPQHslTZDg05RCJDYFhxilkbXkZy/0P0L9EXnkfL vtUKKumqK2I1op307zLXs7eOOEGL6tAFR3JVClmoqGfyWtsV7UEikToQ2iw4yt0p0i8z YgKw== X-Gm-Message-State: AElRT7EDIIpbzwm6GXNYjIUagmPMcFFEXS2XzqpHKdit+EnGg6hqakos ws2Dngzn//tUN5aqFaW8ZDU= X-Google-Smtp-Source: AIpwx4880vkjA8gNbrZDyW5ymA7rj4wcyeu1oEJAKPCW57Ks9HK96a0Hstx/cXvKmrCNpbQU0vieZg== X-Received: by 10.80.170.102 with SMTP id p35mr19170666edc.197.1522815562935; Tue, 03 Apr 2018 21:19:22 -0700 (PDT) Received: from gentoo0.localdomain (x4dba7eb4.dyn.telefonica.de. [77.186.126.180]) by smtp.gmail.com with ESMTPSA id g24sm2866647edj.87.2018.04.03.21.19.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Apr 2018 21:19:22 -0700 (PDT) From: Kirill Marinushkin To: Mark Brown Date: Wed, 4 Apr 2018 06:19:37 +0200 Message-Id: <20180404041939.23317-2-k.marinushkin@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180404041939.23317-1-k.marinushkin@gmail.com> References: <20180404041939.23317-1-k.marinushkin@gmail.com> Cc: alsa-devel@alsa-project.org, Takashi Iwai , Pan Xiuli , Pierre-Louis Bossart , linux-kernel@vger.kernel.org, Liam Girdwood , Kirill Marinushkin Subject: [alsa-devel] [PATCH v4 1/3] 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. Signed-off-by: Kirill Marinushkin Reviewed-by: Pierre-Louis Bossart 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/uapi/sound/asoc.h | 16 ++++++++++++++-- sound/soc/soc-topology.c | 12 +++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h index 69c37ecbff7e..f0e5e21efa54 100644 --- a/include/uapi/sound/asoc.h +++ b/include/uapi/sound/asoc.h @@ -160,6 +160,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. @@ -315,8 +327,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/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 01a50413c66f..c5bdc673b195 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1994,13 +1994,15 @@ static void set_link_hw_format(struct snd_soc_dai_link *link, link->dai_fmt |= SND_SOC_DAIFMT_IB_IF; /* clock masters */ - bclk_master = hw_config->bclk_master; - fsync_master = hw_config->fsync_master; - if (!bclk_master && !fsync_master) + bclk_master = (hw_config->bclk_master == + SND_SOC_TPLG_BCLK_CM); + fsync_master = (hw_config->fsync_master == + SND_SOC_TPLG_FSYNC_CM); + if (bclk_master && fsync_master) link->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; - else if (bclk_master && !fsync_master) - link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFM; else if (!bclk_master && fsync_master) + link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFM; + else if (bclk_master && !fsync_master) link->dai_fmt |= SND_SOC_DAIFMT_CBM_CFS; else link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;