1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com> 3bf215546Sopenharmony_ci * Copyright 2011 Marek Olšák <maraeo@gmail.com> 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 6bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 7bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 8bf215546Sopenharmony_ci * on the rights to use, copy, modify, merge, publish, distribute, sub 9bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom 10bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions: 11bf215546Sopenharmony_ci * 12bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 13bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 14bf215546Sopenharmony_ci * Software. 15bf215546Sopenharmony_ci * 16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19bf215546Sopenharmony_ci * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 20bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 21bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 22bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#include "r300_chipset.h" 25bf215546Sopenharmony_ci#include "winsys/radeon_winsys.h" 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include "util/u_debug.h" 28bf215546Sopenharmony_ci#include "util/u_memory.h" 29bf215546Sopenharmony_ci#include "os/os_process.h" 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#include <stdio.h> 32bf215546Sopenharmony_ci#include <errno.h> 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci/* r300_chipset: A file all to itself for deducing the various properties of 35bf215546Sopenharmony_ci * Radeons. */ 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_cistatic void r300_apply_hyperz_blacklist(struct r300_capabilities* caps) 38bf215546Sopenharmony_ci{ 39bf215546Sopenharmony_ci static const char *list[] = { 40bf215546Sopenharmony_ci "X", /* the DDX or indirect rendering */ 41bf215546Sopenharmony_ci "Xorg", /* (alternative name) */ 42bf215546Sopenharmony_ci "check_gl_texture_size", /* compiz */ 43bf215546Sopenharmony_ci "Compiz", 44bf215546Sopenharmony_ci "gnome-session-check-accelerated-helper", 45bf215546Sopenharmony_ci "gnome-shell", 46bf215546Sopenharmony_ci "kwin_opengl_test", 47bf215546Sopenharmony_ci "kwin", 48bf215546Sopenharmony_ci "firefox", 49bf215546Sopenharmony_ci }; 50bf215546Sopenharmony_ci int i; 51bf215546Sopenharmony_ci char proc_name[128]; 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci if (!os_get_process_name(proc_name, sizeof(proc_name))) 54bf215546Sopenharmony_ci return; 55bf215546Sopenharmony_ci 56bf215546Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(list); i++) { 57bf215546Sopenharmony_ci if (strcmp(list[i], proc_name) == 0) { 58bf215546Sopenharmony_ci caps->zmask_ram = 0; 59bf215546Sopenharmony_ci caps->hiz_ram = 0; 60bf215546Sopenharmony_ci break; 61bf215546Sopenharmony_ci } 62bf215546Sopenharmony_ci } 63bf215546Sopenharmony_ci} 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ci/* Parse a PCI ID and fill an r300_capabilities struct with information. */ 66bf215546Sopenharmony_civoid r300_parse_chipset(uint32_t pci_id, struct r300_capabilities* caps) 67bf215546Sopenharmony_ci{ 68bf215546Sopenharmony_ci switch (pci_id) { 69bf215546Sopenharmony_ci#define CHIPSET(pci_id, name, chipfamily) \ 70bf215546Sopenharmony_ci case pci_id: \ 71bf215546Sopenharmony_ci caps->family = CHIP_##chipfamily; \ 72bf215546Sopenharmony_ci break; 73bf215546Sopenharmony_ci#include "pci_ids/r300_pci_ids.h" 74bf215546Sopenharmony_ci#undef CHIPSET 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_ci default: 77bf215546Sopenharmony_ci fprintf(stderr, "r300: Warning: Unknown chipset 0x%x\nAborting...", 78bf215546Sopenharmony_ci pci_id); 79bf215546Sopenharmony_ci abort(); 80bf215546Sopenharmony_ci } 81bf215546Sopenharmony_ci 82bf215546Sopenharmony_ci /* Defaults. */ 83bf215546Sopenharmony_ci caps->high_second_pipe = FALSE; 84bf215546Sopenharmony_ci caps->num_vert_fpus = 0; 85bf215546Sopenharmony_ci caps->hiz_ram = 0; 86bf215546Sopenharmony_ci caps->zmask_ram = 0; 87bf215546Sopenharmony_ci caps->has_cmask = FALSE; 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_ci switch (caps->family) { 91bf215546Sopenharmony_ci case CHIP_R300: 92bf215546Sopenharmony_ci case CHIP_R350: 93bf215546Sopenharmony_ci caps->high_second_pipe = TRUE; 94bf215546Sopenharmony_ci caps->num_vert_fpus = 4; 95bf215546Sopenharmony_ci caps->has_cmask = TRUE; /* guessed because there is also HiZ */ 96bf215546Sopenharmony_ci caps->hiz_ram = R300_HIZ_LIMIT; 97bf215546Sopenharmony_ci caps->zmask_ram = PIPE_ZMASK_SIZE; 98bf215546Sopenharmony_ci break; 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_ci case CHIP_RV350: 101bf215546Sopenharmony_ci case CHIP_RV370: 102bf215546Sopenharmony_ci caps->high_second_pipe = TRUE; 103bf215546Sopenharmony_ci caps->num_vert_fpus = 2; 104bf215546Sopenharmony_ci caps->zmask_ram = RV3xx_ZMASK_SIZE; 105bf215546Sopenharmony_ci break; 106bf215546Sopenharmony_ci 107bf215546Sopenharmony_ci case CHIP_RV380: 108bf215546Sopenharmony_ci caps->high_second_pipe = TRUE; 109bf215546Sopenharmony_ci caps->num_vert_fpus = 2; 110bf215546Sopenharmony_ci caps->has_cmask = TRUE; /* guessed because there is also HiZ */ 111bf215546Sopenharmony_ci caps->hiz_ram = R300_HIZ_LIMIT; 112bf215546Sopenharmony_ci caps->zmask_ram = RV3xx_ZMASK_SIZE; 113bf215546Sopenharmony_ci break; 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci case CHIP_RS400: 116bf215546Sopenharmony_ci case CHIP_RS600: 117bf215546Sopenharmony_ci case CHIP_RS690: 118bf215546Sopenharmony_ci case CHIP_RS740: 119bf215546Sopenharmony_ci break; 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_ci case CHIP_RC410: 122bf215546Sopenharmony_ci case CHIP_RS480: 123bf215546Sopenharmony_ci caps->zmask_ram = RV3xx_ZMASK_SIZE; 124bf215546Sopenharmony_ci break; 125bf215546Sopenharmony_ci 126bf215546Sopenharmony_ci case CHIP_R420: 127bf215546Sopenharmony_ci case CHIP_R423: 128bf215546Sopenharmony_ci case CHIP_R430: 129bf215546Sopenharmony_ci case CHIP_R480: 130bf215546Sopenharmony_ci case CHIP_R481: 131bf215546Sopenharmony_ci case CHIP_RV410: 132bf215546Sopenharmony_ci caps->num_vert_fpus = 6; 133bf215546Sopenharmony_ci caps->has_cmask = TRUE; /* guessed because there is also HiZ */ 134bf215546Sopenharmony_ci caps->hiz_ram = R300_HIZ_LIMIT; 135bf215546Sopenharmony_ci caps->zmask_ram = PIPE_ZMASK_SIZE; 136bf215546Sopenharmony_ci break; 137bf215546Sopenharmony_ci 138bf215546Sopenharmony_ci case CHIP_R520: 139bf215546Sopenharmony_ci caps->num_vert_fpus = 8; 140bf215546Sopenharmony_ci caps->has_cmask = TRUE; 141bf215546Sopenharmony_ci caps->hiz_ram = R300_HIZ_LIMIT; 142bf215546Sopenharmony_ci caps->zmask_ram = PIPE_ZMASK_SIZE; 143bf215546Sopenharmony_ci break; 144bf215546Sopenharmony_ci 145bf215546Sopenharmony_ci case CHIP_RV515: 146bf215546Sopenharmony_ci caps->num_vert_fpus = 2; 147bf215546Sopenharmony_ci caps->has_cmask = TRUE; 148bf215546Sopenharmony_ci caps->hiz_ram = R300_HIZ_LIMIT; 149bf215546Sopenharmony_ci caps->zmask_ram = PIPE_ZMASK_SIZE; 150bf215546Sopenharmony_ci break; 151bf215546Sopenharmony_ci 152bf215546Sopenharmony_ci case CHIP_RV530: 153bf215546Sopenharmony_ci caps->num_vert_fpus = 5; 154bf215546Sopenharmony_ci caps->has_cmask = TRUE; 155bf215546Sopenharmony_ci caps->hiz_ram = RV530_HIZ_LIMIT; 156bf215546Sopenharmony_ci caps->zmask_ram = PIPE_ZMASK_SIZE; 157bf215546Sopenharmony_ci break; 158bf215546Sopenharmony_ci 159bf215546Sopenharmony_ci case CHIP_R580: 160bf215546Sopenharmony_ci case CHIP_RV560: 161bf215546Sopenharmony_ci case CHIP_RV570: 162bf215546Sopenharmony_ci caps->num_vert_fpus = 8; 163bf215546Sopenharmony_ci caps->has_cmask = TRUE; 164bf215546Sopenharmony_ci caps->hiz_ram = RV530_HIZ_LIMIT; 165bf215546Sopenharmony_ci caps->zmask_ram = PIPE_ZMASK_SIZE; 166bf215546Sopenharmony_ci break; 167bf215546Sopenharmony_ci } 168bf215546Sopenharmony_ci 169bf215546Sopenharmony_ci caps->num_tex_units = 16; 170bf215546Sopenharmony_ci caps->is_r400 = caps->family >= CHIP_R420 && caps->family < CHIP_RV515; 171bf215546Sopenharmony_ci caps->is_r500 = caps->family >= CHIP_RV515; 172bf215546Sopenharmony_ci caps->is_rv350 = caps->family >= CHIP_RV350; 173bf215546Sopenharmony_ci caps->z_compress = caps->is_rv350 ? R300_ZCOMP_8X8 : R300_ZCOMP_4X4; 174bf215546Sopenharmony_ci caps->dxtc_swizzle = caps->is_r400 || caps->is_r500; 175bf215546Sopenharmony_ci caps->has_us_format = caps->family == CHIP_R520; 176bf215546Sopenharmony_ci caps->has_tcl = caps->num_vert_fpus > 0; 177bf215546Sopenharmony_ci 178bf215546Sopenharmony_ci r300_apply_hyperz_blacklist(caps); 179bf215546Sopenharmony_ci} 180