diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/dce_v6_0.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 89 |
1 files changed, 20 insertions, 69 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c index bd2c4f727df6..9f67b7fd3487 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | |||
@@ -142,64 +142,6 @@ static void dce_v6_0_audio_endpt_wreg(struct amdgpu_device *adev, | |||
142 | spin_unlock_irqrestore(&adev->audio_endpt_idx_lock, flags); | 142 | spin_unlock_irqrestore(&adev->audio_endpt_idx_lock, flags); |
143 | } | 143 | } |
144 | 144 | ||
145 | static bool dce_v6_0_is_in_vblank(struct amdgpu_device *adev, int crtc) | ||
146 | { | ||
147 | if (RREG32(mmCRTC_STATUS + crtc_offsets[crtc]) & CRTC_STATUS__CRTC_V_BLANK_MASK) | ||
148 | return true; | ||
149 | else | ||
150 | return false; | ||
151 | } | ||
152 | |||
153 | static bool dce_v6_0_is_counter_moving(struct amdgpu_device *adev, int crtc) | ||
154 | { | ||
155 | u32 pos1, pos2; | ||
156 | |||
157 | pos1 = RREG32(mmCRTC_STATUS_POSITION + crtc_offsets[crtc]); | ||
158 | pos2 = RREG32(mmCRTC_STATUS_POSITION + crtc_offsets[crtc]); | ||
159 | |||
160 | if (pos1 != pos2) | ||
161 | return true; | ||
162 | else | ||
163 | return false; | ||
164 | } | ||
165 | |||
166 | /** | ||
167 | * dce_v6_0_wait_for_vblank - vblank wait asic callback. | ||
168 | * | ||
169 | * @crtc: crtc to wait for vblank on | ||
170 | * | ||
171 | * Wait for vblank on the requested crtc (evergreen+). | ||
172 | */ | ||
173 | static void dce_v6_0_vblank_wait(struct amdgpu_device *adev, int crtc) | ||
174 | { | ||
175 | unsigned i = 100; | ||
176 | |||
177 | if (crtc >= adev->mode_info.num_crtc) | ||
178 | return; | ||
179 | |||
180 | if (!(RREG32(mmCRTC_CONTROL + crtc_offsets[crtc]) & CRTC_CONTROL__CRTC_MASTER_EN_MASK)) | ||
181 | return; | ||
182 | |||
183 | /* depending on when we hit vblank, we may be close to active; if so, | ||
184 | * wait for another frame. | ||
185 | */ | ||
186 | while (dce_v6_0_is_in_vblank(adev, crtc)) { | ||
187 | if (i++ == 100) { | ||
188 | i = 0; | ||
189 | if (!dce_v6_0_is_counter_moving(adev, crtc)) | ||
190 | break; | ||
191 | } | ||
192 | } | ||
193 | |||
194 | while (!dce_v6_0_is_in_vblank(adev, crtc)) { | ||
195 | if (i++ == 100) { | ||
196 | i = 0; | ||
197 | if (!dce_v6_0_is_counter_moving(adev, crtc)) | ||
198 | break; | ||
199 | } | ||
200 | } | ||
201 | } | ||
202 | |||
203 | static u32 dce_v6_0_vblank_get_counter(struct amdgpu_device *adev, int crtc) | 145 | static u32 dce_v6_0_vblank_get_counter(struct amdgpu_device *adev, int crtc) |
204 | { | 146 | { |
205 | if (crtc >= adev->mode_info.num_crtc) | 147 | if (crtc >= adev->mode_info.num_crtc) |
@@ -1108,7 +1050,7 @@ static void dce_v6_0_bandwidth_update(struct amdgpu_device *adev) | |||
1108 | if (!adev->mode_info.mode_config_initialized) | 1050 | if (!adev->mode_info.mode_config_initialized) |
1109 | return; | 1051 | return; |
1110 | 1052 | ||
1111 | amdgpu_update_display_priority(adev); | 1053 | amdgpu_display_update_priority(adev); |
1112 | 1054 | ||
1113 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | 1055 | for (i = 0; i < adev->mode_info.num_crtc; i++) { |
1114 | if (adev->mode_info.crtcs[i]->base.enabled) | 1056 | if (adev->mode_info.crtcs[i]->base.enabled) |
@@ -2407,9 +2349,9 @@ static const struct drm_crtc_funcs dce_v6_0_crtc_funcs = { | |||
2407 | .cursor_set2 = dce_v6_0_crtc_cursor_set2, | 2349 | .cursor_set2 = dce_v6_0_crtc_cursor_set2, |
2408 | .cursor_move = dce_v6_0_crtc_cursor_move, | 2350 | .cursor_move = dce_v6_0_crtc_cursor_move, |
2409 | .gamma_set = dce_v6_0_crtc_gamma_set, | 2351 | .gamma_set = dce_v6_0_crtc_gamma_set, |
2410 | .set_config = amdgpu_crtc_set_config, | 2352 | .set_config = amdgpu_display_crtc_set_config, |
2411 | .destroy = dce_v6_0_crtc_destroy, | 2353 | .destroy = dce_v6_0_crtc_destroy, |
2412 | .page_flip_target = amdgpu_crtc_page_flip_target, | 2354 | .page_flip_target = amdgpu_display_crtc_page_flip_target, |
2413 | }; | 2355 | }; |
2414 | 2356 | ||
2415 | static void dce_v6_0_crtc_dpms(struct drm_crtc *crtc, int mode) | 2357 | static void dce_v6_0_crtc_dpms(struct drm_crtc *crtc, int mode) |
@@ -2425,7 +2367,8 @@ static void dce_v6_0_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
2425 | amdgpu_atombios_crtc_enable(crtc, ATOM_ENABLE); | 2367 | amdgpu_atombios_crtc_enable(crtc, ATOM_ENABLE); |
2426 | amdgpu_atombios_crtc_blank(crtc, ATOM_DISABLE); | 2368 | amdgpu_atombios_crtc_blank(crtc, ATOM_DISABLE); |
2427 | /* Make sure VBLANK and PFLIP interrupts are still enabled */ | 2369 | /* Make sure VBLANK and PFLIP interrupts are still enabled */ |
2428 | type = amdgpu_crtc_idx_to_irq_type(adev, amdgpu_crtc->crtc_id); | 2370 | type = amdgpu_display_crtc_idx_to_irq_type(adev, |
2371 | amdgpu_crtc->crtc_id); | ||
2429 | amdgpu_irq_update(adev, &adev->crtc_irq, type); | 2372 | amdgpu_irq_update(adev, &adev->crtc_irq, type); |
2430 | amdgpu_irq_update(adev, &adev->pageflip_irq, type); | 2373 | amdgpu_irq_update(adev, &adev->pageflip_irq, type); |
2431 | drm_crtc_vblank_on(crtc); | 2374 | drm_crtc_vblank_on(crtc); |
@@ -2562,7 +2505,7 @@ static bool dce_v6_0_crtc_mode_fixup(struct drm_crtc *crtc, | |||
2562 | amdgpu_crtc->connector = NULL; | 2505 | amdgpu_crtc->connector = NULL; |
2563 | return false; | 2506 | return false; |
2564 | } | 2507 | } |
2565 | if (!amdgpu_crtc_scaling_mode_fixup(crtc, mode, adjusted_mode)) | 2508 | if (!amdgpu_display_crtc_scaling_mode_fixup(crtc, mode, adjusted_mode)) |
2566 | return false; | 2509 | return false; |
2567 | if (amdgpu_atombios_crtc_prepare_pll(crtc, adjusted_mode)) | 2510 | if (amdgpu_atombios_crtc_prepare_pll(crtc, adjusted_mode)) |
2568 | return false; | 2511 | return false; |
@@ -2693,9 +2636,9 @@ static int dce_v6_0_sw_init(void *handle) | |||
2693 | adev->ddev->mode_config.max_height = 16384; | 2636 | adev->ddev->mode_config.max_height = 16384; |
2694 | adev->ddev->mode_config.preferred_depth = 24; | 2637 | adev->ddev->mode_config.preferred_depth = 24; |
2695 | adev->ddev->mode_config.prefer_shadow = 1; | 2638 | adev->ddev->mode_config.prefer_shadow = 1; |
2696 | adev->ddev->mode_config.fb_base = adev->mc.aper_base; | 2639 | adev->ddev->mode_config.fb_base = adev->gmc.aper_base; |
2697 | 2640 | ||
2698 | r = amdgpu_modeset_create_props(adev); | 2641 | r = amdgpu_display_modeset_create_props(adev); |
2699 | if (r) | 2642 | if (r) |
2700 | return r; | 2643 | return r; |
2701 | 2644 | ||
@@ -2711,7 +2654,7 @@ static int dce_v6_0_sw_init(void *handle) | |||
2711 | 2654 | ||
2712 | ret = amdgpu_atombios_get_connector_info_from_object_table(adev); | 2655 | ret = amdgpu_atombios_get_connector_info_from_object_table(adev); |
2713 | if (ret) | 2656 | if (ret) |
2714 | amdgpu_print_display_setup(adev->ddev); | 2657 | amdgpu_display_print_display_setup(adev->ddev); |
2715 | else | 2658 | else |
2716 | return -EINVAL; | 2659 | return -EINVAL; |
2717 | 2660 | ||
@@ -2787,6 +2730,11 @@ static int dce_v6_0_hw_fini(void *handle) | |||
2787 | 2730 | ||
2788 | static int dce_v6_0_suspend(void *handle) | 2731 | static int dce_v6_0_suspend(void *handle) |
2789 | { | 2732 | { |
2733 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
2734 | |||
2735 | adev->mode_info.bl_level = | ||
2736 | amdgpu_atombios_encoder_get_backlight_level_from_reg(adev); | ||
2737 | |||
2790 | return dce_v6_0_hw_fini(handle); | 2738 | return dce_v6_0_hw_fini(handle); |
2791 | } | 2739 | } |
2792 | 2740 | ||
@@ -2795,6 +2743,9 @@ static int dce_v6_0_resume(void *handle) | |||
2795 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 2743 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
2796 | int ret; | 2744 | int ret; |
2797 | 2745 | ||
2746 | amdgpu_atombios_encoder_set_backlight_level_to_reg(adev, | ||
2747 | adev->mode_info.bl_level); | ||
2748 | |||
2798 | ret = dce_v6_0_hw_init(handle); | 2749 | ret = dce_v6_0_hw_init(handle); |
2799 | 2750 | ||
2800 | /* turn on the BL */ | 2751 | /* turn on the BL */ |
@@ -2966,7 +2917,8 @@ static int dce_v6_0_crtc_irq(struct amdgpu_device *adev, | |||
2966 | { | 2917 | { |
2967 | unsigned crtc = entry->src_id - 1; | 2918 | unsigned crtc = entry->src_id - 1; |
2968 | uint32_t disp_int = RREG32(interrupt_status_offsets[crtc].reg); | 2919 | uint32_t disp_int = RREG32(interrupt_status_offsets[crtc].reg); |
2969 | unsigned irq_type = amdgpu_crtc_idx_to_irq_type(adev, crtc); | 2920 | unsigned int irq_type = amdgpu_display_crtc_idx_to_irq_type(adev, |
2921 | crtc); | ||
2970 | 2922 | ||
2971 | switch (entry->src_data[0]) { | 2923 | switch (entry->src_data[0]) { |
2972 | case 0: /* vblank */ | 2924 | case 0: /* vblank */ |
@@ -3093,7 +3045,7 @@ static int dce_v6_0_hpd_irq(struct amdgpu_device *adev, | |||
3093 | tmp |= DC_HPD1_INT_CONTROL__DC_HPD1_INT_ACK_MASK; | 3045 | tmp |= DC_HPD1_INT_CONTROL__DC_HPD1_INT_ACK_MASK; |
3094 | WREG32(mmDC_HPD1_INT_CONTROL + hpd_offsets[hpd], tmp); | 3046 | WREG32(mmDC_HPD1_INT_CONTROL + hpd_offsets[hpd], tmp); |
3095 | schedule_work(&adev->hotplug_work); | 3047 | schedule_work(&adev->hotplug_work); |
3096 | DRM_INFO("IH: HPD%d\n", hpd + 1); | 3048 | DRM_DEBUG("IH: HPD%d\n", hpd + 1); |
3097 | } | 3049 | } |
3098 | 3050 | ||
3099 | return 0; | 3051 | return 0; |
@@ -3407,7 +3359,6 @@ static void dce_v6_0_encoder_add(struct amdgpu_device *adev, | |||
3407 | static const struct amdgpu_display_funcs dce_v6_0_display_funcs = { | 3359 | static const struct amdgpu_display_funcs dce_v6_0_display_funcs = { |
3408 | .bandwidth_update = &dce_v6_0_bandwidth_update, | 3360 | .bandwidth_update = &dce_v6_0_bandwidth_update, |
3409 | .vblank_get_counter = &dce_v6_0_vblank_get_counter, | 3361 | .vblank_get_counter = &dce_v6_0_vblank_get_counter, |
3410 | .vblank_wait = &dce_v6_0_vblank_wait, | ||
3411 | .backlight_set_level = &amdgpu_atombios_encoder_set_backlight_level, | 3362 | .backlight_set_level = &amdgpu_atombios_encoder_set_backlight_level, |
3412 | .backlight_get_level = &amdgpu_atombios_encoder_get_backlight_level, | 3363 | .backlight_get_level = &amdgpu_atombios_encoder_get_backlight_level, |
3413 | .hpd_sense = &dce_v6_0_hpd_sense, | 3364 | .hpd_sense = &dce_v6_0_hpd_sense, |