Skip to content

Commit fa6bee4

Browse files
agd5fairlied
authored andcommitted
drm/radeon/kms: fix r6xx+ scanout on BE systems
R6xx+ have per-block swappers. BE content in the framebuffer will now be swapped properly during scanout. Untested, however, the same code is reported working in the UMS ddx. Signed-off-by: Alex Deucher <alexdeucher@gmail.com> Signed-off-by: Dave Airlie <airlied@gmail.com>
1 parent d75ee3b commit fa6bee4

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎drivers/gpu/drm/radeon/atombios_crtc.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@ static int evergreen_crtc_do_set_base(struct drm_crtc *crtc,
994994
struct radeon_bo *rbo;
995995
uint64_t fb_location;
996996
uint32_t fb_format, fb_pitch_pixels, tiling_flags;
997+
u32 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_NONE);
997998
int r;
998999

9991000
/* no fb bound */
@@ -1045,11 +1046,17 @@ static int evergreen_crtc_do_set_base(struct drm_crtc *crtc,
10451046
case 16:
10461047
fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) |
10471048
EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB565));
1049+
#ifdef __BIG_ENDIAN
1050+
fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN16);
1051+
#endif
10481052
break;
10491053
case 24:
10501054
case 32:
10511055
fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_32BPP) |
10521056
EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB8888));
1057+
#ifdef __BIG_ENDIAN
1058+
fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN32);
1059+
#endif
10531060
break;
10541061
default:
10551062
DRM_ERROR("Unsupported screen depth %d\n",
@@ -1094,6 +1101,7 @@ static int evergreen_crtc_do_set_base(struct drm_crtc *crtc,
10941101
WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset,
10951102
(u32) fb_location & EVERGREEN_GRPH_SURFACE_ADDRESS_MASK);
10961103
WREG32(EVERGREEN_GRPH_CONTROL + radeon_crtc->crtc_offset, fb_format);
1104+
WREG32(EVERGREEN_GRPH_SWAP_CONTROL + radeon_crtc->crtc_offset, fb_swap);
10971105

10981106
WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0);
10991107
WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0);
@@ -1150,6 +1158,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
11501158
struct drm_framebuffer *target_fb;
11511159
uint64_t fb_location;
11521160
uint32_t fb_format, fb_pitch_pixels, tiling_flags;
1161+
u32 fb_swap = R600_D1GRPH_SWAP_ENDIAN_NONE;
11531162
int r;
11541163

11551164
/* no fb bound */
@@ -1203,12 +1212,18 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
12031212
fb_format =
12041213
AVIVO_D1GRPH_CONTROL_DEPTH_16BPP |
12051214
AVIVO_D1GRPH_CONTROL_16BPP_RGB565;
1215+
#ifdef __BIG_ENDIAN
1216+
fb_swap = R600_D1GRPH_SWAP_ENDIAN_16BIT;
1217+
#endif
12061218
break;
12071219
case 24:
12081220
case 32:
12091221
fb_format =
12101222
AVIVO_D1GRPH_CONTROL_DEPTH_32BPP |
12111223
AVIVO_D1GRPH_CONTROL_32BPP_ARGB8888;
1224+
#ifdef __BIG_ENDIAN
1225+
fb_swap = R600_D1GRPH_SWAP_ENDIAN_32BIT;
1226+
#endif
12121227
break;
12131228
default:
12141229
DRM_ERROR("Unsupported screen depth %d\n",
@@ -1248,6 +1263,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
12481263
WREG32(AVIVO_D1GRPH_SECONDARY_SURFACE_ADDRESS +
12491264
radeon_crtc->crtc_offset, (u32) fb_location);
12501265
WREG32(AVIVO_D1GRPH_CONTROL + radeon_crtc->crtc_offset, fb_format);
1266+
if (rdev->family >= CHIP_R600)
1267+
WREG32(R600_D1GRPH_SWAP_CONTROL + radeon_crtc->crtc_offset, fb_swap);
12511268

12521269
WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0);
12531270
WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0);

‎drivers/gpu/drm/radeon/r600_reg.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@
8181
#define R600_MEDIUM_VID_LOWER_GPIO_CNTL 0x720
8282
#define R600_LOW_VID_LOWER_GPIO_CNTL 0x724
8383

84-
84+
#define R600_D1GRPH_SWAP_CONTROL 0x610C
85+
# define R600_D1GRPH_SWAP_ENDIAN_NONE (0 << 0)
86+
# define R600_D1GRPH_SWAP_ENDIAN_16BIT (1 << 0)
87+
# define R600_D1GRPH_SWAP_ENDIAN_32BIT (2 << 0)
88+
# define R600_D1GRPH_SWAP_ENDIAN_64BIT (3 << 0)
8589

8690
#define R600_HDP_NONSURFACE_BASE 0x2c04
8791

0 commit comments

Comments
 (0)