Skip to content

Commit 845c02b

Browse files
author
Jyri Sarha
committed
ASoC: SOF: sof-client-probes: Add available points_info(), IPC4 only
Add another debugfs file, "probe_points_available", that shows all the available probe points in the SOF FW at the time of query. The probe points are there only when an active SOF stream exists in the system. However, the stream identifiers are persistent in the sense that the same probe point identifiers always appear with the same playback or capture command in the same system configuration. The output, when reading "probe_points_available", may look like this: 0x1000005,0x0,0x100 host-copier.0.playback output buf idx 0 (connected) 0x7,0x0,0x100 gain.1.1 input buf idx 0 (connected) 0x1000007,0x0,0x0 gain.1.1 output buf idx 0 0x3,0x0,0x0 mixin.1.1 input buf idx 0 0x1000003,0x0,0x0 mixin.1.1 output buf idx 0 0x4,0x0,0x0 mixout.2.1 input buf idx 0 0x1000004,0x0,0x0 mixout.2.1 output buf idx 0 0x10007,0x0,0x0 gain.2.1 input buf idx 0 0x1010007,0x0,0x0 gain.2.1 output buf idx 0 0x11,0x0,0x0 smart_amp.2.1 input buf idx 0 0x1000011,0x0,0x0 smart_amp.2.1 output buf idx 0 0x10005,0x0,0x0 dai-copier.SSP.NoCodec-0.playback input buf idx 0 The triplet at the beginning of a line can be copy-pasted as such to "probe_points" debugfs file for adding a probe point. The rest of the line tries to give human readable explanation of what this probe point is. Signed-off-by: Jyri Sarha <[email protected]>
1 parent 065622a commit 845c02b

4 files changed

+84
-18
lines changed

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

+18-7
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ static int ipc3_probes_deinit(struct sof_client_dev *cdev)
100100
}
101101

102102
static int ipc3_probes_info(struct sof_client_dev *cdev, unsigned int cmd,
103-
void **params, size_t *num_params)
103+
void **params, size_t *num_params,
104+
enum sof_probe_info_type type)
104105
{
105106
size_t max_msg_size = sof_client_get_ipc_max_payload_size(cdev);
107+
struct device *dev = &cdev->auxdev.dev;
106108
struct sof_ipc_probe_info_params msg = {{{0}}};
107109
struct sof_ipc_probe_info_params *reply;
108110
size_t bytes;
@@ -111,6 +113,11 @@ static int ipc3_probes_info(struct sof_client_dev *cdev, unsigned int cmd,
111113
*params = NULL;
112114
*num_params = 0;
113115

116+
if (type != PROBES_INFO_ACTIVE_PROBES) {
117+
dev_err(dev, "%s: info type %u not supported", __func__, type);
118+
return -EOPNOTSUPP;
119+
}
120+
114121
reply = kzalloc(max_msg_size, GFP_KERNEL);
115122
if (!reply)
116123
return -ENOMEM;
@@ -142,21 +149,25 @@ static int ipc3_probes_info(struct sof_client_dev *cdev, unsigned int cmd,
142149
}
143150

144151
/**
145-
* ipc3_probes_points_info - retrieve list of active probe points
152+
* ipc3_probes_points_info - retrieve list of probe points
146153
* @cdev: SOF client device
147154
* @desc: Returned list of active probes
148155
* @num_desc: Returned count of active probes
156+
* @type: Either PROBES_INFO_ACTIVE_PROBES or PROBES_INFO_AVAILABE_PROBES
157+
*
158+
* If type is PROBES_INFO_ACTIVE_PROBES, host sends PROBE_POINT_INFO
159+
* request to obtain list of active probe points, valid for
160+
* disconnection when given probe is no longer required.
149161
*
150-
* Host sends PROBE_POINT_INFO request to obtain list of active probe
151-
* points, valid for disconnection when given probe is no longer
152-
* required.
162+
* Type PROBES_INFO_AVAILABE_PROBES is not yet supported.
153163
*/
154164
static int ipc3_probes_points_info(struct sof_client_dev *cdev,
155165
struct sof_probe_point_desc **desc,
156-
size_t *num_desc)
166+
size_t *num_desc,
167+
enum sof_probe_info_type type)
157168
{
158169
return ipc3_probes_info(cdev, SOF_IPC_PROBE_POINT_INFO,
159-
(void **)desc, num_desc);
170+
(void **)desc, num_desc, type);
160171
}
161172

