Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Advanced Micro Devices, Inc. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 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 |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | * |
| 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, |
| 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 |
| 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 |
| 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | * |
| 22 | */ |
| 23 | #include <linux/hdmi.h> |
| 24 | #include <drm/drmP.h> |
| 25 | #include "radeon.h" |
Slava Grigorev | 1a626b6 | 2014-12-01 13:49:39 -0500 | [diff] [blame] | 26 | #include "radeon_audio.h" |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 27 | #include "sid.h" |
| 28 | |
Slava Grigorev | 2afa326 | 2015-03-02 12:05:29 -0500 | [diff] [blame] | 29 | #define DCE8_DCCG_AUDIO_DTO1_PHASE 0x05b8 |
| 30 | #define DCE8_DCCG_AUDIO_DTO1_MODULE 0x05bc |
| 31 | |
Slava Grigorev | 1a626b6 | 2014-12-01 13:49:39 -0500 | [diff] [blame] | 32 | u32 dce6_endpoint_rreg(struct radeon_device *rdev, |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 33 | u32 block_offset, u32 reg) |
| 34 | { |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 35 | unsigned long flags; |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 36 | u32 r; |
| 37 | |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 38 | spin_lock_irqsave(&rdev->end_idx_lock, flags); |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 39 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg); |
| 40 | r = RREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset); |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 41 | spin_unlock_irqrestore(&rdev->end_idx_lock, flags); |
| 42 | |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 43 | return r; |
| 44 | } |
| 45 | |
Slava Grigorev | 1a626b6 | 2014-12-01 13:49:39 -0500 | [diff] [blame] | 46 | void dce6_endpoint_wreg(struct radeon_device *rdev, |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 47 | u32 block_offset, u32 reg, u32 v) |
| 48 | { |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 49 | unsigned long flags; |
| 50 | |
| 51 | spin_lock_irqsave(&rdev->end_idx_lock, flags); |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 52 | if (ASIC_IS_DCE8(rdev)) |
| 53 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg); |
| 54 | else |
| 55 | WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, |
| 56 | AZ_ENDPOINT_REG_WRITE_EN | AZ_ENDPOINT_REG_INDEX(reg)); |
| 57 | WREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset, v); |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 58 | spin_unlock_irqrestore(&rdev->end_idx_lock, flags); |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 59 | } |
| 60 | |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 61 | static void dce6_afmt_get_connected_pins(struct radeon_device *rdev) |
| 62 | { |
| 63 | int i; |
| 64 | u32 offset, tmp; |
| 65 | |
| 66 | for (i = 0; i < rdev->audio.num_pins; i++) { |
| 67 | offset = rdev->audio.pin[i].offset; |
| 68 | tmp = RREG32_ENDPOINT(offset, |
| 69 | AZ_F0_CODEC_PIN_CONTROL_RESPONSE_CONFIGURATION_DEFAULT); |
| 70 | if (((tmp & PORT_CONNECTIVITY_MASK) >> PORT_CONNECTIVITY_SHIFT) == 1) |
| 71 | rdev->audio.pin[i].connected = false; |
| 72 | else |
| 73 | rdev->audio.pin[i].connected = true; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | struct r600_audio_pin *dce6_audio_get_pin(struct radeon_device *rdev) |
| 78 | { |
| 79 | int i; |
| 80 | |
| 81 | dce6_afmt_get_connected_pins(rdev); |
| 82 | |
| 83 | for (i = 0; i < rdev->audio.num_pins; i++) { |
| 84 | if (rdev->audio.pin[i].connected) |
| 85 | return &rdev->audio.pin[i]; |
| 86 | } |
| 87 | DRM_ERROR("No connected audio pins found!\n"); |
| 88 | return NULL; |
| 89 | } |
| 90 | |
| 91 | void dce6_afmt_select_pin(struct drm_encoder *encoder) |
| 92 | { |
| 93 | struct radeon_device *rdev = encoder->dev->dev_private; |
| 94 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 95 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
Alex Deucher | 53dc0b0 | 2013-12-03 17:45:14 -0500 | [diff] [blame] | 96 | u32 offset; |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 97 | |
Alex Deucher | 53dc0b0 | 2013-12-03 17:45:14 -0500 | [diff] [blame] | 98 | if (!dig || !dig->afmt || !dig->afmt->pin) |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 99 | return; |
| 100 | |
Alex Deucher | 53dc0b0 | 2013-12-03 17:45:14 -0500 | [diff] [blame] | 101 | offset = dig->afmt->offset; |
| 102 | |
Alex Deucher | 7cc0a3d | 2013-09-03 14:03:21 -0400 | [diff] [blame] | 103 | WREG32(AFMT_AUDIO_SRC_CONTROL + offset, |
| 104 | AFMT_AUDIO_SRC_SELECT(dig->afmt->pin->id)); |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 105 | } |
| 106 | |
Alex Deucher | b188025 | 2013-10-10 18:03:06 -0400 | [diff] [blame] | 107 | void dce6_afmt_write_latency_fields(struct drm_encoder *encoder, |
Slava Grigorev | 87654f8 | 2014-12-02 11:20:48 -0500 | [diff] [blame] | 108 | struct drm_connector *connector, struct drm_display_mode *mode) |
Alex Deucher | b188025 | 2013-10-10 18:03:06 -0400 | [diff] [blame] | 109 | { |
| 110 | struct radeon_device *rdev = encoder->dev->dev_private; |
| 111 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 112 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
Alex Deucher | b188025 | 2013-10-10 18:03:06 -0400 | [diff] [blame] | 113 | u32 tmp = 0, offset; |
| 114 | |
Alex Deucher | 53dc0b0 | 2013-12-03 17:45:14 -0500 | [diff] [blame] | 115 | if (!dig || !dig->afmt || !dig->afmt->pin) |
Alex Deucher | b188025 | 2013-10-10 18:03:06 -0400 | [diff] [blame] | 116 | return; |
| 117 | |
| 118 | offset = dig->afmt->pin->offset; |
| 119 | |
Alex Deucher | b188025 | 2013-10-10 18:03:06 -0400 | [diff] [blame] | 120 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { |
| 121 | if (connector->latency_present[1]) |
| 122 | tmp = VIDEO_LIPSYNC(connector->video_latency[1]) | |
| 123 | AUDIO_LIPSYNC(connector->audio_latency[1]); |
| 124 | else |
Stefan Brüns | c748990 | 2014-07-13 01:47:14 +0200 | [diff] [blame] | 125 | tmp = VIDEO_LIPSYNC(0) | AUDIO_LIPSYNC(0); |
Alex Deucher | b188025 | 2013-10-10 18:03:06 -0400 | [diff] [blame] | 126 | } else { |
| 127 | if (connector->latency_present[0]) |
| 128 | tmp = VIDEO_LIPSYNC(connector->video_latency[0]) | |
| 129 | AUDIO_LIPSYNC(connector->audio_latency[0]); |
| 130 | else |
Stefan Brüns | c748990 | 2014-07-13 01:47:14 +0200 | [diff] [blame] | 131 | tmp = VIDEO_LIPSYNC(0) | AUDIO_LIPSYNC(0); |
Alex Deucher | b188025 | 2013-10-10 18:03:06 -0400 | [diff] [blame] | 132 | } |
| 133 | WREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC, tmp); |
| 134 | } |
| 135 | |
Slava Grigorev | 00a9d4b | 2014-12-01 18:02:57 -0500 | [diff] [blame] | 136 | void dce6_afmt_hdmi_write_speaker_allocation(struct drm_encoder *encoder, |
| 137 | u8 *sadb, int sad_count) |
Rafał Miłecki | 6159b65 | 2013-08-15 11:16:30 +0200 | [diff] [blame] | 138 | { |
| 139 | struct radeon_device *rdev = encoder->dev->dev_private; |
| 140 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 141 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
Rafał Miłecki | 6159b65 | 2013-08-15 11:16:30 +0200 | [diff] [blame] | 142 | u32 offset, tmp; |
Rafał Miłecki | 6159b65 | 2013-08-15 11:16:30 +0200 | [diff] [blame] | 143 | |
Alex Deucher | 53dc0b0 | 2013-12-03 17:45:14 -0500 | [diff] [blame] | 144 | if (!dig || !dig->afmt || !dig->afmt->pin) |
Rafał Miłecki | 6159b65 | 2013-08-15 11:16:30 +0200 | [diff] [blame] | 145 | return; |
| 146 | |
| 147 | offset = dig->afmt->pin->offset; |
| 148 | |
Rafał Miłecki | 6159b65 | 2013-08-15 11:16:30 +0200 | [diff] [blame] | 149 | /* program the speaker allocation */ |
| 150 | tmp = RREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER); |
| 151 | tmp &= ~(DP_CONNECTION | SPEAKER_ALLOCATION_MASK); |
| 152 | /* set HDMI mode */ |
| 153 | tmp |= HDMI_CONNECTION; |
| 154 | if (sad_count) |
| 155 | tmp |= SPEAKER_ALLOCATION(sadb[0]); |
| 156 | else |
| 157 | tmp |= SPEAKER_ALLOCATION(5); /* stereo */ |
| 158 | WREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER, tmp); |
Slava Grigorev | 00a9d4b | 2014-12-01 18:02:57 -0500 | [diff] [blame] | 159 | } |
Rafał Miłecki | 6159b65 | 2013-08-15 11:16:30 +0200 | [diff] [blame] | 160 | |
Slava Grigorev | 00a9d4b | 2014-12-01 18:02:57 -0500 | [diff] [blame] | 161 | void dce6_afmt_dp_write_speaker_allocation(struct drm_encoder *encoder, |
| 162 | u8 *sadb, int sad_count) |
| 163 | { |
| 164 | struct radeon_device *rdev = encoder->dev->dev_private; |
| 165 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 166 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
| 167 | u32 offset, tmp; |
| 168 | |
| 169 | if (!dig || !dig->afmt || !dig->afmt->pin) |
| 170 | return; |
| 171 | |
| 172 | offset = dig->afmt->pin->offset; |
| 173 | |
| 174 | /* program the speaker allocation */ |
| 175 | tmp = RREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER); |
| 176 | tmp &= ~(HDMI_CONNECTION | SPEAKER_ALLOCATION_MASK); |
| 177 | /* set DP mode */ |
| 178 | tmp |= DP_CONNECTION; |
| 179 | if (sad_count) |
| 180 | tmp |= SPEAKER_ALLOCATION(sadb[0]); |
| 181 | else |
| 182 | tmp |= SPEAKER_ALLOCATION(5); /* stereo */ |
| 183 | WREG32_ENDPOINT(offset, AZ_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER, tmp); |
Rafał Miłecki | 6159b65 | 2013-08-15 11:16:30 +0200 | [diff] [blame] | 184 | } |
| 185 | |
Alex Deucher | 070a2e6 | 2015-01-22 10:41:55 -0500 | [diff] [blame] | 186 | void dce6_afmt_write_sad_regs(struct drm_encoder *encoder, |
| 187 | struct cea_sad *sads, int sad_count) |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 188 | { |
Alex Deucher | 070a2e6 | 2015-01-22 10:41:55 -0500 | [diff] [blame] | 189 | u32 offset; |
| 190 | int i; |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 191 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 192 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
Alex Deucher | 070a2e6 | 2015-01-22 10:41:55 -0500 | [diff] [blame] | 193 | struct radeon_device *rdev = encoder->dev->dev_private; |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 194 | static const u16 eld_reg_to_type[][2] = { |
| 195 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0, HDMI_AUDIO_CODING_TYPE_PCM }, |
| 196 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR1, HDMI_AUDIO_CODING_TYPE_AC3 }, |
| 197 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR2, HDMI_AUDIO_CODING_TYPE_MPEG1 }, |
| 198 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR3, HDMI_AUDIO_CODING_TYPE_MP3 }, |
| 199 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR4, HDMI_AUDIO_CODING_TYPE_MPEG2 }, |
| 200 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR5, HDMI_AUDIO_CODING_TYPE_AAC_LC }, |
| 201 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR6, HDMI_AUDIO_CODING_TYPE_DTS }, |
| 202 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR7, HDMI_AUDIO_CODING_TYPE_ATRAC }, |
| 203 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR9, HDMI_AUDIO_CODING_TYPE_EAC3 }, |
| 204 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR10, HDMI_AUDIO_CODING_TYPE_DTS_HD }, |
| 205 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR11, HDMI_AUDIO_CODING_TYPE_MLP }, |
| 206 | { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO }, |
| 207 | }; |
| 208 | |
Alex Deucher | 53dc0b0 | 2013-12-03 17:45:14 -0500 | [diff] [blame] | 209 | if (!dig || !dig->afmt || !dig->afmt->pin) |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 210 | return; |
| 211 | |
| 212 | offset = dig->afmt->pin->offset; |
| 213 | |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 214 | for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) { |
| 215 | u32 value = 0; |
Anssi Hannula | 0f57bca | 2013-10-29 01:19:16 +0200 | [diff] [blame] | 216 | u8 stereo_freqs = 0; |
| 217 | int max_channels = -1; |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 218 | int j; |
| 219 | |
| 220 | for (j = 0; j < sad_count; j++) { |
| 221 | struct cea_sad *sad = &sads[j]; |
| 222 | |
| 223 | if (sad->format == eld_reg_to_type[i][1]) { |
Anssi Hannula | 0f57bca | 2013-10-29 01:19:16 +0200 | [diff] [blame] | 224 | if (sad->channels > max_channels) { |
| 225 | value = MAX_CHANNELS(sad->channels) | |
| 226 | DESCRIPTOR_BYTE_2(sad->byte2) | |
| 227 | SUPPORTED_FREQUENCIES(sad->freq); |
| 228 | max_channels = sad->channels; |
| 229 | } |
| 230 | |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 231 | if (sad->format == HDMI_AUDIO_CODING_TYPE_PCM) |
Anssi Hannula | 0f57bca | 2013-10-29 01:19:16 +0200 | [diff] [blame] | 232 | stereo_freqs |= sad->freq; |
| 233 | else |
| 234 | break; |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 235 | } |
| 236 | } |
Anssi Hannula | 0f57bca | 2013-10-29 01:19:16 +0200 | [diff] [blame] | 237 | |
| 238 | value |= SUPPORTED_FREQUENCIES_STEREO(stereo_freqs); |
| 239 | |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 240 | WREG32_ENDPOINT(offset, eld_reg_to_type[i][0], value); |
| 241 | } |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 242 | } |
| 243 | |
Alex Deucher | 832eafa | 2014-02-18 11:07:55 -0500 | [diff] [blame] | 244 | void dce6_audio_enable(struct radeon_device *rdev, |
| 245 | struct r600_audio_pin *pin, |
Alex Deucher | d3d8c14 | 2014-09-18 17:26:39 -0400 | [diff] [blame] | 246 | u8 enable_mask) |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 247 | { |
Alex Deucher | 832eafa | 2014-02-18 11:07:55 -0500 | [diff] [blame] | 248 | if (!pin) |
| 249 | return; |
| 250 | |
Alex Deucher | f68fdbe | 2014-09-18 16:19:04 -0400 | [diff] [blame] | 251 | WREG32_ENDPOINT(pin->offset, AZ_F0_CODEC_PIN_CONTROL_HOT_PLUG_CONTROL, |
Alex Deucher | d3d8c14 | 2014-09-18 17:26:39 -0400 | [diff] [blame] | 252 | enable_mask ? AUDIO_ENABLED : 0); |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 253 | } |
Slava Grigorev | a85d682 | 2014-12-05 13:38:31 -0500 | [diff] [blame] | 254 | |
| 255 | void dce6_hdmi_audio_set_dto(struct radeon_device *rdev, |
| 256 | struct radeon_crtc *crtc, unsigned int clock) |
| 257 | { |
Slava Grigorev | b983a8f | 2015-03-02 11:31:07 -0500 | [diff] [blame] | 258 | /* Two dtos; generally use dto0 for HDMI */ |
Slava Grigorev | a85d682 | 2014-12-05 13:38:31 -0500 | [diff] [blame] | 259 | u32 value = 0; |
| 260 | |
Slava Grigorev | b983a8f | 2015-03-02 11:31:07 -0500 | [diff] [blame] | 261 | if (crtc) |
Slava Grigorev | a85d682 | 2014-12-05 13:38:31 -0500 | [diff] [blame] | 262 | value |= DCCG_AUDIO_DTO0_SOURCE_SEL(crtc->crtc_id); |
| 263 | |
| 264 | WREG32(DCCG_AUDIO_DTO_SOURCE, value); |
| 265 | |
Slava Grigorev | b983a8f | 2015-03-02 11:31:07 -0500 | [diff] [blame] | 266 | /* Express [24MHz / target pixel clock] as an exact rational |
| 267 | * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE |
| 268 | * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator |
| 269 | */ |
| 270 | WREG32(DCCG_AUDIO_DTO0_PHASE, 24000); |
| 271 | WREG32(DCCG_AUDIO_DTO0_MODULE, clock); |
Slava Grigorev | a85d682 | 2014-12-05 13:38:31 -0500 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | void dce6_dp_audio_set_dto(struct radeon_device *rdev, |
| 275 | struct radeon_crtc *crtc, unsigned int clock) |
| 276 | { |
Slava Grigorev | b983a8f | 2015-03-02 11:31:07 -0500 | [diff] [blame] | 277 | /* Two dtos; generally use dto1 for DP */ |
Slava Grigorev | a85d682 | 2014-12-05 13:38:31 -0500 | [diff] [blame] | 278 | u32 value = 0; |
| 279 | value |= DCCG_AUDIO_DTO_SEL; |
| 280 | |
Slava Grigorev | b983a8f | 2015-03-02 11:31:07 -0500 | [diff] [blame] | 281 | if (crtc) |
Slava Grigorev | a85d682 | 2014-12-05 13:38:31 -0500 | [diff] [blame] | 282 | value |= DCCG_AUDIO_DTO0_SOURCE_SEL(crtc->crtc_id); |
| 283 | |
| 284 | WREG32(DCCG_AUDIO_DTO_SOURCE, value); |
| 285 | |
Slava Grigorev | b983a8f | 2015-03-02 11:31:07 -0500 | [diff] [blame] | 286 | /* Express [24MHz / target pixel clock] as an exact rational |
| 287 | * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE |
| 288 | * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator |
| 289 | */ |
Slava Grigorev | 2afa326 | 2015-03-02 12:05:29 -0500 | [diff] [blame] | 290 | if (ASIC_IS_DCE8(rdev)) { |
| 291 | WREG32(DCE8_DCCG_AUDIO_DTO1_PHASE, 24000); |
| 292 | WREG32(DCE8_DCCG_AUDIO_DTO1_MODULE, clock); |
| 293 | } else { |
| 294 | WREG32(DCCG_AUDIO_DTO1_PHASE, 24000); |
| 295 | WREG32(DCCG_AUDIO_DTO1_MODULE, clock); |
| 296 | } |
Slava Grigorev | a85d682 | 2014-12-05 13:38:31 -0500 | [diff] [blame] | 297 | } |