sof-client.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef __SOC_SOF_CLIENT_H
  3. #define __SOC_SOF_CLIENT_H
  4. #include <linux/auxiliary_bus.h>
  5. #include <linux/device.h>
  6. #include <linux/list.h>
  7. #include <sound/sof.h>
  8. struct sof_ipc_fw_version;
  9. struct sof_ipc_cmd_hdr;
  10. struct snd_sof_dev;
  11. struct dentry;
  12. struct sof_ipc4_fw_module;
  13. /**
  14. * struct sof_client_dev - SOF client device
  15. * @auxdev: auxiliary device
  16. * @sdev: pointer to SOF core device struct
  17. * @list: item in SOF core client dev list
  18. * @data: device specific data
  19. */
  20. struct sof_client_dev {
  21. struct auxiliary_device auxdev;
  22. struct snd_sof_dev *sdev;
  23. struct list_head list;
  24. void *data;
  25. };
  26. #define sof_client_dev_to_sof_dev(cdev) ((cdev)->sdev)
  27. #define auxiliary_dev_to_sof_client_dev(auxiliary_dev) \
  28. container_of(auxiliary_dev, struct sof_client_dev, auxdev)
  29. #define dev_to_sof_client_dev(dev) \
  30. container_of(to_auxiliary_dev(dev), struct sof_client_dev, auxdev)
  31. int sof_client_ipc_tx_message(struct sof_client_dev *cdev, void *ipc_msg,
  32. void *reply_data, size_t reply_bytes);
  33. static inline int sof_client_ipc_tx_message_no_reply(struct sof_client_dev *cdev, void *ipc_msg)
  34. {
  35. return sof_client_ipc_tx_message(cdev, ipc_msg, NULL, 0);
  36. }
  37. int sof_client_ipc_set_get_data(struct sof_client_dev *cdev, void *ipc_msg,
  38. bool set);
  39. struct sof_ipc4_fw_module *sof_client_ipc4_find_module(struct sof_client_dev *c, const guid_t *u);
  40. struct dentry *sof_client_get_debugfs_root(struct sof_client_dev *cdev);
  41. struct device *sof_client_get_dma_dev(struct sof_client_dev *cdev);
  42. const struct sof_ipc_fw_version *sof_client_get_fw_version(struct sof_client_dev *cdev);
  43. size_t sof_client_get_ipc_max_payload_size(struct sof_client_dev *cdev);
  44. enum sof_ipc_type sof_client_get_ipc_type(struct sof_client_dev *cdev);
  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. /* IPC notification */
  49. typedef void (*sof_client_event_callback)(struct sof_client_dev *cdev, void *msg_buf);
  50. int sof_client_register_ipc_rx_handler(struct sof_client_dev *cdev,
  51. u32 ipc_msg_type,
  52. sof_client_event_callback callback);
  53. void sof_client_unregister_ipc_rx_handler(struct sof_client_dev *cdev,
  54. u32 ipc_msg_type);
  55. /* DSP state notification and query */
  56. typedef void (*sof_client_fw_state_callback)(struct sof_client_dev *cdev,
  57. enum sof_fw_state state);
  58. int sof_client_register_fw_state_handler(struct sof_client_dev *cdev,
  59. sof_client_fw_state_callback callback);
  60. void sof_client_unregister_fw_state_handler(struct sof_client_dev *cdev);
  61. enum sof_fw_state sof_client_get_fw_state(struct sof_client_dev *cdev);
  62. int sof_client_ipc_rx_message(struct sof_client_dev *cdev, void *ipc_msg, void *msg_buf);
  63. #endif /* __SOC_SOF_CLIENT_H */