xref: /linux/sound/soc/sof/sof-client.h (revision 34f7c6e7d4396090692a09789db231e12cb4762b)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef __SOC_SOF_CLIENT_H
4 #define __SOC_SOF_CLIENT_H
5 
6 #include <linux/auxiliary_bus.h>
7 #include <linux/device.h>
8 #include <linux/list.h>
9 #include <sound/sof.h>
10 
11 struct sof_ipc_fw_version;
12 struct sof_ipc_cmd_hdr;
13 struct snd_sof_dev;
14 struct dentry;
15 
16 /**
17  * struct sof_client_dev - SOF client device
18  * @auxdev:	auxiliary device
19  * @sdev:	pointer to SOF core device struct
20  * @list:	item in SOF core client dev list
21  * @data:	device specific data
22  */
23 struct sof_client_dev {
24 	struct auxiliary_device auxdev;
25 	struct snd_sof_dev *sdev;
26 	struct list_head list;
27 	void *data;
28 };
29 
30 #define sof_client_dev_to_sof_dev(cdev)		((cdev)->sdev)
31 
32 #define auxiliary_dev_to_sof_client_dev(auxiliary_dev) \
33 	container_of(auxiliary_dev, struct sof_client_dev, auxdev)
34 
35 #define dev_to_sof_client_dev(dev) \
36 	container_of(to_auxiliary_dev(dev), struct sof_client_dev, auxdev)
37 
38 int sof_client_ipc_tx_message(struct sof_client_dev *cdev, void *ipc_msg,
39 			      void *reply_data, size_t reply_bytes);
40 
41 struct dentry *sof_client_get_debugfs_root(struct sof_client_dev *cdev);
42 struct device *sof_client_get_dma_dev(struct sof_client_dev *cdev);
43 const struct sof_ipc_fw_version *sof_client_get_fw_version(struct sof_client_dev *cdev);
44 
45 /* module refcount management of SOF core */
46 int sof_client_core_module_get(struct sof_client_dev *cdev);
47 void sof_client_core_module_put(struct sof_client_dev *cdev);
48 
49 /* IPC notification */
50 typedef void (*sof_client_event_callback)(struct sof_client_dev *cdev, void *msg_buf);
51 
52 int sof_client_register_ipc_rx_handler(struct sof_client_dev *cdev,
53 				       u32 ipc_msg_type,
54 				       sof_client_event_callback callback);
55 void sof_client_unregister_ipc_rx_handler(struct sof_client_dev *cdev,
56 					  u32 ipc_msg_type);
57 
58 /* DSP state notification and query */
59 typedef void (*sof_client_fw_state_callback)(struct sof_client_dev *cdev,
60 					     enum sof_fw_state state);
61 
62 int sof_client_register_fw_state_handler(struct sof_client_dev *cdev,
63 					 sof_client_fw_state_callback callback);
64 void sof_client_unregister_fw_state_handler(struct sof_client_dev *cdev);
65 enum sof_fw_state sof_client_get_fw_state(struct sof_client_dev *cdev);
66 
67 #endif /* __SOC_SOF_CLIENT_H */
68