blob: f25acec06fe875a4cece142c18eabd9eddcad6be [file] [log] [blame]
Chia-I Wu1d267e12014-08-05 12:13:22 +08001/*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2014 LunarG, Inc.
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
14 * in 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#ifndef GENHW_H
26#define GENHW_H
27
Chia-I Wu214dac62014-08-05 11:07:40 +080028#include <stdbool.h>
Chia-I Wue6073342014-11-30 09:43:42 +080029#include <stdint.h>
Chia-I Wu214dac62014-08-05 11:07:40 +080030#include <assert.h>
Chia-I Wu1d267e12014-08-05 12:13:22 +080031
32#include "gen_regs.xml.h"
33#include "gen_mi.xml.h"
34#include "gen_blitter.xml.h"
Chia-I Wue6073342014-11-30 09:43:42 +080035#include "gen_render.xml.h"
Chia-I Wu1d267e12014-08-05 12:13:22 +080036#include "gen_render_surface.xml.h"
37#include "gen_render_dynamic.xml.h"
38#include "gen_render_3d.xml.h"
Chia-I Wue6073342014-11-30 09:43:42 +080039#include "gen_render_media.xml.h"
Chia-I Wu1d267e12014-08-05 12:13:22 +080040#include "gen_eu_isa.xml.h"
41#include "gen_eu_message.xml.h"
42
Chia-I Wu426072d2014-08-26 14:31:55 +080043#define GEN_MI_CMD(gen, op) (GEN6_MI_TYPE_MI | gen ## _MI_OPCODE_ ## op)
44#define GEN6_MI_CMD(op) GEN_MI_CMD(GEN6, op)
45#define GEN7_MI_CMD(op) GEN_MI_CMD(GEN7, op)
Chia-I Wu1d267e12014-08-05 12:13:22 +080046
Chia-I Wu426072d2014-08-26 14:31:55 +080047#define GEN_BLITTER_CMD(gen, op) \
48 (GEN6_BLITTER_TYPE_BLITTER | gen ## _BLITTER_OPCODE_ ## op)
49#define GEN6_BLITTER_CMD(op) GEN_BLITTER_CMD(GEN6, op)
Chia-I Wu1d267e12014-08-05 12:13:22 +080050
Chia-I Wu426072d2014-08-26 14:31:55 +080051#define GEN_RENDER_CMD(subtype, gen, op) \
52 (GEN6_RENDER_TYPE_RENDER | \
53 GEN6_RENDER_SUBTYPE_ ## subtype | \
Chia-I Wub0b9f692014-08-21 11:33:29 +080054 gen ## _RENDER_OPCODE_ ## op)
Chia-I Wu426072d2014-08-26 14:31:55 +080055#define GEN6_RENDER_CMD(subtype, op) GEN_RENDER_CMD(subtype, GEN6, op)
56#define GEN7_RENDER_CMD(subtype, op) GEN_RENDER_CMD(subtype, GEN7, op)
57#define GEN75_RENDER_CMD(subtype, op) GEN_RENDER_CMD(subtype, GEN75, op)
Chia-I Wu97aa4de2015-03-05 15:43:16 -070058#define GEN8_RENDER_CMD(subtype, op) GEN_RENDER_CMD(subtype, GEN8, op)
Chia-I Wu1d267e12014-08-05 12:13:22 +080059
Chia-I Wue6073342014-11-30 09:43:42 +080060#define GEN_EXTRACT(bits, field) (((bits) & field ## __MASK) >> field ## __SHIFT)
61#define GEN_SHIFT32(bits, field) gen_shift32(bits, field ## __MASK, field ## __SHIFT)
62
63static inline uint32_t
64gen_shift32(uint32_t bits, uint32_t mask, int shift)
65{
66 bits <<= shift;
67
68 assert((bits & mask) == bits);
69 return bits & mask;
70}
71
Chia-I Wu1d267e12014-08-05 12:13:22 +080072static inline bool
73gen_is_snb(int devid)
74{
75 return (devid == 0x0102 || /* GT1 desktop */
76 devid == 0x0112 || /* GT2 desktop */
77 devid == 0x0122 || /* GT2_PLUS desktop */
78 devid == 0x0106 || /* GT1 mobile */
79 devid == 0x0116 || /* GT2 mobile */
80 devid == 0x0126 || /* GT2_PLUS mobile */
81 devid == 0x010a); /* GT1 server */
82}
83
84static inline int
85gen_get_snb_gt(int devid)
86{
87 assert(gen_is_snb(devid));
88 return (devid & 0x30) ? 2 : 1;
89}
90
91static inline bool
92gen_is_ivb(int devid)
93{
94 return (devid == 0x0152 || /* GT1 desktop */
95 devid == 0x0162 || /* GT2 desktop */
96 devid == 0x0156 || /* GT1 mobile */
97 devid == 0x0166 || /* GT2 mobile */
98 devid == 0x015a || /* GT1 server */
99 devid == 0x016a); /* GT2 server */
100}
101
102static inline int
103gen_get_ivb_gt(int devid)
104{
105 assert(gen_is_ivb(devid));
106 return (devid & 0x30) >> 4;
107}
108
109static inline bool
110gen_is_hsw(int devid)
111{
112 return (devid == 0x0402 || /* GT1 desktop */
113 devid == 0x0412 || /* GT2 desktop */
114 devid == 0x0422 || /* GT3 desktop */
115 devid == 0x0406 || /* GT1 mobile */
116 devid == 0x0416 || /* GT2 mobile */
117 devid == 0x0426 || /* GT2 mobile */
118 devid == 0x040a || /* GT1 server */
119 devid == 0x041a || /* GT2 server */
120 devid == 0x042a || /* GT3 server */
121 devid == 0x040b || /* GT1 reserved */
122 devid == 0x041b || /* GT2 reserved */
123 devid == 0x042b || /* GT3 reserved */
124 devid == 0x040e || /* GT1 reserved */
125 devid == 0x041e || /* GT2 reserved */
126 devid == 0x042e || /* GT3 reserved */
127 devid == 0x0c02 || /* SDV */
128 devid == 0x0c12 ||
129 devid == 0x0c22 ||
130 devid == 0x0c06 ||
131 devid == 0x0c16 ||
132 devid == 0x0c26 ||
133 devid == 0x0c0a ||
134 devid == 0x0c1a ||
135 devid == 0x0c2a ||
136 devid == 0x0c0b ||
137 devid == 0x0c1b ||
138 devid == 0x0c2b ||
139 devid == 0x0c0e ||
140 devid == 0x0c1e ||
141 devid == 0x0c2e ||
142 devid == 0x0a02 || /* ULT */
143 devid == 0x0a12 ||
144 devid == 0x0a22 ||
145 devid == 0x0a06 ||
146 devid == 0x0a16 ||
147 devid == 0x0a26 ||
148 devid == 0x0a0a ||
149 devid == 0x0a1a ||
150 devid == 0x0a2a ||
151 devid == 0x0a0b ||
152 devid == 0x0a1b ||
153 devid == 0x0a2b ||
154 devid == 0x0a0e ||
155 devid == 0x0a1e ||
156 devid == 0x0a2e ||
157 devid == 0x0d02 || /* CRW */
158 devid == 0x0d12 ||
159 devid == 0x0d22 ||
160 devid == 0x0d06 ||
161 devid == 0x0d16 ||
162 devid == 0x0d26 ||
163 devid == 0x0d0a ||
164 devid == 0x0d1a ||
165 devid == 0x0d2a ||
166 devid == 0x0d0b ||
167 devid == 0x0d1b ||
168 devid == 0x0d2b ||
169 devid == 0x0d0e ||
170 devid == 0x0d1e ||
171 devid == 0x0d2e);
172}
173
174static inline int
175gen_get_hsw_gt(int devid)
176{
177 assert(gen_is_hsw(devid));
178 return ((devid & 0x30) >> 4) + 1;
179}
180
181static inline bool
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700182gen_is_bdw(int devid)
183{
184 return (devid == 0x1602 || /* GT1 ULT */
185 devid == 0x1606 || /* GT1 ULT */
186 devid == 0x160a || /* GT1 server */
187 devid == 0x160b || /* GT1 Iris */
188 devid == 0x160d || /* GT1 workstation */
189 devid == 0x160e || /* GT1 ULX */
190 devid == 0x1612 || /* GT2 */
191 devid == 0x1616 ||
192 devid == 0x161a ||
193 devid == 0x161b ||
194 devid == 0x161d ||
195 devid == 0x161e ||
196 devid == 0x1622 || /* GT3 */
197 devid == 0x1626 ||
198 devid == 0x162a ||
199 devid == 0x162b ||
200 devid == 0x162d ||
201 devid == 0x162e);
202}
203
204static inline int
205gen_get_bdw_gt(int devid)
206{
207 assert(gen_is_bdw(devid));
208 return ((devid & 0x30) >> 4) + 1;
209}
210
211static inline bool
Chia-I Wu1d267e12014-08-05 12:13:22 +0800212gen_is_vlv(int devid)
213{
214 return (devid == 0x0f30 ||
215 devid == 0x0f31 ||
216 devid == 0x0f32 ||
217 devid == 0x0f33 ||
218 devid == 0x0157 ||
219 devid == 0x0155);
220}
221
222static inline bool
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700223gen_is_chv(int devid)
224{
225 return (devid == 0x22b0 ||
226 devid == 0x22b1 ||
227 devid == 0x22b2 ||
228 devid == 0x22b3);
229}
230
231static inline bool
Chia-I Wu1d267e12014-08-05 12:13:22 +0800232gen_is_atom(int devid)
233{
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700234 return (gen_is_vlv(devid) ||
235 gen_is_chv(devid));
Chia-I Wu1d267e12014-08-05 12:13:22 +0800236}
237
238static inline bool
239gen_is_desktop(int devid)
240{
241 assert(!gen_is_atom(devid));
242 return ((devid & 0xf) == 0x2);
243}
244
245static inline bool
246gen_is_mobile(int devid)
247{
248 assert(!gen_is_atom(devid));
249 return ((devid & 0xf) == 0x6);
250}
251
252static inline bool
253gen_is_server(int devid)
254{
255 assert(!gen_is_atom(devid));
256 return ((devid & 0xf) == 0xa);
257}
258
259#endif /* GENHW_H */