xref: /kernel/linux/linux-6.6/include/sound/sof.h (revision 62306a36)
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
18struct snd_sof_dsp_ops;
19struct 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_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
32 */
33enum sof_fw_state {
34	SOF_FW_BOOT_NOT_STARTED = 0,
35	SOF_DSPLESS_MODE,
36	SOF_FW_BOOT_PREPARE,
37	SOF_FW_BOOT_IN_PROGRESS,
38	SOF_FW_BOOT_FAILED,
39	SOF_FW_BOOT_READY_FAILED,
40	SOF_FW_BOOT_READY_OK,
41	SOF_FW_BOOT_COMPLETE,
42	SOF_FW_CRASHED,
43};
44
45/* DSP power states */
46enum sof_dsp_power_states {
47	SOF_DSP_PM_D0,
48	SOF_DSP_PM_D1,
49	SOF_DSP_PM_D2,
50	SOF_DSP_PM_D3,
51};
52
53/* Definitions for multiple IPCs */
54enum sof_ipc_type {
55	SOF_IPC,
56	SOF_INTEL_IPC4,
57	SOF_IPC_TYPE_COUNT
58};
59
60/*
61 * SOF Platform data.
62 */
63struct snd_sof_pdata {
64	const char *name;
65	const char *platform;
66
67	/*
68	 * PCI SSID. As PCI does not define 0 as invalid, the subsystem_id_set
69	 * flag indicates that a value has been written to these members.
70	 */
71	unsigned short subsystem_vendor;
72	unsigned short subsystem_device;
73	bool subsystem_id_set;
74
75	struct device *dev;
76
77	/*
78	 * notification callback used if the hardware initialization
79	 * can take time or is handled in a workqueue. This callback
80	 * can be used by the caller to e.g. enable runtime_pm
81	 * or limit functionality until all low-level inits are
82	 * complete.
83	 */
84	void (*sof_probe_complete)(struct device *dev);
85
86	/* descriptor */
87	const struct sof_dev_desc *desc;
88
89	/* firmware and topology filenames */
90	const char *fw_filename_prefix;
91	const char *fw_filename;
92	const char *tplg_filename_prefix;
93	const char *tplg_filename;
94
95	/* loadable external libraries available under this directory */
96	const char *fw_lib_prefix;
97
98	/* machine */
99	struct platform_device *pdev_mach;
100	const struct snd_soc_acpi_mach *machine;
101	const struct snd_sof_of_mach *of_machine;
102
103	void *hw_pdata;
104
105	enum sof_ipc_type ipc_type;
106};
107
108/*
109 * Descriptor used for setting up SOF platform data. This is used when
110 * ACPI/PCI data is missing or mapped differently.
111 */
112struct sof_dev_desc {
113	/* list of machines using this configuration */
114	struct snd_soc_acpi_mach *machines;
115	struct snd_sof_of_mach *of_machines;
116
117	/* alternate list of machines using this configuration */
118	struct snd_soc_acpi_mach *alt_machines;
119
120	bool use_acpi_target_states;
121
122	/* Platform resource indexes in BAR / ACPI resources. */
123	/* Must set to -1 if not used - add new items to end */
124	int resindex_lpe_base;
125	int resindex_pcicfg_base;
126	int resindex_imr_base;
127	int irqindex_host_ipc;
128
129	/* IPC timeouts in ms */
130	int ipc_timeout;
131	int boot_timeout;
132
133	/* chip information for dsp */
134	const void *chip_info;
135
136	/* defaults for no codec mode */
137	const char *nocodec_tplg_filename;
138
139	/* information on supported IPCs */
140	unsigned int ipc_supported_mask;
141	enum sof_ipc_type ipc_default;
142
143	/* The platform supports DSPless mode */
144	bool dspless_mode_supported;
145
146	/* defaults paths for firmware, library and topology files */
147	const char *default_fw_path[SOF_IPC_TYPE_COUNT];
148	const char *default_lib_path[SOF_IPC_TYPE_COUNT];
149	const char *default_tplg_path[SOF_IPC_TYPE_COUNT];
150
151	/* default firmware name */
152	const char *default_fw_filename[SOF_IPC_TYPE_COUNT];
153
154	struct snd_sof_dsp_ops *ops;
155	int (*ops_init)(struct snd_sof_dev *sdev);
156	void (*ops_free)(struct snd_sof_dev *sdev);
157};
158
159int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
160int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
161
162#endif
163