Merge tag 'perf-tools-for-v6.4-3-2023-05-06' of git://git.kernel.org/pub/scm/linux...
[linux-block.git] / include / sound / sof.h
CommitLineData
e149ca29 1/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
c16211d6
LG
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>
8017b8fd 15#include <sound/soc.h>
c16211d6
LG
16#include <sound/soc-acpi.h>
17
18struct snd_sof_dsp_ops;
856601e5 19struct snd_sof_dev;
c16211d6 20
fc179420 21/**
d41607d3 22 * enum sof_fw_state - DSP firmware state definitions
fc179420 23 * @SOF_FW_BOOT_NOT_STARTED: firmware boot is not yet started
59611370 24 * @SOF_DSPLESS_MODE: DSP is not used
fc179420
PU
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 */
d41607d3 33enum sof_fw_state {
fc179420 34 SOF_FW_BOOT_NOT_STARTED = 0,
59611370 35 SOF_DSPLESS_MODE,
fc179420
PU
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
5fdc1242
PU
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
15527fee
PLB
53/* Definitions for multiple IPCs */
54enum sof_ipc_type {
55 SOF_IPC,
56 SOF_INTEL_IPC4,
57 SOF_IPC_TYPE_COUNT
58};
59
c16211d6
LG
60/*
61 * SOF Platform data.
62 */
63struct snd_sof_pdata {
c16211d6
LG
64 const char *name;
65 const char *platform;
66
67 struct device *dev;
68
69 /*
70 * notification callback used if the hardware initialization
71 * can take time or is handled in a workqueue. This callback
72 * can be used by the caller to e.g. enable runtime_pm
73 * or limit functionality until all low-level inits are
74 * complete.
75 */
76 void (*sof_probe_complete)(struct device *dev);
77
78 /* descriptor */
79 const struct sof_dev_desc *desc;
80
81 /* firmware and topology filenames */
82 const char *fw_filename_prefix;
83 const char *fw_filename;
84 const char *tplg_filename_prefix;
85 const char *tplg_filename;
86
25bbc0c5
PU
87 /* loadable external libraries available under this directory */
88 const char *fw_lib_prefix;
89
c16211d6
LG
90 /* machine */
91 struct platform_device *pdev_mach;
92 const struct snd_soc_acpi_mach *machine;
6ace85b9 93 const struct snd_sof_of_mach *of_machine;
c16211d6
LG
94
95 void *hw_pdata;
15527fee
PLB
96
97 enum sof_ipc_type ipc_type;
c16211d6
LG
98};
99
100/*
101 * Descriptor used for setting up SOF platform data. This is used when
102 * ACPI/PCI data is missing or mapped differently.
103 */
104struct sof_dev_desc {
105 /* list of machines using this configuration */
106 struct snd_soc_acpi_mach *machines;
6ace85b9 107 struct snd_sof_of_mach *of_machines;
c16211d6 108
1466327e
PLB
109 /* alternate list of machines using this configuration */
110 struct snd_soc_acpi_mach *alt_machines;
111
43437d04
DB
112 bool use_acpi_target_states;
113
c16211d6
LG
114 /* Platform resource indexes in BAR / ACPI resources. */
115 /* Must set to -1 if not used - add new items to end */
116 int resindex_lpe_base;
117 int resindex_pcicfg_base;
118 int resindex_imr_base;
119 int irqindex_host_ipc;
c16211d6
LG
120
121 /* IPC timeouts in ms */
122 int ipc_timeout;
123 int boot_timeout;
124
125 /* chip information for dsp */
126 const void *chip_info;
127
128 /* defaults for no codec mode */
c16211d6
LG
129 const char *nocodec_tplg_filename;
130
0cf8ff05
PLB
131 /* information on supported IPCs */
132 unsigned int ipc_supported_mask;
133 enum sof_ipc_type ipc_default;
134
59611370
PU
135 /* The platform supports DSPless mode */
136 bool dspless_mode_supported;
137
25bbc0c5 138 /* defaults paths for firmware, library and topology files */
a3757915 139 const char *default_fw_path[SOF_IPC_TYPE_COUNT];
25bbc0c5 140 const char *default_lib_path[SOF_IPC_TYPE_COUNT];
a3757915 141 const char *default_tplg_path[SOF_IPC_TYPE_COUNT];
c16211d6 142
03eec9b4 143 /* default firmware name */
a97abb3c 144 const char *default_fw_filename[SOF_IPC_TYPE_COUNT];
03eec9b4 145
856601e5
PLB
146 struct snd_sof_dsp_ops *ops;
147 int (*ops_init)(struct snd_sof_dev *sdev);
bc433fd7 148 void (*ops_free)(struct snd_sof_dev *sdev);
c16211d6
LG
149};
150
b951b51e 151int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
bc619cfc 152int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
f805e7e0 153
c16211d6 154#endif