Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1b1a7a5 authored by Vidyakumar Athota's avatar Vidyakumar Athota
Browse files

ASoC: msm: Add stub rx and stub tx dais



Modify Stub dai as stub rx and stub tx based on stub dai
definition. This change is required in kernel 3.10 because
two cpu dais should not have same name eventhough all
the stub dais are funcationally same

Change-Id: Iaf0945e056ee0f377559b4a506e34916c3a9a755
Signed-off-by: default avatarVidyakumar Athota <vathota@codeaurora.org>
parent 557127c1
Loading
Loading
Loading
Loading
+12 −3
Original line number Original line Diff line number Diff line
@@ -86,11 +86,20 @@ Required properties:


* msm-dai-stub
* msm-dai-stub


[First Level Nodes]

Required properties:

 - compatible : "msm-dai-stub"

[Second Level Nodes]

Required properties:
Required properties:


 - compatible : "qcom,msm-dai-stub"
 - compatible : "qcom,msm-dai-stub-dev"
 - qcom,msm-dai-stub : This enables stub CPU dai in Audio.
 - qcom,msm-dai-stub-dev-id : Stub dai port ID value is from 0 to 3.
   The stub dai is used when there is no real backend in Audio.
   This enables stub CPU dai in Audio. The stub dai is used when
   there is no real backend in Audio.


* msm-dai-q6-hdmi
* msm-dai-q6-hdmi


+179 −23
Original line number Original line Diff line number Diff line
@@ -12,11 +12,19 @@
#include <linux/init.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/device.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/platform_device.h>
#include <sound/core.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/soc.h>


enum {
	STUB_RX,
	STUB_TX,
	STUB_1_RX,
	STUB_1_TX,
};

static int msm_dai_stub_set_channel_map(struct snd_soc_dai *dai,
static int msm_dai_stub_set_channel_map(struct snd_soc_dai *dai,
		unsigned int tx_num, unsigned int *tx_slot,
		unsigned int tx_num, unsigned int *tx_slot,
		unsigned int rx_num, unsigned int *rx_slot)
		unsigned int rx_num, unsigned int *rx_slot)
@@ -30,8 +38,71 @@ static struct snd_soc_dai_ops msm_dai_stub_ops = {
	.set_channel_map = msm_dai_stub_set_channel_map,
	.set_channel_map = msm_dai_stub_set_channel_map,
};
};


