Received: by 10.213.65.68 with SMTP id h4csp1056785imn; Tue, 27 Mar 2018 13:57:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/KkrUz4WsaAEqVtwWdtEade7K4SA92XYgoDF7819A59efSx9sQ7H5Oid8wjAZci8D9Qd0f X-Received: by 2002:a17:902:141:: with SMTP id 59-v6mr841211plb.219.1522184255100; Tue, 27 Mar 2018 13:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522184255; cv=none; d=google.com; s=arc-20160816; b=qpqCdvAKAq06r3T1VeEl1wSnh1yehBKcxw4Ec0gyrRSFil46OJ6sdIFXWS2sW0bAWV XWlFRqoTSF80AE1YxWSO/wb2gLw4B5kz5kcRCbWZRYQUNTtsXN65GzvHo5C1w5rslmVn E2Q83AmEADBJmMEMadh8zq8vzP6WTLUUj0bFOSKRCWA7f5yxK4IQ/Iem7T5msO5VaZJ0 j22RYkLf4u8FMiXC2S9SDyR3y/HLs1Z3N3N1QVMBi9lSqFuu1bRWtfzzWdF/vMAlNV8B YKMg7rDZFko6YeHgQX2j2tVhPrqPLF4jbdOj+7RCetMT3Qei+LbK+ohEMoHVj5J7sFMX wGAQ== 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=nGcyGfSSLmbPXqrIGUcSGIqkJO0piA301gIOmjtLPxY=; b=fbC4C5WF4YSQwIgT9O3TkIGPjMf+9SkSDgpHWgXfRPRbjsJrPcGNEiF9Mayms1ASo8 zAyY895kPp9n+eqLDik2DxDJbAAGGpwAWhFutxJuTLWeskmxnw5RR/mv9WHlYx8NFIrm wWzF4BEmYvUDrY+LJCRLBf08eX5fHBZSS+mly1vfKhGM8Lbbg3g8wUdD4LtzA2DBdxFd E4p/MrcnWvGjfOxt/DbAfyOEryusF3/dmbNHNF61YUeckoPkJxW6XdBngUThlvVE7TWZ CqjWBRDR5SHhEV0XNDujDV+wbEzlfIFcdOnzfZVH6+jHJB37+5sC8RHE8h+kaQsyG2zk zcEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=J6EpzpN0; 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 l7-v6si2102991plt.89.2018.03.27.13.57.16; Tue, 27 Mar 2018 13:57:35 -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=J6EpzpN0; 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 S1751930AbeC0U4W (ORCPT + 99 others); Tue, 27 Mar 2018 16:56:22 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:55856 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751220AbeC0U4R (ORCPT ); Tue, 27 Mar 2018 16:56:17 -0400 Received: by mail-wm0-f65.google.com with SMTP id b127so321589wmf.5 for ; Tue, 27 Mar 2018 13:56:17 -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=nGcyGfSSLmbPXqrIGUcSGIqkJO0piA301gIOmjtLPxY=; b=J6EpzpN0SHIufVUwp4jbc55pmh2uwHf8jPnSsCxPgpx56nT/0fY9VQLhiiALXTHuhe gMJx6g68divi3LNjFPARfB0+Gugn5MwnxbHiEeP67uzSxaBvtUxi7V0DclEq1NezrRU0 4FV73qXBcFehlBiMbLaJiC4Zg3o9lzUy8BCuHJUMg9Q6f+IqJnXUZgJVRBNxRHpRK4KU nT6+H9tC9Hg3IXGMhDnHrRs4C95MblN6VWz93IDG85WhcZkloxxtWKmb59MTb2+QLnlC EGlkW39Hb8/b8rndm/dxZwCgh1LSXU6ZgFCsFuW+Fyg+v4ekk1b6xzEg88+5nIZACtAb +sAw== 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=nGcyGfSSLmbPXqrIGUcSGIqkJO0piA301gIOmjtLPxY=; b=ewSBla8/QQkh8CyGeQyhujAmZSm12Kc+F6Jck4FgRDHrnBsXVJYXT5rjABi0dEltHh Q6Sf7cQCVsrw67iXywndOUDYBKTS6MAwFpUjtL96a0BB0ed6qygAgEbVlCdyMHyoPptj cbYoEW4RoRFlaMosqFX+9Nr7K1mYTj+0CG6l3JoV63Z8uCYb8JZVtT3cKmDDeW7v72hv JBZUsnHaHJIhq/VzifcBFVMVde7tr5asBdfClR0MiIepVJ5wSCunAty+kEtNqL9frVf5 9ayYMVUlfmIQIF4Y3qp/CIUvTZvuKcBWLdBHVXKGB99IRNN8LqLkqi1BzrVkRPy6bkxb Zw4w== X-Gm-Message-State: AElRT7Ev9TL7sJLxiHUbjvxQQqBjYbU3GSTSeXd5snhkL6svxOKZ/2CM 7v/J2dQ8Rs+hSjOU8qnymu4= X-Received: by 10.80.154.195 with SMTP id p61mr767672edb.68.1522184176580; Tue, 27 Mar 2018 13:56:16 -0700 (PDT) Received: from gentoo0.localdomain (x4dbab50a.dyn.telefonica.de. [77.186.181.10]) by smtp.gmail.com with ESMTPSA id o3sm1307135edi.24.2018.03.27.13.56.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 13:56:15 -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 v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() Date: Tue, 27 Mar 2018 22:56:31 +0200 Message-Id: <20180327205632.3677-2-k.marinushkin@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180327205632.3677-1-k.marinushkin@gmail.com> References: <20180327205632.3677-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 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