blob: e530002cd763f1483aa76628f4456ee3d045dfb9 [file] [log] [blame]
Vinod Koul61b165c2014-06-13 18:03:56 +05301/*
Vinod Kould8499c92014-08-04 15:15:55 +05302 * sst-atom-controls.h - Intel MID Platform driver header file
3 *
Vinod Koul61b165c2014-06-13 18:03:56 +05304 * Copyright (C) 2013-14 Intel Corp
5 * Author: Ramesh Babu <ramesh.babu.koul@intel.com>
6 * Omair M Abdullah <omair.m.abdullah@intel.com>
7 * Samreen Nilofer <samreen.nilofer@intel.com>
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2 of the License.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 *
21 */
22
Vinod Kould8499c92014-08-04 15:15:55 +053023#ifndef __SST_ATOM_CONTROLS_H__
24#define __SST_ATOM_CONTROLS_H__
Vinod Koul61b165c2014-06-13 18:03:56 +053025
Vinod Koul4fa80572014-10-15 20:12:56 +053026#include <sound/soc.h>
27#include <sound/tlv.h>
28
Vinod Koul61b165c2014-06-13 18:03:56 +053029enum {
30 MERR_DPCM_AUDIO = 0,
31 MERR_DPCM_COMPR,
32};
33
Vinod Kould8499c92014-08-04 15:15:55 +053034/* define a bit for each mixer input */
35#define SST_MIX_IP(x) (x)
36
37#define SST_IP_CODEC0 SST_MIX_IP(2)
38#define SST_IP_CODEC1 SST_MIX_IP(3)
39#define SST_IP_LOOP0 SST_MIX_IP(4)
40#define SST_IP_LOOP1 SST_MIX_IP(5)
41#define SST_IP_LOOP2 SST_MIX_IP(6)
42#define SST_IP_PROBE SST_MIX_IP(7)
43#define SST_IP_VOIP SST_MIX_IP(12)
44#define SST_IP_PCM0 SST_MIX_IP(13)
45#define SST_IP_PCM1 SST_MIX_IP(14)
46#define SST_IP_MEDIA0 SST_MIX_IP(17)
47#define SST_IP_MEDIA1 SST_MIX_IP(18)
48#define SST_IP_MEDIA2 SST_MIX_IP(19)
49#define SST_IP_MEDIA3 SST_MIX_IP(20)
50
51#define SST_IP_LAST SST_IP_MEDIA3
52
53#define SST_SWM_INPUT_COUNT (SST_IP_LAST + 1)
54#define SST_CMD_SWM_MAX_INPUTS 6
55
56#define SST_PATH_ID_SHIFT 8
57#define SST_DEFAULT_LOCATION_ID 0xFFFF
58#define SST_DEFAULT_CELL_NBR 0xFF
59#define SST_DEFAULT_MODULE_ID 0xFFFF
60
61/*
62 * Audio DSP Path Ids. Specified by the audio DSP FW
63 */
64enum sst_path_index {
65 SST_PATH_INDEX_CODEC_OUT0 = (0x02 << SST_PATH_ID_SHIFT),
66 SST_PATH_INDEX_CODEC_OUT1 = (0x03 << SST_PATH_ID_SHIFT),
67
68 SST_PATH_INDEX_SPROT_LOOP_OUT = (0x04 << SST_PATH_ID_SHIFT),
69 SST_PATH_INDEX_MEDIA_LOOP1_OUT = (0x05 << SST_PATH_ID_SHIFT),
70 SST_PATH_INDEX_MEDIA_LOOP2_OUT = (0x06 << SST_PATH_ID_SHIFT),
71
72 SST_PATH_INDEX_VOIP_OUT = (0x0C << SST_PATH_ID_SHIFT),
73 SST_PATH_INDEX_PCM0_OUT = (0x0D << SST_PATH_ID_SHIFT),
74 SST_PATH_INDEX_PCM1_OUT = (0x0E << SST_PATH_ID_SHIFT),
75 SST_PATH_INDEX_PCM2_OUT = (0x0F << SST_PATH_ID_SHIFT),
76
77 SST_PATH_INDEX_MEDIA0_OUT = (0x12 << SST_PATH_ID_SHIFT),
78 SST_PATH_INDEX_MEDIA1_OUT = (0x13 << SST_PATH_ID_SHIFT),
79
80
81 /* Start of input paths */
82 SST_PATH_INDEX_CODEC_IN0 = (0x82 << SST_PATH_ID_SHIFT),
83 SST_PATH_INDEX_CODEC_IN1 = (0x83 << SST_PATH_ID_SHIFT),
84
85 SST_PATH_INDEX_SPROT_LOOP_IN = (0x84 << SST_PATH_ID_SHIFT),
86 SST_PATH_INDEX_MEDIA_LOOP1_IN = (0x85 << SST_PATH_ID_SHIFT),
87 SST_PATH_INDEX_MEDIA_LOOP2_IN = (0x86 << SST_PATH_ID_SHIFT),
88
89 SST_PATH_INDEX_VOIP_IN = (0x8C << SST_PATH_ID_SHIFT),
90
91 SST_PATH_INDEX_PCM0_IN = (0x8D << SST_PATH_ID_SHIFT),
92 SST_PATH_INDEX_PCM1_IN = (0x8E << SST_PATH_ID_SHIFT),
93
94 SST_PATH_INDEX_MEDIA0_IN = (0x8F << SST_PATH_ID_SHIFT),
95 SST_PATH_INDEX_MEDIA1_IN = (0x90 << SST_PATH_ID_SHIFT),
96 SST_PATH_INDEX_MEDIA2_IN = (0x91 << SST_PATH_ID_SHIFT),
97
98 SST_PATH_INDEX_MEDIA3_IN = (0x9C << SST_PATH_ID_SHIFT),
99
100 SST_PATH_INDEX_RESERVED = (0xFF << SST_PATH_ID_SHIFT),
101};
102
103/*
104 * path IDs
105 */
106enum sst_swm_inputs {
107 SST_SWM_IN_CODEC0 = (SST_PATH_INDEX_CODEC_IN0 | SST_DEFAULT_CELL_NBR),
108 SST_SWM_IN_CODEC1 = (SST_PATH_INDEX_CODEC_IN1 | SST_DEFAULT_CELL_NBR),
109 SST_SWM_IN_SPROT_LOOP = (SST_PATH_INDEX_SPROT_LOOP_IN | SST_DEFAULT_CELL_NBR),
110 SST_SWM_IN_MEDIA_LOOP1 = (SST_PATH_INDEX_MEDIA_LOOP1_IN | SST_DEFAULT_CELL_NBR),
111 SST_SWM_IN_MEDIA_LOOP2 = (SST_PATH_INDEX_MEDIA_LOOP2_IN | SST_DEFAULT_CELL_NBR),
112 SST_SWM_IN_VOIP = (SST_PATH_INDEX_VOIP_IN | SST_DEFAULT_CELL_NBR),
113 SST_SWM_IN_PCM0 = (SST_PATH_INDEX_PCM0_IN | SST_DEFAULT_CELL_NBR),
114 SST_SWM_IN_PCM1 = (SST_PATH_INDEX_PCM1_IN | SST_DEFAULT_CELL_NBR),
115 SST_SWM_IN_MEDIA0 = (SST_PATH_INDEX_MEDIA0_IN | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
116 SST_SWM_IN_MEDIA1 = (SST_PATH_INDEX_MEDIA1_IN | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
117 SST_SWM_IN_MEDIA2 = (SST_PATH_INDEX_MEDIA2_IN | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
118 SST_SWM_IN_MEDIA3 = (SST_PATH_INDEX_MEDIA3_IN | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
119 SST_SWM_IN_END = (SST_PATH_INDEX_RESERVED | SST_DEFAULT_CELL_NBR)
120};
121
122/*
123 * path IDs
124 */
125enum sst_swm_outputs {
126 SST_SWM_OUT_CODEC0 = (SST_PATH_INDEX_CODEC_OUT0 | SST_DEFAULT_CELL_NBR),
127 SST_SWM_OUT_CODEC1 = (SST_PATH_INDEX_CODEC_OUT1 | SST_DEFAULT_CELL_NBR),
128 SST_SWM_OUT_SPROT_LOOP = (SST_PATH_INDEX_SPROT_LOOP_OUT | SST_DEFAULT_CELL_NBR),
129 SST_SWM_OUT_MEDIA_LOOP1 = (SST_PATH_INDEX_MEDIA_LOOP1_OUT | SST_DEFAULT_CELL_NBR),
130 SST_SWM_OUT_MEDIA_LOOP2 = (SST_PATH_INDEX_MEDIA_LOOP2_OUT | SST_DEFAULT_CELL_NBR),
131 SST_SWM_OUT_VOIP = (SST_PATH_INDEX_VOIP_OUT | SST_DEFAULT_CELL_NBR),
132 SST_SWM_OUT_PCM0 = (SST_PATH_INDEX_PCM0_OUT | SST_DEFAULT_CELL_NBR),
133 SST_SWM_OUT_PCM1 = (SST_PATH_INDEX_PCM1_OUT | SST_DEFAULT_CELL_NBR),
134 SST_SWM_OUT_PCM2 = (SST_PATH_INDEX_PCM2_OUT | SST_DEFAULT_CELL_NBR),
135 SST_SWM_OUT_MEDIA0 = (SST_PATH_INDEX_MEDIA0_OUT | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
136 SST_SWM_OUT_MEDIA1 = (SST_PATH_INDEX_MEDIA1_OUT | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
137 SST_SWM_OUT_END = (SST_PATH_INDEX_RESERVED | SST_DEFAULT_CELL_NBR),
138};
139
140enum sst_ipc_msg {
141 SST_IPC_IA_CMD = 1,
142 SST_IPC_IA_SET_PARAMS,
143 SST_IPC_IA_GET_PARAMS,
144};
145
146enum sst_cmd_type {
147 SST_CMD_BYTES_SET = 1,
148 SST_CMD_BYTES_GET = 2,
149};
150
151enum sst_task {
152 SST_TASK_SBA = 1,
153 SST_TASK_MMX,
154};
155
156enum sst_type {
157 SST_TYPE_CMD = 1,
158 SST_TYPE_PARAMS,
159};
160
161enum sst_flag {
162 SST_FLAG_BLOCKED = 1,
163 SST_FLAG_NONBLOCK,
164};
165
166/*
167 * Enumeration for indexing the gain cells in VB_SET_GAIN DSP command
168 */
169enum sst_gain_index {
170 /* GAIN IDs for SB task start here */
171 SST_GAIN_INDEX_CODEC_OUT0,
172 SST_GAIN_INDEX_CODEC_OUT1,
173 SST_GAIN_INDEX_CODEC_IN0,
174 SST_GAIN_INDEX_CODEC_IN1,
175
176 SST_GAIN_INDEX_SPROT_LOOP_OUT,
177 SST_GAIN_INDEX_MEDIA_LOOP1_OUT,
178 SST_GAIN_INDEX_MEDIA_LOOP2_OUT,
179
180 SST_GAIN_INDEX_PCM0_IN_LEFT,
181 SST_GAIN_INDEX_PCM0_IN_RIGHT,
182
183 SST_GAIN_INDEX_PCM1_OUT_LEFT,
184 SST_GAIN_INDEX_PCM1_OUT_RIGHT,
185 SST_GAIN_INDEX_PCM1_IN_LEFT,
186 SST_GAIN_INDEX_PCM1_IN_RIGHT,
187 SST_GAIN_INDEX_PCM2_OUT_LEFT,
188
189 SST_GAIN_INDEX_PCM2_OUT_RIGHT,
190 SST_GAIN_INDEX_VOIP_OUT,
191 SST_GAIN_INDEX_VOIP_IN,
192
193 /* Gain IDs for MMX task start here */
194 SST_GAIN_INDEX_MEDIA0_IN_LEFT,
195 SST_GAIN_INDEX_MEDIA0_IN_RIGHT,
196 SST_GAIN_INDEX_MEDIA1_IN_LEFT,
197 SST_GAIN_INDEX_MEDIA1_IN_RIGHT,
198
199 SST_GAIN_INDEX_MEDIA2_IN_LEFT,
200 SST_GAIN_INDEX_MEDIA2_IN_RIGHT,
201
202 SST_GAIN_INDEX_GAIN_END
203};
204
205/*
206 * Audio DSP module IDs specified by FW spec
207 * TODO: Update with all modules
208 */
209enum sst_module_id {
210 SST_MODULE_ID_PCM = 0x0001,
211 SST_MODULE_ID_MP3 = 0x0002,
212 SST_MODULE_ID_MP24 = 0x0003,
213 SST_MODULE_ID_AAC = 0x0004,
214 SST_MODULE_ID_AACP = 0x0005,
215 SST_MODULE_ID_EAACP = 0x0006,
216 SST_MODULE_ID_WMA9 = 0x0007,
217 SST_MODULE_ID_WMA10 = 0x0008,
218 SST_MODULE_ID_WMA10P = 0x0009,
219 SST_MODULE_ID_RA = 0x000A,
220 SST_MODULE_ID_DDAC3 = 0x000B,
221 SST_MODULE_ID_TRUE_HD = 0x000C,
222 SST_MODULE_ID_HD_PLUS = 0x000D,
223
224 SST_MODULE_ID_SRC = 0x0064,
225 SST_MODULE_ID_DOWNMIX = 0x0066,
226 SST_MODULE_ID_GAIN_CELL = 0x0067,
227 SST_MODULE_ID_SPROT = 0x006D,
228 SST_MODULE_ID_BASS_BOOST = 0x006E,
229 SST_MODULE_ID_STEREO_WDNG = 0x006F,
230 SST_MODULE_ID_AV_REMOVAL = 0x0070,
231 SST_MODULE_ID_MIC_EQ = 0x0071,
232 SST_MODULE_ID_SPL = 0x0072,
233 SST_MODULE_ID_ALGO_VTSV = 0x0073,
234 SST_MODULE_ID_NR = 0x0076,
235 SST_MODULE_ID_BWX = 0x0077,
236 SST_MODULE_ID_DRP = 0x0078,
237 SST_MODULE_ID_MDRP = 0x0079,
238
239 SST_MODULE_ID_ANA = 0x007A,
240 SST_MODULE_ID_AEC = 0x007B,
241 SST_MODULE_ID_NR_SNS = 0x007C,
242 SST_MODULE_ID_SER = 0x007D,
243 SST_MODULE_ID_AGC = 0x007E,
244
245 SST_MODULE_ID_CNI = 0x007F,
246 SST_MODULE_ID_CONTEXT_ALGO_AWARE = 0x0080,
247 SST_MODULE_ID_FIR_24 = 0x0081,
248 SST_MODULE_ID_IIR_24 = 0x0082,
249
250 SST_MODULE_ID_ASRC = 0x0083,
251 SST_MODULE_ID_TONE_GEN = 0x0084,
252 SST_MODULE_ID_BMF = 0x0086,
253 SST_MODULE_ID_EDL = 0x0087,
254 SST_MODULE_ID_GLC = 0x0088,
255
256 SST_MODULE_ID_FIR_16 = 0x0089,
257 SST_MODULE_ID_IIR_16 = 0x008A,
258 SST_MODULE_ID_DNR = 0x008B,
259
260 SST_MODULE_ID_VIRTUALIZER = 0x008C,
261 SST_MODULE_ID_VISUALIZATION = 0x008D,
262 SST_MODULE_ID_LOUDNESS_OPTIMIZER = 0x008E,
263 SST_MODULE_ID_REVERBERATION = 0x008F,
264
265 SST_MODULE_ID_CNI_TX = 0x0090,
266 SST_MODULE_ID_REF_LINE = 0x0091,
267 SST_MODULE_ID_VOLUME = 0x0092,
268 SST_MODULE_ID_FILT_DCR = 0x0094,
269 SST_MODULE_ID_SLV = 0x009A,
270 SST_MODULE_ID_NLF = 0x009B,
271 SST_MODULE_ID_TNR = 0x009C,
272 SST_MODULE_ID_WNR = 0x009D,
273
274 SST_MODULE_ID_LOG = 0xFF00,
275
276 SST_MODULE_ID_TASK = 0xFFFF,
277};
278
279enum sst_cmd {
280 SBA_IDLE = 14,
281 SBA_VB_SET_SPEECH_PATH = 26,
282 MMX_SET_GAIN = 33,
283 SBA_VB_SET_GAIN = 33,
284 FBA_VB_RX_CNI = 35,
285 MMX_SET_GAIN_TIMECONST = 36,
286 SBA_VB_SET_TIMECONST = 36,
287 SBA_VB_START = 85,
288 SBA_SET_SWM = 114,
289 SBA_SET_MDRP = 116,
290 SBA_HW_SET_SSP = 117,
291 SBA_SET_MEDIA_LOOP_MAP = 118,
292 SBA_SET_MEDIA_PATH = 119,
293 MMX_SET_MEDIA_PATH = 119,
294 SBA_VB_LPRO = 126,
295 SBA_VB_SET_FIR = 128,
296 SBA_VB_SET_IIR = 129,
297 SBA_SET_SSP_SLOT_MAP = 130,
298};
299
300enum sst_dsp_switch {
301 SST_SWITCH_OFF = 0,
302 SST_SWITCH_ON = 3,
303};
304
305enum sst_path_switch {
306 SST_PATH_OFF = 0,
307 SST_PATH_ON = 1,
308};
309
310enum sst_swm_state {
311 SST_SWM_OFF = 0,
312 SST_SWM_ON = 3,
313};
Vinod Koul61b165c2014-06-13 18:03:56 +0530314
Vinod Koul10615a52014-09-09 15:11:25 +0530315#define SST_FILL_LOCATION_IDS(dst, cell_idx, pipe_id) do { \
316 dst.location_id.p.cell_nbr_idx = (cell_idx); \
317 dst.location_id.p.path_id = (pipe_id); \
318 } while (0)
319#define SST_FILL_LOCATION_ID(dst, loc_id) (\
320 dst.location_id.f = (loc_id))
321#define SST_FILL_MODULE_ID(dst, mod_id) (\
322 dst.module_id = (mod_id))
323
324#define SST_FILL_DESTINATION1(dst, id) do { \
325 SST_FILL_LOCATION_ID(dst, (id) & 0xFFFF); \
326 SST_FILL_MODULE_ID(dst, ((id) & 0xFFFF0000) >> 16); \
327 } while (0)
328#define SST_FILL_DESTINATION2(dst, loc_id, mod_id) do { \
329 SST_FILL_LOCATION_ID(dst, loc_id); \
330 SST_FILL_MODULE_ID(dst, mod_id); \
331 } while (0)
332#define SST_FILL_DESTINATION3(dst, cell_idx, path_id, mod_id) do { \
333 SST_FILL_LOCATION_IDS(dst, cell_idx, path_id); \
334 SST_FILL_MODULE_ID(dst, mod_id); \
335 } while (0)
336
337#define SST_FILL_DESTINATION(level, dst, ...) \
338 SST_FILL_DESTINATION##level(dst, __VA_ARGS__)
339#define SST_FILL_DEFAULT_DESTINATION(dst) \
340 SST_FILL_DESTINATION(2, dst, SST_DEFAULT_LOCATION_ID, SST_DEFAULT_MODULE_ID)
341
342struct sst_destination_id {
343 union sst_location_id {
344 struct {
345 u8 cell_nbr_idx; /* module index */
346 u8 path_id; /* pipe_id */
347 } __packed p; /* part */
348 u16 f; /* full */
349 } __packed location_id;
350 u16 module_id;
351} __packed;
352struct sst_dsp_header {
353 struct sst_destination_id dst;
354 u16 command_id;
355 u16 length;
356} __packed;
357
358/*
359 *
360 * Common Commands
361 *
362 */
363struct sst_cmd_generic {
364 struct sst_dsp_header header;
365} __packed;
Vinod Koul4fa80572014-10-15 20:12:56 +0530366
367struct gain_cell {
368 struct sst_destination_id dest;
369 s16 cell_gain_left;
370 s16 cell_gain_right;
371 u16 gain_time_constant;
372} __packed;
373
374#define NUM_GAIN_CELLS 1
375struct sst_cmd_set_gain_dual {
376 struct sst_dsp_header header;
377 u16 gain_cell_num;
378 struct gain_cell cell_gains[NUM_GAIN_CELLS];
379} __packed;
Vinod Koul10615a52014-09-09 15:11:25 +0530380struct sst_cmd_set_params {
381 struct sst_destination_id dst;
382 u16 command_id;
383 char params[0];
384} __packed;
Vinod Koul4fa80572014-10-15 20:12:56 +0530385
386/**** widget defines *****/
387
388struct sst_ids {
389 u16 location_id;
390 u16 module_id;
391 u8 task_id;
392 u8 format;
393 u8 reg;
394 const char *parent_wname;
395 struct snd_soc_dapm_widget *parent_w;
396 struct list_head algo_list;
397 struct list_head gain_list;
398 const struct sst_pcm_format *pcm_fmt;
399};
400enum sst_gain_kcontrol_type {
401 SST_GAIN_TLV,
402 SST_GAIN_MUTE,
403 SST_GAIN_RAMP_DURATION,
404};
405
406struct sst_gain_mixer_control {
407 bool stereo;
408 enum sst_gain_kcontrol_type type;
409 struct sst_gain_value *gain_val;
410 int max;
411 int min;
412 u16 instance_id;
413 u16 module_id;
414 u16 pipe_id;
415 u16 task_id;
416 char pname[44];
417 struct snd_soc_dapm_widget *w;
418};
419
420struct sst_gain_value {
421 u16 ramp_duration;
422 s16 l_gain;
423 s16 r_gain;
424 bool mute;
425};
426#define SST_GAIN_VOLUME_DEFAULT (-1440)
427#define SST_GAIN_RAMP_DURATION_DEFAULT 5 /* timeconstant */
428#define SST_GAIN_MUTE_DEFAULT true
429
430#define SST_GAIN_KCONTROL_TLV(xname, xhandler_get, xhandler_put, \
431 xmod, xpipe, xinstance, xtask, tlv_array, xgain_val, \
432 xmin, xmax, xpname) \
433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
434 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
435 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
436 .tlv.p = (tlv_array), \
437 .info = sst_gain_ctl_info,\
438 .get = xhandler_get, .put = xhandler_put, \
439 .private_value = (unsigned long)&(struct sst_gain_mixer_control) \
440 { .stereo = true, .max = xmax, .min = xmin, .type = SST_GAIN_TLV, \
441 .module_id = xmod, .pipe_id = xpipe, .task_id = xtask,\
442 .instance_id = xinstance, .gain_val = xgain_val, .pname = xpname}
443
444#define SST_GAIN_KCONTROL_INT(xname, xhandler_get, xhandler_put, \
445 xmod, xpipe, xinstance, xtask, xtype, xgain_val, \
446 xmin, xmax, xpname) \
447 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
448 .info = sst_gain_ctl_info, \
449 .get = xhandler_get, .put = xhandler_put, \
450 .private_value = (unsigned long)&(struct sst_gain_mixer_control) \
451 { .stereo = false, .max = xmax, .min = xmin, .type = xtype, \
452 .module_id = xmod, .pipe_id = xpipe, .task_id = xtask,\
453 .instance_id = xinstance, .gain_val = xgain_val, .pname = xpname}
454
455#define SST_GAIN_KCONTROL_BOOL(xname, xhandler_get, xhandler_put,\
456 xmod, xpipe, xinstance, xtask, xgain_val, xpname) \
457 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
458 .info = snd_soc_info_bool_ext, \
459 .get = xhandler_get, .put = xhandler_put, \
460 .private_value = (unsigned long)&(struct sst_gain_mixer_control) \
461 { .stereo = false, .type = SST_GAIN_MUTE, \
462 .module_id = xmod, .pipe_id = xpipe, .task_id = xtask,\
463 .instance_id = xinstance, .gain_val = xgain_val, .pname = xpname}
Vinod Koul10615a52014-09-09 15:11:25 +0530464#define SST_CONTROL_NAME(xpname, xmname, xinstance, xtype) \
465 xpname " " xmname " " #xinstance " " xtype
466
467#define SST_COMBO_CONTROL_NAME(xpname, xmname, xinstance, xtype, xsubmodule) \
468 xpname " " xmname " " #xinstance " " xtype " " xsubmodule
Vinod Koul4fa80572014-10-15 20:12:56 +0530469
470/*
471 * 3 Controls for each Gain module
472 * e.g. - pcm0_in Gain 0 Volume
473 * - pcm0_in Gain 0 Ramp Delay
474 * - pcm0_in Gain 0 Switch
475 */
476#define SST_GAIN_KCONTROLS(xpname, xmname, xmin_gain, xmax_gain, xmin_tc, xmax_tc, \
477 xhandler_get, xhandler_put, \
478 xmod, xpipe, xinstance, xtask, tlv_array, xgain_val) \
479 { SST_GAIN_KCONTROL_INT(SST_CONTROL_NAME(xpname, xmname, xinstance, "Ramp Delay"), \
480 xhandler_get, xhandler_put, xmod, xpipe, xinstance, xtask, SST_GAIN_RAMP_DURATION, \
481 xgain_val, xmin_tc, xmax_tc, xpname) }, \
482 { SST_GAIN_KCONTROL_BOOL(SST_CONTROL_NAME(xpname, xmname, xinstance, "Switch"), \
483 xhandler_get, xhandler_put, xmod, xpipe, xinstance, xtask, \
484 xgain_val, xpname) } ,\
485 { SST_GAIN_KCONTROL_TLV(SST_CONTROL_NAME(xpname, xmname, xinstance, "Volume"), \
486 xhandler_get, xhandler_put, xmod, xpipe, xinstance, xtask, tlv_array, \
487 xgain_val, xmin_gain, xmax_gain, xpname) }
488
489#define SST_GAIN_TC_MIN 5
490#define SST_GAIN_TC_MAX 5000
491#define SST_GAIN_MIN_VALUE -1440 /* in 0.1 DB units */
492#define SST_GAIN_MAX_VALUE 360
493
Vinod Koul10615a52014-09-09 15:11:25 +0530494enum sst_algo_kcontrol_type {
495 SST_ALGO_PARAMS,
496 SST_ALGO_BYPASS,
497};
498
499struct sst_algo_control {
500 enum sst_algo_kcontrol_type type;
501 int max;
502 u16 module_id;
503 u16 pipe_id;
504 u16 task_id;
505 u16 cmd_id;
506 bool bypass;
507 unsigned char *params;
508 struct snd_soc_dapm_widget *w;
509};
510
511/* size of the control = size of params + size of length field */
512#define SST_ALGO_CTL_VALUE(xcount, xtype, xpipe, xmod, xtask, xcmd) \
513 (struct sst_algo_control){ \
514 .max = xcount + sizeof(u16), .type = xtype, .module_id = xmod, \
515 .pipe_id = xpipe, .task_id = xtask, .cmd_id = xcmd, \
516 }
517
518#define SST_ALGO_KCONTROL(xname, xcount, xmod, xpipe, \
519 xtask, xcmd, xtype, xinfo, xget, xput) \
520{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
521 .name = xname, \
522 .info = xinfo, .get = xget, .put = xput, \
523 .private_value = (unsigned long)& \
524 SST_ALGO_CTL_VALUE(xcount, xtype, xpipe, \
525 xmod, xtask, xcmd), \
526}
527
528#define SST_ALGO_KCONTROL_BYTES(xpname, xmname, xcount, xmod, \
529 xpipe, xinstance, xtask, xcmd) \
530 SST_ALGO_KCONTROL(SST_CONTROL_NAME(xpname, xmname, xinstance, "params"), \
531 xcount, xmod, xpipe, xtask, xcmd, SST_ALGO_PARAMS, \
532 sst_algo_bytes_ctl_info, \
533 sst_algo_control_get, sst_algo_control_set)
534
535#define SST_ALGO_KCONTROL_BOOL(xpname, xmname, xmod, xpipe, xinstance, xtask) \
536 SST_ALGO_KCONTROL(SST_CONTROL_NAME(xpname, xmname, xinstance, "bypass"), \
537 0, xmod, xpipe, xtask, 0, SST_ALGO_BYPASS, \
538 snd_soc_info_bool_ext, \
539 sst_algo_control_get, sst_algo_control_set)
540
541#define SST_ALGO_BYPASS_PARAMS(xpname, xmname, xcount, xmod, xpipe, \
542 xinstance, xtask, xcmd) \
543 SST_ALGO_KCONTROL_BOOL(xpname, xmname, xmod, xpipe, xinstance, xtask), \
544 SST_ALGO_KCONTROL_BYTES(xpname, xmname, xcount, xmod, xpipe, xinstance, xtask, xcmd)
545
546#define SST_COMBO_ALGO_KCONTROL_BYTES(xpname, xmname, xsubmod, xcount, xmod, \
547 xpipe, xinstance, xtask, xcmd) \
548 SST_ALGO_KCONTROL(SST_COMBO_CONTROL_NAME(xpname, xmname, xinstance, "params", \
549 xsubmod), \
550 xcount, xmod, xpipe, xtask, xcmd, SST_ALGO_PARAMS, \
551 sst_algo_bytes_ctl_info, \
552 sst_algo_control_get, sst_algo_control_set)
553
554
555struct sst_enum {
556 bool tx;
557 unsigned short reg;
558 unsigned int max;
559 const char * const *texts;
560 struct snd_soc_dapm_widget *w;
561};
562
Vinod Koul61b165c2014-06-13 18:03:56 +0530563#endif