Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/radeon/cik: add hw cursor support (v2)

CIK (DCE8) hw cursors are programmed the same as evergreen
(DCE4) with the following caveats:
- cursors are now 128x128 pixels
- new alpha blend enable bit

v2: rebase

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

+94 -7
+65
drivers/gpu/drm/radeon/cik_reg.h
··· 1 + /* 2 + * Copyright 2012 Advanced Micro Devices, Inc. 3 + * 4 + * Permission is hereby granted, free of charge, to any person obtaining a 5 + * copy of this software and associated documentation files (the "Software"), 6 + * to deal in the Software without restriction, including without limitation 7 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 + * and/or sell copies of the Software, and to permit persons to whom the 9 + * Software is furnished to do so, subject to the following conditions: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 14 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 + * OTHER DEALINGS IN THE SOFTWARE. 21 + * 22 + * Authors: Alex Deucher 23 + */ 24 + #ifndef __CIK_REG_H__ 25 + #define __CIK_REG_H__ 26 + 27 + #define CIK_DC_GPIO_HPD_MASK 0x65b0 28 + #define CIK_DC_GPIO_HPD_A 0x65b4 29 + #define CIK_DC_GPIO_HPD_EN 0x65b8 30 + #define CIK_DC_GPIO_HPD_Y 0x65bc 31 + 32 + /* CUR blocks at 0x6998, 0x7598, 0x10198, 0x10d98, 0x11998, 0x12598 */ 33 + #define CIK_CUR_CONTROL 0x6998 34 + # define CIK_CURSOR_EN (1 << 0) 35 + # define CIK_CURSOR_MODE(x) (((x) & 0x3) << 8) 36 + # define CIK_CURSOR_MONO 0 37 + # define CIK_CURSOR_24_1 1 38 + # define CIK_CURSOR_24_8_PRE_MULT 2 39 + # define CIK_CURSOR_24_8_UNPRE_MULT 3 40 + # define CIK_CURSOR_2X_MAGNIFY (1 << 16) 41 + # define CIK_CURSOR_FORCE_MC_ON (1 << 20) 42 + # define CIK_CURSOR_URGENT_CONTROL(x) (((x) & 0x7) << 24) 43 + # define CIK_CURSOR_URGENT_ALWAYS 0 44 + # define CIK_CURSOR_URGENT_1_8 1 45 + # define CIK_CURSOR_URGENT_1_4 2 46 + # define CIK_CURSOR_URGENT_3_8 3 47 + # define CIK_CURSOR_URGENT_1_2 4 48 + #define CIK_CUR_SURFACE_ADDRESS 0x699c 49 + # define CIK_CUR_SURFACE_ADDRESS_MASK 0xfffff000 50 + #define CIK_CUR_SIZE 0x69a0 51 + #define CIK_CUR_SURFACE_ADDRESS_HIGH 0x69a4 52 + #define CIK_CUR_POSITION 0x69a8 53 + #define CIK_CUR_HOT_SPOT 0x69ac 54 + #define CIK_CUR_COLOR1 0x69b0 55 + #define CIK_CUR_COLOR2 0x69b4 56 + #define CIK_CUR_UPDATE 0x69b8 57 + # define CIK_CURSOR_UPDATE_PENDING (1 << 0) 58 + # define CIK_CURSOR_UPDATE_TAKEN (1 << 1) 59 + # define CIK_CURSOR_UPDATE_LOCK (1 << 16) 60 + # define CIK_CURSOR_DISABLE_MULTIPLE_UPDATE (1 << 24) 61 + 62 + #define CIK_ALPHA_CONTROL 0x6af0 63 + # define CIK_CURSOR_ALPHA_BLND_ENA (1 << 1) 64 + 65 + #endif
+7
drivers/gpu/drm/radeon/radeon.h
··· 150 150 #define RADEON_RESET_MC (1 << 10) 151 151 #define RADEON_RESET_DISPLAY (1 << 11) 152 152 153 + /* max cursor sizes (in pixels) */ 154 + #define CURSOR_WIDTH 64 155 + #define CURSOR_HEIGHT 64 156 + 157 + #define CIK_CURSOR_WIDTH 128 158 + #define CIK_CURSOR_HEIGHT 128 159 + 153 160 /* 154 161 * Errata workarounds. 155 162 */
+4 -6
drivers/gpu/drm/radeon/radeon_cursor.c
··· 27 27 #include <drm/radeon_drm.h> 28 28 #include "radeon.h" 29 29 30 - #define CURSOR_WIDTH 64 31 - #define CURSOR_HEIGHT 64 32 - 33 30 static void radeon_lock_cursor(struct drm_crtc *crtc, bool lock) 34 31 { 35 32 struct radeon_device *rdev = crtc->dev->dev_private; ··· 164 167 goto unpin; 165 168 } 166 169 167 - if ((width > CURSOR_WIDTH) || (height > CURSOR_HEIGHT)) { 170 + if ((width > radeon_crtc->max_cursor_width) || 171 + (height > radeon_crtc->max_cursor_height)) { 168 172 DRM_ERROR("bad cursor width or height %d x %d\n", width, height); 169 173 return -EINVAL; 170 174 } ··· 231 233 DRM_DEBUG("x %d y %d c->x %d c->y %d\n", x, y, crtc->x, crtc->y); 232 234 233 235 if (x < 0) { 234 - xorigin = min(-x, CURSOR_WIDTH - 1); 236 + xorigin = min(-x, radeon_crtc->max_cursor_width - 1); 235 237 x = 0; 236 238 } 237 239 if (y < 0) { 238 - yorigin = min(-y, CURSOR_HEIGHT - 1); 240 + yorigin = min(-y, radeon_crtc->max_cursor_height - 1); 239 241 y = 0; 240 242 } 241 243
+15 -1
drivers/gpu/drm/radeon/radeon_display.c
··· 153 153 NI_OUTPUT_CSC_OVL_MODE(NI_OUTPUT_CSC_BYPASS))); 154 154 /* XXX match this to the depth of the crtc fmt block, move to modeset? */ 155 155 WREG32(0x6940 + radeon_crtc->crtc_offset, 0); 156 - 156 + if (ASIC_IS_DCE8(rdev)) { 157 + /* XXX this only needs to be programmed once per crtc at startup, 158 + * not sure where the best place for it is 159 + */ 160 + WREG32(CIK_ALPHA_CONTROL + radeon_crtc->crtc_offset, 161 + CIK_CURSOR_ALPHA_BLND_ENA); 162 + } 157 163 } 158 164 159 165 static void legacy_crtc_load_lut(struct drm_crtc *crtc) ··· 517 511 drm_mode_crtc_set_gamma_size(&radeon_crtc->base, 256); 518 512 radeon_crtc->crtc_id = index; 519 513 rdev->mode_info.crtcs[index] = radeon_crtc; 514 + 515 + if (rdev->family >= CHIP_BONAIRE) { 516 + radeon_crtc->max_cursor_width = CIK_CURSOR_WIDTH; 517 + radeon_crtc->max_cursor_height = CIK_CURSOR_HEIGHT; 518 + } else { 519 + radeon_crtc->max_cursor_width = CURSOR_WIDTH; 520 + radeon_crtc->max_cursor_height = CURSOR_HEIGHT; 521 + } 520 522 521 523 #if 0 522 524 radeon_crtc->mode_set.crtc = &radeon_crtc->base;
+2
drivers/gpu/drm/radeon/radeon_mode.h
··· 307 307 uint64_t cursor_addr; 308 308 int cursor_width; 309 309 int cursor_height; 310 + int max_cursor_width; 311 + int max_cursor_height; 310 312 uint32_t legacy_display_base_addr; 311 313 uint32_t legacy_cursor_offset; 312 314 enum radeon_rmx_type rmx_type;
+1
drivers/gpu/drm/radeon/radeon_reg.h
··· 57 57 #include "evergreen_reg.h" 58 58 #include "ni_reg.h" 59 59 #include "si_reg.h" 60 + #include "cik_reg.h" 60 61 61 62 #define RADEON_MC_AGP_LOCATION 0x014c 62 63 #define RADEON_MC_AGP_START_MASK 0x0000FFFF