Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Advanced Micro Devices, Inc. |
| 3 | * Copyright 2008 Red Hat Inc. |
| 4 | * Copyright 2009 Jerome Glisse. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 22 | * OTHER DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: Dave Airlie |
| 25 | * Alex Deucher |
| 26 | * Jerome Glisse |
| 27 | */ |
| 28 | #include "drmP.h" |
| 29 | #include "drm.h" |
| 30 | #include "radeon_drm.h" |
| 31 | #include "radeon_reg.h" |
| 32 | #include "radeon.h" |
Daniel Vetter | e699037 | 2010-03-11 21:19:17 +0000 | [diff] [blame] | 33 | #include "radeon_asic.h" |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 34 | |
Pauli Nieminen | 44ca747 | 2010-02-11 17:25:47 +0000 | [diff] [blame] | 35 | #include "r100d.h" |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 36 | #include "r200_reg_safe.h" |
| 37 | |
| 38 | #include "r100_track.h" |
| 39 | |
| 40 | static int r200_get_vtx_size_0(uint32_t vtx_fmt_0) |
| 41 | { |
| 42 | int vtx_size, i; |
| 43 | vtx_size = 2; |
| 44 | |
| 45 | if (vtx_fmt_0 & R200_VTX_Z0) |
| 46 | vtx_size++; |
| 47 | if (vtx_fmt_0 & R200_VTX_W0) |
| 48 | vtx_size++; |
| 49 | /* blend weight */ |
| 50 | if (vtx_fmt_0 & (0x7 << R200_VTX_WEIGHT_COUNT_SHIFT)) |
| 51 | vtx_size += (vtx_fmt_0 >> R200_VTX_WEIGHT_COUNT_SHIFT) & 0x7; |
| 52 | if (vtx_fmt_0 & R200_VTX_PV_MATRIX_SEL) |
| 53 | vtx_size++; |
| 54 | if (vtx_fmt_0 & R200_VTX_N0) |
| 55 | vtx_size += 3; |
| 56 | if (vtx_fmt_0 & R200_VTX_POINT_SIZE) |
| 57 | vtx_size++; |
| 58 | if (vtx_fmt_0 & R200_VTX_DISCRETE_FOG) |
| 59 | vtx_size++; |
| 60 | if (vtx_fmt_0 & R200_VTX_SHININESS_0) |
| 61 | vtx_size++; |
| 62 | if (vtx_fmt_0 & R200_VTX_SHININESS_1) |
| 63 | vtx_size++; |
| 64 | for (i = 0; i < 8; i++) { |
| 65 | int color_size = (vtx_fmt_0 >> (11 + 2*i)) & 0x3; |
| 66 | switch (color_size) { |
| 67 | case 0: break; |
| 68 | case 1: vtx_size++; break; |
| 69 | case 2: vtx_size += 3; break; |
| 70 | case 3: vtx_size += 4; break; |
| 71 | } |
| 72 | } |
| 73 | if (vtx_fmt_0 & R200_VTX_XY1) |
| 74 | vtx_size += 2; |
| 75 | if (vtx_fmt_0 & R200_VTX_Z1) |
| 76 | vtx_size++; |
| 77 | if (vtx_fmt_0 & R200_VTX_W1) |
| 78 | vtx_size++; |
| 79 | if (vtx_fmt_0 & R200_VTX_N1) |
| 80 | vtx_size += 3; |
| 81 | return vtx_size; |
| 82 | } |
| 83 | |
Pauli Nieminen | 44ca747 | 2010-02-11 17:25:47 +0000 | [diff] [blame] | 84 | int r200_copy_dma(struct radeon_device *rdev, |
| 85 | uint64_t src_offset, |
| 86 | uint64_t dst_offset, |
Alex Deucher | 003cefe | 2011-09-16 12:04:08 -0400 | [diff] [blame] | 87 | unsigned num_gpu_pages, |
Christian König | 876dc9f | 2012-05-08 14:24:01 +0200 | [diff] [blame] | 88 | struct radeon_fence **fence) |
Pauli Nieminen | 44ca747 | 2010-02-11 17:25:47 +0000 | [diff] [blame] | 89 | { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 90 | struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
Pauli Nieminen | 44ca747 | 2010-02-11 17:25:47 +0000 | [diff] [blame] | 91 | uint32_t size; |
| 92 | uint32_t cur_size; |
| 93 | int i, num_loops; |
| 94 | int r = 0; |
| 95 | |
| 96 | /* radeon pitch is /64 */ |
Alex Deucher | 003cefe | 2011-09-16 12:04:08 -0400 | [diff] [blame] | 97 | size = num_gpu_pages << RADEON_GPU_PAGE_SHIFT; |
Pauli Nieminen | 44ca747 | 2010-02-11 17:25:47 +0000 | [diff] [blame] | 98 | num_loops = DIV_ROUND_UP(size, 0x1FFFFF); |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 99 | r = radeon_ring_lock(rdev, ring, num_loops * 4 + 64); |
Pauli Nieminen | 44ca747 | 2010-02-11 17:25:47 +0000 | [diff] [blame] | 100 | if (r) { |
| 101 | DRM_ERROR("radeon: moving bo (%d).\n", r); |
| 102 | return r; |
| 103 | } |
| 104 | /* Must wait for 2D idle & clean before DMA or hangs might happen */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 105 | radeon_ring_write(ring, PACKET0(RADEON_WAIT_UNTIL, 0)); |
| 106 | radeon_ring_write(ring, (1 << 16)); |
Pauli Nieminen | 44ca747 | 2010-02-11 17:25:47 +0000 | [diff] [blame] | 107 | for (i = 0; i < num_loops; i++) { |
| 108 | cur_size = size; |
| 109 | if (cur_size > 0x1FFFFF) { |
| 110 | cur_size = 0x1FFFFF; |
| 111 | } |
| 112 | size -= cur_size; |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 113 | radeon_ring_write(ring, PACKET0(0x720, 2)); |
| 114 | radeon_ring_write(ring, src_offset); |
| 115 | radeon_ring_write(ring, dst_offset); |
| 116 | radeon_ring_write(ring, cur_size | (1 << 31) | (1 << 30)); |
Pauli Nieminen | 44ca747 | 2010-02-11 17:25:47 +0000 | [diff] [blame] | 117 | src_offset += cur_size; |
| 118 | dst_offset += cur_size; |
| 119 | } |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 120 | radeon_ring_write(ring, PACKET0(RADEON_WAIT_UNTIL, 0)); |
| 121 | radeon_ring_write(ring, RADEON_WAIT_DMA_GUI_IDLE); |
Pauli Nieminen | 44ca747 | 2010-02-11 17:25:47 +0000 | [diff] [blame] | 122 | if (fence) { |
Christian König | 876dc9f | 2012-05-08 14:24:01 +0200 | [diff] [blame] | 123 | r = radeon_fence_emit(rdev, fence, RADEON_RING_TYPE_GFX_INDEX); |
Pauli Nieminen | 44ca747 | 2010-02-11 17:25:47 +0000 | [diff] [blame] | 124 | } |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 125 | radeon_ring_unlock_commit(rdev, ring); |
Pauli Nieminen | 44ca747 | 2010-02-11 17:25:47 +0000 | [diff] [blame] | 126 | return r; |
| 127 | } |
| 128 | |
| 129 | |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 130 | static int r200_get_vtx_size_1(uint32_t vtx_fmt_1) |
| 131 | { |
| 132 | int vtx_size, i, tex_size; |
| 133 | vtx_size = 0; |
| 134 | for (i = 0; i < 6; i++) { |
| 135 | tex_size = (vtx_fmt_1 >> (i * 3)) & 0x7; |
| 136 | if (tex_size > 4) |
| 137 | continue; |
| 138 | vtx_size += tex_size; |
| 139 | } |
| 140 | return vtx_size; |
| 141 | } |
| 142 | |
| 143 | int r200_packet0_check(struct radeon_cs_parser *p, |
| 144 | struct radeon_cs_packet *pkt, |
| 145 | unsigned idx, unsigned reg) |
| 146 | { |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 147 | struct radeon_cs_reloc *reloc; |
| 148 | struct r100_cs_track *track; |
| 149 | volatile uint32_t *ib; |
| 150 | uint32_t tmp; |
| 151 | int r; |
| 152 | int i; |
| 153 | int face; |
| 154 | u32 tile_flags = 0; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 155 | u32 idx_value; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 156 | |
Jerome Glisse | f2e3922 | 2012-05-09 15:35:02 +0200 | [diff] [blame] | 157 | ib = p->ib.ptr; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 158 | track = (struct r100_cs_track *)p->track; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 159 | idx_value = radeon_get_ib_value(p, idx); |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 160 | switch (reg) { |
| 161 | case RADEON_CRTC_GUI_TRIG_VLINE: |
| 162 | r = r100_cs_packet_parse_vline(p); |
| 163 | if (r) { |
| 164 | DRM_ERROR("No reloc for ib[%d]=0x%04X\n", |
| 165 | idx, reg); |
| 166 | r100_cs_dump_packet(p, pkt); |
| 167 | return r; |
| 168 | } |
| 169 | break; |
| 170 | /* FIXME: only allow PACKET3 blit? easier to check for out of |
| 171 | * range access */ |
| 172 | case RADEON_DST_PITCH_OFFSET: |
| 173 | case RADEON_SRC_PITCH_OFFSET: |
| 174 | r = r100_reloc_pitch_offset(p, pkt, idx, reg); |
| 175 | if (r) |
| 176 | return r; |
| 177 | break; |
| 178 | case RADEON_RB3D_DEPTHOFFSET: |
| 179 | r = r100_cs_packet_next_reloc(p, &reloc); |
| 180 | if (r) { |
| 181 | DRM_ERROR("No reloc for ib[%d]=0x%04X\n", |
| 182 | idx, reg); |
| 183 | r100_cs_dump_packet(p, pkt); |
| 184 | return r; |
| 185 | } |
| 186 | track->zb.robj = reloc->robj; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 187 | track->zb.offset = idx_value; |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 188 | track->zb_dirty = true; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 189 | ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset); |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 190 | break; |
| 191 | case RADEON_RB3D_COLOROFFSET: |
| 192 | r = r100_cs_packet_next_reloc(p, &reloc); |
| 193 | if (r) { |
| 194 | DRM_ERROR("No reloc for ib[%d]=0x%04X\n", |
| 195 | idx, reg); |
| 196 | r100_cs_dump_packet(p, pkt); |
| 197 | return r; |
| 198 | } |
| 199 | track->cb[0].robj = reloc->robj; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 200 | track->cb[0].offset = idx_value; |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 201 | track->cb_dirty = true; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 202 | ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset); |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 203 | break; |
| 204 | case R200_PP_TXOFFSET_0: |
| 205 | case R200_PP_TXOFFSET_1: |
| 206 | case R200_PP_TXOFFSET_2: |
| 207 | case R200_PP_TXOFFSET_3: |
| 208 | case R200_PP_TXOFFSET_4: |
| 209 | case R200_PP_TXOFFSET_5: |
| 210 | i = (reg - R200_PP_TXOFFSET_0) / 24; |
| 211 | r = r100_cs_packet_next_reloc(p, &reloc); |
| 212 | if (r) { |
| 213 | DRM_ERROR("No reloc for ib[%d]=0x%04X\n", |
| 214 | idx, reg); |
| 215 | r100_cs_dump_packet(p, pkt); |
| 216 | return r; |
| 217 | } |
Alex Deucher | f2746f8 | 2012-02-02 10:11:12 -0500 | [diff] [blame] | 218 | if (!(p->cs_flags & RADEON_CS_KEEP_TILING_FLAGS)) { |
| 219 | if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO) |
| 220 | tile_flags |= R200_TXO_MACRO_TILE; |
| 221 | if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO) |
| 222 | tile_flags |= R200_TXO_MICRO_TILE; |
| 223 | |
| 224 | tmp = idx_value & ~(0x7 << 2); |
| 225 | tmp |= tile_flags; |
| 226 | ib[idx] = tmp + ((u32)reloc->lobj.gpu_offset); |
| 227 | } else |
| 228 | ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset); |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 229 | track->textures[i].robj = reloc->robj; |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 230 | track->tex_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 231 | break; |
| 232 | case R200_PP_CUBIC_OFFSET_F1_0: |
| 233 | case R200_PP_CUBIC_OFFSET_F2_0: |
| 234 | case R200_PP_CUBIC_OFFSET_F3_0: |
| 235 | case R200_PP_CUBIC_OFFSET_F4_0: |
| 236 | case R200_PP_CUBIC_OFFSET_F5_0: |
| 237 | case R200_PP_CUBIC_OFFSET_F1_1: |
| 238 | case R200_PP_CUBIC_OFFSET_F2_1: |
| 239 | case R200_PP_CUBIC_OFFSET_F3_1: |
| 240 | case R200_PP_CUBIC_OFFSET_F4_1: |
| 241 | case R200_PP_CUBIC_OFFSET_F5_1: |
| 242 | case R200_PP_CUBIC_OFFSET_F1_2: |
| 243 | case R200_PP_CUBIC_OFFSET_F2_2: |
| 244 | case R200_PP_CUBIC_OFFSET_F3_2: |
| 245 | case R200_PP_CUBIC_OFFSET_F4_2: |
| 246 | case R200_PP_CUBIC_OFFSET_F5_2: |
| 247 | case R200_PP_CUBIC_OFFSET_F1_3: |
| 248 | case R200_PP_CUBIC_OFFSET_F2_3: |
| 249 | case R200_PP_CUBIC_OFFSET_F3_3: |
| 250 | case R200_PP_CUBIC_OFFSET_F4_3: |
| 251 | case R200_PP_CUBIC_OFFSET_F5_3: |
| 252 | case R200_PP_CUBIC_OFFSET_F1_4: |
| 253 | case R200_PP_CUBIC_OFFSET_F2_4: |
| 254 | case R200_PP_CUBIC_OFFSET_F3_4: |
| 255 | case R200_PP_CUBIC_OFFSET_F4_4: |
| 256 | case R200_PP_CUBIC_OFFSET_F5_4: |
| 257 | case R200_PP_CUBIC_OFFSET_F1_5: |
| 258 | case R200_PP_CUBIC_OFFSET_F2_5: |
| 259 | case R200_PP_CUBIC_OFFSET_F3_5: |
| 260 | case R200_PP_CUBIC_OFFSET_F4_5: |
| 261 | case R200_PP_CUBIC_OFFSET_F5_5: |
| 262 | i = (reg - R200_PP_TXOFFSET_0) / 24; |
| 263 | face = (reg - ((i * 24) + R200_PP_TXOFFSET_0)) / 4; |
| 264 | r = r100_cs_packet_next_reloc(p, &reloc); |
| 265 | if (r) { |
| 266 | DRM_ERROR("No reloc for ib[%d]=0x%04X\n", |
| 267 | idx, reg); |
| 268 | r100_cs_dump_packet(p, pkt); |
| 269 | return r; |
| 270 | } |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 271 | track->textures[i].cube_info[face - 1].offset = idx_value; |
| 272 | ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset); |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 273 | track->textures[i].cube_info[face - 1].robj = reloc->robj; |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 274 | track->tex_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 275 | break; |
| 276 | case RADEON_RE_WIDTH_HEIGHT: |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 277 | track->maxy = ((idx_value >> 16) & 0x7FF); |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 278 | track->cb_dirty = true; |
| 279 | track->zb_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 280 | break; |
| 281 | case RADEON_RB3D_COLORPITCH: |
| 282 | r = r100_cs_packet_next_reloc(p, &reloc); |
| 283 | if (r) { |
| 284 | DRM_ERROR("No reloc for ib[%d]=0x%04X\n", |
| 285 | idx, reg); |
| 286 | r100_cs_dump_packet(p, pkt); |
| 287 | return r; |
| 288 | } |
| 289 | |
Alex Deucher | c9068eb | 2012-02-02 10:11:11 -0500 | [diff] [blame] | 290 | if (!(p->cs_flags & RADEON_CS_KEEP_TILING_FLAGS)) { |
| 291 | if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO) |
| 292 | tile_flags |= RADEON_COLOR_TILE_ENABLE; |
| 293 | if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO) |
| 294 | tile_flags |= RADEON_COLOR_MICROTILE_ENABLE; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 295 | |
Alex Deucher | c9068eb | 2012-02-02 10:11:11 -0500 | [diff] [blame] | 296 | tmp = idx_value & ~(0x7 << 16); |
| 297 | tmp |= tile_flags; |
| 298 | ib[idx] = tmp; |
| 299 | } else |
| 300 | ib[idx] = idx_value; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 301 | |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 302 | track->cb[0].pitch = idx_value & RADEON_COLORPITCH_MASK; |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 303 | track->cb_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 304 | break; |
| 305 | case RADEON_RB3D_DEPTHPITCH: |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 306 | track->zb.pitch = idx_value & RADEON_DEPTHPITCH_MASK; |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 307 | track->zb_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 308 | break; |
| 309 | case RADEON_RB3D_CNTL: |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 310 | switch ((idx_value >> RADEON_RB3D_COLOR_FORMAT_SHIFT) & 0x1f) { |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 311 | case 7: |
| 312 | case 8: |
| 313 | case 9: |
| 314 | case 11: |
| 315 | case 12: |
| 316 | track->cb[0].cpp = 1; |
| 317 | break; |
| 318 | case 3: |
| 319 | case 4: |
| 320 | case 15: |
| 321 | track->cb[0].cpp = 2; |
| 322 | break; |
| 323 | case 6: |
| 324 | track->cb[0].cpp = 4; |
| 325 | break; |
| 326 | default: |
| 327 | DRM_ERROR("Invalid color buffer format (%d) !\n", |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 328 | ((idx_value >> RADEON_RB3D_COLOR_FORMAT_SHIFT) & 0x1f)); |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 329 | return -EINVAL; |
| 330 | } |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 331 | if (idx_value & RADEON_DEPTHXY_OFFSET_ENABLE) { |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 332 | DRM_ERROR("No support for depth xy offset in kms\n"); |
| 333 | return -EINVAL; |
| 334 | } |
| 335 | |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 336 | track->z_enabled = !!(idx_value & RADEON_Z_ENABLE); |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 337 | track->cb_dirty = true; |
| 338 | track->zb_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 339 | break; |
| 340 | case RADEON_RB3D_ZSTENCILCNTL: |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 341 | switch (idx_value & 0xf) { |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 342 | case 0: |
| 343 | track->zb.cpp = 2; |
| 344 | break; |
| 345 | case 2: |
| 346 | case 3: |
| 347 | case 4: |
| 348 | case 5: |
| 349 | case 9: |
| 350 | case 11: |
| 351 | track->zb.cpp = 4; |
| 352 | break; |
| 353 | default: |
| 354 | break; |
| 355 | } |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 356 | track->zb_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 357 | break; |
| 358 | case RADEON_RB3D_ZPASS_ADDR: |
| 359 | r = r100_cs_packet_next_reloc(p, &reloc); |
| 360 | if (r) { |
| 361 | DRM_ERROR("No reloc for ib[%d]=0x%04X\n", |
| 362 | idx, reg); |
| 363 | r100_cs_dump_packet(p, pkt); |
| 364 | return r; |
| 365 | } |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 366 | ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset); |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 367 | break; |
| 368 | case RADEON_PP_CNTL: |
| 369 | { |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 370 | uint32_t temp = idx_value >> 4; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 371 | for (i = 0; i < track->num_texture; i++) |
| 372 | track->textures[i].enabled = !!(temp & (1 << i)); |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 373 | track->tex_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 374 | } |
| 375 | break; |
| 376 | case RADEON_SE_VF_CNTL: |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 377 | track->vap_vf_cntl = idx_value; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 378 | break; |
| 379 | case 0x210c: |
| 380 | /* VAP_VF_MAX_VTX_INDX */ |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 381 | track->max_indx = idx_value & 0x00FFFFFFUL; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 382 | break; |
| 383 | case R200_SE_VTX_FMT_0: |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 384 | track->vtx_size = r200_get_vtx_size_0(idx_value); |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 385 | break; |
| 386 | case R200_SE_VTX_FMT_1: |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 387 | track->vtx_size += r200_get_vtx_size_1(idx_value); |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 388 | break; |
| 389 | case R200_PP_TXSIZE_0: |
| 390 | case R200_PP_TXSIZE_1: |
| 391 | case R200_PP_TXSIZE_2: |
| 392 | case R200_PP_TXSIZE_3: |
| 393 | case R200_PP_TXSIZE_4: |
| 394 | case R200_PP_TXSIZE_5: |
| 395 | i = (reg - R200_PP_TXSIZE_0) / 32; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 396 | track->textures[i].width = (idx_value & RADEON_TEX_USIZE_MASK) + 1; |
| 397 | track->textures[i].height = ((idx_value & RADEON_TEX_VSIZE_MASK) >> RADEON_TEX_VSIZE_SHIFT) + 1; |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 398 | track->tex_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 399 | break; |
| 400 | case R200_PP_TXPITCH_0: |
| 401 | case R200_PP_TXPITCH_1: |
| 402 | case R200_PP_TXPITCH_2: |
| 403 | case R200_PP_TXPITCH_3: |
| 404 | case R200_PP_TXPITCH_4: |
| 405 | case R200_PP_TXPITCH_5: |
| 406 | i = (reg - R200_PP_TXPITCH_0) / 32; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 407 | track->textures[i].pitch = idx_value + 32; |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 408 | track->tex_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 409 | break; |
| 410 | case R200_PP_TXFILTER_0: |
| 411 | case R200_PP_TXFILTER_1: |
| 412 | case R200_PP_TXFILTER_2: |
| 413 | case R200_PP_TXFILTER_3: |
| 414 | case R200_PP_TXFILTER_4: |
| 415 | case R200_PP_TXFILTER_5: |
| 416 | i = (reg - R200_PP_TXFILTER_0) / 32; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 417 | track->textures[i].num_levels = ((idx_value & R200_MAX_MIP_LEVEL_MASK) |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 418 | >> R200_MAX_MIP_LEVEL_SHIFT); |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 419 | tmp = (idx_value >> 23) & 0x7; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 420 | if (tmp == 2 || tmp == 6) |
| 421 | track->textures[i].roundup_w = false; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 422 | tmp = (idx_value >> 27) & 0x7; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 423 | if (tmp == 2 || tmp == 6) |
| 424 | track->textures[i].roundup_h = false; |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 425 | track->tex_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 426 | break; |
| 427 | case R200_PP_TXMULTI_CTL_0: |
| 428 | case R200_PP_TXMULTI_CTL_1: |
| 429 | case R200_PP_TXMULTI_CTL_2: |
| 430 | case R200_PP_TXMULTI_CTL_3: |
| 431 | case R200_PP_TXMULTI_CTL_4: |
| 432 | case R200_PP_TXMULTI_CTL_5: |
| 433 | i = (reg - R200_PP_TXMULTI_CTL_0) / 32; |
| 434 | break; |
| 435 | case R200_PP_TXFORMAT_X_0: |
| 436 | case R200_PP_TXFORMAT_X_1: |
| 437 | case R200_PP_TXFORMAT_X_2: |
| 438 | case R200_PP_TXFORMAT_X_3: |
| 439 | case R200_PP_TXFORMAT_X_4: |
| 440 | case R200_PP_TXFORMAT_X_5: |
| 441 | i = (reg - R200_PP_TXFORMAT_X_0) / 32; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 442 | track->textures[i].txdepth = idx_value & 0x7; |
| 443 | tmp = (idx_value >> 16) & 0x3; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 444 | /* 2D, 3D, CUBE */ |
| 445 | switch (tmp) { |
| 446 | case 0: |
Roland Scheidegger | 688acaa | 2010-06-12 13:31:10 -0400 | [diff] [blame] | 447 | case 3: |
| 448 | case 4: |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 449 | case 5: |
| 450 | case 6: |
| 451 | case 7: |
Andrew Randrianasulu | f3d1ccc | 2010-01-20 11:36:30 -0500 | [diff] [blame] | 452 | /* 1D/2D */ |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 453 | track->textures[i].tex_coord_type = 0; |
| 454 | break; |
| 455 | case 1: |
Andrew Randrianasulu | f3d1ccc | 2010-01-20 11:36:30 -0500 | [diff] [blame] | 456 | /* CUBE */ |
| 457 | track->textures[i].tex_coord_type = 2; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 458 | break; |
| 459 | case 2: |
Andrew Randrianasulu | f3d1ccc | 2010-01-20 11:36:30 -0500 | [diff] [blame] | 460 | /* 3D */ |
| 461 | track->textures[i].tex_coord_type = 1; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 462 | break; |
| 463 | } |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 464 | track->tex_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 465 | break; |
| 466 | case R200_PP_TXFORMAT_0: |
| 467 | case R200_PP_TXFORMAT_1: |
| 468 | case R200_PP_TXFORMAT_2: |
| 469 | case R200_PP_TXFORMAT_3: |
| 470 | case R200_PP_TXFORMAT_4: |
| 471 | case R200_PP_TXFORMAT_5: |
| 472 | i = (reg - R200_PP_TXFORMAT_0) / 32; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 473 | if (idx_value & R200_TXFORMAT_NON_POWER2) { |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 474 | track->textures[i].use_pitch = 1; |
| 475 | } else { |
| 476 | track->textures[i].use_pitch = 0; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 477 | track->textures[i].width = 1 << ((idx_value >> RADEON_TXFORMAT_WIDTH_SHIFT) & RADEON_TXFORMAT_WIDTH_MASK); |
| 478 | track->textures[i].height = 1 << ((idx_value >> RADEON_TXFORMAT_HEIGHT_SHIFT) & RADEON_TXFORMAT_HEIGHT_MASK); |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 479 | } |
Alex Deucher | 43b93fb | 2010-10-27 01:02:35 -0400 | [diff] [blame] | 480 | if (idx_value & R200_TXFORMAT_LOOKUP_DISABLE) |
| 481 | track->textures[i].lookup_disable = true; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 482 | switch ((idx_value & RADEON_TXFORMAT_FORMAT_MASK)) { |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 483 | case R200_TXFORMAT_I8: |
| 484 | case R200_TXFORMAT_RGB332: |
| 485 | case R200_TXFORMAT_Y8: |
| 486 | track->textures[i].cpp = 1; |
Roland Scheidegger | f9da52d | 2010-06-12 12:12:37 -0400 | [diff] [blame] | 487 | track->textures[i].compress_format = R100_TRACK_COMP_NONE; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 488 | break; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 489 | case R200_TXFORMAT_AI88: |
| 490 | case R200_TXFORMAT_ARGB1555: |
| 491 | case R200_TXFORMAT_RGB565: |
| 492 | case R200_TXFORMAT_ARGB4444: |
| 493 | case R200_TXFORMAT_VYUY422: |
| 494 | case R200_TXFORMAT_YVYU422: |
| 495 | case R200_TXFORMAT_LDVDU655: |
| 496 | case R200_TXFORMAT_DVDU88: |
| 497 | case R200_TXFORMAT_AVYU4444: |
| 498 | track->textures[i].cpp = 2; |
Roland Scheidegger | f9da52d | 2010-06-12 12:12:37 -0400 | [diff] [blame] | 499 | track->textures[i].compress_format = R100_TRACK_COMP_NONE; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 500 | break; |
| 501 | case R200_TXFORMAT_ARGB8888: |
| 502 | case R200_TXFORMAT_RGBA8888: |
| 503 | case R200_TXFORMAT_ABGR8888: |
| 504 | case R200_TXFORMAT_BGR111110: |
| 505 | case R200_TXFORMAT_LDVDU8888: |
Dave Airlie | d785d78 | 2009-12-07 13:16:06 +1000 | [diff] [blame] | 506 | track->textures[i].cpp = 4; |
Roland Scheidegger | f9da52d | 2010-06-12 12:12:37 -0400 | [diff] [blame] | 507 | track->textures[i].compress_format = R100_TRACK_COMP_NONE; |
Dave Airlie | d785d78 | 2009-12-07 13:16:06 +1000 | [diff] [blame] | 508 | break; |
| 509 | case R200_TXFORMAT_DXT1: |
| 510 | track->textures[i].cpp = 1; |
| 511 | track->textures[i].compress_format = R100_TRACK_COMP_DXT1; |
| 512 | break; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 513 | case R200_TXFORMAT_DXT23: |
| 514 | case R200_TXFORMAT_DXT45: |
Dave Airlie | d785d78 | 2009-12-07 13:16:06 +1000 | [diff] [blame] | 515 | track->textures[i].cpp = 1; |
| 516 | track->textures[i].compress_format = R100_TRACK_COMP_DXT1; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 517 | break; |
| 518 | } |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 519 | track->textures[i].cube_info[4].width = 1 << ((idx_value >> 16) & 0xf); |
| 520 | track->textures[i].cube_info[4].height = 1 << ((idx_value >> 20) & 0xf); |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 521 | track->tex_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 522 | break; |
| 523 | case R200_PP_CUBIC_FACES_0: |
| 524 | case R200_PP_CUBIC_FACES_1: |
| 525 | case R200_PP_CUBIC_FACES_2: |
| 526 | case R200_PP_CUBIC_FACES_3: |
| 527 | case R200_PP_CUBIC_FACES_4: |
| 528 | case R200_PP_CUBIC_FACES_5: |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 529 | tmp = idx_value; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 530 | i = (reg - R200_PP_CUBIC_FACES_0) / 32; |
| 531 | for (face = 0; face < 4; face++) { |
| 532 | track->textures[i].cube_info[face].width = 1 << ((tmp >> (face * 8)) & 0xf); |
| 533 | track->textures[i].cube_info[face].height = 1 << ((tmp >> ((face * 8) + 4)) & 0xf); |
| 534 | } |
Marek Olšák | 40b4a75 | 2011-02-12 19:21:35 +0100 | [diff] [blame] | 535 | track->tex_dirty = true; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 536 | break; |
| 537 | default: |
| 538 | printk(KERN_ERR "Forbidden register 0x%04X in cs at %d\n", |
| 539 | reg, idx); |
| 540 | return -EINVAL; |
| 541 | } |
| 542 | return 0; |
| 543 | } |
| 544 | |
Jerome Glisse | d455090 | 2009-10-01 10:12:06 +0200 | [diff] [blame] | 545 | void r200_set_safe_registers(struct radeon_device *rdev) |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 546 | { |
| 547 | rdev->config.r100.reg_safe_bm = r200_reg_safe_bm; |
| 548 | rdev->config.r100.reg_safe_bm_size = ARRAY_SIZE(r200_reg_safe_bm); |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 549 | } |