Received: by 10.213.65.68 with SMTP id h4csp300478imn; Tue, 3 Apr 2018 21:23:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx49MJd4KGXn9D2RxFBXSfoECq1bmqe1bSXSao5qGBkUqBUbgS3uV3Swueu9P4qDRmF5iJ4Sl X-Received: by 10.99.124.29 with SMTP id x29mr10979504pgc.284.1522815837521; Tue, 03 Apr 2018 21:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522815837; cv=none; d=google.com; s=arc-20160816; b=ESXIIS0o/SNELvJe41ZNTjRwqaiLvCQOkcLfARz6PBIuVtIommJ0eAr5jyIepIGIaN Z/TU0ppJcMyk7Q4YootAJ+OAR+h3vG3g+dNSIjCWyaOHRk8wpxf/F87qQZ00EO1lraJW Aorjbt+txay5ij+do6SKaXPrAdNsaX2nJhnhAF3MvkUOc4djRADNShl20+OZZ/gSMOIW 83jk34mAcnNEygC01GY34Dn/F5839LXvxvXXPXU4KxV5jrvGEh5uGMORDk8L6/sevse2 PziRBa0/0NVclqV6T+jr7zzKM6r+7hNcnOwZASs2/EWpL+EdmcRzHX071Wztd8FQ9N1/ D1NA== 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=bF+btP9JA4OdYzZv25baCXmy6KNt/wVy8eOljuNAF50=; b=vmlqQ8Qbfg4VoBuaXrYMvOZlB9WIz632zdLSLgrQbtTuqjjhu8aI93NR10HmqUmlIl fmrSA5nk7Jv/Eas2ZvVwsqDPcFqavYWvYKOVflKkikqHMsrJa6jLj9XVQSZdVZYn+PsU rexcSAj93c2ZWP5V7kq/rQ+CHcaj8BoSuA3lO7kQLMyTEGqp8k9H4SDOijRjRagywvtO 15b06lzdajsVFXxOzvHpyJ0MbSQ1dW2ZpgExVKoiMg3yf/rB23zlAXIKHcaPz35D8C/l uTumCv+EnbP2MhxXGS60U44w/GGZtUl412Q9me/DgHucayNVMouTQfTjKkdu5nAumMs/ Qp7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rvi5s97n; 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 p61-v6si2169339plb.633.2018.04.03.21.23.43; Tue, 03 Apr 2018 21:23: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=rvi5s97n; 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 S1751529AbeDDET0 (ORCPT + 99 others); Wed, 4 Apr 2018 00:19:26 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:52393 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751367AbeDDETY (ORCPT ); Wed, 4 Apr 2018 00:19:24 -0400 Received: by mail-wm0-f65.google.com with SMTP id g8so13645789wmd.2 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=sUUGTQWQg5CCZ6d+5TFsUpg1SsNCb9lg/I+Ya3sxBJ7Bb24y1iXU4cuFzeZUsXhMjV q7oNWDO3e1jwhw5ZU7Y9WJFSElv8H4xWOlp3N3njDyR24GrUy19Go3PXa7AZfhE3Xp4F sASzehnXqTz2FFdMpizJyDlxqlFsBHiOcApDA6v4YoBMj/+kMDTr+gFGqe+vHoaPaKXw d/dKI8OFFlr/5/G4eQjWNY6q5c35x3FUs7XWUqRykrQDSCVUYHqBCpjG2j6I9vfZ5cB9 /q7LcPh47kvFcZl/SLFbbMH1iM7kOXU5TizTG/+67JBxLI03gPuQpRwBJA9RR0wDlOPr V1tg== X-Gm-Message-State: AElRT7HKqghRrZrKRlTLoLZu1fJC10c585CH2TFqukTo+tQfXMgKJAhK 2DagqM5RVYWzQkVRjPnySSo= 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 Cc: Pierre-Louis Bossart , Jaroslav Kysela , Takashi Iwai , Pan Xiuli , Liam Girdwood , linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Kirill Marinushkin Subject: [PATCH v4 1/3] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() 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> 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. 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; -- 2.13.6