Skip to content

Commit

Permalink
Merge remote-tracking branch 'sof/main' into zephyr
Browse files Browse the repository at this point in the history
  • Loading branch information
nashif committed Aug 8, 2023
2 parents e763929 + 2d1f53a commit ee40f61
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 223 deletions.
14 changes: 1 addition & 13 deletions src/audio/aria/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,11 @@ static void aria_set_stream_params(struct comp_buffer *buffer,
struct processing_module *mod)
{
struct comp_buffer __sparse_cache *buffer_c;
enum sof_ipc_frame valid_fmt, frame_fmt;
const struct ipc4_audio_format *audio_fmt = &mod->priv.cfg.base_cfg.audio_fmt;
struct aria_data *cd = module_get_private_data(mod);

buffer_c = buffer_acquire(buffer);

audio_stream_fmt_conversion(audio_fmt->depth,
audio_fmt->valid_bit_depth,
&frame_fmt, &valid_fmt,
audio_fmt->s_type);
audio_stream_set_buffer_fmt(&buffer_c->stream,
audio_fmt->interleaving_style);
audio_stream_set_frm_fmt(&buffer_c->stream, frame_fmt);
audio_stream_set_valid_fmt(&buffer_c->stream, valid_fmt);
audio_stream_set_channels(&buffer_c->stream, cd->chan_cnt);
audio_stream_set_rate(&buffer_c->stream, audio_fmt->sampling_frequency);

ipc4_update_buffer_format(buffer_c, audio_fmt);
#ifdef ARIA_GENERIC
audio_stream_init_alignment_constants(1, 1, &buffer_c->stream);
#else
Expand Down
9 changes: 3 additions & 6 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ static int copier_init(struct processing_module *mod)
switch (node_id.f.dma_type) {
case ipc4_hda_host_output_class:
case ipc4_hda_host_input_class:
ret = copier_host_create(dev, cd, &dev->ipc_config,
copier, cd->direction, ipc_pipe->pipeline);
ret = copier_host_create(dev, cd, copier, ipc_pipe->pipeline);
if (ret < 0) {
comp_err(dev, "unable to create host");
goto error;
Expand All @@ -115,8 +114,7 @@ static int copier_init(struct processing_module *mod)
case ipc4_i2s_link_input_class:
case ipc4_alh_link_output_class:
case ipc4_alh_link_input_class:
ret = copier_dai_create(dev, cd, &dev->ipc_config,
copier, ipc_pipe->pipeline);
ret = copier_dai_create(dev, cd, copier, ipc_pipe->pipeline);
if (ret < 0) {
comp_err(dev, "unable to create dai");
goto error;
Expand All @@ -125,8 +123,7 @@ static int copier_init(struct processing_module *mod)
#if CONFIG_IPC4_GATEWAY
case ipc4_ipc_output_class:
case ipc4_ipc_input_class:
ret = copier_ipcgtw_create(dev, cd, &dev->ipc_config,
copier, ipc_pipe->pipeline);
ret = copier_ipcgtw_create(dev, cd, copier, ipc_pipe->pipeline);
if (ret < 0) {
comp_err(dev, "unable to create IPC gateway");
goto error;
Expand Down
50 changes: 24 additions & 26 deletions src/audio/copier/copier_dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ static uint32_t bitmask_to_nibble_channel_map(uint8_t bitmask)
return nibble_map;
}

static int copier_set_alh_multi_gtw_channel_map(struct comp_dev *parent_dev,
static int copier_set_alh_multi_gtw_channel_map(struct comp_dev *dev,
const struct ipc4_copier_module_cfg *copier_cfg,
int index)
{
struct processing_module *mod = comp_get_drvdata(parent_dev);
struct processing_module *mod = comp_get_drvdata(dev);
struct copier_data *cd = module_get_private_data(mod);
const struct sof_alh_configuration_blob *alh_blob;
uint8_t chan_bitmask;
int channels;

if (!copier_cfg->gtw_cfg.config_length) {
comp_err(parent_dev, "No ipc4_alh_multi_gtw_cfg found in blob!");
comp_err(dev, "No ipc4_alh_multi_gtw_cfg found in blob!");
return -EINVAL;
}

Expand All @@ -54,7 +54,7 @@ static int copier_set_alh_multi_gtw_channel_map(struct comp_dev *parent_dev,

channels = popcount(chan_bitmask);
if (channels < 1 || channels > SOF_IPC_MAX_CHANNELS) {
comp_err(parent_dev, "Invalid channels mask: 0x%x", chan_bitmask);
comp_err(dev, "Invalid channels mask: 0x%x", chan_bitmask);
return -EINVAL;
}

Expand All @@ -64,15 +64,15 @@ static int copier_set_alh_multi_gtw_channel_map(struct comp_dev *parent_dev,
return 0;
}

static int copier_dai_init(struct comp_dev *parent_dev,
static int copier_dai_init(struct comp_dev *dev,
struct comp_ipc_config *config,
const struct ipc4_copier_module_cfg *copier,
struct pipeline *pipeline,
struct ipc_config_dai *dai,
enum ipc4_gateway_type type,
int index, int dai_count)
{
struct processing_module *mod = comp_get_drvdata(parent_dev);
struct processing_module *mod = comp_get_drvdata(dev);
struct copier_data *cd = module_get_private_data(mod);
struct dai_data *dd;
int ret;
Expand All @@ -86,7 +86,7 @@ static int copier_dai_init(struct comp_dev *parent_dev,
&out_valid_fmt,
copier->out_fmt.s_type);
config->frame_fmt = out_frame_fmt;
pipeline->sink_comp = parent_dev;
pipeline->sink_comp = dev;
cd->bsource_buffer = true;
} else {
enum sof_ipc_frame in_frame_fmt, in_valid_fmt;
Expand All @@ -96,14 +96,12 @@ static int copier_dai_init(struct comp_dev *parent_dev,
&in_frame_fmt, &in_valid_fmt,
copier->base.audio_fmt.s_type);
config->frame_fmt = in_frame_fmt;
pipeline->source_comp = parent_dev;
pipeline->source_comp = dev;
}

parent_dev->ipc_config.frame_fmt = config->frame_fmt;

/* save the channel map and count for ALH multi-gateway */
if (type == ipc4_gtw_alh && is_multi_gateway(copier->gtw_cfg.node_id)) {
ret = copier_set_alh_multi_gtw_channel_map(parent_dev, copier, index);
ret = copier_set_alh_multi_gtw_channel_map(dev, copier, index);
if (ret < 0)
return ret;
}
Expand All @@ -112,14 +110,14 @@ static int copier_dai_init(struct comp_dev *parent_dev,
if (!dd)
return -ENOMEM;

ret = dai_common_new(dd, parent_dev, dai);
ret = dai_common_new(dd, dev, dai);
if (ret < 0)
goto free_dd;

pipeline->sched_id = config->id;

cd->dd[index] = dd;
ret = comp_dai_config(cd->dd[index], parent_dev, dai, copier);
ret = comp_dai_config(cd->dd[index], dev, dai, copier);
if (ret < 0)
goto e_zephyr_free;

Expand All @@ -137,12 +135,12 @@ static int copier_dai_init(struct comp_dev *parent_dev,
* ssp, dmic or alh. Sof dai component can support this case so copier
* reuses dai component to support non-host gateway.
*/
int copier_dai_create(struct comp_dev *parent_dev, struct copier_data *cd,
struct comp_ipc_config *config,
int copier_dai_create(struct comp_dev *dev, struct copier_data *cd,
const struct ipc4_copier_module_cfg *copier,
struct pipeline *pipeline)
{
struct processing_module *mod = comp_get_drvdata(parent_dev);
struct processing_module *mod = comp_get_drvdata(dev);
struct comp_ipc_config *config = &dev->ipc_config;
int dai_index[IPC4_ALH_MAX_NUMBER_OF_GTW];
union ipc4_connector_node_id node_id;
enum ipc4_gateway_type type;
Expand Down Expand Up @@ -177,7 +175,7 @@ int copier_dai_create(struct comp_dev *parent_dev, struct copier_data *cd,
ret = ipc4_find_dma_config(&dai, (uint8_t *)copier->gtw_cfg.config_data,
copier->gtw_cfg.config_length * 4);
if (ret != 0) {
comp_err(parent_dev, "No ssp dma_config found in blob!");
comp_err(dev, "No ssp dma_config found in blob!");
return -EINVAL;
}
dai.out_fmt = &copier->out_fmt;
Expand Down Expand Up @@ -214,14 +212,14 @@ int copier_dai_create(struct comp_dev *parent_dev, struct copier_data *cd,

dai_count = alh_blob->alh_cfg.count;
if (dai_count > IPC4_ALH_MAX_NUMBER_OF_GTW || dai_count < 0) {
comp_err(parent_dev, "Invalid dai_count: %d", dai_count);
comp_err(dev, "Invalid dai_count: %d", dai_count);
return -EINVAL;
}
for (i = 0; i < dai_count; i++)
dai_index[i] =
IPC4_ALH_DAI_INDEX(alh_blob->alh_cfg.mapping[i].alh_id);
} else {
comp_err(parent_dev, "No ipc4_alh_multi_gtw_cfg found in blob!");
comp_err(dev, "No ipc4_alh_multi_gtw_cfg found in blob!");
return -EINVAL;
}
} else {
Expand All @@ -237,7 +235,7 @@ int copier_dai_create(struct comp_dev *parent_dev, struct copier_data *cd,
ret = ipc4_find_dma_config(&dai, (uint8_t *)copier->gtw_cfg.config_data,
copier->gtw_cfg.config_length * 4);
if (ret != 0) {
comp_err(parent_dev, "No dmic dma_config found in blob!");
comp_err(dev, "No dmic dma_config found in blob!");
return -EINVAL;
}
dai.out_fmt = &copier->out_fmt;
Expand All @@ -248,10 +246,10 @@ int copier_dai_create(struct comp_dev *parent_dev, struct copier_data *cd,

for (i = 0; i < dai_count; i++) {
dai.dai_index = dai_index[i];
ret = copier_dai_init(parent_dev, config, copier, pipeline, &dai, type, i,
ret = copier_dai_init(dev, config, copier, pipeline, &dai, type, i,
dai_count);
if (ret) {
comp_err(parent_dev, "failed to create dai");
comp_err(dev, "failed to create dai");
return ret;
}
}
Expand All @@ -260,22 +258,22 @@ int copier_dai_create(struct comp_dev *parent_dev, struct copier_data *cd,
get_converter_func(&copier->base.audio_fmt, &copier->out_fmt, type,
IPC4_DIRECTION(dai.direction));
if (!cd->converter[IPC4_COPIER_GATEWAY_PIN]) {
comp_err(parent_dev, "failed to get converter type %d, dir %d",
comp_err(dev, "failed to get converter type %d, dir %d",
type, dai.direction);
return -EINVAL;
}

/* create multi_endpoint_buffer for ALH multi-gateway case */
if (dai_count > 1) {
ret = create_endpoint_buffer(parent_dev, cd, config, copier, type, true, 0);
ret = create_endpoint_buffer(dev, cd, copier, true);
if (ret < 0)
return ret;
}

if (cd->direction == SOF_IPC_STREAM_PLAYBACK) {
pipeline->sink_comp = parent_dev;
pipeline->sink_comp = dev;
} else {
pipeline->source_comp = parent_dev;
pipeline->source_comp = dev;

/* set max sink count for capture */
mod->max_sinks = IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT;
Expand Down
10 changes: 4 additions & 6 deletions src/audio/copier/copier_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,12 @@ void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
}
}

int create_endpoint_buffer(struct comp_dev *parent_dev,
int create_endpoint_buffer(struct comp_dev *dev,
struct copier_data *cd,
struct comp_ipc_config *config,
const struct ipc4_copier_module_cfg *copier_cfg,
enum ipc4_gateway_type type,
bool create_multi_endpoint_buffer,
int index)
bool create_multi_endpoint_buffer)
{
struct comp_ipc_config *config = &dev->ipc_config;
enum sof_ipc_frame in_frame_fmt, out_frame_fmt;
enum sof_ipc_frame in_valid_fmt, out_valid_fmt;
enum sof_ipc_frame valid_fmt;
Expand Down Expand Up @@ -200,7 +198,7 @@ int create_endpoint_buffer(struct comp_dev *parent_dev,
chan_map = copier_cfg->base.audio_fmt.ch_map;
}

parent_dev->ipc_config.frame_fmt = config->frame_fmt;
dev->ipc_config.frame_fmt = config->frame_fmt;

memset(&ipc_buf, 0, sizeof(ipc_buf));
ipc_buf.size = buf_size;
Expand Down
22 changes: 11 additions & 11 deletions src/audio/copier/copier_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,15 @@ static int init_pipeline_reg(struct comp_dev *dev)
* Sof host component can support this case so copier reuses host
* component to support host gateway.
*/
int copier_host_create(struct comp_dev *parent_dev, struct copier_data *cd,
struct comp_ipc_config *config,
int copier_host_create(struct comp_dev *dev, struct copier_data *cd,
const struct ipc4_copier_module_cfg *copier_cfg,
int dir, struct pipeline *pipeline)
struct pipeline *pipeline)
{
struct processing_module *mod = comp_get_drvdata(parent_dev);
struct processing_module *mod = comp_get_drvdata(dev);
struct comp_ipc_config *config = &dev->ipc_config;
struct ipc_config_host ipc_host;
struct host_data *hd;
int dir = cd->direction;
int ret;
enum sof_ipc_frame in_frame_fmt, out_frame_fmt;
enum sof_ipc_frame in_valid_fmt, out_valid_fmt;
Expand All @@ -155,9 +156,9 @@ int copier_host_create(struct comp_dev *parent_dev, struct copier_data *cd,
if (!hd)
return -ENOMEM;

ret = host_common_new(hd, parent_dev, &ipc_host, config->id);
ret = host_common_new(hd, dev, &ipc_host, config->id);
if (ret < 0) {
comp_err(parent_dev, "copier: host new failed with exit");
comp_err(dev, "copier: host new failed with exit");
goto e_data;
}
#if CONFIG_HOST_DMA_STREAM_SYNCHRONIZATION
Expand Down Expand Up @@ -196,7 +197,7 @@ int copier_host_create(struct comp_dev *parent_dev, struct copier_data *cd,
&copier_cfg->out_fmt,
ipc4_gtw_host, IPC4_DIRECTION(dir));
if (!cd->converter[IPC4_COPIER_GATEWAY_PIN]) {
comp_err(parent_dev, "failed to get converter for host, dir %d", dir);
comp_err(dev, "failed to get converter for host, dir %d", dir);
ret = -EINVAL;
goto e_conv;
}
Expand All @@ -206,18 +207,17 @@ int copier_host_create(struct comp_dev *parent_dev, struct copier_data *cd,

if (cd->direction == SOF_IPC_STREAM_PLAYBACK) {
config->frame_fmt = in_frame_fmt;
pipeline->source_comp = parent_dev;
ret = init_pipeline_reg(parent_dev);
pipeline->source_comp = dev;
ret = init_pipeline_reg(dev);
if (ret)
goto e_conv;

/* set max sink count for playback */
mod->max_sinks = IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT;
} else {
config->frame_fmt = out_frame_fmt;
pipeline->sink_comp = parent_dev;
pipeline->sink_comp = dev;
}
parent_dev->ipc_config.frame_fmt = config->frame_fmt;

return 0;

Expand Down
Loading

0 comments on commit ee40f61

Please sign in to comment.