diff options
author | Takashi Iwai <tiwai@suse.de> | 2017-02-07 06:17:23 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-02-07 09:12:37 -0500 |
commit | 77531beeb97d079fb422d2b78a0d75c564384310 (patch) | |
tree | a3137bab83c04a1f58911291fa9cc71fb820fb64 | |
parent | 1df989242d3d790aec79e72d12874bf763c958e1 (diff) |
ALSA: x86: Rearrange defines
We have two header files and everything is mixed up chaotically.
Move the chip-specific definitions like the hardware registers to
intel_hdmi_lpe_audio.h, and the rest, the implementation specific
stuff into intel_hdmi_audio.h.
In addition, put some more comments to the register fields, and fix
the incorrect name prefix for AUD_HDMI_STATUS bits, too.
The whole changes are merely a code shuffling, and there is no
functional change.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/x86/intel_hdmi_audio.c | 5 | ||||
-rw-r--r-- | sound/x86/intel_hdmi_audio.h | 64 | ||||
-rw-r--r-- | sound/x86/intel_hdmi_lpe_audio.h | 95 |
3 files changed, 83 insertions, 81 deletions
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c index 1022aaa005c4..34750c54663a 100644 --- a/sound/x86/intel_hdmi_audio.c +++ b/sound/x86/intel_hdmi_audio.c | |||
@@ -252,7 +252,8 @@ static void had_ack_irqs(struct snd_intelhad *ctx) | |||
252 | /* Reset buffer pointers */ | 252 | /* Reset buffer pointers */ |
253 | static void had_reset_audio(struct snd_intelhad *intelhaddata) | 253 | static void had_reset_audio(struct snd_intelhad *intelhaddata) |
254 | { | 254 | { |
255 | had_write_register(intelhaddata, AUD_HDMI_STATUS, 1); | 255 | had_write_register(intelhaddata, AUD_HDMI_STATUS, |
256 | AUD_HDMI_STATUSG_MASK_FUNCRST); | ||
256 | had_write_register(intelhaddata, AUD_HDMI_STATUS, 0); | 257 | had_write_register(intelhaddata, AUD_HDMI_STATUS, 0); |
257 | } | 258 | } |
258 | 259 | ||
@@ -989,7 +990,7 @@ static void wait_clear_underrun_bit(struct snd_intelhad *intelhaddata) | |||
989 | for (i = 0; i < MAX_CNT; i++) { | 990 | for (i = 0; i < MAX_CNT; i++) { |
990 | /* clear bit30, 31 AUD_HDMI_STATUS */ | 991 | /* clear bit30, 31 AUD_HDMI_STATUS */ |
991 | had_read_register(intelhaddata, AUD_HDMI_STATUS, &val); | 992 | had_read_register(intelhaddata, AUD_HDMI_STATUS, &val); |
992 | if (!(val & AUD_CONFIG_MASK_UNDERRUN)) | 993 | if (!(val & AUD_HDMI_STATUS_MASK_UNDERRUN)) |
993 | return; | 994 | return; |
994 | had_write_register(intelhaddata, AUD_HDMI_STATUS, val); | 995 | had_write_register(intelhaddata, AUD_HDMI_STATUS, val); |
995 | } | 996 | } |
diff --git a/sound/x86/intel_hdmi_audio.h b/sound/x86/intel_hdmi_audio.h index 7e2546b853ca..fe8d99cb839f 100644 --- a/sound/x86/intel_hdmi_audio.h +++ b/sound/x86/intel_hdmi_audio.h | |||
@@ -35,32 +35,50 @@ | |||
35 | #define PCM_INDEX 0 | 35 | #define PCM_INDEX 0 |
36 | #define MAX_PB_STREAMS 1 | 36 | #define MAX_PB_STREAMS 1 |
37 | #define MAX_CAP_STREAMS 0 | 37 | #define MAX_CAP_STREAMS 0 |
38 | |||
39 | #define HDMI_INFO_FRAME_WORD1 0x000a0184 | ||
40 | #define DP_INFO_FRAME_WORD1 0x00441b84 | ||
41 | #define FIFO_THRESHOLD 0xFE | ||
42 | #define DMA_FIFO_THRESHOLD 0x7 | ||
43 | #define BYTES_PER_WORD 0x4 | 38 | #define BYTES_PER_WORD 0x4 |
39 | #define INTEL_HAD "HdmiLpeAudio" | ||
40 | |||
41 | /* | ||
42 | * CEA speaker placement: | ||
43 | * | ||
44 | * FL FLC FC FRC FR | ||
45 | * | ||
46 | * LFE | ||
47 | * | ||
48 | * RL RLC RC RRC RR | ||
49 | * | ||
50 | * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M | ||
51 | * corresponds to CEA RL/RR; The SMPTE channel _assignment_ C/LFE is | ||
52 | * swapped to CEA LFE/FC. | ||
53 | */ | ||
54 | enum cea_speaker_placement { | ||
55 | FL = (1 << 0), /* Front Left */ | ||
56 | FC = (1 << 1), /* Front Center */ | ||
57 | FR = (1 << 2), /* Front Right */ | ||
58 | FLC = (1 << 3), /* Front Left Center */ | ||
59 | FRC = (1 << 4), /* Front Right Center */ | ||
60 | RL = (1 << 5), /* Rear Left */ | ||
61 | RC = (1 << 6), /* Rear Center */ | ||
62 | RR = (1 << 7), /* Rear Right */ | ||
63 | RLC = (1 << 8), /* Rear Left Center */ | ||
64 | RRC = (1 << 9), /* Rear Right Center */ | ||
65 | LFE = (1 << 10), /* Low Frequency Effect */ | ||
66 | }; | ||
44 | 67 | ||
45 | /* Sampling rate as per IEC60958 Ver 3 */ | 68 | struct cea_channel_speaker_allocation { |
46 | #define CH_STATUS_MAP_32KHZ 0x3 | 69 | int ca_index; |
47 | #define CH_STATUS_MAP_44KHZ 0x0 | 70 | int speakers[8]; |
48 | #define CH_STATUS_MAP_48KHZ 0x2 | ||
49 | #define CH_STATUS_MAP_88KHZ 0x8 | ||
50 | #define CH_STATUS_MAP_96KHZ 0xA | ||
51 | #define CH_STATUS_MAP_176KHZ 0xC | ||
52 | #define CH_STATUS_MAP_192KHZ 0xE | ||
53 | 71 | ||
54 | #define MAX_SMPL_WIDTH_20 0x0 | 72 | /* derived values, just for convenience */ |
55 | #define MAX_SMPL_WIDTH_24 0x1 | 73 | int channels; |
56 | #define SMPL_WIDTH_16BITS 0x1 | 74 | int spk_mask; |
57 | #define SMPL_WIDTH_24BITS 0x5 | 75 | }; |
58 | #define CHANNEL_ALLOCATION 0x1F | 76 | |
59 | #define VALID_DIP_WORDS 3 | 77 | struct channel_map_table { |
60 | #define LAYOUT0 0 | 78 | unsigned char map; /* ALSA API channel map position */ |
61 | #define LAYOUT1 1 | 79 | unsigned char cea_slot; /* CEA slot value */ |
62 | #define SWAP_LFE_CENTER 0x00fac4c8 | 80 | int spk_mask; /* speaker position bit mask */ |
63 | #define AUD_CONFIG_CH_MASK 0x70 | 81 | }; |
64 | 82 | ||
65 | struct pcm_stream_info { | 83 | struct pcm_stream_info { |
66 | struct snd_pcm_substream *substream; | 84 | struct snd_pcm_substream *substream; |
diff --git a/sound/x86/intel_hdmi_lpe_audio.h b/sound/x86/intel_hdmi_lpe_audio.h index 48cab1b84c7b..97bbca19333a 100644 --- a/sound/x86/intel_hdmi_lpe_audio.h +++ b/sound/x86/intel_hdmi_lpe_audio.h | |||
@@ -23,7 +23,6 @@ | |||
23 | #ifndef __INTEL_HDMI_LPE_AUDIO_H | 23 | #ifndef __INTEL_HDMI_LPE_AUDIO_H |
24 | #define __INTEL_HDMI_LPE_AUDIO_H | 24 | #define __INTEL_HDMI_LPE_AUDIO_H |
25 | 25 | ||
26 | #define HAD_MAX_DEVICES 1 | ||
27 | #define HAD_MIN_CHANNEL 2 | 26 | #define HAD_MIN_CHANNEL 2 |
28 | #define HAD_MAX_CHANNEL 8 | 27 | #define HAD_MAX_CHANNEL 8 |
29 | #define HAD_NUM_OF_RING_BUFS 4 | 28 | #define HAD_NUM_OF_RING_BUFS 4 |
@@ -55,9 +54,7 @@ | |||
55 | #define DIS_SAMPLE_RATE_74_25 74250 | 54 | #define DIS_SAMPLE_RATE_74_25 74250 |
56 | #define DIS_SAMPLE_RATE_148_5 148500 | 55 | #define DIS_SAMPLE_RATE_148_5 148500 |
57 | #define HAD_REG_WIDTH 0x08 | 56 | #define HAD_REG_WIDTH 0x08 |
58 | #define HAD_MAX_HW_BUFS 0x04 | ||
59 | #define HAD_MAX_DIP_WORDS 16 | 57 | #define HAD_MAX_DIP_WORDS 16 |
60 | #define INTEL_HAD "HdmiLpeAudio" | ||
61 | 58 | ||
62 | /* DP Link Rates */ | 59 | /* DP Link Rates */ |
63 | #define DP_2_7_GHZ 270000 | 60 | #define DP_2_7_GHZ 270000 |
@@ -112,72 +109,34 @@ enum hdmi_ctrl_reg_offset { | |||
112 | AUD_HDMIW_INFOFR = 0x68, /* v2 */ | 109 | AUD_HDMIW_INFOFR = 0x68, /* v2 */ |
113 | }; | 110 | }; |
114 | 111 | ||
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 | |||
157 | /* Audio configuration */ | 112 | /* Audio configuration */ |
158 | union aud_cfg { | 113 | union aud_cfg { |
159 | struct { | 114 | struct { |
160 | u32 aud_en:1; | 115 | u32 aud_en:1; |
161 | u32 layout:1; | 116 | u32 layout:1; /* LAYOUT[01], see below */ |
162 | u32 fmt:2; | 117 | u32 fmt:2; |
163 | u32 num_ch:3; | 118 | u32 num_ch:3; |
164 | u32 set:1; | 119 | u32 set:1; |
165 | u32 flat:1; | 120 | u32 flat:1; |
166 | u32 val_bit:1; | 121 | u32 val_bit:1; |
167 | u32 user_bit:1; | 122 | u32 user_bit:1; |
168 | u32 underrun:1; | 123 | u32 underrun:1; /* 0: send null packets, |
169 | u32 packet_mode:1; | 124 | * 1: send silence stream |
170 | u32 left_align:1; | 125 | */ |
171 | u32 bogus_sample:1; | 126 | u32 packet_mode:1; /* 0: 32bit container, 1: 16bit */ |
172 | u32 dp_modei:1; | 127 | u32 left_align:1; /* 0: MSB bits 0-23, 1: bits 8-31 */ |
128 | u32 bogus_sample:1; /* bogus sample for odd channels */ | ||
129 | u32 dp_modei:1; /* 0: HDMI, 1: DP */ | ||
173 | u32 rsvd:16; | 130 | u32 rsvd:16; |
174 | } regx; | 131 | } regx; |
175 | u32 regval; | 132 | u32 regval; |
176 | }; | 133 | }; |
177 | 134 | ||
178 | #define AUD_CONFIG_BLOCK_BIT (1 << 7) | ||
179 | #define AUD_CONFIG_VALID_BIT (1 << 9) | 135 | #define AUD_CONFIG_VALID_BIT (1 << 9) |
180 | #define AUD_CONFIG_DP_MODE (1 << 15) | 136 | #define AUD_CONFIG_DP_MODE (1 << 15) |
137 | #define AUD_CONFIG_CH_MASK 0x70 | ||
138 | #define LAYOUT0 0 /* interleaved stereo */ | ||
139 | #define LAYOUT1 1 /* for channels > 2 */ | ||
181 | 140 | ||
182 | /* Audio Channel Status 0 Attributes */ | 141 | /* Audio Channel Status 0 Attributes */ |
183 | union aud_ch_status_0 { | 142 | union aud_ch_status_0 { |
@@ -190,13 +149,22 @@ union aud_ch_status_0 { | |||
190 | u32 ctg_code:8; | 149 | u32 ctg_code:8; |
191 | u32 src_num:4; | 150 | u32 src_num:4; |
192 | u32 ch_num:4; | 151 | u32 ch_num:4; |
193 | u32 samp_freq:4; | 152 | u32 samp_freq:4; /* CH_STATUS_MAP_XXX */ |
194 | u32 clk_acc:2; | 153 | u32 clk_acc:2; |
195 | u32 rsvd:2; | 154 | u32 rsvd:2; |
196 | } regx; | 155 | } regx; |
197 | u32 regval; | 156 | u32 regval; |
198 | }; | 157 | }; |
199 | 158 | ||
159 | /* samp_freq values - Sampling rate as per IEC60958 Ver 3 */ | ||
160 | #define CH_STATUS_MAP_32KHZ 0x3 | ||
161 | #define CH_STATUS_MAP_44KHZ 0x0 | ||
162 | #define CH_STATUS_MAP_48KHZ 0x2 | ||
163 | #define CH_STATUS_MAP_88KHZ 0x8 | ||
164 | #define CH_STATUS_MAP_96KHZ 0xA | ||
165 | #define CH_STATUS_MAP_176KHZ 0xC | ||
166 | #define CH_STATUS_MAP_192KHZ 0xE | ||
167 | |||
200 | /* Audio Channel Status 1 Attributes */ | 168 | /* Audio Channel Status 1 Attributes */ |
201 | union aud_ch_status_1 { | 169 | union aud_ch_status_1 { |
202 | struct { | 170 | struct { |
@@ -207,6 +175,11 @@ union aud_ch_status_1 { | |||
207 | u32 regval; | 175 | u32 regval; |
208 | }; | 176 | }; |
209 | 177 | ||
178 | #define MAX_SMPL_WIDTH_20 0x0 | ||
179 | #define MAX_SMPL_WIDTH_24 0x1 | ||
180 | #define SMPL_WIDTH_16BITS 0x1 | ||
181 | #define SMPL_WIDTH_24BITS 0x5 | ||
182 | |||
210 | /* CTS register */ | 183 | /* CTS register */ |
211 | union aud_hdmi_cts { | 184 | union aud_hdmi_cts { |
212 | struct { | 185 | struct { |
@@ -239,6 +212,9 @@ union aud_buf_config { | |||
239 | u32 regval; | 212 | u32 regval; |
240 | }; | 213 | }; |
241 | 214 | ||
215 | #define FIFO_THRESHOLD 0xFE | ||
216 | #define DMA_FIFO_THRESHOLD 0x7 | ||
217 | |||
242 | /* Audio Sample Swapping offset */ | 218 | /* Audio Sample Swapping offset */ |
243 | union aud_buf_ch_swap { | 219 | union aud_buf_ch_swap { |
244 | struct { | 220 | struct { |
@@ -255,6 +231,8 @@ union aud_buf_ch_swap { | |||
255 | u32 regval; | 231 | u32 regval; |
256 | }; | 232 | }; |
257 | 233 | ||
234 | #define SWAP_LFE_CENTER 0x00fac4c8 /* octal 76543210 */ | ||
235 | |||
258 | /* Address for Audio Buffer */ | 236 | /* Address for Audio Buffer */ |
259 | union aud_buf_addr { | 237 | union aud_buf_addr { |
260 | struct { | 238 | struct { |
@@ -306,6 +284,9 @@ union aud_info_frame1 { | |||
306 | u32 regval; | 284 | u32 regval; |
307 | }; | 285 | }; |
308 | 286 | ||
287 | #define HDMI_INFO_FRAME_WORD1 0x000a0184 | ||
288 | #define DP_INFO_FRAME_WORD1 0x00441b84 | ||
289 | |||
309 | /* DIP frame 2 */ | 290 | /* DIP frame 2 */ |
310 | union aud_info_frame2 { | 291 | union aud_info_frame2 { |
311 | struct { | 292 | struct { |
@@ -333,13 +314,15 @@ union aud_info_frame3 { | |||
333 | u32 regval; | 314 | u32 regval; |
334 | }; | 315 | }; |
335 | 316 | ||
317 | #define VALID_DIP_WORDS 3 | ||
318 | |||
336 | /* AUD_HDMI_STATUS bits */ | 319 | /* AUD_HDMI_STATUS bits */ |
337 | #define HDMI_AUDIO_UNDERRUN (1U << 31) | 320 | #define HDMI_AUDIO_UNDERRUN (1U << 31) |
338 | #define HDMI_AUDIO_BUFFER_DONE (1U << 29) | 321 | #define HDMI_AUDIO_BUFFER_DONE (1U << 29) |
339 | 322 | ||
340 | /* AUD_HDMI_STATUS register mask */ | 323 | /* AUD_HDMI_STATUS register mask */ |
341 | #define AUD_CONFIG_MASK_UNDERRUN 0xC0000000 | 324 | #define AUD_HDMI_STATUS_MASK_UNDERRUN 0xC0000000 |
342 | #define AUD_CONFIG_MASK_SRDBG 0x00000002 | 325 | #define AUD_HDMI_STATUS_MASK_SRDBG 0x00000002 |
343 | #define AUD_CONFIG_MASK_FUNCRST 0x00000001 | 326 | #define AUD_HDMI_STATUSG_MASK_FUNCRST 0x00000001 |
344 | 327 | ||
345 | #endif | 328 | #endif |