2 * intel_hdmi_lpe_audio.h - Intel HDMI LPE audio driver
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 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
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.
21 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 #ifndef __INTEL_HDMI_LPE_AUDIO_H
24 #define __INTEL_HDMI_LPE_AUDIO_H
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
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 */
38 #define HAD_FIFO_SIZE 0 /* fifo not being used */
39 #define MAX_SPEAKERS 8
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
49 #define HAD_MIN_RATE AUD_SAMPLE_RATE_32
50 #define HAD_MAX_RATE AUD_SAMPLE_RATE_192
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"
63 #define DP_2_7_GHZ 270000
64 #define DP_1_62_GHZ 162000
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
83 #define DP_NAUD_VAL 32768
85 /* HDMI Controller register offsets - audio domain common */
86 /* Base address for below regs = 0x65000 */
87 enum hdmi_ctrl_reg_offset_common {
88 AUDIO_HDMI_CONFIG_A = 0x000,
89 AUDIO_HDMI_CONFIG_B = 0x800,
90 AUDIO_HDMI_CONFIG_C = 0x900,
92 /* HDMI controller register offsets */
93 enum hdmi_ctrl_reg_offset {
95 AUD_CH_STATUS_0 = 0x08,
96 AUD_CH_STATUS_1 = 0x0C,
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,
111 AUD_HDMI_STATUS = 0x64, /* v2 */
112 AUD_HDMIW_INFOFR = 0x68, /* v2 */
116 * CEA speaker placement:
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.
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 */
142 struct cea_channel_speaker_allocation {
146 /* derived values, just for convenience */
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 */
157 /* Audio configuration */
178 #define AUD_CONFIG_BLOCK_BIT (1 << 7)
179 #define AUD_CONFIG_VALID_BIT (1 << 9)
180 #define AUD_CONFIG_DP_MODE (1 << 15)
182 /* Audio Channel Status 0 Attributes */
183 union aud_ch_status_0 {
200 /* Audio Channel Status 1 Attributes */
201 union aud_ch_status_1 {
221 union aud_hdmi_n_enable {
230 /* Audio Buffer configurations */
231 union aud_buf_config {
233 u32 audio_fifo_watermark:8;
234 u32 dma_fifo_watermark:3;
242 /* Audio Sample Swapping offset */
243 union aud_buf_ch_swap {
258 /* Address for Audio Buffer */
269 #define AUD_BUF_VALID (1U << 0)
270 #define AUD_BUF_INTR_EN (1U << 1)
272 /* Length of Audio Buffer */
281 /* Audio Control State Register offset */
298 /* Audio HDMI Widget Data Island Packet offset */
299 union aud_info_frame1 {
310 union aud_info_frame2 {
325 union aud_info_frame3 {
336 /* AUD_HDMI_STATUS bits */
337 #define HDMI_AUDIO_UNDERRUN (1U << 31)
338 #define HDMI_AUDIO_BUFFER_DONE (1U << 29)
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