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
2 changes: 1 addition & 1 deletion drivers/soundwire/amd_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ static int amd_sdw_hw_params(struct snd_pcm_substream *substream,
{
struct amd_sdw_manager *amd_manager = snd_soc_dai_get_drvdata(dai);
struct sdw_amd_dai_runtime *dai_runtime;
struct sdw_stream_config sconfig;
struct sdw_stream_config sconfig = {0};
int ch, dir;
int ret;

Expand Down
4 changes: 4 additions & 0 deletions drivers/soundwire/generic_bandwidth_allocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ void sdw_compute_slave_ports(struct sdw_master_runtime *m_rt,

port_bo += bps * ch;
slave_total_ch += ch;

}
/* Make sure all Peripherals use the same bit slots */
if (m_rt->stream->transport_type == SDW_TRANSPORT_PERIPHERAL_PERIPHERAL)
port_bo = t_data->block_offset;

if (m_rt->direction == SDW_DATA_DIR_TX &&
m_rt->ch_count == slave_total_ch) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/soundwire/intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
struct sdw_intel *sdw = cdns_to_intel(cdns);
struct sdw_cdns_dai_runtime *dai_runtime;
struct sdw_cdns_pdi *pdi;
struct sdw_stream_config sconfig;
struct sdw_stream_config sconfig = {0};
int ch, dir;
int ret;

Expand Down
4 changes: 2 additions & 2 deletions drivers/soundwire/intel_ace2x.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static int intel_ace2x_bpt_open_stream(struct sdw_intel *sdw, struct sdw_slave *
struct sdw_bus *bus = &cdns->bus;
struct sdw_master_prop *prop = &bus->prop;
struct sdw_stream_runtime *stream;
struct sdw_stream_config sconfig;
struct sdw_stream_config sconfig = {0};
struct sdw_port_config *pconfig;
unsigned int pdi0_buf_size_pre_frame;
unsigned int pdi1_buf_size_pre_frame;
Expand Down Expand Up @@ -724,7 +724,7 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
struct sdw_intel *sdw = cdns_to_intel(cdns);
struct sdw_cdns_dai_runtime *dai_runtime;
struct sdw_cdns_pdi *pdi;
struct sdw_stream_config sconfig;
struct sdw_stream_config sconfig = {0};
int ch, dir;
int ret;

Expand Down
2 changes: 1 addition & 1 deletion drivers/soundwire/qcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
struct snd_pcm_hw_params *params,
int direction)
{
struct sdw_stream_config sconfig;
struct sdw_stream_config sconfig = {0};
struct sdw_master_runtime *m_rt;
struct sdw_slave_runtime *s_rt;
struct sdw_port_runtime *p_rt;
Expand Down
1 change: 1 addition & 0 deletions drivers/soundwire/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,7 @@ static int sdw_config_stream(struct device *dev,
}

stream->type = stream_config->type;
stream->transport_type = stream_config->transport_type;
stream->params.rate = stream_config->frame_rate;
stream->params.bps = stream_config->bps;

Expand Down
15 changes: 15 additions & 0 deletions include/linux/soundwire/sdw.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,17 @@ struct sdw_port_params {
unsigned int data_mode;
};

/**
* enum sdw_transport_type: Data Port transport type
*
* @SDW_TRANSPORT_MANAGER_PERIPHERAL: Data is exchanged between the Manager and a Peripheral
* @SDW_TRANSPORT_PERIPHERAL_PERIPHERAL: Data is exchanged between Peripherals
*/
enum sdw_transport_type {
SDW_TRANSPORT_MANAGER_PERIPHERAL = 0,
SDW_TRANSPORT_PERIPHERAL_PERIPHERAL = 1,
};

/**
* struct sdw_transport_params: Data Port Transport Parameters
*
Expand Down Expand Up @@ -924,13 +935,15 @@ struct sdw_port_config {
* @bps: Number of bits per audio sample
* @direction: Data direction
* @type: Stream type PCM, PDM or BPT
* @transport_type: Manager-Peripheral (default) or Peripheral-Peripheral transport
*/
struct sdw_stream_config {
unsigned int frame_rate;
unsigned int ch_count;
unsigned int bps;
enum sdw_data_direction direction;
enum sdw_stream_type type;
enum sdw_transport_type transport_type;
};

/**
Expand Down Expand Up @@ -974,6 +987,7 @@ struct sdw_stream_params {
* @params: Stream parameters
* @state: Current state of the stream
* @type: Stream type PCM, PDM or BPT
* @transport_type: Manager-Peripheral or Peripheral-Peripheral transport
* @m_rt_count: Count of Master runtime(s) in this stream
* @master_list: List of Master runtime(s) in this stream.
* master_list can contain only one m_rt per Master instance
Expand All @@ -984,6 +998,7 @@ struct sdw_stream_runtime {
struct sdw_stream_params params;
enum sdw_stream_state state;
enum sdw_stream_type type;
enum sdw_transport_type transport_type;
int m_rt_count;
struct list_head master_list;
};
Expand Down
29 changes: 28 additions & 1 deletion include/sound/soc_sdw_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
*/
#define SOC_SDW_SIDECAR_AMPS BIT(16)
#define SOC_SDW_CODEC_MIC BIT(17)
/*
* Unlike the sidecar amps, which are not on the SoundWire bus the companion amps are SoundWire
* peripherals. They get their audio data from another SoundWire peripheral (the main amp) over
* the SoundWire bus instead of from the host, so a codec-to-codec dai link is created between
* the main amp and the companion amps.
*/
#define SOC_SDW_COMPANION_AMPS BIT(18)

#define SOC_SDW_UNUSED_DAI_ID -1
#define SOC_SDW_JACK_OUT_DAI_ID 0
Expand Down Expand Up @@ -128,6 +135,11 @@ struct asoc_sdw_dailink {
struct list_head endpoints;
};

struct asoc_sdw_companion_amp_endpoint {
struct asoc_sdw_endpoint *main_amp;
struct list_head comp_ends;
};

extern struct asoc_sdw_codec_info codec_info_list[];
int asoc_sdw_get_codec_info_list_count(void);

Expand All @@ -140,6 +152,17 @@ int asoc_sdw_hw_params(struct snd_pcm_substream *substream,
int asoc_sdw_hw_free(struct snd_pcm_substream *substream);
void asoc_sdw_shutdown(struct snd_pcm_substream *substream);

int asoc_sdw_c_amp_probe(struct snd_soc_dai *dai);
void *asoc_sdw_c_amp_get_sdw_stream(struct snd_soc_dai *dai, int direction);
int asoc_sdw_c_amp_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai);
int asoc_sdw_c_amp_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai);
int asoc_sdw_c_amp_hw_free(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai);
int asoc_sdw_c_amp_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai);
void asoc_sdw_c_amp_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai);

