Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1042709pxk; Thu, 1 Oct 2020 22:36:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxtpEFhrF2RB2JkxgXMQhprCRitGPaDOBRA2lGklQ87Lu58KTzAvwRcdbNx2ZOeu9TvZcu X-Received: by 2002:a50:fb98:: with SMTP id e24mr523302edq.130.1601616986050; Thu, 01 Oct 2020 22:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601616986; cv=none; d=google.com; s=arc-20160816; b=lXSbPcWKiswedK3fx5+7wbr0maS+tU6uQ0KDKymlv3IZCpnonatGAq7jdW38Vzoaw+ sXrjJ2aq9RWNVGcFHEpU4nZGLxkrth7DoeeJ48SQfKuSzMopHc+dnRjP7Oxgy6ATBdbj n9cv2hTUOqBGoLgVQZkCTbBqDf0jyfcdoolC+lnyoEQPaz2xHDHr8uAG1+Ac17fbX5Sl RInsLzFb+deZiSGjvVUcXDmLfH6/92jw8akHqXsLxMK960ClRBzVcfCdYQqVu5hkVqEt hsaMH5fzN0aiuTpd1AZf6BMk3kCDiB8N3O2q+Zv+U7jX8fCoo/6nVJuAMjEYTj4wFyXR wSWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=zPJqkPxpLyCoVN4oamA/A7uh6uVNPxsviAXvBxtVMh8=; b=ZYGt+mi7Q/OXSkAEXExcuQcQ/ABvRW3yk5azlZJgW4Do520+cSujyony6sewH7l8bb /6p09wCUwNapeEdEbyiOuU8qPCRB9RDSdVJI1NUxUJ+9Z2W74pBC6/ZW6araqp5k39L8 hXgtpzg5MTWSWDnxyhQH+qfGO5TnyIoKJ1vptJartqihZwYACTLSE4Ug6a/PGf4ixTnT x/FMUPQfuS4L9O09LP3XEltfJrOENPfXiRw2ah6BtHxzC2fnYIgJ1b73oHSFahcD9zlo 077LC6FPngZV9+Z37l3qWPP50ut4ks7bXeFsX8PuDFYchwWNq3Q8/Y4x4Xge1XGydE53 6Xqg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v10si307234ejx.195.2020.10.01.22.36.00; Thu, 01 Oct 2020 22:36:26 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725991AbgJBFeL (ORCPT + 99 others); Fri, 2 Oct 2020 01:34:11 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:18592 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725926AbgJBFeK (ORCPT ); Fri, 2 Oct 2020 01:34:10 -0400 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 Cc: , , , , , , , , , , , , , , , , , , , , 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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