Skip to content

Commit

Permalink
ipc4: mixin/mixout: Simplify naming after remapping mode been removed
Browse files Browse the repository at this point in the history
Previously we had "normal" and "channel remapping" modes. Since channel
remapping mode was removed, "normal" is the only supported mode, no need
to prepend names with "normal".

Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
  • Loading branch information
serhiy-katsyuba-intel committed Dec 20, 2023
1 parent d96258c commit 24a419a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 100 deletions.
38 changes: 16 additions & 22 deletions src/audio/mixin_mixout/mixin_mixout.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct mixin_sink_config {

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

Expand Down Expand Up @@ -182,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 @@ -197,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 @@ -395,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 @@ -508,7 +502,7 @@ static int mixin_reset(struct processing_module *mod)

comp_dbg(dev, "mixin_reset()");

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

return 0;
}
Expand Down Expand Up @@ -633,14 +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->mix = mixin_get_processing_function(fmt);
break;
default:
comp_err(dev, "unsupported data format %d", fmt);
return -EINVAL;
}

if (!md->normal_mix_channel) {
if (!md->mix) {
comp_err(dev, "have not found the suitable processing function");
return -EINVAL;
}
Expand Down
24 changes: 12 additions & 12 deletions src/audio/mixin_mixout/mixin_mixout.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,35 +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_frame,
int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain);

