diff options
author | Ranjani Sridharan <ranjani.sridharan@linux.intel.com> | 2022-04-26 10:17:37 -0700 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2022-04-29 13:05:59 +0100 |
commit | 7b3a5be546a131f806fa015d1c78987daf1eb5c9 (patch) | |
tree | de7e5e01911255090773787f108fcff6e6af3aee /sound/soc/sof/sof-audio.h | |
parent | f0d31dbb3fc44ac9cb0d9991cc0a629c88e80ac8 (diff) | |
download | lwn-7b3a5be546a131f806fa015d1c78987daf1eb5c9.tar.gz lwn-7b3a5be546a131f806fa015d1c78987daf1eb5c9.zip |
ASoC: SOF: expose a couple of functions
Expose the mixer_to_ipc() and ipc_to_mixer() functions for reuse in
IPC4.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220426171743.171061-6-ranjani.sridharan@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/sof-audio.h')
-rw-r--r-- | sound/soc/sof/sof-audio.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 88def7074d2d..ab8787aab8a0 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -48,6 +48,26 @@ enum sof_widget_op { #define SOF_TLV_ITEMS 3 +static inline u32 mixer_to_ipc(unsigned int value, u32 *volume_map, int size) +{ + if (value >= size) + return volume_map[size - 1]; + + return volume_map[value]; +} + +static inline u32 ipc_to_mixer(u32 value, u32 *volume_map, int size) +{ + int i; + + for (i = 0; i < size; i++) { + if (volume_map[i] >= value) + return i; + } + + return i - 1; +} + struct snd_sof_widget; struct snd_sof_route; struct snd_sof_control; |