Pierre-Louis Bossart | e149ca2 | 2020-05-01 09:58:50 -0500 | [diff] [blame] | 1 | /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 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 <liam.r.girdwood@linux.intel.com> |
| 9 | */ |
| 10 | |
| 11 | #ifndef __INCLUDE_SOUND_SOF_H |
| 12 | #define __INCLUDE_SOUND_SOF_H |
| 13 | |
| 14 | #include <linux/pci.h> |
Liam Girdwood | 8017b8f | 2019-04-12 11:05:17 -0500 | [diff] [blame] | 15 | #include <sound/soc.h> |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 16 | #include <sound/soc-acpi.h> |
| 17 | |
| 18 | struct snd_sof_dsp_ops; |
Pierre-Louis Bossart | 856601e | 2022-04-14 13:48:10 -0500 | [diff] [blame] | 19 | struct snd_sof_dev; |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 20 | |
Peter Ujfalusi | fc17942 | 2021-12-23 13:36:17 +0200 | [diff] [blame] | 21 | /** |
Peter Ujfalusi | d41607d | 2021-12-23 13:36:18 +0200 | [diff] [blame] | 22 | * enum sof_fw_state - DSP firmware state definitions |
Peter Ujfalusi | fc17942 | 2021-12-23 13:36:17 +0200 | [diff] [blame] | 23 | * @SOF_FW_BOOT_NOT_STARTED: firmware boot is not yet started |
| 24 | * @SOF_FW_BOOT_PREPARE: preparing for boot (firmware loading for exaqmple) |
| 25 | * @SOF_FW_BOOT_IN_PROGRESS: firmware boot is in progress |
| 26 | * @SOF_FW_BOOT_FAILED: firmware boot failed |
| 27 | * @SOF_FW_BOOT_READY_FAILED: firmware booted but fw_ready op failed |
| 28 | * @SOF_FW_BOOT_READY_OK: firmware booted and fw_ready op passed |
| 29 | * @SOF_FW_BOOT_COMPLETE: firmware is booted up and functional |
| 30 | * @SOF_FW_CRASHED: firmware crashed after successful boot |
| 31 | */ |
Peter Ujfalusi | d41607d | 2021-12-23 13:36:18 +0200 | [diff] [blame] | 32 | enum sof_fw_state { |
Peter Ujfalusi | fc17942 | 2021-12-23 13:36:17 +0200 | [diff] [blame] | 33 | SOF_FW_BOOT_NOT_STARTED = 0, |
| 34 | SOF_FW_BOOT_PREPARE, |
| 35 | SOF_FW_BOOT_IN_PROGRESS, |
| 36 | SOF_FW_BOOT_FAILED, |
| 37 | SOF_FW_BOOT_READY_FAILED, |
| 38 | SOF_FW_BOOT_READY_OK, |
| 39 | SOF_FW_BOOT_COMPLETE, |
| 40 | SOF_FW_CRASHED, |
| 41 | }; |
| 42 | |
Peter Ujfalusi | 5fdc124 | 2022-02-10 17:05:18 +0200 | [diff] [blame] | 43 | /* DSP power states */ |
| 44 | enum sof_dsp_power_states { |
| 45 | SOF_DSP_PM_D0, |
| 46 | SOF_DSP_PM_D1, |
| 47 | SOF_DSP_PM_D2, |
| 48 | SOF_DSP_PM_D3, |
| 49 | }; |
| 50 | |
Pierre-Louis Bossart | 15527fe | 2022-04-14 13:48:03 -0500 | [diff] [blame] | 51 | /* Definitions for multiple IPCs */ |
| 52 | enum sof_ipc_type { |
| 53 | SOF_IPC, |
| 54 | SOF_INTEL_IPC4, |
| 55 | SOF_IPC_TYPE_COUNT |
| 56 | }; |
| 57 | |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 58 | /* |
| 59 | * SOF Platform data. |
| 60 | */ |
| 61 | struct snd_sof_pdata { |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 62 | const char *name; |
| 63 | const char *platform; |
| 64 | |
| 65 | struct device *dev; |
| 66 | |
| 67 | /* |
| 68 | * notification callback used if the hardware initialization |
| 69 | * can take time or is handled in a workqueue. This callback |
| 70 | * can be used by the caller to e.g. enable runtime_pm |
| 71 | * or limit functionality until all low-level inits are |
| 72 | * complete. |
| 73 | */ |
| 74 | void (*sof_probe_complete)(struct device *dev); |
| 75 | |
| 76 | /* descriptor */ |
| 77 | const struct sof_dev_desc *desc; |
| 78 | |
| 79 | /* firmware and topology filenames */ |
| 80 | const char *fw_filename_prefix; |
| 81 | const char *fw_filename; |
| 82 | const char *tplg_filename_prefix; |
| 83 | const char *tplg_filename; |
| 84 | |
Peter Ujfalusi | 25bbc0c | 2022-10-20 15:12:30 +0300 | [diff] [blame] | 85 | /* loadable external libraries available under this directory */ |
| 86 | const char *fw_lib_prefix; |
| 87 | |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 88 | /* machine */ |
| 89 | struct platform_device *pdev_mach; |
| 90 | const struct snd_soc_acpi_mach *machine; |
Chunxu Li | 6ace85b | 2022-08-05 15:04:48 +0800 | [diff] [blame] | 91 | const struct snd_sof_of_mach *of_machine; |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 92 | |
| 93 | void *hw_pdata; |
Pierre-Louis Bossart | 15527fe | 2022-04-14 13:48:03 -0500 | [diff] [blame] | 94 | |
| 95 | enum sof_ipc_type ipc_type; |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | /* |
| 99 | * Descriptor used for setting up SOF platform data. This is used when |
| 100 | * ACPI/PCI data is missing or mapped differently. |
| 101 | */ |
| 102 | struct sof_dev_desc { |
| 103 | /* list of machines using this configuration */ |
| 104 | struct snd_soc_acpi_mach *machines; |
Chunxu Li | 6ace85b | 2022-08-05 15:04:48 +0800 | [diff] [blame] | 105 | struct snd_sof_of_mach *of_machines; |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 106 | |
Pierre-Louis Bossart | 1466327 | 2019-09-16 16:42:41 -0500 | [diff] [blame] | 107 | /* alternate list of machines using this configuration */ |
| 108 | struct snd_soc_acpi_mach *alt_machines; |
| 109 | |
Daniel Baluta | 43437d0 | 2020-09-21 13:50:38 +0300 | [diff] [blame] | 110 | bool use_acpi_target_states; |
| 111 | |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 112 | /* Platform resource indexes in BAR / ACPI resources. */ |
| 113 | /* Must set to -1 if not used - add new items to end */ |
| 114 | int resindex_lpe_base; |
| 115 | int resindex_pcicfg_base; |
| 116 | int resindex_imr_base; |
| 117 | int irqindex_host_ipc; |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 118 | |
| 119 | /* IPC timeouts in ms */ |
| 120 | int ipc_timeout; |
| 121 | int boot_timeout; |
| 122 | |
| 123 | /* chip information for dsp */ |
| 124 | const void *chip_info; |
| 125 | |
| 126 | /* defaults for no codec mode */ |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 127 | const char *nocodec_tplg_filename; |
| 128 | |
Pierre-Louis Bossart | 0cf8ff0 | 2022-04-14 13:48:05 -0500 | [diff] [blame] | 129 | /* information on supported IPCs */ |
| 130 | unsigned int ipc_supported_mask; |
| 131 | enum sof_ipc_type ipc_default; |
| 132 | |
Peter Ujfalusi | 25bbc0c | 2022-10-20 15:12:30 +0300 | [diff] [blame] | 133 | /* defaults paths for firmware, library and topology files */ |
Pierre-Louis Bossart | a3757915 | 2022-04-14 13:48:04 -0500 | [diff] [blame] | 134 | const char *default_fw_path[SOF_IPC_TYPE_COUNT]; |
Peter Ujfalusi | 25bbc0c | 2022-10-20 15:12:30 +0300 | [diff] [blame] | 135 | const char *default_lib_path[SOF_IPC_TYPE_COUNT]; |
Pierre-Louis Bossart | a3757915 | 2022-04-14 13:48:04 -0500 | [diff] [blame] | 136 | const char *default_tplg_path[SOF_IPC_TYPE_COUNT]; |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 137 | |
Ranjani Sridharan | 03eec9b | 2019-12-04 15:15:50 -0600 | [diff] [blame] | 138 | /* default firmware name */ |
Pierre-Louis Bossart | a97abb3 | 2022-04-14 13:48:06 -0500 | [diff] [blame] | 139 | const char *default_fw_filename[SOF_IPC_TYPE_COUNT]; |
Ranjani Sridharan | 03eec9b | 2019-12-04 15:15:50 -0600 | [diff] [blame] | 140 | |
Pierre-Louis Bossart | 856601e | 2022-04-14 13:48:10 -0500 | [diff] [blame] | 141 | struct snd_sof_dsp_ops *ops; |
| 142 | int (*ops_init)(struct snd_sof_dev *sdev); |
Ranjani Sridharan | bc433fd | 2022-06-08 20:26:37 -0700 | [diff] [blame] | 143 | void (*ops_free)(struct snd_sof_dev *sdev); |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 144 | }; |
| 145 | |
Keyon Jie | b951b51 | 2021-03-19 14:49:49 +0200 | [diff] [blame] | 146 | int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd); |
Brent Lu | bc619cf | 2021-06-25 15:50:41 -0500 | [diff] [blame] | 147 | int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd); |
Ranjani Sridharan | f805e7e | 2020-11-20 16:16:53 +0200 | [diff] [blame] | 148 | |
Liam Girdwood | c16211d | 2019-04-12 11:05:06 -0500 | [diff] [blame] | 149 | #endif |