• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 struct snd_sof_dev;
20 
21 /**
22  * enum sof_fw_state - DSP firmware state definitions
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  */
32 enum sof_fw_state {
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 
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 
51 /* Definitions for multiple IPCs */
52 enum sof_ipc_type {
53 	SOF_IPC,
54 	SOF_INTEL_IPC4,
55 	SOF_IPC_TYPE_COUNT
56 };
57 
58 /*
59  * SOF Platform data.
60  */
61 struct snd_sof_pdata {
62 	const struct firmware *fw;
63 	const char *name;
64 	const char *platform;
65 
66 	/*
67 	 * PCI SSID. As PCI does not define 0 as invalid, the subsystem_id_set
68 	 * flag indicates that a value has been written to these members.
69 	 */
70 	unsigned short subsystem_vendor;
71 	unsigned short subsystem_device;
72 	bool subsystem_id_set;
73 
74 	struct device *dev;
75 
76 	/* indicate how many first bytes shouldn't be loaded into DSP memory. */
77 	size_t fw_offset;
78 
79 	/*
80 	 * notification callback used if the hardware initialization
81 	 * can take time or is handled in a workqueue. This callback
82 	 * can be used by the caller to e.g. enable runtime_pm
83 	 * or limit functionality until all low-level inits are
84 	 * complete.
85 	 */
86 	void (*sof_probe_complete)(struct device *dev);
87 
88 	/* descriptor */
89 	const struct sof_dev_desc *desc;
90 
91 	/* firmware and topology filenames */
92 	const char *fw_filename_prefix;
93 	const char *fw_filename;
94 	const char *tplg_filename_prefix;
95 	const char *tplg_filename;
96 
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 
102 	void *hw_pdata;
103 
104 	enum sof_ipc_type ipc_type;
105 };
106 
107 /*
108  * Descriptor used for setting up SOF platform data. This is used when
109  * ACPI/PCI data is missing or mapped differently.
110  */
111 struct sof_dev_desc {
112 	/* list of machines using this configuration */
113 	struct snd_soc_acpi_mach *machines;
114 	struct snd_sof_of_mach *of_machines;
115 
116 	/* alternate list of machines using this configuration */
117 	struct snd_soc_acpi_mach *alt_machines;
118 
119 	bool use_acpi_target_states;
120 
121 	/* Platform resource indexes in BAR / ACPI resources. */
122 	/* Must set to -1 if not used - add new items to end */
123 	int resindex_lpe_base;
124 	int resindex_pcicfg_base;
125 	int resindex_imr_base;
126 	int irqindex_host_ipc;
127 
128 	/* IPC timeouts in ms */
129 	int ipc_timeout;
130 	int boot_timeout;
131 
132 	/* chip information for dsp */
133 	const void *chip_info;
134 
135 	/* defaults for no codec mode */
136 	const char *nocodec_tplg_filename;
137 
138 	/* information on supported IPCs */
139 	unsigned int ipc_supported_mask;
140 	enum sof_ipc_type ipc_default;
141 
142 	/* defaults paths for firmware and topology files */
143 	const char *default_fw_path[SOF_IPC_TYPE_COUNT];
144 	const char *default_tplg_path[SOF_IPC_TYPE_COUNT];
145 
146 	/* default firmware name */
147 	const char *default_fw_filename[SOF_IPC_TYPE_COUNT];
148 
149 	struct snd_sof_dsp_ops *ops;
150 	int (*ops_init)(struct snd_sof_dev *sdev);
151 	void (*ops_free)(struct snd_sof_dev *sdev);
152 };
153 
154 int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
155 int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
156 
157 #endif
158