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

Probe ipc4 info #9669

Merged
merged 2 commits into from
Nov 26, 2024
Merged
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
1 change: 1 addition & 0 deletions src/include/ipc4/probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#define IPC4_PROBE_MODULE_INJECTION_DMA_DETACH 2
#define IPC4_PROBE_MODULE_PROBE_POINTS_ADD 3
#define IPC4_PROBE_MODULE_DISCONNECT_PROBE_POINTS 4
#define IPC4_PROBE_MODULE_AVAILABLE_PROBE_POINTS 5

/**
* Description of probe dma
Expand Down
100 changes: 100 additions & 0 deletions src/probe/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,105 @@ static int probe_set_config(struct processing_module *mod, uint32_t param_id,
}
}

static int probe_add_point_info_params(struct sof_ipc_probe_info_params *info,
probe_point_id_t id, int index, size_t max_size)
{
struct probe_pdata *_probe = probe_get();
struct probe_point pp = {
.buffer_id = id,
.purpose = PROBE_PURPOSE_EXTRACTION,
};
int i;

if (offsetof(struct sof_ipc_probe_info_params, probe_point[index]) +
sizeof(pp) > max_size) {
info->num_elems = index;
return -ENOENT;
}

for (i = 0; i < ARRAY_SIZE(_probe->probe_points); i++)
if (_probe->probe_points[i].stream_tag != PROBE_POINT_INVALID &&
_probe->probe_points[i].buffer_id.full_id == id.full_id)
pp.stream_tag = _probe->probe_points[i].stream_tag;

info->probe_point[index] = pp;
return 0;
}

static int probe_get_available_points(struct processing_module *mod,
struct sof_ipc_probe_info_params *info,
size_t max_size)
{
struct ipc_comp_dev *icd;
struct list_item *clist;
int i = 0;

list_for_item(clist, &ipc_get()->comp_list) {
struct comp_buffer *buf;
probe_point_id_t id;

icd = container_of(clist, struct ipc_comp_dev, list);
if (icd->type != COMP_TYPE_COMPONENT)
continue;

id.fields.module_id = IPC4_MOD_ID(icd->id);
id.fields.instance_id = IPC4_INST_ID(icd->id);

id.fields.type = PROBE_TYPE_INPUT;
comp_dev_for_each_producer(icd->cd, buf) {
id.fields.index = IPC4_SRC_QUEUE_ID(buf_get_id(buf));
if (probe_add_point_info_params(info, id, i, max_size))
return 0;
i++;
}
id.fields.type = PROBE_TYPE_OUTPUT;
comp_dev_for_each_consumer(icd->cd, buf) {
id.fields.index = IPC4_SINK_QUEUE_ID(buf_get_id(buf));
if (probe_add_point_info_params(info, id, i, max_size))
return 0;
i++;
}
}
info->num_elems = i;
return 0;
}

static int probe_get_config(struct processing_module *mod,
uint32_t config_id, uint32_t *data_offset_size,
uint8_t *fragment, size_t fragment_size)
{
struct sof_ipc_probe_info_params *info =
(struct sof_ipc_probe_info_params *)ASSUME_ALIGNED(fragment, 8);
struct probe_pdata *_probe = probe_get();
struct comp_dev *dev = mod->dev;
int i, j;

comp_dbg(dev, "config_id %u", config_id);
switch (config_id) {
case IPC4_PROBE_MODULE_PROBE_POINTS_ADD:
for (i = 0, j = 0; i < ARRAY_SIZE(_probe->probe_points); i++) {
if (_probe->probe_points[i].stream_tag == PROBE_POINT_INVALID)
continue;
if (offsetof(struct sof_ipc_probe_info_params, probe_point[j]) +
sizeof(info->probe_point[0]) > fragment_size)
break;
info->probe_point[j++] = _probe->probe_points[i];
}
info->num_elems = j;
comp_info(dev, "%u probe points sent", j);
break;
case IPC4_PROBE_MODULE_AVAILABLE_PROBE_POINTS:
probe_get_available_points(mod, info, fragment_size);
comp_info(dev, "%u available probe points sent",
info->num_elems);
break;
default:
comp_err(dev, "unknown config_id %u", config_id);
return -EINVAL;
}
return 0;
}

static int probe_dummy_process(struct processing_module *mod,
struct input_stream_buffer *input_buffers, int num_input_buffers,
struct output_stream_buffer *output_buffers, int num_output_buffers)
Expand All @@ -1506,6 +1605,7 @@ static const struct module_interface probe_interface = {
.init = probe_mod_init,
.process_audio_stream = probe_dummy_process,
.set_configuration = probe_set_config,
.get_configuration = probe_get_config,
.free = probe_free,
};

Expand Down
Loading