Skip to content

Commit

Permalink
ASoC: SOF: ipc4: Make debugfs reading of "probe_points" more informative
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Jyri Sarha committed Nov 21, 2024
1 parent 846e4eb commit b822f74
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 3 deletions.
66 changes: 63 additions & 3 deletions sound/soc/sof/sof-client-probes.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@

#include <sound/soc.h>
#include <sound/sof/header.h>
#include <sound/sof/ipc4/header.h>
#include "sof-client.h"
#include "sof-client-probes.h"
#include "sof-audio.h"

#ifdef CONFIG_SND_SOC_SOF_IPC4
#include "ipc4-priv.h"
#endif

#define SOF_PROBES_SUSPEND_DELAY_MS 3000
/* only extraction supported for now */
Expand Down Expand Up @@ -188,6 +194,56 @@ static const struct snd_compress_ops sof_probes_compressed_ops = {
.copy = sof_probes_compr_copy,
};

#ifdef CONFIG_SND_SOC_SOF_IPC4
static const char *sof_probe_ipc4_type(u32 type)
{
switch (type) {
case PROBE_TYPE_INPUT:
return "input";
case PROBE_TYPE_OUTPUT:
return "output";
case PROBE_TYPE_INTERNAL:
return "internal";
default:
return "UNKNOWN";
}
}

static int sof_probes_ipc4_prints(struct sof_client_dev *cdev, char *buf, size_t size,
struct sof_probe_point_desc *desc)
{
struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
struct device *dev = &cdev->auxdev.dev;
struct snd_sof_widget *w;
int ret;

w = sof_ipc4_find_swidget_by_ids(sdev, SOF_IPC4_MOD_ID_GET(desc->buffer_id),
SOF_IPC4_MOD_INSTANCE_GET(desc->buffer_id));
if (!w) {
dev_warn(dev, "matchin widget to module_id %lu and instance_id %lu not found\n",
SOF_IPC4_MOD_ID_GET(desc->buffer_id),
SOF_IPC4_MOD_INSTANCE_GET(desc->buffer_id));
ret = snprintf(buf, size,
"Id: %#010x Purpose: %u Node id: %#x\n",
desc->buffer_id, desc->purpose, desc->stream_tag);
return ret;
}

ret = snprintf(buf, size, "%u,%u,%u\t%s %s buf idx %lu %s\n",
desc->buffer_id, desc->purpose, desc->stream_tag, w->widget->name,
sof_probe_ipc4_type(SOF_IPC4_PROBE_TYPE_GET(desc->buffer_id)),
SOF_IPC4_PROBE_IDX_GET(desc->buffer_id),
desc->stream_tag ? "(probed)" : "");
return ret;
}
#else
static int sof_probes_ipc4_prints(struct sof_client_dev *cdev, char *buf, size_t size,
struct sof_probe_point_desc *desc)
{
return -ENODEV;
}
#endif

static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
size_t count, loff_t *ppos)
{
Expand Down Expand Up @@ -223,9 +279,13 @@ static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
for (i = 0; i < num_desc; i++) {
offset = strlen(buf);
remaining = PAGE_SIZE - offset;
ret = snprintf(buf + offset, remaining,
"Id: %#010x Purpose: %u Node id: %#x\n",
desc[i].buffer_id, desc[i].purpose, desc[i].stream_tag);
if (sof_client_get_ipc_type(cdev) == SOF_IPC_TYPE_4)
ret = sof_probes_ipc4_prints(cdev, buf + offset, remaining, &desc[i]);
else
ret = snprintf(buf + offset, remaining,
"Id: %#010x Purpose: %u Node id: %#x\n",
desc[i].buffer_id, desc[i].purpose, desc[i].stream_tag);

if (ret < 0 || ret >= remaining) {
/* truncate the output buffer at the last full line */
buf[offset] = '\0';
Expand Down
14 changes: 14 additions & 0 deletions sound/soc/sof/sof-client-probes.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ struct sof_probe_point_desc {
unsigned int stream_tag;
} __packed;

#define SOF_IPC4_PROBE_TYPE_SHIFT 24
#define SOF_IPC4_PROBE_TYPE_MASK GENMASK(25, 24)
#define SOF_IPC4_PROBE_TYPE_GET(x) (((x) & SOF_IPC4_PROBE_TYPE_MASK) \
>> SOF_IPC4_PROBE_TYPE_SHIFT)

#define PROBE_TYPE_INPUT 0
#define PROBE_TYPE_OUTPUT 1
#define PROBE_TYPE_INTERNAL 2

#define SOF_IPC4_PROBE_IDX_SHIFT 26
#define SOF_IPC4_PROBE_IDX_MASK GENMASK(31, 26)
#define SOF_IPC4_PROBE_IDX_GET(x) (((x) & SOF_IPC4_PROBE_IDX_MASK) \
>> SOF_IPC4_PROBE_IDX_SHIFT)

struct sof_probes_ipc_ops {
int (*init)(struct sof_client_dev *cdev, u32 stream_tag,
size_t buffer_size);
Expand Down

0 comments on commit b822f74

Please sign in to comment.