Skip to content

Commit

Permalink
UGLY HACK: debug: debug_stream_thread_info: mic privacy msg HACK
Browse files Browse the repository at this point in the history
UGLY HACK: do not merge!!!

Hack to send global capture hw mute togling message periodically.
  • Loading branch information
Jyri Sarha committed Feb 4, 2025
1 parent 184f7ff commit 1835e7d
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions src/debug/debug_stream/debug_stream_thread_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,23 +313,31 @@ static void thread_info_get(int core, struct record_buf *bufd)
debug_stream_slot_send_record(&hdr->hdr);
}

static void hack_notification_init(void);
static void hack_notification_send(uint32_t val);

static void thread_info_run(void *cnum, void *a, void *b)
{
int core = (int) cnum;
struct record_buf bufd = {
.size = THREAD_INFO_INITIAL_RECORD_BUFFER_SIZE,
.w_ptr = 0,
};
uint32_t val = 0;

bufd.buf = rmalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, bufd.size);
if (!bufd.buf) {
LOG_ERR("malloc failed");
return;
}

hack_notification_init();

for (;;) {
thread_info_get(core, &bufd);
k_sleep(K_SECONDS(CONFIG_SOF_DEBUG_STREAM_THREAD_INFO_INTERVAL));
val = !val;
hack_notification_send(val);
}
}

Expand Down Expand Up @@ -375,3 +383,76 @@ static int thread_info_start(void)
}

SYS_INIT(thread_info_start, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

/* HACK notification test */
#include <sof/ipc/msg.h>
#include <ipc4/notification.h>
#include <ipc4/module.h>
#include <ipc4/header.h>
#include <ipc4/base-config.h>

#define SOF_IPC4_MOD_INIT_BASEFW_MOD_ID 0
#define SOF_IPC4_MOD_INIT_BASEFW_INSTANCE_ID 0

static struct ipc_msg *notification_template;

static void hack_notification_init(void)
{
struct ipc_msg msg_proto;
union ipc4_notification_header *primary =
(union ipc4_notification_header *)&msg_proto.header;
struct sof_ipc4_notify_module_data *msg_module_data;
struct sof_ipc4_control_msg_payload *msg_payload;
struct ipc_msg *msg;

/* Clear header, extension, and other ipc_msg members */
memset_s(&msg_proto, sizeof(msg_proto), 0, sizeof(msg_proto));
primary->r.notif_type = SOF_IPC4_MODULE_NOTIFICATION;
primary->r.type = SOF_IPC4_GLB_NOTIFICATION;
primary->r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
primary->r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG;
msg = ipc_msg_w_ext_init(msg_proto.header, msg_proto.extension,
sizeof(struct sof_ipc4_notify_module_data) +
sizeof(struct sof_ipc4_control_msg_payload) +
sizeof(struct sof_ipc4_ctrl_value_chan));
if (!msg) {
LOG_ERR("ipc_msg_w_ext_init() failed!");
return;
}

msg_module_data = (struct sof_ipc4_notify_module_data *)msg->tx_data;
msg_module_data->instance_id = IPC4_INST_ID(SOF_IPC4_MOD_INIT_BASEFW_INSTANCE_ID);
msg_module_data->module_id = IPC4_MOD_ID(SOF_IPC4_MOD_INIT_BASEFW_MOD_ID);
msg_module_data->event_id = SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_MAGIC_VAL |
SOF_IPC4_SWITCH_CONTROL_PARAM_ID;
msg_module_data->event_data_size = sizeof(struct sof_ipc4_control_msg_payload) +
sizeof(struct sof_ipc4_ctrl_value_chan);

msg_payload = (struct sof_ipc4_control_msg_payload *)msg_module_data->event_data;
msg_payload->id = SOF_IPC4_KCONTROL_GLOBAL_CAPTURE_HW_MUTE;
msg_payload->num_elems = 1;
msg_payload->chanv[0].channel = 0;

LOG_INF("msg initialized");
notification_template = msg;
}

static void hack_notification_send(uint32_t val)
{
struct ipc_msg *msg = notification_template;
struct sof_ipc4_notify_module_data *msg_module_data;
struct sof_ipc4_control_msg_payload *msg_payload;

if (!msg) {
LOG_ERR("msg not initialized");
return;
}

msg_module_data = (struct sof_ipc4_notify_module_data *)msg->tx_data;
msg_payload = (struct sof_ipc4_control_msg_payload *)msg_module_data->event_data;
msg_payload->chanv[0].value = val;

LOG_INF("SENDING msg %p %u", msg->tx_data, (msg->tx_size));

ipc_msg_send(msg, msg->tx_data, false);
}

0 comments on commit 1835e7d

Please sign in to comment.