Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ssp common module - codec type detection #4536

Merged
merged 6 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sound/soc/intel/boards/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ config SND_SOC_INTEL_SOF_REALTEK_COMMON
config SND_SOC_INTEL_SOF_CIRRUS_COMMON
tristate

config SND_SOC_INTEL_SOF_SSP_COMMON
tristate

if SND_SOC_INTEL_CATPT

config SND_SOC_INTEL_HASWELL_MACH
Expand Down Expand Up @@ -493,6 +496,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH
select SND_SOC_INTEL_HDA_DSP_COMMON
select SND_SOC_INTEL_SOF_MAXIM_COMMON
select SND_SOC_INTEL_SOF_REALTEK_COMMON
select SND_SOC_INTEL_SOF_SSP_COMMON
help
This adds support for ASoC machine driver for SOF platforms
with rt5650 or rt5682 codec.
Expand All @@ -510,6 +514,7 @@ config SND_SOC_INTEL_SOF_CS42L42_MACH
select SND_SOC_HDAC_HDMI
select SND_SOC_INTEL_HDA_DSP_COMMON
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 cs42l42 codec.
Expand Down Expand Up @@ -561,6 +566,7 @@ config SND_SOC_INTEL_SOF_NAU8825_MACH
select SND_SOC_INTEL_HDA_DSP_COMMON
select SND_SOC_INTEL_SOF_MAXIM_COMMON
select SND_SOC_INTEL_SOF_REALTEK_COMMON
select SND_SOC_INTEL_SOF_SSP_COMMON
help
This adds support for ASoC machine driver for SOF platforms
with nau8825 codec.
Expand Down Expand Up @@ -632,6 +638,7 @@ config SND_SOC_INTEL_SOF_SSP_AMP_MACH
select SND_SOC_INTEL_HDA_DSP_COMMON
select SND_SOC_INTEL_SOF_REALTEK_COMMON
select SND_SOC_INTEL_SOF_CIRRUS_COMMON
select SND_SOC_INTEL_SOF_SSP_COMMON
help
This adds support for ASoC machine driver for SOF platforms
with RT1308/CS35L41 I2S audio codec.
Expand Down
3 changes: 3 additions & 0 deletions sound/soc/intel/boards/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ obj-$(CONFIG_SND_SOC_INTEL_SOF_REALTEK_COMMON) += snd-soc-intel-sof-realtek-comm

snd-soc-intel-sof-cirrus-common-objs += sof_cirrus_common.o
obj-$(CONFIG_SND_SOC_INTEL_SOF_CIRRUS_COMMON) += snd-soc-intel-sof-cirrus-common.o

snd-soc-intel-sof-ssp-common-objs += sof_ssp_common.o
obj-$(CONFIG_SND_SOC_INTEL_SOF_SSP_COMMON) += snd-soc-intel-sof-ssp-common.o
9 changes: 5 additions & 4 deletions sound/soc/intel/boards/sof_cirrus_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
#define __SOF_CIRRUS_COMMON_H

#include <sound/soc.h>
#include "sof_ssp_common.h"

/*
* Cirrus Logic CS35L41/CS35L53
*/
#define CS35L41_CODEC_DAI "cs35l41-pcm"
#define CS35L41_DEV0_NAME "i2c-CSC3541:00"
#define CS35L41_DEV1_NAME "i2c-CSC3541:01"
#define CS35L41_DEV2_NAME "i2c-CSC3541:02"
#define CS35L41_DEV3_NAME "i2c-CSC3541:03"
#define CS35L41_DEV0_NAME "i2c-" CS35L41_ACPI_HID ":00"
#define CS35L41_DEV1_NAME "i2c-" CS35L41_ACPI_HID ":01"
#define CS35L41_DEV2_NAME "i2c-" CS35L41_ACPI_HID ":02"
#define CS35L41_DEV3_NAME "i2c-" CS35L41_ACPI_HID ":03"