162173
/**

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

+24-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ enum sof_ipc4_probe_runtime_param {
2929
SOF_IPC4_PROBE_INJECTION_DMA_DETACH,
3030
SOF_IPC4_PROBE_POINTS,
3131
SOF_IPC4_PROBE_POINTS_DISCONNECT,
32+
SOF_IPC4_PROBE_POINTS_AVAILABLE,
3233
};
3334

3435
struct sof_ipc4_probe_gtw_cfg {
@@ -193,30 +194,49 @@ static int ipc4_probes_deinit(struct sof_client_dev *cdev)
193194
}
194195

195196
/**
196-
* ipc4_probes_points_info - retrieve list of active probe points
197+
* ipc4_probes_points_info - retrieve list of probe points
197198
* @cdev: SOF client device
198199
* @desc: Returned list of active probes
199200
* @num_desc: Returned count of active probes
201+
* @type: Either PROBES_INFO_ACTIVE_PROBES or PROBES_INFO_AVAILABE_PROBES
200202
* @return: 0 on success, negative error code on error
203+
*
204+
* Returns list if active probe points if type is
205+
* PROBES_INFO_ACTIVE_PROBES, or list of all available probe points if
206+
* type is PROBES_INFO_AVAILABE_PROBES.
201207
*/
202208
static int ipc4_probes_points_info(struct sof_client_dev *cdev,
203209
struct sof_probe_point_desc **desc,
204-
size_t *num_desc)
210+
size_t *num_desc,
211+
enum sof_probe_info_type type)
205212
{
206213
struct sof_man4_module *mentry = sof_ipc4_probe_get_module_info(cdev);
207214
struct device *dev = &cdev->auxdev.dev;
208215
struct sof_ipc4_probe_info *info;
209216
struct sof_ipc4_msg msg;
217+
u32 param_id;
210218
int i, ret;
211219

212220
if (!mentry)
213221
return -ENODEV;
214222

223+
switch (type) {
224+
case PROBES_INFO_ACTIVE_PROBES:
225+
param_id = SOF_IPC4_PROBE_POINTS;
226+
break;
227+
case PROBES_INFO_AVAILABE_PROBES:
228+
param_id = SOF_IPC4_PROBE_POINTS_AVAILABLE;
229+
break;
230+
default:
231+
dev_err(dev, "%s: info type %u not supported", __func__, type);
232+
return -EOPNOTSUPP;
233+
};
234+
215235
msg.primary = mentry->id;
216236
msg.primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST);
217237
msg.primary |= SOF_IPC4_MSG_TARGET(SOF_IPC4_MODULE_MSG);
218238

219-
msg.extension = SOF_IPC4_MOD_EXT_MSG_PARAM_ID(SOF_IPC4_PROBE_POINTS);
239+
msg.extension = SOF_IPC4_MOD_EXT_MSG_PARAM_ID(param_id);
220240

221241
msg.data_size = cdev->sdev->ipc->max_payload_size;
222242
msg.data_ptr = kzalloc(msg.data_size, GFP_KERNEL);
@@ -300,7 +320,7 @@ static int ipc4_probes_points_add(struct sof_client_dev *cdev,
300320
int i, ret;
301321

302322
if (!mentry)
303-
return -ENODEV;
323+
return -EOPNOTSUPP;
304324

305325
/* The sof_probe_point_desc and sof_ipc4_probe_point structs
306326
* are of same size and even the integers are the same in the

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

+36-6
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ static int sof_probes_compr_shutdown(struct snd_compr_stream *cstream,
7575
int i, ret;
7676

7777
/* disconnect all probe points */
78-
ret = ipc->points_info(cdev, &desc, &num_desc);
78+
ret = ipc->points_info(cdev, &desc, &num_desc,
79+
PROBES_INFO_ACTIVE_PROBES);
7980
if (ret < 0) {
8081
dev_err(dai->dev, "Failed to get probe points: %d\n", ret);
8182
goto exit;
@@ -195,7 +196,8 @@ static const struct snd_compress_ops sof_probes_compressed_ops = {
195196
};
196197

197198
static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
198-
size_t count, loff_t *ppos)
199+
size_t count, loff_t *ppos,
200+
enum sof_probe_info_type type)
199201
{
200202
struct sof_client_dev *cdev = file->private_data;
201203
struct sof_probes_priv *priv = cdev->data;
@@ -222,7 +224,7 @@ static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
222224
goto exit;
223225
}
224226

