xref: /openbmc/linux/sound/soc/sof/ipc4-priv.h (revision 2612e3bbc0386368a850140a6c9b990cd496a5ec)
10af82904SRanjani Sridharan /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
20af82904SRanjani Sridharan /*
30af82904SRanjani Sridharan  * This file is provided under a dual BSD/GPLv2 license.  When using or
40af82904SRanjani Sridharan  * redistributing this file, you may do so under either license.
50af82904SRanjani Sridharan  *
60af82904SRanjani Sridharan  * Copyright(c) 2022 Intel Corporation. All rights reserved.
70af82904SRanjani Sridharan  */
80af82904SRanjani Sridharan 
90af82904SRanjani Sridharan #ifndef __SOUND_SOC_SOF_IPC4_PRIV_H
100af82904SRanjani Sridharan #define __SOUND_SOC_SOF_IPC4_PRIV_H
110af82904SRanjani Sridharan 
120af82904SRanjani Sridharan #include <linux/idr.h>
13c62ff366SRanjani Sridharan #include <sound/sof/ext_manifest4.h>
140af82904SRanjani Sridharan #include "sof-priv.h"
150af82904SRanjani Sridharan 
16b59f1532SPeter Ujfalusi /* The DSP window indices are fixed */
174700bfb2SRander Wang #define SOF_IPC4_INBOX_WINDOW_IDX	0
18b59f1532SPeter Ujfalusi #define SOF_IPC4_OUTBOX_WINDOW_IDX	1
19a5d0147aSPeter Ujfalusi #define SOF_IPC4_DEBUG_WINDOW_IDX	2
20b59f1532SPeter Ujfalusi 
21f4ea22f7SPeter Ujfalusi enum sof_ipc4_mtrace_type {
22f4ea22f7SPeter Ujfalusi 	SOF_IPC4_MTRACE_NOT_AVAILABLE = 0,
23f4ea22f7SPeter Ujfalusi 	SOF_IPC4_MTRACE_INTEL_CAVS_1_5,
24f4ea22f7SPeter Ujfalusi 	SOF_IPC4_MTRACE_INTEL_CAVS_1_8,
25f4ea22f7SPeter Ujfalusi 	SOF_IPC4_MTRACE_INTEL_CAVS_2,
26f4ea22f7SPeter Ujfalusi };
27f4ea22f7SPeter Ujfalusi 
280af82904SRanjani Sridharan /**
29c62ff366SRanjani Sridharan  * struct sof_ipc4_fw_module - IPC4 module info
30c62ff366SRanjani Sridharan  * @sof_man4_module: Module info
31fe04f300SPeter Ujfalusi  * @fw_mod_cfg: Pointer to the module config start of the module
32c62ff366SRanjani Sridharan  * @m_ida: Module instance identifier
33c62ff366SRanjani Sridharan  * @private: Module private data
34c62ff366SRanjani Sridharan  */
35c62ff366SRanjani Sridharan struct sof_ipc4_fw_module {
36c62ff366SRanjani Sridharan 	struct sof_man4_module man4_module_entry;
37fe04f300SPeter Ujfalusi 	const struct sof_man4_module_config *fw_mod_cfg;
38c62ff366SRanjani Sridharan 	struct ida m_ida;
39c62ff366SRanjani Sridharan 	void *private;
40c62ff366SRanjani Sridharan };
41c62ff366SRanjani Sridharan 
425a932cfcSPeter Ujfalusi /**
435a932cfcSPeter Ujfalusi  * struct sof_ipc4_fw_library - IPC4 library information
445a932cfcSPeter Ujfalusi  * @sof_fw: SOF Firmware of the library
455a932cfcSPeter Ujfalusi  * @id: Library ID. 0 is reserved for basefw, external libraries must have unique
465a932cfcSPeter Ujfalusi  *	ID number between 1 and (sof_ipc4_fw_data.max_libs_count - 1)
475a932cfcSPeter Ujfalusi  *	Note: sof_ipc4_fw_data.max_libs_count == 1 implies that external libraries
485a932cfcSPeter Ujfalusi  *	are not supported
495a932cfcSPeter Ujfalusi  * @num_modules : Number of FW modules in the library
505a932cfcSPeter Ujfalusi  * @modules: Array of FW modules
515a932cfcSPeter Ujfalusi  */
525a932cfcSPeter Ujfalusi struct sof_ipc4_fw_library {
535a932cfcSPeter Ujfalusi 	struct sof_firmware sof_fw;
5473c091a2SPeter Ujfalusi 	const char *name;
555a932cfcSPeter Ujfalusi 	u32 id;
565a932cfcSPeter Ujfalusi 	int num_modules;
575a932cfcSPeter Ujfalusi 	struct sof_ipc4_fw_module *modules;
585a932cfcSPeter Ujfalusi };
595a932cfcSPeter Ujfalusi 
605a932cfcSPeter Ujfalusi /**
615a932cfcSPeter Ujfalusi  * struct sof_ipc4_fw_data - IPC4-specific data
625a932cfcSPeter Ujfalusi  * @manifest_fw_hdr_offset: FW header offset in the manifest
635a932cfcSPeter Ujfalusi  * @fw_lib_xa: XArray for firmware libraries, including basefw (ID = 0)
645a932cfcSPeter Ujfalusi  *	       Used to store the FW libraries and to manage the unique IDs of the
655a932cfcSPeter Ujfalusi  *	       libraries.
665a932cfcSPeter Ujfalusi  * @nhlt: NHLT table either from the BIOS or the topology manifest
675a932cfcSPeter Ujfalusi  * @mtrace_type: mtrace type supported on the booted platform
685a932cfcSPeter Ujfalusi  * @mtrace_log_bytes: log bytes as reported by the firmware via fw_config reply
69eb2eaf50SBard Liao  * @max_num_pipelines: max number of pipelines
705a932cfcSPeter Ujfalusi  * @max_libs_count: Maximum number of libraries support by the FW including the
715a932cfcSPeter Ujfalusi  *		    base firmware
72a5ab431eSPeter Ujfalusi  *
73a5ab431eSPeter Ujfalusi  * @load_library: Callback function for platform dependent library loading
746bc4d1b7SRanjani Sridharan  * @pipeline_state_mutex: Mutex to protect pipeline triggers, ref counts, states and deletion
755a932cfcSPeter Ujfalusi  */
765a932cfcSPeter Ujfalusi struct sof_ipc4_fw_data {
775a932cfcSPeter Ujfalusi 	u32 manifest_fw_hdr_offset;
785a932cfcSPeter Ujfalusi 	struct xarray fw_lib_xa;
795a932cfcSPeter Ujfalusi 	void *nhlt;
805a932cfcSPeter Ujfalusi 	enum sof_ipc4_mtrace_type mtrace_type;
815a932cfcSPeter Ujfalusi 	u32 mtrace_log_bytes;
82eb2eaf50SBard Liao 	int max_num_pipelines;
835a932cfcSPeter Ujfalusi 	u32 max_libs_count;
84a5ab431eSPeter Ujfalusi 
85a5ab431eSPeter Ujfalusi 	int (*load_library)(struct snd_sof_dev *sdev,
86a5ab431eSPeter Ujfalusi 			    struct sof_ipc4_fw_library *fw_lib, bool reload);
876bc4d1b7SRanjani Sridharan 	struct mutex pipeline_state_mutex; /* protect pipeline triggers, ref counts and states */
885a932cfcSPeter Ujfalusi };
895a932cfcSPeter Ujfalusi 
9065a8ef49SRander Wang /**
9165a8ef49SRander Wang  * struct sof_ipc4_timestamp_info - IPC4 timestamp info
9265a8ef49SRander Wang  * @host_copier: the host copier of the pcm stream
9365a8ef49SRander Wang  * @dai_copier: the dai copier of the pcm stream
9465a8ef49SRander Wang  * @stream_start_offset: reported by fw in memory window
9565a8ef49SRander Wang  * @llp_offset: llp offset in memory window
9665a8ef49SRander Wang  */
9765a8ef49SRander Wang struct sof_ipc4_timestamp_info {
9865a8ef49SRander Wang 	struct sof_ipc4_copier *host_copier;
9965a8ef49SRander Wang 	struct sof_ipc4_copier *dai_copier;
10065a8ef49SRander Wang 	u64 stream_start_offset;
10165a8ef49SRander Wang 	u32 llp_offset;
10265a8ef49SRander Wang };
10365a8ef49SRander Wang 
104c62ff366SRanjani Sridharan extern const struct sof_ipc_fw_loader_ops ipc4_loader_ops;
10590e89155SRanjani Sridharan extern const struct sof_ipc_tplg_ops ipc4_tplg_ops;
106955e84fcSRanjani Sridharan extern const struct sof_ipc_tplg_control_ops tplg_ipc4_control_ops;
107e75e5db8SRanjani Sridharan extern const struct sof_ipc_pcm_ops ipc4_pcm_ops;
108f4ea22f7SPeter Ujfalusi extern const struct sof_ipc_fw_tracing_ops ipc4_mtrace_ops;
109c62ff366SRanjani Sridharan 
110d0c0d5bfSRanjani Sridharan int sof_ipc4_set_pipeline_state(struct snd_sof_dev *sdev, u32 id, u32 state);
111f4ea22f7SPeter Ujfalusi int sof_ipc4_mtrace_update_pos(struct snd_sof_dev *sdev, int core);
112c73f8b47SPeter Ujfalusi 
113e6851310SPeter Ujfalusi int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev);
11473c091a2SPeter Ujfalusi int sof_ipc4_reload_fw_libraries(struct snd_sof_dev *sdev);
115c73f8b47SPeter Ujfalusi struct sof_ipc4_fw_module *sof_ipc4_find_module_by_uuid(struct snd_sof_dev *sdev,
116c73f8b47SPeter Ujfalusi 							const guid_t *uuid);
117*d8a2c987SPeter Ujfalusi 
118*d8a2c987SPeter Ujfalusi struct sof_ipc4_base_module_cfg;
119*d8a2c987SPeter Ujfalusi void sof_ipc4_update_cpc_from_manifest(struct snd_sof_dev *sdev,
120*d8a2c987SPeter Ujfalusi 				       struct sof_ipc4_fw_module *fw_module,
121*d8a2c987SPeter Ujfalusi 				       struct sof_ipc4_base_module_cfg *basecfg);
122*d8a2c987SPeter Ujfalusi 
1230af82904SRanjani Sridharan #endif
124