-
Notifications
You must be signed in to change notification settings - Fork 325
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
[RTNR] Pass binary data to RTNR #5544
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,8 @@ | |
#define RTNR_BLK_LENGTH_MASK (RTNR_BLK_LENGTH - 1) | ||
#define RTNR_MAX_SOURCES 1 /* Microphone stream */ | ||
|
||
#define SOF_RTNR_CONFIG 0 | ||
|
||
static const struct comp_driver comp_rtnr; | ||
|
||
/** \brief RTNR processing functions map item. */ | ||
|
@@ -399,26 +401,52 @@ static int rtnr_cmd_get_data(struct comp_dev *dev, | |
return ret; | ||
} | ||
|
||
static int rtnr_set_bin_data(struct comp_dev *dev, | ||
struct sof_ipc_ctrl_data *cdata) | ||
{ | ||
struct comp_data *cd = comp_get_drvdata(dev); | ||
int ret = 0; | ||
|
||
assert(cd); | ||
|
||
comp_dbg(dev, "rtnr_set_bin_data() msg_index = %d, num_elems = %d, remaining = %d ", | ||
cdata->msg_index, cdata->num_elems, | ||
cdata->elems_remaining); | ||
|
||
if (cdata->data->type == SOF_RTNR_CONFIG) { | ||
comp_dbg(dev, "rtnr_set_bin_data(): SOF_RTNR_CONFIG"); | ||
ret = comp_data_blob_set_cmd(cd->model_handler, cdata); | ||
if (ret >= 0) | ||
ret = rtnr_check_config_validity(dev, cd); | ||
} else { | ||
comp_dbg(dev, "rtnr_set_bin_data(): SOF_RTNR_DATA type: %d", cdata->data->type); | ||
ret = RTKMA_API_Set_Data(cd->rtk_agl, | ||
cdata->data->data, | ||
cdata->msg_index, | ||
cdata->num_elems, | ||
cdata->elems_remaining, | ||
cdata->data->type); | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
static int rtnr_cmd_set_data(struct comp_dev *dev, | ||
struct sof_ipc_ctrl_data *cdata) | ||
{ | ||
struct comp_data *cd = comp_get_drvdata(dev); | ||
int ret = 0; | ||
|
||
switch (cdata->cmd) { | ||
case SOF_CTRL_CMD_BINARY: | ||
comp_info(dev, "rtnr_cmd_set_data(), SOF_CTRL_CMD_BINARY"); | ||
ret = comp_data_blob_set_cmd(cd->model_handler, cdata); | ||
ret = rtnr_set_bin_data(dev, cdata); | ||
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. If you stop using comp_data_blob_set_cmd() for some cases and implement the message handling for those your self, you should do the same thing symmetrically for comp_data_blob_get_cmd(). One alternative would not to use the comp_data_blob_handler at all and write all message fragment handling your self. |
||
break; | ||
default: | ||
comp_err(dev, "rtnr_cmd_set_data() error: invalid command %d", cdata->cmd); | ||
ret = -EINVAL; | ||
break; | ||
} | ||
|
||
if (ret >= 0) | ||
ret = rtnr_check_config_validity(dev, cd); | ||
|
||
return ret; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,12 @@ int RTKMA_API_Set(void *Context, const void *pParameters, int size, unsigned int | |
|
||
int RTKMA_API_Get(void *Context, void *pParameters, int size, unsigned int IDs); | ||
|
||
int RTKMA_API_Set_Data(void *Context, unsigned int *data, | ||
unsigned int msg_index, | ||
unsigned int num_elms, | ||
unsigned int elems_remaining, | ||
unsigned int data_type); | ||
|
||
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. When should we use 1 and when should we use 2 ? can the be better named so users can understand the usage better. I would also put some comments explaining the difference and usage. 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. Thanks for the review. We'll combine those 2 APIs into 1 to avoid confusion. Another question is what's the best practice to send binary configuration file to sof component during system startup? The config is about 2KB, and should only be set once. We've been using sof-ctl which works well, but the same configuration will be sent every time before recording. Besides, using sof-ctl might not be a proper way for final product. We've also tried using cset-tlv to send config just like the control blobs for the UI. However the config is much larger than control blobs and I have no success during my experiments. Is there file size limit for this? Thanks. 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. Just force-pushed a commit to simplify the Set_Data API. There could be different types of the data, but yes they should be handled internally in library. Thanks! 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. You could have a the config data as a static data block as part of the RTNT. This would be build into the DATA section and could be used by default ? 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. Yes currently there is a default config stored in the static table inside the firmware. The proposed method provides a way to overwrite the default config so that we don't have to re-build firmware each time when a new config is needed. 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. Using my PR #5509 you could use the new comp_data_blob_handler_new_ext() with single_blob = true and tap into alloc() and free() callbacks to return always the pointer to the static buffer (and return an error if the requested size is bigger than the buffer). With this approach you should keep using the comp_data_blob_handler and friends mostly the way the other components do. The IPC fragment aggregating would be handled by data_blob.c functions. Just before processing call you should check with comp_is_current_data_blob_valid() if the configuration buffer is currently valid, or if it is in the middle of an update. |
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
#include <stdint.h> | ||
|
||
#define SOF_RTNR_MAX_SIZE 256 | ||
#define SOF_RTNR_MAX_SIZE 8192 | ||
|
||
struct sof_rtnr_params { | ||
/* 1 to enable RTNR, 0 to disable it */ | ||
|
@@ -26,6 +26,7 @@ struct sof_rtnr_config { | |
uint32_t reserved[4]; | ||
|
||
struct sof_rtnr_params params; | ||
int32_t data[]; | ||
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. Wont you need a size here to tell client code how big data[] is ? or maybe this in fully handled in blob API @jsarha please comment here. 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. The data is with variable length. Actual size is stored in the size flag. |
||
} __attribute__((packed, aligned(4))); | ||
|
||
#endif /* __USER_RTNR_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.
@lgirdwood can two parameters be passed at the same time? Just wondering if the same model handler can be reused or if they have to be separate
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.
Currently the model_handler is used for settings only( sample rate/ on&off ). For other data we would like to modify the internal data in RTNR directly.
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.
@jsarha is updated this API at, @jsarha can we support multiple large blobs per module/component ?
@MingJenTai I think the data would have to be serialized so that we only send one at a time from the host, @jsarha pls correct me if I'm wrong.
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 won't work as such, since the handler only maintains one blob per com_data_blob_handler. I think the easiest would adding multiple handlers to the comp_data, one for each blob, and and select the correct one based on component specific type.