GNU Linux-libre 5.19-rc6-gnu
[releases.git] / sound / soc / intel / avs / topology.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright(c) 2021 Intel Corporation. All rights reserved.
4  *
5  * Authors: Cezary Rojewski <cezary.rojewski@intel.com>
6  *          Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
7  */
8
9 #ifndef __SOUND_SOC_INTEL_AVS_TPLG_H
10 #define __SOUND_SOC_INTEL_AVS_TPLG_H
11
12 #include <linux/list.h>
13 #include "messages.h"
14
15 #define INVALID_OBJECT_ID       UINT_MAX
16
17 struct snd_soc_component;
18
19 struct avs_tplg {
20         char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
21         u32 version;
22         struct snd_soc_component *comp;
23
24         struct avs_tplg_library *libs;
25         u32 num_libs;
26         struct avs_audio_format *fmts;
27         u32 num_fmts;
28         struct avs_tplg_modcfg_base *modcfgs_base;
29         u32 num_modcfgs_base;
30         struct avs_tplg_modcfg_ext *modcfgs_ext;
31         u32 num_modcfgs_ext;
32         struct avs_tplg_pplcfg *pplcfgs;
33         u32 num_pplcfgs;
34         struct avs_tplg_binding *bindings;
35         u32 num_bindings;
36
37         struct list_head path_tmpl_list;
38 };
39
40 struct avs_tplg_library {
41         char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
42 };
43
44 /* Matches header of struct avs_mod_cfg_base. */
45 struct avs_tplg_modcfg_base {
46         u32 cpc;
47         u32 ibs;
48         u32 obs;
49         u32 is_pages;
50 };
51
52 struct avs_tplg_pin_format {
53         u32 pin_index;
54         u32 iobs;
55         struct avs_audio_format *fmt;
56 };
57
58 struct avs_tplg_modcfg_ext {
59         guid_t type;
60
61         union {
62                 struct {
63                         u16 num_input_pins;
64                         u16 num_output_pins;
65                         struct avs_tplg_pin_format *pin_fmts;
66                 } generic;
67                 struct {
68                         struct avs_audio_format *out_fmt;
69                         struct avs_audio_format *blob_fmt; /* optional override */
70                         u32 feature_mask;
71                         union avs_virtual_index vindex;
72                         u32 dma_type;
73                         u32 dma_buffer_size;
74                         u32 config_length;
75                         /* config_data part of priv data */
76                 } copier;
77                 struct {
78                         u32 out_channel_config;
79                         u32 coefficients_select;
80                         s32 coefficients[AVS_CHANNELS_MAX];
81                         u32 channel_map;
82                 } updown_mix;
83                 struct {
84                         u32 out_freq;
85                 } src;
86                 struct {
87                         u32 out_freq;
88                         u8 mode;
89                         u8 disable_jitter_buffer;
90                 } asrc;
91                 struct {
92                         u32 cpc_lp_mode;
93                 } wov;
94                 struct {
95                         struct avs_audio_format *ref_fmt;
96                         struct avs_audio_format *out_fmt;
97                         u32 cpc_lp_mode;
98                 } aec;
99                 struct {
100                         struct avs_audio_format *ref_fmt;
101                         struct avs_audio_format *out_fmt;
102                 } mux;
103                 struct {
104                         struct avs_audio_format *out_fmt;
105                 } micsel;
106         };
107 };
108
109 /* Specifies path behaviour during PCM ->trigger(START) command. */
110 enum avs_tplg_trigger {
111         AVS_TPLG_TRIGGER_AUTO = 0,
112 };
113
114 struct avs_tplg_pplcfg {
115         u16 req_size;
116         u8 priority;
117         bool lp;
118         u16 attributes;
119         enum avs_tplg_trigger trigger;
120 };
121
122 struct avs_tplg_binding {
123         char target_tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
124         u32 target_path_tmpl_id;
125         u32 target_ppl_id;
126         u32 target_mod_id;
127         u8 target_mod_pin;
128         u32 mod_id;
129         u8 mod_pin;
130         u8 is_sink;
131 };
132
133 struct avs_tplg_path_template_id {
134         u32 id;
135         char tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
136 };
137
138 struct avs_tplg_path_template {
139         u32 id;
140
141         struct list_head path_list;
142
143         struct avs_tplg *owner;
144         /* Driver path templates management. */
145         struct list_head node;
146 };
147
148 struct avs_tplg_path {
149         u32 id;
150
151         /* Path format requirements. */
152         struct avs_audio_format *fe_fmt;
153         struct avs_audio_format *be_fmt;
154
155         struct list_head ppl_list;
156
157         struct avs_tplg_path_template *owner;
158         /* Path template path-variants management. */
159         struct list_head node;
160 };
161
162 struct avs_tplg_pipeline {
163         u32 id;
164
165         struct avs_tplg_pplcfg *cfg;
166         struct avs_tplg_binding **bindings;
167         u32 num_bindings;
168         struct list_head mod_list;
169
170         struct avs_tplg_path *owner;
171         /* Path pipelines management. */
172         struct list_head node;
173 };
174
175 struct avs_tplg_module {
176         u32 id;
177
178         struct avs_tplg_modcfg_base *cfg_base;
179         struct avs_audio_format *in_fmt;
180         u8 core_id;
181         u8 domain;
182         struct avs_tplg_modcfg_ext *cfg_ext;
183
184         struct avs_tplg_pipeline *owner;
185         /* Pipeline modules management. */
186         struct list_head node;
187 };
188
189 struct avs_tplg *avs_tplg_new(struct snd_soc_component *comp);
190
191 int avs_load_topology(struct snd_soc_component *comp, const char *filename);
192 int avs_remove_topology(struct snd_soc_component *comp);
193
194 #endif