Skip to content

Commit

Permalink
ASoC: Intel: sof_da7219: use ssp-common module to detect codec
Browse files Browse the repository at this point in the history
Use ssp-common module to detect codec and amplifier type in driver
probe function and remove all quirks about amplifier type.

Signed-off-by: Brent Lu <[email protected]>
  • Loading branch information
brentlu authored and bardliao committed Sep 8, 2023
1 parent ae88b42 commit 72c81dd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
1 change: 1 addition & 0 deletions sound/soc/intel/boards/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ config SND_SOC_INTEL_SOF_DA7219_MACH
select SND_SOC_MAX98373_I2C
select SND_SOC_DMIC
select SND_SOC_INTEL_SOF_MAXIM_COMMON
select SND_SOC_INTEL_SOF_SSP_COMMON
help
This adds support for ASoC machine driver for SOF platforms
with Dialog DA7219 I2S audio codec.
Expand Down
45 changes: 28 additions & 17 deletions sound/soc/intel/boards/sof_da7219.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
#include "../../codecs/da7219.h"
#include "hda_dsp_common.h"
#include "sof_maxim_common.h"

/* Speaker amp type
* TBD: use ssp-common module for type detection
*/
#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(0)
#define SOF_MAX98373_SPEAKER_AMP_PRESENT BIT(1)
#include "sof_ssp_common.h"

/* Board Quirks */
#define SOF_DA7219_JSL_BOARD BIT(2)
Expand All @@ -39,6 +34,8 @@ struct card_private {
struct snd_soc_jack headset_jack;
struct list_head hdmi_pcm_list;
struct snd_soc_jack hdmi[3];
enum sof_ssp_codec codec_type;
enum sof_ssp_codec amp_type;

unsigned int pll_bypass:1;
};
Expand Down Expand Up @@ -479,15 +476,24 @@ static int audio_probe(struct platform_device *pdev)
if (pdev->id_entry && pdev->id_entry->driver_data)
board_quirk = (unsigned long)pdev->id_entry->driver_data;

ctx->codec_type = sof_ssp_detect_codec_type(&pdev->dev);
ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev);

if (board_quirk & SOF_DA7219_JSL_BOARD) {
/* backward-compatible with existing devices */
if (board_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT)
switch (ctx->amp_type) {
case CODEC_MAX98360A:
card_da7219.name = devm_kstrdup(&pdev->dev,
"da7219max98360a",
GFP_KERNEL);
else if (board_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT)
break;
case CODEC_MAX98373:
card_da7219.name = devm_kstrdup(&pdev->dev, "da7219max",
GFP_KERNEL);
break;
default:
break;
}

dai_links = jsl_dais;
amp_idx = 0;
Expand All @@ -503,9 +509,11 @@ static int audio_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "board_quirk = %lx\n", board_quirk);

/* speaker amp */
if (board_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) {
switch (ctx->amp_type) {
case CODEC_MAX98360A:
max_98360a_dai_link(&dai_links[amp_idx]);
} else if (board_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) {
break;
case CODEC_MAX98373:
dai_links[amp_idx].codecs = max_98373_components;
dai_links[amp_idx].num_codecs = ARRAY_SIZE(max_98373_components);
dai_links[amp_idx].init = max_98373_spk_codec_init;
Expand All @@ -518,6 +526,10 @@ static int audio_probe(struct platform_device *pdev)
}

max_98373_set_codec_conf(&card_da7219);
break;
default:
dev_err(&pdev->dev, "invalid amp type %d\n", ctx->amp_type);
return -EINVAL;
}

card_da7219.dai_link = dai_links;
Expand All @@ -538,18 +550,16 @@ static int audio_probe(struct platform_device *pdev)

static const struct platform_device_id board_ids[] = {
{
.name = "sof_da7219_mx98373",
.driver_data = (kernel_ulong_t)(SOF_MAX98373_SPEAKER_AMP_PRESENT |
SOF_DA7219_JSL_BOARD),
.name = "jsl_mx98373_da7219",
.driver_data = (kernel_ulong_t)(SOF_DA7219_JSL_BOARD),
},
{
.name = "sof_da7219_mx98360a",
.driver_data = (kernel_ulong_t)(SOF_MAX98360A_SPEAKER_AMP_PRESENT |
SOF_DA7219_JSL_BOARD),
.name = "jsl_mx98360_da7219",
.driver_data = (kernel_ulong_t)(SOF_DA7219_JSL_BOARD),
},
{
.name = "adl_mx98360_da7219",
.driver_data = (kernel_ulong_t)(SOF_MAX98360A_SPEAKER_AMP_PRESENT),
/* no quirk needed for this board */
},
{ }
};
Expand All @@ -572,3 +582,4 @@ MODULE_AUTHOR("Brent Lu <[email protected]>");
MODULE_LICENSE("GPL v2");
MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);
12 changes: 7 additions & 5 deletions sound/soc/intel/common/soc-acpi-intel-jsl-match.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static const struct snd_soc_acpi_codecs essx_83x6 = {
.codecs = { "ESSX8316", "ESSX8326", "ESSX8336"},
};

static const struct snd_soc_acpi_codecs jsl_7219_98373_codecs = {
static const struct snd_soc_acpi_codecs mx98373_spk = {
.num_codecs = 1,
.codecs = {"MX98373"}
};
Expand Down Expand Up @@ -52,14 +52,16 @@ static const struct snd_soc_acpi_codecs rt5682_rt5682s_hp = {
struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = {
{
.id = "DLGS7219",
.drv_name = "sof_da7219_mx98373",
.sof_tplg_filename = "sof-jsl-da7219.tplg",
.drv_name = "jsl_mx98373_da7219",
.machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &jsl_7219_98373_codecs,
.quirk_data = &mx98373_spk,
.sof_tplg_filename = "sof-jsl-da7219.tplg",
},
{
.id = "DLGS7219",
.drv_name = "sof_da7219_mx98360a",
.drv_name = "jsl_mx98360_da7219",
.machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &mx98360a_spk,
.sof_tplg_filename = "sof-jsl-da7219-mx98360a.tplg",
},
{
Expand Down

0 comments on commit 72c81dd

Please sign in to comment.