/**
* @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 */
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.
* \brief Retrievies mixin processing function.
* \param[in] fmt stream PCM frame format
*/
static inline normal_mix_func normal_mix_get_processing_function(int fmt)
static inline mix_func mixin_get_processing_function(int fmt)
{
int i;

/* map the normal mode mixin_mixout 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].normal_func;
return mix_func_map[i].func;
}

return NULL;
Expand Down
45 changes: 12 additions & 33 deletions src/audio/mixin_mixout/mixin_mixout_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,9 @@
#ifdef MIXIN_MIXOUT_GENERIC

#if CONFIG_FORMAT_S16LE
/* Instead of using audio_stream_get_channels(sink) and audio_stream_get_channels(source),
* sink_channel_count and source_channel_count are supplied as parameters. This is done to reuse
* the function to also mix an entire stream. In this case the function is called with fake stream
* parameters: multichannel stream is treated as single channel and so the entire stream
* contents is mixed.
*/
static void normal_mix_channel_s16(struct audio_stream *sink, int32_t start_frame,
int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain)
static void mix_s16(struct audio_stream *sink, int32_t start_frame, int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain)
{
int32_t frames_to_mix, frames_to_copy, left_frames;
int32_t n, nmax, i;
Expand Down Expand Up @@ -64,16 +57,9 @@ static void normal_mix_channel_s16(struct audio_stream *sink, int32_t start_fram
#endif /* CONFIG_FORMAT_S16LE */

#if CONFIG_FORMAT_S24LE
/* Instead of using audio_stream_get_channels(sink) and audio_stream_get_channels(source),
* sink_channel_count and source_channel_count are supplied as parameters. This is done to reuse
* the function to also mix an entire stream. In this case the function is called with fake stream
* parameters: multichannel stream is treated as single channel and so the entire stream
* contents is mixed.
*/
static void normal_mix_channel_s24(struct audio_stream *sink, int32_t start_frame,
int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain)
static void mix_s24(struct audio_stream *sink, int32_t start_frame, int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain)
{
int32_t frames_to_mix, frames_to_copy, left_frames;
int32_t n, nmax, i;
Expand Down Expand Up @@ -116,16 +102,9 @@ static void normal_mix_channel_s24(struct audio_stream *sink, int32_t start_fram
#endif /* CONFIG_FORMAT_S24LE */

#if CONFIG_FORMAT_S32LE
/* Instead of using audio_stream_get_channels(sink) and audio_stream_get_channels(source),
* sink_channel_count and source_channel_count are supplied as parameters. This is done to reuse
* the function to also mix an entire stream. In this case the function is called with fake stream
* parameters: multichannel stream is treated as single channel and so the entire stream
* contents is mixed.
*/
static void normal_mix_channel_s32(struct audio_stream *sink, int32_t start_frame,
int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain)
static void mix_s32(struct audio_stream *sink, int32_t start_frame, int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain)
{
int32_t frames_to_mix, frames_to_copy, left_frames;
int32_t n, nmax, i;
Expand Down Expand Up @@ -168,13 +147,13 @@ static void normal_mix_channel_s32(struct audio_stream *sink, int32_t start_fram

const struct mix_func_map mix_func_map[] = {
#if CONFIG_FORMAT_S16LE
{ SOF_IPC_FRAME_S16_LE, normal_mix_channel_s16 },
{ SOF_IPC_FRAME_S16_LE, mix_s16 },
#endif
#if CONFIG_FORMAT_S24LE
{ SOF_IPC_FRAME_S24_4LE, normal_mix_channel_s24 },
{ SOF_IPC_FRAME_S24_4LE, mix_s24 },
#endif
#if CONFIG_FORMAT_S32LE
{ SOF_IPC_FRAME_S32_LE, normal_mix_channel_s32 }
{ SOF_IPC_FRAME_S32_LE, mix_s32 }
#endif
};

Expand Down
45 changes: 12 additions & 33 deletions src/audio/mixin_mixout/mixin_mixout_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,9 @@
#ifdef MIXIN_MIXOUT_HIFI3

#if CONFIG_FORMAT_S16LE
/* Instead of using audio_stream_get_channels(sink) and audio_stream_get_channels(source),
* sink_channel_count and source_channel_count are supplied as parameters. This is done to reuse
* the function to also mix an entire stream. In this case the function is called with fake stream
* parameters: multichannel stream is treated as single channel and so the entire stream
* contents is mixed.
*/
static void normal_mix_channel_s16(struct audio_stream *sink, int32_t start_frame,
int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain)
static void mix_s16(struct audio_stream *sink, int32_t start_frame, int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain)
{
int frames_to_mix, frames_to_copy, left_frames;
int n, nmax, i, m, left;
Expand Down Expand Up @@ -107,16 +100,9 @@ static void normal_mix_channel_s16(struct audio_stream *sink, int32_t start_fram
#endif /* CONFIG_FORMAT_S16LE */

#if CONFIG_FORMAT_S24LE
/* Instead of using audio_stream_get_channels(sink) and audio_stream_get_channels(source),
* sink_channel_count and source_channel_count are supplied as parameters. This is done to reuse
* the function to also mix an entire stream. In this case the function is called with fake stream
* parameters: multichannel stream is treated as single channel and so the entire stream
* contents is mixed.
*/
static void normal_mix_channel_s24(struct audio_stream *sink, int32_t start_frame,
int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain)
static void mix_s24(struct audio_stream *sink, int32_t start_frame, int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain)
{
int frames_to_mix, frames_to_copy, left_frames;
int n, nmax, i, m, left;
Expand Down Expand Up @@ -197,16 +183,9 @@ static void normal_mix_channel_s24(struct audio_stream *sink, int32_t start_fram
#endif /* CONFIG_FORMAT_S24LE */

#if CONFIG_FORMAT_S32LE
/* Instead of using audio_stream_get_channels(sink) and audio_stream_get_channels(source),
* sink_channel_count and source_channel_count are supplied as parameters. This is done to reuse
* the function to also mix an entire stream. In this case the function is called with fake stream
* parameters: multichannel stream is treated as single channel and so the entire stream
* contents is mixed.
*/
static void normal_mix_channel_s32(struct audio_stream *sink, int32_t start_frame,
int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain)
static void mix_s32(struct audio_stream *sink, int32_t start_frame, int32_t mixed_frames,
const struct audio_stream *source,
int32_t frame_count, uint16_t gain)
{
int frames_to_mix, frames_to_copy, left_frames;
int n, nmax, i, m, left;
Expand Down Expand Up @@ -289,13 +268,13 @@ static void normal_mix_channel_s32(struct audio_stream *sink, int32_t start_fram

const struct mix_func_map mix_func_map[] = {
#if CONFIG_FORMAT_S16LE
{ SOF_IPC_FRAME_S16_LE, normal_mix_channel_s16 },
{ SOF_IPC_FRAME_S16_LE, mix_s16 },
#endif
#if CONFIG_FORMAT_S24LE
{ SOF_IPC_FRAME_S24_4LE, normal_mix_channel_s24 },
{ SOF_IPC_FRAME_S24_4LE, mix_s24 },
#endif
#if CONFIG_FORMAT_S32LE
{ SOF_IPC_FRAME_S32_LE, normal_mix_channel_s32 }
{ SOF_IPC_FRAME_S32_LE, mix_s32 }
#endif
};

Expand Down

0 comments on commit 24a419a

Please sign in to comment.