msm: Add device tree support for audio drivers
Add device tree support to sound soc audio drivers.
These drivers get registered to the alsa framework
and thus aid detection of soundcard.
Change the device tree entries to follow the new
design approach of having individual probe functions
for each audio interface.
Change-Id: Ie8f0bddd5ba6e2cfb66c6a23efdcb434c5082d7d
Signed-off-by: Phani Kumar Uppalapati <phanik@codeaurora.org>
diff --git a/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt b/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
new file mode 100644
index 0000000..b6086e7
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
@@ -0,0 +1,135 @@
+Qualcomm audio devices for ALSA sound soc
+
+* msm-pcm
+
+Required properties:
+
+ - compatible : "qcom,msm-pcm-dsp"
+
+* msm-pcm-routing
+
+Required properties:
+
+ - compatible : "qcom,msm-pcm-routing"
+
+* msm-pcm-lpa
+
+Required properties:
+
+ - compatible : "qcom,msm-pcm-lpa"
+
+* msm-voip-dsp
+
+Required properties:
+
+ - compatible : "qcom,msm-voip-dsp"
+
+* msm-stub-codec
+
+Required properties:
+
+ - compatible : "qcom,msm-stub-codec"
+
+* msm-dai-fe
+
+Required properties:
+
+ - compatible : "qcom,msm-dai-fe"
+
+* msm-auxpcm
+
+[First Level Nodes]
+
+Required properties:
+
+ - compatible : "qcom,msm-auxpcm-resource"
+
+ - qcom,msm-cpudai-auxpcm-clk: clock for auxpcm
+
+ - qcom,msm-cpudai-auxpcm-mode: mode information
+ 0 - for PCM
+
+ - qcom,msm-cpudai-auxpcm-sync: sync information
+
+ - qcom,msm-cpudai-auxpcm-frame: No.of bytes per frame
+ 5 - 256BPF
+
+ - qcom,msm-cpudai-auxpcm-quant: Type of quantization
+ 2 - Linear quantization
+
+ - qcom,msm-cpudai-auxpcm-slot: Slot number for multichannel scenario
+ Value is 1
+
+ - qcom,msm-cpudai-auxpcm-data: Data field - 0
+
+ - qcom,msm-cpudai-auxpcm-pcm-clk-rate: Clock rate for pcm - 2048000
+
+[Second Level Nodes]
+
+Required Properties:
+
+ - qcom,msm-auxpcm-dev-id: This property specifies the device
+ port id.
+ For Rx device, the port id is 4106
+ and for Tx device, the port id is 4107
+
+ - compatible: "qcom,msm-auxpcm-dev"
+
+* msm-pcm-hostless
+
+Required properties:
+
+ - compatible : "qcom,msm-pcm-hostless"
+
+Example:
+
+ qcom,msm-pcm {
+ compatible = "qcom,msm-pcm-dsp";
+ };
+
+ qcom,msm-pcm-routing {
+ compatible = "qcom,msm-pcm-routing";
+ };
+
+ qcom,msm-pcm-lpa {
+ compatible = "qcom,msm-pcm-lpa";
+ };
+
+ qcom,msm-voip-dsp {
+ compatible = "qcom,msm-voip-dsp";
+ };
+
+ qcom,msm-stub-codec {
+ compatible = "qcom,msm-stub-codec";
+ };
+
+ qcom,msm-dai-fe {
+ compatible = "qcom,msm-dai-fe";
+ };
+
+ qcom,msm-auxpcm {
+ compatible = "qcom,msm-auxpcm-resource";
+ qcom,msm-cpudai-auxpcm-clk = "pcm_clk";
+ qcom,msm-cpudai-auxpcm-mode = <0>;
+ qcom,msm-cpudai-auxpcm-sync = <1>;
+ qcom,msm-cpudai-auxpcm-frame = <5>;
+ qcom,msm-cpudai-auxpcm-quant = <2>;
+ qcom,msm-cpudai-auxpcm-slot = <1>;
+ qcom,msm-cpudai-auxpcm-data = <0>;
+ qcom,msm-cpudai-auxpcm-pcm-clk-rate = <2048000>;
+
+ qcom,msm-auxpcm-rx {
+ qcom,msm-auxpcm-dev-id = <4106>;
+ compatible = "qcom,msm-auxpcm-dev";
+ };
+
+ qcom,msm-auxpcm-tx {
+ qcom,msm-auxpcm-dev-id = <4107>;
+ compatible = "qcom,msm-auxpcm-dev";
+ };
+ };
+
+ qcom,msm-pcm-hostless {
+ compatible = "qcom,msm-pcm-hostless";
+ };
+
diff --git a/arch/arm/boot/dts/msm8974.dtsi b/arch/arm/boot/dts/msm8974.dtsi
index 2c19a80..5205a9c 100644
--- a/arch/arm/boot/dts/msm8974.dtsi
+++ b/arch/arm/boot/dts/msm8974.dtsi
@@ -342,52 +342,55 @@
qcom,firmware-name = "adsp";
};
- qcom,msm-pcm {
- compatible = "qcom,msm-pcm-dsp";
- };
+ qcom,msm-pcm {
+ compatible = "qcom,msm-pcm-dsp";
+ };
- qcom,msm-pcm-routing {
- compatible = "qcom,msm-pcm-routing";
- };
+ qcom,msm-pcm-routing {
+ compatible = "qcom,msm-pcm-routing";
+ };
- qcom,msm-pcm-lpa {
- compatible = "qcom,msm-pcm-lpa";
- };
+ qcom,msm-pcm-lpa {
+ compatible = "qcom,msm-pcm-lpa";
+ };
- qcom,msm-voip-dsp {
- compatible = "qcom,msm-voip-dsp";
- };
+ qcom,msm-voip-dsp {
+ compatible = "qcom,msm-voip-dsp";
+ };
- qcom,msm-stub-codec {
- compatible = "qcom,msm-stub-codec";
- };
+ qcom,msm-stub-codec {
+ compatible = "qcom,msm-stub-codec";
+ };
- qcom,msm-dai-fe {
- compatible = "qcom,msm-dai-fe";
- };
+ qcom,msm-dai-fe {
+ compatible = "qcom,msm-dai-fe";
+ };
- qcom,msm-dai-q6 {
- compatible = "qcom,msm-dai-q6";
- qcom,msm-cpudai-auxpcm-clk = "pcm_clk";
- qcom,msm-cpudai-auxpcm-mode = <0>;
- qcom,msm-cpudai-auxpcm-sync = <1>;
- qcom,msm-cpudai-auxpcm-frame = <5>;
- qcom,msm-cpudai-auxpcm-quant = <2>;
- qcom,msm-cpudai-auxpcm-slot = <1>;
- qcom,msm-cpudai-auxpcm-data = <0>;
- qcom,msm-cpudai-auxpcm-pcm-clk-rate = <2048000>;
+ qcom,msm-auxpcm {
+ compatible = "qcom,msm-auxpcm-resource";
+ qcom,msm-cpudai-auxpcm-clk = "pcm_clk";
+ qcom,msm-cpudai-auxpcm-mode = <0>;
+ qcom,msm-cpudai-auxpcm-sync = <1>;
+ qcom,msm-cpudai-auxpcm-frame = <5>;
+ qcom,msm-cpudai-auxpcm-quant = <2>;
+ qcom,msm-cpudai-auxpcm-slot = <1>;
+ qcom,msm-cpudai-auxpcm-data = <0>;
+ qcom,msm-cpudai-auxpcm-pcm-clk-rate = <2048000>;
- qcom,msm-dai-q6-rx {
- qcom,msm-dai-q6-id = <4106>;
- };
- qcom,msm-dai-q6-tx {
- qcom,msm-dai-q6-id = <4107>;
- };
- };
+ qcom,msm-auxpcm-rx {
+ qcom,msm-auxpcm-dev-id = <4106>;
+ compatible = "qcom,msm-auxpcm-dev";
+ };
- qcom,msm-pcm-hostless {
- compatible = "qcom,msm-pcm-hostless";
- };
+ qcom,msm-auxpcm-tx {
+ qcom,msm-auxpcm-dev-id = <4107>;
+ compatible = "qcom,msm-auxpcm-dev";
+ };
+ };
+
+ qcom,msm-pcm-hostless {
+ compatible = "qcom,msm-pcm-hostless";
+ };
qcom,mss@fc880000 {
compatible = "qcom,pil-q6v5-mss";
diff --git a/sound/soc/codecs/msm_stub.c b/sound/soc/codecs/msm_stub.c
index 0a3157f..7e603b4 100644
--- a/sound/soc/codecs/msm_stub.c
+++ b/sound/soc/codecs/msm_stub.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -12,6 +12,7 @@
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
@@ -44,6 +45,11 @@
static int __devinit msm_stub_dev_probe(struct platform_device *pdev)
{
+ if (pdev->dev.of_node)
+ dev_set_name(&pdev->dev, "%s.%d", "msm-stub-codec", 1);
+
+ dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
+
return snd_soc_register_codec(&pdev->dev,
&soc_msm_stub, msm_stub_dais, ARRAY_SIZE(msm_stub_dais));
}
@@ -53,11 +59,16 @@
snd_soc_unregister_codec(&pdev->dev);
return 0;
}
+static const struct of_device_id msm_stub_codec_dt_match[] = {
+ { .compatible = "qcom,msm-stub-codec", },
+ {}
+};
static struct platform_driver msm_stub_driver = {
.driver = {
.name = "msm-stub-codec",
.owner = THIS_MODULE,
+ .of_match_table = msm_stub_codec_dt_match,
},
.probe = msm_stub_dev_probe,
.remove = __devexit_p(msm_stub_dev_remove),
diff --git a/sound/soc/msm/msm-dai-fe.c b/sound/soc/msm/msm-dai-fe.c
index 210cfa9..4cd4a2c 100644
--- a/sound/soc/msm/msm-dai-fe.c
+++ b/sound/soc/msm/msm-dai-fe.c
@@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/device.h>
#include <linux/platform_device.h>
+#include <linux/of_device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
@@ -469,8 +470,11 @@
static __devinit int msm_fe_dai_dev_probe(struct platform_device *pdev)
{
+ if (pdev->dev.of_node)
+ dev_set_name(&pdev->dev, "%s", "msm-dai-fe");
+
dev_dbg(&pdev->dev, "%s: dev name %s\n", __func__,
- dev_name(&pdev->dev));
+ dev_name(&pdev->dev));
return snd_soc_register_dais(&pdev->dev, msm_fe_dais,
ARRAY_SIZE(msm_fe_dais));
}
@@ -481,12 +485,18 @@
return 0;
}
+static const struct of_device_id msm_dai_fe_dt_match[] = {
+ {.compatible = "qcom,msm-dai-fe"},
+ {}
+};
+
static struct platform_driver msm_fe_dai_driver = {
.probe = msm_fe_dai_dev_probe,
.remove = msm_fe_dai_dev_remove,
.driver = {
.name = "msm-dai-fe",
.owner = THIS_MODULE,
+ .of_match_table = msm_dai_fe_dt_match,
},
};
diff --git a/sound/soc/msm/msm-pcm-hostless.c b/sound/soc/msm/msm-pcm-hostless.c
index c61511d..c9b23d0 100644
--- a/sound/soc/msm/msm-pcm-hostless.c
+++ b/sound/soc/msm/msm-pcm-hostless.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -13,6 +13,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/platform_device.h>
+#include <linux/of_device.h>
#include <sound/core.h>
#include <sound/soc.h>
#include <sound/pcm.h>
@@ -25,6 +26,9 @@
static __devinit int msm_pcm_hostless_probe(struct platform_device *pdev)
{
+ if (pdev->dev.of_node)
+ dev_set_name(&pdev->dev, "%s", "msm-pcm-hostless");
+
pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
return snd_soc_register_platform(&pdev->dev,
&msm_soc_hostless_platform);
@@ -36,10 +40,16 @@
return 0;
}
+static const struct of_device_id msm_pcm_hostless_dt_match[] = {
+ {.compatible = "qcom,msm-pcm-hostless"},
+ {}
+};
+
static struct platform_driver msm_pcm_hostless_driver = {
.driver = {
.name = "msm-pcm-hostless",
.owner = THIS_MODULE,
+ .of_match_table = msm_pcm_hostless_dt_match,
},
.probe = msm_pcm_hostless_probe,
.remove = __devexit_p(msm_pcm_hostless_remove),
diff --git a/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c
index 1605062..783a03d 100644
--- a/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c
@@ -18,6 +18,7 @@
#include <linux/bitops.h>
#include <linux/slab.h>
#include <linux/clk.h>
+#include <linux/of_device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
@@ -42,239 +43,7 @@
static struct clk *pcm_clk;
static DEFINE_MUTEX(aux_pcm_mutex);
static int aux_pcm_count;
-static struct msm_dai_auxpcm_pdata *auxpcm_plat_data;
-static u8 num_of_bits_set(u8 sd_line_mask)
-{
- u8 num_bits_set = 0;
-
- while (sd_line_mask) {
- num_bits_set++;
- sd_line_mask = sd_line_mask & (sd_line_mask - 1);
- }
- return num_bits_set;
-}
-
-static int msm_dai_q6_cdc_hw_params(struct snd_pcm_hw_params *params,
- struct snd_soc_dai *dai, int stream)
-{
- struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
- dai_data->channels = params_channels(params);
- switch (dai_data->channels) {
- case 2:
- dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
- break;
- case 1:
- dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
- break;
- default:
- return -EINVAL;
- break;
- }
- dai_data->rate = params_rate(params);
- dai_data->port_config.i2s.sample_rate = dai_data->rate;
- dai_data->port_config.i2s.i2s_cfg_minor_version =
- AFE_API_VERSION_I2S_CONFIG;
- dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
- dev_dbg(dai->dev, " channel %d sample rate %d entered\n",
- dai_data->channels, dai_data->rate);
-
- /* Q6 only supports 16 as now */
- dai_data->port_config.i2s.bit_width = 16;
- dai_data->port_config.i2s.channel_mode = 1;
- return 0;
-}
-
-static int msm_dai_q6_i2s_hw_params(struct snd_pcm_hw_params *params,
- struct snd_soc_dai *dai, int stream)
-{
- struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
- struct msm_i2s_data *i2s_pdata =
- (struct msm_i2s_data *) dai->dev->platform_data;
-
- dai_data->channels = params_channels(params);
- if (num_of_bits_set(i2s_pdata->sd_lines) == 1) {
- switch (dai_data->channels) {
- case 2:
- dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
- break;
- case 1:
- dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
- break;
- default:
- pr_warn("greater than stereo has not been validated");
- break;
- }
- }
- dai_data->rate = params_rate(params);
- dai_data->port_config.i2s.sample_rate = dai_data->rate;
- dai_data->port_config.i2s.i2s_cfg_minor_version =
- AFE_API_VERSION_I2S_CONFIG;
- dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
- /* Q6 only supports 16 as now */
- dai_data->port_config.i2s.bit_width = 16;
- dai_data->port_config.i2s.channel_mode = 1;
-
- return 0;
-}
-
-static int msm_dai_q6_i2s_platform_data_validation(
- struct snd_soc_dai *dai)
-{
- u8 num_of_sd_lines;
- struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
- struct msm_i2s_data *i2s_pdata =
- (struct msm_i2s_data *)dai->dev->platform_data;
- struct snd_soc_dai_driver *dai_driver =
- (struct snd_soc_dai_driver *)dai->driver;
-
- num_of_sd_lines = num_of_bits_set(i2s_pdata->sd_lines);
-
- switch (num_of_sd_lines) {
- case 1:
- switch (i2s_pdata->sd_lines) {
- case MSM_MI2S_SD0:
- dai_data->port_config.i2s.channel_mode =
- AFE_PORT_I2S_SD0;
- break;
- case MSM_MI2S_SD1:
- dai_data->port_config.i2s.channel_mode =
- AFE_PORT_I2S_SD1;
- break;
- case MSM_MI2S_SD2:
- dai_data->port_config.i2s.channel_mode =
- AFE_PORT_I2S_SD2;
- break;
- case MSM_MI2S_SD3:
- dai_data->port_config.i2s.channel_mode =
- AFE_PORT_I2S_SD3;
- break;
- default:
- pr_err("%s: invalid SD line\n",
- __func__);
- goto error_invalid_data;
- }
- break;
- case 2:
- switch (i2s_pdata->sd_lines) {
- case MSM_MI2S_SD0 | MSM_MI2S_SD1:
- dai_data->port_config.i2s.channel_mode =
- AFE_PORT_I2S_QUAD01;
- break;
- case MSM_MI2S_SD2 | MSM_MI2S_SD3:
- dai_data->port_config.i2s.channel_mode =
- AFE_PORT_I2S_QUAD23;
- break;
- default:
- pr_err("%s: invalid SD line\n",
- __func__);
- goto error_invalid_data;
- }
- break;
- case 3:
- switch (i2s_pdata->sd_lines) {
- case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
- dai_data->port_config.i2s.channel_mode =
- AFE_PORT_I2S_6CHS;
- break;
- default:
- pr_err("%s: invalid SD lines\n",
- __func__);
- goto error_invalid_data;
- }
- break;
- case 4:
- switch (i2s_pdata->sd_lines) {
- case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
- dai_data->port_config.i2s.channel_mode =
- AFE_PORT_I2S_8CHS;
- break;
- default:
- pr_err("%s: invalid SD lines\n",
- __func__);
- goto error_invalid_data;
- }
- break;
- default:
- pr_err("%s: invalid SD lines\n", __func__);
- goto error_invalid_data;
- }
- if (i2s_pdata->capability == MSM_MI2S_CAP_RX)
- dai_driver->playback.channels_max = num_of_sd_lines << 1;
-
- return 0;
-
-error_invalid_data:
- return -EINVAL;
-}
-
-static int msm_dai_q6_cdc_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
-{
- struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
- switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
- case SND_SOC_DAIFMT_CBS_CFS:
- dai_data->port_config.i2s.ws_src = 1; /* CPU is master */
- break;
- case SND_SOC_DAIFMT_CBM_CFM:
- dai_data->port_config.i2s.ws_src = 0; /* CPU is slave */
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-
-static int msm_dai_q6_slim_bus_hw_params(struct snd_pcm_hw_params *params,
- struct snd_soc_dai *dai, int stream)
-{
- struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
- dai_data->channels = params_channels(params);
- dai_data->rate = params_rate(params);
-
- /* Q6 only supports 16 as now */
- dai_data->port_config.slim_sch.sb_cfg_minor_version =
- AFE_API_VERSION_SLIMBUS_CONFIG;
- dai_data->port_config.slim_sch.bit_width = 16;
- dai_data->port_config.slim_sch.data_format = 0;
- dai_data->port_config.slim_sch.num_channels = dai_data->channels;
- dai_data->port_config.slim_sch.sample_rate = dai_data->rate;
-
- dev_dbg(dai->dev, "%s:slimbus_dev_id[%hu] bit_wd[%hu] format[%hu]\n"
- "num_channel %hu shared_ch_mapping[0] %hu\n"
- "slave_port_mapping[1] %hu slave_port_mapping[2] %hu\n"
- "sample_rate %d\n", __func__,
- dai_data->port_config.slim_sch.slimbus_dev_id,
- dai_data->port_config.slim_sch.bit_width,
- dai_data->port_config.slim_sch.data_format,
- dai_data->port_config.slim_sch.num_channels,
- dai_data->port_config.slim_sch.shared_ch_mapping[0],
- dai_data->port_config.slim_sch.shared_ch_mapping[1],
- dai_data->port_config.slim_sch.shared_ch_mapping[2],
- dai_data->rate);
-
- return 0;
-}
-
-static int msm_dai_q6_bt_fm_hw_params(struct snd_pcm_hw_params *params,
- struct snd_soc_dai *dai, int stream)
-{
- struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
- dai_data->channels = params_channels(params);
- dai_data->rate = params_rate(params);
-
- dev_dbg(dai->dev, "channels %d sample rate %d entered\n",
- dai_data->channels, dai_data->rate);
-
- memset(&dai_data->port_config, 0, sizeof(dai_data->port_config));
-
- return 0;
-}
static int msm_dai_q6_auxpcm_hw_params(
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
@@ -311,83 +80,6 @@
return 0;
}
-static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params,
- struct snd_soc_dai *dai)
-{
- struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
-
- dai_data->rate = params_rate(params);
- dai_data->port_config.rtproxy.num_channels = params_channels(params);
- dai_data->port_config.rtproxy.sample_rate = params_rate(params);
-
- pr_debug("channel %d entered,dai_id: %d,rate: %d\n",
- dai_data->port_config.rtproxy.num_channels, dai->id, dai_data->rate);
-
- dai_data->port_config.rtproxy.rt_proxy_cfg_minor_version =
- AFE_API_VERSION_RT_PROXY_CONFIG;
- dai_data->port_config.rtproxy.bit_width = 16; /* Q6 only supports 16 */
- dai_data->port_config.rtproxy.interleaved = 1;
- dai_data->port_config.rtproxy.frame_size = params_period_bytes(params);
- dai_data->port_config.rtproxy.jitter_allowance =
- dai_data->port_config.rtproxy.frame_size/2;
- dai_data->port_config.rtproxy.low_water_mark = 0;
- dai_data->port_config.rtproxy.high_water_mark = 0;
-
- return 0;
-}
-
-/* Current implementation assumes hw_param is called once
- * This may not be the case but what to do when ADM and AFE
- * port are already opened and parameter changes
- */
-static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params,
- struct snd_soc_dai *dai)
-{
- int rc = 0;
-
- switch (dai->id) {
- case PRIMARY_I2S_TX:
- case PRIMARY_I2S_RX:
- case SECONDARY_I2S_RX:
- rc = msm_dai_q6_cdc_hw_params(params, dai, substream->stream);
- break;
- case MI2S_RX:
- rc = msm_dai_q6_i2s_hw_params(params, dai, substream->stream);
- break;
- case SLIMBUS_0_RX:
- case SLIMBUS_1_RX:
- case SLIMBUS_0_TX:
- case SLIMBUS_1_TX:
- rc = msm_dai_q6_slim_bus_hw_params(params, dai,
- substream->stream);
- break;
- case INT_BT_SCO_RX:
- case INT_BT_SCO_TX:
- case INT_FM_RX:
- case INT_FM_TX:
- rc = msm_dai_q6_bt_fm_hw_params(params, dai, substream->stream);
- break;
- case RT_PROXY_DAI_001_TX:
- case RT_PROXY_DAI_001_RX:
- case RT_PROXY_DAI_002_TX:
- case RT_PROXY_DAI_002_RX:
- rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai);
- break;
- case VOICE_PLAYBACK_TX:
- case VOICE_RECORD_RX:
- case VOICE_RECORD_TX:
- rc = 0;
- break;
- default:
- dev_err(dai->dev, "invalid AFE port ID\n");
- rc = -EINVAL;
- break;
- }
-
- return rc;
-}
-
static void msm_dai_q6_auxpcm_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
@@ -396,8 +88,8 @@
mutex_lock(&aux_pcm_mutex);
if (aux_pcm_count == 0) {
- dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count is 0. Just"
- " return\n", __func__, dai->id);
+ dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count is 0. Just return\n",
+ __func__, dai->id);
mutex_unlock(&aux_pcm_mutex);
return;
}
@@ -410,8 +102,7 @@
mutex_unlock(&aux_pcm_mutex);
return;
} else if (aux_pcm_count < 0) {
- dev_err(dai->dev, "%s(): ERROR: dai->id %d"
- " aux_pcm_count = %d < 0\n",
+ dev_err(dai->dev, "%s(): ERROR: dai->id %d aux_pcm_count = %d < 0\n",
__func__, dai->id, aux_pcm_count);
aux_pcm_count = 0;
mutex_unlock(&aux_pcm_mutex);
@@ -432,33 +123,6 @@
mutex_unlock(&aux_pcm_mutex);
}
-static void msm_dai_q6_shutdown(struct snd_pcm_substream *substream,
- struct snd_soc_dai *dai)
-{
- struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
- int rc = 0;
-
- if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
- switch (dai->id) {
- case VOICE_PLAYBACK_TX:
- case VOICE_RECORD_TX:
- case VOICE_RECORD_RX:
- pr_debug("%s, stop pseudo port:%d\n",
- __func__, dai->id);
- rc = afe_stop_pseudo_port(dai->id);
- break;
- default:
- rc = afe_close(dai->id); /* can block */
- break;
- }
- if (IS_ERR_VALUE(rc))
- dev_err(dai->dev, "fail to close AFE port\n");
- pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
- *dai_data->status_mask);
- clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
- }
-}
-
static int msm_dai_q6_auxpcm_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
@@ -468,13 +132,12 @@
mutex_lock(&aux_pcm_mutex);
if (aux_pcm_count == 2) {
- dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count is 2. Just"
- " return.\n", __func__, dai->id);
+ dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count is 2. Just return.\n",
+ __func__, dai->id);
mutex_unlock(&aux_pcm_mutex);
return 0;
} else if (aux_pcm_count > 2) {
- dev_err(dai->dev, "%s(): ERROR: dai->id %d"
- " aux_pcm_count = %d > 2\n",
+ dev_err(dai->dev, "%s(): ERROR: dai->id %d aux_pcm_count = %d > 2\n",
__func__, dai->id, aux_pcm_count);
mutex_unlock(&aux_pcm_mutex);
return 0;
@@ -482,8 +145,8 @@
aux_pcm_count++;
if (aux_pcm_count == 2) {
- dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count = %d after "
- " increment\n", __func__, dai->id, aux_pcm_count);
+ dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count = %d after increment\n",
+ __func__, dai->id, aux_pcm_count);
mutex_unlock(&aux_pcm_mutex);
return 0;
}
@@ -516,21 +179,6 @@
return rc;
}
-static int msm_dai_q6_prepare(struct snd_pcm_substream *substream,
- struct snd_soc_dai *dai)
-{
- struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
- int rc = 0;
-
- if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
- /* PORT START should be set if prepare called in active state */
- rc = afe_q6_interface_prepare();
- if (IS_ERR_VALUE(rc))
- dev_err(dai->dev, "fail to open AFE APR\n");
- }
- return rc;
-}
-
static int msm_dai_q6_auxpcm_trigger(struct snd_pcm_substream *substream,
int cmd, struct snd_soc_dai *dai)
{
@@ -560,82 +208,18 @@
}
-static int msm_dai_q6_trigger(struct snd_pcm_substream *substream, int cmd,
- struct snd_soc_dai *dai)
-{
- struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
- int rc = 0;
-
- /* Start/stop port without waiting for Q6 AFE response. Need to have
- * native q6 AFE driver propagates AFE response in order to handle
- * port start/stop command error properly if error does arise.
- */
- pr_debug("%s:port:%d cmd:%d dai_data->status_mask = %ld",
- __func__, dai->id, cmd, *dai_data->status_mask);
- switch (cmd) {
- case SNDRV_PCM_TRIGGER_START:
- case SNDRV_PCM_TRIGGER_RESUME:
- case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
- if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
- switch (dai->id) {
- case VOICE_PLAYBACK_TX:
- case VOICE_RECORD_TX:
- case VOICE_RECORD_RX:
- afe_pseudo_port_start_nowait(dai->id);
- break;
- default:
- afe_port_start_nowait(dai->id,
- &dai_data->port_config, dai_data->rate);
- break;
- }
- set_bit(STATUS_PORT_STARTED,
- dai_data->status_mask);
- }
- break;
- case SNDRV_PCM_TRIGGER_STOP:
- case SNDRV_PCM_TRIGGER_SUSPEND:
- case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
- if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
- switch (dai->id) {
- case VOICE_PLAYBACK_TX:
- case VOICE_RECORD_TX:
- case VOICE_RECORD_RX:
- afe_pseudo_port_stop_nowait(dai->id);
- break;
- default:
- afe_port_stop_nowait(dai->id);
- break;
- }
- clear_bit(STATUS_PORT_STARTED,
- dai_data->status_mask);
- }
- break;
-
- default:
- rc = -EINVAL;
- }
-
- return rc;
-}
static int msm_dai_q6_dai_auxpcm_probe(struct snd_soc_dai *dai)
{
struct msm_dai_q6_dai_data *dai_data;
int rc = 0;
+ struct msm_dai_auxpcm_pdata *auxpcm_pdata = NULL;
- struct msm_dai_auxpcm_pdata *auxpcm_pdata =
- (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data;
+ auxpcm_pdata = (struct msm_dai_auxpcm_pdata *)
+ dev_get_drvdata(dai->dev);
+ dai->dev->platform_data = auxpcm_pdata;
mutex_lock(&aux_pcm_mutex);
- if (!auxpcm_plat_data)
- auxpcm_plat_data = auxpcm_pdata;
- else if (auxpcm_plat_data != auxpcm_pdata) {
-
- dev_err(dai->dev, "AUX PCM RX and TX devices does not have"
- " same platform data\n");
- return -EINVAL;
- }
-
/*
* The clk name for AUX PCM operation is passed as platform
* data to the cpu driver, since cpu drive is unaware of any
@@ -669,8 +253,8 @@
mutex_lock(&aux_pcm_mutex);
if (aux_pcm_count == 0) {
- dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count is 0. clean"
- " up and return\n", __func__, dai->id);
+ dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count is 0. clean up and return\n",
+ __func__, dai->id);
goto done;
}
@@ -681,14 +265,12 @@
__func__, dai->id, aux_pcm_count);
goto done;
} else if (aux_pcm_count < 0) {
- dev_err(dai->dev, "%s(): ERROR: dai->id %d"
- " aux_pcm_count = %d < 0\n",
+ dev_err(dai->dev, "%s(): ERROR: dai->id %d aux_pcm_count = %d < 0\n",
__func__, dai->id, aux_pcm_count);
goto done;
}
- dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count = %d."
- "closing afe\n",
+ dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count = %d.closing afe\n",
__func__, dai->id, aux_pcm_count);
rc = afe_close(PCM_RX); /* can block */
@@ -707,172 +289,6 @@
return 0;
}
-static int msm_dai_q6_dai_i2s_probe(struct snd_soc_dai *dai)
-{
- struct msm_dai_q6_dai_data *dai_data;
- int rc = 0;
-
- dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data),
- GFP_KERNEL);
-
- if (!dai_data) {
- dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n",
- dai->id);
- rc = -ENOMEM;
- goto rtn;
- } else
- dev_set_drvdata(dai->dev, dai_data);
-
- rc = msm_dai_q6_i2s_platform_data_validation(dai);
- if (rc != 0) {
- pr_err("%s: The msm_dai_q6_i2s_platform_data_validation failed\n",
- __func__);
- kfree(dai_data);
- }
-rtn:
- return rc;
-}
-
-static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
-{
- struct msm_dai_q6_dai_data *dai_data;
- int rc = 0;
-
- dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data),
- GFP_KERNEL);
-
- if (!dai_data) {
- dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n",
- dai->id);
- rc = -ENOMEM;
- } else
- dev_set_drvdata(dai->dev, dai_data);
-
- return rc;
-}
-
-static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai)
-{
- struct msm_dai_q6_dai_data *dai_data;
- int rc;
-
- dai_data = dev_get_drvdata(dai->dev);
-
- /* If AFE port is still up, close it */
- if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
- switch (dai->id) {
- case VOICE_PLAYBACK_TX:
- case VOICE_RECORD_TX:
- case VOICE_RECORD_RX:
- pr_debug("%s, stop pseudo port:%d\n",
- __func__, dai->id);
- rc = afe_stop_pseudo_port(dai->id);
- break;
- default:
- rc = afe_close(dai->id); /* can block */
- }
- if (IS_ERR_VALUE(rc))
- dev_err(dai->dev, "fail to close AFE port\n");
- clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
- }
- kfree(dai_data);
- snd_soc_unregister_dai(dai->dev);
-
- return 0;
-}
-
-static int msm_dai_q6_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
-{
- int rc = 0;
-
- dev_dbg(dai->dev, "enter %s, id = %d fmt[%d]\n", __func__,
- dai->id, fmt);
- switch (dai->id) {
- case PRIMARY_I2S_TX:
- case PRIMARY_I2S_RX:
- case MI2S_RX:
- case SECONDARY_I2S_RX:
- rc = msm_dai_q6_cdc_set_fmt(dai, fmt);
- break;
- default:
- dev_err(dai->dev, "invalid cpu_dai set_fmt\n");
- rc = -EINVAL;
- break;
- }
-
- return rc;
-}
-
-static int msm_dai_q6_set_channel_map(struct snd_soc_dai *dai,
- unsigned int tx_num, unsigned int *tx_slot,
- unsigned int rx_num, unsigned int *rx_slot)
-
-{
- int rc = 0;
- struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
- unsigned int i = 0;
-
- dev_dbg(dai->dev, "enter %s, id = %d\n", __func__,
- dai->id);
- switch (dai->id) {
- case SLIMBUS_0_RX:
- case SLIMBUS_1_RX:
- /* channel number to be between 128 and 255. For RX port
- * use channel numbers from 138 to 144, for TX port
- * use channel numbers from 128 to 137
- * For ports between MDM-APQ use channel numbers from 145
- */
- if (!rx_slot)
- return -EINVAL;
- for (i = 0; i < rx_num; i++) {
- dai_data->port_config.slim_sch.shared_ch_mapping[i] =
- rx_slot[i];
- pr_debug("%s: find number of channels[%d] ch[%d]\n",
- __func__, i,
- rx_slot[i]);
- }
- dai_data->port_config.slim_sch.num_channels = rx_num;
- pr_debug("%s:SLIMBUS_0_RX cnt[%d] ch[%d %d]\n", __func__,
- rx_num, dai_data->port_config.slim_sch.shared_ch_mapping[0],
- dai_data->port_config.slim_sch.shared_ch_mapping[1]);
-
- break;
- case SLIMBUS_0_TX:
- case SLIMBUS_1_TX:
- /* channel number to be between 128 and 255. For RX port
- * use channel numbers from 138 to 144, for TX port
- * use channel numbers from 128 to 137
- * For ports between MDM-APQ use channel numbers from 145
- */
- if (!tx_slot)
- return -EINVAL;
- for (i = 0; i < tx_num; i++) {
- dai_data->port_config.slim_sch.shared_ch_mapping[i] =
- tx_slot[i];
- pr_debug("%s: find number of channels[%d] ch[%d]\n",
- __func__, i, tx_slot[i]);
- }
- dai_data->port_config.slim_sch.num_channels = tx_num;
- pr_debug("%s:SLIMBUS_0_TX cnt[%d] ch[%d %d]\n", __func__,
- tx_num, dai_data->port_config.slim_sch.shared_ch_mapping[0],
- dai_data->port_config.slim_sch.shared_ch_mapping[1]);
- break;
- default:
- dev_err(dai->dev, "invalid cpu_dai set_fmt\n");
- rc = -EINVAL;
- break;
- }
- return rc;
-}
-
-static struct snd_soc_dai_ops msm_dai_q6_ops = {
- .prepare = msm_dai_q6_prepare,
- .trigger = msm_dai_q6_trigger,
- .hw_params = msm_dai_q6_hw_params,
- .shutdown = msm_dai_q6_shutdown,
- .set_fmt = msm_dai_q6_set_fmt,
- .set_channel_map = msm_dai_q6_set_channel_map,
-};
static struct snd_soc_dai_ops msm_dai_q6_auxpcm_ops = {
.prepare = msm_dai_q6_auxpcm_prepare,
@@ -881,184 +297,6 @@
.shutdown = msm_dai_q6_auxpcm_shutdown,
};
-static struct snd_soc_dai_driver msm_dai_q6_i2s_rx_dai = {
- .playback = {
- .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
- SNDRV_PCM_RATE_16000,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- .channels_min = 1,
- .channels_max = 4,
- .rate_min = 8000,
- .rate_max = 48000,
- },
- .ops = &msm_dai_q6_ops,
- .probe = msm_dai_q6_dai_i2s_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_i2s_tx_dai = {
- .capture = {
- .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_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_afe_rx_dai = {
- .playback = {
- .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_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_afe_tx_dai = {
- .capture = {
- .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_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_voice_playback_tx_dai = {
- .playback = {
- .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_max = 48000,
- .rate_min = 8000,
- },
- .ops = &msm_dai_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai = {
- .playback = {
- .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_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai = {
- .capture = {
- .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_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai = {
- .capture = {
- .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_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_bt_sco_rx_dai = {
- .playback = {
- .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- .channels_min = 1,
- .channels_max = 1,
- .rate_max = 16000,
- .rate_min = 8000,
- },
- .ops = &msm_dai_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_bt_sco_tx_dai = {
- .playback = {
- .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- .channels_min = 1,
- .channels_max = 1,
- .rate_max = 16000,
- .rate_min = 8000,
- },
- .ops = &msm_dai_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_fm_rx_dai = {
- .playback = {
- .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
- SNDRV_PCM_RATE_16000,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- .channels_min = 2,
- .channels_max = 2,
- .rate_max = 48000,
- .rate_min = 8000,
- },
- .ops = &msm_dai_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_fm_tx_dai = {
- .playback = {
- .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
- SNDRV_PCM_RATE_16000,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- .channels_min = 2,
- .channels_max = 2,
- .rate_max = 48000,
- .rate_min = 8000,
- },
- .ops = &msm_dai_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_rx_dai = {
.playback = {
.rates = SNDRV_PCM_RATE_8000,
@@ -1087,140 +325,217 @@
.remove = msm_dai_q6_dai_auxpcm_remove,
};
-
-static struct snd_soc_dai_driver msm_dai_q6_slimbus_1_rx_dai = {
- .playback = {
- .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- .channels_min = 1,
- .channels_max = 1,
- .rate_min = 8000,
- .rate_max = 16000,
- },
- .ops = &msm_dai_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static struct snd_soc_dai_driver msm_dai_q6_slimbus_1_tx_dai = {
- .capture = {
- .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- .channels_min = 1,
- .channels_max = 1,
- .rate_min = 8000,
- .rate_max = 16000,
- },
- .ops = &msm_dai_q6_ops,
- .probe = msm_dai_q6_dai_probe,
- .remove = msm_dai_q6_dai_remove,
-};
-
-static __devinit int msm_dai_q6_dev_probe(struct platform_device *pdev)
+static int msm_auxpcm_dev_probe(struct platform_device *pdev)
{
+ int id;
+ void *plat_data;
int rc = 0;
+ if (pdev->dev.parent == NULL)
+ return -ENODEV;
+
+ plat_data = dev_get_drvdata(pdev->dev.parent);
+
+ rc = of_property_read_u32(pdev->dev.of_node,
+ "qcom,msm-auxpcm-dev-id", &id);
+ if (rc) {
+ dev_err(&pdev->dev, "%s: qcom,msm-auxpcm-dev-id missing in DT node\n",
+ __func__);
+ return rc;
+ }
+
+ pdev->id = id;
+ dev_set_name(&pdev->dev, "%s.%d", "msm-dai-q6", id);
dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
- switch (pdev->id) {
- case PRIMARY_I2S_RX:
- case SECONDARY_I2S_RX:
- rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_i2s_rx_dai);
- break;
- case PRIMARY_I2S_TX:
- rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_i2s_tx_dai);
- break;
+ dev_set_drvdata(&pdev->dev, plat_data);
+
+ switch (id) {
case AFE_PORT_ID_PRIMARY_PCM_RX:
rc = snd_soc_register_dai(&pdev->dev,
- &msm_dai_q6_aux_pcm_rx_dai);
+ &msm_dai_q6_aux_pcm_rx_dai);
break;
case AFE_PORT_ID_PRIMARY_PCM_TX:
rc = snd_soc_register_dai(&pdev->dev,
- &msm_dai_q6_aux_pcm_tx_dai);
- break;
- case MI2S_RX:
- rc = snd_soc_register_dai(&pdev->dev,
- &msm_dai_q6_i2s_rx_dai);
- break;
- case SLIMBUS_0_RX:
- rc = snd_soc_register_dai(&pdev->dev,
- &msm_dai_q6_slimbus_rx_dai);
- break;
- case SLIMBUS_0_TX:
- rc = snd_soc_register_dai(&pdev->dev,
- &msm_dai_q6_slimbus_tx_dai);
- break;
-
- case SLIMBUS_1_RX:
- rc = snd_soc_register_dai(&pdev->dev,
- &msm_dai_q6_slimbus_1_rx_dai);
- break;
- case SLIMBUS_1_TX:
- rc = snd_soc_register_dai(&pdev->dev,
- &msm_dai_q6_slimbus_1_tx_dai);
- break;
- case INT_BT_SCO_RX:
- rc = snd_soc_register_dai(&pdev->dev,
- &msm_dai_q6_bt_sco_rx_dai);
- break;
- case INT_BT_SCO_TX:
- rc = snd_soc_register_dai(&pdev->dev,
- &msm_dai_q6_bt_sco_tx_dai);
- break;
- case INT_FM_RX:
- rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_fm_rx_dai);
- break;
- case INT_FM_TX:
- rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_fm_tx_dai);
- break;
- case RT_PROXY_DAI_001_RX:
- case RT_PROXY_DAI_002_RX:
- rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_afe_rx_dai);
- break;
- case RT_PROXY_DAI_001_TX:
- case RT_PROXY_DAI_002_TX:
- rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_afe_tx_dai);
- break;
- case VOICE_PLAYBACK_TX:
- rc = snd_soc_register_dai(&pdev->dev,
- &msm_dai_q6_voice_playback_tx_dai);
- break;
- case VOICE_RECORD_RX:
- case VOICE_RECORD_TX:
- rc = snd_soc_register_dai(&pdev->dev,
- &msm_dai_q6_incall_record_dai);
+ &msm_dai_q6_aux_pcm_tx_dai);
break;
default:
rc = -ENODEV;
break;
}
+
return rc;
}
-static __devexit int msm_dai_q6_dev_remove(struct platform_device *pdev)
+static int msm_auxpcm_resource_probe(
+ struct platform_device *pdev)
+{
+ int rc = 0;
+ struct msm_dai_auxpcm_pdata *auxpcm_pdata = NULL;
+ u32 property_val;
+
+ auxpcm_pdata = kzalloc(sizeof(struct msm_dai_auxpcm_pdata),
+ GFP_KERNEL);
+
+ if (!auxpcm_pdata) {
+ dev_err(&pdev->dev, "Failed to allocate memory for platform data\n");
+ return -ENOMEM;
+ }
+
+ rc = of_property_read_string(pdev->dev.of_node,
+ "qcom,msm-cpudai-auxpcm-clk",
+ &auxpcm_pdata->clk);
+ if (rc) {
+ dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-clk missing in DT node\n",
+ __func__);
+ goto fail_free_plat;
+ }
+ rc = of_property_read_u32(pdev->dev.of_node,
+ "qcom,msm-cpudai-auxpcm-mode", &property_val);
+ if (rc) {
+ dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-mode missing in DT node\n",
+ __func__);
+ goto fail_free_plat;
+ }
+ auxpcm_pdata->mode = (u16)property_val;
+ rc = of_property_read_u32(pdev->dev.of_node,
+ "qcom,msm-cpudai-auxpcm-sync", &property_val);
+ if (rc) {
+ dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-sync missing in DT node\n",
+ __func__);
+ goto fail_free_plat;
+ }
+ auxpcm_pdata->sync = (u16)property_val;
+ rc = of_property_read_u32(pdev->dev.of_node,
+ "qcom,msm-cpudai-auxpcm-frame", &property_val);
+ if (rc) {
+ dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-frame missing in DT node\n",
+ __func__);
+ goto fail_free_plat;
+ }
+ auxpcm_pdata->frame = (u16)property_val;
+ rc = of_property_read_u32(pdev->dev.of_node,
+ "qcom,msm-cpudai-auxpcm-quant", &property_val);
+ if (rc) {
+ dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-quant missing in DT node\n",
+ __func__);
+ goto fail_free_plat;
+ }
+ auxpcm_pdata->quant = (u16)property_val;
+ rc = of_property_read_u32(pdev->dev.of_node,
+ "qcom,msm-cpudai-auxpcm-slot", &property_val);
+ if (rc) {
+ dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-slot missing in DT node\n",
+ __func__);
+ goto fail_free_plat;
+ }
+ auxpcm_pdata->slot = (u16)property_val;
+ rc = of_property_read_u32(pdev->dev.of_node,
+ "qcom,msm-cpudai-auxpcm-data", &property_val);
+ if (rc) {
+ dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-data missing in DT node\n",
+ __func__);
+ goto fail_free_plat;
+ }
+ auxpcm_pdata->data = (u16)property_val;
+ rc = of_property_read_u32(pdev->dev.of_node,
+ "qcom,msm-cpudai-auxpcm-pcm-clk-rate",
+ &auxpcm_pdata->pcm_clk_rate);
+ if (rc) {
+ dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-pcm-clk-rate missing in DT node\n",
+ __func__);
+ goto fail_free_plat;
+ }
+ platform_set_drvdata(pdev, auxpcm_pdata);
+
+ 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);
+ goto fail_free_plat;
+ }
+
+ return rc;
+
+fail_free_plat:
+ kfree(auxpcm_pdata);
+ return rc;
+}
+
+static int msm_auxpcm_dev_remove(struct platform_device *pdev)
{
snd_soc_unregister_dai(&pdev->dev);
return 0;
}
-static struct platform_driver msm_dai_q6_driver = {
- .probe = msm_dai_q6_dev_probe,
- .remove = msm_dai_q6_dev_remove,
+static int msm_auxpcm_resource_remove(
+ struct platform_device *pdev)
+{
+ void *auxpcm_pdata;
+
+ auxpcm_pdata = dev_get_drvdata(&pdev->dev);
+ kfree(auxpcm_pdata);
+
+ return 0;
+}
+
+static const struct of_device_id msm_auxpcm_resource_dt_match[] = {
+ { .compatible = "qcom,msm-auxpcm-resource", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, msm_auxpcm_resource_dt_match);
+
+static const struct of_device_id msm_auxpcm_dev_dt_match[] = {
+ { .compatible = "qcom,msm-auxpcm-dev", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, msm_auxpcm_dev_dt_match);
+
+
+static struct platform_driver msm_auxpcm_dev = {
+ .probe = msm_auxpcm_dev_probe,
+ .remove = msm_auxpcm_dev_remove,
.driver = {
- .name = "msm-dai-q6",
+ .name = "msm-auxpcm-dev",
.owner = THIS_MODULE,
+ .of_match_table = msm_auxpcm_dev_dt_match,
},
};
+static struct platform_driver msm_auxpcm_resource = {
+ .probe = msm_auxpcm_resource_probe,
+ .remove = msm_auxpcm_resource_remove,
+ .driver = {
+ .name = "msm-auxpcm-resource",
+ .owner = THIS_MODULE,
+ .of_match_table = msm_auxpcm_resource_dt_match,
+ },
+};
+
+
static int __init msm_dai_q6_init(void)
{
- return platform_driver_register(&msm_dai_q6_driver);
+ int rc;
+
+ rc = platform_driver_register(&msm_auxpcm_dev);
+ if (rc)
+ goto fail;
+
+ rc = platform_driver_register(&msm_auxpcm_resource);
+
+ if (rc) {
+ pr_err("%s: fail to register cpu dai driver\n", __func__);
+ platform_driver_unregister(&msm_auxpcm_dev);
+ }
+fail:
+ return rc;
}
module_init(msm_dai_q6_init);
static void __exit msm_dai_q6_exit(void)
{
- platform_driver_unregister(&msm_dai_q6_driver);
+ platform_driver_unregister(&msm_auxpcm_dev);
+ platform_driver_unregister(&msm_auxpcm_resource);
}
module_exit(msm_dai_q6_exit);
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-lpa-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-lpa-v2.c
index 05ef2ce..1ac872d 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-lpa-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-lpa-v2.c
@@ -27,6 +27,7 @@
#include <asm/dma.h>
#include <linux/dma-mapping.h>
#include <linux/android_pmem.h>
+#include <linux/of_device.h>
#include <sound/compress_params.h>
#include <sound/compress_offload.h>
#include <sound/compress_driver.h>
@@ -562,6 +563,9 @@
static __devinit int msm_pcm_probe(struct platform_device *pdev)
{
+ if (pdev->dev.of_node)
+ dev_set_name(&pdev->dev, "%s", "msm-pcm-lpa");
+
dev_info(&pdev->dev, "%s: dev name %s\n",
__func__, dev_name(&pdev->dev));
return snd_soc_register_platform(&pdev->dev,
@@ -574,10 +578,17 @@
return 0;
}
+static const struct of_device_id msm_pcm_lpa_dt_match[] = {
+ {.compatible = "qcom,msm-pcm-lpa"},
+ {}
+};
+MODULE_DEVICE_TABLE(of, msm_pcm_lpa_dt_match);
+
static struct platform_driver msm_pcm_driver = {
.driver = {
.name = "msm-pcm-lpa",
.owner = THIS_MODULE,
+ .of_match_table = msm_pcm_lpa_dt_match,
},
.probe = msm_pcm_probe,
.remove = __devexit_p(msm_pcm_remove),
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
index f94e6c1..c9f9593 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
@@ -28,6 +28,7 @@
#include <asm/dma.h>
#include <linux/dma-mapping.h>
#include <linux/android_pmem.h>
+#include <linux/of_device.h>
#include "msm-pcm-q6-v2.h"
#include "msm-pcm-routing-v2.h"
@@ -163,8 +164,7 @@
break;
}
if (prtd->mmap_flag) {
- pr_debug("%s:writing %d bytes"
- " of buffer to dsp\n",
+ pr_debug("%s:writing %d bytes of buffer to dsp\n",
__func__,
prtd->pcm_count);
q6asm_write_nolock(prtd->audio_client,
@@ -172,8 +172,7 @@
0, 0, NO_TIMESTAMP);
} else {
while (atomic_read(&prtd->out_needed)) {
- pr_debug("%s:writing %d bytes"
- " of buffer to dsp\n",
+ pr_debug("%s:writing %d bytes of buffer to dsp\n",
__func__,
prtd->pcm_count);
q6asm_write_nolock(prtd->audio_client,
@@ -626,17 +625,17 @@
dir = IN;
else
dir = OUT;
-pr_err("%s: before buf alloc\n", __func__);
+ pr_debug("%s: before buf alloc\n", __func__);
ret = q6asm_audio_client_buf_alloc_contiguous(dir,
prtd->audio_client,
runtime->hw.period_bytes_min,
runtime->hw.periods_max);
if (ret < 0) {
- pr_err("Audio Start: Buffer Allocation failed "
- "rc = %d\n", ret);
+ pr_err("Audio Start: Buffer Allocation failed rc = %d\n",
+ ret);
return -ENOMEM;
}
-pr_err("%s: after buf alloc\n", __func__);
+ pr_debug("%s: after buf alloc\n", __func__);
buf = prtd->audio_client->port[dir].buf;
if (buf == NULL || buf[0].data == NULL)
return -ENOMEM;
@@ -684,6 +683,9 @@
static __devinit int msm_pcm_probe(struct platform_device *pdev)
{
+ if (pdev->dev.of_node)
+ dev_set_name(&pdev->dev, "%s", "msm-pcm-dsp");
+
pr_info("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
return snd_soc_register_platform(&pdev->dev,
&msm_soc_platform);
@@ -694,11 +696,17 @@
snd_soc_unregister_platform(&pdev->dev);
return 0;
}
+static const struct of_device_id msm_pcm_dt_match[] = {
+ {.compatible = "qcom,msm-pcm-dsp"},
+ {}
+};
+MODULE_DEVICE_TABLE(of, msm_pcm_dt_match);
static struct platform_driver msm_pcm_driver = {
.driver = {
.name = "msm-pcm-dsp",
.owner = THIS_MODULE,
+ .of_match_table = msm_pcm_dt_match,
},
.probe = msm_pcm_probe,
.remove = __devexit_p(msm_pcm_remove),
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c
index b7aaf01..67ee8e4 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c
@@ -18,6 +18,7 @@
#include <linux/platform_device.h>
#include <linux/bitops.h>
#include <linux/mutex.h>
+#include <linux/of_device.h>
#include <sound/core.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
@@ -2153,6 +2154,9 @@
static __devinit int msm_routing_pcm_probe(struct platform_device *pdev)
{
+ if (pdev->dev.of_node)
+ dev_set_name(&pdev->dev, "%s", "msm-pcm-routing");
+
dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
return snd_soc_register_platform(&pdev->dev,
&msm_soc_routing_platform);
@@ -2164,10 +2168,17 @@
return 0;
}
+static const struct of_device_id msm_pcm_routing_dt_match[] = {
+ {.compatible = "qcom,msm-pcm-routing"},
+ {}
+};
+MODULE_DEVICE_TABLE(of, msm_pcm_routing_dt_match);
+
static struct platform_driver msm_routing_pcm_driver = {
.driver = {
.name = "msm-pcm-routing",
.owner = THIS_MODULE,
+ .of_match_table = msm_pcm_routing_dt_match,
},
.probe = msm_routing_pcm_probe,
.remove = __devexit_p(msm_routing_pcm_remove),