Received: by 10.213.65.68 with SMTP id h4csp1060676imn; Tue, 27 Mar 2018 14:01:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx49IfFBtknpJEA6ZFXJgtG20RIM+D8VlB6wf0sLmjQer7v8l+sn76fJ0SEG54GkFm3fU4IvY X-Received: by 10.98.111.65 with SMTP id k62mr669187pfc.184.1522184517616; Tue, 27 Mar 2018 14:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522184517; cv=none; d=google.com; s=arc-20160816; b=oJel7upKzfzZObfx7RgyjZo4fEB+/tyszcqGVZLoUGmBsFjOpcYjfhJrnZXjQFP2MQ K789WN74X7DIM1vSD5IZ9zSQ7rv5kSSxWmdoUDgs/FuxtlG1GiKj+y0KAN/zAFUlU0Pf 2xPk3L9h5h35sADUMYULNDhgqvQLPXt/rS/f29oZZ6lRLV4jJIi8GtjYs3h+yKFzJemu 9em3AZ538HPFKvlAHsalbnBCHW7vu0rxdIa8RRKan1lns4KJ1LTBanUwim/C8s0ZuUv5 5+RBdjPSH7c8fMlpmTkbTC8IrR9m6dqIr0kWamt5NW8PgX8+Y2oNR/s3eckPf8kE5cMj VDQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=cKFV8U95JPzsEZaJG91ZIdQD/scdCSuRwOKM9bTtHUw=; b=TlekhqNWvWDcXLsHOIBhD+I2t6eT6V7FZfmuCn6a4c05LlzoYrOJ0mMwLurl1QSa+g vtW4zoT1i0u++rB7+koniKQ/QaB953UFBbFgiyN+p7UDxjOTEH5q7rBFn8pMVjMM9sSl sKReShZhqaA7CFI4XWRPB736emyvdUWVT2Xz2E9HLnJqZy2zqOsCvptr+oJGdZezY/eo algaLcQu+OgZ+kq0L5J6ALsHWvQ8Zvd93jdBUqPVGfFtmOZeSRBh2SoN6sPqD+rKlfo7 6X2RTJnciUC90TLuvs6NGU5RO9tU20mQfDlQCLUiXW7i8yeK7wGWLDG9NiXoxIp4CAdv 7t6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p0Pv+H1Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w128si1372927pgb.460.2018.03.27.14.01.40; Tue, 27 Mar 2018 14:01:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p0Pv+H1Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752131AbeC0VAa (ORCPT + 99 others); Tue, 27 Mar 2018 17:00:30 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:50938 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752044AbeC0VA2 (ORCPT ); Tue, 27 Mar 2018 17:00:28 -0400 Received: by mail-wm0-f65.google.com with SMTP id l201so1224324wmg.0 for ; Tue, 27 Mar 2018 14:00:27 -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=JE7POsYILjdlYw88ivCzIlAiz6bSYX3PdHv6oLzCNCRZKUnB3fjG/JHoS+7tZQAkFS 5If16IcJSSHbNcIAOJrC4txkivWrV5xK0rd61nwuo6zdmIH5b1TLRGpejbvb10FYPWI9 5rPQgE1ue/EdqS4XYJhnzHBC79Xqqerm/xjCkOWYs953jrJACCuAWmxIaB8NSCzByZQw h7o+sNU/DvS38Li9h4kl5L/5XdEJkI/BgGBSIg3LGipS+20HrchXQBhg36sUDl60+weH Mh6NcmcAr4kBeu4mK075trWpYksTAHW7t6wmC3OoQMqg9Z5AUT6YNYcsG4e0ljZgyUAZ JNfw== X-Gm-Message-State: AElRT7HWmGpENpGu0eG+DHeemGpuTV8FzAr1d7UXAgQhe8iYpotCXntF /q/59KcBYz+LDrd0djswVGw= 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 Cc: Pan Xiuli , Pierre-Louis Bossart , Liam Girdwood , linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Kirill Marinushkin Subject: [PATCH, alsa-lib, v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.13.6