Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 1 | /* |
| 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 Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 26 | #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 Iwai | e1b239f3 | 2017-02-03 00:01:18 +0100 | [diff] [blame^] | 31 | /* 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 Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 38 | #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 Bossart | 964ca80 | 2017-01-31 14:16:52 -0600 | [diff] [blame] | 62 | /* 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 Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 85 | /* HDMI Controller register offsets - audio domain common */ |
| 86 | /* Base address for below regs = 0x65000 */ |
| 87 | enum hdmi_ctrl_reg_offset_common { |
Takashi Iwai | 03c3437 | 2017-02-02 16:19:03 +0100 | [diff] [blame] | 88 | AUDIO_HDMI_CONFIG_A = 0x000, |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 89 | AUDIO_HDMI_CONFIG_B = 0x800, |
| 90 | AUDIO_HDMI_CONFIG_C = 0x900, |
| 91 | }; |
| 92 | /* HDMI controller register offsets */ |
Takashi Iwai | 4151ee8 | 2017-01-31 18:14:15 +0100 | [diff] [blame] | 93 | enum hdmi_ctrl_reg_offset { |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 94 | 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 Iwai | 4151ee8 | 2017-01-31 18:14:15 +0100 | [diff] [blame] | 111 | AUD_HDMI_STATUS = 0x64, /* v2 */ |
| 112 | AUD_HDMIW_INFOFR = 0x68, /* v2 */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 113 | }; |
| 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 | */ |
| 128 | enum 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 | |
| 142 | struct 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 | |
| 151 | struct 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 Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 157 | /* Audio configuration */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 158 | union aud_cfg { |
| 159 | struct { |
| 160 | u32 aud_en:1; |
| 161 | u32 layout:1; |
| 162 | u32 fmt:2; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 163 | 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 Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 174 | } regx; |
| 175 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 176 | }; |
| 177 | |
Takashi Iwai | 03c3437 | 2017-02-02 16:19:03 +0100 | [diff] [blame] | 178 | #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 Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 182 | /* Audio Channel Status 0 Attributes */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 183 | union 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 Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 196 | } regx; |
| 197 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 198 | }; |
| 199 | |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 200 | /* Audio Channel Status 1 Attributes */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 201 | union aud_ch_status_1 { |
| 202 | struct { |
| 203 | u32 max_wrd_len:1; |
| 204 | u32 wrd_len:3; |
| 205 | u32 rsvd:28; |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 206 | } regx; |
| 207 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 208 | }; |
| 209 | |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 210 | /* CTS register */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 211 | union aud_hdmi_cts { |
| 212 | struct { |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 213 | u32 cts_val:24; |
| 214 | u32 en_cts_prog:1; |
| 215 | u32 rsvd:7; |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 216 | } regx; |
| 217 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 218 | }; |
| 219 | |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 220 | /* N register */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 221 | union aud_hdmi_n_enable { |
| 222 | struct { |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 223 | u32 n_val:24; |
| 224 | u32 en_n_prog:1; |
| 225 | u32 rsvd:7; |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 226 | } regx; |
| 227 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 228 | }; |
| 229 | |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 230 | /* Audio Buffer configurations */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 231 | union aud_buf_config { |
| 232 | struct { |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 233 | 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 Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 238 | } regx; |
| 239 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 240 | }; |
| 241 | |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 242 | /* Audio Sample Swapping offset */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 243 | union 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 Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 254 | } regx; |
| 255 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 256 | }; |
| 257 | |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 258 | /* Address for Audio Buffer */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 259 | union aud_buf_addr { |
| 260 | struct { |
| 261 | u32 valid:1; |
| 262 | u32 intr_en:1; |
| 263 | u32 rsvd:4; |
| 264 | u32 addr:26; |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 265 | } regx; |
| 266 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 267 | }; |
| 268 | |
Takashi Iwai | e1b239f3 | 2017-02-03 00:01:18 +0100 | [diff] [blame^] | 269 | #define AUD_BUF_VALID (1U << 0) |
| 270 | #define AUD_BUF_INTR_EN (1U << 1) |
| 271 | |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 272 | /* Length of Audio Buffer */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 273 | union aud_buf_len { |
| 274 | struct { |
| 275 | u32 buf_len:20; |
| 276 | u32 rsvd:12; |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 277 | } regx; |
| 278 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 279 | }; |
| 280 | |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 281 | /* Audio Control State Register offset */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 282 | union 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 Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 294 | } regx; |
| 295 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 296 | }; |
| 297 | |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 298 | /* Audio HDMI Widget Data Island Packet offset */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 299 | union aud_info_frame1 { |
| 300 | struct { |
| 301 | u32 pkt_type:8; |
| 302 | u32 ver_num:8; |
| 303 | u32 len:5; |
| 304 | u32 rsvd:11; |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 305 | } regx; |
| 306 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 307 | }; |
| 308 | |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 309 | /* DIP frame 2 */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 310 | union 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 Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 320 | } regx; |
| 321 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 322 | }; |
| 323 | |
Takashi Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 324 | /* DIP frame 3 */ |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 325 | union 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 Iwai | 7ceba75 | 2017-02-02 15:58:35 +0100 | [diff] [blame] | 332 | } regx; |
| 333 | u32 regval; |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 334 | }; |
| 335 | |
Takashi Iwai | 03c3437 | 2017-02-02 16:19:03 +0100 | [diff] [blame] | 336 | /* AUD_HDMI_STATUS bits */ |
| 337 | #define HDMI_AUDIO_UNDERRUN (1U << 31) |
| 338 | #define HDMI_AUDIO_BUFFER_DONE (1U << 29) |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 339 | |
Takashi Iwai | 03c3437 | 2017-02-02 16:19:03 +0100 | [diff] [blame] | 340 | /* 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 Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 344 | |
Jerome Anand | 287599c | 2017-01-25 04:27:51 +0530 | [diff] [blame] | 345 | #endif |