void cs35l41_set_dai_link(struct snd_soc_dai_link *link);
void cs35l41_set_codec_conf(struct snd_soc_card *card);
Expand Down
55 changes: 28 additions & 27 deletions sound/soc/intel/boards/sof_cs42l42.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
#include "../common/soc-intel-quirks.h"
#include "hda_dsp_common.h"
#include "sof_maxim_common.h"
#include "sof_ssp_common.h"

#define NAME_SIZE 32

#define SOF_CS42L42_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0))
#define SOF_CS42L42_SSP_CODEC_MASK (GENMASK(2, 0))
#define SOF_SPEAKER_AMP_PRESENT BIT(3)
#define SOF_CS42L42_SSP_AMP_SHIFT 4
#define SOF_CS42L42_SSP_AMP_MASK (GENMASK(6, 4))
#define SOF_CS42L42_SSP_AMP(quirk) \
Expand All @@ -46,8 +46,6 @@
#define SOF_CS42L42_SSP_BT_MASK (GENMASK(28, 26))
#define SOF_CS42L42_SSP_BT(quirk) \
(((quirk) << SOF_CS42L42_SSP_BT_SHIFT) & SOF_CS42L42_SSP_BT_MASK)
#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(29)
#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(30)

enum {
LINK_NONE = 0,
Expand Down Expand Up @@ -83,6 +81,8 @@ struct sof_card_private {
struct snd_soc_jack headset_jack;
struct list_head hdmi_pcm_list;
bool common_hdmi_codec_drv;
enum sof_ssp_codec codec_type;
enum sof_ssp_codec amp_type;
};

static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd)
Expand Down Expand Up @@ -299,12 +299,13 @@ static struct snd_soc_dai_link_component dmic_component[] = {
static int create_spk_amp_dai_links(struct device *dev,
struct snd_soc_dai_link *links,
struct snd_soc_dai_link_component *cpus,
int *id, int ssp_amp)
int *id, enum sof_ssp_codec amp_type,
int ssp_amp)
{
int ret = 0;

/* speaker amp */
if (!(sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT))
if (amp_type == CODEC_NONE)
return 0;

links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec",
Expand All @@ -316,14 +317,16 @@ static int create_spk_amp_dai_links(struct device *dev,

links[*id].id = *id;

if (sof_cs42l42_quirk & SOF_MAX98357A_SPEAKER_AMP_PRESENT) {
switch (amp_type) {
case CODEC_MAX98357A:
max_98357a_dai_link(&links[*id]);
} else if (sof_cs42l42_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) {
break;
case CODEC_MAX98360A:
max_98360a_dai_link(&links[*id]);
} else {
dev_err(dev, "no amp defined\n");
ret = -EINVAL;
goto devm_err;
break;
default:
dev_err(dev, "invalid amp type %d\n", amp_type);
return -EINVAL;
}

links[*id].platforms = platform_component;
Expand Down Expand Up @@ -528,12 +531,10 @@ static int create_bt_offload_dai_links(struct device *dev,
return -ENOMEM;
}

static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
int ssp_codec,
int ssp_amp,
int ssp_bt,
int dmic_be_num,
int hdmi_num)
static struct snd_soc_dai_link *
sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
int ssp_codec, int ssp_amp, int ssp_bt,
int dmic_be_num, int hdmi_num)
{
struct snd_soc_dai_link_component *cpus;
struct snd_soc_dai_link *links;
Expand Down Expand Up @@ -561,7 +562,8 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
}
break;
case LINK_SPK:
ret = create_spk_amp_dai_links(dev, links, cpus, &id, ssp_amp);
ret = create_spk_amp_dai_links(dev, links, cpus, &id,
amp_type, ssp_amp);
if (ret < 0) {
dev_err(dev, "fail to create spk amp dai links, ret %d\n",
ret);
Expand Down Expand Up @@ -624,6 +626,9 @@ static int sof_audio_probe(struct platform_device *pdev)

mach = pdev->dev.platform_data;

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

if (soc_intel_is_glk()) {
dmic_be_num = 1;
hdmi_num = 3;
Expand All @@ -649,13 +654,14 @@ static int sof_audio_probe(struct platform_device *pdev)
/* compute number of dai links */
sof_audio_card_cs42l42.num_links = 1 + dmic_be_num + hdmi_num;

if (sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT)
if (ctx->amp_type != CODEC_NONE)
sof_audio_card_cs42l42.num_links++;
if (sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT)
sof_audio_card_cs42l42.num_links++;

dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp,
ssp_bt, dmic_be_num, hdmi_num);
dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type,
ssp_codec, ssp_amp, ssp_bt,
dmic_be_num, hdmi_num);
if (!dai_links)
return -ENOMEM;

Expand Down Expand Up @@ -683,24 +689,18 @@ static const struct platform_device_id board_ids[] = {
{
.name = "glk_cs4242_mx98357a",
.driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(2) |
SOF_SPEAKER_AMP_PRESENT |
SOF_MAX98357A_SPEAKER_AMP_PRESENT |
SOF_CS42L42_SSP_AMP(1)) |
SOF_CS42L42_DAILINK(LINK_SPK, LINK_HP, LINK_DMIC, LINK_HDMI, LINK_NONE),
},
{
.name = "jsl_cs4242_mx98360a",
.driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(0) |
SOF_SPEAKER_AMP_PRESENT |
SOF_MAX98360A_SPEAKER_AMP_PRESENT |
SOF_CS42L42_SSP_AMP(1)) |
SOF_CS42L42_DAILINK(LINK_HP, LINK_DMIC, LINK_HDMI, LINK_SPK, LINK_NONE),
},
{
.name = "adl_mx98360a_cs4242",
.driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(0) |
SOF_SPEAKER_AMP_PRESENT |
SOF_MAX98360A_SPEAKER_AMP_PRESENT |
SOF_CS42L42_SSP_AMP(1) |
SOF_CS42L42_NUM_HDMIDEV(4) |
SOF_BT_OFFLOAD_PRESENT |
Expand All @@ -727,3 +727,4 @@ MODULE_AUTHOR("Brent Lu <[email protected]>");
MODULE_LICENSE("GPL");
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);
13 changes: 8 additions & 5 deletions sound/soc/intel/boards/sof_maxim_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
#define __SOF_MAXIM_COMMON_H

