提交 dfb6ec7a 编写于 作者: P Pierre-Louis Bossart 提交者: Mark Brown

ASoC: Intel: boards: use helper to get codec_dai

Remove duplicate code with a common helper in all Intel machine drivers.
Suggested-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Suggested-by: NTakashi Iwai <tiwai@suse.de>
Signed-off-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Acked-by: NLiam Girdwood <liam.r.girdwood@linux.intel.com>
Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NMark Brown <broonie@kernel.org>
上级 8a2eca50
...@@ -55,20 +55,6 @@ enum { ...@@ -55,20 +55,6 @@ enum {
BXT_DPCM_AUDIO_HDMI3_PB, BXT_DPCM_AUDIO_HDMI3_PB,
}; };
static inline struct snd_soc_dai *bxt_get_codec_dai(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
list_for_each_entry(rtd, &card->rtd_list, list) {
if (!strncmp(rtd->codec_dai->name, BXT_DIALOG_CODEC_DAI,
strlen(BXT_DIALOG_CODEC_DAI)))
return rtd->codec_dai;
}
return NULL;
}
static int platform_clock_control(struct snd_soc_dapm_widget *w, static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
...@@ -77,7 +63,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, ...@@ -77,7 +63,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct snd_soc_card *card = dapm->card; struct snd_soc_card *card = dapm->card;
struct snd_soc_dai *codec_dai; struct snd_soc_dai *codec_dai;
codec_dai = bxt_get_codec_dai(card); codec_dai = snd_soc_card_get_codec_dai(card, BXT_DIALOG_CODEC_DAI);
if (!codec_dai) { if (!codec_dai) {
dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n"); dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
return -EIO; return -EIO;
......
...@@ -145,22 +145,6 @@ static void log_quirks(struct device *dev) ...@@ -145,22 +145,6 @@ static void log_quirks(struct device *dev)
#define BYT_CODEC_DAI1 "rt5640-aif1" #define BYT_CODEC_DAI1 "rt5640-aif1"
#define BYT_CODEC_DAI2 "rt5640-aif2" #define BYT_CODEC_DAI2 "rt5640-aif2"
static inline struct snd_soc_dai *byt_get_codec_dai(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
list_for_each_entry(rtd, &card->rtd_list, list) {
if (!strncmp(rtd->codec_dai->name, BYT_CODEC_DAI1,
strlen(BYT_CODEC_DAI1)))
return rtd->codec_dai;
if (!strncmp(rtd->codec_dai->name, BYT_CODEC_DAI2,
strlen(BYT_CODEC_DAI2)))
return rtd->codec_dai;
}
return NULL;
}
static int platform_clock_control(struct snd_soc_dapm_widget *w, static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
...@@ -170,7 +154,10 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, ...@@ -170,7 +154,10 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
int ret; int ret;
codec_dai = byt_get_codec_dai(card); codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI1);
if (!codec_dai)
codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI2);
if (!codec_dai) { if (!codec_dai) {
dev_err(card->dev, dev_err(card->dev,
"Codec dai not found; Unable to set platform clock\n"); "Codec dai not found; Unable to set platform clock\n");
......
...@@ -68,18 +68,6 @@ static void log_quirks(struct device *dev) ...@@ -68,18 +68,6 @@ static void log_quirks(struct device *dev)
#define BYT_CODEC_DAI1 "rt5651-aif1" #define BYT_CODEC_DAI1 "rt5651-aif1"
static inline struct snd_soc_dai *byt_get_codec_dai(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
list_for_each_entry(rtd, &card->rtd_list, list) {
if (!strncmp(rtd->codec_dai->name, BYT_CODEC_DAI1,
strlen(BYT_CODEC_DAI1)))
return rtd->codec_dai;
}
return NULL;
}
static int platform_clock_control(struct snd_soc_dapm_widget *w, static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
...@@ -89,7 +77,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, ...@@ -89,7 +77,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card); struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card);
int ret; int ret;
codec_dai = byt_get_codec_dai(card); codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI1);
if (!codec_dai) { if (!codec_dai) {
dev_err(card->dev, dev_err(card->dev,
"Codec dai not found; Unable to set platform clock\n"); "Codec dai not found; Unable to set platform clock\n");
......
...@@ -41,18 +41,6 @@ struct cht_mc_private { ...@@ -41,18 +41,6 @@ struct cht_mc_private {
bool ts3a227e_present; bool ts3a227e_present;
}; };
static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
list_for_each_entry(rtd, &card->rtd_list, list) {
if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI,
strlen(CHT_CODEC_DAI)))
return rtd->codec_dai;
}
return NULL;
}
static int platform_clock_control(struct snd_soc_dapm_widget *w, static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
...@@ -62,7 +50,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, ...@@ -62,7 +50,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
int ret; int ret;
codec_dai = cht_get_codec_dai(card); codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI);
if (!codec_dai) { if (!codec_dai) {
dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
return -EIO; return -EIO;
......
...@@ -70,21 +70,6 @@ static void log_quirks(struct device *dev) ...@@ -70,21 +70,6 @@ static void log_quirks(struct device *dev)
dev_info(dev, "quirk SSP0_AIF2 enabled"); dev_info(dev, "quirk SSP0_AIF2 enabled");
} }
static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
list_for_each_entry(rtd, &card->rtd_list, list) {
if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI1,
strlen(CHT_CODEC_DAI1)))
return rtd->codec_dai;
if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI2,
strlen(CHT_CODEC_DAI2)))
return rtd->codec_dai;
}
return NULL;
}
static int platform_clock_control(struct snd_soc_dapm_widget *w, static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
...@@ -94,7 +79,10 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, ...@@ -94,7 +79,10 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
int ret; int ret;
codec_dai = cht_get_codec_dai(card); codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI1);
if (!codec_dai)
codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI2);
if (!codec_dai) { if (!codec_dai) {
dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
return -EIO; return -EIO;
......
...@@ -50,18 +50,6 @@ static struct snd_soc_jack_pin cht_bsw_headset_pins[] = { ...@@ -50,18 +50,6 @@ static struct snd_soc_jack_pin cht_bsw_headset_pins[] = {
}, },
}; };
static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
list_for_each_entry(rtd, &card->rtd_list, list) {
if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI,
strlen(CHT_CODEC_DAI)))
return rtd->codec_dai;
}
return NULL;
}
static int platform_clock_control(struct snd_soc_dapm_widget *w, static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
...@@ -71,7 +59,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, ...@@ -71,7 +59,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
int ret; int ret;
codec_dai = cht_get_codec_dai(card); codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI);
if (!codec_dai) { if (!codec_dai) {
dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
return -EIO; return -EIO;
......
...@@ -54,20 +54,6 @@ enum { ...@@ -54,20 +54,6 @@ enum {
SKL_DPCM_AUDIO_HDMI3_PB, SKL_DPCM_AUDIO_HDMI3_PB,
}; };
static inline struct snd_soc_dai *skl_get_codec_dai(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
list_for_each_entry(rtd, &card->rtd_list, list) {
if (!strncmp(rtd->codec_dai->name, SKL_NUVOTON_CODEC_DAI,
strlen(SKL_NUVOTON_CODEC_DAI)))
return rtd->codec_dai;
}
return NULL;
}
static int platform_clock_control(struct snd_soc_dapm_widget *w, static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
...@@ -76,7 +62,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, ...@@ -76,7 +62,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct snd_soc_dai *codec_dai; struct snd_soc_dai *codec_dai;
int ret; int ret;
codec_dai = skl_get_codec_dai(card); codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI);
if (!codec_dai) { if (!codec_dai) {
dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
return -EIO; return -EIO;
......
...@@ -57,20 +57,6 @@ enum { ...@@ -57,20 +57,6 @@ enum {
SKL_DPCM_AUDIO_HDMI3_PB, SKL_DPCM_AUDIO_HDMI3_PB,
}; };
static inline struct snd_soc_dai *skl_get_codec_dai(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
list_for_each_entry(rtd, &card->rtd_list, list) {
if (!strncmp(rtd->codec_dai->name, SKL_NUVOTON_CODEC_DAI,
strlen(SKL_NUVOTON_CODEC_DAI)))
return rtd->codec_dai;
}
return NULL;
}
static const struct snd_kcontrol_new skylake_controls[] = { static const struct snd_kcontrol_new skylake_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone Jack"), SOC_DAPM_PIN_SWITCH("Headphone Jack"),
SOC_DAPM_PIN_SWITCH("Headset Mic"), SOC_DAPM_PIN_SWITCH("Headset Mic"),
...@@ -86,7 +72,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, ...@@ -86,7 +72,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct snd_soc_dai *codec_dai; struct snd_soc_dai *codec_dai;
int ret; int ret;
codec_dai = skl_get_codec_dai(card); codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI);
if (!codec_dai) { if (!codec_dai) {
dev_err(card->dev, "Codec dai not found\n"); dev_err(card->dev, "Codec dai not found\n");
return -EIO; return -EIO;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册