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

ipc4: mixin/mixout cleanup after channel remapping mode been removed #8655

Merged
merged 3 commits into from
Dec 20, 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
41 changes: 16 additions & 25 deletions src/audio/mixin_mixout/mixin_mixout.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ struct mixin_sink_config {

/* mixin component private data */
struct mixin_data {
normal_mix_func normal_mix_channel;
mute_func mute_channel;
mix_func mix;
struct mixin_sink_config sink_config[MIXIN_MAX_SINKS];
};

Expand Down Expand Up @@ -183,10 +182,10 @@ static int mixout_free(struct processing_module *mod)
return 0;
}

static int mix_and_remap(struct comp_dev *dev, const struct mixin_data *mixin_data,
uint16_t sink_index, struct audio_stream *sink,
uint32_t start_frame, uint32_t mixed_frames,
const struct audio_stream *source, uint32_t frame_count)
static int mix(struct comp_dev *dev, const struct mixin_data *mixin_data,
uint16_t sink_index, struct audio_stream *sink,
uint32_t start_frame, uint32_t mixed_frames,
const struct audio_stream *source, uint32_t frame_count)
{
const struct mixin_sink_config *sink_config;

Expand All @@ -198,17 +197,11 @@ static int mix_and_remap(struct comp_dev *dev, const struct mixin_data *mixin_da

sink_config = &mixin_data->sink_config[sink_index];

/* Mix streams. mix_channel() is reused here to mix streams, not individual
* channels. To do so, (multichannel) stream is treated as single channel:
* channel count is passed as 1, channel index is 0, frame indices (start_frame
* and mixed_frame) and frame count are multiplied by real stream channel count.
*/
mixin_data->normal_mix_channel(sink, start_frame * audio_stream_get_channels(sink),
mixed_frames * audio_stream_get_channels(sink),
source,
frame_count * audio_stream_get_channels(sink),
sink_config->gain);

mixin_data->mix(sink, start_frame * audio_stream_get_channels(sink),
mixed_frames * audio_stream_get_channels(sink),
source,
frame_count * audio_stream_get_channels(sink),
sink_config->gain);

return 0;
}
Expand Down Expand Up @@ -396,9 +389,9 @@ static int mixin_process(struct processing_module *mod,
* sink buffer has some data (written by another mixin) mix that data
* with source data.
*/
ret = mix_and_remap(dev, mixin_data, sinks_ids[i], &sink->stream,
start_frame, mixout_data->mixed_frames,
input_buffers[0].data, frames_to_copy);
ret = mix(dev, mixin_data, sinks_ids[i], &sink->stream,
start_frame, mixout_data->mixed_frames,
input_buffers[0].data, frames_to_copy);
if (ret < 0) {
return ret;
}
Expand Down Expand Up @@ -509,8 +502,7 @@ static int mixin_reset(struct processing_module *mod)

comp_dbg(dev, "mixin_reset()");

mixin_data->normal_mix_channel = NULL;
mixin_data->mute_channel = NULL;
mixin_data->mix = NULL;

return 0;
}
Expand Down Expand Up @@ -635,15 +627,14 @@ static int mixin_prepare(struct processing_module *mod,
case SOF_IPC_FRAME_S16_LE:
case SOF_IPC_FRAME_S24_4LE:
case SOF_IPC_FRAME_S32_LE:
md->normal_mix_channel = normal_mix_get_processing_function(fmt);
md->mute_channel = mute_mix_get_processing_function(fmt);
md->mix = mixin_get_processing_function(fmt);
break;
default:
comp_err(dev, "unsupported data format %d", fmt);
return -EINVAL;
}

if (!md->normal_mix_channel || !md->mute_channel) {
if (!md->mix) {
comp_err(dev, "have not found the suitable processing function");
return -EINVAL;
}
Expand Down
48 changes: 12 additions & 36 deletions src/audio/mixin_mixout/mixin_mixout.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,59 +103,35 @@ struct ipc4_mixer_mode_config {
} __packed __aligned(4);

/**
* \brief normal mode mixin_mixout processing function interface
* \brief mixin processing function interface
*/
typedef void (*normal_mix_func)(struct audio_stream *sink, int32_t start_frame,
int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain);
typedef void (*mix_func)(struct audio_stream *sink, int32_t start_sample,
int32_t mixed_samples,
const struct audio_stream *source,
int32_t sample_count, uint16_t gain);

/**
* \brief mixin_mixout mute processing function interface
*/
typedef void (*mute_func) (struct audio_stream *stream, int32_t channel_index,
int32_t start_frame, int32_t mixed_frames, int32_t frame_count);

/**
* @brief mixin_mixout processing functions map.
* @brief mixin processing functions map.
*/
struct mix_func_map {
uint16_t frame_fmt; /* frame format */
normal_mix_func normal_func; /* normal mode mixin_mixout processing function */
mute_func mute_func; /* mute processing function */
uint16_t frame_fmt; /* frame format */
mix_func func; /* mixin processing function */
};

extern const struct mix_func_map mix_func_map[];
extern const size_t mix_count;
/**
* \brief Retrievies normal mode mixer processing function.
* \param[in] fmt stream PCM frame format
*/
static inline normal_mix_func normal_mix_get_processing_function(int fmt)
{
int i;

/* map the normal mode mixin_mixout function for source and sink buffers */
for (i = 0; i < mix_count; i++) {
if (fmt == mix_func_map[i].frame_fmt)
return mix_func_map[i].normal_func;
}

return NULL;
}

/**
* \brief Retrievies normal mode mixer processing function.
* \brief Retrievies mixin processing function.
* \param[in] fmt stream PCM frame format
*/
static inline mute_func mute_mix_get_processing_function(int fmt)
static inline mix_func mixin_get_processing_function(int fmt)
{
int i;

/* map the mute function for source and sink buffers */
/* map mixin processing function for source and sink buffers */
for (i = 0; i < mix_count; i++) {
if (fmt == mix_func_map[i].frame_fmt)
return mix_func_map[i].mute_func;
return mix_func_map[i].func;
}

return NULL;
Expand Down
Loading