From patchwork Tue Feb 27 20:35:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Marinushkin X-Patchwork-Id: 10246019 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 7FBFC60362 for ; Tue, 27 Feb 2018 20:35:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62F2328994 for ; Tue, 27 Feb 2018 20:35:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57C9228A5C; Tue, 27 Feb 2018 20:35: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 81D0428994 for ; Tue, 27 Feb 2018 20:35:32 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 0B66F26772E; Tue, 27 Feb 2018 21:35:31 +0100 (CET) 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 BBE5C26772F; Tue, 27 Feb 2018 21:35:28 +0100 (CET) Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by alsa0.perex.cz (Postfix) with ESMTP id 7CD8926772C for ; Tue, 27 Feb 2018 21:35:26 +0100 (CET) Received: by mail-wr0-f195.google.com with SMTP id v65so118816wrc.11 for ; Tue, 27 Feb 2018 12:35:26 -0800 (PST) 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=BrpLxKKmn6fym/YUCd9iEtkaWBwZ2vjRf+4NkARoMaE=; b=isodUwVS8U/0k9Sn4infsB85rD0E9VbQAVsTAoffFyrHV+PW2oEEbH6aJnSf3Z3oVj 8Hji2wal9fnQ+D4X89X477pdOPoRwdg4vEtWV2cHfqQu7h46QG+7uQJmAY36bVGHBV+X 1eiVMShUamOwl3g3wC9WPadQqU5PKkuI6yfjHOkjETwm0FR2nB9X2OdYecTgR+HLn9M2 jgeiIuzKH5Dad3NHEJSFsy9XN6S8qwXpxncsKtZvD4WEe3ASsQyZsQ6ymLfRCHgs2Y+T DcWXplmY/a97HGXBPoCvVMuGR3e+w8CubO5fiu58G4wHpHZldJV+MUbbwQItpEZJPZpK jogg== 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=BrpLxKKmn6fym/YUCd9iEtkaWBwZ2vjRf+4NkARoMaE=; b=GRvaCaVhMczbJos8+kH+E/LcAv3+jnHsumHfkeoa1DLnlXA3XD/YxS8o6GeswCYlqp lwX4o/nYCQzlv9vQ+WYg02d5K+dHBlUsXhs2fW808Kiip3v8nWW2lhuEJm/q3KA4Nd/R x4DbbTNUhLEGs4/WrT5IvEBXwVJjDNkZsYlbcNO2TkPY1xVk+kpYYCp1W6Q4cmgPMPyL I198/NgowAJj572FxbVsrBB7VkSuURphYwJYnVnEOaS+nIbr60vFkxYNUMdttIfylkB9 QnC/aqeMZ2lJrtDhOG3Er0SbRvlc1Wvw1enb4SI+Mde1d4j5j63HovD8dqi1EqW9IVID jSDg== X-Gm-Message-State: APf1xPDNeCz4PiifQulo67LvNvn0USkx+BC1FFuGoJYdxeLn5JLX+vTx X3gDvvrOe85oLkmmShvBOg+5cSuZ X-Google-Smtp-Source: AH8x225Uhbaz8oG3mbg6UFwndhUgWsJkUP0f5JTBfQalvrGdGLtMpJDiJON55101o/J5uUNz33lxQA== X-Received: by 10.223.141.150 with SMTP id o22mr13579608wrb.280.1519763726032; Tue, 27 Feb 2018 12:35:26 -0800 (PST) Received: from gentoo0.localdomain (x4e34ba44.dyn.telefonica.de. [78.52.186.68]) by smtp.gmail.com with ESMTPSA id t91sm20452wrc.21.2018.02.27.12.35.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 12:35:25 -0800 (PST) From: Kirill Marinushkin To: Mark Brown Date: Tue, 27 Feb 2018 21:35:41 +0100 Message-Id: <20180227203541.17343-1-k.marinushkin@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180227203317.17274-2-k.marinushkin@gmail.com> References: <20180227203317.17274-2-k.marinushkin@gmail.com> Cc: Liam Girdwood , alsa-devel@alsa-project.org, Pan Xiuli , Pierre-Louis Bossart , Kirill Marinushkin Subject: [alsa-devel] [PATCH, alsa-lib] 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 Cc: Mark Brown Cc: Pierre-Louis Bossart Cc: Pan Xiuli Cc: Liam Girdwood Cc: alsa-devel@alsa-project.org --- include/sound/asoc.h | 16 ++++++++++++++-- src/conf/topology/broadwell/broadwell.conf | 4 ++-- src/topology/pcm.c | 20 ++++++++++++++++---- 3 files changed, 32 insertions(+), 8 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/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 58cee31d..d5d5e5b3 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -1137,8 +1137,14 @@ 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; + /* For backwards capability, + * "master" == "codec is slave" + */ + if (!strcmp(val, "master") || + !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; } @@ -1163,8 +1169,14 @@ 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; + /* For backwards capability, + * "master" == "codec is slave" + */ + if (!strcmp(val, "master") || + !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; }