Skip to content
Open
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
1 change: 1 addition & 0 deletions drivers/soundwire/intel_auxdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct wake_capable_part {

static struct wake_capable_part wake_capable_list[] = {
{0x01fa, 0x4243},
{0x01fa, 0x4245},
{0x025d, 0x5682},
{0x025d, 0x700},
{0x025d, 0x711},
Expand Down
17 changes: 14 additions & 3 deletions include/sound/soc_sdw_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <sound/soc-acpi.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No commit message?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sorry that should definitely have one will add that.


#define SOC_SDW_MAX_DAI_NUM 8
#define SOC_SDW_MAX_AUX_NUM 2
#define SOC_SDW_MAX_NO_PROPS 2
#define SOC_SDW_JACK_JDSRC(quirk) ((quirk) & GENMASK(3, 0))

Expand Down Expand Up @@ -45,6 +46,7 @@ struct asoc_sdw_codec_info;

struct asoc_sdw_dai_info {
const bool direction[2]; /* playback & capture support */
const char *codec_name;
const char *dai_name;
const char *component_name;
const int dai_type;
Expand All @@ -64,17 +66,22 @@ struct asoc_sdw_dai_info {
bool quirk_exclude;
};

struct asoc_sdw_aux_info {
const char *codec_name;
};

struct asoc_sdw_codec_info {
const int part_id;
const int version_id;
const char *codec_name;
const char *name_prefix;
int amp_num;
const u8 acpi_id[ACPI_ID_LEN];
const bool ignore_internal_dmic;
const struct snd_soc_ops *ops;
struct asoc_sdw_dai_info dais[SOC_SDW_MAX_DAI_NUM];
const int dai_num;
struct asoc_sdw_aux_info auxs[SOC_SDW_MAX_AUX_NUM];
const int aux_num;

int (*codec_card_late_probe)(struct snd_soc_card *card);

Expand Down Expand Up @@ -131,7 +138,7 @@ int asoc_sdw_hw_free(struct snd_pcm_substream *substream);
void asoc_sdw_shutdown(struct snd_pcm_substream *substream);

const char *asoc_sdw_get_codec_name(struct device *dev,
const struct asoc_sdw_codec_info *codec_info,
const struct asoc_sdw_dai_info *dai_info,
const struct snd_soc_acpi_link_adr *adr_link,
int adr_index);

Expand Down Expand Up @@ -165,13 +172,15 @@ int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *d
int no_pcm, int (*init)(struct snd_soc_pcm_runtime *rtd),
const struct snd_soc_ops *ops);

int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends);
int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card,
int *num_devs, int *num_ends, int *num_aux);

struct asoc_sdw_dailink *asoc_sdw_find_dailink(struct asoc_sdw_dailink *dailinks,
const struct snd_soc_acpi_endpoint *new);
int asoc_sdw_get_dai_type(u32 type);

int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
struct snd_soc_aux_dev *soc_aux,
struct asoc_sdw_dailink *soc_dais,
struct asoc_sdw_endpoint *soc_ends,
int *num_devs);
Expand Down Expand Up @@ -248,6 +257,8 @@ int asoc_sdw_cs42l42_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_da
int asoc_sdw_cs42l43_hs_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs42l43_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs42l43_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs42l45_hs_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs42l45_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_maxim_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
/* TI */
Expand Down
19 changes: 15 additions & 4 deletions sound/soc/amd/acp/acp-sdw-legacy-mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,20 +360,25 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
struct asoc_sdw_endpoint *soc_ends __free(kfree) = NULL;
struct asoc_sdw_dailink *soc_dais __free(kfree) = NULL;
struct snd_soc_aux_dev *soc_aux;
struct snd_soc_codec_conf *codec_conf;
struct snd_soc_dai_link *dai_links;
int num_devs = 0;
int num_ends = 0;
int num_aux = 0;
int num_confs;
int num_links;
int be_id = 0;
int ret;

ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends);
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
if (ret < 0) {
dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
return ret;
}

num_confs = num_ends;

/* One per DAI link, worst case is a DAI link for every endpoint */
soc_dais = kcalloc(num_ends, sizeof(*soc_dais), GFP_KERNEL);
if (!soc_dais)
Expand All @@ -384,7 +389,11 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
if (!soc_ends)
return -ENOMEM;

