Merge remote-tracking branch 'asoc/for-5.8' into asoc-linus
This commit is contained in:
@@ -899,7 +899,7 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
|
|||||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 8) |
|
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 8) |
|
||||||
SPI_BPW_MASK(16) | SPI_BPW_MASK(32);
|
SPI_BPW_MASK(16) | SPI_BPW_MASK(32);
|
||||||
|
|
||||||
spi->wq = alloc_ordered_workqueue(dev_name(dev), 0);
|
spi->wq = alloc_ordered_workqueue(dev_name(dev), WQ_MEM_RECLAIM);
|
||||||
if (!spi->wq) {
|
if (!spi->wq) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto err_clk_put;
|
goto err_clk_put;
|
||||||
|
@@ -23,8 +23,40 @@
|
|||||||
struct max98357a_priv {
|
struct max98357a_priv {
|
||||||
struct gpio_desc *sdmode;
|
struct gpio_desc *sdmode;
|
||||||
unsigned int sdmode_delay;
|
unsigned int sdmode_delay;
|
||||||
|
int sdmode_switch;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int max98357a_daiops_trigger(struct snd_pcm_substream *substream,
|
||||||
|
int cmd, struct snd_soc_dai *dai)
|
||||||
|
{
|
||||||
|
struct snd_soc_component *component = dai->component;
|
||||||
|
struct max98357a_priv *max98357a =
|
||||||
|
snd_soc_component_get_drvdata(component);
|
||||||
|
|
||||||
|
if (!max98357a->sdmode)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
|
case SNDRV_PCM_TRIGGER_RESUME:
|
||||||
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
||||||
|
mdelay(max98357a->sdmode_delay);
|
||||||
|
if (max98357a->sdmode_switch) {
|
||||||
|
gpiod_set_value(max98357a->sdmode, 1);
|
||||||
|
dev_dbg(component->dev, "set sdmode to 1");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SNDRV_PCM_TRIGGER_STOP:
|
||||||
|
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||||
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||||
|
gpiod_set_value(max98357a->sdmode, 0);
|
||||||
|
dev_dbg(component->dev, "set sdmode to 0");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int max98357a_sdmode_event(struct snd_soc_dapm_widget *w,
|
static int max98357a_sdmode_event(struct snd_soc_dapm_widget *w,
|
||||||
struct snd_kcontrol *kcontrol, int event)
|
struct snd_kcontrol *kcontrol, int event)
|
||||||
{
|
{
|
||||||
@@ -33,17 +65,10 @@ static int max98357a_sdmode_event(struct snd_soc_dapm_widget *w,
|
|||||||
struct max98357a_priv *max98357a =
|
struct max98357a_priv *max98357a =
|
||||||
snd_soc_component_get_drvdata(component);
|
snd_soc_component_get_drvdata(component);
|
||||||
|
|
||||||
if (!max98357a->sdmode)
|
if (event & SND_SOC_DAPM_POST_PMU)
|
||||||
return 0;
|
max98357a->sdmode_switch = 1;
|
||||||
|
else if (event & SND_SOC_DAPM_POST_PMD)
|
||||||
if (event & SND_SOC_DAPM_POST_PMU) {
|
max98357a->sdmode_switch = 0;
|
||||||
msleep(max98357a->sdmode_delay);
|
|
||||||
gpiod_set_value(max98357a->sdmode, 1);
|
|
||||||
dev_dbg(component->dev, "set sdmode to 1");
|
|
||||||
} else if (event & SND_SOC_DAPM_PRE_PMD) {
|
|
||||||
gpiod_set_value(max98357a->sdmode, 0);
|
|
||||||
dev_dbg(component->dev, "set sdmode to 0");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -52,7 +77,7 @@ static const struct snd_soc_dapm_widget max98357a_dapm_widgets[] = {
|
|||||||
SND_SOC_DAPM_OUTPUT("Speaker"),
|
SND_SOC_DAPM_OUTPUT("Speaker"),
|
||||||
SND_SOC_DAPM_OUT_DRV_E("SD_MODE", SND_SOC_NOPM, 0, 0, NULL, 0,
|
SND_SOC_DAPM_OUT_DRV_E("SD_MODE", SND_SOC_NOPM, 0, 0, NULL, 0,
|
||||||
max98357a_sdmode_event,
|
max98357a_sdmode_event,
|
||||||
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
|
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct snd_soc_dapm_route max98357a_dapm_routes[] = {
|
static const struct snd_soc_dapm_route max98357a_dapm_routes[] = {
|
||||||
@@ -71,6 +96,10 @@ static const struct snd_soc_component_driver max98357a_component_driver = {
|
|||||||
.non_legacy_dai_naming = 1,
|
.non_legacy_dai_naming = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct snd_soc_dai_ops max98357a_dai_ops = {
|
||||||
|
.trigger = max98357a_daiops_trigger,
|
||||||
|
};
|
||||||
|
|
||||||
static struct snd_soc_dai_driver max98357a_dai_driver = {
|
static struct snd_soc_dai_driver max98357a_dai_driver = {
|
||||||
.name = "HiFi",
|
.name = "HiFi",
|
||||||
.playback = {
|
.playback = {
|
||||||
@@ -90,6 +119,7 @@ static struct snd_soc_dai_driver max98357a_dai_driver = {
|
|||||||
.channels_min = 1,
|
.channels_min = 1,
|
||||||
.channels_max = 2,
|
.channels_max = 2,
|
||||||
},
|
},
|
||||||
|
.ops = &max98357a_dai_ops,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int max98357a_platform_probe(struct platform_device *pdev)
|
static int max98357a_platform_probe(struct platform_device *pdev)
|
||||||
|
@@ -678,7 +678,7 @@ static const struct snd_kcontrol_new max98390_dai_controls =
|
|||||||
|
|
||||||
static const struct snd_soc_dapm_widget max98390_dapm_widgets[] = {
|
static const struct snd_soc_dapm_widget max98390_dapm_widgets[] = {
|
||||||
SND_SOC_DAPM_DAC_E("Amp Enable", "HiFi Playback",
|
SND_SOC_DAPM_DAC_E("Amp Enable", "HiFi Playback",
|
||||||
MAX98390_R203A_AMP_EN, 0, 0, max98390_dac_event,
|
SND_SOC_NOPM, 0, 0, max98390_dac_event,
|
||||||
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
|
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
|
||||||
SND_SOC_DAPM_MUX("DAI Sel Mux", SND_SOC_NOPM, 0, 0,
|
SND_SOC_DAPM_MUX("DAI Sel Mux", SND_SOC_NOPM, 0, 0,
|
||||||
&max98390_dai_controls),
|
&max98390_dai_controls),
|
||||||
|
@@ -680,10 +680,11 @@ static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai)
|
|||||||
regmap_write(sai->regmap, FSL_SAI_RCSR(ofs), 0);
|
regmap_write(sai->regmap, FSL_SAI_RCSR(ofs), 0);
|
||||||
|
|
||||||
regmap_update_bits(sai->regmap, FSL_SAI_TCR1(ofs),
|
regmap_update_bits(sai->regmap, FSL_SAI_TCR1(ofs),
|
||||||
FSL_SAI_CR1_RFW_MASK,
|
FSL_SAI_CR1_RFW_MASK(sai->soc_data->fifo_depth),
|
||||||
sai->soc_data->fifo_depth - FSL_SAI_MAXBURST_TX);
|
sai->soc_data->fifo_depth - FSL_SAI_MAXBURST_TX);
|
||||||
regmap_update_bits(sai->regmap, FSL_SAI_RCR1(ofs),
|
regmap_update_bits(sai->regmap, FSL_SAI_RCR1(ofs),
|
||||||
FSL_SAI_CR1_RFW_MASK, FSL_SAI_MAXBURST_RX - 1);
|
FSL_SAI_CR1_RFW_MASK(sai->soc_data->fifo_depth),
|
||||||
|
FSL_SAI_MAXBURST_RX - 1);
|
||||||
|
|
||||||
snd_soc_dai_init_dma_data(cpu_dai, &sai->dma_params_tx,
|
snd_soc_dai_init_dma_data(cpu_dai, &sai->dma_params_tx,
|
||||||
&sai->dma_params_rx);
|
&sai->dma_params_rx);
|
||||||
|
@@ -94,7 +94,7 @@
|
|||||||
#define FSL_SAI_CSR_FRDE BIT(0)
|
#define FSL_SAI_CSR_FRDE BIT(0)
|
||||||
|
|
||||||
/* SAI Transmit and Receive Configuration 1 Register */
|
/* SAI Transmit and Receive Configuration 1 Register */
|
||||||
#define FSL_SAI_CR1_RFW_MASK 0x1f
|
#define FSL_SAI_CR1_RFW_MASK(x) ((x) - 1)
|
||||||
|
|
||||||
/* SAI Transmit and Receive Configuration 2 Register */
|
/* SAI Transmit and Receive Configuration 2 Register */
|
||||||
#define FSL_SAI_CR2_SYNC BIT(30)
|
#define FSL_SAI_CR2_SYNC BIT(30)
|
||||||
|
@@ -336,22 +336,45 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
|
|||||||
struct snd_interval *chan = hw_param_interval(params,
|
struct snd_interval *chan = hw_param_interval(params,
|
||||||
SNDRV_PCM_HW_PARAM_CHANNELS);
|
SNDRV_PCM_HW_PARAM_CHANNELS);
|
||||||
struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
|
struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
|
||||||
struct snd_soc_dpcm *dpcm = container_of(
|
struct snd_soc_dpcm *dpcm, *rtd_dpcm = NULL;
|
||||||
params, struct snd_soc_dpcm, hw_params);
|
|
||||||
struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link;
|
/*
|
||||||
struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link;
|
* The following loop will be called only for playback stream
|
||||||
|
* In this platform, there is only one playback device on every SSP
|
||||||
|
*/
|
||||||
|
for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_PLAYBACK, dpcm) {
|
||||||
|
rtd_dpcm = dpcm;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This following loop will be called only for capture stream
|
||||||
|
* In this platform, there is only one capture device on every SSP
|
||||||
|
*/
|
||||||
|
for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_CAPTURE, dpcm) {
|
||||||
|
rtd_dpcm = dpcm;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rtd_dpcm)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The above 2 loops are mutually exclusive based on the stream direction,
|
||||||
|
* thus rtd_dpcm variable will never be overwritten
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The ADSP will convert the FE rate to 48k, stereo, 24 bit
|
* The ADSP will convert the FE rate to 48k, stereo, 24 bit
|
||||||
*/
|
*/
|
||||||
if (!strcmp(fe_dai_link->name, "Kbl Audio Port") ||
|
if (!strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Port") ||
|
||||||
!strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") ||
|
!strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Headset Playback") ||
|
||||||
!strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) {
|
!strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Capture Port")) {
|
||||||
rate->min = rate->max = 48000;
|
rate->min = rate->max = 48000;
|
||||||
chan->min = chan->max = 2;
|
chan->min = chan->max = 2;
|
||||||
snd_mask_none(fmt);
|
snd_mask_none(fmt);
|
||||||
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
|
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
|
||||||
} else if (!strcmp(fe_dai_link->name, "Kbl Audio DMIC cap")) {
|
} else if (!strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio DMIC cap")) {
|
||||||
if (params_channels(params) == 2 ||
|
if (params_channels(params) == 2 ||
|
||||||
DMIC_CH(dmic_constraints) == 2)
|
DMIC_CH(dmic_constraints) == 2)
|
||||||
chan->min = chan->max = 2;
|
chan->min = chan->max = 2;
|
||||||
@@ -362,7 +385,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
|
|||||||
* The speaker on the SSP0 supports S16_LE and not S24_LE.
|
* The speaker on the SSP0 supports S16_LE and not S24_LE.
|
||||||
* thus changing the mask here
|
* thus changing the mask here
|
||||||
*/
|
*/
|
||||||
if (!strcmp(be_dai_link->name, "SSP0-Codec"))
|
if (!strcmp(rtd_dpcm->be->dai_link->name, "SSP0-Codec"))
|
||||||
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
|
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -33,6 +33,7 @@ struct skl_hda_private {
|
|||||||
int dai_index;
|
int dai_index;
|
||||||
const char *platform_name;
|
const char *platform_name;
|
||||||
bool common_hdmi_codec_drv;
|
bool common_hdmi_codec_drv;
|
||||||
|
bool idisp_codec;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];
|
extern struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];
|
||||||
|
@@ -79,6 +79,9 @@ skl_hda_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link)
|
|||||||
link->platforms->name = ctx->platform_name;
|
link->platforms->name = ctx->platform_name;
|
||||||
link->nonatomic = 1;
|
link->nonatomic = 1;
|
||||||
|
|
||||||
|
if (!ctx->idisp_codec)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (strstr(link->name, "HDMI")) {
|
if (strstr(link->name, "HDMI")) {
|
||||||
ret = skl_hda_hdmi_add_pcm(card, ctx->pcm_count);
|
ret = skl_hda_hdmi_add_pcm(card, ctx->pcm_count);
|
||||||
|
|
||||||
@@ -118,19 +121,20 @@ static char hda_soc_components[30];
|
|||||||
static int skl_hda_fill_card_info(struct snd_soc_acpi_mach_params *mach_params)
|
static int skl_hda_fill_card_info(struct snd_soc_acpi_mach_params *mach_params)
|
||||||
{
|
{
|
||||||
struct snd_soc_card *card = &hda_soc_card;
|
struct snd_soc_card *card = &hda_soc_card;
|
||||||
|
struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
|
||||||
struct snd_soc_dai_link *dai_link;
|
struct snd_soc_dai_link *dai_link;
|
||||||
u32 codec_count, codec_mask, idisp_mask;
|
u32 codec_count, codec_mask;
|
||||||
int i, num_links, num_route;
|
int i, num_links, num_route;
|
||||||
|
|
||||||
codec_mask = mach_params->codec_mask;
|
codec_mask = mach_params->codec_mask;
|
||||||
codec_count = hweight_long(codec_mask);
|
codec_count = hweight_long(codec_mask);
|
||||||
idisp_mask = codec_mask & IDISP_CODEC_MASK;
|
ctx->idisp_codec = !!(codec_mask & IDISP_CODEC_MASK);
|
||||||
|
|
||||||
if (!codec_count || codec_count > 2 ||
|
if (!codec_count || codec_count > 2 ||
|
||||||
(codec_count == 2 && !idisp_mask))
|
(codec_count == 2 && !ctx->idisp_codec))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (codec_mask == idisp_mask) {
|
if (codec_mask == IDISP_CODEC_MASK) {
|
||||||
/* topology with iDisp as the only HDA codec */
|
/* topology with iDisp as the only HDA codec */
|
||||||
num_links = IDISP_DAI_COUNT + DMIC_DAI_COUNT;
|
num_links = IDISP_DAI_COUNT + DMIC_DAI_COUNT;
|
||||||
num_route = IDISP_ROUTE_COUNT;
|
num_route = IDISP_ROUTE_COUNT;
|
||||||
@@ -152,7 +156,7 @@ static int skl_hda_fill_card_info(struct snd_soc_acpi_mach_params *mach_params)
|
|||||||
num_route = ARRAY_SIZE(skl_hda_map);
|
num_route = ARRAY_SIZE(skl_hda_map);
|
||||||
card->dapm_widgets = skl_hda_widgets;
|
card->dapm_widgets = skl_hda_widgets;
|
||||||
card->num_dapm_widgets = ARRAY_SIZE(skl_hda_widgets);
|
card->num_dapm_widgets = ARRAY_SIZE(skl_hda_widgets);
|
||||||
if (!idisp_mask) {
|
if (!ctx->idisp_codec) {
|
||||||
for (i = 0; i < IDISP_DAI_COUNT; i++) {
|
for (i = 0; i < IDISP_DAI_COUNT; i++) {
|
||||||
skl_hda_be_dai_links[i].codecs = dummy_codec;
|
skl_hda_be_dai_links[i].codecs = dummy_codec;
|
||||||
skl_hda_be_dai_links[i].num_codecs =
|
skl_hda_be_dai_links[i].num_codecs =
|
||||||
@@ -211,6 +215,8 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
|
|||||||
if (!mach)
|
if (!mach)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
snd_soc_card_set_drvdata(&hda_soc_card, ctx);
|
||||||
|
|
||||||
ret = skl_hda_fill_card_info(&mach->mach_params);
|
ret = skl_hda_fill_card_info(&mach->mach_params);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&pdev->dev, "Unsupported HDAudio/iDisp configuration found\n");
|
dev_err(&pdev->dev, "Unsupported HDAudio/iDisp configuration found\n");
|
||||||
@@ -223,7 +229,6 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
|
|||||||
ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
|
ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
|
||||||
|
|
||||||
hda_soc_card.dev = &pdev->dev;
|
hda_soc_card.dev = &pdev->dev;
|
||||||
snd_soc_card_set_drvdata(&hda_soc_card, ctx);
|
|
||||||
|
|
||||||
if (mach->mach_params.dmic_num > 0) {
|
if (mach->mach_params.dmic_num > 0) {
|
||||||
snprintf(hda_soc_components, sizeof(hda_soc_components),
|
snprintf(hda_soc_components, sizeof(hda_soc_components),
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
struct snd_soc_acpi_mach snd_soc_acpi_intel_ehl_machines[] = {
|
struct snd_soc_acpi_mach snd_soc_acpi_intel_ehl_machines[] = {
|
||||||
{
|
{
|
||||||
.id = "INTC1027",
|
.id = "10EC5660",
|
||||||
.drv_name = "ehl_rt5660",
|
.drv_name = "ehl_rt5660",
|
||||||
.sof_fw_filename = "sof-ehl.ri",
|
.sof_fw_filename = "sof-ehl.ri",
|
||||||
.sof_tplg_filename = "sof-ehl-rt5660.tplg",
|
.sof_tplg_filename = "sof-ehl-rt5660.tplg",
|
||||||
|
@@ -116,7 +116,7 @@ static int axg_card_add_tdm_loopback(struct snd_soc_card *card,
|
|||||||
|
|
||||||
lb = &card->dai_link[*index + 1];
|
lb = &card->dai_link[*index + 1];
|
||||||
|
|
||||||
lb->name = kasprintf(GFP_KERNEL, "%s-lb", pad->name);
|
lb->name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-lb", pad->name);
|
||||||
if (!lb->name)
|
if (!lb->name)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@@ -327,20 +327,22 @@ static int axg_card_add_link(struct snd_soc_card *card, struct device_node *np,
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (axg_card_cpu_is_playback_fe(dai_link->cpus->of_node))
|
if (axg_card_cpu_is_playback_fe(dai_link->cpus->of_node))
|
||||||
ret = meson_card_set_fe_link(card, dai_link, np, true);
|
return meson_card_set_fe_link(card, dai_link, np, true);
|
||||||
else if (axg_card_cpu_is_capture_fe(dai_link->cpus->of_node))
|
else if (axg_card_cpu_is_capture_fe(dai_link->cpus->of_node))
|
||||||
ret = meson_card_set_fe_link(card, dai_link, np, false);
|
return meson_card_set_fe_link(card, dai_link, np, false);
|
||||||
else
|
|
||||||
ret = meson_card_set_be_link(card, dai_link, np);
|
|
||||||
|
|
||||||
|
|
||||||
|
ret = meson_card_set_be_link(card, dai_link, np);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (axg_card_cpu_is_tdm_iface(dai_link->cpus->of_node))
|
if (axg_card_cpu_is_codec(dai_link->cpus->of_node)) {
|
||||||
ret = axg_card_parse_tdm(card, np, index);
|
|
||||||
else if (axg_card_cpu_is_codec(dai_link->cpus->of_node)) {
|
|
||||||
dai_link->params = &codec_params;
|
dai_link->params = &codec_params;
|
||||||
dai_link->no_pcm = 0; /* link is not a DPCM BE */
|
} else {
|
||||||
|
dai_link->no_pcm = 1;
|
||||||
|
snd_soc_dai_link_set_capabilities(dai_link);
|
||||||
|
if (axg_card_cpu_is_tdm_iface(dai_link->cpus->of_node))
|
||||||
|
ret = axg_card_parse_tdm(card, np, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -70,7 +70,7 @@ EXPORT_SYMBOL_GPL(axg_tdm_formatter_set_channel_masks);
|
|||||||
static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter)
|
static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter)
|
||||||
{
|
{
|
||||||
struct axg_tdm_stream *ts = formatter->stream;
|
struct axg_tdm_stream *ts = formatter->stream;
|
||||||
bool invert = formatter->drv->quirks->invert_sclk;
|
bool invert;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Do nothing if the formatter is already enabled */
|
/* Do nothing if the formatter is already enabled */
|
||||||
@@ -96,11 +96,12 @@ static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If sclk is inverted, invert it back and provide the inversion
|
* If sclk is inverted, it means the bit should latched on the
|
||||||
* required by the formatter
|
* rising edge which is what our HW expects. If not, we need to
|
||||||
|
* invert it before the formatter.
|
||||||
*/
|
*/
|
||||||
invert ^= axg_tdm_sclk_invert(ts->iface->fmt);
|
invert = axg_tdm_sclk_invert(ts->iface->fmt);
|
||||||
ret = clk_set_phase(formatter->sclk, invert ? 180 : 0);
|
ret = clk_set_phase(formatter->sclk, invert ? 0 : 180);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@@ -16,7 +16,6 @@ struct snd_kcontrol;
|
|||||||
|
|
||||||
struct axg_tdm_formatter_hw {
|
struct axg_tdm_formatter_hw {
|
||||||
unsigned int skew_offset;
|
unsigned int skew_offset;
|
||||||
bool invert_sclk;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct axg_tdm_formatter_ops {
|
struct axg_tdm_formatter_ops {
|
||||||
|
@@ -119,16 +119,23 @@ static int axg_tdm_iface_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
|||||||
{
|
{
|
||||||
struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai);
|
struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai);
|
||||||
|
|
||||||
/* These modes are not supported */
|
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||||
if (fmt & (SND_SOC_DAIFMT_CBS_CFM | SND_SOC_DAIFMT_CBM_CFS)) {
|
case SND_SOC_DAIFMT_CBS_CFS:
|
||||||
dev_err(dai->dev, "only CBS_CFS and CBM_CFM are supported\n");
|
if (!iface->mclk) {
|
||||||
return -EINVAL;
|
dev_err(dai->dev, "cpu clock master: mclk missing\n");
|
||||||
}
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
/* If the TDM interface is the clock master, it requires mclk */
|
case SND_SOC_DAIFMT_CBM_CFM:
|
||||||
if (!iface->mclk && (fmt & SND_SOC_DAIFMT_CBS_CFS)) {
|
break;
|
||||||
dev_err(dai->dev, "cpu clock master: mclk missing\n");
|
|
||||||
return -ENODEV;
|
case SND_SOC_DAIFMT_CBS_CFM:
|
||||||
|
case SND_SOC_DAIFMT_CBM_CFS:
|
||||||
|
dev_err(dai->dev, "only CBS_CFS and CBM_CFM are supported\n");
|
||||||
|
/* Fall-through */
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
iface->fmt = fmt;
|
iface->fmt = fmt;
|
||||||
@@ -319,7 +326,8 @@ static int axg_tdm_iface_hw_params(struct snd_pcm_substream *substream,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (iface->fmt & SND_SOC_DAIFMT_CBS_CFS) {
|
if ((iface->fmt & SND_SOC_DAIFMT_MASTER_MASK) ==
|
||||||
|
SND_SOC_DAIFMT_CBS_CFS) {
|
||||||
ret = axg_tdm_iface_set_sclk(dai, params);
|
ret = axg_tdm_iface_set_sclk(dai, params);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -228,15 +228,29 @@ static const struct axg_tdm_formatter_driver axg_tdmin_drv = {
|
|||||||
.regmap_cfg = &axg_tdmin_regmap_cfg,
|
.regmap_cfg = &axg_tdmin_regmap_cfg,
|
||||||
.ops = &axg_tdmin_ops,
|
.ops = &axg_tdmin_ops,
|
||||||
.quirks = &(const struct axg_tdm_formatter_hw) {
|
.quirks = &(const struct axg_tdm_formatter_hw) {
|
||||||
.invert_sclk = false,
|
|
||||||
.skew_offset = 2,
|
.skew_offset = 2,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct axg_tdm_formatter_driver g12a_tdmin_drv = {
|
||||||
|
.component_drv = &axg_tdmin_component_drv,
|
||||||
|
.regmap_cfg = &axg_tdmin_regmap_cfg,
|
||||||
|
.ops = &axg_tdmin_ops,
|
||||||
|
.quirks = &(const struct axg_tdm_formatter_hw) {
|
||||||
|
.skew_offset = 3,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
static const struct of_device_id axg_tdmin_of_match[] = {
|
static const struct of_device_id axg_tdmin_of_match[] = {
|
||||||
{
|
{
|
||||||
.compatible = "amlogic,axg-tdmin",
|
.compatible = "amlogic,axg-tdmin",
|
||||||
.data = &axg_tdmin_drv,
|
.data = &axg_tdmin_drv,
|
||||||
|
}, {
|
||||||
|
.compatible = "amlogic,g12a-tdmin",
|
||||||
|
.data = &g12a_tdmin_drv,
|
||||||
|
}, {
|
||||||
|
.compatible = "amlogic,sm1-tdmin",
|
||||||
|
.data = &g12a_tdmin_drv,
|
||||||
}, {}
|
}, {}
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, axg_tdmin_of_match);
|
MODULE_DEVICE_TABLE(of, axg_tdmin_of_match);
|
||||||
|
@@ -238,7 +238,6 @@ static const struct axg_tdm_formatter_driver axg_tdmout_drv = {
|
|||||||
.regmap_cfg = &axg_tdmout_regmap_cfg,
|
.regmap_cfg = &axg_tdmout_regmap_cfg,
|
||||||
.ops = &axg_tdmout_ops,
|
.ops = &axg_tdmout_ops,
|
||||||
.quirks = &(const struct axg_tdm_formatter_hw) {
|
.quirks = &(const struct axg_tdm_formatter_hw) {
|
||||||
.invert_sclk = true,
|
|
||||||
.skew_offset = 1,
|
.skew_offset = 1,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -248,7 +247,6 @@ static const struct axg_tdm_formatter_driver g12a_tdmout_drv = {
|
|||||||
.regmap_cfg = &axg_tdmout_regmap_cfg,
|
.regmap_cfg = &axg_tdmout_regmap_cfg,
|
||||||
.ops = &axg_tdmout_ops,
|
.ops = &axg_tdmout_ops,
|
||||||
.quirks = &(const struct axg_tdm_formatter_hw) {
|
.quirks = &(const struct axg_tdm_formatter_hw) {
|
||||||
.invert_sclk = true,
|
|
||||||
.skew_offset = 2,
|
.skew_offset = 2,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -309,7 +307,6 @@ static const struct axg_tdm_formatter_driver sm1_tdmout_drv = {
|
|||||||
.regmap_cfg = &axg_tdmout_regmap_cfg,
|
.regmap_cfg = &axg_tdmout_regmap_cfg,
|
||||||
.ops = &axg_tdmout_ops,
|
.ops = &axg_tdmout_ops,
|
||||||
.quirks = &(const struct axg_tdm_formatter_hw) {
|
.quirks = &(const struct axg_tdm_formatter_hw) {
|
||||||
.invert_sclk = true,
|
|
||||||
.skew_offset = 2,
|
.skew_offset = 2,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@@ -96,21 +96,21 @@ static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (gx_card_cpu_identify(dai_link->cpus, "FIFO"))
|
if (gx_card_cpu_identify(dai_link->cpus, "FIFO"))
|
||||||
ret = meson_card_set_fe_link(card, dai_link, np, true);
|
return meson_card_set_fe_link(card, dai_link, np, true);
|
||||||
else
|
|
||||||
ret = meson_card_set_be_link(card, dai_link, np);
|
|
||||||
|
|
||||||
|
ret = meson_card_set_be_link(card, dai_link, np);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Check if the cpu is the i2s encoder and parse i2s data */
|
|
||||||
if (gx_card_cpu_identify(dai_link->cpus, "I2S Encoder"))
|
|
||||||
ret = gx_card_parse_i2s(card, np, index);
|
|
||||||
|
|
||||||
/* Or apply codec to codec params if necessary */
|
/* Or apply codec to codec params if necessary */
|
||||||
else if (gx_card_cpu_identify(dai_link->cpus, "CODEC CTRL")) {
|
if (gx_card_cpu_identify(dai_link->cpus, "CODEC CTRL")) {
|
||||||
dai_link->params = &codec_params;
|
dai_link->params = &codec_params;
|
||||||
dai_link->no_pcm = 0; /* link is not a DPCM BE */
|
} else {
|
||||||
|
dai_link->no_pcm = 1;
|
||||||
|
snd_soc_dai_link_set_capabilities(dai_link);
|
||||||
|
/* Check if the cpu is the i2s encoder and parse i2s data */
|
||||||
|
if (gx_card_cpu_identify(dai_link->cpus, "I2S Encoder"))
|
||||||
|
ret = gx_card_parse_i2s(card, np, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -147,10 +147,6 @@ int meson_card_set_be_link(struct snd_soc_card *card,
|
|||||||
struct device_node *np;
|
struct device_node *np;
|
||||||
int ret, num_codecs;
|
int ret, num_codecs;
|
||||||
|
|
||||||
link->no_pcm = 1;
|
|
||||||
link->dpcm_playback = 1;
|
|
||||||
link->dpcm_capture = 1;
|
|
||||||
|
|
||||||
num_codecs = of_get_child_count(node);
|
num_codecs = of_get_child_count(node);
|
||||||
if (!num_codecs) {
|
if (!num_codecs) {
|
||||||
dev_err(card->dev, "be link %s has no codec\n",
|
dev_err(card->dev, "be link %s has no codec\n",
|
||||||
|
@@ -446,7 +446,6 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
|
|||||||
|
|
||||||
dev->parent = card->dev;
|
dev->parent = card->dev;
|
||||||
dev->release = soc_release_rtd_dev;
|
dev->release = soc_release_rtd_dev;
|
||||||
dev->groups = soc_dev_attr_groups;
|
|
||||||
|
|
||||||
dev_set_name(dev, "%s", dai_link->name);
|
dev_set_name(dev, "%s", dai_link->name);
|
||||||
|
|
||||||
@@ -503,6 +502,10 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
|
|||||||
/* see for_each_card_rtds */
|
/* see for_each_card_rtds */
|
||||||
list_add_tail(&rtd->list, &card->rtd_list);
|
list_add_tail(&rtd->list, &card->rtd_list);
|
||||||
|
|
||||||
|
ret = device_add_groups(dev, soc_dev_attr_groups);
|
||||||
|
if (ret < 0)
|
||||||
|
goto free_rtd;
|
||||||
|
|
||||||
return rtd;
|
return rtd;
|
||||||
|
|
||||||
free_rtd:
|
free_rtd:
|
||||||
|
@@ -400,28 +400,30 @@ void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link)
|
|||||||
struct snd_soc_dai_link_component *codec;
|
struct snd_soc_dai_link_component *codec;
|
||||||
struct snd_soc_dai *dai;
|
struct snd_soc_dai *dai;
|
||||||
bool supported[SNDRV_PCM_STREAM_LAST + 1];
|
bool supported[SNDRV_PCM_STREAM_LAST + 1];
|
||||||
|
bool supported_cpu;
|
||||||
|
bool supported_codec;
|
||||||
int direction;
|
int direction;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for_each_pcm_streams(direction) {
|
for_each_pcm_streams(direction) {
|
||||||
supported[direction] = true;
|
supported_cpu = false;
|
||||||
|
supported_codec = false;
|
||||||
|
|
||||||
for_each_link_cpus(dai_link, i, cpu) {
|
for_each_link_cpus(dai_link, i, cpu) {
|
||||||
dai = snd_soc_find_dai(cpu);
|
dai = snd_soc_find_dai(cpu);
|
||||||
if (!dai || !snd_soc_dai_stream_valid(dai, direction)) {
|
if (dai && snd_soc_dai_stream_valid(dai, direction)) {
|
||||||
supported[direction] = false;
|
supported_cpu = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!supported[direction])
|
|
||||||
continue;
|
|
||||||
for_each_link_codecs(dai_link, i, codec) {
|
for_each_link_codecs(dai_link, i, codec) {
|
||||||
dai = snd_soc_find_dai(codec);
|
dai = snd_soc_find_dai(codec);
|
||||||
if (!dai || !snd_soc_dai_stream_valid(dai, direction)) {
|
if (dai && snd_soc_dai_stream_valid(dai, direction)) {
|
||||||
supported[direction] = false;
|
supported_codec = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
supported[direction] = supported_cpu && supported_codec;
|
||||||
}
|
}
|
||||||
|
|
||||||
dai_link->dpcm_playback = supported[SNDRV_PCM_STREAM_PLAYBACK];
|
dai_link->dpcm_playback = supported[SNDRV_PCM_STREAM_PLAYBACK];
|
||||||
|
@@ -2802,30 +2802,36 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
|
|||||||
if (rtd->dai_link->dpcm_playback) {
|
if (rtd->dai_link->dpcm_playback) {
|
||||||
stream = SNDRV_PCM_STREAM_PLAYBACK;
|
stream = SNDRV_PCM_STREAM_PLAYBACK;
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
|
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
||||||
if (!snd_soc_dai_stream_valid(cpu_dai,
|
if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
|
||||||
stream)) {
|
playback = 1;
|
||||||
dev_err(rtd->card->dev,
|
break;
|
||||||
"CPU DAI %s for rtd %s does not support playback\n",
|
|
||||||
cpu_dai->name,
|
|
||||||
rtd->dai_link->stream_name);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
playback = 1;
|
}
|
||||||
|
|
||||||
|
if (!playback) {
|
||||||
|
dev_err(rtd->card->dev,
|
||||||
|
"No CPU DAIs support playback for stream %s\n",
|
||||||
|
rtd->dai_link->stream_name);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (rtd->dai_link->dpcm_capture) {
|
if (rtd->dai_link->dpcm_capture) {
|
||||||
stream = SNDRV_PCM_STREAM_CAPTURE;
|
stream = SNDRV_PCM_STREAM_CAPTURE;
|
||||||
|
|
||||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai)
|
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
||||||
if (!snd_soc_dai_stream_valid(cpu_dai,
|
if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
|
||||||
stream)) {
|
capture = 1;
|
||||||
dev_err(rtd->card->dev,
|
break;
|
||||||
"CPU DAI %s for rtd %s does not support capture\n",
|
|
||||||
cpu_dai->name,
|
|
||||||
rtd->dai_link->stream_name);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
capture = 1;
|
}
|
||||||
|
|
||||||
|
if (!capture) {
|
||||||
|
dev_err(rtd->card->dev,
|
||||||
|
"No CPU DAIs support capture for stream %s\n",
|
||||||
|
rtd->dai_link->stream_name);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Adapt stream for codec2codec links */
|
/* Adapt stream for codec2codec links */
|
||||||
|
Reference in New Issue
Block a user