225-
ret = ipc->points_info(cdev, &desc, &num_desc);
227+
ret = ipc->points_info(cdev, &desc, &num_desc, type);
226228
if (ret < 0)
227229
goto pm_error;
228230

@@ -258,6 +260,22 @@ static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
258260
return ret;
259261
}
260262

263+
static ssize_t sof_probes_dfs_active_points_read(struct file *file,
264+
char __user *to,
265+
size_t count, loff_t *ppos)
266+
{
267+
return sof_probes_dfs_points_read(file, to, count, ppos,
268+
PROBES_INFO_ACTIVE_PROBES);
269+
}
270+
271+
static ssize_t sof_probes_dfs_available_points_read(struct file *file,
272+
char __user *to,
273+
size_t count, loff_t *ppos)
274+
{
275+
return sof_probes_dfs_points_read(file, to, count, ppos,
276+
PROBES_INFO_AVAILABE_PROBES);
277+
}
278+
261279
static ssize_t
262280
sof_probes_dfs_points_write(struct file *file, const char __user *from,
263281
size_t count, loff_t *ppos)
@@ -308,15 +326,23 @@ sof_probes_dfs_points_write(struct file *file, const char __user *from,
308326
return ret;
309327
}
310328

311-
static const struct file_operations sof_probes_points_fops = {
329+
static const struct file_operations sof_probes_active_points_fops = {
312330
.open = simple_open,
313-
.read = sof_probes_dfs_points_read,
331+
.read = sof_probes_dfs_active_points_read,
314332
.write = sof_probes_dfs_points_write,
315333
.llseek = default_llseek,
316334

317335
.owner = THIS_MODULE,
318336
};
319337

338+
static const struct file_operations sof_probes_available_points_fops = {
339+
.open = simple_open,
340+
.read = sof_probes_dfs_available_points_read,
341+
.llseek = default_llseek,
342+
343+
.owner = THIS_MODULE,
344+
};
345+
320346
static ssize_t
321347
sof_probes_dfs_points_remove_write(struct file *file, const char __user *from,
322348
size_t count, loff_t *ppos)
@@ -462,13 +488,17 @@ static int sof_probes_client_probe(struct auxiliary_device *auxdev,
462488

463489
/* create read-write probes_points debugfs entry */
464490
priv->dfs_points = debugfs_create_file("probe_points", 0644, dfsroot,
465-
cdev, &sof_probes_points_fops);
491+
cdev, &sof_probes_active_points_fops);
466492

467493
/* create read-write probe_points_remove debugfs entry */
468494
priv->dfs_points_remove = debugfs_create_file("probe_points_remove", 0644,
469495
dfsroot, cdev,
470496
&sof_probes_points_remove_fops);
471497

498+
/* create read-write probes_points debugfs entry */
499+
priv->dfs_points = debugfs_create_file("probe_points_available", 0644, dfsroot,
500+
cdev, &sof_probes_available_points_fops);
501+
472502
links = devm_kcalloc(dev, SOF_PROBES_NUM_DAI_LINKS, sizeof(*links), GFP_KERNEL);
473503
cpus = devm_kcalloc(dev, SOF_PROBES_NUM_DAI_LINKS, sizeof(*cpus), GFP_KERNEL);
474504
if (!links || !cpus) {

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

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

37+
enum sof_probe_info_type {
38+
PROBES_INFO_ACTIVE_PROBES,
39+
PROBES_INFO_AVAILABE_PROBES,
40+
};
41+
3742
struct sof_probes_ipc_ops {
3843
int (*init)(struct sof_client_dev *cdev, u32 stream_tag,
3944
size_t buffer_size);
4045
int (*deinit)(struct sof_client_dev *cdev);
4146
int (*points_info)(struct sof_client_dev *cdev,
4247
struct sof_probe_point_desc **desc,
43-
size_t *num_desc);
48+
size_t *num_desc, enum sof_probe_info_type type);
4449
int (*point_print)(struct sof_client_dev *cdev, char *buf, size_t size,
4550
struct sof_probe_point_desc *desc);
4651
int (*points_add)(struct sof_client_dev *cdev,

0 commit comments

Comments
 (0)