Skip to content

Commit 2e21b9d

Browse files
author
Jyri Sarha
committed
src/audio/selector/selector_generic.c: HACK notify test, with payload
1 parent 20d8a67 commit 2e21b9d

1 file changed

Lines changed: 42 additions & 9 deletions

File tree

src/audio/selector/selector_generic.c

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,65 @@
2020
#include <stdint.h>
2121

2222
/* HACK: test ipc_msg_send syscall from LL */
23+
#include <sof/audio/module_adapter/module/generic.h>
2324
#include <sof/ipc/msg.h>
2425
#include <sof/ipc/ipc_msg_send.h>
2526
#include <ipc4/notification.h>
27+
#include <ipc4/header.h>
28+
#include <ipc4/module.h>
2629

2730
LOG_MODULE_DECLARE(selector, CONFIG_SOF_LOG_LEVEL);
2831

2932
#define BYTES_TO_S16_SAMPLES 1
3033
#define BYTES_TO_S32_SAMPLES 2
3134

32-
/* HACK: send PHRASE_DETECTED notification every 1000 LL frames (~1 s) */
35+
/* HACK: send MODULE_NOTIFICATION every 1000 LL frames (~1 s) with payload */
3336
static void sel_hack_notify(struct processing_module *mod, struct comp_data *cd)
3437
{
3538
if (!cd->hack_msg) {
36-
union ipc4_notification_header nhdr;
37-
38-
nhdr.r.notif_type = SOF_IPC4_NOTIFY_PHRASE_DETECTED;
39-
nhdr.r.type = SOF_IPC4_GLB_NOTIFICATION;
40-
nhdr.r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
41-
nhdr.r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG;
42-
43-
cd->hack_msg = mod_ipc_msg_w_ext_init(mod, nhdr.dat, 0, 0);
39+
struct ipc_msg msg_proto;
40+
union ipc4_notification_header *primary =
41+
(union ipc4_notification_header *)&msg_proto.header;
42+
struct comp_dev *dev = mod->dev;
43+
struct comp_ipc_config *ipc_config = &dev->ipc_config;
44+
struct sof_ipc4_notify_module_data *msg_module_data;
45+
struct sof_ipc4_control_msg_payload *msg_payload;
46+
47+
memset(&msg_proto, 0, sizeof(msg_proto));
48+
primary->r.notif_type = SOF_IPC4_MODULE_NOTIFICATION;
49+
primary->r.type = SOF_IPC4_GLB_NOTIFICATION;
50+
primary->r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
51+
primary->r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG;
52+
53+
cd->hack_msg = mod_ipc_msg_w_ext_init(mod, msg_proto.header,
54+
msg_proto.extension,
55+
sizeof(*msg_module_data) +
56+
sizeof(*msg_payload) +
57+
sizeof(struct sof_ipc4_ctrl_value_chan));
4458
if (!cd->hack_msg)
4559
return;
60+
61+
msg_module_data = (struct sof_ipc4_notify_module_data *)cd->hack_msg->tx_data;
62+
msg_module_data->instance_id = IPC4_INST_ID(ipc_config->id);
63+
msg_module_data->module_id = IPC4_MOD_ID(ipc_config->id);
64+
msg_module_data->event_id = SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_MAGIC_VAL |
65+
SOF_IPC4_ENUM_CONTROL_PARAM_ID;
66+
msg_module_data->event_data_size = sizeof(*msg_payload) +
67+
sizeof(struct sof_ipc4_ctrl_value_chan);
68+
69+
msg_payload = (struct sof_ipc4_control_msg_payload *)msg_module_data->event_data;
70+
msg_payload->id = 0;
71+
msg_payload->num_elems = 1;
72+
msg_payload->chanv[0].channel = 0;
4673
}
4774

4875
if (++cd->hack_frame_count >= 1000) {
76+
struct sof_ipc4_notify_module_data *mdata =
77+
(struct sof_ipc4_notify_module_data *)cd->hack_msg->tx_data;
78+
struct sof_ipc4_control_msg_payload *payload =
79+
(struct sof_ipc4_control_msg_payload *)mdata->event_data;
80+
81+
payload->chanv[0].value = cd->hack_frame_count + cd->hack_frame_count;
4982
cd->hack_frame_count = 0;
5083
ipc_msg_send(cd->hack_msg, NULL, true);
5184
}

0 commit comments

Comments
 (0)