ASoC: Intel: sof_rt5682: Move rt1015 speaker amp to common file
Subsystems (3)
PATCH 1/1 ASoC: Intel: sof_rt5682: Move rt1015 speaker amp to common file
From: Yong Zhi <[email protected]>
Move rt1015 driver code to common file to be consistent with rt1011 and rt1015p.
No functional change.
--- sound/soc/intel/boards/sof_realtek_common.c | 119 +++++++++++++++++++- sound/soc/intel/boards/sof_realtek_common.h | 7 ++ sound/soc/intel/boards/sof_rt5682.c | 107 +----------------- 3 files changed, 127 insertions(+), 106 deletions(-)
sound/soc/intel/boards/sof_realtek_common.c +116 -3
@@ -12,12 +12,13 @@#include <sound/soc-dapm.h> #include <uapi/sound/asound.h> #include "../../codecs/rt1011.h" +#include "../../codecs/rt1015.h" #include "sof_realtek_common.h" /* * Current only 2-amp configuration is supported for rt1011 */ -static const struct snd_soc_dapm_route rt1011_dapm_routes[] = { +static const struct snd_soc_dapm_route speaker_map_lr[] = {/* speaker */ {"Left Spk" ,NULL ,"Left SPO" }, {"Right Spk" ,NULL ,"Right SPO" },
@@ -117,8 +118,8 @@ static int rt1011_init(struct snd_soc_pcm_runtime *rtd)struct snd_soc_card *card = rtd->card;int ret; - ret =snd_soc_dapm_add_routes (&card->dapm, rt1011_dapm_routes, -ARRAY_SIZE (rt1011_dapm_routes)); + ret =snd_soc_dapm_add_routes (&card->dapm, speaker_map_lr, +ARRAY_SIZE (speaker_map_lr));if (ret)dev_err (rtd->dev,"Speaker map addition failed: %d\n" , ret);return ret;
@@ -241,3 +242,115 @@ void sof_rt1015p_codec_conf(struct snd_soc_card *card) card->codec_conf = rt1015p_codec_confs; card->num_configs =ARRAY_SIZE (rt1015p_codec_confs); } + +/* +* RT1015 audio amplifier +*/ + +static int rt1015_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd =asoc_substream_to_rtd (substream); +struct snd_soc_dai *codec_dai; +int i, fs =64 , ret; + +for_each_rtd_codec_dais (rtd, i, codec_dai) { + ret =snd_soc_dai_set_pll (codec_dai,0 ,RT1015_PLL_S_BCLK , +params_rate (params) * fs, +params_rate (params) *256 ); +if (ret) +return ret; + + ret =snd_soc_dai_set_sysclk (codec_dai,RT1015_SCLK_S_PLL , +params_rate (params) *256 , +SND_SOC_CLOCK_IN ); +if (ret) +return ret; + } + +return 0 ; +} + +static int rt1015_hw_params_pll_and_tdm (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd =asoc_substream_to_rtd (substream); +struct snd_soc_dai *codec_dai; +int i, fs =100 , ret; + +for_each_rtd_codec_dais (rtd, i, codec_dai) { + ret =snd_soc_dai_set_pll (codec_dai,0 ,RT1015_PLL_S_BCLK , +params_rate (params) * fs, +params_rate (params) *256 ); +if (ret) +return ret; + + ret =snd_soc_dai_set_sysclk (codec_dai,RT1015_SCLK_S_PLL , +params_rate (params) *256 , +SND_SOC_CLOCK_IN ); +if (ret) +return ret; + } +/* rx slot 1 for RT1015_DEV0_NAME */ + ret =snd_soc_dai_set_tdm_slot (asoc_rtd_to_codec (rtd,0 ), +0x0 ,0x1 ,4 ,24 ); +if (ret) +return ret; + +/* rx slot 2 for RT1015_DEV1_NAME */ + ret =snd_soc_dai_set_tdm_slot (asoc_rtd_to_codec (rtd,1 ), +0x0 ,0x2 ,4 ,24 ); +if (ret) +return ret; + +return 0 ; +} + +static struct snd_soc_ops rt1015_ops = { + .hw_params = rt1015_hw_params, +}; + +static struct snd_soc_codec_conf rt1015_amp_conf[] = { + { + .dlc =COMP_CODEC_CONF (RT1015_DEV0_NAME ), + .name_prefix ="Left" , + }, + { + .dlc =COMP_CODEC_CONF (RT1015_DEV1_NAME ), + .name_prefix ="Right" , + }, +}; + +static struct snd_soc_dai_link_component rt1015_components[] = { + { + .name =RT1015_DEV0_NAME , + .dai_name =RT1015_CODEC_DAI , + }, + { + .name =RT1015_DEV1_NAME , + .dai_name =RT1015_CODEC_DAI , + }, +}; + +static int speaker_codec_init_lr (struct snd_soc_pcm_runtime *rtd) +{ +return snd_soc_dapm_add_routes (&rtd->card->dapm, speaker_map_lr, +ARRAY_SIZE (speaker_map_lr)); +} + +void sof_rt1015_codec_conf (struct snd_soc_card *card) +{ + card->codec_conf = rt1015_amp_conf; + card->num_configs =ARRAY_SIZE (rt1015_amp_conf); +} + +void sof_rt1015_dai_link (struct snd_soc_dai_link *link,unsigned int fs) +{ + link->codecs = rt1015_components; + link->num_codecs =ARRAY_SIZE (rt1015_components); + link->init = speaker_codec_init_lr; + link->ops = &rt1015_ops; + +if (fs ==100 ) + rt1015_ops.hw_params = rt1015_hw_params_pll_and_tdm; +}
sound/soc/intel/boards/sof_realtek_common.h +7 -0
@@ -28,4 +28,11 @@ void sof_rt1011_codec_conf(struct snd_soc_card *card);void sof_rt1015p_dai_link (struct snd_soc_dai_link *link);void sof_rt1015p_codec_conf (struct snd_soc_card *card); +#define RT1015_CODEC_DAI "rt1015-aif" +#define RT1015_DEV0_NAME "i2c-10EC1015:00" +#define RT1015_DEV1_NAME "i2c-10EC1015:01" + +void sof_rt1015_dai_link (struct snd_soc_dai_link *link,unsigned int fs); +void sof_rt1015_codec_conf (struct snd_soc_card *card); +#endif /* __SOF_REALTEK_COMMON_H */
sound/soc/intel/boards/sof_rt5682.c +4 -103
154 lines not on this page · raw message
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 8 lines · Pierre-Louis Bossart
From: Yong Zhi <[email protected]>
Move rt1015 driver code to common file to be consistent with rt1011 and rt1015p.
No functional change.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: Intel: sof_rt5682: Move rt1015 speaker amp to common file
commit: 77659872be233e56019041d05b44d134022296b7
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark