From 08ebb6692767a0e3c1a9371aa2f35b346f3d0e91 Mon Sep 17 00:00:00 2001 From: Ben Romberger Date: Wed, 2 Mar 2016 17:26:11 -0800 Subject: [PATCH] ASoC: msm: qdsp6v2: Add get for App Type mixer control Implement get function for App Type mixer control in pcm and compress driver. Returns app type, ACDB ID, and sample rate in use for FE ID. Change-Id: I4972de893a638f2482c37796dd1718628526351d Signed-off-by: Ben Romberger --- sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c | 30 ++++++++++++- sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c | 30 ++++++++++++- sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c | 49 +++++++++++++++++++++- sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h | 2 + 4 files changed, 107 insertions(+), 4 deletions(-) diff --git a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c index 1115b13c233c..0af4b336acd7 100755 --- a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c @@ -2749,7 +2749,35 @@ static int msm_compr_app_type_cfg_put(struct snd_kcontrol *kcontrol, static int msm_compr_app_type_cfg_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - return 0; + u64 fe_id = kcontrol->private_value; + int ret = 0; + int app_type; + int acdb_dev_id; + int sample_rate; + + pr_debug("%s: fe_id- %llu\n", __func__, fe_id); + if (fe_id >= MSM_FRONTEND_DAI_MAX) { + pr_err("%s Received out of bounds fe_id %llu\n", + __func__, fe_id); + ret = -EINVAL; + goto done; + } + + ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, &app_type, + &acdb_dev_id, &sample_rate); + if (ret < 0) { + pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n", + __func__, ret); + goto done; + } + + ucontrol->value.integer.value[0] = app_type; + ucontrol->value.integer.value[1] = acdb_dev_id; + ucontrol->value.integer.value[2] = sample_rate; + pr_debug("%s: fedai_id %llu, app_type %d, acdb_dev_id %d, sample_rate %d\n", + __func__, fe_id, app_type, acdb_dev_id, sample_rate); +done: + return ret; } static int msm_compr_channel_map_put(struct snd_kcontrol *kcontrol, diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c index cf40f07a9f23..4e3745d4d976 100644 --- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c @@ -1174,7 +1174,35 @@ static int msm_pcm_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol, static int msm_pcm_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - return 0; + u64 fe_id = kcontrol->private_value; + int ret = 0; + int app_type; + int acdb_dev_id; + int sample_rate; + + pr_debug("%s: fe_id- %llu\n", __func__, fe_id); + if (fe_id >= MSM_FRONTEND_DAI_MAX) { + pr_err("%s Received out of bounds fe_id %llu\n", + __func__, fe_id); + ret = -EINVAL; + goto done; + } + + ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, &app_type, + &acdb_dev_id, &sample_rate); + if (ret < 0) { + pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n", + __func__, ret); + goto done; + } + + ucontrol->value.integer.value[0] = app_type; + ucontrol->value.integer.value[1] = acdb_dev_id; + ucontrol->value.integer.value[2] = sample_rate; + pr_debug("%s: fedai_id %llu, app_type %d, acdb_dev_id %d, sample_rate %d\n", + __func__, fe_id, app_type, acdb_dev_id, sample_rate); +done: + return ret; } static int msm_pcm_add_app_type_controls(struct snd_soc_pcm_runtime *rtd) diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c index 4fb61470f118..8ca9bb7b2ad8 100644 --- a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c @@ -551,8 +551,8 @@ void msm_pcm_routing_reg_stream_app_type_cfg(int fedai_id, int app_type, pr_debug("%s: fedai_id %d, app_type %d, sample_rate %d\n", __func__, fedai_id, app_type, sample_rate); if (fedai_id > MSM_FRONTEND_DAI_MM_MAX_ID) { - /* bad ID assigned in machine driver */ - pr_err("%s: bad MM ID %d\n", __func__, fedai_id); + pr_err("%s: Invalid machine driver ID %d\n", + __func__, fedai_id); return; } fe_dai_app_type_cfg[fedai_id].app_type = app_type; @@ -560,6 +560,51 @@ void msm_pcm_routing_reg_stream_app_type_cfg(int fedai_id, int app_type, fe_dai_app_type_cfg[fedai_id].sample_rate = sample_rate; } +/** + * msm_pcm_routing_get_stream_app_type_cfg + * + * Receives fedai_id and populates app_type, acdb_dev_id, & + * sample rate. Returns 0 on success. On failure returns + * -EINVAL and does not alter passed values. + * + * fedai_id - Passed value, front end ID for which app type config is wanted + * app_type - Returned value, app type used by app type config + * acdb_dev_id - Returned value, ACDB device ID used by app type config + * sample_rate - Returned value, sample rate used by app type config + */ +int msm_pcm_routing_get_stream_app_type_cfg(int fedai_id, int *app_type, + int *acdb_dev_id, int *sample_rate) +{ + int ret = 0; + + if (app_type == NULL) { + pr_err("%s: NULL pointer sent for app_type\n", __func__); + ret = -EINVAL; + goto done; + } else if (acdb_dev_id == NULL) { + pr_err("%s: NULL pointer sent for acdb_dev_id\n", __func__); + ret = -EINVAL; + goto done; + } else if (sample_rate == NULL) { + pr_err("%s: NULL pointer sent for sample rate\n", __func__); + ret = -EINVAL; + goto done; + } else if (fedai_id > MSM_FRONTEND_DAI_MM_MAX_ID) { + pr_err("%s: Invalid FE ID %d\n", + __func__, fedai_id); + ret = -EINVAL; + goto done; + } + *app_type = fe_dai_app_type_cfg[fedai_id].app_type; + *acdb_dev_id = fe_dai_app_type_cfg[fedai_id].acdb_dev_id; + *sample_rate = fe_dai_app_type_cfg[fedai_id].sample_rate; + + pr_debug("%s: fedai_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n", + __func__, fedai_id, *app_type, *acdb_dev_id, *sample_rate); +done: + return ret; +} +EXPORT_SYMBOL(msm_pcm_routing_get_stream_app_type_cfg); static struct cal_block_data *msm_routing_find_topology_by_path(int path) { diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h index 6d1109f0bc6d..992d0d48e999 100644 --- a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h +++ b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.h @@ -414,4 +414,6 @@ void msm_pcm_routing_release_lock(void); void msm_pcm_routing_reg_stream_app_type_cfg(int fedai_id, int app_type, int acdb_dev_id, int sample_rate); +int msm_pcm_routing_get_stream_app_type_cfg(int fedai_id, int *app_type, + int *acdb_dev_id, int *sample_rate); #endif /*_MSM_PCM_H*/