Repository navigation
mux: simplifies mux processing functions #3000
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
Merged
lgirdwood
merged 1 commit into
thesofproject:master
from
bkokoszx:topic/mux-process-refinement
Jul 14, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,9 @@ static int mux_set_values(struct comp_dev *dev, struct comp_data *cd, | |
| { | ||
| uint8_t i; | ||
| uint8_t j; | ||
| bool channel_set; | ||
|
|
||
| comp_info(dev, "mux_set_values()"); | ||
|
|
||
| /* check if number of streams configured doesn't exceed maximum */ | ||
| if (cfg->num_streams > MUX_MAX_STREAMS) { | ||
|
|
@@ -69,12 +72,44 @@ static int mux_set_values(struct comp_dev *dev, struct comp_data *cd, | |
| } | ||
| } | ||
|
|
||
| for (i = 0; i < cfg->num_streams; i++) { | ||
| for (j = 0 ; j < PLATFORM_MAX_CHANNELS; j++) { | ||
| if (popcount(cfg->streams[i].mask[j]) > 1) { | ||
| comp_cl_err(&comp_mux, "mux_set_values(): mux component is not able to mix channels"); | ||
| return -EINVAL; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (dev->comp.type == SOF_COMP_MUX) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
| for (j = 0 ; j < PLATFORM_MAX_CHANNELS; j++) { | ||
| channel_set = false; | ||
| for (i = 0 ; i < cfg->num_streams; i++) { | ||
| if (popcount(cfg->streams[i].mask[j])) { | ||
| if (!channel_set) { | ||
| channel_set = true; | ||
| } else { | ||
| comp_cl_err(&comp_mux, "mux_set_values(): mux component is not able to mix channels"); | ||
| return -EINVAL; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| for (i = 0; i < cfg->num_streams; i++) { | ||
| cd->config.streams[i].pipeline_id = cfg->streams[i].pipeline_id; | ||
| for (j = 0; j < PLATFORM_MAX_CHANNELS; j++) | ||
| cd->config.streams[i].mask[j] = cfg->streams[i].mask[j]; | ||
| } | ||
|
|
||
| cd->config.num_streams = cfg->num_streams; | ||
|
|
||
| if (dev->comp.type == SOF_COMP_MUX) | ||
| mux_prepare_look_up_table(dev); | ||
| else | ||
| demux_prepare_look_up_table(dev); | ||
|
|
||
| if (dev->state > COMP_STATE_INIT) { | ||
| if (dev->comp.type == SOF_COMP_MUX) | ||
| cd->mux = mux_get_processing_function(dev); | ||
|
|
@@ -157,6 +192,21 @@ static uint8_t get_stream_index(struct comp_data *cd, uint32_t pipe_id) | |
| return 0; | ||
| } | ||
|
|
||
| static struct mux_look_up *get_lookup_table(struct comp_data *cd, | ||
| uint32_t pipe_id) | ||
| { | ||
| int i; | ||
|
|
||
| for (i = 0; i < MUX_MAX_STREAMS; i++) | ||
| if (cd->config.streams[i].pipeline_id == pipe_id) | ||
| return &cd->lookup[i]; | ||
|
|
||
| comp_cl_err(&comp_mux, "get_lookup_table(): couldn't find configuration for connected pipeline %u", | ||
| pipe_id); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| static int mux_verify_params(struct comp_dev *dev, | ||
| struct sof_ipc_stream_params *params) | ||
| { | ||
|
|
@@ -269,13 +319,41 @@ static int mux_cmd(struct comp_dev *dev, int cmd, void *data, | |
| } | ||
| } | ||
|
|
||
| static void prepare_active_look_up(struct comp_dev *dev, | ||
| struct audio_stream *sink, | ||
| const struct audio_stream **sources) | ||
| { | ||
| struct comp_data *cd = comp_get_drvdata(dev); | ||
| const struct audio_stream *source; | ||
| uint8_t active_elem; | ||
| uint8_t elem; | ||
|
|
||
| cd->active_lookup.num_elems = 0; | ||
|
|
||
| active_elem = 0; | ||
|
|
||
| /* init pointers */ | ||
| for (elem = 0; elem < cd->lookup[0].num_elems; elem++) { | ||
| source = sources[cd->lookup[0].copy_elem[elem].stream_id]; | ||
|
lgirdwood marked this conversation as resolved.
Resolved
|
||
| if (!source) | ||
| continue; | ||
|
|
||
| cd->active_lookup.copy_elem[active_elem] = | ||
| cd->lookup[0].copy_elem[elem]; | ||
| active_elem++; | ||
| cd->active_lookup.num_elems = active_elem; | ||
| } | ||
| } | ||
|
|
||
| /* process and copy stream data from source to sink buffers */ | ||
| static int demux_copy(struct comp_dev *dev) | ||
| { | ||
| struct comp_data *cd = comp_get_drvdata(dev); | ||
| struct comp_buffer *source; | ||
| struct comp_buffer *sink; | ||
| struct comp_buffer *sinks[MUX_MAX_STREAMS] = { NULL }; | ||
| struct mux_look_up *look_ups[MUX_MAX_STREAMS] = { NULL }; | ||
| struct mux_look_up *look_up; | ||
| struct list_item *clist; | ||
| uint32_t num_sinks = 0; | ||
| uint32_t i = 0; | ||
|
|
@@ -300,7 +378,9 @@ static int demux_copy(struct comp_dev *dev) | |
| if (sink->sink->state == dev->state) { | ||
| num_sinks++; | ||
| i = get_stream_index(cd, sink->pipeline_id); | ||
| look_up = get_lookup_table(cd, sink->pipeline_id); | ||
| sinks[i] = sink; | ||
| look_ups[i] = look_up; | ||
| } | ||
| buffer_unlock(sink, flags); | ||
| } | ||
|
|
@@ -346,8 +426,8 @@ static int demux_copy(struct comp_dev *dev) | |
| continue; | ||
|
|
||
| buffer_invalidate(source, source_bytes); | ||
| cd->demux(&sinks[i]->stream, &source->stream, frames, | ||
| &cd->config.streams[i]); | ||
| cd->demux(dev, &sinks[i]->stream, &source->stream, frames, | ||
| look_ups[i]); | ||
| buffer_writeback(sinks[i], sinks_bytes[i]); | ||
| } | ||
|
|
||
|
|
@@ -441,9 +521,11 @@ static int mux_copy(struct comp_dev *dev) | |
| } | ||
| sink_bytes = frames * audio_stream_frame_bytes(&sink->stream); | ||
|
|
||
| prepare_active_look_up(dev, &sink->stream, &sources_stream[0]); | ||
|
|
||
| /* produce output */ | ||
| cd->mux(&sink->stream, &sources_stream[0], frames, | ||
| &cd->config.streams[0]); | ||
| cd->mux(dev, &sink->stream, &sources_stream[0], frames, | ||
| &cd->active_lookup); | ||
| buffer_writeback(sink, sink_bytes); | ||
|
|
||
| /* update components */ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have an inline comment on what each loop block is doing