ret = asoc_sdw_parse_sdw_endpoints(card, soc_dais, soc_ends, &num_devs);
soc_aux = devm_kcalloc(dev, num_aux, sizeof(*soc_aux), GFP_KERNEL);
if (!soc_aux)
return -ENOMEM;

ret = asoc_sdw_parse_sdw_endpoints(card, soc_aux, soc_dais, soc_ends, &num_confs);
if (ret < 0)
return ret;

Expand All @@ -396,7 +405,7 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)

dev_dbg(dev, "sdw %d, dmic %d", sdw_be_num, dmic_num);

codec_conf = devm_kcalloc(dev, num_devs, sizeof(*codec_conf), GFP_KERNEL);
codec_conf = devm_kcalloc(dev, num_confs, sizeof(*codec_conf), GFP_KERNEL);
if (!codec_conf)
return -ENOMEM;

Expand All @@ -407,9 +416,11 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
return -ENOMEM;

card->codec_conf = codec_conf;
card->num_configs = num_devs;
card->num_configs = num_confs;
card->dai_link = dai_links;
card->num_links = num_links;
card->aux_dev = soc_aux;
card->num_aux_devs = num_aux;

/* SDW */
if (sdw_be_num) {
Expand Down
12 changes: 10 additions & 2 deletions sound/soc/amd/acp/acp-sdw-sof-mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,17 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
struct asoc_sdw_endpoint *sof_ends __free(kfree) = NULL;
struct asoc_sdw_dailink *sof_dais __free(kfree) = NULL;
struct snd_soc_aux_dev *sof_aux;
struct snd_soc_codec_conf *codec_conf;
struct snd_soc_dai_link *dai_links;
int num_devs = 0;
int num_ends = 0;
int num_aux = 0;
int num_links;
int be_id = 0;
int ret;

ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends);
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
if (ret < 0) {
dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
return ret;
Expand All @@ -296,7 +298,11 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
if (!sof_ends)
return -ENOMEM;

ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs);
sof_aux = devm_kcalloc(dev, num_aux, sizeof(*sof_aux), GFP_KERNEL);
if (!sof_aux)
return -ENOMEM;

ret = asoc_sdw_parse_sdw_endpoints(card, sof_aux, sof_dais, sof_ends, &num_devs);
if (ret < 0)
return ret;

Expand All @@ -322,6 +328,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
card->num_configs = num_devs;
card->dai_link = dai_links;
card->num_links = num_links;
card->aux_dev = sof_aux;
card->num_aux_devs = num_aux;

/* SDW */
if (sdw_be_num) {
Expand Down
21 changes: 17 additions & 4 deletions sound/soc/intel/boards/sof_sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,21 +1208,26 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
struct asoc_sdw_codec_info *ssp_info;
struct asoc_sdw_endpoint *sof_ends;
struct asoc_sdw_dailink *sof_dais;
struct snd_soc_aux_dev *sof_aux;
int num_devs = 0;
int num_ends = 0;
int num_aux = 0;
int num_confs;
struct snd_soc_dai_link *dai_links;
int num_links;
int be_id = 0;
int hdmi_num;
unsigned long ssp_mask;
int ret;

ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends);
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
if (ret < 0) {
dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
return ret;
}

num_confs = num_ends;

