aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/r100.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2009-06-23 19:48:08 -0400
committerDave Airlie <airlied@redhat.com>2009-07-29 01:42:18 -0400
commite024e11070a0a0dc7163ce1ec2da354a638bdbed (patch)
treeadd483e7428f91da6f3c26be702aa45e6d69b694 /drivers/gpu/drm/radeon/r100.c
parentc836e862803b2aa2bd9a354e151316d2b42c44ec (diff)
drm/radeon/kms: add initial colortiling support.
This adds new set/get tiling interfaces where the pitch and macro/micro tiling enables can be set. Along with a flag to decide if this object should have a surface when mapped. The only thing we need to allocate with a mapped surface should be the frontbuffer. Note rotate scanout shouldn't require one, and back/depth shouldn't either, though mesa needs some fixes. It fixes the TTM interfaces along Thomas's suggestions, and I've tested the surface stealing code with two X servers and not seen any lockdep issues. I've stopped tiling the fbcon frontbuffer, as I don't see there being any advantage other than testing, I've left the testing commands in there, just flip the fb_tiled to true in radeon_fb.c Open: Can we integrate endian swapping in with this? Future features: texture tiling - need to relocate texture registers TXOFFSET* with tiling info. This also merges Michel's cleanup surfaces regs at init time patch even though it makes sense on its own, this patch really relies on it. Some PowerMac firmwares set up a tiling surface at the beginning of VRAM which messes us up otherwise. that patch is: Signed-off-by: Michel Dänzer <daenzer@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/r100.c')
-rw-r--r--drivers/gpu/drm/radeon/r100.c79
1 files changed, 78 insertions, 1 deletions
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 0d05909f03f6..69bd7cb59972 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -909,6 +909,7 @@ static int r100_packet0_check(struct radeon_cs_parser *p,
909 unsigned idx; 909 unsigned idx;
910 bool onereg; 910 bool onereg;
911 int r; 911 int r;
912 u32 tile_flags = 0;
912 913
913 ib = p->ib->ptr; 914 ib = p->ib->ptr;
914 ib_chunk = &p->chunks[p->chunk_ib_idx]; 915 ib_chunk = &p->chunks[p->chunk_ib_idx];
@@ -942,7 +943,20 @@ static int r100_packet0_check(struct radeon_cs_parser *p,
942 } 943 }
943 tmp = ib_chunk->kdata[idx] & 0x003fffff; 944 tmp = ib_chunk->kdata[idx] & 0x003fffff;
944 tmp += (((u32)reloc->lobj.gpu_offset) >> 10); 945 tmp += (((u32)reloc->lobj.gpu_offset) >> 10);
945 ib[idx] = (ib_chunk->kdata[idx] & 0xffc00000) | tmp; 946
947 if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO)
948 tile_flags |= RADEON_DST_TILE_MACRO;
949 if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO) {
950 if (reg == RADEON_SRC_PITCH_OFFSET) {
951 DRM_ERROR("Cannot src blit from microtiled surface\n");
952 r100_cs_dump_packet(p, pkt);
953 return -EINVAL;
954 }
955 tile_flags |= RADEON_DST_TILE_MICRO;
956 }
957
958 tmp |= tile_flags;
959 ib[idx] = (ib_chunk->kdata[idx] & 0x3fc00000) | tmp;
946 break; 960 break;
947 case RADEON_RB3D_DEPTHOFFSET: 961 case RADEON_RB3D_DEPTHOFFSET:
948 case RADEON_RB3D_COLOROFFSET: 962 case RADEON_RB3D_COLOROFFSET:
@@ -987,6 +1001,25 @@ static int r100_packet0_check(struct radeon_cs_parser *p,
987 } 1001 }
988 ib[idx] = ib_chunk->kdata[idx] + ((u32)reloc->lobj.gpu_offset); 1002 ib[idx] = ib_chunk->kdata[idx] + ((u32)reloc->lobj.gpu_offset);
989 break; 1003 break;
1004 case R300_RB3D_COLORPITCH0:
1005 case RADEON_RB3D_COLORPITCH:
1006 r = r100_cs_packet_next_reloc(p, &reloc);
1007 if (r) {
1008 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
1009 idx, reg);
1010 r100_cs_dump_packet(p, pkt);
1011 return r;
1012 }
1013
1014 if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO)
1015 tile_flags |= RADEON_COLOR_TILE_ENABLE;
1016 if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO)
1017 tile_flags |= RADEON_COLOR_MICROTILE_ENABLE;
1018
1019 tmp = ib_chunk->kdata[idx] & ~(0x7 << 16);
1020 tmp |= tile_flags;
1021 ib[idx] = tmp;
1022 break;
990 default: 1023 default:
991 /* FIXME: we don't want to allow anyothers packet */ 1024 /* FIXME: we don't want to allow anyothers packet */
992 break; 1025 break;
@@ -1707,3 +1740,47 @@ int r100_debugfs_mc_info_init(struct radeon_device *rdev)
1707 return 0; 1740 return 0;
1708#endif 1741#endif
1709} 1742}
1743
1744int r100_set_surface_reg(struct radeon_device *rdev, int reg,
1745 uint32_t tiling_flags, uint32_t pitch,
1746 uint32_t offset, uint32_t obj_size)
1747{
1748 int surf_index = reg * 16;
1749 int flags = 0;
1750
1751 /* r100/r200 divide by 16 */
1752 if (rdev->family < CHIP_R300)
1753 flags = pitch / 16;
1754 else
1755 flags = pitch / 8;
1756
1757 if (rdev->family <= CHIP_RS200) {
1758 if ((tiling_flags & (RADEON_TILING_MACRO|RADEON_TILING_MICRO))
1759 == (RADEON_TILING_MACRO|RADEON_TILING_MICRO))
1760 flags |= RADEON_SURF_TILE_COLOR_BOTH;
1761 if (tiling_flags & RADEON_TILING_MACRO)
1762 flags |= RADEON_SURF_TILE_COLOR_MACRO;
1763 } else if (rdev->family <= CHIP_RV280) {
1764 if (tiling_flags & (RADEON_TILING_MACRO))
1765 flags |= R200_SURF_TILE_COLOR_MACRO;
1766 if (tiling_flags & RADEON_TILING_MICRO)
1767 flags |= R200_SURF_TILE_COLOR_MICRO;
1768 } else {
1769 if (tiling_flags & RADEON_TILING_MACRO)
1770 flags |= R300_SURF_TILE_MACRO;
1771 if (tiling_flags & RADEON_TILING_MICRO)
1772 flags |= R300_SURF_TILE_MICRO;
1773 }
1774
1775 DRM_DEBUG("writing surface %d %d %x %x\n", reg, flags, offset, offset+obj_size-1);
1776 WREG32(RADEON_SURFACE0_INFO + surf_index, flags);
1777 WREG32(RADEON_SURFACE0_LOWER_BOUND + surf_index, offset);
1778 WREG32(RADEON_SURFACE0_UPPER_BOUND + surf_index, offset + obj_size - 1);
1779 return 0;
1780}
1781
1782void r100_clear_surface_reg(struct radeon_device *rdev, int reg)
1783{
1784 int surf_index = reg * 16;
1785 WREG32(RADEON_SURFACE0_INFO + surf_index, 0);
1786}