Skip to content

Commit

Permalink
Smart_amp: Remove the k_mute lock of IPC3 implementation
Browse files Browse the repository at this point in the history
Since smart_amp_test will always start feedback path firston IPC3
and the k_mute lock is added for IPC4 to support arbitrarily order
of starting source path and feedback source. So remove the k_mute
from IPC3 implementation.

Signed-off-by: Andrula Song <[email protected]>
  • Loading branch information
andrula-song authored and kv2019i committed May 8, 2023
1 parent 250a17c commit 460bca5
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/samples/audio/smart_amp_test_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ struct smart_amp_data {
struct comp_buffer *feedback_buf; /**< feedback source buffer */
struct comp_buffer *sink_buf; /**< sink buffer */

struct k_mutex lock; /**< protect feedback_buf updated */

smart_amp_proc process;

uint32_t in_channels;
Expand Down Expand Up @@ -76,18 +74,14 @@ static struct comp_dev *smart_amp_new(const struct comp_driver *drv,
if (!sad->model_handler)
goto sad_fail;

k_mutex_init(&sad->lock);

cfg = (struct sof_smart_amp_config *)ipc_sa->data;
bs = ipc_sa->size;

if (bs > 0 && bs < sizeof(struct sof_smart_amp_config)) {
comp_err(dev, "smart_amp_new(): failed to apply config");
goto sad_fail;
}

memcpy_s(&sad->config, sizeof(struct sof_smart_amp_config), cfg, bs);

dev->state = COMP_STATE_READY;

return dev;
Expand Down Expand Up @@ -321,14 +315,11 @@ static int smart_amp_trigger(struct comp_dev *dev, int cmd)
switch (cmd) {
case COMP_TRIGGER_START:
case COMP_TRIGGER_RELEASE:
k_mutex_lock(&sad->lock, K_FOREVER);
if (sad->feedback_buf) {
struct comp_buffer __sparse_cache *buf = buffer_acquire(sad->feedback_buf);

buffer_zero(buf);
buffer_release(buf);
}
k_mutex_unlock(&sad->lock);
break;
case COMP_TRIGGER_PAUSE:
case COMP_TRIGGER_STOP:
Expand Down Expand Up @@ -439,7 +430,6 @@ static int smart_amp_copy(struct comp_dev *dev)
audio_stream_avail_frames(&source_buf->stream,
&sink_buf->stream);

k_mutex_lock(&sad->lock, K_FOREVER);
if (sad->feedback_buf) {
struct comp_buffer __sparse_cache *buf = buffer_acquire(sad->feedback_buf);

Expand Down Expand Up @@ -467,7 +457,6 @@ static int smart_amp_copy(struct comp_dev *dev)

buffer_release(buf);
}
k_mutex_unlock(&sad->lock);

if (!avail_frames)
avail_frames = avail_passthrough_frames;
Expand Down Expand Up @@ -545,15 +534,13 @@ static int smart_amp_prepare(struct comp_dev *dev)
buffer_c = buffer_acquire(sad->source_buf);
sad->in_channels = audio_stream_get_channels(&buffer_c->stream);

k_mutex_lock(&sad->lock, K_FOREVER);
if (sad->feedback_buf) {
struct comp_buffer __sparse_cache *buf = buffer_acquire(sad->feedback_buf);

buf->stream.channels = sad->config.feedback_channels;
buf->stream.rate = audio_stream_get_rate(&buffer_c->stream);
buffer_release(buf);
}
k_mutex_unlock(&sad->lock);

sad->process = get_smart_amp_process(dev, buffer_c);
if (!sad->process) {
Expand Down

0 comments on commit 460bca5

Please sign in to comment.