sof.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. All rights reserved.
  7. *
  8. * Author: Liam Girdwood <[email protected]>
  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_FW_BOOT_PREPARE: preparing for boot (firmware loading for exaqmple)
  21. * @SOF_FW_BOOT_IN_PROGRESS: firmware boot is in progress
  22. * @SOF_FW_BOOT_FAILED: firmware boot failed
  23. * @SOF_FW_BOOT_READY_FAILED: firmware booted but fw_ready op failed
  24. * @SOF_FW_BOOT_READY_OK: firmware booted and fw_ready op passed
  25. * @SOF_FW_BOOT_COMPLETE: firmware is booted up and functional
  26. * @SOF_FW_CRASHED: firmware crashed after successful boot
  27. */
  28. enum sof_fw_state {
  29. SOF_FW_BOOT_NOT_STARTED = 0,
  30. SOF_FW_BOOT_PREPARE,
  31. SOF_FW_BOOT_IN_PROGRESS,
  32. SOF_FW_BOOT_FAILED,
  33. SOF_FW_BOOT_READY_FAILED,
  34. SOF_FW_BOOT_READY_OK,
  35. SOF_FW_BOOT_COMPLETE,
  36. SOF_FW_CRASHED,
  37. };
  38. /* DSP power states */
  39. enum sof_dsp_power_states {
  40. SOF_DSP_PM_D0,
  41. SOF_DSP_PM_D1,
  42. SOF_DSP_PM_D2,
  43. SOF_DSP_PM_D3,
  44. };
  45. /* Definitions for multiple IPCs */
  46. enum sof_ipc_type {
  47. SOF_IPC,
  48. SOF_INTEL_IPC4,
  49. SOF_IPC_TYPE_COUNT
  50. };
  51. /*
  52. * SOF Platform data.
  53. */
  54. struct snd_sof_pdata {
  55. const struct firmware *fw;
  56. const char *name;
  57. const char *platform;
  58. /*
  59. * PCI SSID. As PCI does not define 0 as invalid, the subsystem_id_set
  60. * flag indicates that a value has been written to these members.
  61. */
  62. unsigned short subsystem_vendor;
  63. unsigned short subsystem_device;
  64. bool subsystem_id_set;
  65. struct device *dev;
  66. /* indicate how many first bytes shouldn't be loaded into DSP memory. */
  67. size_t fw_offset;
  68. /*
  69. * notification callback used if the hardware initialization
  70. * can take time or is handled in a workqueue. This callback
  71. * can be used by the caller to e.g. enable runtime_pm
  72. * or limit functionality until all low-level inits are
  73. * complete.
  74. */
  75. void (*sof_probe_complete)(struct device *dev);
  76. /* descriptor */
  77. const struct sof_dev_desc *desc;
  78. /* firmware and topology filenames */
  79. const char *fw_filename_prefix;
  80. const char *fw_filename;
  81. const char *tplg_filename_prefix;
  82. const char *tplg_filename;
  83. /* machine */
  84. struct platform_device *pdev_mach;
  85. const struct snd_soc_acpi_mach *machine;
  86. const struct snd_sof_of_mach *of_machine;
  87. void *hw_pdata;
  88. enum sof_ipc_type ipc_type;
  89. };
  90. /*
  91. * Descriptor used for setting up SOF platform data. This is used when
  92. * ACPI/PCI data is missing or mapped differently.
  93. */
  94. struct sof_dev_desc {
  95. /* list of machines using this configuration */
  96. struct snd_soc_acpi_mach *machines;
  97. struct snd_sof_of_mach *of_machines;
  98. /* alternate list of machines using this configuration */
  99. struct snd_soc_acpi_mach *alt_machines;
  100. bool use_acpi_target_states;
  101. /* Platform resource indexes in BAR / ACPI resources. */
  102. /* Must set to -1 if not used - add new items to end */
  103. int resindex_lpe_base;
  104. int resindex_pcicfg_base;
  105. int resindex_imr_base;
  106. int irqindex_host_ipc;
  107. /* IPC timeouts in ms */
  108. int ipc_timeout;
  109. int boot_timeout;
  110. /* chip information for dsp */
  111. const void *chip_info;
  112. /* defaults for no codec mode */
  113. const char *nocodec_tplg_filename;
  114. /* information on supported IPCs */
  115. unsigned int ipc_supported_mask;
  116. enum sof_ipc_type ipc_default;
  117. /* defaults paths for firmware and topology files */
  118. const char *default_fw_path[SOF_IPC_TYPE_COUNT];
  119. const char *default_tplg_path[SOF_IPC_TYPE_COUNT];
  120. /* default firmware name */
  121. const char *default_fw_filename[SOF_IPC_TYPE_COUNT];
  122. struct snd_sof_dsp_ops *ops;
  123. int (*ops_init)(struct snd_sof_dev *sdev);
  124. void (*ops_free)(struct snd_sof_dev *sdev);
  125. };
  126. int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
  127. int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
  128. #endif