sof.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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) 2018 Intel Corporation
  7. *
  8. * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
  9. */
  10. #ifndef __INCLUDE_SOUND_SOF_H
  11. #define __INCLUDE_SOUND_SOF_H
  12. #include <linux/pci.h>
  13. #include <sound/soc.h>
  14. #include <sound/soc-acpi.h>
  15. struct snd_sof_dsp_ops;
  16. struct snd_sof_dev;
  17. /**
  18. * enum sof_fw_state - DSP firmware state definitions
  19. * @SOF_FW_BOOT_NOT_STARTED: firmware boot is not yet started
  20. * @SOF_DSPLESS_MODE: DSP is not used
  21. * @SOF_FW_BOOT_PREPARE: preparing for boot (firmware loading for exaqmple)
  22. * @SOF_FW_BOOT_IN_PROGRESS: firmware boot is in progress
  23. * @SOF_FW_BOOT_FAILED: firmware boot failed
  24. * @SOF_FW_BOOT_READY_FAILED: firmware booted but fw_ready op failed
  25. * @SOF_FW_BOOT_READY_OK: firmware booted and fw_ready op passed
  26. * @SOF_FW_BOOT_COMPLETE: firmware is booted up and functional
  27. * @SOF_FW_CRASHED: firmware crashed after successful boot
  28. */
  29. enum sof_fw_state {
  30. SOF_FW_BOOT_NOT_STARTED = 0,
  31. SOF_DSPLESS_MODE,
  32. SOF_FW_BOOT_PREPARE,
  33. SOF_FW_BOOT_IN_PROGRESS,
  34. SOF_FW_BOOT_FAILED,
  35. SOF_FW_BOOT_READY_FAILED,
  36. SOF_FW_BOOT_READY_OK,
  37. SOF_FW_BOOT_COMPLETE,
  38. SOF_FW_CRASHED,
  39. };
  40. /* DSP power states */
  41. enum sof_dsp_power_states {
  42. SOF_DSP_PM_D0,
  43. SOF_DSP_PM_D1,
  44. SOF_DSP_PM_D2,
  45. SOF_DSP_PM_D3,
  46. };
  47. /* Definitions for multiple IPCs */
  48. enum sof_ipc_type {
  49. SOF_IPC_TYPE_3,
  50. SOF_IPC_TYPE_4,
  51. SOF_IPC_TYPE_COUNT
  52. };
  53. struct sof_loadable_file_profile {
  54. enum sof_ipc_type ipc_type;
  55. const char *fw_path;
  56. const char *fw_path_postfix;
  57. const char *fw_name;
  58. const char *fw_lib_path;
  59. const char *fw_lib_path_postfix;
  60. const char *tplg_path;
  61. const char *tplg_name;
  62. };
  63. /*
  64. * SOF Platform data.
  65. */
  66. struct snd_sof_pdata {
  67. const char *name;
  68. const char *platform;
  69. /*
  70. * PCI SSID. As PCI does not define 0 as invalid, the subsystem_id_set
  71. * flag indicates that a value has been written to these members.
  72. */
  73. unsigned short subsystem_vendor;
  74. unsigned short subsystem_device;
  75. bool subsystem_id_set;
  76. struct device *dev;
  77. /*
  78. * notification callback used if the hardware initialization
  79. * can take time or is handled in a workqueue. This callback
  80. * can be used by the caller to e.g. enable runtime_pm
  81. * or limit functionality until all low-level inits are
  82. * complete.
  83. */
  84. void (*sof_probe_complete)(struct device *dev);
  85. /* descriptor */
  86. const struct sof_dev_desc *desc;
  87. /* platform's preferred IPC type and path overrides */
  88. struct sof_loadable_file_profile ipc_file_profile_base;
  89. /* firmware and topology filenames */
  90. const char *fw_filename_prefix;
  91. const char *fw_filename;
  92. const char *tplg_filename_prefix;
  93. const char *tplg_filename;
  94. bool disable_function_topology;
  95. /* loadable external libraries available under this directory */
  96. const char *fw_lib_prefix;
  97. /* machine */
  98. struct platform_device *pdev_mach;
  99. const struct snd_soc_acpi_mach *machine;
  100. const struct snd_sof_of_mach *of_machine;
  101. void *hw_pdata;
  102. enum sof_ipc_type ipc_type;
  103. };
  104. /*
  105. * Descriptor used for setting up SOF platform data. This is used when
  106. * ACPI/PCI data is missing or mapped differently.
  107. */
  108. struct sof_dev_desc {
  109. /* list of machines using this configuration */
  110. struct snd_soc_acpi_mach *machines;
  111. struct snd_sof_of_mach *of_machines;
  112. /* alternate list of machines using this configuration */
  113. struct snd_soc_acpi_mach *alt_machines;
  114. bool use_acpi_target_states;
  115. /* Platform resource indexes in BAR / ACPI resources. */
  116. /* Must set to -1 if not used - add new items to end */
  117. int resindex_lpe_base;
  118. int resindex_pcicfg_base;
  119. int resindex_imr_base;
  120. int irqindex_host_ipc;
  121. /* IPC timeouts in ms */
  122. int ipc_timeout;
  123. int boot_timeout;
  124. /* chip information for dsp */
  125. const void *chip_info;
  126. /* defaults for no codec mode */
  127. const char *nocodec_tplg_filename;
  128. /* information on supported IPCs */
  129. unsigned int ipc_supported_mask;
  130. enum sof_ipc_type ipc_default;
  131. /* The platform supports DSPless mode */
  132. bool dspless_mode_supported;
  133. /* On demand DSP booting is possible on the platform */
  134. bool on_demand_dsp_boot;
  135. /* defaults paths for firmware, library and topology files */
  136. const char *default_fw_path[SOF_IPC_TYPE_COUNT];
  137. const char *default_lib_path[SOF_IPC_TYPE_COUNT];
  138. const char *default_tplg_path[SOF_IPC_TYPE_COUNT];
  139. /* default firmware name */
  140. const char *default_fw_filename[SOF_IPC_TYPE_COUNT];
  141. const struct snd_sof_dsp_ops *ops;
  142. int (*ops_init)(struct snd_sof_dev *sdev);
  143. void (*ops_free)(struct snd_sof_dev *sdev);
  144. };
  145. int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
  146. int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
  147. int sof_dai_get_tdm_slots(struct snd_soc_pcm_runtime *rtd);
  148. #endif