1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
|
/*
* Copyright © 2022 Imagination Technologies Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef PVR_DEVICE_INFO_H
#define PVR_DEVICE_INFO_H
/* TODO: This file is currently hand-maintained. However, the intention is to
* auto-generate it in the future based on the hwdefs.
*/
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include "util/log.h"
#include "util/macros.h"
#define PVR_BVNC_PACK_SHIFT_B 48
#define PVR_BVNC_PACK_SHIFT_V 32
#define PVR_BVNC_PACK_SHIFT_N 16
#define PVR_BVNC_PACK_SHIFT_C 0
#define PVR_BVNC_PACK_MASK_B UINT64_C(0xFFFF000000000000)
#define PVR_BVNC_PACK_MASK_V UINT64_C(0x0000FFFF00000000)
#define PVR_BVNC_PACK_MASK_N UINT64_C(0x00000000FFFF0000)
#define PVR_BVNC_PACK_MASK_C UINT64_C(0x000000000000FFFF)
/**
* Packs B, V, N and C values into a 64-bit unsigned integer.
*
* The packed layout is as follows:
*
* \verbatim
* +--------+--------+--------+-------+
* | 63..48 | 47..32 | 31..16 | 15..0 |
* +========+========+========+=======+
* | B | V | N | C |
* +--------+--------+--------+-------+
* \endverbatim
*
* #pvr_get_packed_bvnc() should be used instead of this macro when a
* #pvr_device_information is available in order to ensure proper type checking.
*
* \param b Branch ID.
* \param v Version ID.
* \param n Number of scalable units.
* \param c Config ID.
* \return Packed BVNC.
*
* \sa #pvr_get_packed_bvnc(), #PVR_BVNC_UNPACK_B(), #PVR_BVNC_UNPACK_V(),
* #PVR_BVNC_UNPACK_N() and #PVR_BVNC_UNPACK_C()
*/
#define PVR_BVNC_PACK(b, v, n, c) \
((((uint64_t)(b) << PVR_BVNC_PACK_SHIFT_B) & PVR_BVNC_PACK_MASK_B) | \
(((uint64_t)(v) << PVR_BVNC_PACK_SHIFT_V) & PVR_BVNC_PACK_MASK_V) | \
(((uint64_t)(n) << PVR_BVNC_PACK_SHIFT_N) & PVR_BVNC_PACK_MASK_N) | \
(((uint64_t)(c) << PVR_BVNC_PACK_SHIFT_C) & PVR_BVNC_PACK_MASK_C))
/**
* Unpacks B value (branch ID) from packed BVNC.
*
* \param bvnc Packed BVNC.
* \return Branch ID.
*
* \sa #PVR_BVNC_UNPACK_V(), #PVR_BVNC_UNPACK_N(), #PVR_BVNC_UNPACK_C(),
* #pvr_get_packed_bvnc() and #PVR_BVNC_PACK()
*/
#define PVR_BVNC_UNPACK_B(bvnc) \
((uint16_t)(((bvnc)&PVR_BVNC_PACK_MASK_B) >> PVR_BVNC_PACK_SHIFT_B))
/**
* Unpacks V value (version ID) from packed BVNC.
*
* \param bvnc Packed BVNC.
* \return Version ID.
*
* \sa #PVR_BVNC_UNPACK_B(), #PVR_BVNC_UNPACK_N(), #PVR_BVNC_UNPACK_C(),
* #pvr_get_packed_bvnc() and #PVR_BVNC_PACK()
*/
#define PVR_BVNC_UNPACK_V(bvnc) \
((uint16_t)(((bvnc)&PVR_BVNC_PACK_MASK_V) >> PVR_BVNC_PACK_SHIFT_V))
/**
* Unpacks N value (number of scalable units) from packed BVNC.
*
* \param bvnc Packed BVNC.
* \return Number of scalable units.
*
* \sa #PVR_BVNC_UNPACK_B(), #PVR_BVNC_UNPACK_V(), #PVR_BVNC_UNPACK_C(),
* #pvr_get_packed_bvnc() and #PVR_BVNC_PACK()
*/
#define PVR_BVNC_UNPACK_N(bvnc) \
((uint16_t)(((bvnc)&PVR_BVNC_PACK_MASK_N) >> PVR_BVNC_PACK_SHIFT_N))
/**
* Unpacks C value (config ID) from packed BVNC.
*
* \param bvnc Packed BVNC.
* \return Config ID.
*
* \sa #PVR_BVNC_UNPACK_B(), #PVR_BVNC_UNPACK_V(), #PVR_BVNC_UNPACK_N(),
* #pvr_get_packed_bvnc() and #PVR_BVNC_PACK()
*/
#define PVR_BVNC_UNPACK_C(bvnc) \
((uint16_t)(((bvnc)&PVR_BVNC_PACK_MASK_C) >> PVR_BVNC_PACK_SHIFT_C))
/**
* Tests whether a physical device has a given feature.
*
* Feature names are derived from those found in #pvr_device_features by
* dropping the 'has_' prefix, which is applied by this macro.
*
* \param dev_info #pvr_device_info object associated with the target physical
* device.
* \param feature Device feature name.
*
* \return
* * true if the named feature is present in the hardware.
* * false if the named feature is not present in the hardware.
*
* \sa #PVR_FEATURE_VALUE() and #PVR_GET_FEATURE_VALUE()
*/
#define PVR_HAS_FEATURE(dev_info, feature) ((dev_info)->features.has_##feature)
/**
* Gets a physical device feature value if feature is supported.
*
* Feature names are derived from those found in #pvr_device_features by
* dropping the 'has_' prefix.
*
* This macro should be used in preference to #PVR_GET_FEATURE_VALUE() as it has
* proper error handling.
*
* \param dev_info #pvr_device_info object associated with the target physical
* device.
* \param feature Feature name.
* \param value_out Feature value.
*
* \return
* * 0 on success, or
* * -%EINVAL if the named feature is not present in the hardware.
*
* \sa #PVR_HAS_FEATURE() and #PVR_GET_FEATURE_VALUE()
*/
#define PVR_FEATURE_VALUE(dev_info, feature, value_out) \
({ \
const struct pvr_device_info *__dev_info = dev_info; \
int __ret = -EINVAL; \
if (__dev_info->features.has_##feature) { \
*(value_out) = __dev_info->features.feature; \
__ret = 0; \
} \
__ret; \
})
/**
* Gets a physical device feature value if supported, but otherwise returns a
* default value.
*
* Feature names are derived from those found in #pvr_device_features by
* dropping the 'has_' prefix.
*
* #PVR_FEATURE_VALUE() should be used in preference to this macro when errors
* can be returned by the caller. This macro is intended for cases where errors
* can't be returned.
*
* \param dev_info #pvr_device_info object associated with the target
* physical device.
* \param feature Feature name.
* \param default_value Default feature value.
*
* \return Feature value.
*
* \sa #PVR_HAS_FEATURE() and #PVR_FEATURE_VALUE()
*/
#define PVR_GET_FEATURE_VALUE(dev_info, feature, default_value) \
({ \
const struct pvr_device_info *__dev_info = dev_info; \
__typeof__(default_value) __ret = default_value; \
if (__dev_info->features.has_##feature) { \
__ret = __dev_info->features.feature; \
} else { \
mesa_logw("Missing " #feature \
" feature (defaulting to: " #default_value ")"); \
assert(0); \
} \
__ret; \
})
/**
* Tests whether a physical device has a given enhancement.
*
* Enhancement numbers are derived from those found in #pvr_device_enhancements
* by dropping the 'has_ern' prefix, which is applied by this macro.
*
* \param dev_info #pvr_device_info object associated with the target physical
* device.
* \param number Enhancement number.
*
* \return
* * true if the enhancement is present in the hardware.
* * false if the enhancement is not present in the hardware.
*/
#define PVR_HAS_ERN(dev_info, number) ((dev_info)->enhancements.has_ern##number)
/**
* Tests whether a physical device has a given quirk.
*
* Quirk numbers are derived from those found in #pvr_device_quirks by
* dropping the 'has_brn' prefix, which is applied by this macro.
*
* \param dev_info #pvr_device_info object associated with the target physical
* device.
* \param number Quirk number.
*
* \return
* * true if the quirk is present in the hardware.
* * false if the quirk is not present in the hardware.
*/
#define PVR_HAS_QUIRK(dev_info, number) ((dev_info)->quirks.has_brn##number)
struct pvr_device_ident {
uint16_t b, v, n, c;
uint32_t device_id;
const char *series_name;
const char *public_name;
};
struct pvr_device_features {
bool has_astc : 1;
bool has_cluster_grouping : 1;
bool has_common_store_size_in_dwords : 1;
bool has_compute : 1;
bool has_compute_morton_capable : 1;
bool has_compute_overlap : 1;
bool has_eight_output_registers : 1;
bool has_gpu_multicore_support : 1;
bool has_gs_rta_support : 1;
bool has_ipf_creq_pf : 1;
bool has_isp_max_tiles_in_flight : 1;
bool has_isp_samples_per_pixel : 1;
bool has_max_instances_per_pds_task : 1;
bool has_max_multisample : 1;
bool has_max_partitions : 1;
bool has_max_usc_tasks : 1;
bool has_num_clusters : 1;
bool has_num_raster_pipes : 1;
bool has_num_user_clip_planes : 1;
bool has_paired_tiles : 1;
bool has_pbe2_in_xe : 1;
bool has_pbe_filterable_f16 : 1;
bool has_pbe_yuv : 1;
bool has_pds_ddmadt : 1;
bool has_roguexe : 1;
bool has_screen_size8K : 1;
bool has_simple_internal_parameter_format : 1;
bool has_simple_internal_parameter_format_v1 : 1;
bool has_simple_internal_parameter_format_v2 : 1;
bool has_simple_parameter_format_version : 1;
bool has_slc_cache_line_size_bits : 1;
bool has_slc_mcu_cache_controls : 1;
bool has_tf_bicubic_filter : 1;
bool has_tile_per_usc : 1;
bool has_tile_size_16x16 : 1;
bool has_tile_size_x : 1;
bool has_tile_size_y : 1;
bool has_tpu_array_textures : 1;
bool has_tpu_extended_integer_lookup : 1;
bool has_tpu_image_state_v2 : 1;
bool has_usc_f16sop_u8 : 1;
bool has_usc_min_output_registers_per_pix : 1;
bool has_usc_pixel_partition_mask : 1;
bool has_usc_slots : 1;
bool has_uvs_banks : 1;
bool has_uvs_pba_entries : 1;
bool has_uvs_vtx_entries : 1;
bool has_vdm_cam_size : 1;
bool has_vdm_degenerate_culling : 1;
bool has_xpu_max_slaves : 1;
bool has_xt_top_infrastructure : 1;
bool has_zls_subtile : 1;
uint32_t common_store_size_in_dwords;
uint32_t isp_max_tiles_in_flight;
uint32_t isp_samples_per_pixel;
uint32_t max_instances_per_pds_task;
uint32_t max_multisample;
uint32_t max_partitions;
uint32_t max_usc_tasks;
uint32_t num_clusters;
uint32_t num_raster_pipes;
uint32_t num_user_clip_planes;
uint32_t simple_parameter_format_version;
uint32_t slc_cache_line_size_bits;
uint32_t tile_size_x;
uint32_t tile_size_y;
uint32_t usc_min_output_registers_per_pix;
uint32_t usc_slots;
uint32_t uvs_banks;
uint32_t uvs_pba_entries;
uint32_t uvs_vtx_entries;
uint32_t vdm_cam_size;
uint32_t xpu_max_slaves;
/* Derived features. */
bool has_s8xe : 1;
};
struct pvr_device_enhancements {
bool has_ern35421 : 1;
bool has_ern38020 : 1;
bool has_ern38748 : 1;
bool has_ern42064 : 1;
bool has_ern42307 : 1;
bool has_ern45493 : 1;
};
struct pvr_device_quirks {
bool has_brn44079 : 1;
bool has_brn47727 : 1;
bool has_brn48492 : 1;
bool has_brn48545 : 1;
bool has_brn49032 : 1;
bool has_brn49927 : 1;
bool has_brn51025 : 1;
bool has_brn51210 : 1;
bool has_brn51764 : 1;
bool has_brn52354 : 1;
bool has_brn52942 : 1;
bool has_brn58839 : 1;
bool has_brn62269 : 1;
bool has_brn66011 : 1;
bool has_brn70165 : 1;
};
struct pvr_device_info {
struct pvr_device_ident ident;
struct pvr_device_features features;
struct pvr_device_enhancements enhancements;
struct pvr_device_quirks quirks;
};
struct pvr_device_runtime_info {
uint64_t min_free_list_size;
uint64_t max_free_list_size;
uint64_t reserved_shared_size;
uint64_t total_reserved_partition_size;
uint64_t num_phantoms;
uint64_t max_coeffs;
uint64_t cdm_max_local_mem_size_regs;
uint32_t core_count;
};
/**
* Packs B, V, N and C values into a 64-bit unsigned integer.
*
* The packed layout is as follows:
*
* \verbatim
* +--------+--------+--------+-------+
* | 63..48 | 47..32 | 31..16 | 15..0 |
* +========+========+========+=======+
* | B | V | N | C |
* +--------+--------+--------+-------+
* \endverbatim
*
* This should be used in preference to #PVR_BVNC_PACK() when a
* #pvr_device_info is available in order to ensure proper type checking.
*
* \param dev_info Device information.
* \return Packed BVNC.
*/
static ALWAYS_INLINE uint64_t
pvr_get_packed_bvnc(const struct pvr_device_info *dev_info)
{
return PVR_BVNC_PACK(dev_info->ident.b,
dev_info->ident.v,
dev_info->ident.n,
dev_info->ident.c);
}
int pvr_device_info_init(struct pvr_device_info *info, uint64_t bvnc);
#endif /* PVR_DEVICE_INFO_H */
|