const char *asoc_sdw_get_codec_name(struct device *dev,
const struct asoc_sdw_dai_info *dai_info,
const struct snd_soc_acpi_link_adr *adr_link,
Expand Down Expand Up @@ -176,17 +199,21 @@ int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *d
const struct snd_soc_ops *ops);

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

struct asoc_sdw_dailink *asoc_sdw_find_dailink(struct asoc_sdw_dailink *dailinks,
const struct snd_soc_acpi_endpoint *new);
int asoc_sdw_find_amp_endpoints(struct asoc_sdw_dailink *dailink,
struct asoc_sdw_endpoint **amp_ends,
int max_ends);
int asoc_sdw_get_dai_type(u32 type);

int asoc_sdw_parse_sdw_endpoints(struct device *dev,
struct asoc_sdw_mc_private *ctx,
struct snd_soc_aux_dev *soc_aux,
struct asoc_sdw_dailink *soc_dais,
struct asoc_sdw_endpoint *soc_ends,
struct asoc_sdw_companion_amp_endpoint *comp_ends,
int *num_devs);

int asoc_sdw_rtd_init(struct snd_soc_pcm_runtime *rtd);
Expand Down
17 changes: 14 additions & 3 deletions sound/soc/amd/acp/acp-sdw-legacy-mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,18 +415,21 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
struct device *dev = card->dev;
int sdw_be_num = 0, dmic_num = 0;
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
struct asoc_sdw_companion_amp_endpoint *sof_comp_ends;
struct snd_soc_aux_dev *soc_aux;
struct snd_soc_codec_conf *codec_conf;
struct snd_soc_dai_link *dai_links;
int num_comp_amps = 0;
int num_devs = 0;
int num_ends = 0;
int num_aux = 0;
int num_confs;
int num_links;
int be_id = 0;
int ret;
int i;

ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux, &num_comp_amps);
if (ret < 0) {
dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
return ret;
Expand All @@ -442,15 +445,23 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)

