Skip to content

Commit b822f74

Browse files
author
Jyri Sarha
committed
ASoC: SOF: ipc4: Make debugfs reading of "probe_points" more informative
The current output of three integers is not very human readable. Use ipc4 functions to describe in more detail what the struct sof_probe_point_desc buffer_id is actually referring to in an ipc4 SOF system. Before this commit the "probe_points" debugfs file could read as: Id: 0x01000004 Purpose: 0 Node id: 0x100 Id: 0x00000006 Purpose: 0 Node id: 0x100 And after in the same situation in an ipc4 system it reads: 16777220,0,256 host-copier.0.playback output buf idx 0 (probed) 6,0,256 gain.1.1 input buf idx 0 (probed) The triplet in the beginning of the line can be used to reinserted the probe point again by writing it into "probe_points" debugfs file, if its first removed by writing the fist number in "probe_points_remove". The last number is ignored when creating a probe point. Signed-off-by: Jyri Sarha <[email protected]>
1 parent 846e4eb commit b822f74

File tree

2 files changed

+77
-3
lines changed

2 files changed

+77
-3
lines changed

sound/soc/sof/sof-client-probes.c

+63-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@
1717

1818
#include <sound/soc.h>
1919
#include <sound/sof/header.h>
20+
#include <sound/sof/ipc4/header.h>
2021
#include "sof-client.h"
2122
#include "sof-client-probes.h"
23+
#include "sof-audio.h"
24+
25+
#ifdef CONFIG_SND_SOC_SOF_IPC4
26+
#include "ipc4-priv.h"
27+
#endif
2228

2329
#define SOF_PROBES_SUSPEND_DELAY_MS 3000
2430
/* only extraction supported for now */
@@ -188,6 +194,56 @@ static const struct snd_compress_ops sof_probes_compressed_ops = {
188194
.copy = sof_probes_compr_copy,
189195
};
190196

197+
#ifdef CONFIG_SND_SOC_SOF_IPC4
198+
static const char *sof_probe_ipc4_type(u32 type)
199+
{
200+
switch (type) {
201+
case PROBE_TYPE_INPUT:
202+
return "input";
203+
case PROBE_TYPE_OUTPUT:
204+
return "output";
205+
case PROBE_TYPE_INTERNAL:
206+
return "internal";
207+
default:
208+
return "UNKNOWN";
209+
}
210+
}
211+
212+
static int sof_probes_ipc4_prints(struct sof_client_dev *cdev, char *buf, size_t size,
213+
struct sof_probe_point_desc *desc)
214+
{
215+
struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
216+
struct device *dev = &cdev->auxdev.dev;
217+
struct snd_sof_widget *w;
218+
int ret;
219+
220+
w = sof_ipc4_find_swidget_by_ids(sdev, SOF_IPC4_MOD_ID_GET(desc->buffer_id),
221+
SOF_IPC4_MOD_INSTANCE_GET(desc->buffer_id));
222+
if (!w) {
223+
dev_warn(dev, "matchin widget to module_id %lu and instance_id %lu not found\n",
224+
SOF_IPC4_MOD_ID_GET(desc->buffer_id),
225+
SOF_IPC4_MOD_INSTANCE_GET(desc->buffer_id));
226+
ret = snprintf(buf, size,
227+
"Id: %#010x Purpose: %u Node id: %#x\n",
228+
desc->buffer_id, desc->purpose, desc->stream_tag);
229+
return ret;
230+
}
231+
232+
ret = snprintf(buf, size, "%u,%u,%u\t%s %s buf idx %lu %s\n",
233+
desc->buffer_id, desc->purpose, desc->stream_tag, w->widget->name,
234+
sof_probe_ipc4_type(SOF_IPC4_PROBE_TYPE_GET(desc->buffer_id)),
235+
SOF_IPC4_PROBE_IDX_GET(desc->buffer_id),
236+
desc->stream_tag ? "(probed)" : "");
237+
return ret;
238+
}
239+
#else
240+
static int sof_probes_ipc4_prints(struct sof_client_dev *cdev, char *buf, size_t size,
241+
struct sof_probe_point_desc *desc)
242+
{
243+
return -ENODEV;
244+
}
245+
#endif
246+
191247
static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
192248
size_t count, loff_t *ppos)
193249
{
@@ -223,9 +279,13 @@ static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
223279
for (i = 0; i < num_desc; i++) {
224280
offset = strlen(buf);
225281
remaining = PAGE_SIZE - offset;
226-
ret = snprintf(buf + offset, remaining,
227-
"Id: %#010x Purpose: %u Node id: %#x\n",
228-
desc[i].buffer_id, desc[i].purpose, desc[i].stream_tag);
282+
if (sof_client_get_ipc_type(cdev) == SOF_IPC_TYPE_4)
283+
ret = sof_probes_ipc4_prints(cdev, buf + offset, remaining, &desc[i]);
284+
else
285+
ret = snprintf(buf + offset, remaining,
286+
"Id: %#010x Purpose: %u Node id: %#x\n",
287+
desc[i].buffer_id, desc[i].purpose, desc[i].stream_tag);
288+
229289
if (ret < 0 || ret >= remaining) {
230290
/* truncate the output buffer at the last full line */
231291
buf[offset] = '\0';

sound/soc/sof/sof-client-probes.h

+14
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ struct sof_probe_point_desc {
3434
unsigned int stream_tag;
3535
} __packed;
3636

37+
#define SOF_IPC4_PROBE_TYPE_SHIFT 24
38+
#define SOF_IPC4_PROBE_TYPE_MASK GENMASK(25, 24)
39+
#define SOF_IPC4_PROBE_TYPE_GET(x) (((x) & SOF_IPC4_PROBE_TYPE_MASK) \
40+
>> SOF_IPC4_PROBE_TYPE_SHIFT)
41+
42+
#define PROBE_TYPE_INPUT 0
43+
#define PROBE_TYPE_OUTPUT 1
44+
#define PROBE_TYPE_INTERNAL 2
45+
46+
#define SOF_IPC4_PROBE_IDX_SHIFT 26
47+
#define SOF_IPC4_PROBE_IDX_MASK GENMASK(31, 26)
48+
#define SOF_IPC4_PROBE_IDX_GET(x) (((x) & SOF_IPC4_PROBE_IDX_MASK) \
49+
>> SOF_IPC4_PROBE_IDX_SHIFT)
50+
3751
struct sof_probes_ipc_ops {
3852
int (*init)(struct sof_client_dev *cdev, u32 stream_tag,
3953
size_t buffer_size);

0 commit comments

Comments
 (0)