/*
* One per DAI link, worst case is a DAI link for every endpoint, also
* add one additional to act as a terminator such that code can iterate
Expand All @@ -1239,7 +1244,13 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
goto err_dai;
}

ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs);
sof_aux = devm_kcalloc(dev, num_aux, sizeof(*sof_aux), GFP_KERNEL);
if (!sof_aux) {
ret = -ENOMEM;
goto err_dai;
}

ret = asoc_sdw_parse_sdw_endpoints(card, sof_aux, sof_dais, sof_ends, &num_confs);
if (ret < 0)
goto err_end;

Expand Down Expand Up @@ -1287,7 +1298,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
sdw_be_num, ssp_num, dmic_num,
intel_ctx->hdmi.idisp_codec ? hdmi_num : 0, bt_num);

codec_conf = devm_kcalloc(dev, num_devs, sizeof(*codec_conf), GFP_KERNEL);
codec_conf = devm_kcalloc(dev, num_confs, sizeof(*codec_conf), GFP_KERNEL);
if (!codec_conf) {
ret = -ENOMEM;
goto err_end;
Expand All @@ -1302,9 +1313,11 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
}

card->codec_conf = codec_conf;
card->num_configs = num_devs;
card->num_configs = num_confs;
card->dai_link = dai_links;
card->num_links = num_links;
card->aux_dev = sof_aux;
card->num_aux_devs = num_aux;

/* SDW */
if (sdw_be_num) {
Expand Down
1 change: 1 addition & 0 deletions sound/soc/sdw_utils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ snd-soc-sdw-utils-y := soc_sdw_utils.o soc_sdw_dmic.o soc_sdw_rt_dmic.o \
soc_sdw_rt_amp.o soc_sdw_rt_mf_sdca.o \
soc_sdw_bridge_cs35l56.o \
soc_sdw_cs42l42.o soc_sdw_cs42l43.o \
soc_sdw_cs42l45.o \
soc_sdw_cs_amp.o \
soc_sdw_maxim.o \
soc_sdw_ti_amp.o
Expand Down
80 changes: 80 additions & 0 deletions sound/soc/sdw_utils/soc_sdw_cs42l45.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// SPDX-License-Identifier: GPL-2.0-only
// Based on sof_sdw_rt5682.c
// This file incorporates work covered by the following copyright notice:
// Copyright (c) 2023 Intel Corporation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if the Copyright is needed. And 2025 maybe? @ujfalusi @lgirdwood

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this matches what was done on cs42l42,cs42l42 so I think its probably fine.

// Copyright (c) 2024 Advanced Micro Devices, Inc.

/*
* soc_sdw_cs42l45 - Helpers to handle CS42L45 from generic machine driver
*/
#include <linux/device.h>
#include <linux/errno.h>
#include <sound/jack.h>
#include <sound/soc.h>
#include <sound/soc-card.h>
#include <sound/soc-component.h>
#include <sound/soc-dai.h>
#include <sound/soc_sdw_utils.h>

static struct snd_soc_jack_pin soc_jack_pins[] = {
{
.pin = "cs42l45 OT 43",
.mask = SND_JACK_HEADPHONE,
},
{
.pin = "cs42l45 OT 45",
.mask = SND_JACK_HEADPHONE,
},
{
.pin = "cs42l45 IT 31",
.mask = SND_JACK_MICROPHONE,
},
{
.pin = "cs42l45 IT 33",
.mask = SND_JACK_MICROPHONE,
},
};

int asoc_sdw_cs42l45_hs_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
{
struct snd_soc_card *card = rtd->card;
struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component;
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
struct snd_soc_jack *jack = &ctx->sdw_headset;
int ret;

card->components = devm_kasprintf(card->dev, GFP_KERNEL, "%s hs:cs42l45",
card->components);
if (!card->components)
return -ENOMEM;

ret = snd_soc_card_jack_new_pins(card, "Jack", SND_JACK_MECHANICAL |
SND_JACK_HEADSET | SND_JACK_LINEOUT, jack,
soc_jack_pins, ARRAY_SIZE(soc_jack_pins));
if (ret) {
dev_err(card->dev, "Failed to create jack: %d\n", ret);
return ret;
}

ret = snd_soc_component_set_jack(component, jack, NULL);
if (ret) {
dev_err(card->dev, "Failed to register jack: %d\n", ret);
return ret;
}

return 0;
}
EXPORT_SYMBOL_NS(asoc_sdw_cs42l45_hs_rtd_init, "SND_SOC_SDW_UTILS");

int asoc_sdw_cs42l45_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
{
struct snd_soc_card *card = rtd->card;

card->components = devm_kasprintf(card->dev, GFP_KERNEL, "%s mic:cs42l45-dmic",
card->components);
if (!card->components)
return -ENOMEM;

return 0;
}
EXPORT_SYMBOL_NS(asoc_sdw_cs42l45_dmic_rtd_init, "SND_SOC_SDW_UTILS");
Loading
Loading