From patchwork Thu Mar 1 06:48:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Marinushkin X-Patchwork-Id: 10250485 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 DDD4C6037D for ; Thu, 1 Mar 2018 06:48:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD54A28E80 for ; Thu, 1 Mar 2018 06:48:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B21C828E9F; Thu, 1 Mar 2018 06:48:07 +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 6C71628E80 for ; Thu, 1 Mar 2018 06:48:06 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 8968526786B; Thu, 1 Mar 2018 07:48:04 +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 465B426786D; Thu, 1 Mar 2018 07:48:02 +0100 (CET) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by alsa0.perex.cz (Postfix) with ESMTP id 7F65226786A for ; Thu, 1 Mar 2018 07:47:59 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id t74so9444971wme.3 for ; Wed, 28 Feb 2018 22:47:59 -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=8RuPWQ5lH10pJVesN9QogujxnR3ceHzApbLxKNqWvfM=; b=lxrbSvvUULhBN4yM6n7kuLSEzo3mye4/jKt+wDjtPzd5836esL1fJCdeuIfUtF/gPG b2LzgLM5lPThT8JbwVZZGSZ6wBM+x81ho8YjsNJcYY3ZWwPaJHCsRlDdBnFxp7H0qE/l CUYBBrfvkoMU+n/z5lnKhJ3xukptKHi59QyMbcdBQHbruMrsucu9+fyr7eRq3mUqHW+R z8tChHYsEw3iOt9nfRcbxglUqPKARMN0IyvGw6nNVQe04qZ4MN6uZLEl96c1yObziVNH ebe2LMpGquqEwV9tJdcYgL4guZybf1X1phKkwX/Yzjvx4yURn6QWVSHDqalvc4c3uIhn sTZA== 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=8RuPWQ5lH10pJVesN9QogujxnR3ceHzApbLxKNqWvfM=; b=tkt/aiC8fGi28dWwRzcTdX5lFIQrQ+3pKivTcspycRyAt5BpjI5zrScB6eu0fv+Rz0 +garV0H6eCF0qHVvLAOvVk4BUjT2/qNAWWI4tx9GXa/91r1kyplBevL1yZ3wni4KGH7J oyEHKoaEdIoLhrwj5mOkkFddXs1xdyIZ3d+tNLmsVnGRY1jxiuSct9uJmHw3sT6ipUQY X7bVJMi7hr3ugAYwiXghzXLSebYs70wDPIdh3Jbd17w2hBPg98+5BpPg8M/15Y6gUUxs Epfz0KiipTixAOwhTbRTtUcTInJIbX0QoRBhlvuy9tlLkSmzsMWmwGukBCdSaE4/xw5l 6XRA== X-Gm-Message-State: APf1xPB/PYG1SYc0E2wvLrhKb5qmVTEJXcE5buDPLBrDo2h/6VIBSXi2 aQw6IdrTCFYQYj5oGmAQ6P0= X-Google-Smtp-Source: AG47ELug4TK57F+j0hhyLwnICjx8075KQFpdOC075qY9sk4gtyxPDrWRWqH4lJJs81EuARLLywOKcg== X-Received: by 10.28.186.66 with SMTP id k63mr703213wmf.156.1519886878985; Wed, 28 Feb 2018 22:47:58 -0800 (PST) Received: from gentoo0.localdomain (x4dbc595e.dyn.telefonica.de. [77.188.89.94]) by smtp.gmail.com with ESMTPSA id o16sm54734wmi.38.2018.02.28.22.47.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 22:47:58 -0800 (PST) From: Kirill Marinushkin To: Mark Brown , Takashi Iwai , Pierre-Louis Bossart , Pan Xiuli Date: Thu, 1 Mar 2018 07:48:12 +0100 Message-Id: <20180301064812.5463-1-k.marinushkin@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180301064556.5387-1-k.marinushkin@gmail.com> References: <20180301064556.5387-1-k.marinushkin@gmail.com> Cc: Liam Girdwood , alsa-devel@alsa-project.org, Kirill Marinushkin Subject: [alsa-devel] [PATCH v2] 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: Takashi Iwai Cc: Jaroslav Kysela Cc: Pierre-Louis Bossart Cc: Pan Xiuli Cc: Liam Girdwood Cc: alsa-devel@alsa-project.org Tested-by: Pierre-Louis Bossart --- 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 58cee31d..bdab8eef 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -1137,8 +1137,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; } @@ -1163,8 +1174,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; }