static struct snd_soc_dai_driver msm_dai_stub_dai = {
static int msm_dai_stub_add_route(struct snd_soc_dai *dai)
{
	struct snd_soc_dapm_route intercon;

	if (!dai || !dai->driver) {
		pr_err("%s Invalid params\n", __func__);
		return -EINVAL;
	}
	memset(&intercon, 0 , sizeof(intercon));
	if (dai->driver->playback.stream_name &&
		dai->driver->playback.aif_name) {
		dev_dbg(dai->dev, "%s add route for widget %s",
			__func__, dai->driver->playback.stream_name);
		intercon.source = dai->driver->playback.aif_name;
		intercon.sink = dai->driver->playback.stream_name;
		dev_dbg(dai->dev, "%s src %s sink %s\n",
			__func__, intercon.source, intercon.sink);
		snd_soc_dapm_add_routes(&dai->dapm, &intercon, 1);
	}
	if (dai->driver->capture.stream_name &&
		dai->driver->capture.aif_name) {
		dev_dbg(dai->dev, "%s add route for widget %s",
			__func__, dai->driver->capture.stream_name);
		intercon.sink = dai->driver->capture.aif_name;
		intercon.source = dai->driver->capture.stream_name;
		dev_dbg(dai->dev, "%s src %s sink %s\n",
			__func__, intercon.source, intercon.sink);
		snd_soc_dapm_add_routes(&dai->dapm, &intercon, 1);
	}
	return 0;
}

static int msm_dai_stub_dai_probe(struct snd_soc_dai *dai)
{
	return msm_dai_stub_add_route(dai);
}

static int msm_dai_stub_dai_remove(struct snd_soc_dai *dai)
{
	pr_debug("%s:\n", __func__);
	return 0;
}

static struct snd_soc_dai_driver msm_dai_stub_dai_rx = {
	.playback = {
	.playback = {
		.stream_name = "Stub Playback",
		.aif_name = "STUB_RX",
		.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
			SNDRV_PCM_RATE_16000,
		.formats = SNDRV_PCM_FMTBIT_S16_LE,
		.channels_min = 1,
		.channels_max = 2,
		.rate_min = 8000,
		.rate_max = 48000,
	},
	.ops = &msm_dai_stub_ops,
	.probe = &msm_dai_stub_dai_probe,
	.remove = &msm_dai_stub_dai_remove,
};

static struct snd_soc_dai_driver msm_dai_stub_dai_tx[] = {
	{
		.capture = {
			.stream_name = "Stub Capture",
			.aif_name = "STUB_TX",
			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
				SNDRV_PCM_RATE_16000,
				SNDRV_PCM_RATE_16000,
			.formats = SNDRV_PCM_FMTBIT_S16_LE,
			.formats = SNDRV_PCM_FMTBIT_S16_LE,
@@ -40,7 +111,14 @@ static struct snd_soc_dai_driver msm_dai_stub_dai = {
			.rate_min = 8000,
			.rate_min = 8000,
			.rate_max = 48000,
			.rate_max = 48000,
		},
		},
		.ops = &msm_dai_stub_ops,
		.probe = &msm_dai_stub_dai_probe,
		.remove = &msm_dai_stub_dai_remove,
	},
	{
		.capture = {
		.capture = {
			.stream_name = "Stub1 Capture",
			.aif_name = "STUB_1_TX",
			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
			.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
				SNDRV_PCM_RATE_16000,
				SNDRV_PCM_RATE_16000,
			.formats = SNDRV_PCM_FMTBIT_S16_LE,
			.formats = SNDRV_PCM_FMTBIT_S16_LE,
@@ -50,33 +128,92 @@ static struct snd_soc_dai_driver msm_dai_stub_dai = {
			.rate_max = 48000,
			.rate_max = 48000,
		},
		},
		.ops = &msm_dai_stub_ops,
		.ops = &msm_dai_stub_ops,
		.probe = &msm_dai_stub_dai_probe,
		.remove = &msm_dai_stub_dai_remove,
	}
};
};


static const struct snd_soc_component_driver msm_dai_stub_component = {
static const struct snd_soc_component_driver msm_dai_stub_component = {
	.name		= "msm-dai-stub",
	.name		= "msm-dai-stub-dev",
};
};



static int msm_dai_stub_dev_probe(struct platform_device *pdev)
static int msm_dai_stub_dev_probe(struct platform_device *pdev)
{
{
	int rc = 0;
	int rc, id = -1;
	const char *stub_dev_id = "qcom,msm-dai-stub-dev-id";


	dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
	rc = of_property_read_u32(pdev->dev.of_node, stub_dev_id, &id);
	if (rc) {
		dev_err(&pdev->dev,
			"%s: missing %s in dt node\n", __func__, stub_dev_id);
		return rc;
	}

	pdev->id = id;
	dev_set_name(&pdev->dev, "%s.%d", "msm-dai-stub-dev", id);


	if (pdev->dev.of_node)
	pr_debug("%s: dev name %s, id:%d\n", __func__,
			dev_set_name(&pdev->dev, "%s", "msm-dai-stub");
		 dev_name(&pdev->dev), pdev->id);
	pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));


