Received: by 10.223.185.116 with SMTP id b49csp7086241wrg; Wed, 28 Feb 2018 22:46:59 -0800 (PST) X-Google-Smtp-Source: AG47ELvI5H9MdQi0mQa4z9h3EnAMvwvPtb7ttWodUp6S4ErubLAIGGth+Ope+20MYsVlzL5dwBl6 X-Received: by 10.101.71.138 with SMTP id e10mr721614pgs.317.1519886818906; Wed, 28 Feb 2018 22:46:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519886818; cv=none; d=google.com; s=arc-20160816; b=Yj0QO9Hs97MeJUSEWbvQr6GoHRv6oTg1JM+8dTW7fXay3wUOw3CNOHH8WENuhK+AuW i6CyCip5fgFyDhuq0V6ySUhkCPeg3Ot4Ahp/FpYR37CyEffLhqXVX6UKF2vvGk6rkSn+ uynHVV+dv+nyV4gdMTFHM4EXemVfUQ5cPDsFsgrzx1p7fifA833WAyjYiqtFvlD0q+L7 +NwqtCCAaQFQTz2UYf6cNT6F5XzGCvPTlTrGEyAIR0QXsTStKhLsh6j6cdEYFcEpW9jz pz3B6OLp0kUdmfaAU0Dhku5a7hT2kULRQ5fZrKE9ruhZ9jHx/QqAgtoca3p9LO+lw1FQ eQcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=LA7AGTEaCuaEgZ0QEVtzldCTtCsagh6QASoZJudC+mY=; b=KstvQ1ZEINAJAJ/ukvlk9eq6VqLP/0uNah2jsR6He7+P8UNtHDp/O0z3wNY40APmey PC9tVPstESx4BlndD39UN77zZIdhAuK9iCKR6acGBOQ8Z8JnEKh7JfhfNeTLRVGxAPHB OLIPYjZzmm1hGH1VtZZLXxT6+OFCMjkKSgxta6CN00TE4edhrmN0R0L3egg87CP1IF8L gLED5qqZieHEGEHyPQR7B8lAgvJMeT7XrJ13tkvKZftd3t7+kVAXJ7s3u6iETR4omnJ/ 4IJDLp9mX0CoO70kO4HFgOPymW8pkpxQjhwe8mVhDYnV4RE2TWQfu++CsxL80ctoKLQ2 xvFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Vwots+TB; 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 s21si2457561pfm.325.2018.02.28.22.46.43; Wed, 28 Feb 2018 22:46:58 -0800 (PST) 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=Vwots+TB; 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 S966349AbeCAGqE (ORCPT + 99 others); Thu, 1 Mar 2018 01:46:04 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:44549 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965457AbeCAGqD (ORCPT ); Thu, 1 Mar 2018 01:46:03 -0500 Received: by mail-wr0-f194.google.com with SMTP id v65so4869969wrc.11 for ; Wed, 28 Feb 2018 22:46:02 -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; bh=LA7AGTEaCuaEgZ0QEVtzldCTtCsagh6QASoZJudC+mY=; b=Vwots+TB9/dO58IeRO8Mok2YcTtv19fdqF4Zgmg7GFZDLWVKv+8fXgSMLilekp6uwQ zr4ImoadyY2VJbmow8PACrmRRoeBzqHRc/o1vpA91pl3/886IAqyHaOTovkTMk+970kV /yleImj9HDioUgVYv6BDXC6d3+5GYmJqEm1Lc3ykE1TRE23tnjV1TRkuT/ImTkRQ5823 jGU1jpsxaelj2gIU2TcFoCblIEOpGzJeQFJx2Lpm3C1nkQHrDAtxg9IW32ryLqVNiTKN aRSCGktU0ViUavnUB4f8FEn5SQv95S+VK+UZZpRce8NY3MD1Bnn/NEiDf9im24K3PATq Aosg== 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; bh=LA7AGTEaCuaEgZ0QEVtzldCTtCsagh6QASoZJudC+mY=; b=I/OwxRfJroXFmsz/DpTL4+qhjQRocYxl9uZ68FQmAG/cFcZSy5lbuXy5XJc6qlRg8q yaSnEqGEOBCI+7RV0Yue1K4DQ5mxCDSHgg8DKeYOUDt+OsLDcEstc8Wr/tKqiDuxsfIF /BfsfYerjDkaQPuBPw/1LJ+OpN6qdKruQS+U6EuYvRAXEaN7p7WbYISAn00RIwk8o+1h 1bYfjp4fafyZp5qU1Uh0RToVKVGkoO9AhuGyl5YjAc7Uhn1o3olG/dYHARZhOZj/tqmJ uO8YQZ3mdIgNFBEoBBjC+kN9kPsNKdJE4HjRovF/WVAbT3NKmuTryTXaYVp8Su8mF0R0 iLqg== X-Gm-Message-State: APf1xPCBOJIY7UrrU5xr06gSBgrJCiFjtzD0c3egpcIcenqW/byeGRQz JFrWiFeebZcqTXEUmwyFi2Y= X-Received: by 10.223.135.102 with SMTP id 35mr692584wrz.53.1519886761870; Wed, 28 Feb 2018 22:46:01 -0800 (PST) Received: from gentoo0.localdomain (x4dbc595e.dyn.telefonica.de. [77.188.89.94]) by smtp.gmail.com with ESMTPSA id w29sm3025425wra.84.2018.02.28.22.45.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 22:45:58 -0800 (PST) From: Kirill Marinushkin To: Mark Brown , Takashi Iwai , Pierre-Louis Bossart , Pan Xiuli Cc: Kirill Marinushkin , Jaroslav Kysela , Liam Girdwood , linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH v2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() Date: Thu, 1 Mar 2018 07:45:56 +0100 Message-Id: <20180301064556.5387-1-k.marinushkin@gmail.com> X-Mailer: git-send-email 2.13.6 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 alsa-lib. 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: 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; -- 2.13.6