ASoC: Intel: avs: ssm4567: Validate machine board configuration
Allow for board to be used with TDMs. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Link: https://lore.kernel.org/r/20231012083514.492626-17-amadeuszx.slawinski@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
797611b5ce
commit
5e07eb3ab9
@ -14,6 +14,7 @@
|
|||||||
#include <sound/soc.h>
|
#include <sound/soc.h>
|
||||||
#include <sound/soc-acpi.h>
|
#include <sound/soc-acpi.h>
|
||||||
#include "../../../codecs/nau8825.h"
|
#include "../../../codecs/nau8825.h"
|
||||||
|
#include "../utils.h"
|
||||||
|
|
||||||
#define SKL_SSM_CODEC_DAI "ssm4567-hifi"
|
#define SKL_SSM_CODEC_DAI "ssm4567-hifi"
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ avs_ssm4567_be_fixup(struct snd_soc_pcm_runtime *runrime, struct snd_pcm_hw_para
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port,
|
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port,
|
||||||
struct snd_soc_dai_link **dai_link)
|
int tdm_slot, struct snd_soc_dai_link **dai_link)
|
||||||
{
|
{
|
||||||
struct snd_soc_dai_link_component *platform;
|
struct snd_soc_dai_link_component *platform;
|
||||||
struct snd_soc_dai_link *dl;
|
struct snd_soc_dai_link *dl;
|
||||||
@ -95,13 +96,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
|
|||||||
|
|
||||||
platform->name = platform_name;
|
platform->name = platform_name;
|
||||||
|
|
||||||
dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port);
|
dl->name = devm_kasprintf(dev, GFP_KERNEL,
|
||||||
|
AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot));
|
||||||
dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL);
|
dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL);
|
||||||
dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs) * 2, GFP_KERNEL);
|
dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs) * 2, GFP_KERNEL);
|
||||||
if (!dl->name || !dl->cpus || !dl->codecs)
|
if (!dl->name || !dl->cpus || !dl->codecs)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port);
|
dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
|
||||||
|
AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot));
|
||||||
dl->codecs[0].name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT343B:00");
|
dl->codecs[0].name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT343B:00");
|
||||||
dl->codecs[0].dai_name = devm_kasprintf(dev, GFP_KERNEL, "ssm4567-hifi");
|
dl->codecs[0].dai_name = devm_kasprintf(dev, GFP_KERNEL, "ssm4567-hifi");
|
||||||
dl->codecs[1].name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT343B:01");
|
dl->codecs[1].name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT343B:01");
|
||||||
@ -136,13 +139,16 @@ static int avs_ssm4567_probe(struct platform_device *pdev)
|
|||||||
struct snd_soc_card *card;
|
struct snd_soc_card *card;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
const char *pname;
|
const char *pname;
|
||||||
int ssp_port, ret;
|
int ssp_port, tdm_slot, ret;
|
||||||
|
|
||||||
mach = dev_get_platdata(dev);
|
mach = dev_get_platdata(dev);
|
||||||
pname = mach->mach_params.platform;
|
pname = mach->mach_params.platform;
|
||||||
ssp_port = __ffs(mach->mach_params.i2s_link_mask);
|
|
||||||
|
|
||||||
ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link);
|
ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "Failed to create dai link: %d", ret);
|
dev_err(dev, "Failed to create dai link: %d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user