projects/linux·blob master · refs

79 lines · 2.8 KiB

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
11struct sof_ipc_fw_version;
12struct sof_ipc_cmd_hdr;
13struct snd_sof_dev;
14struct dentry;
15
16struct sof_ipc4_fw_module;
17
18/**
19 * struct sof_client_dev - SOF client device
20 * @auxdev: auxiliary device
21 * @data: device specific data
22 */
23struct sof_client_dev {
24 struct auxiliary_device auxdev;
25 void *data;
26};
27
28#define auxiliary_dev_to_sof_client_dev(auxiliary_dev) \
29 container_of(auxiliary_dev, struct sof_client_dev, auxdev)
30
31#define dev_to_sof_client_dev(dev) \
32 container_of(to_auxiliary_dev(dev), struct sof_client_dev, auxdev)
33
34int sof_client_ipc_tx_message(struct sof_client_dev *cdev, void *ipc_msg,
35 void *reply_data, size_t reply_bytes);
36static inline int sof_client_ipc_tx_message_no_reply(struct sof_client_dev *cdev, void *ipc_msg)
37{
38 return sof_client_ipc_tx_message(cdev, ipc_msg, NULL, 0);
39}
40int sof_client_ipc_set_get_data(struct sof_client_dev *cdev, void *ipc_msg,
41 bool set);
42
43struct sof_ipc4_fw_module *sof_client_ipc4_find_module(struct sof_client_dev *c, const guid_t *u);
44struct snd_sof_widget *sof_client_ipc4_find_swidget_by_id(struct sof_client_dev *cdev,
45 u32 module_id, int instance_id);
46
47struct dentry *sof_client_get_debugfs_root(struct sof_client_dev *cdev);
48struct device *sof_client_get_dma_dev(struct sof_client_dev *cdev);
49const struct sof_ipc_fw_version *sof_client_get_fw_version(struct sof_client_dev *cdev);
50size_t sof_client_get_ipc_max_payload_size(struct sof_client_dev *cdev);
51enum sof_ipc_type sof_client_get_ipc_type(struct sof_client_dev *cdev);
52
53/* DSP/firmware boot request */
54int sof_client_boot_dsp(struct sof_client_dev *cdev);
55
56/* module refcount management of SOF core */
57int sof_client_core_module_get(struct sof_client_dev *cdev);
58void sof_client_core_module_put(struct sof_client_dev *cdev);
59
60/* IPC notification */
61typedef void (*sof_client_event_callback)(struct sof_client_dev *cdev, void *msg_buf);
62
63int sof_client_register_ipc_rx_handler(struct sof_client_dev *cdev,
64 u32 ipc_msg_type,
65 sof_client_event_callback callback);
66void sof_client_unregister_ipc_rx_handler(struct sof_client_dev *cdev,
67 u32 ipc_msg_type);
68
69/* DSP state notification and query */
70typedef void (*sof_client_fw_state_callback)(struct sof_client_dev *cdev,
71 enum sof_fw_state state);
72
73int sof_client_register_fw_state_handler(struct sof_client_dev *cdev,
74 sof_client_fw_state_callback callback);
75void sof_client_unregister_fw_state_handler(struct sof_client_dev *cdev);
76enum sof_fw_state sof_client_get_fw_state(struct sof_client_dev *cdev);
77int sof_client_ipc_rx_message(struct sof_client_dev *cdev, void *ipc_msg, void *msg_buf);
78
79#endif /* __SOC_SOF_CLIENT_H */