lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87362xkxdv.wl-kuninori.morimoto.gx@renesas.com>
Date:   02 Oct 2020 14:34:09 +0900
From:   Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
To:     Sameer Pujar <spujar@...dia.com>
Cc:     <broonie@...nel.org>, <lgirdwood@...il.com>, <robh+dt@...nel.org>,
        <pierre-louis.bossart@...ux.intel.com>, <perex@...ex.cz>,
        <tiwai@...e.com>, <thierry.reding@...il.com>,
        <jonathanh@...dia.com>, <alsa-devel@...a-project.org>,
        <devicetree@...r.kernel.org>, <linux-tegra@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <sharadg@...dia.com>,
        <mkumard@...dia.com>, <viswanathl@...dia.com>,
        <rlokhande@...dia.com>, <dramesh@...dia.com>,
        <atalambedu@...dia.com>, <nwartikar@...dia.com>,
        <swarren@...dia.com>, <nicoleotsuka@...il.com>
Subject: Re: [PATCH v3 10/13] ASoC: tegra: Add audio graph based card driver


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