Rev 5271 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5271 | Rev 6104 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright 2013 Advanced Micro Devices, Inc. |
2 | * Copyright 2013 Advanced Micro Devices, Inc. |
3 | * |
3 | * |
4 | * Permission is hereby granted, free of charge, to any person obtaining a |
4 | * Permission is hereby granted, free of charge, to any person obtaining a |
5 | * copy of this software and associated documentation files (the "Software"), |
5 | * copy of this software and associated documentation files (the "Software"), |
6 | * to deal in the Software without restriction, including without limitation |
6 | * to deal in the Software without restriction, including without limitation |
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
8 | * and/or sell copies of the Software, and to permit persons to whom the |
8 | * and/or sell copies of the Software, and to permit persons to whom the |
9 | * Software is furnished to do so, subject to the following conditions: |
9 | * Software is furnished to do so, subject to the following conditions: |
10 | * |
10 | * |
11 | * The above copyright notice and this permission notice shall be included in |
11 | * The above copyright notice and this permission notice shall be included in |
12 | * all copies or substantial portions of the Software. |
12 | * all copies or substantial portions of the Software. |
13 | * |
13 | * |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
20 | * OTHER DEALINGS IN THE SOFTWARE. |
20 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | * |
21 | * |
22 | */ |
22 | */ |
23 | #include |
23 | #include |
24 | #include |
24 | #include |
25 | #include "radeon.h" |
25 | #include "radeon.h" |
- | 26 | #include "radeon_audio.h" |
|
26 | #include "sid.h" |
27 | #include "sid.h" |
- | 28 | ||
- | 29 | #define DCE8_DCCG_AUDIO_DTO1_PHASE 0x05b8 |
|
- | 30 | #define DCE8_DCCG_AUDIO_DTO1_MODULE 0x05bc |
|
27 | 31 | ||
28 | static u32 dce6_endpoint_rreg(struct radeon_device *rdev, |
32 | u32 dce6_endpoint_rreg(struct radeon_device *rdev, |
29 | u32 block_offset, u32 reg) |
33 | u32 block_offset, u32 reg) |
30 | { |
34 | { |
31 | unsigned long flags; |
35 | unsigned long flags; |
32 | u32 r; |
36 | u32 r; |
33 | 37 | ||
34 | spin_lock_irqsave(&rdev->end_idx_lock, flags); |
38 | spin_lock_irqsave(&rdev->end_idx_lock, flags); |
35 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg); |
39 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg); |
36 | r = RREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset); |
40 | r = RREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset); |
37 | spin_unlock_irqrestore(&rdev->end_idx_lock, flags); |
41 | spin_unlock_irqrestore(&rdev->end_idx_lock, flags); |
38 | 42 | ||
39 | return r; |
43 | return r; |
40 | } |
44 | } |
41 | 45 | ||
42 | static void dce6_endpoint_wreg(struct radeon_device *rdev, |
46 | void dce6_endpoint_wreg(struct radeon_device *rdev, |
43 | u32 block_offset, u32 reg, u32 v) |
47 | u32 block_offset, u32 reg, u32 v) |
44 | { |
48 | { |
45 | unsigned long flags; |
49 | unsigned long flags; |
46 | 50 | ||
47 | spin_lock_irqsave(&rdev->end_idx_lock, flags); |
51 | spin_lock_irqsave(&rdev->end_idx_lock, flags); |
48 | if (ASIC_IS_DCE8(rdev)) |
52 | if (ASIC_IS_DCE8(rdev)) |
49 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg); |
53 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg); |
50 | else |
54 | else |
51 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, |
55 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, |
52 | AZ_ENDPOINT_REG_WRITE_EN | AZ_ENDPOINT_REG_INDEX(reg)); |
56 | AZ_ENDPOINT_REG_WRITE_EN | AZ_ENDPOINT_REG_INDEX(reg)); |
53 | WREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset, v); |
57 | WREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset, v); |
54 | spin_unlock_irqrestore(&rdev->end_idx_lock, flags); |
58 | spin_unlock_irqrestore(&rdev->end_idx_lock, flags); |
55 | } |
59 | } |
56 | - | ||
57 | #define RREG32_ENDPOINT(block, reg) dce6_endpoint_rreg(rdev, (block), (reg)) |
- | |
58 | #define WREG32_ENDPOINT(block, reg, v) dce6_endpoint_wreg(rdev, (block), (reg), (v)) |
- | |
59 | - | ||
60 | 60 | ||
61 | static void dce6_afmt_get_connected_pins(struct radeon_device *rdev) |
61 | static void dce6_afmt_get_connected_pins(struct radeon_device *rdev) |
62 | { |
62 | { |
63 | int i; |
63 | int i; |
64 | u32 offset, tmp; |
64 | u32 offset, tmp; |
65 | 65 | ||
66 | for (i = 0; i < rdev->audio.num_pins; i++) { |
66 | for (i = 0; i < rdev->audio.num_pins; i++) { |
67 | offset = rdev->audio.pin[i].offset; |
67 | offset = rdev->audio.pin[i].offset; |
68 | tmp = RREG32_ENDPOINT(offset, |
68 | tmp = RREG32_ENDPOINT(offset, |
69 | AZ_F0_CODEC_PIN_CONTROL_RESPONSE_CONFIGURATION_DEFAULT); |
69 | AZ_F0_CODEC_PIN_CONTROL_RESPONSE_CONFIGURATION_DEFAULT); |
70 | if (((tmp & PORT_CONNECTIVITY_MASK) >> PORT_CONNECTIVITY_SHIFT) == 1) |
70 | if (((tmp & PORT_CONNECTIVITY_MASK) >> PORT_CONNECTIVITY_SHIFT) == 1) |
71 | rdev->audio.pin[i].connected = false; |
71 | rdev->audio.pin[i].connected = false; |
72 | else |
72 | else |
73 | rdev->audio.pin[i].connected = true; |
73 | rdev->audio.pin[i].connected = true; |
74 | } |
74 | } |
75 | } |
75 | } |
76 | 76 | ||
77 | struct r600_audio_pin *dce6_audio_get_pin(struct radeon_device *rdev) |
77 | struct r600_audio_pin *dce6_audio_get_pin(struct radeon_device *rdev) |
78 | { |
78 | { |
- | 79 | struct drm_encoder *encoder; |
|
- | 80 | struct radeon_encoder *radeon_encoder; |
|
- | 81 | struct radeon_encoder_atom_dig *dig; |
|
- | 82 | struct r600_audio_pin *pin = NULL; |
|
79 | int i; |
83 | int i, pin_count; |
80 | 84 | ||
81 | dce6_afmt_get_connected_pins(rdev); |
85 | dce6_afmt_get_connected_pins(rdev); |
82 | 86 | ||
83 | for (i = 0; i < rdev->audio.num_pins; i++) { |
87 | for (i = 0; i < rdev->audio.num_pins; i++) { |
84 | if (rdev->audio.pin[i].connected) |
88 | if (rdev->audio.pin[i].connected) { |
85 | return &rdev->audio.pin[i]; |
89 | pin = &rdev->audio.pin[i]; |
- | 90 | pin_count = 0; |
|
- | 91 | ||
- | 92 | list_for_each_entry(encoder, &rdev->ddev->mode_config.encoder_list, head) { |
|
- | 93 | if (radeon_encoder_is_digital(encoder)) { |
|
- | 94 | radeon_encoder = to_radeon_encoder(encoder); |
|
- | 95 | dig = radeon_encoder->enc_priv; |
|
- | 96 | if (dig->pin == pin) |
|
- | 97 | pin_count++; |
|
86 | } |
98 | } |
- | 99 | } |
|
- | 100 | ||
- | 101 | if (pin_count == 0) |
|
- | 102 | return pin; |
|
- | 103 | } |
|
- | 104 | } |
|
- | 105 | if (!pin) |
|
87 | DRM_ERROR("No connected audio pins found!\n"); |
106 | DRM_ERROR("No connected audio pins found!\n"); |
88 | return NULL; |
107 | return pin; |
89 | } |
108 | } |
90 | 109 | ||
91 | void dce6_afmt_select_pin(struct drm_encoder *encoder) |
110 | void dce6_afmt_select_pin(struct drm_encoder *encoder) |
92 | { |
111 | { |
93 | struct radeon_device *rdev = encoder->dev->dev_private; |
112 | struct radeon_device *rdev = encoder->dev->dev_private; |
94 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
113 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
95 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
114 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
96 | u32 offset; |
- | |
97 | 115 | ||
98 | if (!dig || !dig->afmt || !dig->afmt->pin) |
116 | if (!dig || !dig->afmt || !dig->pin) |
99 | return; |
- | |
100 | - | ||
101 | offset = dig->afmt->offset; |
117 | return; |
102 | 118 | ||
103 | WREG32(AFMT_AUDIO_SRC_CONTROL + offset, |
119 | WREG32(AFMT_AUDIO_SRC_CONTROL + dig->afmt->offset, |
104 | AFMT_AUDIO_SRC_SELECT(dig->afmt->pin->id)); |
120 | AFMT_AUDIO_SRC_SELECT(dig->pin->id)); |
105 | } |
121 | } |
106 | 122 | ||
107 | void dce6_afmt_write_latency_fields(struct drm_encoder *encoder, |
123 | void dce6_afmt_write_latency_fields(struct drm_encoder *encoder, |
- | 124 | struct drm_connector *connector, |
|
108 | struct drm_display_mode *mode) |
125 | struct drm_display_mode *mode) |
109 | { |
126 | { |
110 | struct radeon_device *rdev = encoder->dev->dev_private; |
127 | struct radeon_device *rdev = encoder->dev->dev_private; |
111 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
128 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
112 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
129 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
113 | struct drm_connector *connector; |
- | |
114 | struct radeon_connector *radeon_connector = NULL; |
- | |
115 | u32 tmp = 0, offset; |
130 | u32 tmp = 0; |
116 | 131 | ||
117 | if (!dig || !dig->afmt || !dig->afmt->pin) |
132 | if (!dig || !dig->afmt || !dig->pin) |
118 | return; |
- | |
119 | - | ||
120 | offset = dig->afmt->pin->offset; |
- | |
121 | - | ||
122 | list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { |
- | |
123 | if (connector->encoder == encoder) { |
- | |
124 | radeon_connector = to_radeon_connector(connector); |
- | |
125 | break; |
- | |
126 | } |
- | |
127 | } |
- | |
128 | - | ||
129 | if (!radeon_connector) { |
- | |
130 | DRM_ERROR("Couldn't find encoder's connector\n"); |
- | |
131 | return; |
- | |
132 | } |
133 | return; |
133 | 134 | ||
134 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { |
135 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { |
135 | if (connector->latency_present[1]) |
136 | if (connector->latency_present[1]) |
136 | tmp = VIDEO_LIPSYNC(connector->video_latency[1]) | |
137 | tmp = VIDEO_LIPSYNC(connector->video_latency[1]) | |
137 | AUDIO_LIPSYNC(connector->audio_latency[1]); |
138 | AUDIO_LIPSYNC(connector->audio_latency[1]); |
138 | else |
139 | else |
139 | tmp = VIDEO_LIPSYNC(0) | AUDIO_LIPSYNC(0); |
140 | tmp = VIDEO_LIPSYNC(0) | AUDIO_LIPSYNC(0); |
140 | } else { |
141 | } else { |
141 | if (connector->latency_present[0]) |
142 | if (connector->latency_present[0]) |
142 | tmp = VIDEO_LIPSYNC(connector->video_latency[0]) | |
143 | tmp = VIDEO_LIPSYNC(connector->video_latency[0]) | |
143 | AUDIO_LIPSYNC(connector->audio_latency[0]); |
144 | AUDIO_LIPSYNC(connector->audio_latency[0]); |
144 | else |
145 | else |
145 | tmp = VIDEO_LIPSYNC(0) | AUDIO_LIPSYNC(0); |
146 | tmp = VIDEO_LIPSYNC(0) | AUDIO_LIPSYNC(0); |
146 | } |
147 | } |
- | 148 | WREG32_ENDPOINT(dig->pin->offset, |
|
147 | WREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC, tmp); |
149 | AZ_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC, tmp); |
148 | } |
150 | } |
149 | 151 | ||
- | 152 | void dce6_afmt_hdmi_write_speaker_allocation(struct drm_encoder *encoder, |
|
150 | void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder) |
153 | u8 *sadb, int sad_count) |
151 | { |
154 | { |
152 | struct radeon_device *rdev = encoder->dev->dev_private; |
155 | struct radeon_device *rdev = encoder->dev->dev_private; |
153 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
156 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
154 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
157 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
155 | struct drm_connector *connector; |
- | |
156 | struct radeon_connector *radeon_connector = NULL; |
- | |
157 | u32 offset, tmp; |
158 | u32 tmp; |
158 | u8 *sadb = NULL; |
- | |
159 | int sad_count; |
- | |
160 | - | ||
161 | if (!dig || !dig->afmt || !dig->afmt->pin) |
- | |
162 | return; |
- | |
163 | - | ||
164 | offset = dig->afmt->pin->offset; |
- | |
165 | - | ||
166 | list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { |
- | |
167 | if (connector->encoder == encoder) { |
- | |
168 | radeon_connector = to_radeon_connector(connector); |
- | |
169 | break; |
- | |
170 | } |
- | |
171 | } |
- | |
172 | 159 | ||
173 | if (!radeon_connector) { |
- | |
174 | DRM_ERROR("Couldn't find encoder's connector\n"); |
160 | if (!dig || !dig->afmt || !dig->pin) |
175 | return; |
- | |
176 | } |
- | |
177 | - | ||
178 | sad_count = drm_edid_to_speaker_allocation(radeon_connector_edid(connector), &sadb); |
- | |
179 | if (sad_count < 0) { |
- | |
180 | DRM_DEBUG("Couldn't read Speaker Allocation Data Block: %d\n", sad_count); |
- | |
181 | sad_count = 0; |
- | |
182 | } |
161 | return; |
- | 162 | ||
183 | 163 | /* program the speaker allocation */ |
|
184 | /* program the speaker allocation */ |
164 | tmp = RREG32_ENDPOINT(dig->pin->offset, |
185 | tmp = RREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER); |
165 | AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER); |
186 | tmp &= ~(DP_CONNECTION | SPEAKER_ALLOCATION_MASK); |
166 | tmp &= ~(DP_CONNECTION | SPEAKER_ALLOCATION_MASK); |
187 | /* set HDMI mode */ |
167 | /* set HDMI mode */ |
188 | tmp |= HDMI_CONNECTION; |
168 | tmp |= HDMI_CONNECTION; |
189 | if (sad_count) |
169 | if (sad_count) |
190 | tmp |= SPEAKER_ALLOCATION(sadb[0]); |
170 | tmp |= SPEAKER_ALLOCATION(sadb[0]); |
191 | else |
171 | else |
192 | tmp |= SPEAKER_ALLOCATION(5); /* stereo */ |
172 | tmp |= SPEAKER_ALLOCATION(5); /* stereo */ |
- | 173 | WREG32_ENDPOINT(dig->pin->offset, |
|
193 | WREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER, tmp); |
174 | AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER, tmp); |
194 | - | ||
195 | kfree(sadb); |
- | |
196 | } |
175 | } |
197 | 176 | ||
- | 177 | void dce6_afmt_dp_write_speaker_allocation(struct drm_encoder *encoder, |
|
198 | void dce6_afmt_write_sad_regs(struct drm_encoder *encoder) |
178 | u8 *sadb, int sad_count) |
199 | { |
179 | { |
200 | struct radeon_device *rdev = encoder->dev->dev_private; |
180 | struct radeon_device *rdev = encoder->dev->dev_private; |
201 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
181 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
202 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
182 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
203 | u32 offset; |
183 | u32 tmp; |
204 | struct drm_connector *connector; |
- | |
205 | struct radeon_connector *radeon_connector = NULL; |
- | |
206 | struct cea_sad *sads; |
- | |
207 | int i, sad_count; |
- | |
- | 184 | ||
- | 185 | if (!dig || !dig->afmt || !dig->pin) |
|
- | 186 | return; |
|
- | 187 | ||
- | 188 | /* program the speaker allocation */ |
|
- | 189 | tmp = RREG32_ENDPOINT(dig->pin->offset, |
|
- | 190 | AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER); |
|
- | 191 | tmp &= ~(HDMI_CONNECTION | SPEAKER_ALLOCATION_MASK); |
|
- | 192 | /* set DP mode */ |
|
- | 193 | tmp |= DP_CONNECTION; |
|
- | 194 | if (sad_count) |
|
- | 195 | tmp |= SPEAKER_ALLOCATION(sadb[0]); |
|
- | 196 | else |
|
- | 197 | tmp |= SPEAKER_ALLOCATION(5); /* stereo */ |
|
- | 198 | WREG32_ENDPOINT(dig->pin->offset, |
|
- | 199 | AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER, tmp); |
|
- | 200 | } |
|
- | 201 | ||
- | 202 | void dce6_afmt_write_sad_regs(struct drm_encoder *encoder, |
|
- | 203 | struct cea_sad *sads, int sad_count) |
|
- | 204 | { |
|
- | 205 | int i; |
|
- | 206 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
|
- | 207 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
|
208 | 208 | struct radeon_device *rdev = encoder->dev->dev_private; |
|
209 | static const u16 eld_reg_to_type[][2] = { |
209 | static const u16 eld_reg_to_type[][2] = { |
210 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0, HDMI_AUDIO_CODING_TYPE_PCM }, |
210 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0, HDMI_AUDIO_CODING_TYPE_PCM }, |
211 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR1, HDMI_AUDIO_CODING_TYPE_AC3 }, |
211 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR1, HDMI_AUDIO_CODING_TYPE_AC3 }, |
212 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR2, HDMI_AUDIO_CODING_TYPE_MPEG1 }, |
212 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR2, HDMI_AUDIO_CODING_TYPE_MPEG1 }, |
213 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR3, HDMI_AUDIO_CODING_TYPE_MP3 }, |
213 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR3, HDMI_AUDIO_CODING_TYPE_MP3 }, |
214 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR4, HDMI_AUDIO_CODING_TYPE_MPEG2 }, |
214 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR4, HDMI_AUDIO_CODING_TYPE_MPEG2 }, |
215 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR5, HDMI_AUDIO_CODING_TYPE_AAC_LC }, |
215 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR5, HDMI_AUDIO_CODING_TYPE_AAC_LC }, |
216 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR6, HDMI_AUDIO_CODING_TYPE_DTS }, |
216 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR6, HDMI_AUDIO_CODING_TYPE_DTS }, |
217 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR7, HDMI_AUDIO_CODING_TYPE_ATRAC }, |
217 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR7, HDMI_AUDIO_CODING_TYPE_ATRAC }, |
218 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR9, HDMI_AUDIO_CODING_TYPE_EAC3 }, |
218 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR9, HDMI_AUDIO_CODING_TYPE_EAC3 }, |
219 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR10, HDMI_AUDIO_CODING_TYPE_DTS_HD }, |
219 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR10, HDMI_AUDIO_CODING_TYPE_DTS_HD }, |
220 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR11, HDMI_AUDIO_CODING_TYPE_MLP }, |
220 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR11, HDMI_AUDIO_CODING_TYPE_MLP }, |
221 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO }, |
221 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO }, |
222 | }; |
222 | }; |
223 | 223 | ||
224 | if (!dig || !dig->afmt || !dig->afmt->pin) |
224 | if (!dig || !dig->afmt || !dig->pin) |
225 | return; |
- | |
226 | - | ||
227 | offset = dig->afmt->pin->offset; |
- | |
228 | - | ||
229 | list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { |
- | |
230 | if (connector->encoder == encoder) { |
- | |
231 | radeon_connector = to_radeon_connector(connector); |
- | |
232 | break; |
- | |
233 | } |
- | |
234 | } |
- | |
235 | - | ||
236 | if (!radeon_connector) { |
- | |
237 | DRM_ERROR("Couldn't find encoder's connector\n"); |
- | |
238 | return; |
- | |
239 | } |
- | |
240 | - | ||
241 | sad_count = drm_edid_to_sad(radeon_connector_edid(connector), &sads); |
- | |
242 | if (sad_count <= 0) { |
- | |
243 | DRM_ERROR("Couldn't read SADs: %d\n", sad_count); |
- | |
244 | return; |
- | |
245 | } |
- | |
246 | BUG_ON(!sads); |
225 | return; |
247 | 226 | ||
248 | for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) { |
227 | for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) { |
249 | u32 value = 0; |
228 | u32 value = 0; |
250 | u8 stereo_freqs = 0; |
229 | u8 stereo_freqs = 0; |
251 | int max_channels = -1; |
230 | int max_channels = -1; |
252 | int j; |
231 | int j; |
253 | 232 | ||
254 | for (j = 0; j < sad_count; j++) { |
233 | for (j = 0; j < sad_count; j++) { |
255 | struct cea_sad *sad = &sads[j]; |
234 | struct cea_sad *sad = &sads[j]; |
256 | 235 | ||
257 | if (sad->format == eld_reg_to_type[i][1]) { |
236 | if (sad->format == eld_reg_to_type[i][1]) { |
258 | if (sad->channels > max_channels) { |
237 | if (sad->channels > max_channels) { |
259 | value = MAX_CHANNELS(sad->channels) | |
238 | value = MAX_CHANNELS(sad->channels) | |
260 | DESCRIPTOR_BYTE_2(sad->byte2) | |
239 | DESCRIPTOR_BYTE_2(sad->byte2) | |
261 | SUPPORTED_FREQUENCIES(sad->freq); |
240 | SUPPORTED_FREQUENCIES(sad->freq); |
262 | max_channels = sad->channels; |
241 | max_channels = sad->channels; |
263 | } |
242 | } |
264 | 243 | ||
265 | if (sad->format == HDMI_AUDIO_CODING_TYPE_PCM) |
244 | if (sad->format == HDMI_AUDIO_CODING_TYPE_PCM) |
266 | stereo_freqs |= sad->freq; |
245 | stereo_freqs |= sad->freq; |
267 | else |
246 | else |
268 | break; |
247 | break; |
269 | } |
248 | } |
270 | } |
249 | } |
271 | 250 | ||
272 | value |= SUPPORTED_FREQUENCIES_STEREO(stereo_freqs); |
251 | value |= SUPPORTED_FREQUENCIES_STEREO(stereo_freqs); |
273 | 252 | ||
274 | WREG32_ENDPOINT(offset, eld_reg_to_type[i][0], value); |
253 | WREG32_ENDPOINT(dig->pin->offset, eld_reg_to_type[i][0], value); |
275 | } |
- | |
276 | - | ||
277 | kfree(sads); |
- | |
278 | } |
- | |
279 | - | ||
280 | static int dce6_audio_chipset_supported(struct radeon_device *rdev) |
- | |
281 | { |
- | |
282 | return !ASIC_IS_NODCE(rdev); |
254 | } |
283 | } |
255 | } |
284 | 256 | ||
285 | void dce6_audio_enable(struct radeon_device *rdev, |
257 | void dce6_audio_enable(struct radeon_device *rdev, |
286 | struct r600_audio_pin *pin, |
258 | struct r600_audio_pin *pin, |
287 | u8 enable_mask) |
259 | u8 enable_mask) |
288 | { |
260 | { |
289 | if (!pin) |
261 | if (!pin) |
290 | return; |
262 | return; |
291 | 263 | ||
292 | WREG32_ENDPOINT(pin->offset, AZ_F0_CODEC_PIN_CONTROL_HOT_PLUG_CONTROL, |
264 | WREG32_ENDPOINT(pin->offset, AZ_F0_CODEC_PIN_CONTROL_HOT_PLUG_CONTROL, |
293 | enable_mask ? AUDIO_ENABLED : 0); |
265 | enable_mask ? AUDIO_ENABLED : 0); |
294 | } |
266 | } |
- | 267 | ||
295 | 268 | void dce6_hdmi_audio_set_dto(struct radeon_device *rdev, |
|
296 | static const u32 pin_offsets[7] = |
269 | struct radeon_crtc *crtc, unsigned int clock) |
297 | { |
- | |
298 | (0x5e00 - 0x5e00), |
- | |
299 | (0x5e18 - 0x5e00), |
- | |
300 | (0x5e30 - 0x5e00), |
- | |
301 | (0x5e48 - 0x5e00), |
- | |
302 | (0x5e60 - 0x5e00), |
- | |
303 | (0x5e78 - 0x5e00), |
- | |
304 | (0x5e90 - 0x5e00), |
- | |
305 | }; |
- | |
306 | 270 | { |
|
307 | int dce6_audio_init(struct radeon_device *rdev) |
- | |
308 | { |
- | |
309 | int i; |
- | |
310 | - | ||
311 | if (!radeon_audio || !dce6_audio_chipset_supported(rdev)) |
271 | /* Two dtos; generally use dto0 for HDMI */ |
312 | return 0; |
- | |
313 | - | ||
314 | rdev->audio.enabled = true; |
- | |
315 | 272 | u32 value = 0; |
|
316 | if (ASIC_IS_DCE81(rdev)) /* KV: 4 streams, 7 endpoints */ |
273 | |
317 | rdev->audio.num_pins = 7; |
- | |
318 | else if (ASIC_IS_DCE83(rdev)) /* KB: 2 streams, 3 endpoints */ |
- | |
319 | rdev->audio.num_pins = 3; |
- | |
320 | else if (ASIC_IS_DCE8(rdev)) /* BN/HW: 6 streams, 7 endpoints */ |
- | |
321 | rdev->audio.num_pins = 7; |
- | |
322 | else if (ASIC_IS_DCE61(rdev)) /* TN: 4 streams, 6 endpoints */ |
- | |
323 | rdev->audio.num_pins = 6; |
- | |
324 | else if (ASIC_IS_DCE64(rdev)) /* OL: 2 streams, 2 endpoints */ |
- | |
325 | rdev->audio.num_pins = 2; |
- | |
326 | else /* SI: 6 streams, 6 endpoints */ |
- | |
327 | rdev->audio.num_pins = 6; |
- | |
328 | - | ||
329 | for (i = 0; i < rdev->audio.num_pins; i++) { |
- | |
330 | rdev->audio.pin[i].channels = -1; |
- | |
331 | rdev->audio.pin[i].rate = -1; |
- | |
332 | rdev->audio.pin[i].bits_per_sample = -1; |
274 | if (crtc) |
333 | rdev->audio.pin[i].status_bits = 0; |
- | |
334 | rdev->audio.pin[i].category_code = 0; |
- | |
335 | rdev->audio.pin[i].connected = false; |
- | |
336 | rdev->audio.pin[i].offset = pin_offsets[i]; |
- | |
337 | rdev->audio.pin[i].id = i; |
- | |
- | 275 | value |= DCCG_AUDIO_DTO0_SOURCE_SEL(crtc->crtc_id); |
|
- | 276 | ||
- | 277 | WREG32(DCCG_AUDIO_DTO_SOURCE, value); |
|
338 | /* disable audio. it will be set up later */ |
278 | |
- | 279 | /* Express [24MHz / target pixel clock] as an exact rational |
|
- | 280 | * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE |
|
339 | dce6_audio_enable(rdev, &rdev->audio.pin[i], false); |
281 | * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator |
340 | } |
282 | */ |
- | 283 | WREG32(DCCG_AUDIO_DTO0_PHASE, 24000); |
|
341 | 284 | WREG32(DCCG_AUDIO_DTO0_MODULE, clock); |
|
- | 285 | } |
|
342 | return 0; |
286 | |
- | 287 | void dce6_dp_audio_set_dto(struct radeon_device *rdev, |
|
343 | } |
- | |
344 | 288 | struct radeon_crtc *crtc, unsigned int clock) |
|
- | 289 | { |
|
345 | void dce6_audio_fini(struct radeon_device *rdev) |
- | |
346 | { |
290 | /* Two dtos; generally use dto1 for DP */ |
- | 291 | u32 value = 0; |
|
- | 292 | value |= DCCG_AUDIO_DTO_SEL; |
|
- | 293 | ||
- | 294 | if (crtc) |
|
347 | int i; |
295 | value |= DCCG_AUDIO_DTO0_SOURCE_SEL(crtc->crtc_id); |
- | 296 | ||
- | 297 | WREG32(DCCG_AUDIO_DTO_SOURCE, value); |
|
- | 298 | ||
- | 299 | /* Express [24MHz / target pixel clock] as an exact rational |
|
- | 300 | * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE |
|
- | 301 | * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator |
|
348 | 302 | */ |
|
349 | if (!rdev->audio.enabled) |
303 | if (ASIC_IS_DCE8(rdev)) { |
350 | return; |
304 | WREG32(DCE8_DCCG_AUDIO_DTO1_PHASE, 24000); |
351 | 305 | WREG32(DCE8_DCCG_AUDIO_DTO1_MODULE, clock); |
|
352 | for (i = 0; i < rdev->audio.num_pins; i++) |
306 | } else { |
353 | dce6_audio_enable(rdev, &rdev->audio.pin[i], false); |
307 | WREG32(DCCG_AUDIO_DTO1_PHASE, 24000); |
354 | 308 | WREG32(DCCG_AUDIO_DTO1_MODULE, clock); |
|
355 | rdev->audio.enabled = false; |
309 | } |
356 | }>>>>=>>>> |
310 | }>>>> |