Lines Matching +full:is +full:- +full:compress +full:- +full:dai
1 // SPDX-License-Identifier: GPL-2.0-only
3 // Copyright(c) 2019-2022 Intel Corporation
20 #include "sof-client.h"
21 #include "sof-client-probes.h"
34 struct snd_soc_dai *dai) in sof_probes_compr_startup() argument
36 struct snd_soc_card *card = snd_soc_component_get_drvdata(dai->component); in sof_probes_compr_startup()
38 struct sof_probes_priv *priv = cdev->data; in sof_probes_compr_startup()
39 const struct sof_probes_host_ops *ops = priv->host_ops; in sof_probes_compr_startup()
43 return -ENODEV; in sof_probes_compr_startup()
49 ret = ops->startup(cdev, cstream, dai, &priv->extractor_stream_tag); in sof_probes_compr_startup()
51 dev_err(dai->dev, "Failed to startup probe stream: %d\n", ret); in sof_probes_compr_startup()
52 priv->extractor_stream_tag = SOF_PROBES_INVALID_NODE_ID; in sof_probes_compr_startup()
60 struct snd_soc_dai *dai) in sof_probes_compr_shutdown() argument
62 struct snd_soc_card *card = snd_soc_component_get_drvdata(dai->component); in sof_probes_compr_shutdown()
64 struct sof_probes_priv *priv = cdev->data; in sof_probes_compr_shutdown()
65 const struct sof_probes_host_ops *ops = priv->host_ops; in sof_probes_compr_shutdown()
66 const struct sof_probes_ipc_ops *ipc = priv->ipc_ops; in sof_probes_compr_shutdown()
72 ret = ipc->points_info(cdev, &desc, &num_desc); in sof_probes_compr_shutdown()
74 dev_err(dai->dev, "Failed to get probe points: %d\n", ret); in sof_probes_compr_shutdown()
79 ipc->points_remove(cdev, &desc[i].buffer_id, 1); in sof_probes_compr_shutdown()
83 ret = ipc->deinit(cdev); in sof_probes_compr_shutdown()
85 dev_err(dai->dev, "Failed to deinit probe: %d\n", ret); in sof_probes_compr_shutdown()
87 priv->extractor_stream_tag = SOF_PROBES_INVALID_NODE_ID; in sof_probes_compr_shutdown()
90 ret = ops->shutdown(cdev, cstream, dai); in sof_probes_compr_shutdown()
99 struct snd_soc_dai *dai) in sof_probes_compr_set_params() argument
101 struct snd_soc_card *card = snd_soc_component_get_drvdata(dai->component); in sof_probes_compr_set_params()
103 struct snd_compr_runtime *rtd = cstream->runtime; in sof_probes_compr_set_params()
104 struct sof_probes_priv *priv = cdev->data; in sof_probes_compr_set_params()
105 const struct sof_probes_host_ops *ops = priv->host_ops; in sof_probes_compr_set_params()
106 const struct sof_probes_ipc_ops *ipc = priv->ipc_ops; in sof_probes_compr_set_params()
109 cstream->dma_buffer.dev.type = SNDRV_DMA_TYPE_DEV_SG; in sof_probes_compr_set_params()
110 cstream->dma_buffer.dev.dev = sof_client_get_dma_dev(cdev); in sof_probes_compr_set_params()
111 ret = snd_compr_malloc_pages(cstream, rtd->buffer_size); in sof_probes_compr_set_params()
115 ret = ops->set_params(cdev, cstream, params, dai); in sof_probes_compr_set_params()
119 ret = ipc->init(cdev, priv->extractor_stream_tag, rtd->dma_bytes); in sof_probes_compr_set_params()
121 dev_err(dai->dev, "Failed to init probe: %d\n", ret); in sof_probes_compr_set_params()
129 struct snd_soc_dai *dai) in sof_probes_compr_trigger() argument
131 struct snd_soc_card *card = snd_soc_component_get_drvdata(dai->component); in sof_probes_compr_trigger()
133 struct sof_probes_priv *priv = cdev->data; in sof_probes_compr_trigger()
134 const struct sof_probes_host_ops *ops = priv->host_ops; in sof_probes_compr_trigger()
136 return ops->trigger(cdev, cstream, cmd, dai); in sof_probes_compr_trigger()
141 struct snd_soc_dai *dai) in sof_probes_compr_pointer() argument
143 struct snd_soc_card *card = snd_soc_component_get_drvdata(dai->component); in sof_probes_compr_pointer()
145 struct sof_probes_priv *priv = cdev->data; in sof_probes_compr_pointer()
146 const struct sof_probes_host_ops *ops = priv->host_ops; in sof_probes_compr_pointer()
148 return ops->pointer(cdev, cstream, tstamp, dai); in sof_probes_compr_pointer()
163 struct snd_compr_runtime *rtd = cstream->runtime; in sof_probes_compr_copy()
168 if (count > rtd->buffer_size) in sof_probes_compr_copy()
169 count = rtd->buffer_size; in sof_probes_compr_copy()
171 div_u64_rem(rtd->total_bytes_transferred, rtd->buffer_size, &offset); in sof_probes_compr_copy()
172 ptr = rtd->dma_area + offset; in sof_probes_compr_copy()
173 n = rtd->buffer_size - offset; in sof_probes_compr_copy()
179 ret += copy_to_user(buf + n, rtd->dma_area, count - n); in sof_probes_compr_copy()
183 return count - ret; in sof_probes_compr_copy()
194 struct sof_client_dev *cdev = file->private_data; in sof_probes_dfs_points_read()
195 struct sof_probes_priv *priv = cdev->data; in sof_probes_dfs_points_read()
196 struct device *dev = &cdev->auxdev.dev; in sof_probes_dfs_points_read()
198 const struct sof_probes_ipc_ops *ipc = priv->ipc_ops; in sof_probes_dfs_points_read()
204 if (priv->extractor_stream_tag == SOF_PROBES_INVALID_NODE_ID) { in sof_probes_dfs_points_read()
206 return -ENOENT; in sof_probes_dfs_points_read()
211 return -ENOMEM; in sof_probes_dfs_points_read()
214 if (ret < 0 && ret != -EACCES) { in sof_probes_dfs_points_read()
219 ret = ipc->points_info(cdev, &desc, &num_desc); in sof_probes_dfs_points_read()
225 remaining = PAGE_SIZE - offset; in sof_probes_dfs_points_read()
255 struct sof_client_dev *cdev = file->private_data; in sof_probes_dfs_points_write()
256 struct sof_probes_priv *priv = cdev->data; in sof_probes_dfs_points_write()
257 const struct sof_probes_ipc_ops *ipc = priv->ipc_ops; in sof_probes_dfs_points_write()
258 struct device *dev = &cdev->auxdev.dev; in sof_probes_dfs_points_write()
264 if (priv->extractor_stream_tag == SOF_PROBES_INVALID_NODE_ID) { in sof_probes_dfs_points_write()
266 return -ENOENT; in sof_probes_dfs_points_write()
276 ret = -EINVAL; in sof_probes_dfs_points_write()
283 if (ret < 0 && ret != -EACCES) { in sof_probes_dfs_points_write()
288 ret = ipc->points_add(cdev, desc, bytes / sizeof(*desc)); in sof_probes_dfs_points_write()
314 struct sof_client_dev *cdev = file->private_data; in sof_probes_dfs_points_remove_write()
315 struct sof_probes_priv *priv = cdev->data; in sof_probes_dfs_points_remove_write()
316 const struct sof_probes_ipc_ops *ipc = priv->ipc_ops; in sof_probes_dfs_points_remove_write()
317 struct device *dev = &cdev->auxdev.dev; in sof_probes_dfs_points_remove_write()
321 if (priv->extractor_stream_tag == SOF_PROBES_INVALID_NODE_ID) { in sof_probes_dfs_points_remove_write()
323 return -ENOENT; in sof_probes_dfs_points_remove_write()
336 ret = ipc->points_remove(cdev, &array[1], array[0]); in sof_probes_dfs_points_remove_write()
363 .name = "Probe Extraction CPU DAI",
378 .name = "sof-probes-component",
389 struct device *dev = &auxdev->dev; in sof_probes_client_probe()
402 /* do not set up the probes support if it is not enabled */ in sof_probes_client_probe()
404 return -ENXIO; in sof_probes_client_probe()
409 return -ENODEV; in sof_probes_client_probe()
411 if (!ops->startup || !ops->shutdown || !ops->set_params || !ops->trigger || in sof_probes_client_probe()
412 !ops->pointer) { in sof_probes_client_probe()
414 return -ENODEV; in sof_probes_client_probe()
419 return -ENOMEM; in sof_probes_client_probe()
421 priv->host_ops = ops; in sof_probes_client_probe()
426 priv->ipc_ops = &ipc4_probe_ops; in sof_probes_client_probe()
431 priv->ipc_ops = &ipc3_probe_ops; in sof_probes_client_probe()
436 return -ENODEV; in sof_probes_client_probe()
439 cdev->data = priv; in sof_probes_client_probe()
441 /* register probes component driver and dai */ in sof_probes_client_probe()
446 dev_err(dev, "failed to register SOF probes DAI driver %d\n", ret); in sof_probes_client_probe()
451 priv->extractor_stream_tag = SOF_PROBES_INVALID_NODE_ID; in sof_probes_client_probe()
453 /* create read-write probes_points debugfs entry */ in sof_probes_client_probe()
454 priv->dfs_points = debugfs_create_file("probe_points", 0644, dfsroot, in sof_probes_client_probe()
457 /* create read-write probe_points_remove debugfs entry */ in sof_probes_client_probe()
458 priv->dfs_points_remove = debugfs_create_file("probe_points_remove", 0644, in sof_probes_client_probe()
465 debugfs_remove(priv->dfs_points); in sof_probes_client_probe()
466 debugfs_remove(priv->dfs_points_remove); in sof_probes_client_probe()
467 return -ENOMEM; in sof_probes_client_probe()
470 /* extraction DAI link */ in sof_probes_client_probe()
471 links[0].name = "Compress Probe Capture"; in sof_probes_client_probe()
475 links[0].cpus->dai_name = "Probe Extraction CPU DAI"; in sof_probes_client_probe()
482 card = &priv->card; in sof_probes_client_probe()
484 card->dev = dev; in sof_probes_client_probe()
485 card->name = "sof-probes"; in sof_probes_client_probe()
486 card->owner = THIS_MODULE; in sof_probes_client_probe()
487 card->num_links = SOF_PROBES_NUM_DAI_LINKS; in sof_probes_client_probe()
488 card->dai_link = links; in sof_probes_client_probe()
490 /* set idle_bias_off to prevent the core from resuming the card->dev */ in sof_probes_client_probe()
491 card->dapm.idle_bias_off = true; in sof_probes_client_probe()
497 debugfs_remove(priv->dfs_points); in sof_probes_client_probe()
498 debugfs_remove(priv->dfs_points_remove); in sof_probes_client_probe()
516 struct sof_probes_priv *priv = cdev->data; in sof_probes_client_remove()
521 pm_runtime_disable(&auxdev->dev); in sof_probes_client_remove()
522 debugfs_remove(priv->dfs_points); in sof_probes_client_remove()
523 debugfs_remove(priv->dfs_points_remove); in sof_probes_client_remove()
527 { .name = "snd_sof.hda-probes", },
528 { .name = "snd_sof.acp-probes", },