diff options
| author | Linux Build Service Account <lnxbuild@localhost> | 2016-08-01 08:04:22 -0700 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-08-01 08:04:21 -0700 |
| commit | 83978dfbc095e42a6847917e042eae4b81ab45dc (patch) | |
| tree | 7170c7d5ff81b3e53f23e06bce23272bd0595aef | |
| parent | 09955c92f3c8afb0cd747959849bac857d18ccd5 (diff) | |
| parent | 712b785a7308699e6ec52f17894670c8bbfa64dd (diff) | |
Merge "ASoC: msm-cpe-lsm: add support for two CPE sessions"
| -rwxr-xr-x | Documentation/devicetree/bindings/sound/qcom-audio-dev.txt | 7 | ||||
| -rw-r--r-- | sound/soc/msm/msm-cpe-lsm.c | 100 |
2 files changed, 83 insertions, 24 deletions
diff --git a/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt b/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt index b30b6b87add6..d25a7930289e 100755 --- a/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt +++ b/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt @@ -351,6 +351,9 @@ Required properties: Required properties: - compatible : "qcom,msm-cpe-lsm" + - qcom,msm-cpe-lsm-id : lsm afe port ID. CPE lsm driver uses + this property to find out the input afe port ID. Currently + only supported values are 1 and 3. * wcd_us_euro_gpio @@ -1367,12 +1370,12 @@ Example: qcom,mbhc-audio-jack-type = "6-pole-jack"; asoc-platform = <&pcm0>, <&pcm1>, <&pcm2>, <&voip>, <&voice>, <&loopback>, <&compress>, <&hostless>, - <&afe>, <&lsm>, <&routing>, <&cpe>, <&compr>; + <&afe>, <&lsm>, <&routing>, <&cpe>, <&compr>, <&cpe3>; asoc-platform-names = "msm-pcm-dsp.0", "msm-pcm-dsp.1", "msm-pcm-dsp.2", "msm-voip-dsp", "msm-pcm-voice", "msm-pcm-loopback", "msm-compress-dsp", "msm-pcm-hostless", "msm-pcm-afe", "msm-lsm-client", "msm-pcm-routing", "msm-cpe-lsm", - "msm-compr-dsp"; + "msm-compr-dsp", "msm-cpe-lsm.3"; asoc-cpu = <&dai_pri_auxpcm>, <&dai_sec_auxpcm>, <&dai_hdmi>, <&dai_mi2s>, <&sb_0_rx>, <&sb_0_tx>, <&sb_1_rx>, <&sb_1_tx>, <&sb_2_rx>, <&sb_2_tx>, <&sb_3_rx>, <&sb_3_tx>, diff --git a/sound/soc/msm/msm-cpe-lsm.c b/sound/soc/msm/msm-cpe-lsm.c index a509107ea9f2..45eed236c5c9 100644 --- a/sound/soc/msm/msm-cpe-lsm.c +++ b/sound/soc/msm/msm-cpe-lsm.c @@ -28,7 +28,11 @@ #include <sound/pcm_params.h> #include <sound/msm-slim-dma.h> +#define SAMPLE_RATE_48KHZ 48000 +#define SAMPLE_RATE_16KHZ 16000 #define LSM_VOICE_WAKEUP_APP_V2 2 +#define AFE_PORT_ID_1 1 +#define AFE_PORT_ID_3 3 #define AFE_OUT_PORT_2 2 #define LISTEN_MIN_NUM_PERIODS 2 #define LISTEN_MAX_NUM_PERIODS 12 @@ -135,6 +139,7 @@ struct cpe_priv { struct wcd_cpe_lsm_ops lsm_ops; struct wcd_cpe_afe_ops afe_ops; bool afe_mad_ctl; + u32 input_port_id; }; struct cpe_lsm_data { @@ -1156,12 +1161,6 @@ static int msm_cpe_lsm_ioctl_shared(struct snd_pcm_substream *substream, __func__, rc); return rc; } - rc = lsm_ops->lsm_lab_control(cpe->core_handle, - session, false); - if (IS_ERR_VALUE(rc)) - dev_err(rtd->dev, - "%s: Lab Disable Failed rc %d\n", - __func__, rc); /* * Buffer has to be de-allocated even if * lab_control failed. @@ -1390,14 +1389,6 @@ static int msm_cpe_lsm_ioctl_shared(struct snd_pcm_substream *substream, dev_dbg(rtd->dev, "%s: %s\n", __func__, "SNDRV_LSM_START"); - rc = lsm_ops->lsm_get_afe_out_port_id(cpe->core_handle, - session); - if (rc != 0) { - dev_err(rtd->dev, - "%s: failed to get port id, err = %d\n", - __func__, rc); - return rc; - } rc = lsm_ops->lsm_start(cpe->core_handle, session); if (rc != 0) { dev_err(rtd->dev, @@ -2680,6 +2671,8 @@ static int msm_cpe_lsm_prepare(struct snd_pcm_substream *substream) struct cpe_lsm_session *lsm_session; struct cpe_lsm_lab *lab_d = &lsm_d->lab; struct snd_pcm_runtime *runtime = substream->runtime; + struct lsm_hw_params lsm_param; + struct wcd_cpe_lsm_ops *lsm_ops; if (!cpe || !cpe->core_handle) { dev_err(rtd->dev, @@ -2712,23 +2705,74 @@ static int msm_cpe_lsm_prepare(struct snd_pcm_substream *substream) return 0; } + lsm_ops = &cpe->lsm_ops; afe_ops = &cpe->afe_ops; afe_cfg = &(lsm_d->lsm_session->afe_port_cfg); - afe_cfg->port_id = 1; - afe_cfg->bit_width = 16; - afe_cfg->num_channels = 1; - afe_cfg->sample_rate = 16000; + switch (cpe->input_port_id) { + case AFE_PORT_ID_3: + afe_cfg->port_id = AFE_PORT_ID_3; + afe_cfg->bit_width = 16; + afe_cfg->num_channels = 1; + afe_cfg->sample_rate = SAMPLE_RATE_48KHZ; + rc = afe_ops->afe_port_cmd_cfg(cpe->core_handle, afe_cfg); + break; + case AFE_PORT_ID_1: + default: + afe_cfg->port_id = AFE_PORT_ID_1; + afe_cfg->bit_width = 16; + afe_cfg->num_channels = 1; + afe_cfg->sample_rate = SAMPLE_RATE_16KHZ; + rc = afe_ops->afe_set_params(cpe->core_handle, + afe_cfg, cpe->afe_mad_ctl); + break; + } - rc = afe_ops->afe_set_params(cpe->core_handle, - afe_cfg, cpe->afe_mad_ctl); if (rc != 0) { dev_err(rtd->dev, - "%s: cpe afe params failed, err = %d\n", - __func__, rc); + "%s: cpe afe params failed for port = %d, err = %d\n", + __func__, afe_cfg->port_id, rc); + return rc; + } + lsm_param.sample_rate = afe_cfg->sample_rate; + lsm_param.num_chs = afe_cfg->num_channels; + lsm_param.bit_width = afe_cfg->bit_width; + rc = lsm_ops->lsm_set_media_fmt_params(cpe->core_handle, lsm_session, + &lsm_param); + if (rc) + dev_dbg(rtd->dev, + "%s: failed to set lsm media fmt params, err = %d\n", + __func__, rc); + + /* Send connect to port (input) */ + rc = lsm_ops->lsm_set_port(cpe->core_handle, lsm_session, + &cpe->input_port_id); + if (rc) { + dev_err(rtd->dev, + "%s: Failed to set connect input port, err=%d\n", + __func__, rc); return rc; } + if (cpe->input_port_id != 3) { + rc = lsm_ops->lsm_get_afe_out_port_id(cpe->core_handle, + lsm_session); + if (rc != 0) { + dev_err(rtd->dev, + "%s: failed to get port id, err = %d\n", + __func__, rc); + return rc; + } + /* Send connect to port (output) */ + rc = lsm_ops->lsm_set_port(cpe->core_handle, lsm_session, + &lsm_session->afe_out_port_id); + if (rc) { + dev_err(rtd->dev, + "%s: Failed to set connect output port, err=%d\n", + __func__, rc); + return rc; + } + } rc = msm_cpe_afe_port_cntl(substream, cpe->core_handle, afe_ops, afe_cfg, @@ -2978,6 +3022,9 @@ static int msm_asoc_cpe_lsm_probe(struct snd_soc_platform *platform) struct cpe_priv *cpe_priv; const struct snd_kcontrol_new *kcontrol; bool found_runtime = false; + const char *cpe_dev_id = "qcom,msm-cpe-lsm-id"; + u32 port_id = 0; + int ret = 0; int i; if (!platform || !platform->component.card) { @@ -3007,6 +3054,14 @@ static int msm_asoc_cpe_lsm_probe(struct snd_soc_platform *platform) return -EINVAL; } + ret = of_property_read_u32(platform->dev->of_node, cpe_dev_id, + &port_id); + if (ret) { + dev_dbg(platform->dev, + "%s: missing 0x%x in dt node\n", __func__, port_id); + port_id = 1; + } + codec = rtd->codec; cpe_priv = kzalloc(sizeof(struct cpe_priv), @@ -3019,6 +3074,7 @@ static int msm_asoc_cpe_lsm_probe(struct snd_soc_platform *platform) } cpe_priv->codec = codec; + cpe_priv->input_port_id = port_id; wcd_cpe_get_lsm_ops(&cpe_priv->lsm_ops); wcd_cpe_get_afe_ops(&cpe_priv->afe_ops); |
