13ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse/* 23ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * Copyright 2009 Advanced Micro Devices, Inc. 33ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * 43ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * Permission is hereby granted, free of charge, to any person obtaining a 53ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * copy of this software and associated documentation files (the "Software"), 63ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * to deal in the Software without restriction, including without limitation 73ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * the rights to use, copy, modify, merge, publish, distribute, sublicense, 83ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * and/or sell copies of the Software, and to permit persons to whom the 93ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * Software is furnished to do so, subject to the following conditions: 103ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * 113ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * The above copyright notice and this permission notice (including the next 123ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * paragraph) shall be included in all copies or substantial portions of the 133ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * Software. 143ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * 153ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 163ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 173ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 183ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * THE COPYRIGHT HOLDER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 193ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 203ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 213ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * DEALINGS IN THE SOFTWARE. 223ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * 233ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * Authors: 243ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse * Alex Deucher <alexander.deucher@amd.com> 2514adc89298f894816ea2f3aef4d8d2d6ede18575Christian König * 2614adc89298f894816ea2f3aef4d8d2d6ede18575Christian König * ------------------------ This file is DEPRECATED! ------------------------- 273ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse */ 28760285e7e7ab282c25b5e90816f7c47000557f4fDavid Howells#include <drm/drmP.h> 29760285e7e7ab282c25b5e90816f7c47000557f4fDavid Howells#include <drm/radeon_drm.h> 303ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse#include "radeon_drv.h" 313ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 323ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse#include "r600_blit_shaders.h" 333ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 344f8629675800505c274bf7d17baefed197a76cd9Alex Deucher/* 23 bits of float fractional data */ 354f8629675800505c274bf7d17baefed197a76cd9Alex Deucher#define I2F_FRAC_BITS 23 364f8629675800505c274bf7d17baefed197a76cd9Alex Deucher#define I2F_MASK ((1 << I2F_FRAC_BITS) - 1) 374f8629675800505c274bf7d17baefed197a76cd9Alex Deucher 384f8629675800505c274bf7d17baefed197a76cd9Alex Deucher/* 394f8629675800505c274bf7d17baefed197a76cd9Alex Deucher * Converts unsigned integer into 32-bit IEEE floating point representation. 404f8629675800505c274bf7d17baefed197a76cd9Alex Deucher * Will be exact from 0 to 2^24. Above that, we round towards zero 414f8629675800505c274bf7d17baefed197a76cd9Alex Deucher * as the fractional bits will not fit in a float. (It would be better to 424f8629675800505c274bf7d17baefed197a76cd9Alex Deucher * round towards even as the fpu does, but that is slower.) 434f8629675800505c274bf7d17baefed197a76cd9Alex Deucher */ 444f8629675800505c274bf7d17baefed197a76cd9Alex Deucherstatic __pure uint32_t int2float(uint32_t x) 454f8629675800505c274bf7d17baefed197a76cd9Alex Deucher{ 464f8629675800505c274bf7d17baefed197a76cd9Alex Deucher uint32_t msb, exponent, fraction; 474f8629675800505c274bf7d17baefed197a76cd9Alex Deucher 484f8629675800505c274bf7d17baefed197a76cd9Alex Deucher /* Zero is special */ 494f8629675800505c274bf7d17baefed197a76cd9Alex Deucher if (!x) return 0; 504f8629675800505c274bf7d17baefed197a76cd9Alex Deucher 514f8629675800505c274bf7d17baefed197a76cd9Alex Deucher /* Get location of the most significant bit */ 524f8629675800505c274bf7d17baefed197a76cd9Alex Deucher msb = __fls(x); 534f8629675800505c274bf7d17baefed197a76cd9Alex Deucher 544f8629675800505c274bf7d17baefed197a76cd9Alex Deucher /* 554f8629675800505c274bf7d17baefed197a76cd9Alex Deucher * Use a rotate instead of a shift because that works both leftwards 564f8629675800505c274bf7d17baefed197a76cd9Alex Deucher * and rightwards due to the mod(32) behaviour. This means we don't 574f8629675800505c274bf7d17baefed197a76cd9Alex Deucher * need to check to see if we are above 2^24 or not. 584f8629675800505c274bf7d17baefed197a76cd9Alex Deucher */ 594f8629675800505c274bf7d17baefed197a76cd9Alex Deucher fraction = ror32(x, (msb - I2F_FRAC_BITS) & 0x1f) & I2F_MASK; 604f8629675800505c274bf7d17baefed197a76cd9Alex Deucher exponent = (127 + msb) << I2F_FRAC_BITS; 614f8629675800505c274bf7d17baefed197a76cd9Alex Deucher 624f8629675800505c274bf7d17baefed197a76cd9Alex Deucher return fraction + exponent; 634f8629675800505c274bf7d17baefed197a76cd9Alex Deucher} 644f8629675800505c274bf7d17baefed197a76cd9Alex Deucher 653ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse#define DI_PT_RECTLIST 0x11 663ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse#define DI_INDEX_SIZE_16_BIT 0x0 673ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse#define DI_SRC_SEL_AUTO_INDEX 0x2 683ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 693ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse#define FMT_8 0x1 703ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse#define FMT_5_6_5 0x8 713ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse#define FMT_8_8_8_8 0x1a 723ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse#define COLOR_8 0x1 733ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse#define COLOR_5_6_5 0x8 743ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse#define COLOR_8_8_8_8 0x1a 753ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7674740c8324fdcb35f7dfca89075779528ff98827Andi Kleenstatic void 773ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisseset_render_target(drm_radeon_private_t *dev_priv, int format, int w, int h, u64 gpu_addr) 783ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 793ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse u32 cb_color_info; 803ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int pitch, slice; 813ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse RING_LOCALS; 823ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse DRM_DEBUG("\n"); 833ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 84d964fc54ed06cea45dfd10832ed3d34f3ddb661bMatt Turner h = ALIGN(h, 8); 853ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (h < 8) 863ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse h = 8; 873ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 883ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cb_color_info = ((format << 2) | (1 << 27)); 893ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse pitch = (w / 8) - 1; 903ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse slice = ((w * h) / 64) - 1; 913ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 923ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_R600) && 933ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ((dev_priv->flags & RADEON_FAMILY_MASK) < CHIP_RV770)) { 943ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse BEGIN_RING(21 + 2); 953ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 963ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_CB_COLOR0_BASE - R600_SET_CONTEXT_REG_OFFSET) >> 2); 973ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(gpu_addr >> 8); 983ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SURFACE_BASE_UPDATE, 0)); 993ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(2 << 0); 1003ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } else { 1013ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse BEGIN_RING(21); 1023ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 1033ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_CB_COLOR0_BASE - R600_SET_CONTEXT_REG_OFFSET) >> 2); 1043ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(gpu_addr >> 8); 1053ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } 1063ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1073ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 1083ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_CB_COLOR0_SIZE - R600_SET_CONTEXT_REG_OFFSET) >> 2); 1093ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((pitch << 0) | (slice << 10)); 1103ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1113ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 1123ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_CB_COLOR0_VIEW - R600_SET_CONTEXT_REG_OFFSET) >> 2); 1133ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(0); 1143ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1153ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 1163ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_CB_COLOR0_INFO - R600_SET_CONTEXT_REG_OFFSET) >> 2); 1173ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(cb_color_info); 1183ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1193ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 1203ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_CB_COLOR0_TILE - R600_SET_CONTEXT_REG_OFFSET) >> 2); 1213ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(0); 1223ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1233ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 1243ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_CB_COLOR0_FRAG - R600_SET_CONTEXT_REG_OFFSET) >> 2); 1253ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(0); 1263ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1273ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 1283ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_CB_COLOR0_MASK - R600_SET_CONTEXT_REG_OFFSET) >> 2); 1293ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(0); 1303ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1313ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ADVANCE_RING(); 1323ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 1333ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 13474740c8324fdcb35f7dfca89075779528ff98827Andi Kleenstatic void 1353ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glissecp_set_surface_sync(drm_radeon_private_t *dev_priv, 1363ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse u32 sync_type, u32 size, u64 mc_addr) 1373ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 1383ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse u32 cp_coher_size; 1393ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse RING_LOCALS; 1403ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse DRM_DEBUG("\n"); 1413ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1423ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (size == 0xffffffff) 1433ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cp_coher_size = 0xffffffff; 1443ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse else 1453ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cp_coher_size = ((size + 255) >> 8); 1463ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1473ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse BEGIN_RING(5); 1483ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SURFACE_SYNC, 3)); 1493ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sync_type); 1503ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(cp_coher_size); 1513ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((mc_addr >> 8)); 1523ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(10); /* poll interval */ 1533ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ADVANCE_RING(); 1543ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 1553ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 15674740c8324fdcb35f7dfca89075779528ff98827Andi Kleenstatic void 1573ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisseset_shaders(struct drm_device *dev) 1583ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 1593ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse drm_radeon_private_t *dev_priv = dev->dev_private; 1603ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse u64 gpu_addr; 1615d93b135fc051be3740cbe55729fc7b86a7069d7Alex Deucher int i; 1623ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse u32 *vs, *ps; 1633ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse uint32_t sq_pgm_resources; 1643ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse RING_LOCALS; 1653ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse DRM_DEBUG("\n"); 1663ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1673ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* load shaders */ 1683ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse vs = (u32 *) ((char *)dev->agp_buffer_map->handle + dev_priv->blit_vb->offset); 1693ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ps = (u32 *) ((char *)dev->agp_buffer_map->handle + dev_priv->blit_vb->offset + 256); 1703ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1715d93b135fc051be3740cbe55729fc7b86a7069d7Alex Deucher for (i = 0; i < r6xx_vs_size; i++) 172dee54c40a1a9898bcd156436a1d3524f530b5a90Cédric Cano vs[i] = cpu_to_le32(r6xx_vs[i]); 1735d93b135fc051be3740cbe55729fc7b86a7069d7Alex Deucher for (i = 0; i < r6xx_ps_size; i++) 174dee54c40a1a9898bcd156436a1d3524f530b5a90Cédric Cano ps[i] = cpu_to_le32(r6xx_ps[i]); 1753ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1763ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->used = 512; 1773ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1783ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse gpu_addr = dev_priv->gart_buffers_offset + dev_priv->blit_vb->offset; 1793ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1803ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* setup shader regs */ 1813ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_pgm_resources = (1 << 0); 1823ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1833ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse BEGIN_RING(9 + 12); 1843ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* VS */ 1853ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 1863ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_SQ_PGM_START_VS - R600_SET_CONTEXT_REG_OFFSET) >> 2); 1873ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(gpu_addr >> 8); 1883ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1893ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 1903ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_SQ_PGM_RESOURCES_VS - R600_SET_CONTEXT_REG_OFFSET) >> 2); 1913ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sq_pgm_resources); 1923ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1933ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 1943ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_SQ_PGM_CF_OFFSET_VS - R600_SET_CONTEXT_REG_OFFSET) >> 2); 1953ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(0); 1963ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 1973ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* PS */ 1983ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 1993ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_SQ_PGM_START_PS - R600_SET_CONTEXT_REG_OFFSET) >> 2); 2003ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((gpu_addr + 256) >> 8); 2013ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2023ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 2033ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_SQ_PGM_RESOURCES_PS - R600_SET_CONTEXT_REG_OFFSET) >> 2); 2043ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sq_pgm_resources | (1 << 28)); 2053ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2063ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 2073ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_SQ_PGM_EXPORTS_PS - R600_SET_CONTEXT_REG_OFFSET) >> 2); 2083ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(2); 2093ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2103ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 1)); 2113ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_SQ_PGM_CF_OFFSET_PS - R600_SET_CONTEXT_REG_OFFSET) >> 2); 2123ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(0); 2133ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ADVANCE_RING(); 2143ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2153ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cp_set_surface_sync(dev_priv, 2163ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_SH_ACTION_ENA, 512, gpu_addr); 2173ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 2183ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 21974740c8324fdcb35f7dfca89075779528ff98827Andi Kleenstatic void 2203ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisseset_vtx_resource(drm_radeon_private_t *dev_priv, u64 gpu_addr) 2213ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 2223ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse uint32_t sq_vtx_constant_word2; 2233ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse RING_LOCALS; 2243ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse DRM_DEBUG("\n"); 2253ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2263ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_vtx_constant_word2 = (((gpu_addr >> 32) & 0xff) | (16 << 8)); 227dee54c40a1a9898bcd156436a1d3524f530b5a90Cédric Cano#ifdef __BIG_ENDIAN 228dee54c40a1a9898bcd156436a1d3524f530b5a90Cédric Cano sq_vtx_constant_word2 |= (2 << 30); 229dee54c40a1a9898bcd156436a1d3524f530b5a90Cédric Cano#endif 2303ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2313ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse BEGIN_RING(9); 2323ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_RESOURCE, 7)); 2333ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(0x460); 2343ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(gpu_addr & 0xffffffff); 2353ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(48 - 1); 2363ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sq_vtx_constant_word2); 2373ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(1 << 0); 2383ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(0); 2393ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(0); 2403ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(R600_SQ_TEX_VTX_VALID_BUFFER << 30); 2413ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ADVANCE_RING(); 2423ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2433ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) || 2443ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) || 2453ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780) || 2463ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS880) || 2473ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV710)) 2483ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cp_set_surface_sync(dev_priv, 2493ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_TC_ACTION_ENA, 48, gpu_addr); 2503ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse else 2513ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cp_set_surface_sync(dev_priv, 2523ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_VC_ACTION_ENA, 48, gpu_addr); 2533ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 2543ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 25574740c8324fdcb35f7dfca89075779528ff98827Andi Kleenstatic void 2563ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisseset_tex_resource(drm_radeon_private_t *dev_priv, 2573ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int format, int w, int h, int pitch, u64 gpu_addr) 2583ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 2593ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse uint32_t sq_tex_resource_word0, sq_tex_resource_word1, sq_tex_resource_word4; 2603ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse RING_LOCALS; 2613ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse DRM_DEBUG("\n"); 2623ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2633ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (h < 1) 2643ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse h = 1; 2653ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2663ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_tex_resource_word0 = (1 << 0); 2673ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_tex_resource_word0 |= ((((pitch >> 3) - 1) << 8) | 2683ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ((w - 1) << 19)); 2693ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2703ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_tex_resource_word1 = (format << 26); 2713ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_tex_resource_word1 |= ((h - 1) << 0); 2723ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2733ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_tex_resource_word4 = ((1 << 14) | 2743ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse (0 << 16) | 2753ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse (1 << 19) | 2763ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse (2 << 22) | 2773ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse (3 << 25)); 2783ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2793ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse BEGIN_RING(9); 2803ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_RESOURCE, 7)); 2813ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(0); 2823ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sq_tex_resource_word0); 2833ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sq_tex_resource_word1); 2843ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(gpu_addr >> 8); 2853ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(gpu_addr >> 8); 2863ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sq_tex_resource_word4); 2873ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(0); 2883ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(R600_SQ_TEX_VTX_VALID_TEXTURE << 30); 2893ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ADVANCE_RING(); 2903ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2913ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 2923ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 29374740c8324fdcb35f7dfca89075779528ff98827Andi Kleenstatic void 2943ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisseset_scissors(drm_radeon_private_t *dev_priv, int x1, int y1, int x2, int y2) 2953ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 2963ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse RING_LOCALS; 2973ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse DRM_DEBUG("\n"); 2983ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 2993ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse BEGIN_RING(12); 3003ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 2)); 3013ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_PA_SC_SCREEN_SCISSOR_TL - R600_SET_CONTEXT_REG_OFFSET) >> 2); 3023ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((x1 << 0) | (y1 << 16)); 3033ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((x2 << 0) | (y2 << 16)); 3043ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 3053ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 2)); 3063ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_PA_SC_GENERIC_SCISSOR_TL - R600_SET_CONTEXT_REG_OFFSET) >> 2); 3073ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((x1 << 0) | (y1 << 16) | (1 << 31)); 3083ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((x2 << 0) | (y2 << 16)); 3093ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 3103ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG, 2)); 3113ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_PA_SC_WINDOW_SCISSOR_TL - R600_SET_CONTEXT_REG_OFFSET) >> 2); 3123ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((x1 << 0) | (y1 << 16) | (1 << 31)); 3133ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((x2 << 0) | (y2 << 16)); 3143ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ADVANCE_RING(); 3153ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 3163ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 31774740c8324fdcb35f7dfca89075779528ff98827Andi Kleenstatic void 3183ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glissedraw_auto(drm_radeon_private_t *dev_priv) 3193ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 3203ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse RING_LOCALS; 3213ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse DRM_DEBUG("\n"); 3223ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 3233ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse BEGIN_RING(10); 3243ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONFIG_REG, 1)); 3253ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_VGT_PRIMITIVE_TYPE - R600_SET_CONFIG_REG_OFFSET) >> 2); 3263ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(DI_PT_RECTLIST); 3273ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 3283ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_INDEX_TYPE, 0)); 329dee54c40a1a9898bcd156436a1d3524f530b5a90Cédric Cano#ifdef __BIG_ENDIAN 330dee54c40a1a9898bcd156436a1d3524f530b5a90Cédric Cano OUT_RING((2 << 2) | DI_INDEX_SIZE_16_BIT); 331dee54c40a1a9898bcd156436a1d3524f530b5a90Cédric Cano#else 3323ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(DI_INDEX_SIZE_16_BIT); 333dee54c40a1a9898bcd156436a1d3524f530b5a90Cédric Cano#endif 3343ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 3353ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_NUM_INSTANCES, 0)); 3363ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(1); 3373ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 3383ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_DRAW_INDEX_AUTO, 1)); 3393ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(3); 3403ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(DI_SRC_SEL_AUTO_INDEX); 3413ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 3423ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ADVANCE_RING(); 3433ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse COMMIT_RING(); 3443ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 3453ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 34674740c8324fdcb35f7dfca89075779528ff98827Andi Kleenstatic void 3473ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisseset_default_state(drm_radeon_private_t *dev_priv) 3483ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 3495d93b135fc051be3740cbe55729fc7b86a7069d7Alex Deucher int i; 3503ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse u32 sq_config, sq_gpr_resource_mgmt_1, sq_gpr_resource_mgmt_2; 3513ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse u32 sq_thread_resource_mgmt, sq_stack_resource_mgmt_1, sq_stack_resource_mgmt_2; 3523ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int num_ps_gprs, num_vs_gprs, num_temp_gprs, num_gs_gprs, num_es_gprs; 3533ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int num_ps_threads, num_vs_threads, num_gs_threads, num_es_threads; 3543ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int num_ps_stack_entries, num_vs_stack_entries, num_gs_stack_entries, num_es_stack_entries; 3553ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse RING_LOCALS; 3563ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 3573ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse switch ((dev_priv->flags & RADEON_FAMILY_MASK)) { 3583ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse case CHIP_R600: 3593ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_gprs = 192; 3603ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_gprs = 56; 3613ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_temp_gprs = 4; 3623ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_gprs = 0; 3633ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_gprs = 0; 3643ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_threads = 136; 3653ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_threads = 48; 3663ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_threads = 4; 3673ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_threads = 4; 3683ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_stack_entries = 128; 3693ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_stack_entries = 128; 3703ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_stack_entries = 0; 3713ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_stack_entries = 0; 3723ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse break; 3733ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse case CHIP_RV630: 3743ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse case CHIP_RV635: 3753ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_gprs = 84; 3763ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_gprs = 36; 3773ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_temp_gprs = 4; 3783ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_gprs = 0; 3793ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_gprs = 0; 3803ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_threads = 144; 3813ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_threads = 40; 3823ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_threads = 4; 3833ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_threads = 4; 3843ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_stack_entries = 40; 3853ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_stack_entries = 40; 3863ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_stack_entries = 32; 3873ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_stack_entries = 16; 3883ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse break; 3893ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse case CHIP_RV610: 3903ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse case CHIP_RV620: 3913ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse case CHIP_RS780: 3923ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse case CHIP_RS880: 3933ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse default: 3943ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_gprs = 84; 3953ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_gprs = 36; 3963ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_temp_gprs = 4; 3973ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_gprs = 0; 3983ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_gprs = 0; 3993ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_threads = 136; 4003ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_threads = 48; 4013ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_threads = 4; 4023ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_threads = 4; 4033ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_stack_entries = 40; 4043ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_stack_entries = 40; 4053ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_stack_entries = 32; 4063ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_stack_entries = 16; 4073ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse break; 4083ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse case CHIP_RV670: 4093ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_gprs = 144; 4103ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_gprs = 40; 4113ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_temp_gprs = 4; 4123ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_gprs = 0; 4133ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_gprs = 0; 4143ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_threads = 136; 4153ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_threads = 48; 4163ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_threads = 4; 4173ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_threads = 4; 4183ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_stack_entries = 40; 4193ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_stack_entries = 40; 4203ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_stack_entries = 32; 4213ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_stack_entries = 16; 4223ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse break; 4233ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse case CHIP_RV770: 4243ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_gprs = 192; 4253ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_gprs = 56; 4263ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_temp_gprs = 4; 4273ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_gprs = 0; 4283ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_gprs = 0; 4293ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_threads = 188; 4303ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_threads = 60; 4313ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_threads = 0; 4323ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_threads = 0; 4333ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_stack_entries = 256; 4343ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_stack_entries = 256; 4353ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_stack_entries = 0; 4363ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_stack_entries = 0; 4373ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse break; 4383ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse case CHIP_RV730: 4393ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse case CHIP_RV740: 4403ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_gprs = 84; 4413ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_gprs = 36; 4423ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_temp_gprs = 4; 4433ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_gprs = 0; 4443ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_gprs = 0; 4453ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_threads = 188; 4463ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_threads = 60; 4473ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_threads = 0; 4483ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_threads = 0; 4493ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_stack_entries = 128; 4503ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_stack_entries = 128; 4513ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_stack_entries = 0; 4523ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_stack_entries = 0; 4533ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse break; 4543ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse case CHIP_RV710: 4553ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_gprs = 192; 4563ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_gprs = 56; 4573ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_temp_gprs = 4; 4583ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_gprs = 0; 4593ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_gprs = 0; 4603ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_threads = 144; 4613ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_threads = 48; 4623ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_threads = 0; 4633ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_threads = 0; 4643ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_ps_stack_entries = 128; 4653ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_vs_stack_entries = 128; 4663ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_gs_stack_entries = 0; 4673ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse num_es_stack_entries = 0; 4683ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse break; 4693ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } 4703ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 4713ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) || 4723ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) || 4733ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780) || 4743ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS880) || 4753ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV710)) 4763ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_config = 0; 4773ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse else 4783ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_config = R600_VC_ENABLE; 4793ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 4803ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_config |= (R600_DX9_CONSTS | 4813ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_ALU_INST_PREFER_VECTOR | 4823ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_PS_PRIO(0) | 4833ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_VS_PRIO(1) | 4843ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_GS_PRIO(2) | 4853ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_ES_PRIO(3)); 4863ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 4873ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_gpr_resource_mgmt_1 = (R600_NUM_PS_GPRS(num_ps_gprs) | 4883ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_NUM_VS_GPRS(num_vs_gprs) | 4893ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_NUM_CLAUSE_TEMP_GPRS(num_temp_gprs)); 4903ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_gpr_resource_mgmt_2 = (R600_NUM_GS_GPRS(num_gs_gprs) | 4913ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_NUM_ES_GPRS(num_es_gprs)); 4923ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_thread_resource_mgmt = (R600_NUM_PS_THREADS(num_ps_threads) | 4933ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_NUM_VS_THREADS(num_vs_threads) | 4943ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_NUM_GS_THREADS(num_gs_threads) | 4953ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_NUM_ES_THREADS(num_es_threads)); 4963ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_stack_resource_mgmt_1 = (R600_NUM_PS_STACK_ENTRIES(num_ps_stack_entries) | 4973ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_NUM_VS_STACK_ENTRIES(num_vs_stack_entries)); 4983ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse sq_stack_resource_mgmt_2 = (R600_NUM_GS_STACK_ENTRIES(num_gs_stack_entries) | 4993ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_NUM_ES_STACK_ENTRIES(num_es_stack_entries)); 5003ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 5013ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RV770) { 5025d93b135fc051be3740cbe55729fc7b86a7069d7Alex Deucher BEGIN_RING(r7xx_default_size + 10); 5035d93b135fc051be3740cbe55729fc7b86a7069d7Alex Deucher for (i = 0; i < r7xx_default_size; i++) 5043ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(r7xx_default_state[i]); 5053ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } else { 5065d93b135fc051be3740cbe55729fc7b86a7069d7Alex Deucher BEGIN_RING(r6xx_default_size + 10); 5075d93b135fc051be3740cbe55729fc7b86a7069d7Alex Deucher for (i = 0; i < r6xx_default_size; i++) 5083ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(r6xx_default_state[i]); 5093ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } 5103ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_EVENT_WRITE, 0)); 5113ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(R600_CACHE_FLUSH_AND_INV_EVENT); 5123ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* SQ config */ 5133ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONFIG_REG, 6)); 5143ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_SQ_CONFIG - R600_SET_CONFIG_REG_OFFSET) >> 2); 5153ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sq_config); 5163ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sq_gpr_resource_mgmt_1); 5173ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sq_gpr_resource_mgmt_2); 5183ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sq_thread_resource_mgmt); 5193ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sq_stack_resource_mgmt_1); 5203ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(sq_stack_resource_mgmt_2); 5213ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ADVANCE_RING(); 5223ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 5233ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 52474740c8324fdcb35f7dfca89075779528ff98827Andi Kleenstatic int r600_nomm_get_vb(struct drm_device *dev) 5253ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 5263ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse drm_radeon_private_t *dev_priv = dev->dev_private; 5273ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb = radeon_freelist_get(dev); 5283ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (!dev_priv->blit_vb) { 5293ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse DRM_ERROR("Unable to allocate vertex buffer for blit\n"); 5303ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse return -EAGAIN; 5313ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } 5323ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse return 0; 5333ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 5343ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 53574740c8324fdcb35f7dfca89075779528ff98827Andi Kleenstatic void r600_nomm_put_vb(struct drm_device *dev) 5363ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 5373ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse drm_radeon_private_t *dev_priv = dev->dev_private; 5383ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 5393ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->used = 0; 5403ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse radeon_cp_discard_buffer(dev, dev_priv->blit_vb->file_priv->master, dev_priv->blit_vb); 5413ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 5423ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 54374740c8324fdcb35f7dfca89075779528ff98827Andi Kleenstatic void *r600_nomm_get_vb_ptr(struct drm_device *dev) 5443ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 5453ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse drm_radeon_private_t *dev_priv = dev->dev_private; 5463ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse return (((char *)dev->agp_buffer_map->handle + 5473ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->offset + dev_priv->blit_vb->used)); 5483ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 5493ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 5503ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisseint 5513ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisser600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) 5523ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 5533ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse drm_radeon_private_t *dev_priv = dev->dev_private; 554c42750b0261274107ae85c894c088e618a3e38b9Alex Deucher int ret; 5553ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse DRM_DEBUG("\n"); 5563ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 557c42750b0261274107ae85c894c088e618a3e38b9Alex Deucher ret = r600_nomm_get_vb(dev); 558c42750b0261274107ae85c894c088e618a3e38b9Alex Deucher if (ret) 559c42750b0261274107ae85c894c088e618a3e38b9Alex Deucher return ret; 5603ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 5613ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->file_priv = file_priv; 5623ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 5633ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_default_state(dev_priv); 5643ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_shaders(dev); 5653ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 5663ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse return 0; 5673ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 5683ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 5693ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 5703ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glissevoid 5713ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisser600_done_blit_copy(struct drm_device *dev) 5723ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 5733ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse drm_radeon_private_t *dev_priv = dev->dev_private; 5743ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse RING_LOCALS; 5753ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse DRM_DEBUG("\n"); 5763ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 5773ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse BEGIN_RING(5); 5783ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_EVENT_WRITE, 0)); 5793ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(R600_CACHE_FLUSH_AND_INV_EVENT); 5803ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* wait for 3D idle clean */ 5813ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(CP_PACKET3(R600_IT_SET_CONFIG_REG, 1)); 5823ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING((R600_WAIT_UNTIL - R600_SET_CONFIG_REG_OFFSET) >> 2); 5833ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse OUT_RING(RADEON_WAIT_3D_IDLE | RADEON_WAIT_3D_IDLECLEAN); 5843ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 5853ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse ADVANCE_RING(); 5863ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse COMMIT_RING(); 5873ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 5883ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse r600_nomm_put_vb(dev); 5893ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 5903ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 5913ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glissevoid 5923ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisser600_blit_copy(struct drm_device *dev, 5933ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse uint64_t src_gpu_addr, uint64_t dst_gpu_addr, 5943ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int size_bytes) 5953ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 5963ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse drm_radeon_private_t *dev_priv = dev->dev_private; 5973ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int max_bytes; 5983ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse u64 vb_addr; 5993ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse u32 *vb; 6003ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 601ceeb50279b3d05eb7ea2b67e90acb2110d09325fDave Airlie vb = r600_nomm_get_vb_ptr(dev); 602ceeb50279b3d05eb7ea2b67e90acb2110d09325fDave Airlie 6033ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if ((size_bytes & 3) || (src_gpu_addr & 3) || (dst_gpu_addr & 3)) { 6043ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse max_bytes = 8192; 6053ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6063ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse while (size_bytes) { 6073ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int cur_size = size_bytes; 6083ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int src_x = src_gpu_addr & 255; 6093ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int dst_x = dst_gpu_addr & 255; 6103ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int h = 1; 6113ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse src_gpu_addr = src_gpu_addr & ~255; 6123ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dst_gpu_addr = dst_gpu_addr & ~255; 6133ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6143ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (!src_x && !dst_x) { 6153ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse h = (cur_size / max_bytes); 6163ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (h > 8192) 6173ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse h = 8192; 6183ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (h == 0) 6193ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse h = 1; 6203ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse else 6213ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cur_size = max_bytes; 6223ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } else { 6233ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (cur_size > max_bytes) 6243ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cur_size = max_bytes; 6253ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (cur_size > (max_bytes - dst_x)) 6263ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cur_size = (max_bytes - dst_x); 6273ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (cur_size > (max_bytes - src_x)) 6283ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cur_size = (max_bytes - src_x); 6293ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } 6303ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6313ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if ((dev_priv->blit_vb->used + 48) > dev_priv->blit_vb->total) { 6323ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6333ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse r600_nomm_put_vb(dev); 6343ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse r600_nomm_get_vb(dev); 6353ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (!dev_priv->blit_vb) 6363ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse return; 6373ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_shaders(dev); 638ceeb50279b3d05eb7ea2b67e90acb2110d09325fDave Airlie vb = r600_nomm_get_vb_ptr(dev); 6393ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } 6403ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6417ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[0] = int2float(dst_x); 6423ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse vb[1] = 0; 6437ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[2] = int2float(src_x); 6443ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse vb[3] = 0; 6453ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6467ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[4] = int2float(dst_x); 6477ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[5] = int2float(h); 6487ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[6] = int2float(src_x); 6497ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[7] = int2float(h); 6503ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6517ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[8] = int2float(dst_x + cur_size); 6527ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[9] = int2float(h); 6537ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[10] = int2float(src_x + cur_size); 6547ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[11] = int2float(h); 6553ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6563ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* src */ 6573ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_tex_resource(dev_priv, FMT_8, 6583ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse src_x + cur_size, h, src_x + cur_size, 6593ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse src_gpu_addr); 6603ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6613ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cp_set_surface_sync(dev_priv, 6623ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_TC_ACTION_ENA, (src_x + cur_size * h), src_gpu_addr); 6633ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6643ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* dst */ 6653ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_render_target(dev_priv, COLOR_8, 6663ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dst_x + cur_size, h, 6673ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dst_gpu_addr); 6683ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6693ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* scissors */ 6703ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_scissors(dev_priv, dst_x, 0, dst_x + cur_size, h); 6713ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6723ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* Vertex buffer setup */ 6733ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse vb_addr = dev_priv->gart_buffers_offset + 6743ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->offset + 6753ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->used; 6763ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_vtx_resource(dev_priv, vb_addr); 6773ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6783ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* draw */ 6793ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse draw_auto(dev_priv); 6803ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6813ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cp_set_surface_sync(dev_priv, 6823ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_CB_ACTION_ENA | R600_CB0_DEST_BASE_ENA, 6833ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cur_size * h, dst_gpu_addr); 6843ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6853ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse vb += 12; 6863ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->used += 12 * 4; 6873ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6883ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse src_gpu_addr += cur_size * h; 6893ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dst_gpu_addr += cur_size * h; 6903ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse size_bytes -= cur_size * h; 6913ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } 6923ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } else { 6933ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse max_bytes = 8192 * 4; 6943ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 6953ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse while (size_bytes) { 6963ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int cur_size = size_bytes; 6973ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int src_x = (src_gpu_addr & 255); 6983ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int dst_x = (dst_gpu_addr & 255); 6993ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int h = 1; 7003ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse src_gpu_addr = src_gpu_addr & ~255; 7013ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dst_gpu_addr = dst_gpu_addr & ~255; 7023ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7033ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (!src_x && !dst_x) { 7043ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse h = (cur_size / max_bytes); 7053ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (h > 8192) 7063ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse h = 8192; 7073ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (h == 0) 7083ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse h = 1; 7093ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse else 7103ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cur_size = max_bytes; 7113ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } else { 7123ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (cur_size > max_bytes) 7133ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cur_size = max_bytes; 7143ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (cur_size > (max_bytes - dst_x)) 7153ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cur_size = (max_bytes - dst_x); 7163ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (cur_size > (max_bytes - src_x)) 7173ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cur_size = (max_bytes - src_x); 7183ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } 7193ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7203ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if ((dev_priv->blit_vb->used + 48) > dev_priv->blit_vb->total) { 7213ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse r600_nomm_put_vb(dev); 7223ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse r600_nomm_get_vb(dev); 7233ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (!dev_priv->blit_vb) 7243ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse return; 7253ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7263ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_shaders(dev); 727ceeb50279b3d05eb7ea2b67e90acb2110d09325fDave Airlie vb = r600_nomm_get_vb_ptr(dev); 7283ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } 7293ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7307ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[0] = int2float(dst_x / 4); 7313ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse vb[1] = 0; 7327ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[2] = int2float(src_x / 4); 7333ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse vb[3] = 0; 7343ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7357ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[4] = int2float(dst_x / 4); 7367ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[5] = int2float(h); 7377ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[6] = int2float(src_x / 4); 7387ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[7] = int2float(h); 7393ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7407ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[8] = int2float((dst_x + cur_size) / 4); 7417ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[9] = int2float(h); 7427ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[10] = int2float((src_x + cur_size) / 4); 7437ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[11] = int2float(h); 7443ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7453ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* src */ 7463ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_tex_resource(dev_priv, FMT_8_8_8_8, 7473ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse (src_x + cur_size) / 4, 7483ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse h, (src_x + cur_size) / 4, 7493ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse src_gpu_addr); 7503ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7513ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cp_set_surface_sync(dev_priv, 7523ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_TC_ACTION_ENA, (src_x + cur_size * h), src_gpu_addr); 7533ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7543ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* dst */ 7553ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_render_target(dev_priv, COLOR_8_8_8_8, 7565b31aee9d72f529ee6b60e8d66967f817a0e39fcAndre Maasikas (dst_x + cur_size) / 4, h, 7573ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dst_gpu_addr); 7583ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7593ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* scissors */ 7603ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_scissors(dev_priv, (dst_x / 4), 0, (dst_x + cur_size / 4), h); 7613ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7623ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* Vertex buffer setup */ 7633ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse vb_addr = dev_priv->gart_buffers_offset + 7643ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->offset + 7653ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->used; 7663ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_vtx_resource(dev_priv, vb_addr); 7673ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7683ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* draw */ 7693ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse draw_auto(dev_priv); 7703ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7713ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cp_set_surface_sync(dev_priv, 7723ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_CB_ACTION_ENA | R600_CB0_DEST_BASE_ENA, 7733ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cur_size * h, dst_gpu_addr); 7743ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7753ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse vb += 12; 7763ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->used += 12 * 4; 7773ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7783ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse src_gpu_addr += cur_size * h; 7793ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dst_gpu_addr += cur_size * h; 7803ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse size_bytes -= cur_size * h; 7813ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } 7823ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } 7833ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 7843ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7853ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glissevoid 7863ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisser600_blit_swap(struct drm_device *dev, 7873ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse uint64_t src_gpu_addr, uint64_t dst_gpu_addr, 7883ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int sx, int sy, int dx, int dy, 7893ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int w, int h, int src_pitch, int dst_pitch, int cpp) 7903ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse{ 7913ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse drm_radeon_private_t *dev_priv = dev->dev_private; 7923ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse int cb_format, tex_format; 793c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland int sx2, sy2, dx2, dy2; 7943ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse u64 vb_addr; 7953ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse u32 *vb; 7963ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7973ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if ((dev_priv->blit_vb->used + 48) > dev_priv->blit_vb->total) { 7983ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 7993ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse r600_nomm_put_vb(dev); 8003ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse r600_nomm_get_vb(dev); 8013ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse if (!dev_priv->blit_vb) 8023ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse return; 8033ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 8043ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_shaders(dev); 8053ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse } 80633fdb15c99aac20d238af487fa363d3e5c7ed197Robert Noland vb = r600_nomm_get_vb_ptr(dev); 8073ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 808c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland sx2 = sx + w; 809c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland sy2 = sy + h; 810c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland dx2 = dx + w; 811c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland dy2 = dy + h; 8123ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 8137ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[0] = int2float(dx); 8147ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[1] = int2float(dy); 8157ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[2] = int2float(sx); 8167ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[3] = int2float(sy); 8173ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 8187ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[4] = int2float(dx); 8197ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[5] = int2float(dy2); 8207ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[6] = int2float(sx); 8217ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[7] = int2float(sy2); 8223ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 8237ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[8] = int2float(dx2); 8247ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[9] = int2float(dy2); 8257ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[10] = int2float(sx2); 8267ff64fcaa7b7ba62d12758e49643f31dd9e90eceSteven Fuerst vb[11] = int2float(sy2); 827c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland 828c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland switch(cpp) { 829c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland case 4: 830c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland cb_format = COLOR_8_8_8_8; 831c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland tex_format = FMT_8_8_8_8; 832c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland break; 833c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland case 2: 834c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland cb_format = COLOR_5_6_5; 835c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland tex_format = FMT_5_6_5; 836c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland break; 837c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland default: 838c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland cb_format = COLOR_8; 839c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland tex_format = FMT_8; 840c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland break; 841c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland } 8423ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 8433ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* src */ 8443ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_tex_resource(dev_priv, tex_format, 8453ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse src_pitch / cpp, 846c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland sy2, src_pitch / cpp, 8473ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse src_gpu_addr); 8483ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 8493ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cp_set_surface_sync(dev_priv, 850c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland R600_TC_ACTION_ENA, src_pitch * sy2, src_gpu_addr); 8513ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 8523ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* dst */ 8533ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_render_target(dev_priv, cb_format, 854c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland dst_pitch / cpp, dy2, 8553ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dst_gpu_addr); 8563ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 8573ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* scissors */ 858c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland set_scissors(dev_priv, dx, dy, dx2, dy2); 8593ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 8603ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* Vertex buffer setup */ 8613ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse vb_addr = dev_priv->gart_buffers_offset + 8623ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->offset + 8633ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->used; 8643ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse set_vtx_resource(dev_priv, vb_addr); 8653ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 8663ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse /* draw */ 8673ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse draw_auto(dev_priv); 8683ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 8693ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse cp_set_surface_sync(dev_priv, 8703ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse R600_CB_ACTION_ENA | R600_CB0_DEST_BASE_ENA, 871c54b1820d69a1043acaf50d084852e628266e0e2Robert Noland dst_pitch * dy2, dst_gpu_addr); 8723ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse 8733ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse dev_priv->blit_vb->used += 12 * 4; 8743ce0a23d2d253185df24e22e3d5f89800bb3dd1cJerome Glisse} 875