Skip to content

Commit 0576d12

Browse files
ranj063ujfalusi
authored andcommitted
ASoC: SOF: core/ops: Add support for client registration
Add new ops for registering/unregistering clients based on DSP capabilities and/or DT information. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent d03fc53 commit 0576d12

4 files changed

Lines changed: 41 additions & 2 deletions

File tree

sound/soc/sof/core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/module.h>
1313
#include <sound/soc.h>
1414
#include <sound/sof.h>
15+
#include "sof-client.h"
1516
#include "sof-priv.h"
1617
#include "ops.h"
1718
#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_PROBES)
@@ -249,6 +250,12 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
249250
if (plat_data->sof_probe_complete)
250251
plat_data->sof_probe_complete(sdev->dev);
251252

253+
ret = sof_register_clients(sdev);
254+
if (ret < 0) {
255+
dev_err(sdev->dev, "error: failed to register clients %d\n", ret);
256+
goto fw_trace_err;
257+
}
258+
252259
sdev->probe_completed = true;
253260

254261
return 0;
@@ -371,6 +378,7 @@ int snd_sof_device_remove(struct device *dev)
371378
dev_warn(dev, "error: %d failed to prepare DSP for device removal",
372379
ret);
373380

381+
sof_unregister_clients(sdev);
374382
snd_sof_fw_unload(sdev);
375383
snd_sof_ipc_free(sdev);
376384
snd_sof_free_debug(sdev);

sound/soc/sof/sof-client.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/list.h>
1010
#include <linux/mutex.h>
1111
#include <linux/slab.h>
12+
#include "ops.h"
1213
#include "sof-client.h"
1314
#include "sof-priv.h"
1415

@@ -35,6 +36,20 @@ static int sof_client_dev_add_data(struct sof_client_dev *cdev, const void *data
3536
return 0;
3637
}
3738

39+
int sof_register_clients(struct snd_sof_dev *sdev)
40+
{
41+
if (sof_ops(sdev) && sof_ops(sdev)->ipc_register_clients)
42+
return sof_ops(sdev)->ipc_register_clients(sdev);
43+
44+
return 0;
45+
}
46+
47+
void sof_unregister_clients(struct snd_sof_dev *sdev)
48+
{
49+
if (sof_ops(sdev) && sof_ops(sdev)->ipc_unregister_clients)
50+
sof_ops(sdev)->ipc_unregister_clients(sdev);
51+
}
52+
3853
int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name, u32 id,
3954
const void *data, size_t size)
4055
{

sound/soc/sof/sof-client.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ struct device *sof_client_get_dma_dev(struct sof_client_dev *cdev);
3939
int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name, u32 id,
4040
const void *data, size_t size);
4141
void sof_client_dev_unregister(struct snd_sof_dev *sdev, const char *name, u32 id);
42-
#else
42+
43+
int sof_register_clients(struct snd_sof_dev *sdev);
44+
void sof_unregister_clients(struct snd_sof_dev *sdev);
45+
#else /* CONFIG_SND_SOC_SOF_CLIENT */
4346
static inline int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name,
4447
u32 id, const void *data, size_t size)
4548
{
@@ -50,6 +53,15 @@ static inline void sof_client_dev_unregister(struct snd_sof_dev *sdev,
5053
const char *name, u32 id)
5154
{
5255
}
53-
#endif
56+
57+
static inline int sof_register_clients(struct snd_sof_dev *sdev)
58+
{
59+
return 0;
60+
}
61+
62+
static inline void sof_unregister_clients(struct snd_sof_dev *sdev)
63+
{
64+
}
65+
#endif /* CONFIG_SND_SOC_SOF_CLIENT */
5466

5567
#endif /* __SOC_SOF_CLIENT_H */

sound/soc/sof/sof-priv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ struct snd_sof_dsp_ops {
288288
void (*set_mach_params)(const struct snd_soc_acpi_mach *mach,
289289
struct snd_sof_dev *sdev); /* optional */
290290

291+
/* IPC client ops */
292+
int (*ipc_register_clients)(struct snd_sof_dev *sdev); /* optional */
293+
void (*ipc_unregister_clients)(struct snd_sof_dev *sdev); /* optional */
294+
291295
/* DAI ops */
292296
struct snd_soc_dai_driver *drv;
293297
int num_drv;

0 commit comments

Comments
 (0)