Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 0b7990e3 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown
Browse files

ASoC: add for_each_rtd_codec_dai() macro



ALSA SoC snd_soc_pcm_runtime has snd_soc_dai array for codec_dai.
To be more readable code, this patch adds
new for_each_rtd_codec_dai() macro, and replace existing code to it.

Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3db769f1
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1158,6 +1158,13 @@ struct snd_soc_pcm_runtime {
	unsigned int dev_registered:1;
	unsigned int pop_wait:1;
};
#define for_each_rtd_codec_dai(rtd, i, dai)\
	for ((i) = 0;						       \
	     ((i) < rtd->num_codecs) && ((dai) = rtd->codec_dais[i]); \
	     (i)++)
#define for_each_rtd_codec_dai_reverse(rtd, i, dai)				\
	for (; ((i--) >= 0) && ((dai) = rtd->codec_dais[i]);)


/* mixer control */
struct soc_mixer_control {
+2 −3
Original line number Diff line number Diff line
@@ -488,11 +488,10 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
					struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *codec_dai;
	int ret = 0, j;

	for (j = 0; j < rtd->num_codecs; j++) {
		struct snd_soc_dai *codec_dai = rtd->codec_dais[j];

	for_each_rtd_codec_dai(rtd, j, codec_dai) {
		if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME)) {
			/*
			 * Use channel 4 and 5 for the first amp
+2 −3
Original line number Diff line number Diff line
@@ -353,11 +353,10 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
	struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *codec_dai;
	int ret = 0, j;

	for (j = 0; j < rtd->num_codecs; j++) {
		struct snd_soc_dai *codec_dai = rtd->codec_dais[j];

	for_each_rtd_codec_dai(rtd, j, codec_dai) {
		if (!strcmp(codec_dai->component->name, RT5514_DEV_NAME)) {
			ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xF, 0, 8, 16);
			if (ret < 0) {
+2 −3
Original line number Diff line number Diff line
@@ -44,11 +44,10 @@ static int mt8173_rt5650_rt5514_hw_params(struct snd_pcm_substream *substream,
					  struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *codec_dai;
	int i, ret;

	for (i = 0; i < rtd->num_codecs; i++) {
		struct snd_soc_dai *codec_dai = rtd->codec_dais[i];

	for_each_rtd_codec_dai(rtd, i, codec_dai) {
		/* pll from mclk 12.288M */
		ret = snd_soc_dai_set_pll(codec_dai, 0, 0, MCLK_FOR_CODECS,
					  params_rate(params) * 512);
+2 −3
Original line number Diff line number Diff line
@@ -48,11 +48,10 @@ static int mt8173_rt5650_rt5676_hw_params(struct snd_pcm_substream *substream,
					  struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *codec_dai;
	int i, ret;

	for (i = 0; i < rtd->num_codecs; i++) {
		struct snd_soc_dai *codec_dai = rtd->codec_dais[i];

	for_each_rtd_codec_dai(rtd, i, codec_dai) {
		/* pll from mclk 12.288M */
		ret = snd_soc_dai_set_pll(codec_dai, 0, 0, MCLK_FOR_CODECS,
					  params_rate(params) * 512);
Loading