|
20 | 20 | #include <stdint.h> |
21 | 21 |
|
22 | 22 | /* HACK: test ipc_msg_send syscall from LL */ |
| 23 | +#include <sof/audio/module_adapter/module/generic.h> |
23 | 24 | #include <sof/ipc/msg.h> |
24 | 25 | #include <sof/ipc/ipc_msg_send.h> |
25 | 26 | #include <ipc4/notification.h> |
| 27 | +#include <ipc4/header.h> |
| 28 | +#include <ipc4/module.h> |
26 | 29 |
|
27 | 30 | LOG_MODULE_DECLARE(selector, CONFIG_SOF_LOG_LEVEL); |
28 | 31 |
|
29 | 32 | #define BYTES_TO_S16_SAMPLES 1 |
30 | 33 | #define BYTES_TO_S32_SAMPLES 2 |
31 | 34 |
|
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 */ |
33 | 36 | static void sel_hack_notify(struct processing_module *mod, struct comp_data *cd) |
34 | 37 | { |
35 | 38 | 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)); |
44 | 58 | if (!cd->hack_msg) |
45 | 59 | 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; |
46 | 73 | } |
47 | 74 |
|
48 | 75 | 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; |
49 | 82 | cd->hack_frame_count = 0; |
50 | 83 | ipc_msg_send(cd->hack_msg, NULL, true); |
51 | 84 | } |
|
0 commit comments