	switch (id) {
	case STUB_RX:
		rc = snd_soc_register_component(&pdev->dev,
		rc = snd_soc_register_component(&pdev->dev,
		&msm_dai_stub_component, &msm_dai_stub_dai, 1);
			&msm_dai_stub_component, &msm_dai_stub_dai_rx, 1);
		break;
	case STUB_TX:
		rc = snd_soc_register_component(&pdev->dev,
			&msm_dai_stub_component, &msm_dai_stub_dai_tx[0], 1);
		break;
	case STUB_1_TX:
		rc = snd_soc_register_component(&pdev->dev,
			&msm_dai_stub_component, &msm_dai_stub_dai_tx[1], 1);
		break;
	}

	return rc;
	return rc;
}
}


static int msm_dai_stub_dev_remove(struct platform_device *pdev)
static int msm_dai_stub_dev_remove(struct platform_device *pdev)
{
{
	pr_debug("%s:\n", __func__);

	snd_soc_unregister_component(&pdev->dev);
	snd_soc_unregister_component(&pdev->dev);
	return 0;
}

static const struct of_device_id msm_dai_stub_dev_dt_match[] = {
	{ .compatible = "qcom,msm-dai-stub-dev", },
	{ }
};
MODULE_DEVICE_TABLE(of, msm_dai_stub_dev_dt_match);

static struct platform_driver msm_dai_stub_dev = {
	.probe  = msm_dai_stub_dev_probe,
	.remove = msm_dai_stub_dev_remove,
	.driver = {
		.name = "msm-dai-stub-dev",
		.owner = THIS_MODULE,
		.of_match_table = msm_dai_stub_dev_dt_match,
	},
};

static int msm_dai_stub_probe(struct platform_device *pdev)
{
	int rc = 0;

	dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));

	rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
	if (rc) {
		dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
			__func__, rc);
	} else
		dev_dbg(&pdev->dev, "%s: added child node\n", __func__);

	return rc;
}

static int msm_dai_stub_remove(struct platform_device *pdev)
{
	pr_debug("%s:\n", __func__);


	return 0;
	return 0;
}
}
@@ -90,8 +227,8 @@ MODULE_DEVICE_TABLE(of, msm_dai_stub_dt_match);




static struct platform_driver msm_dai_stub_driver = {
static struct platform_driver msm_dai_stub_driver = {
	.probe  = msm_dai_stub_dev_probe,
	.probe  = msm_dai_stub_probe,
	.remove = msm_dai_stub_dev_remove,
	.remove = msm_dai_stub_remove,
	.driver = {
	.driver = {
		.name = "msm-dai-stub",
		.name = "msm-dai-stub",
		.owner = THIS_MODULE,
		.owner = THIS_MODULE,
@@ -101,9 +238,27 @@ static struct platform_driver msm_dai_stub_driver = {


static int __init msm_dai_stub_init(void)
static int __init msm_dai_stub_init(void)
{
{
	int rc = 0;

	pr_debug("%s:\n", __func__);
	pr_debug("%s:\n", __func__);


	return platform_driver_register(&msm_dai_stub_driver);
	rc = platform_driver_register(&msm_dai_stub_driver);
	if (rc) {
		pr_err("%s: fail to register dai q6 driver", __func__);
		goto fail;
	}

	rc = platform_driver_register(&msm_dai_stub_dev);
	if (rc) {
		pr_err("%s: fail to register dai q6 dev driver", __func__);
		goto dai_stub_dev_fail;
	}
	return rc;

dai_stub_dev_fail:
	platform_driver_unregister(&msm_dai_stub_driver);
fail:
	return rc;
}
}
module_init(msm_dai_stub_init);
module_init(msm_dai_stub_init);


@@ -111,6 +266,7 @@ static void __exit msm_dai_stub_exit(void)
{
{
	pr_debug("%s:\n", __func__);
	pr_debug("%s:\n", __func__);


	platform_driver_unregister(&msm_dai_stub_dev);
	platform_driver_unregister(&msm_dai_stub_driver);
	platform_driver_unregister(&msm_dai_stub_driver);
}
}
module_exit(msm_dai_stub_exit);
module_exit(msm_dai_stub_exit);