Merge tag 'kbuild-v5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
[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
PU
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 */
d41607d3 32enum sof_fw_state {
fc179420
PU
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
5fdc1242
PU
43/* DSP power states */
44enum 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
15527fee
PLB
51/* Definitions for multiple IPCs */
52enum sof_ipc_type {
53 SOF_IPC,
54 SOF_INTEL_IPC4,
55 SOF_IPC_TYPE_COUNT
56};
57
c16211d6
LG
58/*
59 * SOF Platform data.
60 */
61struct snd_sof_pdata {
62 const struct firmware *fw;
c16211d6
LG
63 const char *name;
64 const char *platform;
65
66 struct device *dev;
67
92be17a5
KT
68 /* indicate how many first bytes shouldn't be loaded into DSP memory. */
69 size_t fw_offset;
70
c16211d6
LG
71 /*
72 * notification callback used if the hardware initialization
73 * can take time or is handled in a workqueue. This callback
74 * can be used by the caller to e.g. enable runtime_pm
75 * or limit functionality until all low-level inits are
76 * complete.
77 */
78 void (*sof_probe_complete)(struct device *dev);
79
80 /* descriptor */
81 const struct sof_dev_desc *desc;
82
83 /* firmware and topology filenames */
84 const char *fw_filename_prefix;
85 const char *fw_filename;
86 const char *tplg_filename_prefix;
87 const char *tplg_filename;
88
89 /* machine */
90 struct platform_device *pdev_mach;
91 const struct snd_soc_acpi_mach *machine;
92
93 void *hw_pdata;
15527fee
PLB
94
95 enum sof_ipc_type ipc_type;
c16211d6
LG
96};
97
98/*
99 * Descriptor used for setting up SOF platform data. This is used when
100 * ACPI/PCI data is missing or mapped differently.
101 */
102struct sof_dev_desc {
103 /* list of machines using this configuration */
104 struct snd_soc_acpi_mach *machines;
105
1466327e
PLB
106 /* alternate list of machines using this configuration */
107 struct snd_soc_acpi_mach *alt_machines;
108
43437d04
DB
109 bool use_acpi_target_states;
110
c16211d6
LG
111 /* Platform resource indexes in BAR / ACPI resources. */
112 /* Must set to -1 if not used - add new items to end */
113 int resindex_lpe_base;
114 int resindex_pcicfg_base;
115 int resindex_imr_base;
116 int irqindex_host_ipc;
c16211d6
LG
117
118 /* IPC timeouts in ms */
119 int ipc_timeout;
120 int boot_timeout;
121
122 /* chip information for dsp */
123 const void *chip_info;
124
125 /* defaults for no codec mode */
c16211d6
LG
126 const char *nocodec_tplg_filename;
127
0cf8ff05
PLB
128 /* information on supported IPCs */
129 unsigned int ipc_supported_mask;
130 enum sof_ipc_type ipc_default;
131
c16211d6 132 /* defaults paths for firmware and topology files */
a3757915
PLB
133 const char *default_fw_path[SOF_IPC_TYPE_COUNT];
134 const char *default_tplg_path[SOF_IPC_TYPE_COUNT];
c16211d6 135
03eec9b4 136 /* default firmware name */
a97abb3c 137 const char *default_fw_filename[SOF_IPC_TYPE_COUNT];
03eec9b4 138
856601e5
PLB
139 struct snd_sof_dsp_ops *ops;
140 int (*ops_init)(struct snd_sof_dev *sdev);
bc433fd7 141 void (*ops_free)(struct snd_sof_dev *sdev);
c16211d6
LG
142};
143
b951b51e 144int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
bc619cfc 145int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
f805e7e0 146
c16211d6 147#endif