#include <sound/soc.h>
#include "sof_ssp_common.h"

/*
* Maxim MAX98373
*/
#define MAX_98373_CODEC_DAI "max98373-aif1"
#define MAX_98373_DEV0_NAME "i2c-MX98373:00"
#define MAX_98373_DEV1_NAME "i2c-MX98373:01"
#define MAX_98373_DEV0_NAME "i2c-" MAX_98373_ACPI_HID ":00"
#define MAX_98373_DEV1_NAME "i2c-" MAX_98373_ACPI_HID ":01"

extern struct snd_soc_dai_link_component max_98373_components[2];
extern struct snd_soc_ops max_98373_ops;
Expand All @@ -27,7 +31,6 @@ int max_98373_trigger(struct snd_pcm_substream *substream, int cmd);
/*
* Maxim MAX98390
*/
#define MAX_98390_ACPI_HID "MX98390"
#define MAX_98390_CODEC_DAI "max98390-aif1"
#define MAX_98390_DEV0_NAME "i2c-" MAX_98390_ACPI_HID ":00"
#define MAX_98390_DEV1_NAME "i2c-" MAX_98390_ACPI_HID ":01"
Expand All @@ -41,8 +44,8 @@ void max_98390_set_codec_conf(struct device *dev, struct snd_soc_card *card);
* Maxim MAX98357A/MAX98360A
*/
#define MAX_98357A_CODEC_DAI "HiFi"
#define MAX_98357A_DEV0_NAME "MX98357A:00"
#define MAX_98360A_DEV0_NAME "MX98360A:00"
#define MAX_98357A_DEV0_NAME MAX_98357A_ACPI_HID ":00"
#define MAX_98360A_DEV0_NAME MAX_98360A_ACPI_HID ":00"

void max_98357a_dai_link(struct snd_soc_dai_link *link);
void max_98360a_dai_link(struct snd_soc_dai_link *link);
Expand Down
Loading