Skip to content

Commit 37dcc59

Browse files
author
Jyri Sarha
committed
ASoC: SOF: sof-client-probes-ipc4: Implement ipc4_probes_points_info
Upgrade the struct sof_probes_ipc_ops points_info() method from dummy implementation to a working implementation. The actual functionality requires that the DSP FW supports the IPC request. The support was just recently added. If its not there an IPC failure is reported in the logs. Signed-off-by: Jyri Sarha <[email protected]>
1 parent b6d3bb5 commit 37dcc59

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

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

+47-5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ struct sof_ipc4_probe_point {
5555
u32 stream_tag;
5656
} __packed __aligned(4);
5757

58+
struct sof_ipc4_probe_info {
59+
unsigned int num_elems;
60+
DECLARE_FLEX_ARRAY(struct sof_ipc4_probe_point, points);
61+
} __packed;
62+
5863
#define INVALID_PIPELINE_ID 0xFF
5964

6065
/**
@@ -169,16 +174,53 @@ static int ipc4_probes_deinit(struct sof_client_dev *cdev)
169174
* @desc: Returned list of active probes
170175
* @num_desc: Returned count of active probes
171176
* @return: 0 on success, negative error code on error
172-
*
173-
* Dummy implementation returning empty list of probes.
174177
*/
175178
static int ipc4_probes_points_info(struct sof_client_dev *cdev,
176179
struct sof_probe_point_desc **desc,
177180
size_t *num_desc)
178181
{
179-
/* TODO: Firmware side implementation needed first */
180-
*desc = NULL;
181-
*num_desc = 0;
182+
struct sof_man4_module *mentry = sof_ipc4_probe_get_module_info(cdev);
183+
struct device *dev = &cdev->auxdev.dev;
184+
struct sof_ipc4_probe_info *info;
185+
struct sof_ipc4_msg msg;
186+
int i, ret;
187+
188+
if (!mentry)
189+
return -ENODEV;
190+
191+
msg.primary = mentry->id;
192+
msg.primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST);
193+
msg.primary |= SOF_IPC4_MSG_TARGET(SOF_IPC4_MODULE_MSG);
194+
195+
msg.extension = SOF_IPC4_MOD_EXT_MSG_PARAM_ID(SOF_IPC4_PROBE_POINTS);
196+
197+
msg.data_size = cdev->sdev->ipc->max_payload_size;
198+
msg.data_ptr = kzalloc(msg.data_size, GFP_KERNEL);
199+
if (!msg.data_ptr)
200+
return -ENOMEM;
201+
202+
ret = sof_client_ipc_set_get_data(cdev, &msg, false);
203+
if (ret) {
204+
kfree(msg.data_ptr);
205+
return ret;
206+
}
207+
info = msg.data_ptr;
208+
*num_desc = info->num_elems;
209+
dev_dbg(dev, "%s: got %zu probe points", __func__, *num_desc);
210+
211+
*desc = kzalloc(*num_desc * sizeof(*desc), GFP_KERNEL);
212+
if (!*desc) {
213+
kfree(msg.data_ptr);
214+
return -ENOMEM;
215+
}
216+
217+
for (i = 0; i < *num_desc; i++) {
218+
(*desc)[i].buffer_id = info->points[i].point_id;
219+
(*desc)[i].purpose = info->points[i].purpose;
220+
(*desc)[i].stream_tag = info->points[i].stream_tag;
221+
}
222+
kfree(msg.data_ptr);
223+
182224
return 0;
183225
}
184226

0 commit comments

Comments
 (0)