From patchwork Fri Jun 2 09:03:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alvin_=C5=A0ipraga?= X-Patchwork-Id: 102405 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp896350vqr; Fri, 2 Jun 2023 02:23:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ74XL0spuqkJws17kS1/HQ85tnq2N+YNuYS5Yqzs1h1W6IRkX5Xff/z0IV/VUHAXP/Zihib X-Received: by 2002:a05:6a20:3d85:b0:10e:457f:254c with SMTP id s5-20020a056a203d8500b0010e457f254cmr9986518pzi.2.1685697791149; Fri, 02 Jun 2023 02:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685697791; cv=none; d=google.com; s=arc-20160816; b=ZLwRX+zsjEhl1flkv3tVg6c2H2Eie+qGA4pU1NCqslefDaGGGW38Ns2Rm7bx8lWaGa KsBWJMXIhOBlaKIj9mp6BG4xiE2XXjLRjyoQtuvqrDO61/aruCTiKQ5xrSC8EF0IkkBy 6YpqQG8P7or40Ed5VtQ/x356Nl3UgtjkshhbyQLxZyLjNAli165C57Xhr/kYhFAQd9W2 mWbOcA79QpHN4SMNTRXTlYONkywXO1zSsTppyxIssMTmeXkftz0lnyy8obtem6UzMlCZ Vt0D81CK0Lhv/wpzSlWiPTORA6ZQSbOWs6UWsi5XTBqwdR0yW+wlnzNAP+fFMcU7CPzJ c7sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8/iuC9pgq+loj7BUT0q2UIND8pBHqchhclkWSDPXeDM=; b=XKJaFJhqJk9Cf1ZZIqOBPP2M4RhFEvxZfBFuXoajURjqnl+5zHVcATMtifGbYIH+RM kY1noQROIiLB1gh7y4p5o5kczGu2RysqfyJL2LZE6cGhCLTX9c0rFEvziAAfdD87zPEP ZpyE6Q5R16NQE57/KAwIb/u8wnR/dQmTCQU93rF9gfm6YiASnGvv8r5HbfojCJWTVsJc frvRFFgEh7EoLvo9ZoOZrleH5COVhYfmJI8K9tSUBUW2vzl9IbrhdPGSVwQV/f6NwIha GUDaOgb2XiaGwf+Ip9hncCUE96cUmZMV158X/ik9lSUXeEd7F97YQfGb5/xUCGJpZric TZ8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pqrs.dk header.s=google header.b=K1yBeMpB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a170902d48400b001b04a379cd2si618728plg.348.2023.06.02.02.22.56; Fri, 02 Jun 2023 02:23:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@pqrs.dk header.s=google header.b=K1yBeMpB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234584AbjFBJFJ (ORCPT + 99 others); Fri, 2 Jun 2023 05:05:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234281AbjFBJEI (ORCPT ); Fri, 2 Jun 2023 05:04:08 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE39510C6 for ; Fri, 2 Jun 2023 02:03:47 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-97467e06511so41065666b.2 for ; Fri, 02 Jun 2023 02:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=google; t=1685696626; x=1688288626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8/iuC9pgq+loj7BUT0q2UIND8pBHqchhclkWSDPXeDM=; b=K1yBeMpBVIyXpZOk4aIP0ge7LNiFJvDqYOSNIVpD86eYCYyy8DH0RfBt7XJAG4NSRk 5RKTKtJKP/1Oa0yeujEtwik60eVCbWz6w175oko0mwaI+fY0LUHU39kh/wpADcdnjOwa NqDT95GmEvI13yF+WnHDrTE8xsAFdkWt40HxiB4+Wrue8DmFxzQVSAyPbWghNCMdspfk NlNHWIdVoWhLNGrnrxxrPvE7w/CXasgvunm/4116b9qSZ173Cjp7zZHfUfsdbp297AcE FGMwB5xdCy7hUFh7R0RsYEtEsEfHpOl5YNbJKDaWOfWsnIkZs+k6n19ff7HNoKfTrw3F /xrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685696626; x=1688288626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8/iuC9pgq+loj7BUT0q2UIND8pBHqchhclkWSDPXeDM=; b=NQfP9AG7euYd+cRmo9uXBbRJHeXNYbB3NOTtJh3C9BO3+a6DVjLn0Tlhqh43Ftkx2W sz1wA/y6LC6BIrorCdqNQyenRjfK0hjWt1rRmSw2LKwmMOG84ZGg6Vg6/jYybAKqY5ng fVTpixvDJjePZ+kSCbNOdf1rppdqkwtXQPFQhG3b6nMNg9NvkusahZa1kmLHM3aq1Egc c5gVFb4et3AkibRoVcDtgVzVOuvWAxqlNb2FwImeNehZDHD2CygDVOTJxwZ4ZkatT+Pb 3v5bCDYO3umwUf4E2f5VFkwbjPCgZFfRRimHN/vjc1e+kYKE7Kuzz6/1YWNAhFAeCBzP hOEg== X-Gm-Message-State: AC+VfDwiALr4escjwK/C/x+LE+tiP3b94yxImKIlB40M4oBq7hNZ0eDK MsGR7I1i2jZ6qOrhoNRrBo+D1w== X-Received: by 2002:a17:907:3e14:b0:974:545d:cfa3 with SMTP id hp20-20020a1709073e1400b00974545dcfa3mr2630054ejc.64.1685696626324; Fri, 02 Jun 2023 02:03:46 -0700 (PDT) Received: from localhost.localdomain (80.71.142.18.ipv4.parknet.dk. [80.71.142.18]) by smtp.gmail.com with ESMTPSA id w23-20020a170906385700b009707fa1c316sm488031ejc.213.2023.06.02.02.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 02:03:46 -0700 (PDT) From: =?utf-8?q?Alvin_=C5=A0ipraga?= To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Kuninori Morimoto Cc: =?utf-8?q?Alvin_=C5=A0ipraga?= , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] ASoC: core: add support for dai-links with symmetric clock roles Date: Fri, 2 Jun 2023 11:03:19 +0200 Message-Id: <20230602090322.1876359-3-alvin@pqrs.dk> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230602090322.1876359-1-alvin@pqrs.dk> References: <20230602090322.1876359-1-alvin@pqrs.dk> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767582247110787420?= X-GMAIL-MSGID: =?utf-8?q?1767582247110787420?= From: Alvin Šipraga The snd_soc_dai_link::dai_fmt field contains the nominal bit- and frame-clock consumer/provider role from the point of view of the codec. The ASoC core then assumes that it should flip the roles when initializing the format on the CPU. But in cases where both the CPU and codec are clock consumers, e.g. because of an external clock source, this assumption breaks down. To allow for proper configuration of the backing CPU/codec drivers for consumer roles, introduce support for a symmetric_clock_roles flag. The role flipping will be skipped when this flag is set. Signed-off-by: Alvin Šipraga --- include/sound/soc.h | 3 +++ sound/soc/soc-core.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 533e553a343f..87f4fb3d4b20 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -718,6 +718,9 @@ struct snd_soc_dai_link { /* Keep DAI active over suspend */ unsigned int ignore_suspend:1; + /* Assume CPU/Codec have the same clock consumer/provider role */ + unsigned int symmetric_clock_roles:1; + /* Symmetry requirements */ unsigned int symmetric_rate:1; unsigned int symmetric_channels:1; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b48efc3a08d2..7817b86dd93d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1216,6 +1216,7 @@ static void snd_soc_runtime_get_dai_fmt(struct snd_soc_pcm_runtime *rtd) int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, unsigned int dai_fmt) { + struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_dai *cpu_dai; struct snd_soc_dai *codec_dai; unsigned int i; @@ -1231,7 +1232,8 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, } /* Flip the polarity for the "CPU" end of link */ - dai_fmt = snd_soc_daifmt_clock_provider_flipped(dai_fmt); + if (!dai_link->symmetric_clock_roles) + dai_fmt = snd_soc_daifmt_clock_provider_flipped(dai_fmt); for_each_rtd_cpu_dais(rtd, i, cpu_dai) { ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt);