Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM] UGLY HACK: Capture hw mute indicator test code #9800

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/audio/base_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ static int basefw_config(uint32_t *data_offset, char *data)
tlv_value_uint32_set(tuple, IPC4_FW_CONTEXT_SAVE,
IS_ENABLED(CONFIG_ADSP_IMR_CONTEXT_SAVE));

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_FW_GLOBAL_KCONTROL_MASK,
BIT(SOF_IPC4_KCONTROL_GLOBAL_CAPTURE_HW_MUTE));

tuple = tlv_next(tuple);

/* add platform specific tuples */
Expand Down
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);
}
2 changes: 2 additions & 0 deletions src/include/ipc4/base_fw.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ enum ipc4_fw_config_params {
IPC4_DMI_FORCE_L1_EXIT = 28,
/* FW context save on D3 entry */
IPC4_FW_CONTEXT_SAVE = 29,
/* Supported global kcontrol IDs mask */
IPC4_FW_GLOBAL_KCONTROL_MASK = 30,
/* Total number of FW config parameters */
IPC4_FW_CFG_PARAMS_COUNT,
/* Max config parameter id */
Expand Down
4 changes: 4 additions & 0 deletions src/include/ipc4/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,8 @@ struct sof_ipc4_notify_module_data {
uint8_t event_data[];
} __attribute((packed, aligned(4)));

enum sof_ipc4_kcontrol_global_id {
SOF_IPC4_KCONTROL_GLOBAL_CAPTURE_HW_MUTE = 1,
};

#endif
Loading