Skip to content

Commit 2984da4

Browse files
committed
module: cadence / ipc4: Support for EOS handling and notification to host
When the pipeline has the expect_eos flag set and the cadence module produces 0 bytes during process is an indication that the EOS has been completed and the module drained all data from input to output. Send a notification about this to host and set EOS state on downstream module instances. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent ededd70 commit 2984da4

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

src/audio/module_adapter/module/cadence.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ int cadence_codec_init_process(struct processing_module *mod)
250250
struct cadence_codec_data *cd = codec->private;
251251
struct comp_dev *dev = mod->dev;
252252

253+
codec->mpd.eos_reached = false;
254+
codec->mpd.eos_notification_sent = false;
255+
253256
API_CALL(cd, XA_API_CMD_SET_INPUT_BYTES, 0, &codec->mpd.avail, ret);
254257
if (ret != LIB_NO_ERROR) {
255258
comp_err(dev, "error %x: failed to set size of input data",
@@ -475,6 +478,13 @@ int cadence_codec_process_data(struct processing_module *mod)
475478
struct comp_dev *dev = mod->dev;
476479
int ret;
477480

481+
if (codec->mpd.eos_reached) {
482+
codec->mpd.produced = 0;
483+
codec->mpd.consumed = 0;
484+
485+
return 0;
486+
}
487+
478488
API_CALL(cd, XA_API_CMD_SET_INPUT_BYTES, 0, &codec->mpd.avail, ret);
479489
if (ret != LIB_NO_ERROR) {
480490
comp_err(dev, "failed to set size of input data with error: %x:", ret);
@@ -503,5 +513,8 @@ int cadence_codec_process_data(struct processing_module *mod)
503513
return ret;
504514
}
505515

516+
if (!codec->mpd.produced && dev->pipeline->expect_eos)
517+
codec->mpd.eos_reached = true;
518+
506519
return 0;
507520
}

src/audio/module_adapter/module/cadence_ipc4.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
#include <sof/audio/cadence/mp3_dec/xa_mp3_dec_api.h>
99
#include <sof/audio/cadence/mp3_enc/xa_mp3_enc_api.h>
1010
#include <sof/audio/cadence/aac_dec/xa_aac_dec_api.h>
11+
#include <sof/ipc/msg.h>
1112
#include <sof/schedule/ll_schedule_domain.h>
1213
#include <ipc/compress_params.h>
14+
#include <ipc4/notification.h>
1315
#include <rtos/init.h>
1416

1517
SOF_DEFINE_REG_UUID(cadence_codec);
@@ -468,6 +470,36 @@ static int cadence_codec_process(struct processing_module *mod, struct sof_sourc
468470
return ret;
469471
}
470472

473+
if (codec->mpd.eos_reached && !codec->mpd.eos_notification_sent) {
474+
struct ipc_msg msg_proto;
475+
struct comp_ipc_config *ipc_config = &dev->ipc_config;
476+
union ipc4_notification_header *primary =
477+
(union ipc4_notification_header *)&msg_proto.header;
478+
struct sof_ipc4_notify_module_data *msg_module_data;
479+
struct ipc_msg *msg;
480+
481+
memset_s(&msg_proto, sizeof(msg_proto), 0, sizeof(msg_proto));
482+
primary->r.notif_type = SOF_IPC4_MODULE_NOTIFICATION;
483+
primary->r.type = SOF_IPC4_GLB_NOTIFICATION;
484+
primary->r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
485+
primary->r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG;
486+
msg = ipc_msg_w_ext_init(msg_proto.header, msg_proto.extension,
487+
sizeof(*msg_module_data));
488+
if (msg) {
489+
msg_module_data = (struct sof_ipc4_notify_module_data *)msg->tx_data;
490+
msg_module_data->instance_id = IPC4_INST_ID(ipc_config->id);
491+
msg_module_data->module_id = IPC4_MOD_ID(ipc_config->id);
492+
msg_module_data->event_id = SOF_IPC4_NOTIFY_MODULE_EVENTID_COMPR_MAGIC_VAL;
493+
msg_module_data->event_data_size = 0;
494+
495+
ipc_msg_send(msg, NULL, false);
496+
codec->mpd.eos_notification_sent = true;
497+
}
498+
499+
/* Set EOS for the sink as we are not going to produce more data */
500+
audio_buffer_set_eos(sof_audio_buffer_from_sink(sinks[0]));
501+
}
502+
471503
/* do not proceed if not enough free space left */
472504
if (out_space < codec->mpd.produced) {
473505
source_release_data(sources[0], 0);

0 commit comments

Comments
 (0)