From ba9ce1c9fb43145632edb5f027d96f9a1866b1cc Mon Sep 17 00:00:00 2001 From: Laxminath Kasam Date: Fri, 30 Dec 2016 15:02:33 +0530 Subject: [PATCH] ASoC: msm: Register common sound controls Add logic to register common sound controls to ALSA SoC in both internal and external codec machine drivers. CRs-Fixed: 1106498 Change-Id: If5e210fb1f4a5684da4dab7ef567a588e0166d83 Signed-off-by: Laxminath Kasam --- sound/soc/msm/sdm660-common.c | 11 +++++++++++ sound/soc/msm/sdm660-common.h | 1 + sound/soc/msm/sdm660-external.c | 8 ++++++++ sound/soc/msm/sdm660-internal.c | 14 +++++++++++++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/sound/soc/msm/sdm660-common.c b/sound/soc/msm/sdm660-common.c index ee3cf62ee2c2..1497ddcca61f 100644 --- a/sound/soc/msm/sdm660-common.c +++ b/sound/soc/msm/sdm660-common.c @@ -1683,6 +1683,17 @@ const struct snd_kcontrol_new msm_common_snd_controls[] = { tdm_tx_ch_put), }; +/** + * msm_common_snd_controls_size - to return controls size + * + * Return: returns size of common controls array + */ +int msm_common_snd_controls_size(void) +{ + return ARRAY_SIZE(msm_common_snd_controls); +} +EXPORT_SYMBOL(msm_common_snd_controls_size); + static inline int param_is_mask(int p) { return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) && diff --git a/sound/soc/msm/sdm660-common.h b/sound/soc/msm/sdm660-common.h index aa760ba71de2..36c2d9b7ca4e 100644 --- a/sound/soc/msm/sdm660-common.h +++ b/sound/soc/msm/sdm660-common.h @@ -113,4 +113,5 @@ int msm_aux_pcm_snd_startup(struct snd_pcm_substream *substream); void msm_aux_pcm_snd_shutdown(struct snd_pcm_substream *substream); int msm_mi2s_snd_startup(struct snd_pcm_substream *substream); void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream); +int msm_common_snd_controls_size(void); #endif diff --git a/sound/soc/msm/sdm660-external.c b/sound/soc/msm/sdm660-external.c index a741499b2a73..c900ce1a0fe9 100644 --- a/sound/soc/msm/sdm660-external.c +++ b/sound/soc/msm/sdm660-external.c @@ -1530,6 +1530,14 @@ int msm_audrx_init(struct snd_soc_pcm_runtime *rtd) return ret; } + ret = snd_soc_add_codec_controls(codec, msm_common_snd_controls, + msm_common_snd_controls_size()); + if (ret < 0) { + pr_err("%s: add_common_snd_controls failed: %d\n", + __func__, ret); + return ret; + } + snd_soc_dapm_new_controls(dapm, msm_dapm_widgets, ARRAY_SIZE(msm_dapm_widgets)); diff --git a/sound/soc/msm/sdm660-internal.c b/sound/soc/msm/sdm660-internal.c index 4ecf6c996e69..5d3ec356343e 100644 --- a/sound/soc/msm/sdm660-internal.c +++ b/sound/soc/msm/sdm660-internal.c @@ -1300,8 +1300,20 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd) pr_debug("%s(),dev_name%s\n", __func__, dev_name(cpu_dai->dev)); - snd_soc_add_codec_controls(ana_cdc, msm_snd_controls, + ret = snd_soc_add_codec_controls(ana_cdc, msm_snd_controls, ARRAY_SIZE(msm_snd_controls)); + if (ret < 0) { + pr_err("%s: add_codec_controls failed: %d\n", + __func__, ret); + return ret; + } + ret = snd_soc_add_codec_controls(ana_cdc, msm_common_snd_controls, + msm_common_snd_controls_size()); + if (ret < 0) { + pr_err("%s: add common snd controls failed: %d\n", + __func__, ret); + return ret; + } snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets, ARRAY_SIZE(msm_int_dapm_widgets));