Skip to content

Commit e202d78

Browse files
committed
audio: dax: remove dependencies on stdlib
We remove memmove and sprintf for two reasons: 1) Both of them are not available on XTOS when using certain xtensa toolchains. 2) Them are not marked as EXPORT_SYMBOL by Zephyr when compiling as LLEXT module. Signed-off-by: Jun Lai <jun.lai@dolby.com>
1 parent abd969b commit e202d78

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

src/audio/module_adapter/module/dolby/dax.c

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,53 @@ DECLARE_TR_CTX(dolby_dax_audio_processing_tr, SOF_UUID(dolby_dax_audio_processin
3636
#define DAX_ENUM_PROFILE_CONTROL_ID 0
3737
#define DAX_ENUM_DEVICE_CONTROL_ID 1
3838

39+
static int itostr(int num, char *str)
40+
{
41+
int index = 0, digit_count = 0;
42+
int temp;
43+
44+
if (num < 0) {
45+
str[0] = '-';
46+
index = 1;
47+
num = -num;
48+
}
49+
50+
if (num == 0) {
51+
str[index] = '0';
52+
str[index + 1] = '\0';
53+
return index + 1;
54+
}
55+
56+
temp = num;
57+
while (temp > 0) {
58+
temp /= 10;
59+
digit_count++;
60+
}
61+
62+
temp = index + digit_count - 1;
63+
while (num > 0) {
64+
str[temp] = (num % 10) + '0';
65+
num /= 10;
66+
temp--;
67+
}
68+
69+
str[index + digit_count] = '\0';
70+
return index + digit_count;
71+
}
72+
3973
static const char *get_params_str(const void *val, uint32_t val_sz)
4074
{
4175
static char params_str[MAX_PARAMS_STR_BUFFER_SIZE + 16];
4276
const int32_t *param_val = (const int32_t *)val;
4377
const uint32_t param_sz = val_sz >> 2;
4478
uint32_t offset = 0;
4579

46-
for (uint32_t i = 0; i < param_sz && offset < MAX_PARAMS_STR_BUFFER_SIZE; i++)
47-
offset += sprintf(params_str + offset, "%d,", param_val[i]);
80+
for (uint32_t i = 0; i < param_sz && offset < MAX_PARAMS_STR_BUFFER_SIZE; i++) {
81+
offset += itostr(param_val[i], params_str + offset);
82+
params_str[offset] = ',';
83+
offset++;
84+
params_str[offset] = '\0';
85+
}
4886
return &params_str[0];
4987
}
5088

@@ -126,9 +164,14 @@ static int dax_buffer_alloc(struct processing_module *mod,
126164
/* After reading from buffer */
127165
static void dax_buffer_consume(struct dax_buffer *dax_buff, uint32_t bytes)
128166
{
167+
uint8_t *buf = (uint8_t *)dax_buff->addr;
168+
uint32_t copy_bytes;
169+
129170
bytes = MIN(bytes, dax_buff->avail);
130-
memmove(dax_buff->addr, (uint8_t *)dax_buff->addr + bytes, dax_buff->avail - bytes);
131-
dax_buff->avail = dax_buff->avail - bytes;
171+
copy_bytes = dax_buff->avail - bytes;
172+
for (int i = 0; i < copy_bytes; i++)
173+
buf[i] = buf[bytes + i];
174+
dax_buff->avail = copy_bytes;
132175
dax_buff->free = dax_buff->size - dax_buff->avail;
133176
}
134177

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ manifest:
4343

4444
- name: zephyr
4545
repo-path: zephyr
46-
revision: 6cd7cfa104a5f4de68408c9bf6516cd1109b9782
46+
revision: 769ba82aa5ec482af0c4649ba075065e901fbe69
4747
remote: zephyrproject
4848

4949
# Import some projects listed in zephyr/west.yml@revision

0 commit comments

Comments
 (0)