aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
diff options
context:
space:
mode:
authorAlex Deucher <alexander.deucher@amd.com>2015-10-07 23:26:15 -0400
committerAlex Deucher <alexander.deucher@amd.com>2015-10-14 16:16:32 -0400
commit77ed35b889e38775649ed985048cac8c134cd3a3 (patch)
tree7a47db203be79e418b74c98155b1cf156c49d106 /drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
parentec9353dca9a02b429f31ac58ec7b55ee61757441 (diff)
drm/amdgpu/dce8: Use cursor_set2 hook for enabling / disabling the HW cursor
The cursor_set2 hook provides the cursor hotspot position within the cursor image. When the hotspot position changes, we can adjust the cursor position such that the hotspot doesn't move on the screen. This prevents the cursor from appearing to intermittently jump around on the screen when the position of the hotspot within the cursor image changes. Port of radeon commits: 78b1a6010b46a69bcd47b723a80f92693f26d17b 3feba08d79c32777a845c3c8a4ab93092bdf6f19 Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/dce_v8_0.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/dce_v8_0.c74
1 files changed, 51 insertions, 23 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index c86911c2ea2a..aaa6561e9fc8 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -2417,20 +2417,8 @@ static void dce_v8_0_show_cursor(struct drm_crtc *crtc)
2417 (CURSOR_URGENT_1_2 << CUR_CONTROL__CURSOR_URGENT_CONTROL__SHIFT)); 2417 (CURSOR_URGENT_1_2 << CUR_CONTROL__CURSOR_URGENT_CONTROL__SHIFT));
2418} 2418}
2419 2419
2420static void dce_v8_0_set_cursor(struct drm_crtc *crtc, struct drm_gem_object *obj, 2420static int dce_v8_0_cursor_move_locked(struct drm_crtc *crtc,
2421 uint64_t gpu_addr) 2421 int x, int y)
2422{
2423 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2424 struct amdgpu_device *adev = crtc->dev->dev_private;
2425
2426 WREG32(mmCUR_SURFACE_ADDRESS_HIGH + amdgpu_crtc->crtc_offset,
2427 upper_32_bits(gpu_addr));
2428 WREG32(mmCUR_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset,
2429 gpu_addr & 0xffffffff);
2430}
2431
2432static int dce_v8_0_crtc_cursor_move(struct drm_crtc *crtc,
2433 int x, int y)
2434{ 2422{
2435 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 2423 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2436 struct amdgpu_device *adev = crtc->dev->dev_private; 2424 struct amdgpu_device *adev = crtc->dev->dev_private;
@@ -2450,21 +2438,61 @@ static int dce_v8_0_crtc_cursor_move(struct drm_crtc *crtc,
2450 y = 0; 2438 y = 0;
2451 } 2439 }
2452 2440
2453 dce_v8_0_lock_cursor(crtc, true);
2454 WREG32(mmCUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y); 2441 WREG32(mmCUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y);
2455 WREG32(mmCUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin); 2442 WREG32(mmCUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin);
2456 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset, 2443 WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset,
2457 ((amdgpu_crtc->cursor_width - 1) << 16) | (amdgpu_crtc->cursor_height - 1)); 2444 ((amdgpu_crtc->cursor_width - 1) << 16) | (amdgpu_crtc->cursor_height - 1));
2458 dce_v8_0_lock_cursor(crtc, false); 2445
2446 amdgpu_crtc->cursor_x = x;
2447 amdgpu_crtc->cursor_y = y;
2459 2448
2460 return 0; 2449 return 0;
2461} 2450}
2462 2451
2463static int dce_v8_0_crtc_cursor_set(struct drm_crtc *crtc, 2452static void dce_v8_0_set_cursor(struct drm_crtc *crtc, struct drm_gem_object *obj,
2464 struct drm_file *file_priv, 2453 uint64_t gpu_addr, int hot_x, int hot_y)
2465 uint32_t handle, 2454{
2466 uint32_t width, 2455 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2467 uint32_t height) 2456 struct amdgpu_device *adev = crtc->dev->dev_private;
2457
2458 WREG32(mmCUR_SURFACE_ADDRESS_HIGH + amdgpu_crtc->crtc_offset,
2459 upper_32_bits(gpu_addr));
2460 WREG32(mmCUR_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset,
2461 lower_32_bits(gpu_addr));
2462
2463 if (hot_x != amdgpu_crtc->cursor_hot_x ||
2464 hot_y != amdgpu_crtc->cursor_hot_y) {
2465 int x, y;
2466
2467 x = amdgpu_crtc->cursor_x + amdgpu_crtc->cursor_hot_x - hot_x;
2468 y = amdgpu_crtc->cursor_y + amdgpu_crtc->cursor_hot_y - hot_y;
2469
2470 dce_v8_0_cursor_move_locked(crtc, x, y);
2471
2472 amdgpu_crtc->cursor_hot_x = hot_x;
2473 amdgpu_crtc->cursor_hot_y = hot_y;
2474 }
2475}
2476
2477static int dce_v8_0_crtc_cursor_move(struct drm_crtc *crtc,
2478 int x, int y)
2479{
2480 int ret;
2481
2482 dce_v8_0_lock_cursor(crtc, true);
2483 ret = dce_v8_0_cursor_move_locked(crtc, x, y);
2484 dce_v8_0_lock_cursor(crtc, false);
2485
2486 return ret;
2487}
2488
2489static int dce_v8_0_crtc_cursor_set2(struct drm_crtc *crtc,
2490 struct drm_file *file_priv,
2491 uint32_t handle,
2492 uint32_t width,
2493 uint32_t height,
2494 int32_t hot_x,
2495 int32_t hot_y)
2468{ 2496{
2469 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); 2497 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2470 struct drm_gem_object *obj; 2498 struct drm_gem_object *obj;
@@ -2505,7 +2533,7 @@ static int dce_v8_0_crtc_cursor_set(struct drm_crtc *crtc,
2505 amdgpu_crtc->cursor_height = height; 2533 amdgpu_crtc->cursor_height = height;
2506 2534
2507 dce_v8_0_lock_cursor(crtc, true); 2535 dce_v8_0_lock_cursor(crtc, true);
2508 dce_v8_0_set_cursor(crtc, obj, gpu_addr); 2536 dce_v8_0_set_cursor(crtc, obj, gpu_addr, hot_x, hot_y);
2509 dce_v8_0_show_cursor(crtc); 2537 dce_v8_0_show_cursor(crtc);
2510 dce_v8_0_lock_cursor(crtc, false); 2538 dce_v8_0_lock_cursor(crtc, false);
2511 2539
@@ -2553,7 +2581,7 @@ static void dce_v8_0_crtc_destroy(struct drm_crtc *crtc)
2553} 2581}
2554 2582
2555static const struct drm_crtc_funcs dce_v8_0_crtc_funcs = { 2583static const struct drm_crtc_funcs dce_v8_0_crtc_funcs = {
2556 .cursor_set = dce_v8_0_crtc_cursor_set, 2584 .cursor_set2 = dce_v8_0_crtc_cursor_set2,
2557 .cursor_move = dce_v8_0_crtc_cursor_move, 2585 .cursor_move = dce_v8_0_crtc_cursor_move,
2558 .gamma_set = dce_v8_0_crtc_gamma_set, 2586 .gamma_set = dce_v8_0_crtc_gamma_set,
2559 .set_config = amdgpu_crtc_set_config, 2587 .set_config = amdgpu_crtc_set_config,