-
Notifications
You must be signed in to change notification settings - Fork 321
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
audio: src: refactor src component with more common code in src source file #8161
Conversation
9dc6084
to
8531759
Compare
@btian1 why are you splitting IPC3 vs IPC4 on component level? |
@iuliana-prodan , you can see that current module become more and more larger, and inside, ipc3 and ipc4 code are mixed together, make code hard to read/understand/maintain. these changes have two purpose:
currently, volume was done, module adapter is in: #8144, this is the third one. |
src/audio/src/src_uuid.h
Outdated
#if CONFIG_IPC_MAJOR_4 | ||
|
||
/* e61bb28d-149a-4c1f-b709-46823ef5f5a3 */ | ||
DECLARE_SOF_RT_UUID("src", src_uuid, 0xe61bb28d, 0x149a, 0x4c1f, |
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.
the name is confusing, this isn't a declaration, it's a definition - it actually defines objects. So, this shouldn't be in a header. Besides - this can be perfectly placed in src_ipc4.c and src_ipc3.c, they divide very well.
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.
I also want to put it ipc3 and ipc4 separately, however, if you check DECLARE_SOF_RT_UUID inside, you will find static definition, how it can be referred by src.c?
#define DECLARE_SOF_UUID(entity_name, uuid_name,
va, vb, vc,
vd0, vd1, vd2, vd3, vd4, vd5, vd6, vd7)
__section(".static_uuids")
static const struct sof_uuid_entry uuid_name ## _ldc = {
{.a = va, .b = vb, .c = vc,
.d = {vd0, vd1, vd2, vd3, vd4, vd5, vd6, vd7}},
entity_name "\0"
}
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.
right, that defined an object called src_uuid_ldc
, right? And that one is then used in DECLARE_TR_CTX(src_tr, SOF_UUID(src_uuid), LOG_LEVEL_INFO);
So I would either duplicate that single line DECLARE_TR_CTX(...);
in both ipc3 and ipc4 files or leave them all in src.c with #if
s but still please don't include them in a header. By placing them in that header and only including it in src.c you effectively placing them there, so you can just do that explicitly instead.
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.
there is another way to use src_uuid:
DECLARE_MODULE_ADAPTER(src_interface, src_uuid, src_tr);
hard to resolve this one.
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.
sorry, what do you mean? What do you need to resolve there? Its use of src_uuid
decodes as
static const struct comp_driver comp_##adapter##_module = { \
.type = SOF_COMP_MODULE_ADAPTER, \
.uid = &src_uuid, \
and src_uuid
is defined by
DECLARE_SOF_RT_UUID("src", src_uuid, 0xe61bb28d, 0x149a, 0x4c1f,
0xb7, 0x09, 0x46, 0x82, 0x3e, 0xf5, 0xf5, 0xae);
as
const struct sof_uuid src_uuid = { \
i.e. that one isn't static
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.
then have to add extern part, I added, please check again, not sure this looks better or not.
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.
Yes, that now looks correct C. Someone might complain that macros like DECLARE_SOF_RT_UUID()
and DECLARE_TR_CTX()
are supposed to hide their implementation and you aren't supposed to access internals of the code, that they generate, but I'd say that isn't a major concern.
src/audio/src/src_uuid.h
Outdated
#error "No or invalid IPC MAJOR version selected." | ||
#endif /* CONFIG_IPC_MAJOR_4 */ | ||
|
||
DECLARE_TR_CTX(src_tr, SOF_UUID(src_uuid), LOG_LEVEL_INFO); |
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.
this also defines an object, please, keep it in .c
|
||
void src_set_sink_params(struct comp_dev *dev, struct sof_source __sparse_cache *source, | ||
struct sof_sink __sparse_cache *sink) | ||
{ |
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.
well, this function now isn't really setting sink parameters? Please choose a different name
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.
@singalsu any suggestions for appropriate name.
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.
In IPC4 build the same name function sets source and sink parameters and these component data members are updated in init() where directly received from kernel.
If IPC3 function name is changed, then it could be src_get_source_sink_params(), since in IPC3 these are retrieved from params walk result for buffers.
@@ -5,7 +5,7 @@ | |||
*/ | |||
|
|||
/** \cond GENERATED_BY_TOOLS_TUNE_SRC */ | |||
#include <sof/audio/src/src.h> | |||
#include "../src.h" |
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.
Why is the location changed? The coefficients are generic polyphase FIR coefficients for a fractional ratio and could be in theory used by some other SRC like component. It's not a big deal to move and move back if need but was this causing issues?
If needed please make this change also to SRC coefficients generator. It can be a separate PR. These files must be directly generated without any manual edits done.
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.
@singalsu , intention is move all related header to one folder, you can check volume part, all volume related moved to src/audio/volume folder.
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.
OK!
Can you please make another PR to change this similarly
sof/tools/tune/src/src_export_coef.m
Line 53 in 2c6c1b4
fprintf(fh, '#include <sof/audio/src/src.h>\n'); |
Try to run e.g. https://github.com/thesofproject/sof/blob/main/tools/tune/src/src_ipc4_int32.m in octave
and check that you get similar h-files as these edited.
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.
Also I think directory name "coefficients" would be better than "src" for the moved header files.
9dcccc4
to
691d821
Compare
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.
The actual blocking comment has been addressed - thanks. It still would be good to rename src_set_source_sink_params()
and of course this needs an approval from @singalsu when all his concerns have been addressed.
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.
LGTM, name can be fixed incrementally.
|
||
void src_set_sink_params(struct comp_dev *dev, struct sof_source __sparse_cache *source, | ||
struct sof_sink __sparse_cache *sink) | ||
{ |
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.
@singalsu any suggestions for appropriate name.
#include <sof/audio/coefficients/src/src_small_int32_20_21_4167_5000.h> | ||
#include <sof/audio/coefficients/src/src_small_int32_21_20_4167_5000.h> | ||
#include <sof/audio/src/src.h> | ||
#include "src_small_int32_1_2_2268_5000.h" |
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.
This change needs to be updated (other PR) here
sof/tools/tune/src/src_export_table_2s.m
Line 85 in 2c6c1b4
fprintf(fh, '#include <%ssrc_%s_%d_%d_%d_%d.h>\n', ... |
#include "src_small_int32_8_7_4535_5000.h" | ||
#include "src_small_int32_20_21_4167_5000.h" | ||
#include "src_small_int32_21_20_4167_5000.h" | ||
#include "../src.h" |
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.
And this change here
sof/tools/tune/src/src_export_table_2s.m
Line 94 in 2c6c1b4
fprintf(fh, '#include <sof/audio/src/src.h>\n'); |
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.
Looks good. #8167 will conflict though, and needs to go first due to its dependencies (if it is ready today).
${SOF_AUDIO_PATH}/src/src.c | ||
${SOF_AUDIO_PATH}/src/src_ipc4.c | ||
) | ||
endif() |
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.
Nitpick: you could add the common files in one statement and then only have a if-IPC3-else-IPC4 case to select between src_ipc3.c and src_ipc4.c. No need to duplicate the lists for both IPC versions,
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.
it include zephyr_library_sources_ifdef, I am afraid I can't handle it well, so duplicate for security.
you can see volume also use same way, we can improve this later when there is a new change.
Currently, this PR is ready for merge.
move component data out of source file to avoid ipc3 and ipc4 usage in src source file. Signed-off-by: Baofeng Tian <[email protected]>
create new files to cover ipc3 and ipc4 specific code. Signed-off-by: Baofeng Tian <[email protected]>
previously, these headers are located in include directory. Now, move it to src/audio/src/ directory, since these headers are only used by src module. Signed-off-by: Baofeng Tian <[email protected]>
rename it from src to coef to reflect the real content inside. Signed-off-by: Baofeng Tian <[email protected]>
@kv2019i , @singalsu , I think what Seppo mentioned are addressed, only matlab file change is not yet covered, it need use another PR to continue, no worry no this.
|
move out all ipc3 and ipc4 specifc code, data structure and functions.