ipc4-priv.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
  2. /*
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * Copyright(c) 2022 Intel Corporation
  7. */
  8. #ifndef __SOUND_SOC_SOF_IPC4_PRIV_H
  9. #define __SOUND_SOC_SOF_IPC4_PRIV_H
  10. #include <linux/idr.h>
  11. #include <sound/sof/ext_manifest4.h>
  12. #include <sound/sof/ipc4/header.h>
  13. #include "sof-priv.h"
  14. /* The DSP window indices are fixed */
  15. #define SOF_IPC4_INBOX_WINDOW_IDX 0
  16. #define SOF_IPC4_OUTBOX_WINDOW_IDX 1
  17. #define SOF_IPC4_DEBUG_WINDOW_IDX 2
  18. enum sof_ipc4_mtrace_type {
  19. SOF_IPC4_MTRACE_NOT_AVAILABLE = 0,
  20. SOF_IPC4_MTRACE_INTEL_CAVS_1_5,
  21. SOF_IPC4_MTRACE_INTEL_CAVS_1_8,
  22. SOF_IPC4_MTRACE_INTEL_CAVS_2,
  23. };
  24. /**
  25. * struct sof_ipc4_fw_module - IPC4 module info
  26. * @sof_man4_module: Module info
  27. * @fw_mod_cfg: Pointer to the module config start of the module
  28. * @m_ida: Module instance identifier
  29. * @private: Module private data
  30. */
  31. struct sof_ipc4_fw_module {
  32. struct sof_man4_module man4_module_entry;
  33. const struct sof_man4_module_config *fw_mod_cfg;
  34. struct ida m_ida;
  35. void *private;
  36. };
  37. /**
  38. * struct sof_ipc4_fw_library - IPC4 library information
  39. * @sof_fw: SOF Firmware of the library
  40. * @id: Library ID. 0 is reserved for basefw, external libraries must have unique
  41. * ID number between 1 and (sof_ipc4_fw_data.max_libs_count - 1)
  42. * Note: sof_ipc4_fw_data.max_libs_count == 1 implies that external libraries
  43. * are not supported
  44. * @num_modules : Number of FW modules in the library
  45. * @modules: Array of FW modules
  46. */
  47. struct sof_ipc4_fw_library {
  48. struct sof_firmware sof_fw;
  49. const char *name;
  50. u32 id;
  51. int num_modules;
  52. struct sof_ipc4_fw_module *modules;
  53. };
  54. /**
  55. * struct sof_ipc4_fw_data - IPC4-specific data
  56. * @manifest_fw_hdr_offset: FW header offset in the manifest
  57. * @fw_lib_xa: XArray for firmware libraries, including basefw (ID = 0)
  58. * Used to store the FW libraries and to manage the unique IDs of the
  59. * libraries.
  60. * @nhlt: NHLT table either from the BIOS or the topology manifest
  61. * @mtrace_type: mtrace type supported on the booted platform
  62. * @mtrace_log_bytes: log bytes as reported by the firmware via fw_config reply
  63. * @num_playback_streams: max number of playback DMAs, needed for CHAIN_DMA offset
  64. * @num_capture_streams: max number of capture DMAs
  65. * @max_num_pipelines: max number of pipelines
  66. * @max_libs_count: Maximum number of libraries support by the FW including the
  67. * base firmware
  68. * @fw_context_save: Firmware supports full context save and restore
  69. * @libraries_restored: The libraries have been retained during firmware boot
  70. *
  71. * @load_library: Callback function for platform dependent library loading
  72. * @pipeline_state_mutex: Mutex to protect pipeline triggers, ref counts, states and deletion
  73. */
  74. struct sof_ipc4_fw_data {
  75. u32 manifest_fw_hdr_offset;
  76. struct xarray fw_lib_xa;
  77. void *nhlt;
  78. enum sof_ipc4_mtrace_type mtrace_type;
  79. u32 mtrace_log_bytes;
  80. int num_playback_streams;
  81. int num_capture_streams;
  82. int max_num_pipelines;
  83. u32 max_libs_count;
  84. bool fw_context_save;
  85. bool libraries_restored;
  86. int (*load_library)(struct snd_sof_dev *sdev,
  87. struct sof_ipc4_fw_library *fw_lib, bool reload);
  88. void (*intel_configure_mic_privacy)(struct snd_sof_dev *sdev,
  89. struct sof_ipc4_intel_mic_privacy_cap *caps);
  90. struct mutex pipeline_state_mutex; /* protect pipeline triggers, ref counts and states */
  91. };
  92. extern const struct sof_ipc_fw_loader_ops ipc4_loader_ops;
  93. extern const struct sof_ipc_tplg_ops ipc4_tplg_ops;
  94. extern const struct sof_ipc_tplg_control_ops tplg_ipc4_control_ops;
  95. extern const struct sof_ipc_pcm_ops ipc4_pcm_ops;
  96. extern const struct sof_ipc_fw_tracing_ops ipc4_mtrace_ops;
  97. int sof_ipc4_set_pipeline_state(struct snd_sof_dev *sdev, u32 instance_id, u32 state);
  98. int sof_ipc4_mtrace_update_pos(struct snd_sof_dev *sdev, int core);
  99. int sof_ipc4_complete_split_release(struct snd_sof_dev *sdev);
  100. int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev);
  101. int sof_ipc4_reload_fw_libraries(struct snd_sof_dev *sdev);
  102. struct sof_ipc4_fw_module *sof_ipc4_find_module_by_uuid(struct snd_sof_dev *sdev,
  103. const guid_t *uuid);
  104. struct snd_sof_widget *sof_ipc4_find_swidget_by_ids(struct snd_sof_dev *sdev,
  105. u32 module_id, int instance_id);
  106. struct sof_ipc4_base_module_cfg;
  107. void sof_ipc4_update_cpc_from_manifest(struct snd_sof_dev *sdev,
  108. struct sof_ipc4_fw_module *fw_module,
  109. struct sof_ipc4_base_module_cfg *basecfg);
  110. size_t sof_ipc4_find_debug_slot_offset_by_type(struct snd_sof_dev *sdev,
  111. u32 slot_type);
  112. void sof_ipc4_mic_privacy_state_change(struct snd_sof_dev *sdev, bool state);
  113. enum sof_ipc4_pipeline_state;
  114. const char *sof_ipc4_pipeline_state_str(enum sof_ipc4_pipeline_state state);
  115. #endif