mirror of https://gitee.com/openkylin/linux.git
ASoC: Intel: boards: use helper to get codec_dai
Remove duplicate code with a common helper in all Intel machine drivers. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Suggested-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
8a2eca50c6
commit
dfb6ec7ae5
|
@ -55,20 +55,6 @@ enum {
|
|||
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,
|
||||
struct snd_kcontrol *k, int event)
|
||||
{
|
||||
|
@ -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_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) {
|
||||
dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
|
||||
return -EIO;
|
||||
|
|
|
@ -145,22 +145,6 @@ static void log_quirks(struct device *dev)
|
|||
#define BYT_CODEC_DAI1 "rt5640-aif1"
|
||||
#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,
|
||||
struct snd_kcontrol *k, int event)
|
||||
{
|
||||
|
@ -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);
|
||||
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) {
|
||||
dev_err(card->dev,
|
||||
"Codec dai not found; Unable to set platform clock\n");
|
||||
|
|
|
@ -68,18 +68,6 @@ static void log_quirks(struct device *dev)
|
|||
|
||||
#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,
|
||||
struct snd_kcontrol *k, int event)
|
||||
{
|
||||
|
@ -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);
|
||||
int ret;
|
||||
|
||||
codec_dai = byt_get_codec_dai(card);
|
||||
codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI1);
|
||||
if (!codec_dai) {
|
||||
dev_err(card->dev,
|
||||
"Codec dai not found; Unable to set platform clock\n");
|
||||
|
|
|
@ -41,18 +41,6 @@ struct cht_mc_private {
|
|||
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,
|
||||
struct snd_kcontrol *k, int event)
|
||||
{
|
||||
|
@ -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);
|
||||
int ret;
|
||||
|
||||
codec_dai = cht_get_codec_dai(card);
|
||||
codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI);
|
||||
if (!codec_dai) {
|
||||
dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
|
||||
return -EIO;
|
||||
|
|
|
@ -70,21 +70,6 @@ static void log_quirks(struct device *dev)
|
|||
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,
|
||||
struct snd_kcontrol *k, int event)
|
||||
{
|
||||
|
@ -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);
|
||||
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) {
|
||||
dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
|
||||
return -EIO;
|
||||
|
|
|
@ -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,
|
||||
struct snd_kcontrol *k, int event)
|
||||
{
|
||||
|
@ -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);
|
||||
int ret;
|
||||
|
||||
codec_dai = cht_get_codec_dai(card);
|
||||
codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI);
|
||||
if (!codec_dai) {
|
||||
dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
|
||||
return -EIO;
|
||||
|
|
|
@ -54,20 +54,6 @@ enum {
|
|||
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,
|
||||
struct snd_kcontrol *k, int event)
|
||||
{
|
||||
|
@ -76,7 +62,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
|
|||
struct snd_soc_dai *codec_dai;
|
||||
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) {
|
||||
dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
|
||||
return -EIO;
|
||||
|
|
|
@ -57,20 +57,6 @@ enum {
|
|||
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[] = {
|
||||
SOC_DAPM_PIN_SWITCH("Headphone Jack"),
|
||||
SOC_DAPM_PIN_SWITCH("Headset Mic"),
|
||||
|
@ -86,7 +72,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
|
|||
struct snd_soc_dai *codec_dai;
|
||||
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) {
|
||||
dev_err(card->dev, "Codec dai not found\n");
|
||||
return -EIO;
|
||||
|
|
Loading…
Reference in New Issue