Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3372068pxx; Mon, 2 Nov 2020 07:15:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwPxDkADwvHlusPrii1Z95VdDtbss2w9nDrp456wyQV3fGhoVsI48tBwT0ZGgxui/Lf4jj X-Received: by 2002:a50:be8f:: with SMTP id b15mr16705526edk.180.1604330106355; Mon, 02 Nov 2020 07:15:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604330106; cv=none; d=google.com; s=arc-20160816; b=IFBFUGTY6mMQl+h+lkdX18Vn/u6zpx7NArgsWHMpspFTndc94f2p2/yMLCEBVrQAw7 QJipzAb+Nt6S5AxJQoLRuSlrHTTTpF7+qM1/yPOu/33XRLa28qt//QViBigq6xiYG7N7 TtlcVh8Eco0zdfOM5FwRK5AFYtE94GXsJei9iiI8mtsntMHMwiSqiptRVfzCXvO356wi XuApaHjYnuxyWaRIjXikjsmR9SQSYFn3euzLRP5TM8ud8F8Jg6YRfxE/guyWLfyhmT8x xGOHRFgFZx8PMTtFrQiY9qWRqONRzyjWxPA5jDX8NHVkJ3CLsupPSryFjbCF8RemGZLG sF/Q== 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=NXU8XQwjRWZ/2sG+RWIF67eZnui/M+pQ/b5OeUa57ks=; b=xy5paRxPuzg2MtJIiiAX7hSF9kD/uBOQT5GO0Ujc2yUUEcpDD34SVwlt3DbjK29qfM gmyf7/5zJbC8Jgjl96bpJv1jz1buBshciQmRl7OvOoV3QM2aMw8GIF3lIgS9jsJJF1Xx Lhf5cGjOD263013DledVuEmVChtEqNJHv7h7k3LXkNl5N7Ap0QWPEs9+651WUxYYIXFF jPcme0Iqp4wR42B8KD4SYpiaBKPgVNfug9yypYoil9+K4H9nLFZy1iIQ4y294f2lunHk AVadr0WAQSJYe0JP15T05BQ8Na/k7D3X9myVuh05UD9oikciH/aTIQoo7MC2p4ZIdx1J Q7cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=cIO5+jTj; 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 h8si12898216ejj.258.2020.11.02.07.14.43; Mon, 02 Nov 2020 07:15:06 -0800 (PST) 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=cIO5+jTj; 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 S1726456AbgKBPLr (ORCPT + 99 others); Mon, 2 Nov 2020 10:11:47 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:7830 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbgKBPLq (ORCPT ); Mon, 2 Nov 2020 10:11:46 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 02 Nov 2020 07:11:56 -0800 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 2 Nov 2020 15:11:40 +0000 Received: from audio.nvidia.com (10.124.1.5) by mail.nvidia.com (172.20.187.12) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Mon, 2 Nov 2020 15:11:37 +0000 From: Sameer Pujar To: , , , , , CC: , , , , , , Sameer Pujar Subject: [PATCH v5 6/7] ASoC: audio-graph: Expose new members for asoc_simple_priv Date: Mon, 2 Nov 2020 20:40:13 +0530 Message-ID: <1604329814-24779-7-git-send-email-spujar@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604329814-24779-1-git-send-email-spujar@nvidia.com> References: <1604329814-24779-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=1604329916; bh=NXU8XQwjRWZ/2sG+RWIF67eZnui/M+pQ/b5OeUa57ks=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Type; b=cIO5+jTj/JJrY4m33IEpY6HFu4zPXuxmWFV0YixAl1gm4313mJ5VP09Q0FvE/Jfg4 WdDa0wtPSNdliSm7+4bVcCQOpxhGVBQ4a/I1RhYxyviNO9ZMME1CGj3NCr8x5TOqVi LMOavRItwEB3mQXMfyAcKf+pVAUPkcw/gyMoFlwjWjT1Ty//S8SjBungFrdpMK1aLD W1hwjNuljxsHkCptHSSQ860pK7bt15bOvMxOOfaKgP4Bh5f+he4Lg0vcJ7H3f6I0Fx 0PGtRuNHpxZY8HU76zajBXl3Bqln704v4rRBFqUmFmo82y0TpXoFOuYZ0CvtfUVGr0 7vrSLv06ltuHw== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add new members in struct 'asoc_simple_priv'. Idea is to leverage simple or graph card driver as much as possible and vendor can maintain a thin driver to control the behavior by populating these newly exposed members. Following are the members added in 'asoc_simple_priv': - 'ops' struct: In some cases SoC vendor drivers may want to implement 'snd_soc_ops' callbacks differently. In such cases custom callbacks would be used. - 'force_dpcm' flag: Right now simple or graph card drivers detect DAI links as DPCM links if: * The dpcm_selectable is set AND * Codec is connected to multiple CPU endpoints or aconvert property is used for rate/channels. So there is no way to directly specify usage of DPCM alone. So a flag is exposed to mark all links as DPCM. Vendor driver can set this if required. - 'dpcm_selectable': Currently simple or audio graph drivers provide a way to enable this for specific compatibles. However vendor driver may want to define some additional info. Thus expose this variable where vendor drivers can set this if required. Audio graph driver is updated to consider above flags or callbacks. Subsequent patches in the series illustrate usage for above. Signed-off-by: Sameer Pujar Cc: Kuninori Morimoto --- include/sound/simple_card_utils.h | 3 +++ sound/soc/generic/audio-graph-card.c | 41 ++++++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 86a1e95..ba4a3e1 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -56,6 +56,9 @@ struct asoc_simple_priv { struct asoc_simple_dai *dais; struct snd_soc_codec_conf *codec_conf; struct gpio_desc *pa_gpio; + const struct snd_soc_ops *ops; + unsigned int dpcm_selectable:1; + unsigned int force_dpcm:1; }; #define simple_priv_to_card(priv) (&(priv)->snd_card) #define simple_priv_to_props(priv, i) ((priv)->dai_props + (i)) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 0ba50be9..4db9c0e 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,9 @@ static int graph_probe(struct platform_device *pdev) card->num_dapm_widgets = ARRAY_SIZE(graph_dapm_widgets); card->probe = graph_card_probe; + if (of_device_get_match_data(dev)) + priv->dpcm_selectable = 1; + memset(&li, 0, sizeof(li)); graph_get_dais_count(priv, &li); if (!li.link || !li.dais) -- 2.7.4