blob: ca4212dca94ecaf411f918b9e40086c66e26103e [file] [log] [blame]
Jerome Anand287599c2017-01-25 04:27:51 +05301/*
2 * intel_hdmi_lpe_audio.h - Intel HDMI LPE audio driver
3 *
4 * Copyright (C) 2016 Intel Corp
5 * Authors: Sailaja Bandarupalli <sailaja.bandarupalli@intel.com>
6 * Ramesh Babu K V <ramesh.babu@intel.com>
7 * Vaibhav Agarwal <vaibhav.agarwal@intel.com>
8 * Jerome Anand <jerome.anand@intel.com>
9 * Aravind Siddappaji <aravindx.siddappaji@intel.com>
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2 of the License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 */
23#ifndef __INTEL_HDMI_LPE_AUDIO_H
24#define __INTEL_HDMI_LPE_AUDIO_H
25
Jerome Anand287599c2017-01-25 04:27:51 +053026#define HAD_MAX_DEVICES 1
27#define HAD_MIN_CHANNEL 2
28#define HAD_MAX_CHANNEL 8
29#define HAD_NUM_OF_RING_BUFS 4
30
Takashi Iwaie1b239f32017-02-03 00:01:18 +010031/* max 20bit address, aligned to 64 */
32#define HAD_MAX_BUFFER ((1024 * 1024 - 1) & ~0x3f)
33#define HAD_DEFAULT_BUFFER (600 * 1024) /* default prealloc size */
34#define HAD_MAX_PERIODS 256 /* arbitrary, but should suffice */
35#define HAD_MIN_PERIODS 2
36#define HAD_MAX_PERIOD_BYTES ((HAD_MAX_BUFFER / HAD_MIN_PERIODS) & ~0x3f)
37#define HAD_MIN_PERIOD_BYTES 1024 /* might be smaller */
Jerome Anand287599c2017-01-25 04:27:51 +053038#define HAD_FIFO_SIZE 0 /* fifo not being used */
39#define MAX_SPEAKERS 8
40
41#define AUD_SAMPLE_RATE_32 32000
42#define AUD_SAMPLE_RATE_44_1 44100
43#define AUD_SAMPLE_RATE_48 48000
44#define AUD_SAMPLE_RATE_88_2 88200
45#define AUD_SAMPLE_RATE_96 96000
46#define AUD_SAMPLE_RATE_176_4 176400
47#define AUD_SAMPLE_RATE_192 192000
48
49#define HAD_MIN_RATE AUD_SAMPLE_RATE_32
50#define HAD_MAX_RATE AUD_SAMPLE_RATE_192
51
52#define DIS_SAMPLE_RATE_25_2 25200
53#define DIS_SAMPLE_RATE_27 27000
54#define DIS_SAMPLE_RATE_54 54000
55#define DIS_SAMPLE_RATE_74_25 74250
56#define DIS_SAMPLE_RATE_148_5 148500
57#define HAD_REG_WIDTH 0x08
58#define HAD_MAX_HW_BUFS 0x04
59#define HAD_MAX_DIP_WORDS 16
60#define INTEL_HAD "IntelHdmiLpeAudio"
61
Pierre-Louis Bossart964ca802017-01-31 14:16:52 -060062/* DP Link Rates */
63#define DP_2_7_GHZ 270000
64#define DP_1_62_GHZ 162000
65
66/* Maud Values */
67#define AUD_SAMPLE_RATE_32_DP_2_7_MAUD_VAL 1988
68#define AUD_SAMPLE_RATE_44_1_DP_2_7_MAUD_VAL 2740
69#define AUD_SAMPLE_RATE_48_DP_2_7_MAUD_VAL 2982
70#define AUD_SAMPLE_RATE_88_2_DP_2_7_MAUD_VAL 5480
71#define AUD_SAMPLE_RATE_96_DP_2_7_MAUD_VAL 5965
72#define AUD_SAMPLE_RATE_176_4_DP_2_7_MAUD_VAL 10961
73#define HAD_MAX_RATE_DP_2_7_MAUD_VAL 11930
74#define AUD_SAMPLE_RATE_32_DP_1_62_MAUD_VAL 3314
75#define AUD_SAMPLE_RATE_44_1_DP_1_62_MAUD_VAL 4567
76#define AUD_SAMPLE_RATE_48_DP_1_62_MAUD_VAL 4971
77#define AUD_SAMPLE_RATE_88_2_DP_1_62_MAUD_VAL 9134
78#define AUD_SAMPLE_RATE_96_DP_1_62_MAUD_VAL 9942
79#define AUD_SAMPLE_RATE_176_4_DP_1_62_MAUD_VAL 18268
80#define HAD_MAX_RATE_DP_1_62_MAUD_VAL 19884
81
82/* Naud Value */
83#define DP_NAUD_VAL 32768
84
Jerome Anand287599c2017-01-25 04:27:51 +053085/* HDMI Controller register offsets - audio domain common */
86/* Base address for below regs = 0x65000 */
87enum hdmi_ctrl_reg_offset_common {
Takashi Iwai03c34372017-02-02 16:19:03 +010088 AUDIO_HDMI_CONFIG_A = 0x000,
Jerome Anand287599c2017-01-25 04:27:51 +053089 AUDIO_HDMI_CONFIG_B = 0x800,
90 AUDIO_HDMI_CONFIG_C = 0x900,
91};
92/* HDMI controller register offsets */
Takashi Iwai4151ee82017-01-31 18:14:15 +010093enum hdmi_ctrl_reg_offset {
Jerome Anand287599c2017-01-25 04:27:51 +053094 AUD_CONFIG = 0x0,
95 AUD_CH_STATUS_0 = 0x08,
96 AUD_CH_STATUS_1 = 0x0C,
97 AUD_HDMI_CTS = 0x10,
98 AUD_N_ENABLE = 0x14,
99 AUD_SAMPLE_RATE = 0x18,
100 AUD_BUF_CONFIG = 0x20,
101 AUD_BUF_CH_SWAP = 0x24,
102 AUD_BUF_A_ADDR = 0x40,
103 AUD_BUF_A_LENGTH = 0x44,
104 AUD_BUF_B_ADDR = 0x48,
105 AUD_BUF_B_LENGTH = 0x4c,
106 AUD_BUF_C_ADDR = 0x50,
107 AUD_BUF_C_LENGTH = 0x54,
108 AUD_BUF_D_ADDR = 0x58,
109 AUD_BUF_D_LENGTH = 0x5c,
110 AUD_CNTL_ST = 0x60,
Takashi Iwai4151ee82017-01-31 18:14:15 +0100111 AUD_HDMI_STATUS = 0x64, /* v2 */
112 AUD_HDMIW_INFOFR = 0x68, /* v2 */
Jerome Anand287599c2017-01-25 04:27:51 +0530113};
114
115/*
116 * CEA speaker placement:
117 *
118 * FL FLC FC FRC FR
119 *
120 * LFE
121 *
122 * RL RLC RC RRC RR
123 *
124 * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M
125 * corresponds to CEA RL/RR; The SMPTE channel _assignment_ C/LFE is
126 * swapped to CEA LFE/FC.
127 */
128enum cea_speaker_placement {
129 FL = (1 << 0), /* Front Left */
130 FC = (1 << 1), /* Front Center */
131 FR = (1 << 2), /* Front Right */
132 FLC = (1 << 3), /* Front Left Center */
133 FRC = (1 << 4), /* Front Right Center */
134 RL = (1 << 5), /* Rear Left */
135 RC = (1 << 6), /* Rear Center */
136 RR = (1 << 7), /* Rear Right */
137 RLC = (1 << 8), /* Rear Left Center */
138 RRC = (1 << 9), /* Rear Right Center */
139 LFE = (1 << 10), /* Low Frequency Effect */
140};
141
142struct cea_channel_speaker_allocation {
143 int ca_index;
144 int speakers[8];
145
146 /* derived values, just for convenience */
147 int channels;
148 int spk_mask;
149};
150
151struct channel_map_table {
152 unsigned char map; /* ALSA API channel map position */
153 unsigned char cea_slot; /* CEA slot value */
154 int spk_mask; /* speaker position bit mask */
155};
156
Takashi Iwai7ceba752017-02-02 15:58:35 +0100157/* Audio configuration */
Jerome Anand287599c2017-01-25 04:27:51 +0530158union aud_cfg {
159 struct {
160 u32 aud_en:1;
161 u32 layout:1;
162 u32 fmt:2;
Jerome Anand287599c2017-01-25 04:27:51 +0530163 u32 num_ch:3;
164 u32 set:1;
165 u32 flat:1;
166 u32 val_bit:1;
167 u32 user_bit:1;
168 u32 underrun:1;
169 u32 packet_mode:1;
170 u32 left_align:1;
171 u32 bogus_sample:1;
172 u32 dp_modei:1;
173 u32 rsvd:16;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100174 } regx;
175 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530176};
177
Takashi Iwai03c34372017-02-02 16:19:03 +0100178#define AUD_CONFIG_BLOCK_BIT (1 << 7)
179#define AUD_CONFIG_VALID_BIT (1 << 9)
180#define AUD_CONFIG_DP_MODE (1 << 15)
181
Takashi Iwai7ceba752017-02-02 15:58:35 +0100182/* Audio Channel Status 0 Attributes */
Jerome Anand287599c2017-01-25 04:27:51 +0530183union aud_ch_status_0 {
184 struct {
185 u32 ch_status:1;
186 u32 lpcm_id:1;
187 u32 cp_info:1;
188 u32 format:3;
189 u32 mode:2;
190 u32 ctg_code:8;
191 u32 src_num:4;
192 u32 ch_num:4;
193 u32 samp_freq:4;
194 u32 clk_acc:2;
195 u32 rsvd:2;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100196 } regx;
197 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530198};
199
Takashi Iwai7ceba752017-02-02 15:58:35 +0100200/* Audio Channel Status 1 Attributes */
Jerome Anand287599c2017-01-25 04:27:51 +0530201union aud_ch_status_1 {
202 struct {
203 u32 max_wrd_len:1;
204 u32 wrd_len:3;
205 u32 rsvd:28;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100206 } regx;
207 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530208};
209
Takashi Iwai7ceba752017-02-02 15:58:35 +0100210/* CTS register */
Jerome Anand287599c2017-01-25 04:27:51 +0530211union aud_hdmi_cts {
212 struct {
Jerome Anand287599c2017-01-25 04:27:51 +0530213 u32 cts_val:24;
214 u32 en_cts_prog:1;
215 u32 rsvd:7;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100216 } regx;
217 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530218};
219
Takashi Iwai7ceba752017-02-02 15:58:35 +0100220/* N register */
Jerome Anand287599c2017-01-25 04:27:51 +0530221union aud_hdmi_n_enable {
222 struct {
Jerome Anand287599c2017-01-25 04:27:51 +0530223 u32 n_val:24;
224 u32 en_n_prog:1;
225 u32 rsvd:7;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100226 } regx;
227 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530228};
229
Takashi Iwai7ceba752017-02-02 15:58:35 +0100230/* Audio Buffer configurations */
Jerome Anand287599c2017-01-25 04:27:51 +0530231union aud_buf_config {
232 struct {
Jerome Anand287599c2017-01-25 04:27:51 +0530233 u32 audio_fifo_watermark:8;
234 u32 dma_fifo_watermark:3;
235 u32 rsvd0:5;
236 u32 aud_delay:8;
237 u32 rsvd1:8;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100238 } regx;
239 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530240};
241
Takashi Iwai7ceba752017-02-02 15:58:35 +0100242/* Audio Sample Swapping offset */
Jerome Anand287599c2017-01-25 04:27:51 +0530243union aud_buf_ch_swap {
244 struct {
245 u32 first_0:3;
246 u32 second_0:3;
247 u32 first_1:3;
248 u32 second_1:3;
249 u32 first_2:3;
250 u32 second_2:3;
251 u32 first_3:3;
252 u32 second_3:3;
253 u32 rsvd:8;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100254 } regx;
255 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530256};
257
Takashi Iwai7ceba752017-02-02 15:58:35 +0100258/* Address for Audio Buffer */
Jerome Anand287599c2017-01-25 04:27:51 +0530259union aud_buf_addr {
260 struct {
261 u32 valid:1;
262 u32 intr_en:1;
263 u32 rsvd:4;
264 u32 addr:26;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100265 } regx;
266 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530267};
268
Takashi Iwaie1b239f32017-02-03 00:01:18 +0100269#define AUD_BUF_VALID (1U << 0)
270#define AUD_BUF_INTR_EN (1U << 1)
271
Takashi Iwai7ceba752017-02-02 15:58:35 +0100272/* Length of Audio Buffer */
Jerome Anand287599c2017-01-25 04:27:51 +0530273union aud_buf_len {
274 struct {
275 u32 buf_len:20;
276 u32 rsvd:12;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100277 } regx;
278 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530279};
280
Takashi Iwai7ceba752017-02-02 15:58:35 +0100281/* Audio Control State Register offset */
Jerome Anand287599c2017-01-25 04:27:51 +0530282union aud_ctrl_st {
283 struct {
284 u32 ram_addr:4;
285 u32 eld_ack:1;
286 u32 eld_addr:4;
287 u32 eld_buf_size:5;
288 u32 eld_valid:1;
289 u32 cp_ready:1;
290 u32 dip_freq:2;
291 u32 dip_idx:3;
292 u32 dip_en_sta:4;
293 u32 rsvd:7;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100294 } regx;
295 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530296};
297
Takashi Iwai7ceba752017-02-02 15:58:35 +0100298/* Audio HDMI Widget Data Island Packet offset */
Jerome Anand287599c2017-01-25 04:27:51 +0530299union aud_info_frame1 {
300 struct {
301 u32 pkt_type:8;
302 u32 ver_num:8;
303 u32 len:5;
304 u32 rsvd:11;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100305 } regx;
306 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530307};
308
Takashi Iwai7ceba752017-02-02 15:58:35 +0100309/* DIP frame 2 */
Jerome Anand287599c2017-01-25 04:27:51 +0530310union aud_info_frame2 {
311 struct {
312 u32 chksum:8;
313 u32 chnl_cnt:3;
314 u32 rsvd0:1;
315 u32 coding_type:4;
316 u32 smpl_size:2;
317 u32 smpl_freq:3;
318 u32 rsvd1:3;
319 u32 format:8;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100320 } regx;
321 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530322};
323
Takashi Iwai7ceba752017-02-02 15:58:35 +0100324/* DIP frame 3 */
Jerome Anand287599c2017-01-25 04:27:51 +0530325union aud_info_frame3 {
326 struct {
327 u32 chnl_alloc:8;
328 u32 rsvd0:3;
329 u32 lsv:4;
330 u32 dm_inh:1;
331 u32 rsvd1:16;
Takashi Iwai7ceba752017-02-02 15:58:35 +0100332 } regx;
333 u32 regval;
Jerome Anand287599c2017-01-25 04:27:51 +0530334};
335
Takashi Iwai03c34372017-02-02 16:19:03 +0100336/* AUD_HDMI_STATUS bits */
337#define HDMI_AUDIO_UNDERRUN (1U << 31)
338#define HDMI_AUDIO_BUFFER_DONE (1U << 29)
Jerome Anand287599c2017-01-25 04:27:51 +0530339
Takashi Iwai03c34372017-02-02 16:19:03 +0100340/* AUD_HDMI_STATUS register mask */
341#define AUD_CONFIG_MASK_UNDERRUN 0xC0000000
342#define AUD_CONFIG_MASK_SRDBG 0x00000002
343#define AUD_CONFIG_MASK_FUNCRST 0x00000001
Jerome Anand287599c2017-01-25 04:27:51 +0530344
Jerome Anand287599c2017-01-25 04:27:51 +0530345#endif