From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 096DEC4363D for ; Fri, 2 Oct 2020 05:35:21 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7DA22206A5 for ; Fri, 2 Oct 2020 05:35:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="stb7BTNz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7DA22206A5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A43251B16; Fri, 2 Oct 2020 07:34:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A43251B16 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1601616917; bh=O08fwH6kHG2ri3o9tQtKUHUpIO/LccQcRyNsUvDBvao=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=stb7BTNzjXV1cjX6TMItDiAoKk0mCpc4eqwPpa6w9W8jiJKSD67J3sO/vF2yyrY9j r5OfPqGwQKlyn7CPYnML5Zx4fF+MgaSNAyDDuGCTWZBdmQ5/dfnUpPY7eNyflZOSAz WaqMmXyF835QkXHAOWRKYd1GsSx3hAJpSPK0XwsA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0E810F801ED; Fri, 2 Oct 2020 07:34:27 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E1705F801F9; Fri, 2 Oct 2020 07:34:24 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id EA0B8F800E5 for ; Fri, 2 Oct 2020 07:34:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EA0B8F800E5 Date: 02 Oct 2020 14:34:09 +0900 X-IronPort-AV: E=Sophos;i="5.77,326,1596466800"; d="scan'208";a="58517478" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 02 Oct 2020 14:34:09 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id D5B8D4000A97; Fri, 2 Oct 2020 14:34:08 +0900 (JST) Message-ID: <87362xkxdv.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Sameer Pujar Subject: Re: [PATCH v3 10/13] ASoC: tegra: Add audio graph based card driver In-Reply-To: <1601573587-15288-11-git-send-email-spujar@nvidia.com> References: <1601573587-15288-1-git-send-email-spujar@nvidia.com> <1601573587-15288-11-git-send-email-spujar@nvidia.com> User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, atalambedu@nvidia.com, swarren@nvidia.com, lgirdwood@gmail.com, nicoleotsuka@gmail.com, linux-kernel@vger.kernel.org, nwartikar@nvidia.com, tiwai@suse.com, robh+dt@kernel.org, viswanathl@nvidia.com, sharadg@nvidia.com, devicetree@vger.kernel.org, broonie@kernel.org, thierry.reding@gmail.com, linux-tegra@vger.kernel.org, jonathanh@nvidia.com, rlokhande@nvidia.com, mkumard@nvidia.com, dramesh@nvidia.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Hi Sameer > Add Tegra audio machine driver which is based on generic audio graph card > driver. It re-uses most of the common stuff from audio graph driver and > uses the same DT binding. Required Tegra specific customizations are done > in the driver. (snip) > +static const struct snd_soc_ops tegra_audio_graph_ops = { > + .startup = asoc_simple_startup, > + .shutdown = asoc_simple_shutdown, > + .hw_params = tegra_audio_graph_hw_params, > +}; This is just an idea, but can we use hooks here somehow ? .ops_hook_pre .ops_hook_func .ops_hook_post if (priv->ops_hook_pre->func) priv->ops_hook_pre->func_pre(...); if (priv->ops_hook_func->func) priv->ops_hook_func->func(...); /* driver's function */ else graph_func(...); /* audio-graph function */ if (priv->ops_hook_post->func) priv->ops_hook_post->func(...); > +static int tegra_audio_graph_probe(struct platform_device *pdev) > +{ > + struct asoc_simple_priv *priv; > + struct device *dev = &pdev->dev; > + struct snd_soc_card *card; > + struct link_info li; > + int err; > + > + /* Allocate the private data and the DAI link array */ > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + priv->data = (struct tegra_audio_graph_data *) > + devm_kzalloc(dev, sizeof(*priv->data), GFP_KERNEL); > + if (!priv->data) > + return -ENOMEM; > + > + card = simple_priv_to_card(priv); > + > + card->owner = THIS_MODULE; > + card->dev = dev; > + card->component_chaining = true; > + card->probe = tegra_audio_graph_card_probe; > + > + priv->ops = &tegra_audio_graph_ops; > + priv->force_dpcm = 1; > + > + memset(&li, 0, sizeof(li)); > + graph_get_dais_count(priv, &li); > + if (!li.link || !li.dais) > + return -EINVAL; > + > + err = asoc_simple_init_priv(priv, &li); > + if (err < 0) > + return err; > + > + err = graph_parse_of(priv); > + if (err < 0) { > + if (err != -EPROBE_DEFER) > + dev_err(dev, "Parse error %d\n", err); > + goto cleanup; > + } > + > + snd_soc_card_set_drvdata(card, priv); > + > + asoc_simple_debug_info(priv); > + > + err = devm_snd_soc_register_card(dev, card); > + if (err < 0) > + goto cleanup; > + > + return 0; > + > +cleanup: > + asoc_simple_clean_reference(card); > + > + return err; > +} These are almost same as graph_probe(). Maybe we can separate graph_probe() and export function ? struct tegra_audio_graph_data { struct asoc_simple_priv simple; ... }; #define simple_to_priv(_simple) container_of((_simple), struct my_priv, simple) static int tegra_audio_graph_probe(struct platform_device *pdev) { struct tegra_audio_graph_data *data; struct asoc_simple_priv *priv; /* Allocate the private data */ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; /* initial audio-graph */ ret = audio_graph_init(priv, pdev); if (ret < 0) return -xxx; /* over-write for own settings */ card = simple_priv_to_card(priv); card->component_chaining = true; card->probe = tegra_audio_graph_card_probe; priv = &data->simple; priv->ops_hook_pre = &tegra_audio_graph_ops; priv->force_dpcm = 1; /* audio-graph remain */ return audio_graph_prove(priv, pdev); } Thank you for your help !! Best regards --- Kuninori Morimoto