2 * Copyright 2014 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
25 #include "amdgpu_pm.h"
26 #include "amdgpu_i2c.h"
29 #include "amdgpu_atombios.h"
30 #include "atombios_crtc.h"
31 #include "atombios_encoders.h"
32 #include "amdgpu_pll.h"
33 #include "amdgpu_connectors.h"
34 #include "dce_v10_0.h"
36 #include "dce/dce_10_0_d.h"
37 #include "dce/dce_10_0_sh_mask.h"
38 #include "dce/dce_10_0_enum.h"
39 #include "oss/oss_3_0_d.h"
40 #include "oss/oss_3_0_sh_mask.h"
41 #include "gmc/gmc_8_1_d.h"
42 #include "gmc/gmc_8_1_sh_mask.h"
44 static void dce_v10_0_set_display_funcs(struct amdgpu_device
*adev
);
45 static void dce_v10_0_set_irq_funcs(struct amdgpu_device
*adev
);
47 static const u32 crtc_offsets
[] =
49 CRTC0_REGISTER_OFFSET
,
50 CRTC1_REGISTER_OFFSET
,
51 CRTC2_REGISTER_OFFSET
,
52 CRTC3_REGISTER_OFFSET
,
53 CRTC4_REGISTER_OFFSET
,
54 CRTC5_REGISTER_OFFSET
,
58 static const u32 hpd_offsets
[] =
68 static const uint32_t dig_offsets
[] = {
84 } interrupt_status_offsets
[] = { {
85 .reg
= mmDISP_INTERRUPT_STATUS
,
86 .vblank
= DISP_INTERRUPT_STATUS__LB_D1_VBLANK_INTERRUPT_MASK
,
87 .vline
= DISP_INTERRUPT_STATUS__LB_D1_VLINE_INTERRUPT_MASK
,
88 .hpd
= DISP_INTERRUPT_STATUS__DC_HPD1_INTERRUPT_MASK
90 .reg
= mmDISP_INTERRUPT_STATUS_CONTINUE
,
91 .vblank
= DISP_INTERRUPT_STATUS_CONTINUE__LB_D2_VBLANK_INTERRUPT_MASK
,
92 .vline
= DISP_INTERRUPT_STATUS_CONTINUE__LB_D2_VLINE_INTERRUPT_MASK
,
93 .hpd
= DISP_INTERRUPT_STATUS_CONTINUE__DC_HPD2_INTERRUPT_MASK
95 .reg
= mmDISP_INTERRUPT_STATUS_CONTINUE2
,
96 .vblank
= DISP_INTERRUPT_STATUS_CONTINUE2__LB_D3_VBLANK_INTERRUPT_MASK
,
97 .vline
= DISP_INTERRUPT_STATUS_CONTINUE2__LB_D3_VLINE_INTERRUPT_MASK
,
98 .hpd
= DISP_INTERRUPT_STATUS_CONTINUE2__DC_HPD3_INTERRUPT_MASK
100 .reg
= mmDISP_INTERRUPT_STATUS_CONTINUE3
,
101 .vblank
= DISP_INTERRUPT_STATUS_CONTINUE3__LB_D4_VBLANK_INTERRUPT_MASK
,
102 .vline
= DISP_INTERRUPT_STATUS_CONTINUE3__LB_D4_VLINE_INTERRUPT_MASK
,
103 .hpd
= DISP_INTERRUPT_STATUS_CONTINUE3__DC_HPD4_INTERRUPT_MASK
105 .reg
= mmDISP_INTERRUPT_STATUS_CONTINUE4
,
106 .vblank
= DISP_INTERRUPT_STATUS_CONTINUE4__LB_D5_VBLANK_INTERRUPT_MASK
,
107 .vline
= DISP_INTERRUPT_STATUS_CONTINUE4__LB_D5_VLINE_INTERRUPT_MASK
,
108 .hpd
= DISP_INTERRUPT_STATUS_CONTINUE4__DC_HPD5_INTERRUPT_MASK
110 .reg
= mmDISP_INTERRUPT_STATUS_CONTINUE5
,
111 .vblank
= DISP_INTERRUPT_STATUS_CONTINUE5__LB_D6_VBLANK_INTERRUPT_MASK
,
112 .vline
= DISP_INTERRUPT_STATUS_CONTINUE5__LB_D6_VLINE_INTERRUPT_MASK
,
113 .hpd
= DISP_INTERRUPT_STATUS_CONTINUE5__DC_HPD6_INTERRUPT_MASK
116 static const u32 golden_settings_tonga_a11
[] =
118 mmDCI_CLK_CNTL
, 0x00000080, 0x00000000,
119 mmFBC_DEBUG_COMP
, 0x000000f0, 0x00000070,
120 mmFBC_MISC
, 0x1f311fff, 0x12300000,
121 mmHDMI_CONTROL
, 0x31000111, 0x00000011,
124 static const u32 tonga_mgcg_cgcg_init
[] =
126 mmXDMA_CLOCK_GATING_CNTL
, 0xffffffff, 0x00000100,
127 mmXDMA_MEM_POWER_CNTL
, 0x00000101, 0x00000000,
130 static const u32 golden_settings_fiji_a10
[] =
132 mmDCI_CLK_CNTL
, 0x00000080, 0x00000000,
133 mmFBC_DEBUG_COMP
, 0x000000f0, 0x00000070,
134 mmFBC_MISC
, 0x1f311fff, 0x12300000,
135 mmHDMI_CONTROL
, 0x31000111, 0x00000011,
138 static const u32 fiji_mgcg_cgcg_init
[] =
140 mmXDMA_CLOCK_GATING_CNTL
, 0xffffffff, 0x00000100,
141 mmXDMA_MEM_POWER_CNTL
, 0x00000101, 0x00000000,
144 static void dce_v10_0_init_golden_registers(struct amdgpu_device
*adev
)
146 switch (adev
->asic_type
) {
148 amdgpu_device_program_register_sequence(adev
,
150 ARRAY_SIZE(fiji_mgcg_cgcg_init
));
151 amdgpu_device_program_register_sequence(adev
,
152 golden_settings_fiji_a10
,
153 ARRAY_SIZE(golden_settings_fiji_a10
));
156 amdgpu_device_program_register_sequence(adev
,
157 tonga_mgcg_cgcg_init
,
158 ARRAY_SIZE(tonga_mgcg_cgcg_init
));
159 amdgpu_device_program_register_sequence(adev
,
160 golden_settings_tonga_a11
,
161 ARRAY_SIZE(golden_settings_tonga_a11
));
168 static u32
dce_v10_0_audio_endpt_rreg(struct amdgpu_device
*adev
,
169 u32 block_offset
, u32 reg
)
174 spin_lock_irqsave(&adev
->audio_endpt_idx_lock
, flags
);
175 WREG32(mmAZALIA_F0_CODEC_ENDPOINT_INDEX
+ block_offset
, reg
);
176 r
= RREG32(mmAZALIA_F0_CODEC_ENDPOINT_DATA
+ block_offset
);
177 spin_unlock_irqrestore(&adev
->audio_endpt_idx_lock
, flags
);
182 static void dce_v10_0_audio_endpt_wreg(struct amdgpu_device
*adev
,
183 u32 block_offset
, u32 reg
, u32 v
)
187 spin_lock_irqsave(&adev
->audio_endpt_idx_lock
, flags
);
188 WREG32(mmAZALIA_F0_CODEC_ENDPOINT_INDEX
+ block_offset
, reg
);
189 WREG32(mmAZALIA_F0_CODEC_ENDPOINT_DATA
+ block_offset
, v
);
190 spin_unlock_irqrestore(&adev
->audio_endpt_idx_lock
, flags
);
193 static bool dce_v10_0_is_in_vblank(struct amdgpu_device
*adev
, int crtc
)
195 if (RREG32(mmCRTC_STATUS
+ crtc_offsets
[crtc
]) &
196 CRTC_V_BLANK_START_END__CRTC_V_BLANK_START_MASK
)
202 static bool dce_v10_0_is_counter_moving(struct amdgpu_device
*adev
, int crtc
)
206 pos1
= RREG32(mmCRTC_STATUS_POSITION
+ crtc_offsets
[crtc
]);
207 pos2
= RREG32(mmCRTC_STATUS_POSITION
+ crtc_offsets
[crtc
]);
216 * dce_v10_0_vblank_wait - vblank wait asic callback.
218 * @adev: amdgpu_device pointer
219 * @crtc: crtc to wait for vblank on
221 * Wait for vblank on the requested crtc (evergreen+).
223 static void dce_v10_0_vblank_wait(struct amdgpu_device
*adev
, int crtc
)
227 if (crtc
>= adev
->mode_info
.num_crtc
)
230 if (!(RREG32(mmCRTC_CONTROL
+ crtc_offsets
[crtc
]) & CRTC_CONTROL__CRTC_MASTER_EN_MASK
))
233 /* depending on when we hit vblank, we may be close to active; if so,
234 * wait for another frame.
236 while (dce_v10_0_is_in_vblank(adev
, crtc
)) {
239 if (!dce_v10_0_is_counter_moving(adev
, crtc
))
244 while (!dce_v10_0_is_in_vblank(adev
, crtc
)) {
247 if (!dce_v10_0_is_counter_moving(adev
, crtc
))
253 static u32
dce_v10_0_vblank_get_counter(struct amdgpu_device
*adev
, int crtc
)
255 if (crtc
>= adev
->mode_info
.num_crtc
)
258 return RREG32(mmCRTC_STATUS_FRAME_COUNT
+ crtc_offsets
[crtc
]);
261 static void dce_v10_0_pageflip_interrupt_init(struct amdgpu_device
*adev
)
265 /* Enable pflip interrupts */
266 for (i
= 0; i
< adev
->mode_info
.num_crtc
; i
++)
267 amdgpu_irq_get(adev
, &adev
->pageflip_irq
, i
);
270 static void dce_v10_0_pageflip_interrupt_fini(struct amdgpu_device
*adev
)
274 /* Disable pflip interrupts */
275 for (i
= 0; i
< adev
->mode_info
.num_crtc
; i
++)
276 amdgpu_irq_put(adev
, &adev
->pageflip_irq
, i
);
280 * dce_v10_0_page_flip - pageflip callback.
282 * @adev: amdgpu_device pointer
283 * @crtc_id: crtc to cleanup pageflip on
284 * @crtc_base: new address of the crtc (GPU MC address)
286 * Triggers the actual pageflip by updating the primary
287 * surface base address.
289 static void dce_v10_0_page_flip(struct amdgpu_device
*adev
,
290 int crtc_id
, u64 crtc_base
, bool async
)
292 struct amdgpu_crtc
*amdgpu_crtc
= adev
->mode_info
.crtcs
[crtc_id
];
295 /* flip at hsync for async, default is vsync */
296 tmp
= RREG32(mmGRPH_FLIP_CONTROL
+ amdgpu_crtc
->crtc_offset
);
297 tmp
= REG_SET_FIELD(tmp
, GRPH_FLIP_CONTROL
,
298 GRPH_SURFACE_UPDATE_H_RETRACE_EN
, async
? 1 : 0);
299 WREG32(mmGRPH_FLIP_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
300 /* update the primary scanout address */
301 WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS_HIGH
+ amdgpu_crtc
->crtc_offset
,
302 upper_32_bits(crtc_base
));
303 /* writing to the low address triggers the update */
304 WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS
+ amdgpu_crtc
->crtc_offset
,
305 lower_32_bits(crtc_base
));
307 RREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS
+ amdgpu_crtc
->crtc_offset
);
310 static int dce_v10_0_crtc_get_scanoutpos(struct amdgpu_device
*adev
, int crtc
,
311 u32
*vbl
, u32
*position
)
313 if ((crtc
< 0) || (crtc
>= adev
->mode_info
.num_crtc
))
316 *vbl
= RREG32(mmCRTC_V_BLANK_START_END
+ crtc_offsets
[crtc
]);
317 *position
= RREG32(mmCRTC_STATUS_POSITION
+ crtc_offsets
[crtc
]);
323 * dce_v10_0_hpd_sense - hpd sense callback.
325 * @adev: amdgpu_device pointer
326 * @hpd: hpd (hotplug detect) pin
328 * Checks if a digital monitor is connected (evergreen+).
329 * Returns true if connected, false if not connected.
331 static bool dce_v10_0_hpd_sense(struct amdgpu_device
*adev
,
332 enum amdgpu_hpd_id hpd
)
334 bool connected
= false;
336 if (hpd
>= adev
->mode_info
.num_hpd
)
339 if (RREG32(mmDC_HPD_INT_STATUS
+ hpd_offsets
[hpd
]) &
340 DC_HPD_INT_STATUS__DC_HPD_SENSE_MASK
)
347 * dce_v10_0_hpd_set_polarity - hpd set polarity callback.
349 * @adev: amdgpu_device pointer
350 * @hpd: hpd (hotplug detect) pin
352 * Set the polarity of the hpd pin (evergreen+).
354 static void dce_v10_0_hpd_set_polarity(struct amdgpu_device
*adev
,
355 enum amdgpu_hpd_id hpd
)
358 bool connected
= dce_v10_0_hpd_sense(adev
, hpd
);
360 if (hpd
>= adev
->mode_info
.num_hpd
)
363 tmp
= RREG32(mmDC_HPD_INT_CONTROL
+ hpd_offsets
[hpd
]);
365 tmp
= REG_SET_FIELD(tmp
, DC_HPD_INT_CONTROL
, DC_HPD_INT_POLARITY
, 0);
367 tmp
= REG_SET_FIELD(tmp
, DC_HPD_INT_CONTROL
, DC_HPD_INT_POLARITY
, 1);
368 WREG32(mmDC_HPD_INT_CONTROL
+ hpd_offsets
[hpd
], tmp
);
372 * dce_v10_0_hpd_init - hpd setup callback.
374 * @adev: amdgpu_device pointer
376 * Setup the hpd pins used by the card (evergreen+).
377 * Enable the pin, set the polarity, and enable the hpd interrupts.
379 static void dce_v10_0_hpd_init(struct amdgpu_device
*adev
)
381 struct drm_device
*dev
= adev
->ddev
;
382 struct drm_connector
*connector
;
385 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
386 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
388 if (amdgpu_connector
->hpd
.hpd
>= adev
->mode_info
.num_hpd
)
391 if (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
||
392 connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
) {
393 /* don't try to enable hpd on eDP or LVDS avoid breaking the
394 * aux dp channel on imac and help (but not completely fix)
395 * https://bugzilla.redhat.com/show_bug.cgi?id=726143
396 * also avoid interrupt storms during dpms.
398 tmp
= RREG32(mmDC_HPD_INT_CONTROL
+ hpd_offsets
[amdgpu_connector
->hpd
.hpd
]);
399 tmp
= REG_SET_FIELD(tmp
, DC_HPD_INT_CONTROL
, DC_HPD_INT_EN
, 0);
400 WREG32(mmDC_HPD_INT_CONTROL
+ hpd_offsets
[amdgpu_connector
->hpd
.hpd
], tmp
);
404 tmp
= RREG32(mmDC_HPD_CONTROL
+ hpd_offsets
[amdgpu_connector
->hpd
.hpd
]);
405 tmp
= REG_SET_FIELD(tmp
, DC_HPD_CONTROL
, DC_HPD_EN
, 1);
406 WREG32(mmDC_HPD_CONTROL
+ hpd_offsets
[amdgpu_connector
->hpd
.hpd
], tmp
);
408 tmp
= RREG32(mmDC_HPD_TOGGLE_FILT_CNTL
+ hpd_offsets
[amdgpu_connector
->hpd
.hpd
]);
409 tmp
= REG_SET_FIELD(tmp
, DC_HPD_TOGGLE_FILT_CNTL
,
410 DC_HPD_CONNECT_INT_DELAY
,
411 AMDGPU_HPD_CONNECT_INT_DELAY_IN_MS
);
412 tmp
= REG_SET_FIELD(tmp
, DC_HPD_TOGGLE_FILT_CNTL
,
413 DC_HPD_DISCONNECT_INT_DELAY
,
414 AMDGPU_HPD_DISCONNECT_INT_DELAY_IN_MS
);
415 WREG32(mmDC_HPD_TOGGLE_FILT_CNTL
+ hpd_offsets
[amdgpu_connector
->hpd
.hpd
], tmp
);
417 dce_v10_0_hpd_set_polarity(adev
, amdgpu_connector
->hpd
.hpd
);
418 amdgpu_irq_get(adev
, &adev
->hpd_irq
,
419 amdgpu_connector
->hpd
.hpd
);
424 * dce_v10_0_hpd_fini - hpd tear down callback.
426 * @adev: amdgpu_device pointer
428 * Tear down the hpd pins used by the card (evergreen+).
429 * Disable the hpd interrupts.
431 static void dce_v10_0_hpd_fini(struct amdgpu_device
*adev
)
433 struct drm_device
*dev
= adev
->ddev
;
434 struct drm_connector
*connector
;
437 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
438 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
440 if (amdgpu_connector
->hpd
.hpd
>= adev
->mode_info
.num_hpd
)
443 tmp
= RREG32(mmDC_HPD_CONTROL
+ hpd_offsets
[amdgpu_connector
->hpd
.hpd
]);
444 tmp
= REG_SET_FIELD(tmp
, DC_HPD_CONTROL
, DC_HPD_EN
, 0);
445 WREG32(mmDC_HPD_CONTROL
+ hpd_offsets
[amdgpu_connector
->hpd
.hpd
], tmp
);
447 amdgpu_irq_put(adev
, &adev
->hpd_irq
,
448 amdgpu_connector
->hpd
.hpd
);
452 static u32
dce_v10_0_hpd_get_gpio_reg(struct amdgpu_device
*adev
)
454 return mmDC_GPIO_HPD_A
;
457 static bool dce_v10_0_is_display_hung(struct amdgpu_device
*adev
)
463 for (i
= 0; i
< adev
->mode_info
.num_crtc
; i
++) {
464 tmp
= RREG32(mmCRTC_CONTROL
+ crtc_offsets
[i
]);
465 if (REG_GET_FIELD(tmp
, CRTC_CONTROL
, CRTC_MASTER_EN
)) {
466 crtc_status
[i
] = RREG32(mmCRTC_STATUS_HV_COUNT
+ crtc_offsets
[i
]);
467 crtc_hung
|= (1 << i
);
471 for (j
= 0; j
< 10; j
++) {
472 for (i
= 0; i
< adev
->mode_info
.num_crtc
; i
++) {
473 if (crtc_hung
& (1 << i
)) {
474 tmp
= RREG32(mmCRTC_STATUS_HV_COUNT
+ crtc_offsets
[i
]);
475 if (tmp
!= crtc_status
[i
])
476 crtc_hung
&= ~(1 << i
);
487 static void dce_v10_0_set_vga_render_state(struct amdgpu_device
*adev
,
492 /* Lockout access through VGA aperture*/
493 tmp
= RREG32(mmVGA_HDP_CONTROL
);
495 tmp
= REG_SET_FIELD(tmp
, VGA_HDP_CONTROL
, VGA_MEMORY_DISABLE
, 0);
497 tmp
= REG_SET_FIELD(tmp
, VGA_HDP_CONTROL
, VGA_MEMORY_DISABLE
, 1);
498 WREG32(mmVGA_HDP_CONTROL
, tmp
);
500 /* disable VGA render */
501 tmp
= RREG32(mmVGA_RENDER_CONTROL
);
503 tmp
= REG_SET_FIELD(tmp
, VGA_RENDER_CONTROL
, VGA_VSTATUS_CNTL
, 1);
505 tmp
= REG_SET_FIELD(tmp
, VGA_RENDER_CONTROL
, VGA_VSTATUS_CNTL
, 0);
506 WREG32(mmVGA_RENDER_CONTROL
, tmp
);
509 static int dce_v10_0_get_num_crtc(struct amdgpu_device
*adev
)
513 switch (adev
->asic_type
) {
524 void dce_v10_0_disable_dce(struct amdgpu_device
*adev
)
526 /*Disable VGA render and enabled crtc, if has DCE engine*/
527 if (amdgpu_atombios_has_dce_engine_info(adev
)) {
531 dce_v10_0_set_vga_render_state(adev
, false);
534 for (i
= 0; i
< dce_v10_0_get_num_crtc(adev
); i
++) {
535 crtc_enabled
= REG_GET_FIELD(RREG32(mmCRTC_CONTROL
+ crtc_offsets
[i
]),
536 CRTC_CONTROL
, CRTC_MASTER_EN
);
538 WREG32(mmCRTC_UPDATE_LOCK
+ crtc_offsets
[i
], 1);
539 tmp
= RREG32(mmCRTC_CONTROL
+ crtc_offsets
[i
]);
540 tmp
= REG_SET_FIELD(tmp
, CRTC_CONTROL
, CRTC_MASTER_EN
, 0);
541 WREG32(mmCRTC_CONTROL
+ crtc_offsets
[i
], tmp
);
542 WREG32(mmCRTC_UPDATE_LOCK
+ crtc_offsets
[i
], 0);
548 static void dce_v10_0_program_fmt(struct drm_encoder
*encoder
)
550 struct drm_device
*dev
= encoder
->dev
;
551 struct amdgpu_device
*adev
= dev
->dev_private
;
552 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
553 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(encoder
->crtc
);
554 struct drm_connector
*connector
= amdgpu_get_connector_for_encoder(encoder
);
557 enum amdgpu_connector_dither dither
= AMDGPU_FMT_DITHER_DISABLE
;
560 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
561 bpc
= amdgpu_connector_get_monitor_bpc(connector
);
562 dither
= amdgpu_connector
->dither
;
565 /* LVDS/eDP FMT is set up by atom */
566 if (amdgpu_encoder
->devices
& ATOM_DEVICE_LCD_SUPPORT
)
569 /* not needed for analog */
570 if ((amdgpu_encoder
->encoder_id
== ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
) ||
571 (amdgpu_encoder
->encoder_id
== ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
))
579 if (dither
== AMDGPU_FMT_DITHER_ENABLE
) {
580 /* XXX sort out optimal dither settings */
581 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_FRAME_RANDOM_ENABLE
, 1);
582 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_HIGHPASS_RANDOM_ENABLE
, 1);
583 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_SPATIAL_DITHER_EN
, 1);
584 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_SPATIAL_DITHER_DEPTH
, 0);
586 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_TRUNCATE_EN
, 1);
587 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_TRUNCATE_DEPTH
, 0);
591 if (dither
== AMDGPU_FMT_DITHER_ENABLE
) {
592 /* XXX sort out optimal dither settings */
593 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_FRAME_RANDOM_ENABLE
, 1);
594 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_HIGHPASS_RANDOM_ENABLE
, 1);
595 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_RGB_RANDOM_ENABLE
, 1);
596 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_SPATIAL_DITHER_EN
, 1);
597 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_SPATIAL_DITHER_DEPTH
, 1);
599 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_TRUNCATE_EN
, 1);
600 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_TRUNCATE_DEPTH
, 1);
604 if (dither
== AMDGPU_FMT_DITHER_ENABLE
) {
605 /* XXX sort out optimal dither settings */
606 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_FRAME_RANDOM_ENABLE
, 1);
607 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_HIGHPASS_RANDOM_ENABLE
, 1);
608 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_RGB_RANDOM_ENABLE
, 1);
609 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_SPATIAL_DITHER_EN
, 1);
610 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_SPATIAL_DITHER_DEPTH
, 2);
612 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_TRUNCATE_EN
, 1);
613 tmp
= REG_SET_FIELD(tmp
, FMT_BIT_DEPTH_CONTROL
, FMT_TRUNCATE_DEPTH
, 2);
621 WREG32(mmFMT_BIT_DEPTH_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
625 /* display watermark setup */
627 * dce_v10_0_line_buffer_adjust - Set up the line buffer
629 * @adev: amdgpu_device pointer
630 * @amdgpu_crtc: the selected display controller
631 * @mode: the current display mode on the selected display
634 * Setup up the line buffer allocation for
635 * the selected display controller (CIK).
636 * Returns the line buffer size in pixels.
638 static u32
dce_v10_0_line_buffer_adjust(struct amdgpu_device
*adev
,
639 struct amdgpu_crtc
*amdgpu_crtc
,
640 struct drm_display_mode
*mode
)
642 u32 tmp
, buffer_alloc
, i
, mem_cfg
;
643 u32 pipe_offset
= amdgpu_crtc
->crtc_id
;
646 * There are 6 line buffers, one for each display controllers.
647 * There are 3 partitions per LB. Select the number of partitions
648 * to enable based on the display width. For display widths larger
649 * than 4096, you need use to use 2 display controllers and combine
650 * them using the stereo blender.
652 if (amdgpu_crtc
->base
.enabled
&& mode
) {
653 if (mode
->crtc_hdisplay
< 1920) {
656 } else if (mode
->crtc_hdisplay
< 2560) {
659 } else if (mode
->crtc_hdisplay
< 4096) {
661 buffer_alloc
= (adev
->flags
& AMD_IS_APU
) ? 2 : 4;
663 DRM_DEBUG_KMS("Mode too big for LB!\n");
665 buffer_alloc
= (adev
->flags
& AMD_IS_APU
) ? 2 : 4;
672 tmp
= RREG32(mmLB_MEMORY_CTRL
+ amdgpu_crtc
->crtc_offset
);
673 tmp
= REG_SET_FIELD(tmp
, LB_MEMORY_CTRL
, LB_MEMORY_CONFIG
, mem_cfg
);
674 WREG32(mmLB_MEMORY_CTRL
+ amdgpu_crtc
->crtc_offset
, tmp
);
676 tmp
= RREG32(mmPIPE0_DMIF_BUFFER_CONTROL
+ pipe_offset
);
677 tmp
= REG_SET_FIELD(tmp
, PIPE0_DMIF_BUFFER_CONTROL
, DMIF_BUFFERS_ALLOCATED
, buffer_alloc
);
678 WREG32(mmPIPE0_DMIF_BUFFER_CONTROL
+ pipe_offset
, tmp
);
680 for (i
= 0; i
< adev
->usec_timeout
; i
++) {
681 tmp
= RREG32(mmPIPE0_DMIF_BUFFER_CONTROL
+ pipe_offset
);
682 if (REG_GET_FIELD(tmp
, PIPE0_DMIF_BUFFER_CONTROL
, DMIF_BUFFERS_ALLOCATION_COMPLETED
))
687 if (amdgpu_crtc
->base
.enabled
&& mode
) {
699 /* controller not enabled, so no lb used */
704 * cik_get_number_of_dram_channels - get the number of dram channels
706 * @adev: amdgpu_device pointer
708 * Look up the number of video ram channels (CIK).
709 * Used for display watermark bandwidth calculations
710 * Returns the number of dram channels
712 static u32
cik_get_number_of_dram_channels(struct amdgpu_device
*adev
)
714 u32 tmp
= RREG32(mmMC_SHARED_CHMAP
);
716 switch (REG_GET_FIELD(tmp
, MC_SHARED_CHMAP
, NOOFCHAN
)) {
739 struct dce10_wm_params
{
740 u32 dram_channels
; /* number of dram channels */
741 u32 yclk
; /* bandwidth per dram data pin in kHz */
742 u32 sclk
; /* engine clock in kHz */
743 u32 disp_clk
; /* display clock in kHz */
744 u32 src_width
; /* viewport width */
745 u32 active_time
; /* active display time in ns */
746 u32 blank_time
; /* blank time in ns */
747 bool interlaced
; /* mode is interlaced */
748 fixed20_12 vsc
; /* vertical scale ratio */
749 u32 num_heads
; /* number of active crtcs */
750 u32 bytes_per_pixel
; /* bytes per pixel display + overlay */
751 u32 lb_size
; /* line buffer allocated to pipe */
752 u32 vtaps
; /* vertical scaler taps */
756 * dce_v10_0_dram_bandwidth - get the dram bandwidth
758 * @wm: watermark calculation data
760 * Calculate the raw dram bandwidth (CIK).
761 * Used for display watermark bandwidth calculations
762 * Returns the dram bandwidth in MBytes/s
764 static u32
dce_v10_0_dram_bandwidth(struct dce10_wm_params
*wm
)
766 /* Calculate raw DRAM Bandwidth */
767 fixed20_12 dram_efficiency
; /* 0.7 */
768 fixed20_12 yclk
, dram_channels
, bandwidth
;
771 a
.full
= dfixed_const(1000);
772 yclk
.full
= dfixed_const(wm
->yclk
);
773 yclk
.full
= dfixed_div(yclk
, a
);
774 dram_channels
.full
= dfixed_const(wm
->dram_channels
* 4);
775 a
.full
= dfixed_const(10);
776 dram_efficiency
.full
= dfixed_const(7);
777 dram_efficiency
.full
= dfixed_div(dram_efficiency
, a
);
778 bandwidth
.full
= dfixed_mul(dram_channels
, yclk
);
779 bandwidth
.full
= dfixed_mul(bandwidth
, dram_efficiency
);
781 return dfixed_trunc(bandwidth
);
785 * dce_v10_0_dram_bandwidth_for_display - get the dram bandwidth for display
787 * @wm: watermark calculation data
789 * Calculate the dram bandwidth used for display (CIK).
790 * Used for display watermark bandwidth calculations
791 * Returns the dram bandwidth for display in MBytes/s
793 static u32
dce_v10_0_dram_bandwidth_for_display(struct dce10_wm_params
*wm
)
795 /* Calculate DRAM Bandwidth and the part allocated to display. */
796 fixed20_12 disp_dram_allocation
; /* 0.3 to 0.7 */
797 fixed20_12 yclk
, dram_channels
, bandwidth
;
800 a
.full
= dfixed_const(1000);
801 yclk
.full
= dfixed_const(wm
->yclk
);
802 yclk
.full
= dfixed_div(yclk
, a
);
803 dram_channels
.full
= dfixed_const(wm
->dram_channels
* 4);
804 a
.full
= dfixed_const(10);
805 disp_dram_allocation
.full
= dfixed_const(3); /* XXX worse case value 0.3 */
806 disp_dram_allocation
.full
= dfixed_div(disp_dram_allocation
, a
);
807 bandwidth
.full
= dfixed_mul(dram_channels
, yclk
);
808 bandwidth
.full
= dfixed_mul(bandwidth
, disp_dram_allocation
);
810 return dfixed_trunc(bandwidth
);
814 * dce_v10_0_data_return_bandwidth - get the data return bandwidth
816 * @wm: watermark calculation data
818 * Calculate the data return bandwidth used for display (CIK).
819 * Used for display watermark bandwidth calculations
820 * Returns the data return bandwidth in MBytes/s
822 static u32
dce_v10_0_data_return_bandwidth(struct dce10_wm_params
*wm
)
824 /* Calculate the display Data return Bandwidth */
825 fixed20_12 return_efficiency
; /* 0.8 */
826 fixed20_12 sclk
, bandwidth
;
829 a
.full
= dfixed_const(1000);
830 sclk
.full
= dfixed_const(wm
->sclk
);
831 sclk
.full
= dfixed_div(sclk
, a
);
832 a
.full
= dfixed_const(10);
833 return_efficiency
.full
= dfixed_const(8);
834 return_efficiency
.full
= dfixed_div(return_efficiency
, a
);
835 a
.full
= dfixed_const(32);
836 bandwidth
.full
= dfixed_mul(a
, sclk
);
837 bandwidth
.full
= dfixed_mul(bandwidth
, return_efficiency
);
839 return dfixed_trunc(bandwidth
);
843 * dce_v10_0_dmif_request_bandwidth - get the dmif bandwidth
845 * @wm: watermark calculation data
847 * Calculate the dmif bandwidth used for display (CIK).
848 * Used for display watermark bandwidth calculations
849 * Returns the dmif bandwidth in MBytes/s
851 static u32
dce_v10_0_dmif_request_bandwidth(struct dce10_wm_params
*wm
)
853 /* Calculate the DMIF Request Bandwidth */
854 fixed20_12 disp_clk_request_efficiency
; /* 0.8 */
855 fixed20_12 disp_clk
, bandwidth
;
858 a
.full
= dfixed_const(1000);
859 disp_clk
.full
= dfixed_const(wm
->disp_clk
);
860 disp_clk
.full
= dfixed_div(disp_clk
, a
);
861 a
.full
= dfixed_const(32);
862 b
.full
= dfixed_mul(a
, disp_clk
);
864 a
.full
= dfixed_const(10);
865 disp_clk_request_efficiency
.full
= dfixed_const(8);
866 disp_clk_request_efficiency
.full
= dfixed_div(disp_clk_request_efficiency
, a
);
868 bandwidth
.full
= dfixed_mul(b
, disp_clk_request_efficiency
);
870 return dfixed_trunc(bandwidth
);
874 * dce_v10_0_available_bandwidth - get the min available bandwidth
876 * @wm: watermark calculation data
878 * Calculate the min available bandwidth used for display (CIK).
879 * Used for display watermark bandwidth calculations
880 * Returns the min available bandwidth in MBytes/s
882 static u32
dce_v10_0_available_bandwidth(struct dce10_wm_params
*wm
)
884 /* Calculate the Available bandwidth. Display can use this temporarily but not in average. */
885 u32 dram_bandwidth
= dce_v10_0_dram_bandwidth(wm
);
886 u32 data_return_bandwidth
= dce_v10_0_data_return_bandwidth(wm
);
887 u32 dmif_req_bandwidth
= dce_v10_0_dmif_request_bandwidth(wm
);
889 return min(dram_bandwidth
, min(data_return_bandwidth
, dmif_req_bandwidth
));
893 * dce_v10_0_average_bandwidth - get the average available bandwidth
895 * @wm: watermark calculation data
897 * Calculate the average available bandwidth used for display (CIK).
898 * Used for display watermark bandwidth calculations
899 * Returns the average available bandwidth in MBytes/s
901 static u32
dce_v10_0_average_bandwidth(struct dce10_wm_params
*wm
)
903 /* Calculate the display mode Average Bandwidth
904 * DisplayMode should contain the source and destination dimensions,
908 fixed20_12 line_time
;
909 fixed20_12 src_width
;
910 fixed20_12 bandwidth
;
913 a
.full
= dfixed_const(1000);
914 line_time
.full
= dfixed_const(wm
->active_time
+ wm
->blank_time
);
915 line_time
.full
= dfixed_div(line_time
, a
);
916 bpp
.full
= dfixed_const(wm
->bytes_per_pixel
);
917 src_width
.full
= dfixed_const(wm
->src_width
);
918 bandwidth
.full
= dfixed_mul(src_width
, bpp
);
919 bandwidth
.full
= dfixed_mul(bandwidth
, wm
->vsc
);
920 bandwidth
.full
= dfixed_div(bandwidth
, line_time
);
922 return dfixed_trunc(bandwidth
);
926 * dce_v10_0_latency_watermark - get the latency watermark
928 * @wm: watermark calculation data
930 * Calculate the latency watermark (CIK).
931 * Used for display watermark bandwidth calculations
932 * Returns the latency watermark in ns
934 static u32
dce_v10_0_latency_watermark(struct dce10_wm_params
*wm
)
936 /* First calculate the latency in ns */
937 u32 mc_latency
= 2000; /* 2000 ns. */
938 u32 available_bandwidth
= dce_v10_0_available_bandwidth(wm
);
939 u32 worst_chunk_return_time
= (512 * 8 * 1000) / available_bandwidth
;
940 u32 cursor_line_pair_return_time
= (128 * 4 * 1000) / available_bandwidth
;
941 u32 dc_latency
= 40000000 / wm
->disp_clk
; /* dc pipe latency */
942 u32 other_heads_data_return_time
= ((wm
->num_heads
+ 1) * worst_chunk_return_time
) +
943 (wm
->num_heads
* cursor_line_pair_return_time
);
944 u32 latency
= mc_latency
+ other_heads_data_return_time
+ dc_latency
;
945 u32 max_src_lines_per_dst_line
, lb_fill_bw
, line_fill_time
;
946 u32 tmp
, dmif_size
= 12288;
949 if (wm
->num_heads
== 0)
952 a
.full
= dfixed_const(2);
953 b
.full
= dfixed_const(1);
954 if ((wm
->vsc
.full
> a
.full
) ||
955 ((wm
->vsc
.full
> b
.full
) && (wm
->vtaps
>= 3)) ||
957 ((wm
->vsc
.full
>= a
.full
) && wm
->interlaced
))
958 max_src_lines_per_dst_line
= 4;
960 max_src_lines_per_dst_line
= 2;
962 a
.full
= dfixed_const(available_bandwidth
);
963 b
.full
= dfixed_const(wm
->num_heads
);
964 a
.full
= dfixed_div(a
, b
);
965 tmp
= div_u64((u64
) dmif_size
* (u64
) wm
->disp_clk
, mc_latency
+ 512);
966 tmp
= min(dfixed_trunc(a
), tmp
);
968 lb_fill_bw
= min(tmp
, wm
->disp_clk
* wm
->bytes_per_pixel
/ 1000);
970 a
.full
= dfixed_const(max_src_lines_per_dst_line
* wm
->src_width
* wm
->bytes_per_pixel
);
971 b
.full
= dfixed_const(1000);
972 c
.full
= dfixed_const(lb_fill_bw
);
973 b
.full
= dfixed_div(c
, b
);
974 a
.full
= dfixed_div(a
, b
);
975 line_fill_time
= dfixed_trunc(a
);
977 if (line_fill_time
< wm
->active_time
)
980 return latency
+ (line_fill_time
- wm
->active_time
);
985 * dce_v10_0_average_bandwidth_vs_dram_bandwidth_for_display - check
986 * average and available dram bandwidth
988 * @wm: watermark calculation data
990 * Check if the display average bandwidth fits in the display
991 * dram bandwidth (CIK).
992 * Used for display watermark bandwidth calculations
993 * Returns true if the display fits, false if not.
995 static bool dce_v10_0_average_bandwidth_vs_dram_bandwidth_for_display(struct dce10_wm_params
*wm
)
997 if (dce_v10_0_average_bandwidth(wm
) <=
998 (dce_v10_0_dram_bandwidth_for_display(wm
) / wm
->num_heads
))
1005 * dce_v10_0_average_bandwidth_vs_available_bandwidth - check
1006 * average and available bandwidth
1008 * @wm: watermark calculation data
1010 * Check if the display average bandwidth fits in the display
1011 * available bandwidth (CIK).
1012 * Used for display watermark bandwidth calculations
1013 * Returns true if the display fits, false if not.
1015 static bool dce_v10_0_average_bandwidth_vs_available_bandwidth(struct dce10_wm_params
*wm
)
1017 if (dce_v10_0_average_bandwidth(wm
) <=
1018 (dce_v10_0_available_bandwidth(wm
) / wm
->num_heads
))
1025 * dce_v10_0_check_latency_hiding - check latency hiding
1027 * @wm: watermark calculation data
1029 * Check latency hiding (CIK).
1030 * Used for display watermark bandwidth calculations
1031 * Returns true if the display fits, false if not.
1033 static bool dce_v10_0_check_latency_hiding(struct dce10_wm_params
*wm
)
1035 u32 lb_partitions
= wm
->lb_size
/ wm
->src_width
;
1036 u32 line_time
= wm
->active_time
+ wm
->blank_time
;
1037 u32 latency_tolerant_lines
;
1041 a
.full
= dfixed_const(1);
1042 if (wm
->vsc
.full
> a
.full
)
1043 latency_tolerant_lines
= 1;
1045 if (lb_partitions
<= (wm
->vtaps
+ 1))
1046 latency_tolerant_lines
= 1;
1048 latency_tolerant_lines
= 2;
1051 latency_hiding
= (latency_tolerant_lines
* line_time
+ wm
->blank_time
);
1053 if (dce_v10_0_latency_watermark(wm
) <= latency_hiding
)
1060 * dce_v10_0_program_watermarks - program display watermarks
1062 * @adev: amdgpu_device pointer
1063 * @amdgpu_crtc: the selected display controller
1064 * @lb_size: line buffer size
1065 * @num_heads: number of display controllers in use
1067 * Calculate and program the display watermarks for the
1068 * selected display controller (CIK).
1070 static void dce_v10_0_program_watermarks(struct amdgpu_device
*adev
,
1071 struct amdgpu_crtc
*amdgpu_crtc
,
1072 u32 lb_size
, u32 num_heads
)
1074 struct drm_display_mode
*mode
= &amdgpu_crtc
->base
.mode
;
1075 struct dce10_wm_params wm_low
, wm_high
;
1078 u32 latency_watermark_a
= 0, latency_watermark_b
= 0;
1079 u32 tmp
, wm_mask
, lb_vblank_lead_lines
= 0;
1081 if (amdgpu_crtc
->base
.enabled
&& num_heads
&& mode
) {
1082 active_time
= (u32
) div_u64((u64
)mode
->crtc_hdisplay
* 1000000,
1084 line_time
= (u32
) div_u64((u64
)mode
->crtc_htotal
* 1000000,
1086 line_time
= min(line_time
, (u32
)65535);
1088 /* watermark for high clocks */
1089 if (adev
->pm
.dpm_enabled
) {
1091 amdgpu_dpm_get_mclk(adev
, false) * 10;
1093 amdgpu_dpm_get_sclk(adev
, false) * 10;
1095 wm_high
.yclk
= adev
->pm
.current_mclk
* 10;
1096 wm_high
.sclk
= adev
->pm
.current_sclk
* 10;
1099 wm_high
.disp_clk
= mode
->clock
;
1100 wm_high
.src_width
= mode
->crtc_hdisplay
;
1101 wm_high
.active_time
= active_time
;
1102 wm_high
.blank_time
= line_time
- wm_high
.active_time
;
1103 wm_high
.interlaced
= false;
1104 if (mode
->flags
& DRM_MODE_FLAG_INTERLACE
)
1105 wm_high
.interlaced
= true;
1106 wm_high
.vsc
= amdgpu_crtc
->vsc
;
1108 if (amdgpu_crtc
->rmx_type
!= RMX_OFF
)
1110 wm_high
.bytes_per_pixel
= 4; /* XXX: get this from fb config */
1111 wm_high
.lb_size
= lb_size
;
1112 wm_high
.dram_channels
= cik_get_number_of_dram_channels(adev
);
1113 wm_high
.num_heads
= num_heads
;
1115 /* set for high clocks */
1116 latency_watermark_a
= min(dce_v10_0_latency_watermark(&wm_high
), (u32
)65535);
1118 /* possibly force display priority to high */
1119 /* should really do this at mode validation time... */
1120 if (!dce_v10_0_average_bandwidth_vs_dram_bandwidth_for_display(&wm_high
) ||
1121 !dce_v10_0_average_bandwidth_vs_available_bandwidth(&wm_high
) ||
1122 !dce_v10_0_check_latency_hiding(&wm_high
) ||
1123 (adev
->mode_info
.disp_priority
== 2)) {
1124 DRM_DEBUG_KMS("force priority to high\n");
1127 /* watermark for low clocks */
1128 if (adev
->pm
.dpm_enabled
) {
1130 amdgpu_dpm_get_mclk(adev
, true) * 10;
1132 amdgpu_dpm_get_sclk(adev
, true) * 10;
1134 wm_low
.yclk
= adev
->pm
.current_mclk
* 10;
1135 wm_low
.sclk
= adev
->pm
.current_sclk
* 10;
1138 wm_low
.disp_clk
= mode
->clock
;
1139 wm_low
.src_width
= mode
->crtc_hdisplay
;
1140 wm_low
.active_time
= active_time
;
1141 wm_low
.blank_time
= line_time
- wm_low
.active_time
;
1142 wm_low
.interlaced
= false;
1143 if (mode
->flags
& DRM_MODE_FLAG_INTERLACE
)
1144 wm_low
.interlaced
= true;
1145 wm_low
.vsc
= amdgpu_crtc
->vsc
;
1147 if (amdgpu_crtc
->rmx_type
!= RMX_OFF
)
1149 wm_low
.bytes_per_pixel
= 4; /* XXX: get this from fb config */
1150 wm_low
.lb_size
= lb_size
;
1151 wm_low
.dram_channels
= cik_get_number_of_dram_channels(adev
);
1152 wm_low
.num_heads
= num_heads
;
1154 /* set for low clocks */
1155 latency_watermark_b
= min(dce_v10_0_latency_watermark(&wm_low
), (u32
)65535);
1157 /* possibly force display priority to high */
1158 /* should really do this at mode validation time... */
1159 if (!dce_v10_0_average_bandwidth_vs_dram_bandwidth_for_display(&wm_low
) ||
1160 !dce_v10_0_average_bandwidth_vs_available_bandwidth(&wm_low
) ||
1161 !dce_v10_0_check_latency_hiding(&wm_low
) ||
1162 (adev
->mode_info
.disp_priority
== 2)) {
1163 DRM_DEBUG_KMS("force priority to high\n");
1165 lb_vblank_lead_lines
= DIV_ROUND_UP(lb_size
, mode
->crtc_hdisplay
);
1169 wm_mask
= RREG32(mmDPG_WATERMARK_MASK_CONTROL
+ amdgpu_crtc
->crtc_offset
);
1170 tmp
= REG_SET_FIELD(wm_mask
, DPG_WATERMARK_MASK_CONTROL
, URGENCY_WATERMARK_MASK
, 1);
1171 WREG32(mmDPG_WATERMARK_MASK_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
1172 tmp
= RREG32(mmDPG_PIPE_URGENCY_CONTROL
+ amdgpu_crtc
->crtc_offset
);
1173 tmp
= REG_SET_FIELD(tmp
, DPG_PIPE_URGENCY_CONTROL
, URGENCY_LOW_WATERMARK
, latency_watermark_a
);
1174 tmp
= REG_SET_FIELD(tmp
, DPG_PIPE_URGENCY_CONTROL
, URGENCY_HIGH_WATERMARK
, line_time
);
1175 WREG32(mmDPG_PIPE_URGENCY_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
1177 tmp
= REG_SET_FIELD(wm_mask
, DPG_WATERMARK_MASK_CONTROL
, URGENCY_WATERMARK_MASK
, 2);
1178 WREG32(mmDPG_WATERMARK_MASK_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
1179 tmp
= RREG32(mmDPG_PIPE_URGENCY_CONTROL
+ amdgpu_crtc
->crtc_offset
);
1180 tmp
= REG_SET_FIELD(tmp
, DPG_PIPE_URGENCY_CONTROL
, URGENCY_LOW_WATERMARK
, latency_watermark_b
);
1181 tmp
= REG_SET_FIELD(tmp
, DPG_PIPE_URGENCY_CONTROL
, URGENCY_HIGH_WATERMARK
, line_time
);
1182 WREG32(mmDPG_PIPE_URGENCY_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
1183 /* restore original selection */
1184 WREG32(mmDPG_WATERMARK_MASK_CONTROL
+ amdgpu_crtc
->crtc_offset
, wm_mask
);
1186 /* save values for DPM */
1187 amdgpu_crtc
->line_time
= line_time
;
1188 amdgpu_crtc
->wm_high
= latency_watermark_a
;
1189 amdgpu_crtc
->wm_low
= latency_watermark_b
;
1190 /* Save number of lines the linebuffer leads before the scanout */
1191 amdgpu_crtc
->lb_vblank_lead_lines
= lb_vblank_lead_lines
;
1195 * dce_v10_0_bandwidth_update - program display watermarks
1197 * @adev: amdgpu_device pointer
1199 * Calculate and program the display watermarks and line
1200 * buffer allocation (CIK).
1202 static void dce_v10_0_bandwidth_update(struct amdgpu_device
*adev
)
1204 struct drm_display_mode
*mode
= NULL
;
1205 u32 num_heads
= 0, lb_size
;
1208 amdgpu_update_display_priority(adev
);
1210 for (i
= 0; i
< adev
->mode_info
.num_crtc
; i
++) {
1211 if (adev
->mode_info
.crtcs
[i
]->base
.enabled
)
1214 for (i
= 0; i
< adev
->mode_info
.num_crtc
; i
++) {
1215 mode
= &adev
->mode_info
.crtcs
[i
]->base
.mode
;
1216 lb_size
= dce_v10_0_line_buffer_adjust(adev
, adev
->mode_info
.crtcs
[i
], mode
);
1217 dce_v10_0_program_watermarks(adev
, adev
->mode_info
.crtcs
[i
],
1218 lb_size
, num_heads
);
1222 static void dce_v10_0_audio_get_connected_pins(struct amdgpu_device
*adev
)
1227 for (i
= 0; i
< adev
->mode_info
.audio
.num_pins
; i
++) {
1228 offset
= adev
->mode_info
.audio
.pin
[i
].offset
;
1229 tmp
= RREG32_AUDIO_ENDPT(offset
,
1230 ixAZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_CONFIGURATION_DEFAULT
);
1232 AZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_CONFIGURATION_DEFAULT__PORT_CONNECTIVITY_MASK
) >>
1233 AZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_CONFIGURATION_DEFAULT__PORT_CONNECTIVITY__SHIFT
) == 1)
1234 adev
->mode_info
.audio
.pin
[i
].connected
= false;
1236 adev
->mode_info
.audio
.pin
[i
].connected
= true;
1240 static struct amdgpu_audio_pin
*dce_v10_0_audio_get_pin(struct amdgpu_device
*adev
)
1244 dce_v10_0_audio_get_connected_pins(adev
);
1246 for (i
= 0; i
< adev
->mode_info
.audio
.num_pins
; i
++) {
1247 if (adev
->mode_info
.audio
.pin
[i
].connected
)
1248 return &adev
->mode_info
.audio
.pin
[i
];
1250 DRM_ERROR("No connected audio pins found!\n");
1254 static void dce_v10_0_afmt_audio_select_pin(struct drm_encoder
*encoder
)
1256 struct amdgpu_device
*adev
= encoder
->dev
->dev_private
;
1257 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1258 struct amdgpu_encoder_atom_dig
*dig
= amdgpu_encoder
->enc_priv
;
1261 if (!dig
|| !dig
->afmt
|| !dig
->afmt
->pin
)
1264 tmp
= RREG32(mmAFMT_AUDIO_SRC_CONTROL
+ dig
->afmt
->offset
);
1265 tmp
= REG_SET_FIELD(tmp
, AFMT_AUDIO_SRC_CONTROL
, AFMT_AUDIO_SRC_SELECT
, dig
->afmt
->pin
->id
);
1266 WREG32(mmAFMT_AUDIO_SRC_CONTROL
+ dig
->afmt
->offset
, tmp
);
1269 static void dce_v10_0_audio_write_latency_fields(struct drm_encoder
*encoder
,
1270 struct drm_display_mode
*mode
)
1272 struct amdgpu_device
*adev
= encoder
->dev
->dev_private
;
1273 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1274 struct amdgpu_encoder_atom_dig
*dig
= amdgpu_encoder
->enc_priv
;
1275 struct drm_connector
*connector
;
1276 struct amdgpu_connector
*amdgpu_connector
= NULL
;
1280 if (!dig
|| !dig
->afmt
|| !dig
->afmt
->pin
)
1283 list_for_each_entry(connector
, &encoder
->dev
->mode_config
.connector_list
, head
) {
1284 if (connector
->encoder
== encoder
) {
1285 amdgpu_connector
= to_amdgpu_connector(connector
);
1290 if (!amdgpu_connector
) {
1291 DRM_ERROR("Couldn't find encoder's connector\n");
1295 if (mode
->flags
& DRM_MODE_FLAG_INTERLACE
)
1297 if (connector
->latency_present
[interlace
]) {
1298 tmp
= REG_SET_FIELD(0, AZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC
,
1299 VIDEO_LIPSYNC
, connector
->video_latency
[interlace
]);
1300 tmp
= REG_SET_FIELD(0, AZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC
,
1301 AUDIO_LIPSYNC
, connector
->audio_latency
[interlace
]);
1303 tmp
= REG_SET_FIELD(0, AZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC
,
1305 tmp
= REG_SET_FIELD(0, AZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC
,
1308 WREG32_AUDIO_ENDPT(dig
->afmt
->pin
->offset
,
1309 ixAZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC
, tmp
);
1312 static void dce_v10_0_audio_write_speaker_allocation(struct drm_encoder
*encoder
)
1314 struct amdgpu_device
*adev
= encoder
->dev
->dev_private
;
1315 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1316 struct amdgpu_encoder_atom_dig
*dig
= amdgpu_encoder
->enc_priv
;
1317 struct drm_connector
*connector
;
1318 struct amdgpu_connector
*amdgpu_connector
= NULL
;
1323 if (!dig
|| !dig
->afmt
|| !dig
->afmt
->pin
)
1326 list_for_each_entry(connector
, &encoder
->dev
->mode_config
.connector_list
, head
) {
1327 if (connector
->encoder
== encoder
) {
1328 amdgpu_connector
= to_amdgpu_connector(connector
);
1333 if (!amdgpu_connector
) {
1334 DRM_ERROR("Couldn't find encoder's connector\n");
1338 sad_count
= drm_edid_to_speaker_allocation(amdgpu_connector_edid(connector
), &sadb
);
1339 if (sad_count
< 0) {
1340 DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sad_count
);
1344 /* program the speaker allocation */
1345 tmp
= RREG32_AUDIO_ENDPT(dig
->afmt
->pin
->offset
,
1346 ixAZALIA_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER
);
1347 tmp
= REG_SET_FIELD(tmp
, AZALIA_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER
,
1350 tmp
= REG_SET_FIELD(tmp
, AZALIA_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER
,
1351 HDMI_CONNECTION
, 1);
1353 tmp
= REG_SET_FIELD(tmp
, AZALIA_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER
,
1354 SPEAKER_ALLOCATION
, sadb
[0]);
1356 tmp
= REG_SET_FIELD(tmp
, AZALIA_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER
,
1357 SPEAKER_ALLOCATION
, 5); /* stereo */
1358 WREG32_AUDIO_ENDPT(dig
->afmt
->pin
->offset
,
1359 ixAZALIA_F0_CODEC_PIN_CONTROL_CHANNEL_SPEAKER
, tmp
);
1364 static void dce_v10_0_audio_write_sad_regs(struct drm_encoder
*encoder
)
1366 struct amdgpu_device
*adev
= encoder
->dev
->dev_private
;
1367 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1368 struct amdgpu_encoder_atom_dig
*dig
= amdgpu_encoder
->enc_priv
;
1369 struct drm_connector
*connector
;
1370 struct amdgpu_connector
*amdgpu_connector
= NULL
;
1371 struct cea_sad
*sads
;
1374 static const u16 eld_reg_to_type
[][2] = {
1375 { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0
, HDMI_AUDIO_CODING_TYPE_PCM
},
1376 { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR1
, HDMI_AUDIO_CODING_TYPE_AC3
},
1377 { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR2
, HDMI_AUDIO_CODING_TYPE_MPEG1
},
1378 { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR3
, HDMI_AUDIO_CODING_TYPE_MP3
},
1379 { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR4
, HDMI_AUDIO_CODING_TYPE_MPEG2
},
1380 { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR5
, HDMI_AUDIO_CODING_TYPE_AAC_LC
},
1381 { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR6
, HDMI_AUDIO_CODING_TYPE_DTS
},
1382 { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR7
, HDMI_AUDIO_CODING_TYPE_ATRAC
},
1383 { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR9
, HDMI_AUDIO_CODING_TYPE_EAC3
},
1384 { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR10
, HDMI_AUDIO_CODING_TYPE_DTS_HD
},
1385 { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR11
, HDMI_AUDIO_CODING_TYPE_MLP
},
1386 { ixAZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13
, HDMI_AUDIO_CODING_TYPE_WMA_PRO
},
1389 if (!dig
|| !dig
->afmt
|| !dig
->afmt
->pin
)
1392 list_for_each_entry(connector
, &encoder
->dev
->mode_config
.connector_list
, head
) {
1393 if (connector
->encoder
== encoder
) {
1394 amdgpu_connector
= to_amdgpu_connector(connector
);
1399 if (!amdgpu_connector
) {
1400 DRM_ERROR("Couldn't find encoder's connector\n");
1404 sad_count
= drm_edid_to_sad(amdgpu_connector_edid(connector
), &sads
);
1405 if (sad_count
<= 0) {
1406 DRM_ERROR("Couldn't read SADs: %d\n", sad_count
);
1411 for (i
= 0; i
< ARRAY_SIZE(eld_reg_to_type
); i
++) {
1413 u8 stereo_freqs
= 0;
1414 int max_channels
= -1;
1417 for (j
= 0; j
< sad_count
; j
++) {
1418 struct cea_sad
*sad
= &sads
[j
];
1420 if (sad
->format
== eld_reg_to_type
[i
][1]) {
1421 if (sad
->channels
> max_channels
) {
1422 tmp
= REG_SET_FIELD(tmp
, AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0
,
1423 MAX_CHANNELS
, sad
->channels
);
1424 tmp
= REG_SET_FIELD(tmp
, AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0
,
1425 DESCRIPTOR_BYTE_2
, sad
->byte2
);
1426 tmp
= REG_SET_FIELD(tmp
, AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0
,
1427 SUPPORTED_FREQUENCIES
, sad
->freq
);
1428 max_channels
= sad
->channels
;
1431 if (sad
->format
== HDMI_AUDIO_CODING_TYPE_PCM
)
1432 stereo_freqs
|= sad
->freq
;
1438 tmp
= REG_SET_FIELD(tmp
, AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0
,
1439 SUPPORTED_FREQUENCIES_STEREO
, stereo_freqs
);
1440 WREG32_AUDIO_ENDPT(dig
->afmt
->pin
->offset
, eld_reg_to_type
[i
][0], tmp
);
1446 static void dce_v10_0_audio_enable(struct amdgpu_device
*adev
,
1447 struct amdgpu_audio_pin
*pin
,
1453 WREG32_AUDIO_ENDPT(pin
->offset
, ixAZALIA_F0_CODEC_PIN_CONTROL_HOT_PLUG_CONTROL
,
1454 enable
? AZALIA_F0_CODEC_PIN_CONTROL_HOT_PLUG_CONTROL__AUDIO_ENABLED_MASK
: 0);
1457 static const u32 pin_offsets
[] =
1459 AUD0_REGISTER_OFFSET
,
1460 AUD1_REGISTER_OFFSET
,
1461 AUD2_REGISTER_OFFSET
,
1462 AUD3_REGISTER_OFFSET
,
1463 AUD4_REGISTER_OFFSET
,
1464 AUD5_REGISTER_OFFSET
,
1465 AUD6_REGISTER_OFFSET
,
1468 static int dce_v10_0_audio_init(struct amdgpu_device
*adev
)
1475 adev
->mode_info
.audio
.enabled
= true;
1477 adev
->mode_info
.audio
.num_pins
= 7;
1479 for (i
= 0; i
< adev
->mode_info
.audio
.num_pins
; i
++) {
1480 adev
->mode_info
.audio
.pin
[i
].channels
= -1;
1481 adev
->mode_info
.audio
.pin
[i
].rate
= -1;
1482 adev
->mode_info
.audio
.pin
[i
].bits_per_sample
= -1;
1483 adev
->mode_info
.audio
.pin
[i
].status_bits
= 0;
1484 adev
->mode_info
.audio
.pin
[i
].category_code
= 0;
1485 adev
->mode_info
.audio
.pin
[i
].connected
= false;
1486 adev
->mode_info
.audio
.pin
[i
].offset
= pin_offsets
[i
];
1487 adev
->mode_info
.audio
.pin
[i
].id
= i
;
1488 /* disable audio. it will be set up later */
1489 /* XXX remove once we switch to ip funcs */
1490 dce_v10_0_audio_enable(adev
, &adev
->mode_info
.audio
.pin
[i
], false);
1496 static void dce_v10_0_audio_fini(struct amdgpu_device
*adev
)
1503 if (!adev
->mode_info
.audio
.enabled
)
1506 for (i
= 0; i
< adev
->mode_info
.audio
.num_pins
; i
++)
1507 dce_v10_0_audio_enable(adev
, &adev
->mode_info
.audio
.pin
[i
], false);
1509 adev
->mode_info
.audio
.enabled
= false;
1513 * update the N and CTS parameters for a given pixel clock rate
1515 static void dce_v10_0_afmt_update_ACR(struct drm_encoder
*encoder
, uint32_t clock
)
1517 struct drm_device
*dev
= encoder
->dev
;
1518 struct amdgpu_device
*adev
= dev
->dev_private
;
1519 struct amdgpu_afmt_acr acr
= amdgpu_afmt_acr(clock
);
1520 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1521 struct amdgpu_encoder_atom_dig
*dig
= amdgpu_encoder
->enc_priv
;
1524 tmp
= RREG32(mmHDMI_ACR_32_0
+ dig
->afmt
->offset
);
1525 tmp
= REG_SET_FIELD(tmp
, HDMI_ACR_32_0
, HDMI_ACR_CTS_32
, acr
.cts_32khz
);
1526 WREG32(mmHDMI_ACR_32_0
+ dig
->afmt
->offset
, tmp
);
1527 tmp
= RREG32(mmHDMI_ACR_32_1
+ dig
->afmt
->offset
);
1528 tmp
= REG_SET_FIELD(tmp
, HDMI_ACR_32_1
, HDMI_ACR_N_32
, acr
.n_32khz
);
1529 WREG32(mmHDMI_ACR_32_1
+ dig
->afmt
->offset
, tmp
);
1531 tmp
= RREG32(mmHDMI_ACR_44_0
+ dig
->afmt
->offset
);
1532 tmp
= REG_SET_FIELD(tmp
, HDMI_ACR_44_0
, HDMI_ACR_CTS_44
, acr
.cts_44_1khz
);
1533 WREG32(mmHDMI_ACR_44_0
+ dig
->afmt
->offset
, tmp
);
1534 tmp
= RREG32(mmHDMI_ACR_44_1
+ dig
->afmt
->offset
);
1535 tmp
= REG_SET_FIELD(tmp
, HDMI_ACR_44_1
, HDMI_ACR_N_44
, acr
.n_44_1khz
);
1536 WREG32(mmHDMI_ACR_44_1
+ dig
->afmt
->offset
, tmp
);
1538 tmp
= RREG32(mmHDMI_ACR_48_0
+ dig
->afmt
->offset
);
1539 tmp
= REG_SET_FIELD(tmp
, HDMI_ACR_48_0
, HDMI_ACR_CTS_48
, acr
.cts_48khz
);
1540 WREG32(mmHDMI_ACR_48_0
+ dig
->afmt
->offset
, tmp
);
1541 tmp
= RREG32(mmHDMI_ACR_48_1
+ dig
->afmt
->offset
);
1542 tmp
= REG_SET_FIELD(tmp
, HDMI_ACR_48_1
, HDMI_ACR_N_48
, acr
.n_48khz
);
1543 WREG32(mmHDMI_ACR_48_1
+ dig
->afmt
->offset
, tmp
);
1548 * build a HDMI Video Info Frame
1550 static void dce_v10_0_afmt_update_avi_infoframe(struct drm_encoder
*encoder
,
1551 void *buffer
, size_t size
)
1553 struct drm_device
*dev
= encoder
->dev
;
1554 struct amdgpu_device
*adev
= dev
->dev_private
;
1555 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1556 struct amdgpu_encoder_atom_dig
*dig
= amdgpu_encoder
->enc_priv
;
1557 uint8_t *frame
= buffer
+ 3;
1558 uint8_t *header
= buffer
;
1560 WREG32(mmAFMT_AVI_INFO0
+ dig
->afmt
->offset
,
1561 frame
[0x0] | (frame
[0x1] << 8) | (frame
[0x2] << 16) | (frame
[0x3] << 24));
1562 WREG32(mmAFMT_AVI_INFO1
+ dig
->afmt
->offset
,
1563 frame
[0x4] | (frame
[0x5] << 8) | (frame
[0x6] << 16) | (frame
[0x7] << 24));
1564 WREG32(mmAFMT_AVI_INFO2
+ dig
->afmt
->offset
,
1565 frame
[0x8] | (frame
[0x9] << 8) | (frame
[0xA] << 16) | (frame
[0xB] << 24));
1566 WREG32(mmAFMT_AVI_INFO3
+ dig
->afmt
->offset
,
1567 frame
[0xC] | (frame
[0xD] << 8) | (header
[1] << 24));
1570 static void dce_v10_0_audio_set_dto(struct drm_encoder
*encoder
, u32 clock
)
1572 struct drm_device
*dev
= encoder
->dev
;
1573 struct amdgpu_device
*adev
= dev
->dev_private
;
1574 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1575 struct amdgpu_encoder_atom_dig
*dig
= amdgpu_encoder
->enc_priv
;
1576 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(encoder
->crtc
);
1577 u32 dto_phase
= 24 * 1000;
1578 u32 dto_modulo
= clock
;
1581 if (!dig
|| !dig
->afmt
)
1584 /* XXX two dtos; generally use dto0 for hdmi */
1585 /* Express [24MHz / target pixel clock] as an exact rational
1586 * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE
1587 * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator
1589 tmp
= RREG32(mmDCCG_AUDIO_DTO_SOURCE
);
1590 tmp
= REG_SET_FIELD(tmp
, DCCG_AUDIO_DTO_SOURCE
, DCCG_AUDIO_DTO0_SOURCE_SEL
,
1591 amdgpu_crtc
->crtc_id
);
1592 WREG32(mmDCCG_AUDIO_DTO_SOURCE
, tmp
);
1593 WREG32(mmDCCG_AUDIO_DTO0_PHASE
, dto_phase
);
1594 WREG32(mmDCCG_AUDIO_DTO0_MODULE
, dto_modulo
);
1598 * update the info frames with the data from the current display mode
1600 static void dce_v10_0_afmt_setmode(struct drm_encoder
*encoder
,
1601 struct drm_display_mode
*mode
)
1603 struct drm_device
*dev
= encoder
->dev
;
1604 struct amdgpu_device
*adev
= dev
->dev_private
;
1605 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1606 struct amdgpu_encoder_atom_dig
*dig
= amdgpu_encoder
->enc_priv
;
1607 struct drm_connector
*connector
= amdgpu_get_connector_for_encoder(encoder
);
1608 u8 buffer
[HDMI_INFOFRAME_HEADER_SIZE
+ HDMI_AVI_INFOFRAME_SIZE
];
1609 struct hdmi_avi_infoframe frame
;
1614 if (!dig
|| !dig
->afmt
)
1617 /* Silent, r600_hdmi_enable will raise WARN for us */
1618 if (!dig
->afmt
->enabled
)
1621 /* hdmi deep color mode general control packets setup, if bpc > 8 */
1622 if (encoder
->crtc
) {
1623 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(encoder
->crtc
);
1624 bpc
= amdgpu_crtc
->bpc
;
1627 /* disable audio prior to setting up hw */
1628 dig
->afmt
->pin
= dce_v10_0_audio_get_pin(adev
);
1629 dce_v10_0_audio_enable(adev
, dig
->afmt
->pin
, false);
1631 dce_v10_0_audio_set_dto(encoder
, mode
->clock
);
1633 tmp
= RREG32(mmHDMI_VBI_PACKET_CONTROL
+ dig
->afmt
->offset
);
1634 tmp
= REG_SET_FIELD(tmp
, HDMI_VBI_PACKET_CONTROL
, HDMI_NULL_SEND
, 1);
1635 WREG32(mmHDMI_VBI_PACKET_CONTROL
+ dig
->afmt
->offset
, tmp
); /* send null packets when required */
1637 WREG32(mmAFMT_AUDIO_CRC_CONTROL
+ dig
->afmt
->offset
, 0x1000);
1639 tmp
= RREG32(mmHDMI_CONTROL
+ dig
->afmt
->offset
);
1646 tmp
= REG_SET_FIELD(tmp
, HDMI_CONTROL
, HDMI_DEEP_COLOR_ENABLE
, 0);
1647 tmp
= REG_SET_FIELD(tmp
, HDMI_CONTROL
, HDMI_DEEP_COLOR_DEPTH
, 0);
1648 DRM_DEBUG("%s: Disabling hdmi deep color for %d bpc.\n",
1649 connector
->name
, bpc
);
1652 tmp
= REG_SET_FIELD(tmp
, HDMI_CONTROL
, HDMI_DEEP_COLOR_ENABLE
, 1);
1653 tmp
= REG_SET_FIELD(tmp
, HDMI_CONTROL
, HDMI_DEEP_COLOR_DEPTH
, 1);
1654 DRM_DEBUG("%s: Enabling hdmi deep color 30 for 10 bpc.\n",
1658 tmp
= REG_SET_FIELD(tmp
, HDMI_CONTROL
, HDMI_DEEP_COLOR_ENABLE
, 1);
1659 tmp
= REG_SET_FIELD(tmp
, HDMI_CONTROL
, HDMI_DEEP_COLOR_DEPTH
, 2);
1660 DRM_DEBUG("%s: Enabling hdmi deep color 36 for 12 bpc.\n",
1664 WREG32(mmHDMI_CONTROL
+ dig
->afmt
->offset
, tmp
);
1666 tmp
= RREG32(mmHDMI_VBI_PACKET_CONTROL
+ dig
->afmt
->offset
);
1667 tmp
= REG_SET_FIELD(tmp
, HDMI_VBI_PACKET_CONTROL
, HDMI_NULL_SEND
, 1); /* send null packets when required */
1668 tmp
= REG_SET_FIELD(tmp
, HDMI_VBI_PACKET_CONTROL
, HDMI_GC_SEND
, 1); /* send general control packets */
1669 tmp
= REG_SET_FIELD(tmp
, HDMI_VBI_PACKET_CONTROL
, HDMI_GC_CONT
, 1); /* send general control packets every frame */
1670 WREG32(mmHDMI_VBI_PACKET_CONTROL
+ dig
->afmt
->offset
, tmp
);
1672 tmp
= RREG32(mmHDMI_INFOFRAME_CONTROL0
+ dig
->afmt
->offset
);
1673 /* enable audio info frames (frames won't be set until audio is enabled) */
1674 tmp
= REG_SET_FIELD(tmp
, HDMI_INFOFRAME_CONTROL0
, HDMI_AUDIO_INFO_SEND
, 1);
1675 /* required for audio info values to be updated */
1676 tmp
= REG_SET_FIELD(tmp
, HDMI_INFOFRAME_CONTROL0
, HDMI_AUDIO_INFO_CONT
, 1);
1677 WREG32(mmHDMI_INFOFRAME_CONTROL0
+ dig
->afmt
->offset
, tmp
);
1679 tmp
= RREG32(mmAFMT_INFOFRAME_CONTROL0
+ dig
->afmt
->offset
);
1680 /* required for audio info values to be updated */
1681 tmp
= REG_SET_FIELD(tmp
, AFMT_INFOFRAME_CONTROL0
, AFMT_AUDIO_INFO_UPDATE
, 1);
1682 WREG32(mmAFMT_INFOFRAME_CONTROL0
+ dig
->afmt
->offset
, tmp
);
1684 tmp
= RREG32(mmHDMI_INFOFRAME_CONTROL1
+ dig
->afmt
->offset
);
1685 /* anything other than 0 */
1686 tmp
= REG_SET_FIELD(tmp
, HDMI_INFOFRAME_CONTROL1
, HDMI_AUDIO_INFO_LINE
, 2);
1687 WREG32(mmHDMI_INFOFRAME_CONTROL1
+ dig
->afmt
->offset
, tmp
);
1689 WREG32(mmHDMI_GC
+ dig
->afmt
->offset
, 0); /* unset HDMI_GC_AVMUTE */
1691 tmp
= RREG32(mmHDMI_AUDIO_PACKET_CONTROL
+ dig
->afmt
->offset
);
1692 /* set the default audio delay */
1693 tmp
= REG_SET_FIELD(tmp
, HDMI_AUDIO_PACKET_CONTROL
, HDMI_AUDIO_DELAY_EN
, 1);
1694 /* should be suffient for all audio modes and small enough for all hblanks */
1695 tmp
= REG_SET_FIELD(tmp
, HDMI_AUDIO_PACKET_CONTROL
, HDMI_AUDIO_PACKETS_PER_LINE
, 3);
1696 WREG32(mmHDMI_AUDIO_PACKET_CONTROL
+ dig
->afmt
->offset
, tmp
);
1698 tmp
= RREG32(mmAFMT_AUDIO_PACKET_CONTROL
+ dig
->afmt
->offset
);
1699 /* allow 60958 channel status fields to be updated */
1700 tmp
= REG_SET_FIELD(tmp
, AFMT_AUDIO_PACKET_CONTROL
, AFMT_60958_CS_UPDATE
, 1);
1701 WREG32(mmAFMT_AUDIO_PACKET_CONTROL
+ dig
->afmt
->offset
, tmp
);
1703 tmp
= RREG32(mmHDMI_ACR_PACKET_CONTROL
+ dig
->afmt
->offset
);
1705 /* clear SW CTS value */
1706 tmp
= REG_SET_FIELD(tmp
, HDMI_ACR_PACKET_CONTROL
, HDMI_ACR_SOURCE
, 0);
1708 /* select SW CTS value */
1709 tmp
= REG_SET_FIELD(tmp
, HDMI_ACR_PACKET_CONTROL
, HDMI_ACR_SOURCE
, 1);
1710 /* allow hw to sent ACR packets when required */
1711 tmp
= REG_SET_FIELD(tmp
, HDMI_ACR_PACKET_CONTROL
, HDMI_ACR_AUTO_SEND
, 1);
1712 WREG32(mmHDMI_ACR_PACKET_CONTROL
+ dig
->afmt
->offset
, tmp
);
1714 dce_v10_0_afmt_update_ACR(encoder
, mode
->clock
);
1716 tmp
= RREG32(mmAFMT_60958_0
+ dig
->afmt
->offset
);
1717 tmp
= REG_SET_FIELD(tmp
, AFMT_60958_0
, AFMT_60958_CS_CHANNEL_NUMBER_L
, 1);
1718 WREG32(mmAFMT_60958_0
+ dig
->afmt
->offset
, tmp
);
1720 tmp
= RREG32(mmAFMT_60958_1
+ dig
->afmt
->offset
);
1721 tmp
= REG_SET_FIELD(tmp
, AFMT_60958_1
, AFMT_60958_CS_CHANNEL_NUMBER_R
, 2);
1722 WREG32(mmAFMT_60958_1
+ dig
->afmt
->offset
, tmp
);
1724 tmp
= RREG32(mmAFMT_60958_2
+ dig
->afmt
->offset
);
1725 tmp
= REG_SET_FIELD(tmp
, AFMT_60958_2
, AFMT_60958_CS_CHANNEL_NUMBER_2
, 3);
1726 tmp
= REG_SET_FIELD(tmp
, AFMT_60958_2
, AFMT_60958_CS_CHANNEL_NUMBER_3
, 4);
1727 tmp
= REG_SET_FIELD(tmp
, AFMT_60958_2
, AFMT_60958_CS_CHANNEL_NUMBER_4
, 5);
1728 tmp
= REG_SET_FIELD(tmp
, AFMT_60958_2
, AFMT_60958_CS_CHANNEL_NUMBER_5
, 6);
1729 tmp
= REG_SET_FIELD(tmp
, AFMT_60958_2
, AFMT_60958_CS_CHANNEL_NUMBER_6
, 7);
1730 tmp
= REG_SET_FIELD(tmp
, AFMT_60958_2
, AFMT_60958_CS_CHANNEL_NUMBER_7
, 8);
1731 WREG32(mmAFMT_60958_2
+ dig
->afmt
->offset
, tmp
);
1733 dce_v10_0_audio_write_speaker_allocation(encoder
);
1735 WREG32(mmAFMT_AUDIO_PACKET_CONTROL2
+ dig
->afmt
->offset
,
1736 (0xff << AFMT_AUDIO_PACKET_CONTROL2__AFMT_AUDIO_CHANNEL_ENABLE__SHIFT
));
1738 dce_v10_0_afmt_audio_select_pin(encoder
);
1739 dce_v10_0_audio_write_sad_regs(encoder
);
1740 dce_v10_0_audio_write_latency_fields(encoder
, mode
);
1742 err
= drm_hdmi_avi_infoframe_from_display_mode(&frame
, mode
, false);
1744 DRM_ERROR("failed to setup AVI infoframe: %zd\n", err
);
1748 err
= hdmi_avi_infoframe_pack(&frame
, buffer
, sizeof(buffer
));
1750 DRM_ERROR("failed to pack AVI infoframe: %zd\n", err
);
1754 dce_v10_0_afmt_update_avi_infoframe(encoder
, buffer
, sizeof(buffer
));
1756 tmp
= RREG32(mmHDMI_INFOFRAME_CONTROL0
+ dig
->afmt
->offset
);
1757 /* enable AVI info frames */
1758 tmp
= REG_SET_FIELD(tmp
, HDMI_INFOFRAME_CONTROL0
, HDMI_AVI_INFO_SEND
, 1);
1759 /* required for audio info values to be updated */
1760 tmp
= REG_SET_FIELD(tmp
, HDMI_INFOFRAME_CONTROL0
, HDMI_AVI_INFO_CONT
, 1);
1761 WREG32(mmHDMI_INFOFRAME_CONTROL0
+ dig
->afmt
->offset
, tmp
);
1763 tmp
= RREG32(mmHDMI_INFOFRAME_CONTROL1
+ dig
->afmt
->offset
);
1764 tmp
= REG_SET_FIELD(tmp
, HDMI_INFOFRAME_CONTROL1
, HDMI_AVI_INFO_LINE
, 2);
1765 WREG32(mmHDMI_INFOFRAME_CONTROL1
+ dig
->afmt
->offset
, tmp
);
1767 tmp
= RREG32(mmAFMT_AUDIO_PACKET_CONTROL
+ dig
->afmt
->offset
);
1768 /* send audio packets */
1769 tmp
= REG_SET_FIELD(tmp
, AFMT_AUDIO_PACKET_CONTROL
, AFMT_AUDIO_SAMPLE_SEND
, 1);
1770 WREG32(mmAFMT_AUDIO_PACKET_CONTROL
+ dig
->afmt
->offset
, tmp
);
1772 WREG32(mmAFMT_RAMP_CONTROL0
+ dig
->afmt
->offset
, 0x00FFFFFF);
1773 WREG32(mmAFMT_RAMP_CONTROL1
+ dig
->afmt
->offset
, 0x007FFFFF);
1774 WREG32(mmAFMT_RAMP_CONTROL2
+ dig
->afmt
->offset
, 0x00000001);
1775 WREG32(mmAFMT_RAMP_CONTROL3
+ dig
->afmt
->offset
, 0x00000001);
1777 /* enable audio after to setting up hw */
1778 dce_v10_0_audio_enable(adev
, dig
->afmt
->pin
, true);
1781 static void dce_v10_0_afmt_enable(struct drm_encoder
*encoder
, bool enable
)
1783 struct drm_device
*dev
= encoder
->dev
;
1784 struct amdgpu_device
*adev
= dev
->dev_private
;
1785 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1786 struct amdgpu_encoder_atom_dig
*dig
= amdgpu_encoder
->enc_priv
;
1788 if (!dig
|| !dig
->afmt
)
1791 /* Silent, r600_hdmi_enable will raise WARN for us */
1792 if (enable
&& dig
->afmt
->enabled
)
1794 if (!enable
&& !dig
->afmt
->enabled
)
1797 if (!enable
&& dig
->afmt
->pin
) {
1798 dce_v10_0_audio_enable(adev
, dig
->afmt
->pin
, false);
1799 dig
->afmt
->pin
= NULL
;
1802 dig
->afmt
->enabled
= enable
;
1804 DRM_DEBUG("%sabling AFMT interface @ 0x%04X for encoder 0x%x\n",
1805 enable
? "En" : "Dis", dig
->afmt
->offset
, amdgpu_encoder
->encoder_id
);
1808 static int dce_v10_0_afmt_init(struct amdgpu_device
*adev
)
1812 for (i
= 0; i
< adev
->mode_info
.num_dig
; i
++)
1813 adev
->mode_info
.afmt
[i
] = NULL
;
1815 /* DCE10 has audio blocks tied to DIG encoders */
1816 for (i
= 0; i
< adev
->mode_info
.num_dig
; i
++) {
1817 adev
->mode_info
.afmt
[i
] = kzalloc(sizeof(struct amdgpu_afmt
), GFP_KERNEL
);
1818 if (adev
->mode_info
.afmt
[i
]) {
1819 adev
->mode_info
.afmt
[i
]->offset
= dig_offsets
[i
];
1820 adev
->mode_info
.afmt
[i
]->id
= i
;
1823 for (j
= 0; j
< i
; j
++) {
1824 kfree(adev
->mode_info
.afmt
[j
]);
1825 adev
->mode_info
.afmt
[j
] = NULL
;
1833 static void dce_v10_0_afmt_fini(struct amdgpu_device
*adev
)
1837 for (i
= 0; i
< adev
->mode_info
.num_dig
; i
++) {
1838 kfree(adev
->mode_info
.afmt
[i
]);
1839 adev
->mode_info
.afmt
[i
] = NULL
;
1843 static const u32 vga_control_regs
[6] =
1853 static void dce_v10_0_vga_enable(struct drm_crtc
*crtc
, bool enable
)
1855 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
1856 struct drm_device
*dev
= crtc
->dev
;
1857 struct amdgpu_device
*adev
= dev
->dev_private
;
1860 vga_control
= RREG32(vga_control_regs
[amdgpu_crtc
->crtc_id
]) & ~1;
1862 WREG32(vga_control_regs
[amdgpu_crtc
->crtc_id
], vga_control
| 1);
1864 WREG32(vga_control_regs
[amdgpu_crtc
->crtc_id
], vga_control
);
1867 static void dce_v10_0_grph_enable(struct drm_crtc
*crtc
, bool enable
)
1869 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
1870 struct drm_device
*dev
= crtc
->dev
;
1871 struct amdgpu_device
*adev
= dev
->dev_private
;
1874 WREG32(mmGRPH_ENABLE
+ amdgpu_crtc
->crtc_offset
, 1);
1876 WREG32(mmGRPH_ENABLE
+ amdgpu_crtc
->crtc_offset
, 0);
1879 static int dce_v10_0_crtc_do_set_base(struct drm_crtc
*crtc
,
1880 struct drm_framebuffer
*fb
,
1881 int x
, int y
, int atomic
)
1883 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
1884 struct drm_device
*dev
= crtc
->dev
;
1885 struct amdgpu_device
*adev
= dev
->dev_private
;
1886 struct amdgpu_framebuffer
*amdgpu_fb
;
1887 struct drm_framebuffer
*target_fb
;
1888 struct drm_gem_object
*obj
;
1889 struct amdgpu_bo
*abo
;
1890 uint64_t fb_location
, tiling_flags
;
1891 uint32_t fb_format
, fb_pitch_pixels
;
1892 u32 fb_swap
= REG_SET_FIELD(0, GRPH_SWAP_CNTL
, GRPH_ENDIAN_SWAP
, ENDIAN_NONE
);
1894 u32 tmp
, viewport_w
, viewport_h
;
1896 bool bypass_lut
= false;
1897 struct drm_format_name_buf format_name
;
1900 if (!atomic
&& !crtc
->primary
->fb
) {
1901 DRM_DEBUG_KMS("No FB bound\n");
1906 amdgpu_fb
= to_amdgpu_framebuffer(fb
);
1909 amdgpu_fb
= to_amdgpu_framebuffer(crtc
->primary
->fb
);
1910 target_fb
= crtc
->primary
->fb
;
1913 /* If atomic, assume fb object is pinned & idle & fenced and
1914 * just update base pointers
1916 obj
= amdgpu_fb
->obj
;
1917 abo
= gem_to_amdgpu_bo(obj
);
1918 r
= amdgpu_bo_reserve(abo
, false);
1919 if (unlikely(r
!= 0))
1923 fb_location
= amdgpu_bo_gpu_offset(abo
);
1925 r
= amdgpu_bo_pin(abo
, AMDGPU_GEM_DOMAIN_VRAM
, &fb_location
);
1926 if (unlikely(r
!= 0)) {
1927 amdgpu_bo_unreserve(abo
);
1932 amdgpu_bo_get_tiling_flags(abo
, &tiling_flags
);
1933 amdgpu_bo_unreserve(abo
);
1935 pipe_config
= AMDGPU_TILING_GET(tiling_flags
, PIPE_CONFIG
);
1937 switch (target_fb
->format
->format
) {
1939 fb_format
= REG_SET_FIELD(0, GRPH_CONTROL
, GRPH_DEPTH
, 0);
1940 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_FORMAT
, 0);
1942 case DRM_FORMAT_XRGB4444
:
1943 case DRM_FORMAT_ARGB4444
:
1944 fb_format
= REG_SET_FIELD(0, GRPH_CONTROL
, GRPH_DEPTH
, 1);
1945 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_FORMAT
, 2);
1947 fb_swap
= REG_SET_FIELD(fb_swap
, GRPH_SWAP_CNTL
, GRPH_ENDIAN_SWAP
,
1951 case DRM_FORMAT_XRGB1555
:
1952 case DRM_FORMAT_ARGB1555
:
1953 fb_format
= REG_SET_FIELD(0, GRPH_CONTROL
, GRPH_DEPTH
, 1);
1954 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_FORMAT
, 0);
1956 fb_swap
= REG_SET_FIELD(fb_swap
, GRPH_SWAP_CNTL
, GRPH_ENDIAN_SWAP
,
1960 case DRM_FORMAT_BGRX5551
:
1961 case DRM_FORMAT_BGRA5551
:
1962 fb_format
= REG_SET_FIELD(0, GRPH_CONTROL
, GRPH_DEPTH
, 1);
1963 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_FORMAT
, 5);
1965 fb_swap
= REG_SET_FIELD(fb_swap
, GRPH_SWAP_CNTL
, GRPH_ENDIAN_SWAP
,
1969 case DRM_FORMAT_RGB565
:
1970 fb_format
= REG_SET_FIELD(0, GRPH_CONTROL
, GRPH_DEPTH
, 1);
1971 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_FORMAT
, 1);
1973 fb_swap
= REG_SET_FIELD(fb_swap
, GRPH_SWAP_CNTL
, GRPH_ENDIAN_SWAP
,
1977 case DRM_FORMAT_XRGB8888
:
1978 case DRM_FORMAT_ARGB8888
:
1979 fb_format
= REG_SET_FIELD(0, GRPH_CONTROL
, GRPH_DEPTH
, 2);
1980 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_FORMAT
, 0);
1982 fb_swap
= REG_SET_FIELD(fb_swap
, GRPH_SWAP_CNTL
, GRPH_ENDIAN_SWAP
,
1986 case DRM_FORMAT_XRGB2101010
:
1987 case DRM_FORMAT_ARGB2101010
:
1988 fb_format
= REG_SET_FIELD(0, GRPH_CONTROL
, GRPH_DEPTH
, 2);
1989 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_FORMAT
, 1);
1991 fb_swap
= REG_SET_FIELD(fb_swap
, GRPH_SWAP_CNTL
, GRPH_ENDIAN_SWAP
,
1994 /* Greater 8 bpc fb needs to bypass hw-lut to retain precision */
1997 case DRM_FORMAT_BGRX1010102
:
1998 case DRM_FORMAT_BGRA1010102
:
1999 fb_format
= REG_SET_FIELD(0, GRPH_CONTROL
, GRPH_DEPTH
, 2);
2000 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_FORMAT
, 4);
2002 fb_swap
= REG_SET_FIELD(fb_swap
, GRPH_SWAP_CNTL
, GRPH_ENDIAN_SWAP
,
2005 /* Greater 8 bpc fb needs to bypass hw-lut to retain precision */
2009 DRM_ERROR("Unsupported screen format %s\n",
2010 drm_get_format_name(target_fb
->format
->format
, &format_name
));
2014 if (AMDGPU_TILING_GET(tiling_flags
, ARRAY_MODE
) == ARRAY_2D_TILED_THIN1
) {
2015 unsigned bankw
, bankh
, mtaspect
, tile_split
, num_banks
;
2017 bankw
= AMDGPU_TILING_GET(tiling_flags
, BANK_WIDTH
);
2018 bankh
= AMDGPU_TILING_GET(tiling_flags
, BANK_HEIGHT
);
2019 mtaspect
= AMDGPU_TILING_GET(tiling_flags
, MACRO_TILE_ASPECT
);
2020 tile_split
= AMDGPU_TILING_GET(tiling_flags
, TILE_SPLIT
);
2021 num_banks
= AMDGPU_TILING_GET(tiling_flags
, NUM_BANKS
);
2023 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_NUM_BANKS
, num_banks
);
2024 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_ARRAY_MODE
,
2025 ARRAY_2D_TILED_THIN1
);
2026 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_TILE_SPLIT
,
2028 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_BANK_WIDTH
, bankw
);
2029 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_BANK_HEIGHT
, bankh
);
2030 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_MACRO_TILE_ASPECT
,
2032 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_MICRO_TILE_MODE
,
2033 ADDR_SURF_MICRO_TILING_DISPLAY
);
2034 } else if (AMDGPU_TILING_GET(tiling_flags
, ARRAY_MODE
) == ARRAY_1D_TILED_THIN1
) {
2035 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_ARRAY_MODE
,
2036 ARRAY_1D_TILED_THIN1
);
2039 fb_format
= REG_SET_FIELD(fb_format
, GRPH_CONTROL
, GRPH_PIPE_CONFIG
,
2042 dce_v10_0_vga_enable(crtc
, false);
2044 /* Make sure surface address is updated at vertical blank rather than
2047 tmp
= RREG32(mmGRPH_FLIP_CONTROL
+ amdgpu_crtc
->crtc_offset
);
2048 tmp
= REG_SET_FIELD(tmp
, GRPH_FLIP_CONTROL
,
2049 GRPH_SURFACE_UPDATE_H_RETRACE_EN
, 0);
2050 WREG32(mmGRPH_FLIP_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
2052 WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS_HIGH
+ amdgpu_crtc
->crtc_offset
,
2053 upper_32_bits(fb_location
));
2054 WREG32(mmGRPH_SECONDARY_SURFACE_ADDRESS_HIGH
+ amdgpu_crtc
->crtc_offset
,
2055 upper_32_bits(fb_location
));
2056 WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS
+ amdgpu_crtc
->crtc_offset
,
2057 (u32
)fb_location
& GRPH_PRIMARY_SURFACE_ADDRESS__GRPH_PRIMARY_SURFACE_ADDRESS_MASK
);
2058 WREG32(mmGRPH_SECONDARY_SURFACE_ADDRESS
+ amdgpu_crtc
->crtc_offset
,
2059 (u32
) fb_location
& GRPH_SECONDARY_SURFACE_ADDRESS__GRPH_SECONDARY_SURFACE_ADDRESS_MASK
);
2060 WREG32(mmGRPH_CONTROL
+ amdgpu_crtc
->crtc_offset
, fb_format
);
2061 WREG32(mmGRPH_SWAP_CNTL
+ amdgpu_crtc
->crtc_offset
, fb_swap
);
2064 * The LUT only has 256 slots for indexing by a 8 bpc fb. Bypass the LUT
2065 * for > 8 bpc scanout to avoid truncation of fb indices to 8 msb's, to
2066 * retain the full precision throughout the pipeline.
2068 tmp
= RREG32(mmGRPH_LUT_10BIT_BYPASS
+ amdgpu_crtc
->crtc_offset
);
2070 tmp
= REG_SET_FIELD(tmp
, GRPH_LUT_10BIT_BYPASS
, GRPH_LUT_10BIT_BYPASS_EN
, 1);
2072 tmp
= REG_SET_FIELD(tmp
, GRPH_LUT_10BIT_BYPASS
, GRPH_LUT_10BIT_BYPASS_EN
, 0);
2073 WREG32(mmGRPH_LUT_10BIT_BYPASS
+ amdgpu_crtc
->crtc_offset
, tmp
);
2076 DRM_DEBUG_KMS("Bypassing hardware LUT due to 10 bit fb scanout.\n");
2078 WREG32(mmGRPH_SURFACE_OFFSET_X
+ amdgpu_crtc
->crtc_offset
, 0);
2079 WREG32(mmGRPH_SURFACE_OFFSET_Y
+ amdgpu_crtc
->crtc_offset
, 0);
2080 WREG32(mmGRPH_X_START
+ amdgpu_crtc
->crtc_offset
, 0);
2081 WREG32(mmGRPH_Y_START
+ amdgpu_crtc
->crtc_offset
, 0);
2082 WREG32(mmGRPH_X_END
+ amdgpu_crtc
->crtc_offset
, target_fb
->width
);
2083 WREG32(mmGRPH_Y_END
+ amdgpu_crtc
->crtc_offset
, target_fb
->height
);
2085 fb_pitch_pixels
= target_fb
->pitches
[0] / target_fb
->format
->cpp
[0];
2086 WREG32(mmGRPH_PITCH
+ amdgpu_crtc
->crtc_offset
, fb_pitch_pixels
);
2088 dce_v10_0_grph_enable(crtc
, true);
2090 WREG32(mmLB_DESKTOP_HEIGHT
+ amdgpu_crtc
->crtc_offset
,
2095 WREG32(mmVIEWPORT_START
+ amdgpu_crtc
->crtc_offset
,
2097 viewport_w
= crtc
->mode
.hdisplay
;
2098 viewport_h
= (crtc
->mode
.vdisplay
+ 1) & ~1;
2099 WREG32(mmVIEWPORT_SIZE
+ amdgpu_crtc
->crtc_offset
,
2100 (viewport_w
<< 16) | viewport_h
);
2102 /* set pageflip to happen anywhere in vblank interval */
2103 WREG32(mmMASTER_UPDATE_MODE
+ amdgpu_crtc
->crtc_offset
, 0);
2105 if (!atomic
&& fb
&& fb
!= crtc
->primary
->fb
) {
2106 amdgpu_fb
= to_amdgpu_framebuffer(fb
);
2107 abo
= gem_to_amdgpu_bo(amdgpu_fb
->obj
);
2108 r
= amdgpu_bo_reserve(abo
, true);
2109 if (unlikely(r
!= 0))
2111 amdgpu_bo_unpin(abo
);
2112 amdgpu_bo_unreserve(abo
);
2115 /* Bytes per pixel may have changed */
2116 dce_v10_0_bandwidth_update(adev
);
2121 static void dce_v10_0_set_interleave(struct drm_crtc
*crtc
,
2122 struct drm_display_mode
*mode
)
2124 struct drm_device
*dev
= crtc
->dev
;
2125 struct amdgpu_device
*adev
= dev
->dev_private
;
2126 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2129 tmp
= RREG32(mmLB_DATA_FORMAT
+ amdgpu_crtc
->crtc_offset
);
2130 if (mode
->flags
& DRM_MODE_FLAG_INTERLACE
)
2131 tmp
= REG_SET_FIELD(tmp
, LB_DATA_FORMAT
, INTERLEAVE_EN
, 1);
2133 tmp
= REG_SET_FIELD(tmp
, LB_DATA_FORMAT
, INTERLEAVE_EN
, 0);
2134 WREG32(mmLB_DATA_FORMAT
+ amdgpu_crtc
->crtc_offset
, tmp
);
2137 static void dce_v10_0_crtc_load_lut(struct drm_crtc
*crtc
)
2139 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2140 struct drm_device
*dev
= crtc
->dev
;
2141 struct amdgpu_device
*adev
= dev
->dev_private
;
2146 DRM_DEBUG_KMS("%d\n", amdgpu_crtc
->crtc_id
);
2148 tmp
= RREG32(mmINPUT_CSC_CONTROL
+ amdgpu_crtc
->crtc_offset
);
2149 tmp
= REG_SET_FIELD(tmp
, INPUT_CSC_CONTROL
, INPUT_CSC_GRPH_MODE
, 0);
2150 tmp
= REG_SET_FIELD(tmp
, INPUT_CSC_CONTROL
, INPUT_CSC_OVL_MODE
, 0);
2151 WREG32(mmINPUT_CSC_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
2153 tmp
= RREG32(mmPRESCALE_GRPH_CONTROL
+ amdgpu_crtc
->crtc_offset
);
2154 tmp
= REG_SET_FIELD(tmp
, PRESCALE_GRPH_CONTROL
, GRPH_PRESCALE_BYPASS
, 1);
2155 WREG32(mmPRESCALE_GRPH_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
2157 tmp
= RREG32(mmPRESCALE_OVL_CONTROL
+ amdgpu_crtc
->crtc_offset
);
2158 tmp
= REG_SET_FIELD(tmp
, PRESCALE_OVL_CONTROL
, OVL_PRESCALE_BYPASS
, 1);
2159 WREG32(mmPRESCALE_OVL_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
2161 tmp
= RREG32(mmINPUT_GAMMA_CONTROL
+ amdgpu_crtc
->crtc_offset
);
2162 tmp
= REG_SET_FIELD(tmp
, INPUT_GAMMA_CONTROL
, GRPH_INPUT_GAMMA_MODE
, 0);
2163 tmp
= REG_SET_FIELD(tmp
, INPUT_GAMMA_CONTROL
, OVL_INPUT_GAMMA_MODE
, 0);
2164 WREG32(mmINPUT_GAMMA_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
2166 WREG32(mmDC_LUT_CONTROL
+ amdgpu_crtc
->crtc_offset
, 0);
2168 WREG32(mmDC_LUT_BLACK_OFFSET_BLUE
+ amdgpu_crtc
->crtc_offset
, 0);
2169 WREG32(mmDC_LUT_BLACK_OFFSET_GREEN
+ amdgpu_crtc
->crtc_offset
, 0);
2170 WREG32(mmDC_LUT_BLACK_OFFSET_RED
+ amdgpu_crtc
->crtc_offset
, 0);
2172 WREG32(mmDC_LUT_WHITE_OFFSET_BLUE
+ amdgpu_crtc
->crtc_offset
, 0xffff);
2173 WREG32(mmDC_LUT_WHITE_OFFSET_GREEN
+ amdgpu_crtc
->crtc_offset
, 0xffff);
2174 WREG32(mmDC_LUT_WHITE_OFFSET_RED
+ amdgpu_crtc
->crtc_offset
, 0xffff);
2176 WREG32(mmDC_LUT_RW_MODE
+ amdgpu_crtc
->crtc_offset
, 0);
2177 WREG32(mmDC_LUT_WRITE_EN_MASK
+ amdgpu_crtc
->crtc_offset
, 0x00000007);
2179 WREG32(mmDC_LUT_RW_INDEX
+ amdgpu_crtc
->crtc_offset
, 0);
2180 r
= crtc
->gamma_store
;
2181 g
= r
+ crtc
->gamma_size
;
2182 b
= g
+ crtc
->gamma_size
;
2183 for (i
= 0; i
< 256; i
++) {
2184 WREG32(mmDC_LUT_30_COLOR
+ amdgpu_crtc
->crtc_offset
,
2185 ((*r
++ & 0xffc0) << 14) |
2186 ((*g
++ & 0xffc0) << 4) |
2190 tmp
= RREG32(mmDEGAMMA_CONTROL
+ amdgpu_crtc
->crtc_offset
);
2191 tmp
= REG_SET_FIELD(tmp
, DEGAMMA_CONTROL
, GRPH_DEGAMMA_MODE
, 0);
2192 tmp
= REG_SET_FIELD(tmp
, DEGAMMA_CONTROL
, OVL_DEGAMMA_MODE
, 0);
2193 tmp
= REG_SET_FIELD(tmp
, DEGAMMA_CONTROL
, CURSOR_DEGAMMA_MODE
, 0);
2194 WREG32(mmDEGAMMA_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
2196 tmp
= RREG32(mmGAMUT_REMAP_CONTROL
+ amdgpu_crtc
->crtc_offset
);
2197 tmp
= REG_SET_FIELD(tmp
, GAMUT_REMAP_CONTROL
, GRPH_GAMUT_REMAP_MODE
, 0);
2198 tmp
= REG_SET_FIELD(tmp
, GAMUT_REMAP_CONTROL
, OVL_GAMUT_REMAP_MODE
, 0);
2199 WREG32(mmGAMUT_REMAP_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
2201 tmp
= RREG32(mmREGAMMA_CONTROL
+ amdgpu_crtc
->crtc_offset
);
2202 tmp
= REG_SET_FIELD(tmp
, REGAMMA_CONTROL
, GRPH_REGAMMA_MODE
, 0);
2203 tmp
= REG_SET_FIELD(tmp
, REGAMMA_CONTROL
, OVL_REGAMMA_MODE
, 0);
2204 WREG32(mmREGAMMA_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
2206 tmp
= RREG32(mmOUTPUT_CSC_CONTROL
+ amdgpu_crtc
->crtc_offset
);
2207 tmp
= REG_SET_FIELD(tmp
, OUTPUT_CSC_CONTROL
, OUTPUT_CSC_GRPH_MODE
, 0);
2208 tmp
= REG_SET_FIELD(tmp
, OUTPUT_CSC_CONTROL
, OUTPUT_CSC_OVL_MODE
, 0);
2209 WREG32(mmOUTPUT_CSC_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
2211 /* XXX match this to the depth of the crtc fmt block, move to modeset? */
2212 WREG32(mmDENORM_CONTROL
+ amdgpu_crtc
->crtc_offset
, 0);
2213 /* XXX this only needs to be programmed once per crtc at startup,
2214 * not sure where the best place for it is
2216 tmp
= RREG32(mmALPHA_CONTROL
+ amdgpu_crtc
->crtc_offset
);
2217 tmp
= REG_SET_FIELD(tmp
, ALPHA_CONTROL
, CURSOR_ALPHA_BLND_ENA
, 1);
2218 WREG32(mmALPHA_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
2221 static int dce_v10_0_pick_dig_encoder(struct drm_encoder
*encoder
)
2223 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
2224 struct amdgpu_encoder_atom_dig
*dig
= amdgpu_encoder
->enc_priv
;
2226 switch (amdgpu_encoder
->encoder_id
) {
2227 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
2233 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
:
2239 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
:
2245 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY3
:
2249 DRM_ERROR("invalid encoder_id: 0x%x\n", amdgpu_encoder
->encoder_id
);
2255 * dce_v10_0_pick_pll - Allocate a PPLL for use by the crtc.
2259 * Returns the PPLL (Pixel PLL) to be used by the crtc. For DP monitors
2260 * a single PPLL can be used for all DP crtcs/encoders. For non-DP
2261 * monitors a dedicated PPLL must be used. If a particular board has
2262 * an external DP PLL, return ATOM_PPLL_INVALID to skip PLL programming
2263 * as there is no need to program the PLL itself. If we are not able to
2264 * allocate a PLL, return ATOM_PPLL_INVALID to skip PLL programming to
2265 * avoid messing up an existing monitor.
2267 * Asic specific PLL information
2271 * - PPLL1, PPLL2 are available for all UNIPHY (both DP and non-DP)
2273 * - PPLL0, PPLL1, PPLL2 are available for all UNIPHY (both DP and non-DP) and DAC
2276 static u32
dce_v10_0_pick_pll(struct drm_crtc
*crtc
)
2278 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2279 struct drm_device
*dev
= crtc
->dev
;
2280 struct amdgpu_device
*adev
= dev
->dev_private
;
2284 if (ENCODER_MODE_IS_DP(amdgpu_atombios_encoder_get_encoder_mode(amdgpu_crtc
->encoder
))) {
2285 if (adev
->clock
.dp_extclk
)
2286 /* skip PPLL programming if using ext clock */
2287 return ATOM_PPLL_INVALID
;
2289 /* use the same PPLL for all DP monitors */
2290 pll
= amdgpu_pll_get_shared_dp_ppll(crtc
);
2291 if (pll
!= ATOM_PPLL_INVALID
)
2295 /* use the same PPLL for all monitors with the same clock */
2296 pll
= amdgpu_pll_get_shared_nondp_ppll(crtc
);
2297 if (pll
!= ATOM_PPLL_INVALID
)
2301 /* DCE10 has PPLL0, PPLL1, and PPLL2 */
2302 pll_in_use
= amdgpu_pll_get_use_mask(crtc
);
2303 if (!(pll_in_use
& (1 << ATOM_PPLL2
)))
2305 if (!(pll_in_use
& (1 << ATOM_PPLL1
)))
2307 if (!(pll_in_use
& (1 << ATOM_PPLL0
)))
2309 DRM_ERROR("unable to allocate a PPLL\n");
2310 return ATOM_PPLL_INVALID
;
2313 static void dce_v10_0_lock_cursor(struct drm_crtc
*crtc
, bool lock
)
2315 struct amdgpu_device
*adev
= crtc
->dev
->dev_private
;
2316 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2319 cur_lock
= RREG32(mmCUR_UPDATE
+ amdgpu_crtc
->crtc_offset
);
2321 cur_lock
= REG_SET_FIELD(cur_lock
, CUR_UPDATE
, CURSOR_UPDATE_LOCK
, 1);
2323 cur_lock
= REG_SET_FIELD(cur_lock
, CUR_UPDATE
, CURSOR_UPDATE_LOCK
, 0);
2324 WREG32(mmCUR_UPDATE
+ amdgpu_crtc
->crtc_offset
, cur_lock
);
2327 static void dce_v10_0_hide_cursor(struct drm_crtc
*crtc
)
2329 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2330 struct amdgpu_device
*adev
= crtc
->dev
->dev_private
;
2333 tmp
= RREG32_IDX(mmCUR_CONTROL
+ amdgpu_crtc
->crtc_offset
);
2334 tmp
= REG_SET_FIELD(tmp
, CUR_CONTROL
, CURSOR_EN
, 0);
2335 WREG32_IDX(mmCUR_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
2338 static void dce_v10_0_show_cursor(struct drm_crtc
*crtc
)
2340 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2341 struct amdgpu_device
*adev
= crtc
->dev
->dev_private
;
2344 WREG32(mmCUR_SURFACE_ADDRESS_HIGH
+ amdgpu_crtc
->crtc_offset
,
2345 upper_32_bits(amdgpu_crtc
->cursor_addr
));
2346 WREG32(mmCUR_SURFACE_ADDRESS
+ amdgpu_crtc
->crtc_offset
,
2347 lower_32_bits(amdgpu_crtc
->cursor_addr
));
2349 tmp
= RREG32_IDX(mmCUR_CONTROL
+ amdgpu_crtc
->crtc_offset
);
2350 tmp
= REG_SET_FIELD(tmp
, CUR_CONTROL
, CURSOR_EN
, 1);
2351 tmp
= REG_SET_FIELD(tmp
, CUR_CONTROL
, CURSOR_MODE
, 2);
2352 WREG32_IDX(mmCUR_CONTROL
+ amdgpu_crtc
->crtc_offset
, tmp
);
2355 static int dce_v10_0_cursor_move_locked(struct drm_crtc
*crtc
,
2358 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2359 struct amdgpu_device
*adev
= crtc
->dev
->dev_private
;
2360 int xorigin
= 0, yorigin
= 0;
2362 amdgpu_crtc
->cursor_x
= x
;
2363 amdgpu_crtc
->cursor_y
= y
;
2365 /* avivo cursor are offset into the total surface */
2368 DRM_DEBUG("x %d y %d c->x %d c->y %d\n", x
, y
, crtc
->x
, crtc
->y
);
2371 xorigin
= min(-x
, amdgpu_crtc
->max_cursor_width
- 1);
2375 yorigin
= min(-y
, amdgpu_crtc
->max_cursor_height
- 1);
2379 WREG32(mmCUR_POSITION
+ amdgpu_crtc
->crtc_offset
, (x
<< 16) | y
);
2380 WREG32(mmCUR_HOT_SPOT
+ amdgpu_crtc
->crtc_offset
, (xorigin
<< 16) | yorigin
);
2381 WREG32(mmCUR_SIZE
+ amdgpu_crtc
->crtc_offset
,
2382 ((amdgpu_crtc
->cursor_width
- 1) << 16) | (amdgpu_crtc
->cursor_height
- 1));
2387 static int dce_v10_0_crtc_cursor_move(struct drm_crtc
*crtc
,
2392 dce_v10_0_lock_cursor(crtc
, true);
2393 ret
= dce_v10_0_cursor_move_locked(crtc
, x
, y
);
2394 dce_v10_0_lock_cursor(crtc
, false);
2399 static int dce_v10_0_crtc_cursor_set2(struct drm_crtc
*crtc
,
2400 struct drm_file
*file_priv
,
2407 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2408 struct drm_gem_object
*obj
;
2409 struct amdgpu_bo
*aobj
;
2413 /* turn off cursor */
2414 dce_v10_0_hide_cursor(crtc
);
2419 if ((width
> amdgpu_crtc
->max_cursor_width
) ||
2420 (height
> amdgpu_crtc
->max_cursor_height
)) {
2421 DRM_ERROR("bad cursor width or height %d x %d\n", width
, height
);
2425 obj
= drm_gem_object_lookup(file_priv
, handle
);
2427 DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle
, amdgpu_crtc
->crtc_id
);
2431 aobj
= gem_to_amdgpu_bo(obj
);
2432 ret
= amdgpu_bo_reserve(aobj
, false);
2434 drm_gem_object_put_unlocked(obj
);
2438 ret
= amdgpu_bo_pin(aobj
, AMDGPU_GEM_DOMAIN_VRAM
, &amdgpu_crtc
->cursor_addr
);
2439 amdgpu_bo_unreserve(aobj
);
2441 DRM_ERROR("Failed to pin new cursor BO (%d)\n", ret
);
2442 drm_gem_object_put_unlocked(obj
);
2446 dce_v10_0_lock_cursor(crtc
, true);
2448 if (width
!= amdgpu_crtc
->cursor_width
||
2449 height
!= amdgpu_crtc
->cursor_height
||
2450 hot_x
!= amdgpu_crtc
->cursor_hot_x
||
2451 hot_y
!= amdgpu_crtc
->cursor_hot_y
) {
2454 x
= amdgpu_crtc
->cursor_x
+ amdgpu_crtc
->cursor_hot_x
- hot_x
;
2455 y
= amdgpu_crtc
->cursor_y
+ amdgpu_crtc
->cursor_hot_y
- hot_y
;
2457 dce_v10_0_cursor_move_locked(crtc
, x
, y
);
2459 amdgpu_crtc
->cursor_width
= width
;
2460 amdgpu_crtc
->cursor_height
= height
;
2461 amdgpu_crtc
->cursor_hot_x
= hot_x
;
2462 amdgpu_crtc
->cursor_hot_y
= hot_y
;
2465 dce_v10_0_show_cursor(crtc
);
2466 dce_v10_0_lock_cursor(crtc
, false);
2469 if (amdgpu_crtc
->cursor_bo
) {
2470 struct amdgpu_bo
*aobj
= gem_to_amdgpu_bo(amdgpu_crtc
->cursor_bo
);
2471 ret
= amdgpu_bo_reserve(aobj
, true);
2472 if (likely(ret
== 0)) {
2473 amdgpu_bo_unpin(aobj
);
2474 amdgpu_bo_unreserve(aobj
);
2476 drm_gem_object_put_unlocked(amdgpu_crtc
->cursor_bo
);
2479 amdgpu_crtc
->cursor_bo
= obj
;
2483 static void dce_v10_0_cursor_reset(struct drm_crtc
*crtc
)
2485 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2487 if (amdgpu_crtc
->cursor_bo
) {
2488 dce_v10_0_lock_cursor(crtc
, true);
2490 dce_v10_0_cursor_move_locked(crtc
, amdgpu_crtc
->cursor_x
,
2491 amdgpu_crtc
->cursor_y
);
2493 dce_v10_0_show_cursor(crtc
);
2495 dce_v10_0_lock_cursor(crtc
, false);
2499 static int dce_v10_0_crtc_gamma_set(struct drm_crtc
*crtc
, u16
*red
, u16
*green
,
2500 u16
*blue
, uint32_t size
,
2501 struct drm_modeset_acquire_ctx
*ctx
)
2503 dce_v10_0_crtc_load_lut(crtc
);
2508 static void dce_v10_0_crtc_destroy(struct drm_crtc
*crtc
)
2510 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2512 drm_crtc_cleanup(crtc
);
2516 static const struct drm_crtc_funcs dce_v10_0_crtc_funcs
= {
2517 .cursor_set2
= dce_v10_0_crtc_cursor_set2
,
2518 .cursor_move
= dce_v10_0_crtc_cursor_move
,
2519 .gamma_set
= dce_v10_0_crtc_gamma_set
,
2520 .set_config
= amdgpu_crtc_set_config
,
2521 .destroy
= dce_v10_0_crtc_destroy
,
2522 .page_flip_target
= amdgpu_crtc_page_flip_target
,
2525 static void dce_v10_0_crtc_dpms(struct drm_crtc
*crtc
, int mode
)
2527 struct drm_device
*dev
= crtc
->dev
;
2528 struct amdgpu_device
*adev
= dev
->dev_private
;
2529 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2533 case DRM_MODE_DPMS_ON
:
2534 amdgpu_crtc
->enabled
= true;
2535 amdgpu_atombios_crtc_enable(crtc
, ATOM_ENABLE
);
2536 dce_v10_0_vga_enable(crtc
, true);
2537 amdgpu_atombios_crtc_blank(crtc
, ATOM_DISABLE
);
2538 dce_v10_0_vga_enable(crtc
, false);
2539 /* Make sure VBLANK and PFLIP interrupts are still enabled */
2540 type
= amdgpu_crtc_idx_to_irq_type(adev
, amdgpu_crtc
->crtc_id
);
2541 amdgpu_irq_update(adev
, &adev
->crtc_irq
, type
);
2542 amdgpu_irq_update(adev
, &adev
->pageflip_irq
, type
);
2543 drm_crtc_vblank_on(crtc
);
2544 dce_v10_0_crtc_load_lut(crtc
);
2546 case DRM_MODE_DPMS_STANDBY
:
2547 case DRM_MODE_DPMS_SUSPEND
:
2548 case DRM_MODE_DPMS_OFF
:
2549 drm_crtc_vblank_off(crtc
);
2550 if (amdgpu_crtc
->enabled
) {
2551 dce_v10_0_vga_enable(crtc
, true);
2552 amdgpu_atombios_crtc_blank(crtc
, ATOM_ENABLE
);
2553 dce_v10_0_vga_enable(crtc
, false);
2555 amdgpu_atombios_crtc_enable(crtc
, ATOM_DISABLE
);
2556 amdgpu_crtc
->enabled
= false;
2559 /* adjust pm to dpms */
2560 amdgpu_pm_compute_clocks(adev
);
2563 static void dce_v10_0_crtc_prepare(struct drm_crtc
*crtc
)
2565 /* disable crtc pair power gating before programming */
2566 amdgpu_atombios_crtc_powergate(crtc
, ATOM_DISABLE
);
2567 amdgpu_atombios_crtc_lock(crtc
, ATOM_ENABLE
);
2568 dce_v10_0_crtc_dpms(crtc
, DRM_MODE_DPMS_OFF
);
2571 static void dce_v10_0_crtc_commit(struct drm_crtc
*crtc
)
2573 dce_v10_0_crtc_dpms(crtc
, DRM_MODE_DPMS_ON
);
2574 amdgpu_atombios_crtc_lock(crtc
, ATOM_DISABLE
);
2577 static void dce_v10_0_crtc_disable(struct drm_crtc
*crtc
)
2579 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2580 struct drm_device
*dev
= crtc
->dev
;
2581 struct amdgpu_device
*adev
= dev
->dev_private
;
2582 struct amdgpu_atom_ss ss
;
2585 dce_v10_0_crtc_dpms(crtc
, DRM_MODE_DPMS_OFF
);
2586 if (crtc
->primary
->fb
) {
2588 struct amdgpu_framebuffer
*amdgpu_fb
;
2589 struct amdgpu_bo
*abo
;
2591 amdgpu_fb
= to_amdgpu_framebuffer(crtc
->primary
->fb
);
2592 abo
= gem_to_amdgpu_bo(amdgpu_fb
->obj
);
2593 r
= amdgpu_bo_reserve(abo
, true);
2595 DRM_ERROR("failed to reserve abo before unpin\n");
2597 amdgpu_bo_unpin(abo
);
2598 amdgpu_bo_unreserve(abo
);
2601 /* disable the GRPH */
2602 dce_v10_0_grph_enable(crtc
, false);
2604 amdgpu_atombios_crtc_powergate(crtc
, ATOM_ENABLE
);
2606 for (i
= 0; i
< adev
->mode_info
.num_crtc
; i
++) {
2607 if (adev
->mode_info
.crtcs
[i
] &&
2608 adev
->mode_info
.crtcs
[i
]->enabled
&&
2609 i
!= amdgpu_crtc
->crtc_id
&&
2610 amdgpu_crtc
->pll_id
== adev
->mode_info
.crtcs
[i
]->pll_id
) {
2611 /* one other crtc is using this pll don't turn
2618 switch (amdgpu_crtc
->pll_id
) {
2622 /* disable the ppll */
2623 amdgpu_atombios_crtc_program_pll(crtc
, amdgpu_crtc
->crtc_id
, amdgpu_crtc
->pll_id
,
2624 0, 0, ATOM_DISABLE
, 0, 0, 0, 0, 0, false, &ss
);
2630 amdgpu_crtc
->pll_id
= ATOM_PPLL_INVALID
;
2631 amdgpu_crtc
->adjusted_clock
= 0;
2632 amdgpu_crtc
->encoder
= NULL
;
2633 amdgpu_crtc
->connector
= NULL
;
2636 static int dce_v10_0_crtc_mode_set(struct drm_crtc
*crtc
,
2637 struct drm_display_mode
*mode
,
2638 struct drm_display_mode
*adjusted_mode
,
2639 int x
, int y
, struct drm_framebuffer
*old_fb
)
2641 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2643 if (!amdgpu_crtc
->adjusted_clock
)
2646 amdgpu_atombios_crtc_set_pll(crtc
, adjusted_mode
);
2647 amdgpu_atombios_crtc_set_dtd_timing(crtc
, adjusted_mode
);
2648 dce_v10_0_crtc_do_set_base(crtc
, old_fb
, x
, y
, 0);
2649 amdgpu_atombios_crtc_overscan_setup(crtc
, mode
, adjusted_mode
);
2650 amdgpu_atombios_crtc_scaler_setup(crtc
);
2651 dce_v10_0_cursor_reset(crtc
);
2652 /* update the hw version fpr dpm */
2653 amdgpu_crtc
->hw_mode
= *adjusted_mode
;
2658 static bool dce_v10_0_crtc_mode_fixup(struct drm_crtc
*crtc
,
2659 const struct drm_display_mode
*mode
,
2660 struct drm_display_mode
*adjusted_mode
)
2662 struct amdgpu_crtc
*amdgpu_crtc
= to_amdgpu_crtc(crtc
);
2663 struct drm_device
*dev
= crtc
->dev
;
2664 struct drm_encoder
*encoder
;
2666 /* assign the encoder to the amdgpu crtc to avoid repeated lookups later */
2667 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
2668 if (encoder
->crtc
== crtc
) {
2669 amdgpu_crtc
->encoder
= encoder
;
2670 amdgpu_crtc
->connector
= amdgpu_get_connector_for_encoder(encoder
);
2674 if ((amdgpu_crtc
->encoder
== NULL
) || (amdgpu_crtc
->connector
== NULL
)) {
2675 amdgpu_crtc
->encoder
= NULL
;
2676 amdgpu_crtc
->connector
= NULL
;
2679 if (!amdgpu_crtc_scaling_mode_fixup(crtc
, mode
, adjusted_mode
))
2681 if (amdgpu_atombios_crtc_prepare_pll(crtc
, adjusted_mode
))
2684 amdgpu_crtc
->pll_id
= dce_v10_0_pick_pll(crtc
);
2685 /* if we can't get a PPLL for a non-DP encoder, fail */
2686 if ((amdgpu_crtc
->pll_id
== ATOM_PPLL_INVALID
) &&
2687 !ENCODER_MODE_IS_DP(amdgpu_atombios_encoder_get_encoder_mode(amdgpu_crtc
->encoder
)))
2693 static int dce_v10_0_crtc_set_base(struct drm_crtc
*crtc
, int x
, int y
,
2694 struct drm_framebuffer
*old_fb
)
2696 return dce_v10_0_crtc_do_set_base(crtc
, old_fb
, x
, y
, 0);
2699 static int dce_v10_0_crtc_set_base_atomic(struct drm_crtc
*crtc
,
2700 struct drm_framebuffer
*fb
,
2701 int x
, int y
, enum mode_set_atomic state
)
2703 return dce_v10_0_crtc_do_set_base(crtc
, fb
, x
, y
, 1);
2706 static const struct drm_crtc_helper_funcs dce_v10_0_crtc_helper_funcs
= {
2707 .dpms
= dce_v10_0_crtc_dpms
,
2708 .mode_fixup
= dce_v10_0_crtc_mode_fixup
,
2709 .mode_set
= dce_v10_0_crtc_mode_set
,
2710 .mode_set_base
= dce_v10_0_crtc_set_base
,
2711 .mode_set_base_atomic
= dce_v10_0_crtc_set_base_atomic
,
2712 .prepare
= dce_v10_0_crtc_prepare
,
2713 .commit
= dce_v10_0_crtc_commit
,
2714 .disable
= dce_v10_0_crtc_disable
,
2717 static int dce_v10_0_crtc_init(struct amdgpu_device
*adev
, int index
)
2719 struct amdgpu_crtc
*amdgpu_crtc
;
2721 amdgpu_crtc
= kzalloc(sizeof(struct amdgpu_crtc
) +
2722 (AMDGPUFB_CONN_LIMIT
* sizeof(struct drm_connector
*)), GFP_KERNEL
);
2723 if (amdgpu_crtc
== NULL
)
2726 drm_crtc_init(adev
->ddev
, &amdgpu_crtc
->base
, &dce_v10_0_crtc_funcs
);
2728 drm_mode_crtc_set_gamma_size(&amdgpu_crtc
->base
, 256);
2729 amdgpu_crtc
->crtc_id
= index
;
2730 adev
->mode_info
.crtcs
[index
] = amdgpu_crtc
;
2732 amdgpu_crtc
->max_cursor_width
= 128;
2733 amdgpu_crtc
->max_cursor_height
= 128;
2734 adev
->ddev
->mode_config
.cursor_width
= amdgpu_crtc
->max_cursor_width
;
2735 adev
->ddev
->mode_config
.cursor_height
= amdgpu_crtc
->max_cursor_height
;
2737 switch (amdgpu_crtc
->crtc_id
) {
2740 amdgpu_crtc
->crtc_offset
= CRTC0_REGISTER_OFFSET
;
2743 amdgpu_crtc
->crtc_offset
= CRTC1_REGISTER_OFFSET
;
2746 amdgpu_crtc
->crtc_offset
= CRTC2_REGISTER_OFFSET
;
2749 amdgpu_crtc
->crtc_offset
= CRTC3_REGISTER_OFFSET
;
2752 amdgpu_crtc
->crtc_offset
= CRTC4_REGISTER_OFFSET
;
2755 amdgpu_crtc
->crtc_offset
= CRTC5_REGISTER_OFFSET
;
2759 amdgpu_crtc
->pll_id
= ATOM_PPLL_INVALID
;
2760 amdgpu_crtc
->adjusted_clock
= 0;
2761 amdgpu_crtc
->encoder
= NULL
;
2762 amdgpu_crtc
->connector
= NULL
;
2763 drm_crtc_helper_add(&amdgpu_crtc
->base
, &dce_v10_0_crtc_helper_funcs
);
2768 static int dce_v10_0_early_init(void *handle
)
2770 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
2772 adev
->audio_endpt_rreg
= &dce_v10_0_audio_endpt_rreg
;
2773 adev
->audio_endpt_wreg
= &dce_v10_0_audio_endpt_wreg
;
2775 dce_v10_0_set_display_funcs(adev
);
2777 adev
->mode_info
.num_crtc
= dce_v10_0_get_num_crtc(adev
);
2779 switch (adev
->asic_type
) {
2782 adev
->mode_info
.num_hpd
= 6;
2783 adev
->mode_info
.num_dig
= 7;
2786 /* FIXME: not supported yet */
2790 dce_v10_0_set_irq_funcs(adev
);
2795 static int dce_v10_0_sw_init(void *handle
)
2798 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
2800 for (i
= 0; i
< adev
->mode_info
.num_crtc
; i
++) {
2801 r
= amdgpu_irq_add_id(adev
, AMDGPU_IH_CLIENTID_LEGACY
, i
+ 1, &adev
->crtc_irq
);
2806 for (i
= 8; i
< 20; i
+= 2) {
2807 r
= amdgpu_irq_add_id(adev
, AMDGPU_IH_CLIENTID_LEGACY
, i
, &adev
->pageflip_irq
);
2813 r
= amdgpu_irq_add_id(adev
, AMDGPU_IH_CLIENTID_LEGACY
, 42, &adev
->hpd_irq
);
2817 adev
->ddev
->mode_config
.funcs
= &amdgpu_mode_funcs
;
2819 adev
->ddev
->mode_config
.async_page_flip
= true;
2821 adev
->ddev
->mode_config
.max_width
= 16384;
2822 adev
->ddev
->mode_config
.max_height
= 16384;
2824 adev
->ddev
->mode_config
.preferred_depth
= 24;
2825 adev
->ddev
->mode_config
.prefer_shadow
= 1;
2827 adev
->ddev
->mode_config
.fb_base
= adev
->mc
.aper_base
;
2829 r
= amdgpu_modeset_create_props(adev
);
2833 adev
->ddev
->mode_config
.max_width
= 16384;
2834 adev
->ddev
->mode_config
.max_height
= 16384;
2836 /* allocate crtcs */
2837 for (i
= 0; i
< adev
->mode_info
.num_crtc
; i
++) {
2838 r
= dce_v10_0_crtc_init(adev
, i
);
2843 if (amdgpu_atombios_get_connector_info_from_object_table(adev
))
2844 amdgpu_print_display_setup(adev
->ddev
);
2849 r
= dce_v10_0_afmt_init(adev
);
2853 r
= dce_v10_0_audio_init(adev
);
2857 drm_kms_helper_poll_init(adev
->ddev
);
2859 adev
->mode_info
.mode_config_initialized
= true;
2863 static int dce_v10_0_sw_fini(void *handle
)
2865 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
2867 kfree(adev
->mode_info
.bios_hardcoded_edid
);
2869 drm_kms_helper_poll_fini(adev
->ddev
);
2871 dce_v10_0_audio_fini(adev
);
2873 dce_v10_0_afmt_fini(adev
);
2875 drm_mode_config_cleanup(adev
->ddev
);
2876 adev
->mode_info
.mode_config_initialized
= false;
2881 static int dce_v10_0_hw_init(void *handle
)
2884 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
2886 dce_v10_0_init_golden_registers(adev
);
2888 /* disable vga render */
2889 dce_v10_0_set_vga_render_state(adev
, false);
2890 /* init dig PHYs, disp eng pll */
2891 amdgpu_atombios_encoder_init_dig(adev
);
2892 amdgpu_atombios_crtc_set_disp_eng_pll(adev
, adev
->clock
.default_dispclk
);
2894 /* initialize hpd */
2895 dce_v10_0_hpd_init(adev
);
2897 for (i
= 0; i
< adev
->mode_info
.audio
.num_pins
; i
++) {
2898 dce_v10_0_audio_enable(adev
, &adev
->mode_info
.audio
.pin
[i
], false);
2901 dce_v10_0_pageflip_interrupt_init(adev
);
2906 static int dce_v10_0_hw_fini(void *handle
)
2909 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
2911 dce_v10_0_hpd_fini(adev
);
2913 for (i
= 0; i
< adev
->mode_info
.audio
.num_pins
; i
++) {
2914 dce_v10_0_audio_enable(adev
, &adev
->mode_info
.audio
.pin
[i
], false);
2917 dce_v10_0_pageflip_interrupt_fini(adev
);
2922 static int dce_v10_0_suspend(void *handle
)
2924 return dce_v10_0_hw_fini(handle
);
2927 static int dce_v10_0_resume(void *handle
)
2929 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
2932 ret
= dce_v10_0_hw_init(handle
);
2934 /* turn on the BL */
2935 if (adev
->mode_info
.bl_encoder
) {
2936 u8 bl_level
= amdgpu_display_backlight_get_level(adev
,
2937 adev
->mode_info
.bl_encoder
);
2938 amdgpu_display_backlight_set_level(adev
, adev
->mode_info
.bl_encoder
,
2945 static bool dce_v10_0_is_idle(void *handle
)
2950 static int dce_v10_0_wait_for_idle(void *handle
)
2955 static bool dce_v10_0_check_soft_reset(void *handle
)
2957 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
2959 return dce_v10_0_is_display_hung(adev
);
2962 static int dce_v10_0_soft_reset(void *handle
)
2964 u32 srbm_soft_reset
= 0, tmp
;
2965 struct amdgpu_device
*adev
= (struct amdgpu_device
*)handle
;
2967 if (dce_v10_0_is_display_hung(adev
))
2968 srbm_soft_reset
|= SRBM_SOFT_RESET__SOFT_RESET_DC_MASK
;
2970 if (srbm_soft_reset
) {
2971 tmp
= RREG32(mmSRBM_SOFT_RESET
);
2972 tmp
|= srbm_soft_reset
;
2973 dev_info(adev
->dev
, "SRBM_SOFT_RESET=0x%08X\n", tmp
);
2974 WREG32(mmSRBM_SOFT_RESET
, tmp
);
2975 tmp
= RREG32(mmSRBM_SOFT_RESET
);
2979 tmp
&= ~srbm_soft_reset
;
2980 WREG32(mmSRBM_SOFT_RESET
, tmp
);
2981 tmp
= RREG32(mmSRBM_SOFT_RESET
);
2983 /* Wait a little for things to settle down */
2989 static void dce_v10_0_set_crtc_vblank_interrupt_state(struct amdgpu_device
*adev
,
2991 enum amdgpu_interrupt_state state
)
2993 u32 lb_interrupt_mask
;
2995 if (crtc
>= adev
->mode_info
.num_crtc
) {
2996 DRM_DEBUG("invalid crtc %d\n", crtc
);
3001 case AMDGPU_IRQ_STATE_DISABLE
:
3002 lb_interrupt_mask
= RREG32(mmLB_INTERRUPT_MASK
+ crtc_offsets
[crtc
]);
3003 lb_interrupt_mask
= REG_SET_FIELD(lb_interrupt_mask
, LB_INTERRUPT_MASK
,
3004 VBLANK_INTERRUPT_MASK
, 0);
3005 WREG32(mmLB_INTERRUPT_MASK
+ crtc_offsets
[crtc
], lb_interrupt_mask
);
3007 case AMDGPU_IRQ_STATE_ENABLE
:
3008 lb_interrupt_mask
= RREG32(mmLB_INTERRUPT_MASK
+ crtc_offsets
[crtc
]);
3009 lb_interrupt_mask
= REG_SET_FIELD(lb_interrupt_mask
, LB_INTERRUPT_MASK
,
3010 VBLANK_INTERRUPT_MASK
, 1);
3011 WREG32(mmLB_INTERRUPT_MASK
+ crtc_offsets
[crtc
], lb_interrupt_mask
);
3018 static void dce_v10_0_set_crtc_vline_interrupt_state(struct amdgpu_device
*adev
,
3020 enum amdgpu_interrupt_state state
)
3022 u32 lb_interrupt_mask
;
3024 if (crtc
>= adev
->mode_info
.num_crtc
) {
3025 DRM_DEBUG("invalid crtc %d\n", crtc
);
3030 case AMDGPU_IRQ_STATE_DISABLE
:
3031 lb_interrupt_mask
= RREG32(mmLB_INTERRUPT_MASK
+ crtc_offsets
[crtc
]);
3032 lb_interrupt_mask
= REG_SET_FIELD(lb_interrupt_mask
, LB_INTERRUPT_MASK
,
3033 VLINE_INTERRUPT_MASK
, 0);
3034 WREG32(mmLB_INTERRUPT_MASK
+ crtc_offsets
[crtc
], lb_interrupt_mask
);
3036 case AMDGPU_IRQ_STATE_ENABLE
:
3037 lb_interrupt_mask
= RREG32(mmLB_INTERRUPT_MASK
+ crtc_offsets
[crtc
]);
3038 lb_interrupt_mask
= REG_SET_FIELD(lb_interrupt_mask
, LB_INTERRUPT_MASK
,
3039 VLINE_INTERRUPT_MASK
, 1);
3040 WREG32(mmLB_INTERRUPT_MASK
+ crtc_offsets
[crtc
], lb_interrupt_mask
);
3047 static int dce_v10_0_set_hpd_irq_state(struct amdgpu_device
*adev
,
3048 struct amdgpu_irq_src
*source
,
3050 enum amdgpu_interrupt_state state
)
3054 if (hpd
>= adev
->mode_info
.num_hpd
) {
3055 DRM_DEBUG("invalid hdp %d\n", hpd
);
3060 case AMDGPU_IRQ_STATE_DISABLE
:
3061 tmp
= RREG32(mmDC_HPD_INT_CONTROL
+ hpd_offsets
[hpd
]);
3062 tmp
= REG_SET_FIELD(tmp
, DC_HPD_INT_CONTROL
, DC_HPD_INT_EN
, 0);
3063 WREG32(mmDC_HPD_INT_CONTROL
+ hpd_offsets
[hpd
], tmp
);
3065 case AMDGPU_IRQ_STATE_ENABLE
:
3066 tmp
= RREG32(mmDC_HPD_INT_CONTROL
+ hpd_offsets
[hpd
]);
3067 tmp
= REG_SET_FIELD(tmp
, DC_HPD_INT_CONTROL
, DC_HPD_INT_EN
, 1);
3068 WREG32(mmDC_HPD_INT_CONTROL
+ hpd_offsets
[hpd
], tmp
);
3077 static int dce_v10_0_set_crtc_irq_state(struct amdgpu_device
*adev
,
3078 struct amdgpu_irq_src
*source
,
3080 enum amdgpu_interrupt_state state
)
3083 case AMDGPU_CRTC_IRQ_VBLANK1
:
3084 dce_v10_0_set_crtc_vblank_interrupt_state(adev
, 0, state
);
3086 case AMDGPU_CRTC_IRQ_VBLANK2
:
3087 dce_v10_0_set_crtc_vblank_interrupt_state(adev
, 1, state
);
3089 case AMDGPU_CRTC_IRQ_VBLANK3
:
3090 dce_v10_0_set_crtc_vblank_interrupt_state(adev
, 2, state
);
3092 case AMDGPU_CRTC_IRQ_VBLANK4
:
3093 dce_v10_0_set_crtc_vblank_interrupt_state(adev
, 3, state
);
3095 case AMDGPU_CRTC_IRQ_VBLANK5
:
3096 dce_v10_0_set_crtc_vblank_interrupt_state(adev
, 4, state
);
3098 case AMDGPU_CRTC_IRQ_VBLANK6
:
3099 dce_v10_0_set_crtc_vblank_interrupt_state(adev
, 5, state
);
3101 case AMDGPU_CRTC_IRQ_VLINE1
:
3102 dce_v10_0_set_crtc_vline_interrupt_state(adev
, 0, state
);
3104 case AMDGPU_CRTC_IRQ_VLINE2
:
3105 dce_v10_0_set_crtc_vline_interrupt_state(adev
, 1, state
);
3107 case AMDGPU_CRTC_IRQ_VLINE3
:
3108 dce_v10_0_set_crtc_vline_interrupt_state(adev
, 2, state
);
3110 case AMDGPU_CRTC_IRQ_VLINE4
:
3111 dce_v10_0_set_crtc_vline_interrupt_state(adev
, 3, state
);
3113 case AMDGPU_CRTC_IRQ_VLINE5
:
3114 dce_v10_0_set_crtc_vline_interrupt_state(adev
, 4, state
);
3116 case AMDGPU_CRTC_IRQ_VLINE6
:
3117 dce_v10_0_set_crtc_vline_interrupt_state(adev
, 5, state
);
3125 static int dce_v10_0_set_pageflip_irq_state(struct amdgpu_device
*adev
,
3126 struct amdgpu_irq_src
*src
,
3128 enum amdgpu_interrupt_state state
)
3132 if (type
>= adev
->mode_info
.num_crtc
) {
3133 DRM_ERROR("invalid pageflip crtc %d\n", type
);
3137 reg
= RREG32(mmGRPH_INTERRUPT_CONTROL
+ crtc_offsets
[type
]);
3138 if (state
== AMDGPU_IRQ_STATE_DISABLE
)
3139 WREG32(mmGRPH_INTERRUPT_CONTROL
+ crtc_offsets
[type
],
3140 reg
& ~GRPH_INTERRUPT_CONTROL__GRPH_PFLIP_INT_MASK_MASK
);
3142 WREG32(mmGRPH_INTERRUPT_CONTROL
+ crtc_offsets
[type
],
3143 reg
| GRPH_INTERRUPT_CONTROL__GRPH_PFLIP_INT_MASK_MASK
);
3148 static int dce_v10_0_pageflip_irq(struct amdgpu_device
*adev
,
3149 struct amdgpu_irq_src
*source
,
3150 struct amdgpu_iv_entry
*entry
)
3152 unsigned long flags
;
3154 struct amdgpu_crtc
*amdgpu_crtc
;
3155 struct amdgpu_flip_work
*works
;
3157 crtc_id
= (entry
->src_id
- 8) >> 1;
3158 amdgpu_crtc
= adev
->mode_info
.crtcs
[crtc_id
];
3160 if (crtc_id
>= adev
->mode_info
.num_crtc
) {
3161 DRM_ERROR("invalid pageflip crtc %d\n", crtc_id
);
3165 if (RREG32(mmGRPH_INTERRUPT_STATUS
+ crtc_offsets
[crtc_id
]) &
3166 GRPH_INTERRUPT_STATUS__GRPH_PFLIP_INT_OCCURRED_MASK
)
3167 WREG32(mmGRPH_INTERRUPT_STATUS
+ crtc_offsets
[crtc_id
],
3168 GRPH_INTERRUPT_STATUS__GRPH_PFLIP_INT_CLEAR_MASK
);
3170 /* IRQ could occur when in initial stage */
3171 if (amdgpu_crtc
== NULL
)
3174 spin_lock_irqsave(&adev
->ddev
->event_lock
, flags
);
3175 works
= amdgpu_crtc
->pflip_works
;
3176 if (amdgpu_crtc
->pflip_status
!= AMDGPU_FLIP_SUBMITTED
) {
3177 DRM_DEBUG_DRIVER("amdgpu_crtc->pflip_status = %d != "
3178 "AMDGPU_FLIP_SUBMITTED(%d)\n",
3179 amdgpu_crtc
->pflip_status
,
3180 AMDGPU_FLIP_SUBMITTED
);
3181 spin_unlock_irqrestore(&adev
->ddev
->event_lock
, flags
);
3185 /* page flip completed. clean up */
3186 amdgpu_crtc
->pflip_status
= AMDGPU_FLIP_NONE
;
3187 amdgpu_crtc
->pflip_works
= NULL
;
3189 /* wakeup usersapce */
3191 drm_crtc_send_vblank_event(&amdgpu_crtc
->base
, works
->event
);
3193 spin_unlock_irqrestore(&adev
->ddev
->event_lock
, flags
);
3195 drm_crtc_vblank_put(&amdgpu_crtc
->base
);
3196 schedule_work(&works
->unpin_work
);
3201 static void dce_v10_0_hpd_int_ack(struct amdgpu_device
*adev
,
3206 if (hpd
>= adev
->mode_info
.num_hpd
) {
3207 DRM_DEBUG("invalid hdp %d\n", hpd
);
3211 tmp
= RREG32(mmDC_HPD_INT_CONTROL
+ hpd_offsets
[hpd
]);
3212 tmp
= REG_SET_FIELD(tmp
, DC_HPD_INT_CONTROL
, DC_HPD_INT_ACK
, 1);
3213 WREG32(mmDC_HPD_INT_CONTROL
+ hpd_offsets
[hpd
], tmp
);
3216 static void dce_v10_0_crtc_vblank_int_ack(struct amdgpu_device
*adev
,
3221 if (crtc
>= adev
->mode_info
.num_crtc
) {
3222 DRM_DEBUG("invalid crtc %d\n", crtc
);
3226 tmp
= RREG32(mmLB_VBLANK_STATUS
+ crtc_offsets
[crtc
]);
3227 tmp
= REG_SET_FIELD(tmp
, LB_VBLANK_STATUS
, VBLANK_ACK
, 1);
3228 WREG32(mmLB_VBLANK_STATUS
+ crtc_offsets
[crtc
], tmp
);
3231 static void dce_v10_0_crtc_vline_int_ack(struct amdgpu_device
*adev
,
3236 if (crtc
>= adev
->mode_info
.num_crtc
) {
3237 DRM_DEBUG("invalid crtc %d\n", crtc
);
3241 tmp
= RREG32(mmLB_VLINE_STATUS
+ crtc_offsets
[crtc
]);
3242 tmp
= REG_SET_FIELD(tmp
, LB_VLINE_STATUS
, VLINE_ACK
, 1);
3243 WREG32(mmLB_VLINE_STATUS
+ crtc_offsets
[crtc
], tmp
);
3246 static int dce_v10_0_crtc_irq(struct amdgpu_device
*adev
,
3247 struct amdgpu_irq_src
*source
,
3248 struct amdgpu_iv_entry
*entry
)
3250 unsigned crtc
= entry
->src_id
- 1;
3251 uint32_t disp_int
= RREG32(interrupt_status_offsets
[crtc
].reg
);
3252 unsigned irq_type
= amdgpu_crtc_idx_to_irq_type(adev
, crtc
);
3254 switch (entry
->src_data
[0]) {
3255 case 0: /* vblank */
3256 if (disp_int
& interrupt_status_offsets
[crtc
].vblank
)
3257 dce_v10_0_crtc_vblank_int_ack(adev
, crtc
);
3259 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
3261 if (amdgpu_irq_enabled(adev
, source
, irq_type
)) {
3262 drm_handle_vblank(adev
->ddev
, crtc
);
3264 DRM_DEBUG("IH: D%d vblank\n", crtc
+ 1);
3268 if (disp_int
& interrupt_status_offsets
[crtc
].vline
)
3269 dce_v10_0_crtc_vline_int_ack(adev
, crtc
);
3271 DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
3273 DRM_DEBUG("IH: D%d vline\n", crtc
+ 1);
3277 DRM_DEBUG("Unhandled interrupt: %d %d\n", entry
->src_id
, entry
->src_data
[0]);
3284 static int dce_v10_0_hpd_irq(struct amdgpu_device
*adev
,
3285 struct amdgpu_irq_src
*source
,
3286 struct amdgpu_iv_entry
*entry
)
3288 uint32_t disp_int
, mask
;
3291 if (entry
->src_data
[0] >= adev
->mode_info
.num_hpd
) {
3292 DRM_DEBUG("Unhandled interrupt: %d %d\n", entry
->src_id
, entry
->src_data
[0]);
3296 hpd
= entry
->src_data
[0];
3297 disp_int
= RREG32(interrupt_status_offsets
[hpd
].reg
);
3298 mask
= interrupt_status_offsets
[hpd
].hpd
;
3300 if (disp_int
& mask
) {
3301 dce_v10_0_hpd_int_ack(adev
, hpd
);
3302 schedule_work(&adev
->hotplug_work
);
3303 DRM_DEBUG("IH: HPD%d\n", hpd
+ 1);
3309 static int dce_v10_0_set_clockgating_state(void *handle
,
3310 enum amd_clockgating_state state
)
3315 static int dce_v10_0_set_powergating_state(void *handle
,
3316 enum amd_powergating_state state
)
3321 static const struct amd_ip_funcs dce_v10_0_ip_funcs
= {
3322 .name
= "dce_v10_0",
3323 .early_init
= dce_v10_0_early_init
,
3325 .sw_init
= dce_v10_0_sw_init
,
3326 .sw_fini
= dce_v10_0_sw_fini
,
3327 .hw_init
= dce_v10_0_hw_init
,
3328 .hw_fini
= dce_v10_0_hw_fini
,
3329 .suspend
= dce_v10_0_suspend
,
3330 .resume
= dce_v10_0_resume
,
3331 .is_idle
= dce_v10_0_is_idle
,
3332 .wait_for_idle
= dce_v10_0_wait_for_idle
,
3333 .check_soft_reset
= dce_v10_0_check_soft_reset
,
3334 .soft_reset
= dce_v10_0_soft_reset
,
3335 .set_clockgating_state
= dce_v10_0_set_clockgating_state
,
3336 .set_powergating_state
= dce_v10_0_set_powergating_state
,
3340 dce_v10_0_encoder_mode_set(struct drm_encoder
*encoder
,
3341 struct drm_display_mode
*mode
,
3342 struct drm_display_mode
*adjusted_mode
)
3344 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
3346 amdgpu_encoder
->pixel_clock
= adjusted_mode
->clock
;
3348 /* need to call this here rather than in prepare() since we need some crtc info */
3349 amdgpu_atombios_encoder_dpms(encoder
, DRM_MODE_DPMS_OFF
);
3351 /* set scaler clears this on some chips */
3352 dce_v10_0_set_interleave(encoder
->crtc
, mode
);
3354 if (amdgpu_atombios_encoder_get_encoder_mode(encoder
) == ATOM_ENCODER_MODE_HDMI
) {
3355 dce_v10_0_afmt_enable(encoder
, true);
3356 dce_v10_0_afmt_setmode(encoder
, adjusted_mode
);
3360 static void dce_v10_0_encoder_prepare(struct drm_encoder
*encoder
)
3362 struct amdgpu_device
*adev
= encoder
->dev
->dev_private
;
3363 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
3364 struct drm_connector
*connector
= amdgpu_get_connector_for_encoder(encoder
);
3366 if ((amdgpu_encoder
->active_device
&
3367 (ATOM_DEVICE_DFP_SUPPORT
| ATOM_DEVICE_LCD_SUPPORT
)) ||
3368 (amdgpu_encoder_get_dp_bridge_encoder_id(encoder
) !=
3369 ENCODER_OBJECT_ID_NONE
)) {
3370 struct amdgpu_encoder_atom_dig
*dig
= amdgpu_encoder
->enc_priv
;
3372 dig
->dig_encoder
= dce_v10_0_pick_dig_encoder(encoder
);
3373 if (amdgpu_encoder
->active_device
& ATOM_DEVICE_DFP_SUPPORT
)
3374 dig
->afmt
= adev
->mode_info
.afmt
[dig
->dig_encoder
];
3378 amdgpu_atombios_scratch_regs_lock(adev
, true);
3381 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
3383 /* select the clock/data port if it uses a router */
3384 if (amdgpu_connector
->router
.cd_valid
)
3385 amdgpu_i2c_router_select_cd_port(amdgpu_connector
);
3387 /* turn eDP panel on for mode set */
3388 if (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
)
3389 amdgpu_atombios_encoder_set_edp_panel_power(connector
,
3390 ATOM_TRANSMITTER_ACTION_POWER_ON
);
3393 /* this is needed for the pll/ss setup to work correctly in some cases */
3394 amdgpu_atombios_encoder_set_crtc_source(encoder
);
3395 /* set up the FMT blocks */
3396 dce_v10_0_program_fmt(encoder
);
3399 static void dce_v10_0_encoder_commit(struct drm_encoder
*encoder
)
3401 struct drm_device
*dev
= encoder
->dev
;
3402 struct amdgpu_device
*adev
= dev
->dev_private
;
3404 /* need to call this here as we need the crtc set up */
3405 amdgpu_atombios_encoder_dpms(encoder
, DRM_MODE_DPMS_ON
);
3406 amdgpu_atombios_scratch_regs_lock(adev
, false);
3409 static void dce_v10_0_encoder_disable(struct drm_encoder
*encoder
)
3411 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
3412 struct amdgpu_encoder_atom_dig
*dig
;
3414 amdgpu_atombios_encoder_dpms(encoder
, DRM_MODE_DPMS_OFF
);
3416 if (amdgpu_atombios_encoder_is_digital(encoder
)) {
3417 if (amdgpu_atombios_encoder_get_encoder_mode(encoder
) == ATOM_ENCODER_MODE_HDMI
)
3418 dce_v10_0_afmt_enable(encoder
, false);
3419 dig
= amdgpu_encoder
->enc_priv
;
3420 dig
->dig_encoder
= -1;
3422 amdgpu_encoder
->active_device
= 0;
3425 /* these are handled by the primary encoders */
3426 static void dce_v10_0_ext_prepare(struct drm_encoder
*encoder
)
3431 static void dce_v10_0_ext_commit(struct drm_encoder
*encoder
)
3437 dce_v10_0_ext_mode_set(struct drm_encoder
*encoder
,
3438 struct drm_display_mode
*mode
,
3439 struct drm_display_mode
*adjusted_mode
)
3444 static void dce_v10_0_ext_disable(struct drm_encoder
*encoder
)
3450 dce_v10_0_ext_dpms(struct drm_encoder
*encoder
, int mode
)
3455 static const struct drm_encoder_helper_funcs dce_v10_0_ext_helper_funcs
= {
3456 .dpms
= dce_v10_0_ext_dpms
,
3457 .prepare
= dce_v10_0_ext_prepare
,
3458 .mode_set
= dce_v10_0_ext_mode_set
,
3459 .commit
= dce_v10_0_ext_commit
,
3460 .disable
= dce_v10_0_ext_disable
,
3461 /* no detect for TMDS/LVDS yet */
3464 static const struct drm_encoder_helper_funcs dce_v10_0_dig_helper_funcs
= {
3465 .dpms
= amdgpu_atombios_encoder_dpms
,
3466 .mode_fixup
= amdgpu_atombios_encoder_mode_fixup
,
3467 .prepare
= dce_v10_0_encoder_prepare
,
3468 .mode_set
= dce_v10_0_encoder_mode_set
,
3469 .commit
= dce_v10_0_encoder_commit
,
3470 .disable
= dce_v10_0_encoder_disable
,
3471 .detect
= amdgpu_atombios_encoder_dig_detect
,
3474 static const struct drm_encoder_helper_funcs dce_v10_0_dac_helper_funcs
= {
3475 .dpms
= amdgpu_atombios_encoder_dpms
,
3476 .mode_fixup
= amdgpu_atombios_encoder_mode_fixup
,
3477 .prepare
= dce_v10_0_encoder_prepare
,
3478 .mode_set
= dce_v10_0_encoder_mode_set
,
3479 .commit
= dce_v10_0_encoder_commit
,
3480 .detect
= amdgpu_atombios_encoder_dac_detect
,
3483 static void dce_v10_0_encoder_destroy(struct drm_encoder
*encoder
)
3485 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
3486 if (amdgpu_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
))
3487 amdgpu_atombios_encoder_fini_backlight(amdgpu_encoder
);
3488 kfree(amdgpu_encoder
->enc_priv
);
3489 drm_encoder_cleanup(encoder
);
3490 kfree(amdgpu_encoder
);
3493 static const struct drm_encoder_funcs dce_v10_0_encoder_funcs
= {
3494 .destroy
= dce_v10_0_encoder_destroy
,
3497 static void dce_v10_0_encoder_add(struct amdgpu_device
*adev
,
3498 uint32_t encoder_enum
,
3499 uint32_t supported_device
,
3502 struct drm_device
*dev
= adev
->ddev
;
3503 struct drm_encoder
*encoder
;
3504 struct amdgpu_encoder
*amdgpu_encoder
;
3506 /* see if we already added it */
3507 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
3508 amdgpu_encoder
= to_amdgpu_encoder(encoder
);
3509 if (amdgpu_encoder
->encoder_enum
== encoder_enum
) {
3510 amdgpu_encoder
->devices
|= supported_device
;
3517 amdgpu_encoder
= kzalloc(sizeof(struct amdgpu_encoder
), GFP_KERNEL
);
3518 if (!amdgpu_encoder
)
3521 encoder
= &amdgpu_encoder
->base
;
3522 switch (adev
->mode_info
.num_crtc
) {
3524 encoder
->possible_crtcs
= 0x1;
3528 encoder
->possible_crtcs
= 0x3;
3531 encoder
->possible_crtcs
= 0xf;
3534 encoder
->possible_crtcs
= 0x3f;
3538 amdgpu_encoder
->enc_priv
= NULL
;
3540 amdgpu_encoder
->encoder_enum
= encoder_enum
;
3541 amdgpu_encoder
->encoder_id
= (encoder_enum
& OBJECT_ID_MASK
) >> OBJECT_ID_SHIFT
;
3542 amdgpu_encoder
->devices
= supported_device
;
3543 amdgpu_encoder
->rmx_type
= RMX_OFF
;
3544 amdgpu_encoder
->underscan_type
= UNDERSCAN_OFF
;
3545 amdgpu_encoder
->is_ext_encoder
= false;
3546 amdgpu_encoder
->caps
= caps
;
3548 switch (amdgpu_encoder
->encoder_id
) {
3549 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
:
3550 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
:
3551 drm_encoder_init(dev
, encoder
, &dce_v10_0_encoder_funcs
,
3552 DRM_MODE_ENCODER_DAC
, NULL
);
3553 drm_encoder_helper_add(encoder
, &dce_v10_0_dac_helper_funcs
);
3555 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1
:
3556 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
3557 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
:
3558 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
:
3559 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY3
:
3560 if (amdgpu_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
3561 amdgpu_encoder
->rmx_type
= RMX_FULL
;
3562 drm_encoder_init(dev
, encoder
, &dce_v10_0_encoder_funcs
,
3563 DRM_MODE_ENCODER_LVDS
, NULL
);
3564 amdgpu_encoder
->enc_priv
= amdgpu_atombios_encoder_get_lcd_info(amdgpu_encoder
);
3565 } else if (amdgpu_encoder
->devices
& (ATOM_DEVICE_CRT_SUPPORT
)) {
3566 drm_encoder_init(dev
, encoder
, &dce_v10_0_encoder_funcs
,
3567 DRM_MODE_ENCODER_DAC
, NULL
);
3568 amdgpu_encoder
->enc_priv
= amdgpu_atombios_encoder_get_dig_info(amdgpu_encoder
);
3570 drm_encoder_init(dev
, encoder
, &dce_v10_0_encoder_funcs
,
3571 DRM_MODE_ENCODER_TMDS
, NULL
);
3572 amdgpu_encoder
->enc_priv
= amdgpu_atombios_encoder_get_dig_info(amdgpu_encoder
);
3574 drm_encoder_helper_add(encoder
, &dce_v10_0_dig_helper_funcs
);
3576 case ENCODER_OBJECT_ID_SI170B
:
3577 case ENCODER_OBJECT_ID_CH7303
:
3578 case ENCODER_OBJECT_ID_EXTERNAL_SDVOA
:
3579 case ENCODER_OBJECT_ID_EXTERNAL_SDVOB
:
3580 case ENCODER_OBJECT_ID_TITFP513
:
3581 case ENCODER_OBJECT_ID_VT1623
:
3582 case ENCODER_OBJECT_ID_HDMI_SI1930
:
3583 case ENCODER_OBJECT_ID_TRAVIS
:
3584 case ENCODER_OBJECT_ID_NUTMEG
:
3585 /* these are handled by the primary encoders */
3586 amdgpu_encoder
->is_ext_encoder
= true;
3587 if (amdgpu_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
))
3588 drm_encoder_init(dev
, encoder
, &dce_v10_0_encoder_funcs
,
3589 DRM_MODE_ENCODER_LVDS
, NULL
);
3590 else if (amdgpu_encoder
->devices
& (ATOM_DEVICE_CRT_SUPPORT
))
3591 drm_encoder_init(dev
, encoder
, &dce_v10_0_encoder_funcs
,
3592 DRM_MODE_ENCODER_DAC
, NULL
);
3594 drm_encoder_init(dev
, encoder
, &dce_v10_0_encoder_funcs
,
3595 DRM_MODE_ENCODER_TMDS
, NULL
);
3596 drm_encoder_helper_add(encoder
, &dce_v10_0_ext_helper_funcs
);
3601 static const struct amdgpu_display_funcs dce_v10_0_display_funcs
= {
3602 .bandwidth_update
= &dce_v10_0_bandwidth_update
,
3603 .vblank_get_counter
= &dce_v10_0_vblank_get_counter
,
3604 .vblank_wait
= &dce_v10_0_vblank_wait
,
3605 .backlight_set_level
= &amdgpu_atombios_encoder_set_backlight_level
,
3606 .backlight_get_level
= &amdgpu_atombios_encoder_get_backlight_level
,
3607 .hpd_sense
= &dce_v10_0_hpd_sense
,
3608 .hpd_set_polarity
= &dce_v10_0_hpd_set_polarity
,
3609 .hpd_get_gpio_reg
= &dce_v10_0_hpd_get_gpio_reg
,
3610 .page_flip
= &dce_v10_0_page_flip
,
3611 .page_flip_get_scanoutpos
= &dce_v10_0_crtc_get_scanoutpos
,
3612 .add_encoder
= &dce_v10_0_encoder_add
,
3613 .add_connector
= &amdgpu_connector_add
,
3616 static void dce_v10_0_set_display_funcs(struct amdgpu_device
*adev
)
3618 if (adev
->mode_info
.funcs
== NULL
)
3619 adev
->mode_info
.funcs
= &dce_v10_0_display_funcs
;
3622 static const struct amdgpu_irq_src_funcs dce_v10_0_crtc_irq_funcs
= {
3623 .set
= dce_v10_0_set_crtc_irq_state
,
3624 .process
= dce_v10_0_crtc_irq
,
3627 static const struct amdgpu_irq_src_funcs dce_v10_0_pageflip_irq_funcs
= {
3628 .set
= dce_v10_0_set_pageflip_irq_state
,
3629 .process
= dce_v10_0_pageflip_irq
,
3632 static const struct amdgpu_irq_src_funcs dce_v10_0_hpd_irq_funcs
= {
3633 .set
= dce_v10_0_set_hpd_irq_state
,
3634 .process
= dce_v10_0_hpd_irq
,
3637 static void dce_v10_0_set_irq_funcs(struct amdgpu_device
*adev
)
3639 if (adev
->mode_info
.num_crtc
> 0)
3640 adev
->crtc_irq
.num_types
= AMDGPU_CRTC_IRQ_VLINE1
+ adev
->mode_info
.num_crtc
;
3642 adev
->crtc_irq
.num_types
= 0;
3643 adev
->crtc_irq
.funcs
= &dce_v10_0_crtc_irq_funcs
;
3645 adev
->pageflip_irq
.num_types
= adev
->mode_info
.num_crtc
;
3646 adev
->pageflip_irq
.funcs
= &dce_v10_0_pageflip_irq_funcs
;
3648 adev
->hpd_irq
.num_types
= adev
->mode_info
.num_hpd
;
3649 adev
->hpd_irq
.funcs
= &dce_v10_0_hpd_irq_funcs
;
3652 const struct amdgpu_ip_block_version dce_v10_0_ip_block
=
3654 .type
= AMD_IP_BLOCK_TYPE_DCE
,
3658 .funcs
= &dce_v10_0_ip_funcs
,
3661 const struct amdgpu_ip_block_version dce_v10_1_ip_block
=
3663 .type
= AMD_IP_BLOCK_TYPE_DCE
,
3667 .funcs
= &dce_v10_0_ip_funcs
,