17ec681f3Smrg/* 27ec681f3Smrg * Copyright (C) 2019 Collabora, Ltd. 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 207ec681f3Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 217ec681f3Smrg * SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#ifndef __MDG_QUIRKS_H 257ec681f3Smrg#define __MDG_QUIRKS_H 267ec681f3Smrg 277ec681f3Smrg/* Model-specific quirks requiring compiler workarounds/etc. Quirks 287ec681f3Smrg * may be errata requiring a workaround, or features. We're trying to be 297ec681f3Smrg * quirk-positive here; quirky is the best! */ 307ec681f3Smrg 317ec681f3Smrg/* bit 0 unused */ 327ec681f3Smrg 337ec681f3Smrg/* Whether output texture registers (normally r28/r29) overlap with work 347ec681f3Smrg * registers r0/r1 and input texture registers (also normally r28/r29) overlap 357ec681f3Smrg * with load/store registers r26/r27. This constrains register allocation 367ec681f3Smrg * considerably but is a space-saving measure on small Midgards. It's worth 377ec681f3Smrg * noting if you try to access r28/r29, it may still work, but you'll mess up 387ec681f3Smrg * the interference. Corresponds to BASE_HW_FEATURE_INTERPIPE_REG_ALIASING in 397ec681f3Smrg * kbase. */ 407ec681f3Smrg 417ec681f3Smrg#define MIDGARD_INTERPIPE_REG_ALIASING (1 << 1) 427ec681f3Smrg 437ec681f3Smrg/* Whether we should use old-style blend opcodes */ 447ec681f3Smrg 457ec681f3Smrg#define MIDGARD_OLD_BLEND (1 << 2) 467ec681f3Smrg 477ec681f3Smrg/* Errata causing the LOD clamps and bias in the sampler descriptor to be 487ec681f3Smrg * ignored. This errata affects the command stream but uses a compiler 497ec681f3Smrg * workaround (applying the clamps/bias manually in the shader. Corresponds in 507ec681f3Smrg * BASE_HW_ISSUE_10471 in kbase, described as "TEXGRD doesn't honor Sampler 517ec681f3Smrg * Descriptor LOD clamps nor bias". (I'm assuming TEXGRD is what we call 527ec681f3Smrg * textureLod) */ 537ec681f3Smrg 547ec681f3Smrg#define MIDGARD_BROKEN_LOD (1 << 3) 557ec681f3Smrg 567ec681f3Smrg/* Don't use upper ALU tags for writeout (if you do, you'll get a 577ec681f3Smrg * INSTR_INVALID_ENC). It's not clear to me what these tags are for. */ 587ec681f3Smrg 597ec681f3Smrg#define MIDGARD_NO_UPPER_ALU (1 << 4) 607ec681f3Smrg 617ec681f3Smrg/* Whether (texture) out-of-order execution support is missing on early 627ec681f3Smrg * Midgards. For these just set the OoO bits to 0. */ 637ec681f3Smrg 647ec681f3Smrg#define MIDGARD_NO_OOO (1 << 5) 657ec681f3Smrg 667ec681f3Smrgstatic inline unsigned 677ec681f3Smrgmidgard_get_quirks(unsigned gpu_id) 687ec681f3Smrg{ 697ec681f3Smrg switch (gpu_id) { 707ec681f3Smrg case 0x600: 717ec681f3Smrg case 0x620: 727ec681f3Smrg return MIDGARD_OLD_BLEND | 737ec681f3Smrg MIDGARD_BROKEN_LOD | 747ec681f3Smrg MIDGARD_NO_UPPER_ALU | 757ec681f3Smrg MIDGARD_NO_OOO; 767ec681f3Smrg 777ec681f3Smrg case 0x720: 787ec681f3Smrg return MIDGARD_INTERPIPE_REG_ALIASING | 797ec681f3Smrg MIDGARD_OLD_BLEND | 807ec681f3Smrg MIDGARD_BROKEN_LOD | 817ec681f3Smrg MIDGARD_NO_UPPER_ALU | 827ec681f3Smrg MIDGARD_NO_OOO; 837ec681f3Smrg 847ec681f3Smrg case 0x820: 857ec681f3Smrg case 0x830: 867ec681f3Smrg return MIDGARD_INTERPIPE_REG_ALIASING; 877ec681f3Smrg 887ec681f3Smrg case 0x750: 897ec681f3Smrg return MIDGARD_NO_UPPER_ALU; 907ec681f3Smrg 917ec681f3Smrg case 0x860: 927ec681f3Smrg case 0x880: 937ec681f3Smrg return 0; 947ec681f3Smrg 957ec681f3Smrg default: 967ec681f3Smrg unreachable("Invalid Midgard GPU ID"); 977ec681f3Smrg } 987ec681f3Smrg} 997ec681f3Smrg 1007ec681f3Smrg#endif 101