forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsof_shell.c
More file actions
84 lines (64 loc) · 2 KB
/
sof_shell.c
File metadata and controls
84 lines (64 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// SPDX-License-Identifier: BSD-3-Clause
/*
* Copyright(c) 2024 Intel Corporation.
*
* Author: Kai Vehmanen <kai.vehmanen@linux.intel.com>
*/
#include <rtos/sof.h> /* sof_get() */
#include <sof/schedule/ll_schedule_domain.h>
#include <sof/audio/module_adapter/module/generic.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
#include <zephyr/shell/shell.h>
#include <stdlib.h>
#define SOF_TEST_INJECT_SCHED_GAP_USEC 1500
static int cmd_sof_test_inject_sched_gap(const struct shell *sh,
size_t argc, char *argv[])
{
uint32_t block_time = SOF_TEST_INJECT_SCHED_GAP_USEC;
char *endptr = NULL;
#ifndef CONFIG_CROSS_CORE_STREAM
shell_fprintf(sh, SHELL_NORMAL, "Domain blocking not supported, not reliable on SMP\n");
#endif
domain_block(sof_get()->platform_timer_domain);
if (argc > 1) {
block_time = strtol(argv[1], &endptr, 0);
if (endptr == argv[1])
return -EINVAL;
}
k_busy_wait(block_time);
domain_unblock(sof_get()->platform_timer_domain);
return 0;
}
static int cmd_sof_module_heap_usage(const struct shell *sh,
size_t argc, char *argv[])
{
struct ipc *ipc = sof_get()->ipc;
struct list_item *clist, *_clist;
struct ipc_comp_dev *icd;
if (!ipc) {
shell_print(sh, "No IPC");
return 0;
}
list_for_item_safe(clist, _clist, &ipc->comp_list) {
size_t usage, hwm;
icd = container_of(clist, struct ipc_comp_dev, list);
if (icd->type != COMP_TYPE_COMPONENT)
continue;
usage = module_adapter_heap_usage(comp_mod(icd->cd), &hwm);
shell_print(sh, "comp id 0x%08x%9zu usage%9zu hwm %9zu max\tbytes",
icd->id, usage, hwm, comp_mod(icd->cd)->priv.cfg.heap_bytes);
}
return 0;
}
SHELL_STATIC_SUBCMD_SET_CREATE(sof_commands,
SHELL_CMD(test_inject_sched_gap, NULL,
"Inject a gap to audio scheduling\n",
cmd_sof_test_inject_sched_gap),
SHELL_CMD(module_heap_usage, NULL,
"Print heap memory usage of each module\n",
cmd_sof_module_heap_usage),
SHELL_SUBCMD_SET_END
);
SHELL_CMD_REGISTER(sof, &sof_commands,
"SOF application commands", NULL);