sof-client.h 2.8 KB

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