1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
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.
6 * Copyright(c) 2018 Intel Corporation
8 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
11 #ifndef __INCLUDE_SOUND_SOF_H
12 #define __INCLUDE_SOUND_SOF_H
14 #include <linux/pci.h>
15 #include <sound/soc.h>
16 #include <sound/soc-acpi.h>
18 struct snd_sof_dsp_ops
;
22 * enum sof_fw_state - DSP firmware state definitions
23 * @SOF_FW_BOOT_NOT_STARTED: firmware boot is not yet started
24 * @SOF_DSPLESS_MODE: DSP is not used
25 * @SOF_FW_BOOT_PREPARE: preparing for boot (firmware loading for exaqmple)
26 * @SOF_FW_BOOT_IN_PROGRESS: firmware boot is in progress
27 * @SOF_FW_BOOT_FAILED: firmware boot failed
28 * @SOF_FW_BOOT_READY_FAILED: firmware booted but fw_ready op failed
29 * @SOF_FW_BOOT_READY_OK: firmware booted and fw_ready op passed
30 * @SOF_FW_BOOT_COMPLETE: firmware is booted up and functional
31 * @SOF_FW_CRASHED: firmware crashed after successful boot
34 SOF_FW_BOOT_NOT_STARTED
= 0,
37 SOF_FW_BOOT_IN_PROGRESS
,
39 SOF_FW_BOOT_READY_FAILED
,
45 /* DSP power states */
46 enum sof_dsp_power_states
{
53 /* Definitions for multiple IPCs */
60 struct sof_loadable_file_profile
{
61 enum sof_ipc_type ipc_type
;
64 const char *fw_path_postfix
;
66 const char *fw_lib_path
;
67 const char *fw_lib_path_postfix
;
68 const char *tplg_path
;
69 const char *tplg_name
;
75 struct snd_sof_pdata
{
80 * PCI SSID. As PCI does not define 0 as invalid, the subsystem_id_set
81 * flag indicates that a value has been written to these members.
83 unsigned short subsystem_vendor
;
84 unsigned short subsystem_device
;
85 bool subsystem_id_set
;
90 * notification callback used if the hardware initialization
91 * can take time or is handled in a workqueue. This callback
92 * can be used by the caller to e.g. enable runtime_pm
93 * or limit functionality until all low-level inits are
96 void (*sof_probe_complete
)(struct device
*dev
);
99 const struct sof_dev_desc
*desc
;
101 /* platform's preferred IPC type and path overrides */
102 struct sof_loadable_file_profile ipc_file_profile_base
;
104 /* firmware and topology filenames */
105 const char *fw_filename_prefix
;
106 const char *fw_filename
;
107 const char *tplg_filename_prefix
;
108 const char *tplg_filename
;
110 /* loadable external libraries available under this directory */
111 const char *fw_lib_prefix
;
114 struct platform_device
*pdev_mach
;
115 const struct snd_soc_acpi_mach
*machine
;
116 const struct snd_sof_of_mach
*of_machine
;
120 enum sof_ipc_type ipc_type
;
124 * Descriptor used for setting up SOF platform data. This is used when
125 * ACPI/PCI data is missing or mapped differently.
127 struct sof_dev_desc
{
128 /* list of machines using this configuration */
129 struct snd_soc_acpi_mach
*machines
;
130 struct snd_sof_of_mach
*of_machines
;
132 /* alternate list of machines using this configuration */
133 struct snd_soc_acpi_mach
*alt_machines
;
135 bool use_acpi_target_states
;
137 /* Platform resource indexes in BAR / ACPI resources. */
138 /* Must set to -1 if not used - add new items to end */
139 int resindex_lpe_base
;
140 int resindex_pcicfg_base
;
141 int resindex_imr_base
;
142 int irqindex_host_ipc
;
144 /* IPC timeouts in ms */
148 /* chip information for dsp */
149 const void *chip_info
;
151 /* defaults for no codec mode */
152 const char *nocodec_tplg_filename
;
154 /* information on supported IPCs */
155 unsigned int ipc_supported_mask
;
156 enum sof_ipc_type ipc_default
;
158 /* The platform supports DSPless mode */
159 bool dspless_mode_supported
;
161 /* defaults paths for firmware, library and topology files */
162 const char *default_fw_path
[SOF_IPC_TYPE_COUNT
];
163 const char *default_lib_path
[SOF_IPC_TYPE_COUNT
];
164 const char *default_tplg_path
[SOF_IPC_TYPE_COUNT
];
166 /* default firmware name */
167 const char *default_fw_filename
[SOF_IPC_TYPE_COUNT
];
169 const struct snd_sof_dsp_ops
*ops
;
170 int (*ops_init
)(struct snd_sof_dev
*sdev
);
171 void (*ops_free
)(struct snd_sof_dev
*sdev
);
174 int sof_dai_get_mclk(struct snd_soc_pcm_runtime
*rtd
);
175 int sof_dai_get_bclk(struct snd_soc_pcm_runtime
*rtd
);
176 int sof_dai_get_tdm_slots(struct snd_soc_pcm_runtime
*rtd
);