aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-03-18 04:02:05 -0400
committerMark Brown <broonie@linaro.org>2014-04-14 12:22:43 -0400
commitf6272ff8a5f42c614f4a338013f5323979121e0f (patch)
tree3234194eddb26577f3fa1c8e2ea720fe6c005a97
parentea53bf77d147e7e560ac007fdaa30fb98c37c712 (diff)
ASoC: Add snd_soc_kcontrol_platform() helper function
For platform controls snd_kcontrol_chip() currently returns a pointer to the platform that registered the control. With the upcoming consolidation of platform and CODEC controls this will change. Prepare for this by introducing the snd_soc_kcontrol_platform() helper function that will hide the implementation details of how the platform for a control can be obtained. This will allow us to change this easily in the future. The patch also updates all platforms to use this new helper function. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--include/sound/soc.h14
-rw-r--r--sound/soc/intel/sst-haswell-pcm.c8
2 files changed, 18 insertions, 4 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index e150030b754d..14e7457e2347 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1242,6 +1242,20 @@ static inline struct snd_soc_codec *snd_soc_kcontrol_codec(
1242 return snd_kcontrol_chip(kcontrol); 1242 return snd_kcontrol_chip(kcontrol);
1243} 1243}
1244 1244
1245/**
1246 * snd_soc_kcontrol_platform() - Returns the platform that registerd the control
1247 * @kcontrol: The control for which to get the platform
1248 *
1249 * Note: This function will only work correctly if the control has been
1250 * registered with snd_soc_add_platform_controls() or via table based setup of
1251 * a snd_soc_platform_driver. Otherwise the behavior is undefined.
1252 */
1253static inline struct snd_soc_codec *snd_soc_kcontrol_platform(
1254 struct snd_kcontrol *kcontrol)
1255{
1256 return snd_kcontrol_chip(kcontrol);
1257}
1258
1245int snd_soc_util_init(void); 1259int snd_soc_util_init(void);
1246void snd_soc_util_exit(void); 1260void snd_soc_util_exit(void);
1247 1261
diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c
index 0a32dd13a23d..67a5eb3c6196 100644
--- a/sound/soc/intel/sst-haswell-pcm.c
+++ b/sound/soc/intel/sst-haswell-pcm.c
@@ -136,7 +136,7 @@ static inline unsigned int hsw_ipc_to_mixer(u32 value)
136static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, 136static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol,
137 struct snd_ctl_elem_value *ucontrol) 137 struct snd_ctl_elem_value *ucontrol)
138{ 138{
139 struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol); 139 struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
140 struct soc_mixer_control *mc = 140 struct soc_mixer_control *mc =
141 (struct soc_mixer_control *)kcontrol->private_value; 141 (struct soc_mixer_control *)kcontrol->private_value;
142 struct hsw_priv_data *pdata = 142 struct hsw_priv_data *pdata =
@@ -174,7 +174,7 @@ static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol,
174static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, 174static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol,
175 struct snd_ctl_elem_value *ucontrol) 175 struct snd_ctl_elem_value *ucontrol)
176{ 176{
177 struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol); 177 struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
178 struct soc_mixer_control *mc = 178 struct soc_mixer_control *mc =
179 (struct soc_mixer_control *)kcontrol->private_value; 179 (struct soc_mixer_control *)kcontrol->private_value;
180 struct hsw_priv_data *pdata = 180 struct hsw_priv_data *pdata =
@@ -206,7 +206,7 @@ static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol,
206static int hsw_volume_put(struct snd_kcontrol *kcontrol, 206static int hsw_volume_put(struct snd_kcontrol *kcontrol,
207 struct snd_ctl_elem_value *ucontrol) 207 struct snd_ctl_elem_value *ucontrol)
208{ 208{
209 struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol); 209 struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
210 struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); 210 struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform);
211 struct sst_hsw *hsw = pdata->hsw; 211 struct sst_hsw *hsw = pdata->hsw;
212 u32 volume; 212 u32 volume;
@@ -231,7 +231,7 @@ static int hsw_volume_put(struct snd_kcontrol *kcontrol,
231static int hsw_volume_get(struct snd_kcontrol *kcontrol, 231static int hsw_volume_get(struct snd_kcontrol *kcontrol,
232 struct snd_ctl_elem_value *ucontrol) 232 struct snd_ctl_elem_value *ucontrol)
233{ 233{
234 struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol); 234 struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
235 struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); 235 struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform);
236 struct sst_hsw *hsw = pdata->hsw; 236 struct sst_hsw *hsw = pdata->hsw;
237 unsigned int volume = 0; 237 unsigned int volume = 0;