Skip to content

Commit 065622a

Browse files
author
Jyri Sarha
committed
ASoC: SOF: sof-client-probes-ipc4: Human readable debugfs "probe_points"
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: 0x7,0x0,0x100 gain.1.1 input buf idx 0 (connected) 0x1000005,0x0,0x100 host-copier.0.playback output buf idx 0 (connected) 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 7b0b5e7 commit 065622a

File tree

3 files changed

+72
-3
lines changed

3 files changed

+72
-3
lines changed

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

+57
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <sound/soc.h>
99
#include <sound/sof/ipc4/header.h>
1010
#include <uapi/sound/sof/header.h>
11+
#include "sof-audio.h"
1112
#include "sof-priv.h"
1213
#include "ipc4-priv.h"
1314
#include "sof-client.h"
@@ -49,6 +50,15 @@ enum sof_ipc4_probe_type {
4950
SOF_IPC4_PROBE_TYPE_INTERNAL
5051
};
5152

53+
#define SOF_IPC4_PROBE_TYPE_SHIFT 24
54+
#define SOF_IPC4_PROBE_TYPE_MASK GENMASK(25, 24)
55+
#define SOF_IPC4_PROBE_TYPE_GET(x) (((x) & SOF_IPC4_PROBE_TYPE_MASK) \
56+
>> SOF_IPC4_PROBE_TYPE_SHIFT)
57+
#define SOF_IPC4_PROBE_IDX_SHIFT 26
58+
#define SOF_IPC4_PROBE_IDX_MASK GENMASK(31, 26)
59+
#define SOF_IPC4_PROBE_IDX_GET(x) (((x) & SOF_IPC4_PROBE_IDX_MASK) \
60+
>> SOF_IPC4_PROBE_IDX_SHIFT)
61+
5262
struct sof_ipc4_probe_point {
5363
u32 point_id;
5464
u32 purpose;
@@ -62,6 +72,20 @@ struct sof_ipc4_probe_info {
6272

6373
#define INVALID_PIPELINE_ID 0xFF
6474

75+
static const char *sof_probe_ipc4_type_string(u32 type)
76+
{
77+
switch (type) {
78+
case SOF_IPC4_PROBE_TYPE_INPUT:
79+
return "input";
80+
case SOF_IPC4_PROBE_TYPE_OUTPUT:
81+
return "output";
82+
case SOF_IPC4_PROBE_TYPE_INTERNAL:
83+
return "internal";
84+
default:
85+
return "UNKNOWN";
86+
}
87+
}
88+
6589
/**
6690
* sof_ipc4_probe_get_module_info - Get IPC4 module info for probe module
6791
* @cdev: SOF client device
@@ -224,6 +248,38 @@ static int ipc4_probes_points_info(struct sof_client_dev *cdev,
224248
return 0;
225249
}
226250

251+
/**
252+
* ipc4_probes_point_print - Human readable print of probe point descriptor
253+
* @cdev: SOF client device
254+
* @buf: Buffer to print to
255+
* @size: Available bytes in buffer
256+
* @desc: Describes the probe point to print
257+
* @return: Number of bytes printed or an error code (snprintf return value)
258+
*/
259+
static int ipc4_probes_point_print(struct sof_client_dev *cdev, char *buf, size_t size,
260+
struct sof_probe_point_desc *desc)
261+
{
262+
struct device *dev = &cdev->auxdev.dev;
263+
struct snd_sof_widget *swidget;
264+
int ret;
265+
266+
swidget = sof_client_ipc4_find_swidget_by_id(cdev, SOF_IPC4_MOD_ID_GET(desc->buffer_id),
267+
SOF_IPC4_MOD_INSTANCE_GET(desc->buffer_id));
268+
if (!swidget)
269+
dev_err(dev, "%s: Failed to find widget for module %lu.%lu\n",
270+
__func__, SOF_IPC4_MOD_ID_GET(desc->buffer_id),
271+
SOF_IPC4_MOD_INSTANCE_GET(desc->buffer_id));
272+
273+
ret = snprintf(buf, size, "0x%x,0x%x,0x%x\t%s %s buf idx %lu %s\n",
274+
desc->buffer_id, desc->purpose, desc->stream_tag,
275+
swidget ? swidget->widget->name : "<unknown>",
276+
sof_probe_ipc4_type_string(SOF_IPC4_PROBE_TYPE_GET(desc->buffer_id)),
277+
SOF_IPC4_PROBE_IDX_GET(desc->buffer_id),
278+
desc->stream_tag ? "(connected)" : "");
279+
280+
return ret;
281+
}
282+
227283
/**
228284
* ipc4_probes_points_add - connect specified probes
229285
* @cdev: SOF client device
@@ -328,6 +384,7 @@ const struct sof_probes_ipc_ops ipc4_probe_ops = {
328384
.init = ipc4_probes_init,
329385
.deinit = ipc4_probes_deinit,
330386
.points_info = ipc4_probes_points_info,
387+
.point_print = ipc4_probes_point_print,
331388
.points_add = ipc4_probes_points_add,
332389
.points_remove = ipc4_probes_points_remove,
333390
};

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

+13-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 */
@@ -223,9 +229,13 @@ static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
223229
for (i = 0; i < num_desc; i++) {
224230
offset = strlen(buf);
225231
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);
232+
if (ipc->point_print)
233+
ret = ipc->point_print(cdev, buf + offset, remaining, &desc[i]);
234+
else
235+
ret = snprintf(buf + offset, remaining,
236+
"Id: %#010x Purpose: %u Node id: %#x\n",
237+
desc[i].buffer_id, desc[i].purpose, desc[i].stream_tag);
238+
229239
if (ret < 0 || ret >= remaining) {
230240
/* truncate the output buffer at the last full line */
231241
buf[offset] = '\0';

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

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ struct sof_probes_ipc_ops {
4141
int (*points_info)(struct sof_client_dev *cdev,
4242
struct sof_probe_point_desc **desc,
4343
size_t *num_desc);
44+
int (*point_print)(struct sof_client_dev *cdev, char *buf, size_t size,
45+
struct sof_probe_point_desc *desc);
4446
int (*points_add)(struct sof_client_dev *cdev,
4547
struct sof_probe_point_desc *desc,
4648
size_t num_desc);

0 commit comments

Comments
 (0)