mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
ASoC: Intel: sof_rt5682: use common module for HDMI link
Use intel_board module for Intel HDMI DAI link initialization. Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Brent Lu <brent.lu@intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20231012190826.142619-23-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
498a4da506
commit
89cadbd8d8
2 changed files with 33 additions and 94 deletions
|
@ -499,6 +499,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH
|
|||
select SND_SOC_RT5682S
|
||||
select SND_SOC_DMIC
|
||||
select SND_SOC_INTEL_HDA_DSP_COMMON
|
||||
select SND_SOC_INTEL_SOF_BOARD_HELPERS
|
||||
select SND_SOC_INTEL_SOF_MAXIM_COMMON
|
||||
select SND_SOC_INTEL_SOF_REALTEK_COMMON
|
||||
select SND_SOC_INTEL_SOF_SSP_COMMON
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
#include "../../codecs/rt5682s.h"
|
||||
#include "../../codecs/rt5645.h"
|
||||
#include "../common/soc-intel-quirks.h"
|
||||
#include "hda_dsp_common.h"
|
||||
#include "sof_hdmi_common.h"
|
||||
#include "sof_board_helpers.h"
|
||||
#include "sof_maxim_common.h"
|
||||
#include "sof_realtek_common.h"
|
||||
#include "sof_ssp_common.h"
|
||||
|
@ -60,16 +59,6 @@
|
|||
static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
|
||||
SOF_RT5682_SSP_CODEC(0);
|
||||
|
||||
static int is_legacy_cpu;
|
||||
|
||||
struct sof_card_private {
|
||||
struct clk *mclk;
|
||||
struct snd_soc_jack sof_headset;
|
||||
struct sof_hdmi_private hdmi;
|
||||
enum sof_ssp_codec codec_type;
|
||||
enum sof_ssp_codec amp_type;
|
||||
};
|
||||
|
||||
static int sof_rt5682_quirk_cb(const struct dmi_system_id *id)
|
||||
{
|
||||
sof_rt5682_quirk = (unsigned long)id->driver_data;
|
||||
|
@ -221,16 +210,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
|
|||
{}
|
||||
};
|
||||
|
||||
static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct snd_soc_dai *dai = snd_soc_rtd_to_codec(rtd, 0);
|
||||
|
||||
ctx->hdmi.hdmi_comp = dai->component;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct snd_soc_jack_pin jack_pins[] = {
|
||||
{
|
||||
.pin = "Headphone Jack",
|
||||
|
@ -246,7 +225,7 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
|
|||
{
|
||||
struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component;
|
||||
struct snd_soc_jack *jack;
|
||||
struct snd_soc_jack *jack = &ctx->headset_jack;
|
||||
int extra_jack_data;
|
||||
int ret, mclk_freq;
|
||||
|
||||
|
@ -302,11 +281,11 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
|
|||
* to disable a clock that has not been enabled,
|
||||
* we need to enable the clock first.
|
||||
*/
|
||||
ret = clk_prepare_enable(ctx->mclk);
|
||||
ret = clk_prepare_enable(ctx->rt5682.mclk);
|
||||
if (!ret)
|
||||
clk_disable_unprepare(ctx->mclk);
|
||||
clk_disable_unprepare(ctx->rt5682.mclk);
|
||||
|
||||
ret = clk_set_rate(ctx->mclk, 19200000);
|
||||
ret = clk_set_rate(ctx->rt5682.mclk, 19200000);
|
||||
|
||||
if (ret)
|
||||
dev_err(rtd->dev, "unable to set MCLK rate\n");
|
||||
|
@ -321,7 +300,7 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
|
|||
SND_JACK_HEADSET | SND_JACK_BTN_0 |
|
||||
SND_JACK_BTN_1 | SND_JACK_BTN_2 |
|
||||
SND_JACK_BTN_3,
|
||||
&ctx->sof_headset,
|
||||
jack,
|
||||
jack_pins,
|
||||
ARRAY_SIZE(jack_pins));
|
||||
if (ret) {
|
||||
|
@ -329,8 +308,6 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
|
|||
return ret;
|
||||
}
|
||||
|
||||
jack = &ctx->sof_headset;
|
||||
|
||||
snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
|
||||
snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
|
||||
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
|
||||
|
@ -367,7 +344,7 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream,
|
|||
|
||||
if (sof_rt5682_quirk & SOF_RT5682_MCLK_EN) {
|
||||
if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) {
|
||||
ret = clk_prepare_enable(ctx->mclk);
|
||||
ret = clk_prepare_enable(ctx->rt5682.mclk);
|
||||
if (ret < 0) {
|
||||
dev_err(rtd->dev,
|
||||
"could not configure MCLK state");
|
||||
|
@ -508,14 +485,7 @@ static int sof_card_late_probe(struct snd_soc_card *card)
|
|||
return err;
|
||||
}
|
||||
|
||||
/* HDMI is not supported by SOF on Baytrail/CherryTrail */
|
||||
if (is_legacy_cpu || !ctx->hdmi.idisp_codec)
|
||||
return 0;
|
||||
|
||||
if (!ctx->hdmi.hdmi_comp)
|
||||
return -EINVAL;
|
||||
|
||||
return hda_dsp_hdmi_build_controls(card, ctx->hdmi.hdmi_comp);
|
||||
return sof_intel_board_card_late_probe(card);
|
||||
}
|
||||
|
||||
static const struct snd_kcontrol_new sof_controls[] = {
|
||||
|
@ -642,12 +612,13 @@ static struct snd_soc_dai_link *
|
|||
sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type,
|
||||
enum sof_ssp_codec amp_type, int ssp_codec,
|
||||
int ssp_amp, int dmic_be_num, int hdmi_num,
|
||||
bool idisp_codec)
|
||||
bool idisp_codec, bool is_legacy_cpu)
|
||||
{
|
||||
struct snd_soc_dai_link_component *idisp_components;
|
||||
struct snd_soc_dai_link_component *cpus;
|
||||
struct snd_soc_dai_link *links;
|
||||
int i, id = 0;
|
||||
int i;
|
||||
int id = 0;
|
||||
int ret;
|
||||
int hdmi_id_offset = 0;
|
||||
|
||||
links = devm_kcalloc(dev, sof_audio_card_rt5682.num_links,
|
||||
|
@ -748,47 +719,12 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type,
|
|||
}
|
||||
|
||||
/* HDMI */
|
||||
if (hdmi_num > 0) {
|
||||
idisp_components = devm_kcalloc(dev,
|
||||
hdmi_num,
|
||||
sizeof(struct snd_soc_dai_link_component),
|
||||
GFP_KERNEL);
|
||||
if (!idisp_components)
|
||||
goto devm_err;
|
||||
}
|
||||
for (i = 1; i <= hdmi_num; i++) {
|
||||
links[id].name = devm_kasprintf(dev, GFP_KERNEL,
|
||||
"iDisp%d", i);
|
||||
if (!links[id].name)
|
||||
goto devm_err;
|
||||
ret = sof_intel_board_set_intel_hdmi_link(dev, &links[id], id,
|
||||
i, idisp_codec);
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
||||
links[id].id = id;
|
||||
links[id].cpus = &cpus[id];
|
||||
links[id].num_cpus = 1;
|
||||
links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
|
||||
"iDisp%d Pin", i);
|
||||
if (!links[id].cpus->dai_name)
|
||||
goto devm_err;
|
||||
|
||||
if (idisp_codec) {
|
||||
idisp_components[i - 1].name = "ehdaudio0D2";
|
||||
idisp_components[i - 1].dai_name = devm_kasprintf(dev,
|
||||
GFP_KERNEL,
|
||||
"intel-hdmi-hifi%d",
|
||||
i);
|
||||
if (!idisp_components[i - 1].dai_name)
|
||||
goto devm_err;
|
||||
} else {
|
||||
idisp_components[i - 1] = snd_soc_dummy_dlc;
|
||||
}
|
||||
|
||||
links[id].codecs = &idisp_components[i - 1];
|
||||
links[id].num_codecs = 1;
|
||||
links[id].platforms = platform_component;
|
||||
links[id].num_platforms = ARRAY_SIZE(platform_component);
|
||||
links[id].init = (i == 1) ? sof_hdmi_init : NULL;
|
||||
links[id].dpcm_playback = 1;
|
||||
links[id].no_pcm = 1;
|
||||
id++;
|
||||
}
|
||||
|
||||
|
@ -929,7 +865,7 @@ static int sof_audio_probe(struct platform_device *pdev)
|
|||
struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
|
||||
struct snd_soc_dai_link *dai_links;
|
||||
struct sof_card_private *ctx;
|
||||
int dmic_be_num, hdmi_num;
|
||||
int dmic_be_num;
|
||||
int ret, ssp_amp, ssp_codec;
|
||||
|
||||
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
|
||||
|
@ -954,20 +890,21 @@ static int sof_audio_probe(struct platform_device *pdev)
|
|||
}
|
||||
|
||||
if (soc_intel_is_byt() || soc_intel_is_cht()) {
|
||||
is_legacy_cpu = 1;
|
||||
ctx->rt5682.is_legacy_cpu = true;
|
||||
dmic_be_num = 0;
|
||||
hdmi_num = 0;
|
||||
/* HDMI is not supported by SOF on Baytrail/CherryTrail */
|
||||
ctx->hdmi_num = 0;
|
||||
/* default quirk for legacy cpu */
|
||||
sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
|
||||
SOF_RT5682_MCLK_BYTCHT_EN |
|
||||
SOF_RT5682_SSP_CODEC(2);
|
||||
} else {
|
||||
dmic_be_num = 2;
|
||||
hdmi_num = (sof_rt5682_quirk & SOF_RT5682_NUM_HDMIDEV_MASK) >>
|
||||
ctx->hdmi_num = (sof_rt5682_quirk & SOF_RT5682_NUM_HDMIDEV_MASK) >>
|
||||
SOF_RT5682_NUM_HDMIDEV_SHIFT;
|
||||
/* default number of HDMI DAI's */
|
||||
if (!hdmi_num)
|
||||
hdmi_num = 3;
|
||||
if (!ctx->hdmi_num)
|
||||
ctx->hdmi_num = 3;
|
||||
|
||||
if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)
|
||||
ctx->hdmi.idisp_codec = true;
|
||||
|
@ -975,9 +912,9 @@ static int sof_audio_probe(struct platform_device *pdev)
|
|||
|
||||
/* need to get main clock from pmc */
|
||||
if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) {
|
||||
ctx->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
|
||||
if (IS_ERR(ctx->mclk)) {
|
||||
ret = PTR_ERR(ctx->mclk);
|
||||
ctx->rt5682.mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
|
||||
if (IS_ERR(ctx->rt5682.mclk)) {
|
||||
ret = PTR_ERR(ctx->rt5682.mclk);
|
||||
|
||||
dev_err(&pdev->dev,
|
||||
"Failed to get MCLK from pmc_plt_clk_3: %d\n",
|
||||
|
@ -985,7 +922,7 @@ static int sof_audio_probe(struct platform_device *pdev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(ctx->mclk);
|
||||
ret = clk_prepare_enable(ctx->rt5682.mclk);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev,
|
||||
"could not configure MCLK state");
|
||||
|
@ -1001,7 +938,7 @@ static int sof_audio_probe(struct platform_device *pdev)
|
|||
ssp_codec = sof_rt5682_quirk & SOF_RT5682_SSP_CODEC_MASK;
|
||||
|
||||
/* compute number of dai links */
|
||||
sof_audio_card_rt5682.num_links = 1 + dmic_be_num + hdmi_num;
|
||||
sof_audio_card_rt5682.num_links = 1 + dmic_be_num + ctx->hdmi_num;
|
||||
|
||||
if (ctx->amp_type != CODEC_NONE)
|
||||
sof_audio_card_rt5682.num_links++;
|
||||
|
@ -1016,8 +953,9 @@ static int sof_audio_probe(struct platform_device *pdev)
|
|||
|
||||
dai_links = sof_card_dai_links_create(&pdev->dev, ctx->codec_type,
|
||||
ctx->amp_type, ssp_codec, ssp_amp,
|
||||
dmic_be_num, hdmi_num,
|
||||
ctx->hdmi.idisp_codec);
|
||||
dmic_be_num, ctx->hdmi_num,
|
||||
ctx->hdmi.idisp_codec,
|
||||
ctx->rt5682.is_legacy_cpu);
|
||||
if (!dai_links)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -1277,7 +1215,7 @@ MODULE_AUTHOR("Sathya Prakash M R <sathya.prakash.m.r@intel.com>");
|
|||
MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>");
|
||||
MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
|
||||
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS);
|
||||
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);
|
||||
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON);
|
||||
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);
|
||||
|
|
Loading…
Reference in a new issue