blob: 387511f12d858505f99090d872735413ad38905f [file] [log] [blame]
Mark Browna4b12992014-03-12 23:04:35 +00001/*
2 * Intel SST Haswell/Broadwell IPC Support
3 *
4 * Copyright (C) 2013, Intel Corporation. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#ifndef __SST_HASWELL_IPC_H
18#define __SST_HASWELL_IPC_H
19
20#include <linux/types.h>
21#include <linux/kernel.h>
22#include <linux/platform_device.h>
23
Jie Yangf74e2c92014-11-03 21:59:37 +080024#define SST_HSW_NO_CHANNELS 4
Mark Browna4b12992014-03-12 23:04:35 +000025#define SST_HSW_MAX_DX_REGIONS 14
Liam Girdwoodaed3c7b2014-10-29 17:40:42 +000026#define SST_HSW_DX_CONTEXT_SIZE (640 * 1024)
Mark Browna4b12992014-03-12 23:04:35 +000027
28#define SST_HSW_FW_LOG_CONFIG_DWORDS 12
29#define SST_HSW_GLOBAL_LOG 15
30
31/**
32 * Upfront defined maximum message size that is
33 * expected by the in/out communication pipes in FW.
34 */
35#define SST_HSW_IPC_MAX_PAYLOAD_SIZE 400
36#define SST_HSW_MAX_INFO_SIZE 64
37#define SST_HSW_BUILD_HASH_LENGTH 40
38
39struct sst_hsw;
40struct sst_hsw_stream;
41struct sst_hsw_log_stream;
42struct sst_pdata;
43struct sst_module;
Liam Girdwoode9600bc2014-10-28 17:37:12 +000044struct sst_module_runtime;
Mark Browna4b12992014-03-12 23:04:35 +000045extern struct sst_ops haswell_ops;
46
47/* Stream Allocate Path ID */
48enum sst_hsw_stream_path_id {
49 SST_HSW_STREAM_PATH_SSP0_OUT = 0,
50 SST_HSW_STREAM_PATH_SSP0_IN = 1,
51 SST_HSW_STREAM_PATH_MAX_PATH_ID = 2,
52};
53
54/* Stream Allocate Stream Type */
55enum sst_hsw_stream_type {
56 SST_HSW_STREAM_TYPE_RENDER = 0,
57 SST_HSW_STREAM_TYPE_SYSTEM = 1,
58 SST_HSW_STREAM_TYPE_CAPTURE = 2,
59 SST_HSW_STREAM_TYPE_LOOPBACK = 3,
60 SST_HSW_STREAM_TYPE_MAX_STREAM_TYPE = 4,
61};
62
63/* Stream Allocate Stream Format */
64enum sst_hsw_stream_format {
65 SST_HSW_STREAM_FORMAT_PCM_FORMAT = 0,
66 SST_HSW_STREAM_FORMAT_MP3_FORMAT = 1,
67 SST_HSW_STREAM_FORMAT_AAC_FORMAT = 2,
68 SST_HSW_STREAM_FORMAT_MAX_FORMAT_ID = 3,
69};
70
71/* Device ID */
72enum sst_hsw_device_id {
73 SST_HSW_DEVICE_SSP_0 = 0,
74 SST_HSW_DEVICE_SSP_1 = 1,
75};
76
77/* Device Master Clock Frequency */
78enum sst_hsw_device_mclk {
79 SST_HSW_DEVICE_MCLK_OFF = 0,
80 SST_HSW_DEVICE_MCLK_FREQ_6_MHZ = 1,
81 SST_HSW_DEVICE_MCLK_FREQ_12_MHZ = 2,
82 SST_HSW_DEVICE_MCLK_FREQ_24_MHZ = 3,
83};
84
85/* Device Clock Master */
86enum sst_hsw_device_mode {
87 SST_HSW_DEVICE_CLOCK_SLAVE = 0,
88 SST_HSW_DEVICE_CLOCK_MASTER = 1,
Liam Girdwoodf07e51c2014-10-16 15:29:15 +010089 SST_HSW_DEVICE_TDM_CLOCK_MASTER = 2,
Mark Browna4b12992014-03-12 23:04:35 +000090};
91
92/* DX Power State */
93enum sst_hsw_dx_state {
94 SST_HSW_DX_STATE_D0 = 0,
95 SST_HSW_DX_STATE_D1 = 1,
96 SST_HSW_DX_STATE_D3 = 3,
97 SST_HSW_DX_STATE_MAX = 3,
98};
99
100/* Audio stream stage IDs */
101enum sst_hsw_fx_stage_id {
102 SST_HSW_STAGE_ID_WAVES = 0,
103 SST_HSW_STAGE_ID_DTS = 1,
104 SST_HSW_STAGE_ID_DOLBY = 2,
105 SST_HSW_STAGE_ID_BOOST = 3,
106 SST_HSW_STAGE_ID_MAX_FX_ID
107};
108
109/* DX State Type */
110enum sst_hsw_dx_type {
111 SST_HSW_DX_TYPE_FW_IMAGE = 0,
112 SST_HSW_DX_TYPE_MEMORY_DUMP = 1
113};
114
115/* Volume Curve Type*/
116enum sst_hsw_volume_curve {
117 SST_HSW_VOLUME_CURVE_NONE = 0,
118 SST_HSW_VOLUME_CURVE_FADE = 1
119};
120
121/* Sample ordering */
122enum sst_hsw_interleaving {
123 SST_HSW_INTERLEAVING_PER_CHANNEL = 0,
124 SST_HSW_INTERLEAVING_PER_SAMPLE = 1,
125};
126
127/* Channel indices */
128enum sst_hsw_channel_index {
129 SST_HSW_CHANNEL_LEFT = 0,
130 SST_HSW_CHANNEL_CENTER = 1,
131 SST_HSW_CHANNEL_RIGHT = 2,
132 SST_HSW_CHANNEL_LEFT_SURROUND = 3,
133 SST_HSW_CHANNEL_CENTER_SURROUND = 3,
134 SST_HSW_CHANNEL_RIGHT_SURROUND = 4,
135 SST_HSW_CHANNEL_LFE = 7,
136 SST_HSW_CHANNEL_INVALID = 0xF,
137};
138
139/* List of supported channel maps. */
140enum sst_hsw_channel_config {
141 SST_HSW_CHANNEL_CONFIG_MONO = 0, /* mono only. */
142 SST_HSW_CHANNEL_CONFIG_STEREO = 1, /* L & R. */
143 SST_HSW_CHANNEL_CONFIG_2_POINT_1 = 2, /* L, R & LFE; PCM only. */
144 SST_HSW_CHANNEL_CONFIG_3_POINT_0 = 3, /* L, C & R; MP3 & AAC only. */
145 SST_HSW_CHANNEL_CONFIG_3_POINT_1 = 4, /* L, C, R & LFE; PCM only. */
146 SST_HSW_CHANNEL_CONFIG_QUATRO = 5, /* L, R, Ls & Rs; PCM only. */
147 SST_HSW_CHANNEL_CONFIG_4_POINT_0 = 6, /* L, C, R & Cs; MP3 & AAC only. */
148 SST_HSW_CHANNEL_CONFIG_5_POINT_0 = 7, /* L, C, R, Ls & Rs. */
149 SST_HSW_CHANNEL_CONFIG_5_POINT_1 = 8, /* L, C, R, Ls, Rs & LFE. */
150 SST_HSW_CHANNEL_CONFIG_DUAL_MONO = 9, /* One channel replicated in two. */
151 SST_HSW_CHANNEL_CONFIG_INVALID,
152};
153
154/* List of supported bit depths. */
155enum sst_hsw_bitdepth {
156 SST_HSW_DEPTH_8BIT = 8,
157 SST_HSW_DEPTH_16BIT = 16,
158 SST_HSW_DEPTH_24BIT = 24, /* Default. */
159 SST_HSW_DEPTH_32BIT = 32,
160 SST_HSW_DEPTH_INVALID = 33,
161};
162
163enum sst_hsw_module_id {
164 SST_HSW_MODULE_BASE_FW = 0x0,
165 SST_HSW_MODULE_MP3 = 0x1,
166 SST_HSW_MODULE_AAC_5_1 = 0x2,
167 SST_HSW_MODULE_AAC_2_0 = 0x3,
168 SST_HSW_MODULE_SRC = 0x4,
169 SST_HSW_MODULE_WAVES = 0x5,
170 SST_HSW_MODULE_DOLBY = 0x6,
171 SST_HSW_MODULE_BOOST = 0x7,
172 SST_HSW_MODULE_LPAL = 0x8,
173 SST_HSW_MODULE_DTS = 0x9,
174 SST_HSW_MODULE_PCM_CAPTURE = 0xA,
175 SST_HSW_MODULE_PCM_SYSTEM = 0xB,
176 SST_HSW_MODULE_PCM_REFERENCE = 0xC,
177 SST_HSW_MODULE_PCM = 0xD,
178 SST_HSW_MODULE_BLUETOOTH_RENDER_MODULE = 0xE,
179 SST_HSW_MODULE_BLUETOOTH_CAPTURE_MODULE = 0xF,
180 SST_HSW_MAX_MODULE_ID,
181};
182
183enum sst_hsw_performance_action {
184 SST_HSW_PERF_START = 0,
185 SST_HSW_PERF_STOP = 1,
186};
187
188/* SST firmware module info */
189struct sst_hsw_module_info {
190 u8 name[SST_HSW_MAX_INFO_SIZE];
191 u8 version[SST_HSW_MAX_INFO_SIZE];
192} __attribute__((packed));
193
194/* Module entry point */
195struct sst_hsw_module_entry {
196 enum sst_hsw_module_id module_id;
197 u32 entry_point;
198} __attribute__((packed));
199
200/* Module map - alignement matches DSP */
201struct sst_hsw_module_map {
202 u8 module_entries_count;
203 struct sst_hsw_module_entry module_entries[1];
204} __attribute__((packed));
205
206struct sst_hsw_memory_info {
207 u32 offset;
208 u32 size;
209} __attribute__((packed));
210
211struct sst_hsw_fx_enable {
212 struct sst_hsw_module_map module_map;
213 struct sst_hsw_memory_info persistent_mem;
214} __attribute__((packed));
215
216struct sst_hsw_get_fx_param {
217 u32 parameter_id;
218 u32 param_size;
219} __attribute__((packed));
220
221struct sst_hsw_perf_action {
222 u32 action;
223} __attribute__((packed));
224
225struct sst_hsw_perf_data {
226 u64 timestamp;
227 u64 cycles;
228 u64 datatime;
229} __attribute__((packed));
230
231/* FW version */
232struct sst_hsw_ipc_fw_version {
233 u8 build;
234 u8 minor;
235 u8 major;
236 u8 type;
237 u8 fw_build_hash[SST_HSW_BUILD_HASH_LENGTH];
238 u32 fw_log_providers_hash;
239} __attribute__((packed));
240
241/* Stream ring info */
242struct sst_hsw_ipc_stream_ring {
243 u32 ring_pt_address;
244 u32 num_pages;
245 u32 ring_size;
246 u32 ring_offset;
247 u32 ring_first_pfn;
248} __attribute__((packed));
249
250/* Debug Dump Log Enable Request */
251struct sst_hsw_ipc_debug_log_enable_req {
252 struct sst_hsw_ipc_stream_ring ringinfo;
253 u32 config[SST_HSW_FW_LOG_CONFIG_DWORDS];
254} __attribute__((packed));
255
256/* Debug Dump Log Reply */
257struct sst_hsw_ipc_debug_log_reply {
258 u32 log_buffer_begining;
259 u32 log_buffer_size;
260} __attribute__((packed));
261
262/* Stream glitch position */
263struct sst_hsw_ipc_stream_glitch_position {
264 u32 glitch_type;
265 u32 present_pos;
266 u32 write_pos;
267} __attribute__((packed));
268
269/* Stream get position */
270struct sst_hsw_ipc_stream_get_position {
271 u32 position;
272 u32 fw_cycle_count;
273} __attribute__((packed));
274
275/* Stream set position */
276struct sst_hsw_ipc_stream_set_position {
277 u32 position;
278 u32 end_of_buffer;
279} __attribute__((packed));
280
281/* Stream Free Request */
282struct sst_hsw_ipc_stream_free_req {
283 u8 stream_id;
284 u8 reserved[3];
285} __attribute__((packed));
286
287/* Set Volume Request */
288struct sst_hsw_ipc_volume_req {
289 u32 channel;
290 u32 target_volume;
291 u64 curve_duration;
292 u32 curve_type;
293} __attribute__((packed));
294
295/* Device Configuration Request */
296struct sst_hsw_ipc_device_config_req {
297 u32 ssp_interface;
298 u32 clock_frequency;
299 u32 mode;
300 u16 clock_divider;
Liam Girdwoodf07e51c2014-10-16 15:29:15 +0100301 u8 channels;
302 u8 reserved;
Mark Browna4b12992014-03-12 23:04:35 +0000303} __attribute__((packed));
304
305/* Audio Data formats */
306struct sst_hsw_audio_data_format_ipc {
307 u32 frequency;
308 u32 bitdepth;
309 u32 map;
310 u32 config;
311 u32 style;
312 u8 ch_num;
313 u8 valid_bit;
314 u8 reserved[2];
315} __attribute__((packed));
316
317/* Stream Allocate Request */
318struct sst_hsw_ipc_stream_alloc_req {
319 u8 path_id;
320 u8 stream_type;
321 u8 format_id;
322 u8 reserved;
323 struct sst_hsw_audio_data_format_ipc format;
324 struct sst_hsw_ipc_stream_ring ringinfo;
325 struct sst_hsw_module_map map;
326 struct sst_hsw_memory_info persistent_mem;
327 struct sst_hsw_memory_info scratch_mem;
328 u32 number_of_notifications;
329} __attribute__((packed));
330
331/* Stream Allocate Reply */
332struct sst_hsw_ipc_stream_alloc_reply {
333 u32 stream_hw_id;
334 u32 mixer_hw_id; // returns rate ????
335 u32 read_position_register_address;
336 u32 presentation_position_register_address;
337 u32 peak_meter_register_address[SST_HSW_NO_CHANNELS];
338 u32 volume_register_address[SST_HSW_NO_CHANNELS];
339} __attribute__((packed));
340
341/* Get Mixer Stream Info */
342struct sst_hsw_ipc_stream_info_reply {
343 u32 mixer_hw_id;
344 u32 peak_meter_register_address[SST_HSW_NO_CHANNELS];
345 u32 volume_register_address[SST_HSW_NO_CHANNELS];
346} __attribute__((packed));
347
348/* DX State Request */
349struct sst_hsw_ipc_dx_req {
350 u8 state;
351 u8 reserved[3];
352} __attribute__((packed));
353
354/* DX State Reply Memory Info Item */
355struct sst_hsw_ipc_dx_memory_item {
356 u32 offset;
357 u32 size;
358 u32 source;
359} __attribute__((packed));
360
361/* DX State Reply */
362struct sst_hsw_ipc_dx_reply {
363 u32 entries_no;
364 struct sst_hsw_ipc_dx_memory_item mem_info[SST_HSW_MAX_DX_REGIONS];
365} __attribute__((packed));
366
367struct sst_hsw_ipc_fw_version;
368
369/* SST Init & Free */
370struct sst_hsw *sst_hsw_new(struct device *dev, const u8 *fw, size_t fw_length,
371 u32 fw_offset);
372void sst_hsw_free(struct sst_hsw *hsw);
373int sst_hsw_fw_get_version(struct sst_hsw *hsw,
374 struct sst_hsw_ipc_fw_version *version);
375u32 create_channel_map(enum sst_hsw_channel_config config);
376
377/* Stream Mixer Controls - */
378int sst_hsw_stream_mute(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
379 u32 stage_id, u32 channel);
380int sst_hsw_stream_unmute(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
381 u32 stage_id, u32 channel);
382
383int sst_hsw_stream_set_volume(struct sst_hsw *hsw,
384 struct sst_hsw_stream *stream, u32 stage_id, u32 channel, u32 volume);
385int sst_hsw_stream_get_volume(struct sst_hsw *hsw,
386 struct sst_hsw_stream *stream, u32 stage_id, u32 channel, u32 *volume);
387
388int sst_hsw_stream_set_volume_curve(struct sst_hsw *hsw,
389 struct sst_hsw_stream *stream, u64 curve_duration,
390 enum sst_hsw_volume_curve curve);
391
392/* Global Mixer Controls - */
393int sst_hsw_mixer_mute(struct sst_hsw *hsw, u32 stage_id, u32 channel);
394int sst_hsw_mixer_unmute(struct sst_hsw *hsw, u32 stage_id, u32 channel);
395
396int sst_hsw_mixer_set_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel,
397 u32 volume);
398int sst_hsw_mixer_get_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel,
399 u32 *volume);
400
401int sst_hsw_mixer_set_volume_curve(struct sst_hsw *hsw,
402 u64 curve_duration, enum sst_hsw_volume_curve curve);
403
404/* Stream API */
405struct sst_hsw_stream *sst_hsw_stream_new(struct sst_hsw *hsw, int id,
406 u32 (*get_write_position)(struct sst_hsw_stream *stream, void *data),
407 void *data);
408
409int sst_hsw_stream_free(struct sst_hsw *hsw, struct sst_hsw_stream *stream);
410
411/* Stream Configuration */
412int sst_hsw_stream_format(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
413 enum sst_hsw_stream_path_id path_id,
414 enum sst_hsw_stream_type stream_type,
415 enum sst_hsw_stream_format format_id);
416
417int sst_hsw_stream_buffer(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
418 u32 ring_pt_address, u32 num_pages,
419 u32 ring_size, u32 ring_offset, u32 ring_first_pfn);
420
421int sst_hsw_stream_commit(struct sst_hsw *hsw, struct sst_hsw_stream *stream);
422
423int sst_hsw_stream_set_valid(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
424 u32 bits);
425int sst_hsw_stream_set_rate(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
426 int rate);
427int sst_hsw_stream_set_bits(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
428 enum sst_hsw_bitdepth bits);
429int sst_hsw_stream_set_channels(struct sst_hsw *hsw,
430 struct sst_hsw_stream *stream, int channels);
431int sst_hsw_stream_set_map_config(struct sst_hsw *hsw,
432 struct sst_hsw_stream *stream, u32 map,
433 enum sst_hsw_channel_config config);
434int sst_hsw_stream_set_style(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
435 enum sst_hsw_interleaving style);
436int sst_hsw_stream_set_module_info(struct sst_hsw *hsw,
Liam Girdwoode9600bc2014-10-28 17:37:12 +0000437 struct sst_hsw_stream *stream, struct sst_module_runtime *runtime);
Mark Browna4b12992014-03-12 23:04:35 +0000438int sst_hsw_stream_set_pmemory_info(struct sst_hsw *hsw,
439 struct sst_hsw_stream *stream, u32 offset, u32 size);
440int sst_hsw_stream_set_smemory_info(struct sst_hsw *hsw,
441 struct sst_hsw_stream *stream, u32 offset, u32 size);
442int sst_hsw_stream_get_hw_id(struct sst_hsw *hsw,
443 struct sst_hsw_stream *stream);
444int sst_hsw_stream_get_mixer_id(struct sst_hsw *hsw,
445 struct sst_hsw_stream *stream);
446u32 sst_hsw_stream_get_read_reg(struct sst_hsw *hsw,
447 struct sst_hsw_stream *stream);
448u32 sst_hsw_stream_get_pointer_reg(struct sst_hsw *hsw,
449 struct sst_hsw_stream *stream);
450u32 sst_hsw_stream_get_peak_reg(struct sst_hsw *hsw,
451 struct sst_hsw_stream *stream, u32 channel);
452u32 sst_hsw_stream_get_vol_reg(struct sst_hsw *hsw,
453 struct sst_hsw_stream *stream, u32 channel);
454int sst_hsw_mixer_get_info(struct sst_hsw *hsw);
455
456/* Stream ALSA trigger operations */
457int sst_hsw_stream_pause(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
458 int wait);
459int sst_hsw_stream_resume(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
460 int wait);
461int sst_hsw_stream_reset(struct sst_hsw *hsw, struct sst_hsw_stream *stream);
462
463/* Stream pointer positions */
464int sst_hsw_stream_get_read_pos(struct sst_hsw *hsw,
465 struct sst_hsw_stream *stream, u32 *position);
466int sst_hsw_stream_get_write_pos(struct sst_hsw *hsw,
467 struct sst_hsw_stream *stream, u32 *position);
468int sst_hsw_stream_set_write_position(struct sst_hsw *hsw,
469 struct sst_hsw_stream *stream, u32 stage_id, u32 position);
Liam Girdwood51b4e242014-05-02 16:56:33 +0100470u32 sst_hsw_get_dsp_position(struct sst_hsw *hsw,
471 struct sst_hsw_stream *stream);
472u64 sst_hsw_get_dsp_presentation_position(struct sst_hsw *hsw,
Mark Browna4b12992014-03-12 23:04:35 +0000473 struct sst_hsw_stream *stream);
474
475/* HW port config */
476int sst_hsw_device_set_config(struct sst_hsw *hsw,
477 enum sst_hsw_device_id dev, enum sst_hsw_device_mclk mclk,
478 enum sst_hsw_device_mode mode, u32 clock_divider);
479
480/* DX Config */
481int sst_hsw_dx_set_state(struct sst_hsw *hsw,
482 enum sst_hsw_dx_state state, struct sst_hsw_ipc_dx_reply *dx);
483int sst_hsw_dx_get_state(struct sst_hsw *hsw, u32 item,
484 u32 *offset, u32 *size, u32 *source);
485
486/* init */
487int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata);
488void sst_hsw_dsp_free(struct device *dev, struct sst_pdata *pdata);
489struct sst_dsp *sst_hsw_get_dsp(struct sst_hsw *hsw);
Liam Girdwoode9600bc2014-10-28 17:37:12 +0000490
491/* runtime module management */
492struct sst_module_runtime *sst_hsw_runtime_module_create(struct sst_hsw *hsw,
493 int mod_id, int offset);
494void sst_hsw_runtime_module_free(struct sst_module_runtime *runtime);
Mark Browna4b12992014-03-12 23:04:35 +0000495
Liam Girdwoodaed3c7b2014-10-29 17:40:42 +0000496/* PM */
497int sst_hsw_dsp_runtime_resume(struct sst_hsw *hsw);
498int sst_hsw_dsp_runtime_suspend(struct sst_hsw *hsw);
499int sst_hsw_dsp_load(struct sst_hsw *hsw);
500int sst_hsw_dsp_runtime_sleep(struct sst_hsw *hsw);
501
Mark Browna4b12992014-03-12 23:04:35 +0000502#endif