|
17 | 17 |
|
18 | 18 | #include <sound/soc.h>
|
19 | 19 | #include <sound/sof/header.h>
|
| 20 | +#include <sound/sof/ipc4/header.h> |
20 | 21 | #include "sof-client.h"
|
21 | 22 | #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 |
22 | 28 |
|
23 | 29 | #define SOF_PROBES_SUSPEND_DELAY_MS 3000
|
24 | 30 | /* only extraction supported for now */
|
@@ -188,6 +194,56 @@ static const struct snd_compress_ops sof_probes_compressed_ops = {
|
188 | 194 | .copy = sof_probes_compr_copy,
|
189 | 195 | };
|
190 | 196 |
|
| 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 | + |
191 | 247 | static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
|
192 | 248 | size_t count, loff_t *ppos)
|
193 | 249 | {
|
@@ -223,9 +279,13 @@ static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
|
223 | 279 | for (i = 0; i < num_desc; i++) {
|
224 | 280 | offset = strlen(buf);
|
225 | 281 | 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 | + |
229 | 289 | if (ret < 0 || ret >= remaining) {
|
230 | 290 | /* truncate the output buffer at the last full line */
|
231 | 291 | buf[offset] = '\0';
|
|
0 commit comments