/* One per endpoint, ie. each DAI on each codec/amp */
struct asoc_sdw_endpoint *soc_ends __free(kfree) =
kzalloc_objs(*soc_ends, num_ends);
kzalloc_objs(*soc_ends, num_ends + num_comp_amps);
if (!soc_ends)
return -ENOMEM;

soc_aux = devm_kcalloc(dev, num_aux, sizeof(*soc_aux), GFP_KERNEL);
if (!soc_aux)
return -ENOMEM;

ret = asoc_sdw_parse_sdw_endpoints(dev, ctx, soc_aux, soc_dais, soc_ends, &num_confs);
sof_comp_ends = devm_kcalloc(dev, num_comp_amps, sizeof(*sof_comp_ends), GFP_KERNEL);
if (!sof_comp_ends)
return -ENOMEM;

for (i = 0; i < num_comp_amps; i++)
INIT_LIST_HEAD(&sof_comp_ends[i].comp_ends);

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

Expand Down
17 changes: 14 additions & 3 deletions sound/soc/amd/acp/acp-sdw-sof-mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,18 +280,21 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
int sdw_be_num = 0, dmic_num = 0;
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
struct asoc_sdw_companion_amp_endpoint *sof_comp_ends;
struct snd_soc_aux_dev *sof_aux;
struct snd_soc_codec_conf *codec_conf;
struct snd_soc_dai_link *dai_links;
int num_comp_amps = 0;
int num_devs = 0;
int num_ends = 0;
int num_aux = 0;
int num_confs;
int num_links;
int be_id = 0;
int ret;
int i;

ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux, &num_comp_amps);
if (ret < 0) {
dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
return ret;
Expand All @@ -306,15 +309,23 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)

/* One per endpoint, ie. each DAI on each codec/amp */
struct asoc_sdw_endpoint *sof_ends __free(kfree) =
kzalloc_objs(*sof_ends, num_ends);
kzalloc_objs(*sof_ends, num_ends + num_comp_amps);
if (!sof_ends)
return -ENOMEM;

sof_aux = devm_kcalloc(dev, num_aux, sizeof(*sof_aux), GFP_KERNEL);
if (!sof_aux)
return -ENOMEM;

ret = asoc_sdw_parse_sdw_endpoints(dev, ctx, sof_aux, sof_dais, sof_ends, &num_confs);
sof_comp_ends = devm_kcalloc(dev, num_comp_amps, sizeof(*sof_comp_ends), GFP_KERNEL);
if (!sof_comp_ends)
return -ENOMEM;

for (i = 0; i < num_comp_amps; i++)
INIT_LIST_HEAD(&sof_comp_ends[i].comp_ends);

ret = asoc_sdw_parse_sdw_endpoints(dev, ctx, sof_aux, sof_dais, sof_ends, sof_comp_ends,
&num_confs);
if (ret < 0)
return ret;

Expand Down
Loading
Loading