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