Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp656066pxk; Thu, 1 Oct 2020 10:36:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLrQtV+7MbuW0sg9zSbLB/M8oq+n1Y+sqo8eP9KHAduNnku9FRnAdqJzGHEtIWZt8RkGxk X-Received: by 2002:a17:906:7010:: with SMTP id n16mr2653233ejj.328.1601573791714; Thu, 01 Oct 2020 10:36:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601573791; cv=none; d=google.com; s=arc-20160816; b=y5xDN1gW/oNxEmSOOds+gGzxegFI22x8VxvnHFAcxiLDmwLPmwSWafihDNmtJsZw6M g419iJhtqKxkICAE7ZNmN2B73wISU9v+VCCM6J0lRZ45zs+x6BT4iFw63G8aja2XQHdO g2MBaxDX06FogNS2lyqlonIKn8eLsMbaP50UwU/+nM4FJf2h8jsekUCK3qDq8eSCwYIZ oTCk97kD86lQyzl5BWDNR7e40HVKOeZ4XVfqNem3ke54384UCLRxpEN7k8K7aSSeTfdd i1Zi8Y/C2q0VwyIJFhol8DfDHg8aDs58GbYMcDJFUVv5+1LV+OpEVZ53HlqnV5SAKWas JJvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=KGVHwu7gz2uVTadbhaTYCpdQftlC5kySO8eaYF0Uy+k=; b=hLqxTk0eOLYA+ILnEESvTdaT3BMDK5bsA56nbbtUoT3ahF42TgwtEx/BCMuU6z7703 JKE9A0Us2xb52C5VCPV9++7DfzAAugACsnGc1//Gwp98PL7PzwNV0O9lrHEXlWqW4hRY TQClmsRl+Dab7s8XOHB1Py5/mSM7echMwcdYn2F8hv9KN6PW74O4MD+jiGWWFDsa/58i Fh9wDqv7zXUmXtm6yOQ5LXPG54PKTjAkubV1fNG7+Jjk9YwVs/SP9jll8Ll6U7eU+scS wyB2fb6yZxNPN1dBFJDmI/k4bK+9co+Zl/GyTOq7QxjqSr4IrawEcVoQ2wxxZ4PGt2Xs x7ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=fYUhqZEf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si4192262edm.176.2020.10.01.10.36.09; Thu, 01 Oct 2020 10:36:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=fYUhqZEf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733041AbgJARei (ORCPT + 99 others); Thu, 1 Oct 2020 13:34:38 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:10042 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732407AbgJARei (ORCPT ); Thu, 1 Oct 2020 13:34:38 -0400 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 01 Oct 2020 10:33:46 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 1 Oct 2020 17:34:36 +0000 Received: from audio.nvidia.com (10.124.1.5) by mail.nvidia.com (172.20.187.18) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Thu, 1 Oct 2020 17:34:30 +0000 From: Sameer Pujar To: , , , , , , , , CC: , , , , , , , , , , , , , Sameer Pujar Subject: [PATCH v3 07/13] ASoC: audio-graph: Update driver as per new exposed members Date: Thu, 1 Oct 2020 23:03:01 +0530 Message-ID: <1601573587-15288-8-git-send-email-spujar@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1601573587-15288-1-git-send-email-spujar@nvidia.com> References: <1601573587-15288-1-git-send-email-spujar@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1601573626; bh=KGVHwu7gz2uVTadbhaTYCpdQftlC5kySO8eaYF0Uy+k=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Type; b=fYUhqZEfnTADS7VXjUCEX/mFkoL/V4WT96/Hsx2evVoPrcLybnJFba3ISNLNlf7WU FnMTpnqun8xFjI3uVJi23uQ5ITpAkVfig+Fh9UK5HXzMM57j0zib40G5wWHOlt18Ij trZtM1py2HX8SMfwyVM5mGIg2N3lLMfVOIWhOe9GKnpwJNlT8Oo+GKrlqeOaFGSjIQ Ml3t6d0ZsZzx7E3uUefwAzqKIcWh6WVaXCZPk37uTzTBwjfU2UOJf9FUjFjk4MSvAE r06/nS0fX0dtHlwVTnfqW4iKDrzNDW4J8vUOMm/+AP1uzw6JJ7dzaRQovXi9GcY+Nb ajIa1X4fl2TlA== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As per the members exposed earlier in the series, audio graph driver is updated to make use of these. Functionally there is no change in behavior if these are not populated. So following changes are made as part of this. - Update 'dai_link->ops' for DPCM links if a custom 'snd_soc_ops' is defined by the vendor driver. - Consider 'force_dpcm' flag status when deciding if a DAI link needs to be treated as DPCM or not. In doing so the logic is moved to a separate inline function for a better readability. - Populate 'dpcm_selectable' flag which is then used to detect DPCM DAI links. Signed-off-by: Sameer Pujar Cc: Kuninori Morimoto --- sound/soc/generic/audio-graph-card.c | 40 ++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 0ba50be9..fb34e34 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -355,6 +355,11 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, snd_soc_dai_link_set_capabilities(dai_link); dai_link->ops = &graph_ops; + + /* Use custom snd_soc_ops callbacks if available */ + if (priv->ops) + dai_link->ops = priv->ops; + dai_link->init = asoc_simple_dai_init; out_put_node: @@ -439,6 +444,28 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, return 0; } +static inline bool parse_as_dpcm_link(struct asoc_simple_priv *priv, + struct device_node *codec_port, + struct asoc_simple_data *adata) +{ + if (priv->force_dpcm) + return true; + + if (!priv->dpcm_selectable) + return false; + + /* + * It is DPCM + * if Codec port has many endpoints, + * or has convert-xxx property + */ + if ((of_get_child_count(codec_port) > 1) || + (adata->convert_rate || adata->convert_channels)) + return true; + + return false; +} + static int graph_for_each_link(struct asoc_simple_priv *priv, struct link_info *li, int (*func_noml)(struct asoc_simple_priv *priv, @@ -459,7 +486,6 @@ static int graph_for_each_link(struct asoc_simple_priv *priv, struct device_node *codec_port; struct device_node *codec_port_old = NULL; struct asoc_simple_data adata; - uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev); int rc, ret; /* loop for all listed CPU port */ @@ -482,14 +508,8 @@ static int graph_for_each_link(struct asoc_simple_priv *priv, graph_parse_convert(dev, codec_ep, &adata); graph_parse_convert(dev, cpu_ep, &adata); - /* - * It is DPCM - * if Codec port has many endpoints, - * or has convert-xxx property - */ - if (dpcm_selectable && - ((of_get_child_count(codec_port) > 1) || - adata.convert_rate || adata.convert_channels)) + /* check if link requires DPCM parsing */ + if (parse_as_dpcm_link(priv, codec_port, &adata)) ret = func_dpcm(priv, cpu_ep, codec_ep, li, (codec_port_old == codec_port)); /* else normal sound */ @@ -678,6 +698,8 @@ static int graph_probe(struct platform_device *pdev) card->num_dapm_widgets = ARRAY_SIZE(graph_dapm_widgets); card->probe = graph_card_probe; + priv->dpcm_selectable = (uintptr_t)of_device_get_match_data(dev); + memset(&li, 0, sizeof(li)); graph_get_dais_count(priv, &li); if (!li.link || !li.dais) -- 2.7.4