blob: 0a66fab5982861d51621cbb683791ef717c533e2 [file] [log] [blame]
Jeeja KP23db4722015-08-01 19:40:41 +05301/*
2 * skl_topology.h - Intel HDA Platform topology header file
3 *
4 * Copyright (C) 2014-15 Intel Corp
5 * Author: Jeeja KP <jeeja.kp@intel.com>
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 *
19 */
20
21#ifndef __SKL_TOPOLOGY_H__
22#define __SKL_TOPOLOGY_H__
23
24#include <linux/types.h>
25
26#include <sound/hdaudio_ext.h>
27#include <sound/soc.h>
28#include "skl.h"
29#include "skl-tplg-interface.h"
30
31#define BITS_PER_BYTE 8
32#define MAX_TS_GROUPS 8
33#define MAX_DMIC_TS_GROUPS 4
34#define MAX_FIXED_DMIC_PARAMS_SIZE 727
35
36/* Maximum number of coefficients up down mixer module */
37#define UP_DOWN_MIXER_MAX_COEFF 6
38
Hardik T Shah4cd98992015-10-27 09:22:55 +090039#define MODULE_MAX_IN_PINS 8
40#define MODULE_MAX_OUT_PINS 8
41
Jeeja KP23db4722015-08-01 19:40:41 +053042enum skl_channel_index {
43 SKL_CHANNEL_LEFT = 0,
44 SKL_CHANNEL_RIGHT = 1,
45 SKL_CHANNEL_CENTER = 2,
46 SKL_CHANNEL_LEFT_SURROUND = 3,
47 SKL_CHANNEL_CENTER_SURROUND = 3,
48 SKL_CHANNEL_RIGHT_SURROUND = 4,
49 SKL_CHANNEL_LFE = 7,
50 SKL_CHANNEL_INVALID = 0xF,
51};
52
53enum skl_bitdepth {
54 SKL_DEPTH_8BIT = 8,
55 SKL_DEPTH_16BIT = 16,
56 SKL_DEPTH_24BIT = 24,
57 SKL_DEPTH_32BIT = 32,
58 SKL_DEPTH_INVALID
59};
60
Jeeja KP23db4722015-08-01 19:40:41 +053061
62enum skl_s_freq {
63 SKL_FS_8000 = 8000,
64 SKL_FS_11025 = 11025,
65 SKL_FS_12000 = 12000,
66 SKL_FS_16000 = 16000,
67 SKL_FS_22050 = 22050,
68 SKL_FS_24000 = 24000,
69 SKL_FS_32000 = 32000,
70 SKL_FS_44100 = 44100,
71 SKL_FS_48000 = 48000,
72 SKL_FS_64000 = 64000,
73 SKL_FS_88200 = 88200,
74 SKL_FS_96000 = 96000,
75 SKL_FS_128000 = 128000,
76 SKL_FS_176400 = 176400,
77 SKL_FS_192000 = 192000,
78 SKL_FS_INVALID
79};
80
81enum skl_widget_type {
82 SKL_WIDGET_VMIXER = 1,
83 SKL_WIDGET_MIXER = 2,
84 SKL_WIDGET_PGA = 3,
85 SKL_WIDGET_MUX = 4
86};
87
88struct skl_audio_data_format {
89 enum skl_s_freq s_freq;
90 enum skl_bitdepth bit_depth;
91 u32 channel_map;
92 enum skl_ch_cfg ch_cfg;
93 enum skl_interleaving interleaving;
94 u8 number_of_channels;
95 u8 valid_bit_depth;
96 u8 sample_type;
97 u8 reserved[1];
98} __packed;
99
100struct skl_base_cfg {
101 u32 cps;
102 u32 ibs;
103 u32 obs;
104 u32 is_pages;
105 struct skl_audio_data_format audio_fmt;
106};
107
108struct skl_cpr_gtw_cfg {
109 u32 node_id;
110 u32 dma_buffer_size;
111 u32 config_length;
112 /* not mandatory; required only for DMIC/I2S */
113 u32 config_data[1];
114} __packed;
115
116struct skl_cpr_cfg {
117 struct skl_base_cfg base_cfg;
118 struct skl_audio_data_format out_fmt;
119 u32 cpr_feature_mask;
120 struct skl_cpr_gtw_cfg gtw_cfg;
121} __packed;
122
Hardik T Shaha0ffe482015-08-01 19:40:42 +0530123
124struct skl_src_module_cfg {
125 struct skl_base_cfg base_cfg;
126 enum skl_s_freq src_cfg;
127} __packed;
128
Jeeja KP4e109962015-10-22 23:22:39 +0530129struct notification_mask {
130 u32 notify;
131 u32 enable;
132} __packed;
133
Hardik T Shaha0ffe482015-08-01 19:40:42 +0530134struct skl_up_down_mixer_cfg {
135 struct skl_base_cfg base_cfg;
136 enum skl_ch_cfg out_ch_cfg;
137 /* This should be set to 1 if user coefficients are required */
138 u32 coeff_sel;
139 /* Pass the user coeff in this array */
140 s32 coeff[UP_DOWN_MIXER_MAX_COEFF];
141} __packed;
142
Jeeja KP399b2102015-11-28 15:01:48 +0530143struct skl_algo_cfg {
144 struct skl_base_cfg base_cfg;
145 char params[0];
146} __packed;
147
Jeeja KP23db4722015-08-01 19:40:41 +0530148enum skl_dma_type {
149 SKL_DMA_HDA_HOST_OUTPUT_CLASS = 0,
150 SKL_DMA_HDA_HOST_INPUT_CLASS = 1,
151 SKL_DMA_HDA_HOST_INOUT_CLASS = 2,
152 SKL_DMA_HDA_LINK_OUTPUT_CLASS = 8,
153 SKL_DMA_HDA_LINK_INPUT_CLASS = 9,
154 SKL_DMA_HDA_LINK_INOUT_CLASS = 0xA,
155 SKL_DMA_DMIC_LINK_INPUT_CLASS = 0xB,
156 SKL_DMA_I2S_LINK_OUTPUT_CLASS = 0xC,
157 SKL_DMA_I2S_LINK_INPUT_CLASS = 0xD,
158};
159
160union skl_ssp_dma_node {
161 u8 val;
162 struct {
Jeeja KPd7b18812015-10-22 23:22:38 +0530163 u8 time_slot_index:4;
Jeeja KP23db4722015-08-01 19:40:41 +0530164 u8 i2s_instance:4;
165 } dma_node;
166};
167
168union skl_connector_node_id {
169 u32 val;
170 struct {
171 u32 vindex:8;
172 u32 dma_type:4;
173 u32 rsvd:20;
174 } node;
175};
176
177struct skl_module_fmt {
178 u32 channels;
179 u32 s_freq;
180 u32 bit_depth;
181 u32 valid_bit_depth;
182 u32 ch_cfg;
Hardik T Shah4cd98992015-10-27 09:22:55 +0900183 u32 interleaving_style;
184 u32 sample_type;
185 u32 ch_map;
Jeeja KP23db4722015-08-01 19:40:41 +0530186};
187
Jeeja KP4f745702015-10-27 09:22:49 +0900188struct skl_module_cfg;
189
Jeeja KP23db4722015-08-01 19:40:41 +0530190struct skl_module_inst_id {
191 u32 module_id;
192 u32 instance_id;
193};
194
Jeeja KP4f745702015-10-27 09:22:49 +0900195enum skl_module_pin_state {
196 SKL_PIN_UNBIND = 0,
197 SKL_PIN_BIND_DONE = 1,
198};
199
Jeeja KP23db4722015-08-01 19:40:41 +0530200struct skl_module_pin {
201 struct skl_module_inst_id id;
Jeeja KP23db4722015-08-01 19:40:41 +0530202 bool is_dynamic;
203 bool in_use;
Jeeja KP4f745702015-10-27 09:22:49 +0900204 enum skl_module_pin_state pin_state;
205 struct skl_module_cfg *tgt_mcfg;
Jeeja KP23db4722015-08-01 19:40:41 +0530206};
207
208struct skl_specific_cfg {
209 u32 caps_size;
210 u32 *caps;
211};
212
213enum skl_pipe_state {
214 SKL_PIPE_INVALID = 0,
215 SKL_PIPE_CREATED = 1,
216 SKL_PIPE_PAUSED = 2,
217 SKL_PIPE_STARTED = 3
218};
219
220struct skl_pipe_module {
221 struct snd_soc_dapm_widget *w;
222 struct list_head node;
223};
224
225struct skl_pipe_params {
226 u8 host_dma_id;
227 u8 link_dma_id;
228 u32 ch;
229 u32 s_freq;
230 u32 s_fmt;
231 u8 linktype;
232 int stream;
233};
234
235struct skl_pipe {
236 u8 ppl_id;
237 u8 pipe_priority;
238 u16 conn_type;
239 u32 memory_pages;
240 struct skl_pipe_params *p_params;
241 enum skl_pipe_state state;
242 struct list_head w_list;
243};
244
245enum skl_module_state {
246 SKL_MODULE_UNINIT = 0,
247 SKL_MODULE_INIT_DONE = 1,
248 SKL_MODULE_LOADED = 2,
249 SKL_MODULE_UNLOADED = 3,
250 SKL_MODULE_BIND_DONE = 4
251};
252
253struct skl_module_cfg {
Hardik T Shah65aecfa2015-10-27 09:22:57 +0900254 char guid[SKL_UUID_STR_SZ];
Jeeja KP23db4722015-08-01 19:40:41 +0530255 struct skl_module_inst_id id;
Hardik T Shah04afbbb2015-10-27 09:22:56 +0900256 u8 domain;
Hardik T Shah4cd98992015-10-27 09:22:55 +0900257 bool homogenous_inputs;
258 bool homogenous_outputs;
259 struct skl_module_fmt in_fmt[MODULE_MAX_IN_PINS];
260 struct skl_module_fmt out_fmt[MODULE_MAX_OUT_PINS];
Jeeja KP23db4722015-08-01 19:40:41 +0530261 u8 max_in_queue;
262 u8 max_out_queue;
263 u8 in_queue_mask;
264 u8 out_queue_mask;
265 u8 in_queue;
266 u8 out_queue;
267 u32 mcps;
268 u32 ibs;
269 u32 obs;
270 u8 is_loadable;
271 u8 core_id;
272 u8 dev_type;
273 u8 dma_id;
274 u8 time_slot;
275 u32 params_fixup;
276 u32 converter;
277 u32 vbus_id;
278 struct skl_module_pin *m_in_pin;
279 struct skl_module_pin *m_out_pin;
280 enum skl_module_type m_type;
281 enum skl_hw_conn_type hw_conn_type;
282 enum skl_module_state m_state;
283 struct skl_pipe *pipe;
284 struct skl_specific_cfg formats_config;
285};
Hardik T Shaha0ffe482015-08-01 19:40:42 +0530286
Jeeja KPe4e2d2f2015-10-07 11:31:52 +0100287struct skl_pipeline {
288 struct skl_pipe *pipe;
289 struct list_head node;
290};
291
Vinod Kould93f8e52015-10-07 11:31:54 +0100292static inline struct skl *get_skl_ctx(struct device *dev)
293{
294 struct hdac_ext_bus *ebus = dev_get_drvdata(dev);
295
296 return ebus_to_skl(ebus);
297}
298
Vinod Koulcfb0a872015-10-07 11:31:55 +0100299int skl_tplg_be_update_params(struct snd_soc_dai *dai,
300 struct skl_pipe_params *params);
301void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai,
302 struct skl_pipe_params *params, int stream);
303int skl_tplg_init(struct snd_soc_platform *platform,
304 struct hdac_ext_bus *ebus);
305struct skl_module_cfg *skl_tplg_fe_get_cpr_module(
306 struct snd_soc_dai *dai, int stream);
307int skl_tplg_update_pipe_params(struct device *dev,
308 struct skl_module_cfg *mconfig, struct skl_pipe_params *params);
309
Jeeja KPc9b1e832015-08-01 19:40:44 +0530310int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe);
311
312int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
313
314int skl_pause_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
315
316int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
317
318int skl_stop_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
319
Jeeja KP9939a9c2015-11-28 15:01:47 +0530320int skl_init_module(struct skl_sst *ctx, struct skl_module_cfg *module_config);
Jeeja KPbeb73b22015-08-01 19:40:43 +0530321
322int skl_bind_modules(struct skl_sst *ctx, struct skl_module_cfg
323 *src_module, struct skl_module_cfg *dst_module);
324
325int skl_unbind_modules(struct skl_sst *ctx, struct skl_module_cfg
326 *src_module, struct skl_module_cfg *dst_module);
327
Jeeja KP9939a9c2015-11-28 15:01:47 +0530328int skl_set_module_params(struct skl_sst *ctx, u32 *params, int size,
329 u32 param_id, struct skl_module_cfg *mcfg);
330
Jeeja KP23db4722015-08-01 19:40:41 +0530331enum skl_bitdepth skl_get_bit_depth(int params);
332#endif