OSDN Git Service

d43895edf81cdc927264f695c7b0d2ed4851be76
[android-x86/external-libdrm.git] / include / drm / amdgpu_drm.h
1 /* amdgpu_drm.h -- Public header for the amdgpu driver -*- linux-c -*-
2  *
3  * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
4  * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
5  * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
6  * Copyright 2014 Advanced Micro Devices, Inc.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
22  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24  * OTHER DEALINGS IN THE SOFTWARE.
25  *
26  * Authors:
27  *    Kevin E. Martin <martin@valinux.com>
28  *    Gareth Hughes <gareth@valinux.com>
29  *    Keith Whitwell <keith@tungstengraphics.com>
30  */
31
32 #ifndef __AMDGPU_DRM_H__
33 #define __AMDGPU_DRM_H__
34
35 #include "drm.h"
36
37 #define DRM_AMDGPU_GEM_CREATE           0x00
38 #define DRM_AMDGPU_GEM_MMAP             0x01
39 #define DRM_AMDGPU_CTX                  0x02
40 #define DRM_AMDGPU_BO_LIST              0x03
41 #define DRM_AMDGPU_CS                   0x04
42 #define DRM_AMDGPU_INFO                 0x05
43 #define DRM_AMDGPU_GEM_METADATA         0x06
44 #define DRM_AMDGPU_GEM_WAIT_IDLE        0x07
45 #define DRM_AMDGPU_GEM_VA               0x08
46 #define DRM_AMDGPU_WAIT_CS              0x09
47 #define DRM_AMDGPU_GEM_OP               0x10
48 #define DRM_AMDGPU_GEM_USERPTR          0x11
49
50 #define DRM_IOCTL_AMDGPU_GEM_CREATE     DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
51 #define DRM_IOCTL_AMDGPU_GEM_MMAP       DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
52 #define DRM_IOCTL_AMDGPU_CTX            DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
53 #define DRM_IOCTL_AMDGPU_BO_LIST        DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
54 #define DRM_IOCTL_AMDGPU_CS             DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
55 #define DRM_IOCTL_AMDGPU_INFO           DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
56 #define DRM_IOCTL_AMDGPU_GEM_METADATA   DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
57 #define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE  DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
58 #define DRM_IOCTL_AMDGPU_GEM_VA         DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
59 #define DRM_IOCTL_AMDGPU_WAIT_CS        DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
60 #define DRM_IOCTL_AMDGPU_GEM_OP         DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
61 #define DRM_IOCTL_AMDGPU_GEM_USERPTR    DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
62
63 #define AMDGPU_GEM_DOMAIN_CPU           0x1
64 #define AMDGPU_GEM_DOMAIN_GTT           0x2
65 #define AMDGPU_GEM_DOMAIN_VRAM          0x4
66 #define AMDGPU_GEM_DOMAIN_GDS           0x8
67 #define AMDGPU_GEM_DOMAIN_GWS           0x10
68 #define AMDGPU_GEM_DOMAIN_OA            0x20
69
70 /* Flag that CPU access will be required for the case of VRAM domain */
71 #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED   (1 << 0)
72 /* Flag that CPU access will not work, this VRAM domain is invisible */
73 #define AMDGPU_GEM_CREATE_NO_CPU_ACCESS         (1 << 1)
74 /* Flag that USWC attributes should be used for GTT */
75 #define AMDGPU_GEM_CREATE_CPU_GTT_USWC          (1 << 2)
76 /* Flag that the memory should be in VRAM and cleared */
77 #define AMDGPU_GEM_CREATE_VRAM_CLEARED          (1 << 3)
78
79 struct drm_amdgpu_gem_create_in  {
80         /** the requested memory size */
81         uint64_t bo_size;
82         /** physical start_addr alignment in bytes for some HW requirements */
83         uint64_t alignment;
84         /** the requested memory domains */
85         uint64_t domains;
86         /** allocation flags */
87         uint64_t domain_flags;
88 };
89
90 struct drm_amdgpu_gem_create_out  {
91         /** returned GEM object handle */
92         uint32_t handle;
93         uint32_t _pad;
94 };
95
96 union drm_amdgpu_gem_create {
97         struct drm_amdgpu_gem_create_in         in;
98         struct drm_amdgpu_gem_create_out        out;
99 };
100
101 /** Opcode to create new residency list.  */
102 #define AMDGPU_BO_LIST_OP_CREATE        0
103 /** Opcode to destroy previously created residency list */
104 #define AMDGPU_BO_LIST_OP_DESTROY       1
105 /** Opcode to update resource information in the list */
106 #define AMDGPU_BO_LIST_OP_UPDATE        2
107
108 struct drm_amdgpu_bo_list_in {
109         /** Type of operation */
110         uint32_t operation;
111         /** Handle of list or 0 if we want to create one */
112         uint32_t list_handle;
113         /** Number of BOs in list  */
114         uint32_t bo_number;
115         /** Size of each element describing BO */
116         uint32_t bo_info_size;
117         /** Pointer to array describing BOs */
118         uint64_t bo_info_ptr;
119 };
120
121 struct drm_amdgpu_bo_list_entry {
122         /** Handle of BO */
123         uint32_t bo_handle;
124         /** New (if specified) BO priority to be used during migration */
125         uint32_t bo_priority;
126 };
127
128 struct drm_amdgpu_bo_list_out {
129         /** Handle of resource list  */
130         uint32_t list_handle;
131         uint32_t _pad;
132 };
133
134 union drm_amdgpu_bo_list {
135         struct drm_amdgpu_bo_list_in in;
136         struct drm_amdgpu_bo_list_out out;
137 };
138
139 /* context related */
140 #define AMDGPU_CTX_OP_ALLOC_CTX 1
141 #define AMDGPU_CTX_OP_FREE_CTX  2
142 #define AMDGPU_CTX_OP_QUERY_STATE       3
143
144 /* GPU reset status */
145 #define AMDGPU_CTX_NO_RESET             0
146 /* this the context caused it */
147 #define AMDGPU_CTX_GUILTY_RESET         1
148 /* some other context caused it */
149 #define AMDGPU_CTX_INNOCENT_RESET       2
150 /* unknown cause */
151 #define AMDGPU_CTX_UNKNOWN_RESET        3
152
153 struct drm_amdgpu_ctx_in {
154         /** AMDGPU_CTX_OP_* */
155         uint32_t        op;
156         /** For future use, no flags defined so far */
157         uint32_t        flags;
158         uint32_t        ctx_id;
159         uint32_t        _pad;
160 };
161
162 union drm_amdgpu_ctx_out {
163                 struct {
164                         uint32_t        ctx_id;
165                         uint32_t        _pad;
166                 } alloc;
167
168                 struct {
169                         /** For future use, no flags defined so far */
170                         uint64_t        flags;
171                         /** Number of resets caused by this context so far. */
172                         uint32_t        hangs;
173                         /** Reset status since the last call of the ioctl. */
174                         uint32_t        reset_status;
175                 } state;
176 };
177
178 union drm_amdgpu_ctx {
179         struct drm_amdgpu_ctx_in in;
180         union drm_amdgpu_ctx_out out;
181 };
182
183 /*
184  * This is not a reliable API and you should expect it to fail for any
185  * number of reasons and have fallback path that do not use userptr to
186  * perform any operation.
187  */
188 #define AMDGPU_GEM_USERPTR_READONLY     (1 << 0)
189 #define AMDGPU_GEM_USERPTR_ANONONLY     (1 << 1)
190 #define AMDGPU_GEM_USERPTR_VALIDATE     (1 << 2)
191 #define AMDGPU_GEM_USERPTR_REGISTER     (1 << 3)
192
193 struct drm_amdgpu_gem_userptr {
194         uint64_t                addr;
195         uint64_t                size;
196         /* AMDGPU_GEM_USERPTR_* */
197         uint32_t                flags;
198         /* Resulting GEM handle */
199         uint32_t                handle;
200 };
201
202 /* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
203 #define AMDGPU_TILING_ARRAY_MODE_SHIFT                  0
204 #define AMDGPU_TILING_ARRAY_MODE_MASK                   0xf
205 #define AMDGPU_TILING_PIPE_CONFIG_SHIFT                 4
206 #define AMDGPU_TILING_PIPE_CONFIG_MASK                  0x1f
207 #define AMDGPU_TILING_TILE_SPLIT_SHIFT                  9
208 #define AMDGPU_TILING_TILE_SPLIT_MASK                   0x7
209 #define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT             12
210 #define AMDGPU_TILING_MICRO_TILE_MODE_MASK              0x7
211 #define AMDGPU_TILING_BANK_WIDTH_SHIFT                  15
212 #define AMDGPU_TILING_BANK_WIDTH_MASK                   0x3
213 #define AMDGPU_TILING_BANK_HEIGHT_SHIFT                 17
214 #define AMDGPU_TILING_BANK_HEIGHT_MASK                  0x3
215 #define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT           19
216 #define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK            0x3
217 #define AMDGPU_TILING_NUM_BANKS_SHIFT                   21
218 #define AMDGPU_TILING_NUM_BANKS_MASK                    0x3
219
220 #define AMDGPU_TILING_SET(field, value) \
221         (((value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
222 #define AMDGPU_TILING_GET(value, field) \
223         (((value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
224
225 #define AMDGPU_GEM_METADATA_OP_SET_METADATA                  1
226 #define AMDGPU_GEM_METADATA_OP_GET_METADATA                  2
227
228 /** The same structure is shared for input/output */
229 struct drm_amdgpu_gem_metadata {
230         /** GEM Object handle */
231         uint32_t        handle;
232         /** Do we want get or set metadata */
233         uint32_t        op;
234         struct {
235                 /** For future use, no flags defined so far */
236                 uint64_t        flags;
237                 /** family specific tiling info */
238                 uint64_t        tiling_info;
239                 uint32_t        data_size_bytes;
240                 uint32_t        data[64];
241         } data;
242 };
243
244 struct drm_amdgpu_gem_mmap_in {
245         /** the GEM object handle */
246         uint32_t handle;
247         uint32_t _pad;
248 };
249
250 struct drm_amdgpu_gem_mmap_out {
251         /** mmap offset from the vma offset manager */
252         uint64_t addr_ptr;
253 };
254
255 union drm_amdgpu_gem_mmap {
256         struct drm_amdgpu_gem_mmap_in   in;
257         struct drm_amdgpu_gem_mmap_out out;
258 };
259
260 struct drm_amdgpu_gem_wait_idle_in {
261         /** GEM object handle */
262         uint32_t handle;
263         /** For future use, no flags defined so far */
264         uint32_t flags;
265         /** Absolute timeout to wait */
266         uint64_t timeout;
267 };
268
269 struct drm_amdgpu_gem_wait_idle_out {
270         /** BO status:  0 - BO is idle, 1 - BO is busy */
271         uint32_t status;
272         /** Returned current memory domain */
273         uint32_t domain;
274 };
275
276 union drm_amdgpu_gem_wait_idle {
277         struct drm_amdgpu_gem_wait_idle_in  in;
278         struct drm_amdgpu_gem_wait_idle_out out;
279 };
280
281 struct drm_amdgpu_wait_cs_in {
282         /** Command submission handle */
283         uint64_t handle;
284         /** Absolute timeout to wait */
285         uint64_t timeout;
286         uint32_t ip_type;
287         uint32_t ip_instance;
288         uint32_t ring;
289         uint32_t ctx_id;
290 };
291
292 struct drm_amdgpu_wait_cs_out {
293         /** CS status:  0 - CS completed, 1 - CS still busy */
294         uint64_t status;
295 };
296
297 union drm_amdgpu_wait_cs {
298         struct drm_amdgpu_wait_cs_in in;
299         struct drm_amdgpu_wait_cs_out out;
300 };
301
302 #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO       0
303 #define AMDGPU_GEM_OP_SET_PLACEMENT             1
304
305 /* Sets or returns a value associated with a buffer. */
306 struct drm_amdgpu_gem_op {
307         /** GEM object handle */
308         uint32_t        handle;
309         /** AMDGPU_GEM_OP_* */
310         uint32_t        op;
311         /** Input or return value */
312         uint64_t        value;
313 };
314
315 #define AMDGPU_VA_OP_MAP                        1
316 #define AMDGPU_VA_OP_UNMAP                      2
317
318 /* Delay the page table update till the next CS */
319 #define AMDGPU_VM_DELAY_UPDATE          (1 << 0)
320
321 /* Mapping flags */
322 /* readable mapping */
323 #define AMDGPU_VM_PAGE_READABLE         (1 << 1)
324 /* writable mapping */
325 #define AMDGPU_VM_PAGE_WRITEABLE        (1 << 2)
326 /* executable mapping, new for VI */
327 #define AMDGPU_VM_PAGE_EXECUTABLE       (1 << 3)
328
329 struct drm_amdgpu_gem_va {
330         /** GEM object handle */
331         uint32_t handle;
332         uint32_t _pad;
333         /** AMDGPU_VA_OP_* */
334         uint32_t operation;
335         /** AMDGPU_VM_PAGE_* */
336         uint32_t flags;
337         /** va address to assign . Must be correctly aligned.*/
338         uint64_t va_address;
339         /** Specify offset inside of BO to assign. Must be correctly aligned.*/
340         uint64_t offset_in_bo;
341         /** Specify mapping size. Must be correctly aligned. */
342         uint64_t map_size;
343 };
344
345 #define AMDGPU_HW_IP_GFX          0
346 #define AMDGPU_HW_IP_COMPUTE      1
347 #define AMDGPU_HW_IP_DMA          2
348 #define AMDGPU_HW_IP_UVD          3
349 #define AMDGPU_HW_IP_VCE          4
350 #define AMDGPU_HW_IP_NUM          5
351
352 #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
353
354 #define AMDGPU_CHUNK_ID_IB              0x01
355 #define AMDGPU_CHUNK_ID_FENCE           0x02
356 #define AMDGPU_CHUNK_ID_DEPENDENCIES    0x03
357
358 struct drm_amdgpu_cs_chunk {
359         uint32_t                chunk_id;
360         uint32_t                length_dw;
361         uint64_t                chunk_data;
362 };
363
364 struct drm_amdgpu_cs_in {
365         /** Rendering context id */
366         uint32_t                ctx_id;
367         /**  Handle of resource list associated with CS */
368         uint32_t                bo_list_handle;
369         uint32_t                num_chunks;
370         uint32_t                _pad;
371         /** this points to uint64_t * which point to cs chunks */
372         uint64_t                chunks;
373 };
374
375 struct drm_amdgpu_cs_out {
376         uint64_t handle;
377 };
378
379 union drm_amdgpu_cs {
380         struct drm_amdgpu_cs_in in;
381         struct drm_amdgpu_cs_out out;
382 };
383
384 /* Specify flags to be used for IB */
385
386 /* This IB should be submitted to CE */
387 #define AMDGPU_IB_FLAG_CE       (1<<0)
388
389 /* CE Preamble */
390 #define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
391
392 struct drm_amdgpu_cs_chunk_ib {
393         uint32_t _pad;
394         /** AMDGPU_IB_FLAG_* */
395         uint32_t flags;
396         /** Virtual address to begin IB execution */
397         uint64_t va_start;
398         /** Size of submission */
399         uint32_t ib_bytes;
400         /** HW IP to submit to */
401         uint32_t ip_type;
402         /** HW IP index of the same type to submit to  */
403         uint32_t ip_instance;
404         /** Ring index to submit to */
405         uint32_t ring;
406 };
407
408 struct drm_amdgpu_cs_chunk_dep {
409         uint32_t ip_type;
410         uint32_t ip_instance;
411         uint32_t ring;
412         uint32_t ctx_id;
413         uint64_t handle;
414 };
415
416 struct drm_amdgpu_cs_chunk_fence {
417         uint32_t handle;
418         uint32_t offset;
419 };
420
421 struct drm_amdgpu_cs_chunk_data {
422         union {
423                 struct drm_amdgpu_cs_chunk_ib           ib_data;
424                 struct drm_amdgpu_cs_chunk_fence        fence_data;
425         };
426 };
427
428 /**
429  *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
430  *
431  */
432 #define AMDGPU_IDS_FLAGS_FUSION         0x1
433
434 /* indicate if acceleration can be working */
435 #define AMDGPU_INFO_ACCEL_WORKING               0x00
436 /* get the crtc_id from the mode object id? */
437 #define AMDGPU_INFO_CRTC_FROM_ID                0x01
438 /* query hw IP info */
439 #define AMDGPU_INFO_HW_IP_INFO                  0x02
440 /* query hw IP instance count for the specified type */
441 #define AMDGPU_INFO_HW_IP_COUNT                 0x03
442 /* timestamp for GL_ARB_timer_query */
443 #define AMDGPU_INFO_TIMESTAMP                   0x05
444 /* Query the firmware version */
445 #define AMDGPU_INFO_FW_VERSION                  0x0e
446         /* Subquery id: Query VCE firmware version */
447         #define AMDGPU_INFO_FW_VCE              0x1
448         /* Subquery id: Query UVD firmware version */
449         #define AMDGPU_INFO_FW_UVD              0x2
450         /* Subquery id: Query GMC firmware version */
451         #define AMDGPU_INFO_FW_GMC              0x03
452         /* Subquery id: Query GFX ME firmware version */
453         #define AMDGPU_INFO_FW_GFX_ME           0x04
454         /* Subquery id: Query GFX PFP firmware version */
455         #define AMDGPU_INFO_FW_GFX_PFP          0x05
456         /* Subquery id: Query GFX CE firmware version */
457         #define AMDGPU_INFO_FW_GFX_CE           0x06
458         /* Subquery id: Query GFX RLC firmware version */
459         #define AMDGPU_INFO_FW_GFX_RLC          0x07
460         /* Subquery id: Query GFX MEC firmware version */
461         #define AMDGPU_INFO_FW_GFX_MEC          0x08
462         /* Subquery id: Query SMC firmware version */
463         #define AMDGPU_INFO_FW_SMC              0x0a
464         /* Subquery id: Query SDMA firmware version */
465         #define AMDGPU_INFO_FW_SDMA             0x0b
466 /* number of bytes moved for TTM migration */
467 #define AMDGPU_INFO_NUM_BYTES_MOVED             0x0f
468 /* the used VRAM size */
469 #define AMDGPU_INFO_VRAM_USAGE                  0x10
470 /* the used GTT size */
471 #define AMDGPU_INFO_GTT_USAGE                   0x11
472 /* Information about GDS, etc. resource configuration */
473 #define AMDGPU_INFO_GDS_CONFIG                  0x13
474 /* Query information about VRAM and GTT domains */
475 #define AMDGPU_INFO_VRAM_GTT                    0x14
476 /* Query information about register in MMR address space*/
477 #define AMDGPU_INFO_READ_MMR_REG                0x15
478 /* Query information about device: rev id, family, etc. */
479 #define AMDGPU_INFO_DEV_INFO                    0x16
480 /* visible vram usage */
481 #define AMDGPU_INFO_VIS_VRAM_USAGE              0x17
482
483 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT  0
484 #define AMDGPU_INFO_MMR_SE_INDEX_MASK   0xff
485 #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT  8
486 #define AMDGPU_INFO_MMR_SH_INDEX_MASK   0xff
487
488 /* Input structure for the INFO ioctl */
489 struct drm_amdgpu_info {
490         /* Where the return value will be stored */
491         uint64_t return_pointer;
492         /* The size of the return value. Just like "size" in "snprintf",
493          * it limits how many bytes the kernel can write. */
494         uint32_t return_size;
495         /* The query request id. */
496         uint32_t query;
497
498         union {
499                 struct {
500                         uint32_t id;
501                         uint32_t _pad;
502                 } mode_crtc;
503
504                 struct {
505                         /** AMDGPU_HW_IP_* */
506                         uint32_t type;
507                         /**
508                          * Index of the IP if there are more IPs of the same
509                          * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
510                          */
511                         uint32_t ip_instance;
512                 } query_hw_ip;
513
514                 struct {
515                         uint32_t dword_offset;
516                         /** number of registers to read */
517                         uint32_t count;
518                         uint32_t instance;
519                         /** For future use, no flags defined so far */
520                         uint32_t flags;
521                 } read_mmr_reg;
522
523                 struct {
524                         /** AMDGPU_INFO_FW_* */
525                         uint32_t fw_type;
526                         /**
527                          * Index of the IP if there are more IPs of
528                          * the same type.
529                          */
530                         uint32_t ip_instance;
531                         /**
532                          * Index of the engine. Whether this is used depends
533                          * on the firmware type. (e.g. MEC, SDMA)
534                          */
535                         uint32_t index;
536                         uint32_t _pad;
537                 } query_fw;
538         };
539 };
540
541 struct drm_amdgpu_info_gds {
542         /** GDS GFX partition size */
543         uint32_t gds_gfx_partition_size;
544         /** GDS compute partition size */
545         uint32_t compute_partition_size;
546         /** total GDS memory size */
547         uint32_t gds_total_size;
548         /** GWS size per GFX partition */
549         uint32_t gws_per_gfx_partition;
550         /** GSW size per compute partition */
551         uint32_t gws_per_compute_partition;
552         /** OA size per GFX partition */
553         uint32_t oa_per_gfx_partition;
554         /** OA size per compute partition */
555         uint32_t oa_per_compute_partition;
556         uint32_t _pad;
557 };
558
559 struct drm_amdgpu_info_vram_gtt {
560         uint64_t vram_size;
561         uint64_t vram_cpu_accessible_size;
562         uint64_t gtt_size;
563 };
564
565 struct drm_amdgpu_info_firmware {
566         uint32_t ver;
567         uint32_t feature;
568 };
569
570 #define AMDGPU_VRAM_TYPE_UNKNOWN 0
571 #define AMDGPU_VRAM_TYPE_GDDR1 1
572 #define AMDGPU_VRAM_TYPE_DDR2  2
573 #define AMDGPU_VRAM_TYPE_GDDR3 3
574 #define AMDGPU_VRAM_TYPE_GDDR4 4
575 #define AMDGPU_VRAM_TYPE_GDDR5 5
576 #define AMDGPU_VRAM_TYPE_HBM   6
577 #define AMDGPU_VRAM_TYPE_DDR3  7
578
579 struct drm_amdgpu_info_device {
580         /** PCI Device ID */
581         uint32_t device_id;
582         /** Internal chip revision: A0, A1, etc.) */
583         uint32_t chip_rev;
584         uint32_t external_rev;
585         /** Revision id in PCI Config space */
586         uint32_t pci_rev;
587         uint32_t family;
588         uint32_t num_shader_engines;
589         uint32_t num_shader_arrays_per_engine;
590         /* in KHz */
591         uint32_t gpu_counter_freq;
592         uint64_t max_engine_clock;
593         uint64_t max_memory_clock;
594         /* cu information */
595         uint32_t cu_active_number;
596         uint32_t cu_ao_mask;
597         uint32_t cu_bitmap[4][4];
598         /** Render backend pipe mask. One render backend is CB+DB. */
599         uint32_t enabled_rb_pipes_mask;
600         uint32_t num_rb_pipes;
601         uint32_t num_hw_gfx_contexts;
602         uint32_t _pad;
603         uint64_t ids_flags;
604         /** Starting virtual address for UMDs. */
605         uint64_t virtual_address_offset;
606         /** The maximum virtual address */
607         uint64_t virtual_address_max;
608         /** Required alignment of virtual addresses. */
609         uint32_t virtual_address_alignment;
610         /** Page table entry - fragment size */
611         uint32_t pte_fragment_size;
612         uint32_t gart_page_size;
613         /** constant engine ram size*/
614         uint32_t ce_ram_size;
615         /** video memory type info*/
616         uint32_t vram_type;
617         /** video memory bit width*/
618         uint32_t vram_bit_width;
619         /* vce harvesting instance */
620         uint32_t vce_harvest_config;
621 };
622
623 struct drm_amdgpu_info_hw_ip {
624         /** Version of h/w IP */
625         uint32_t  hw_ip_version_major;
626         uint32_t  hw_ip_version_minor;
627         /** Capabilities */
628         uint64_t  capabilities_flags;
629         /** command buffer address start alignment*/
630         uint32_t  ib_start_alignment;
631         /** command buffer size alignment*/
632         uint32_t  ib_size_alignment;
633         /** Bitmask of available rings. Bit 0 means ring 0, etc. */
634         uint32_t  available_rings;
635         uint32_t  _pad;
636 };
637
638 /*
639  * Supported GPU families
640  */
641 #define AMDGPU_FAMILY_UNKNOWN                   0
642 #define AMDGPU_FAMILY_CI                        120 /* Bonaire, Hawaii */
643 #define AMDGPU_FAMILY_KV                        125 /* Kaveri, Kabini, Mullins */
644 #define AMDGPU_FAMILY_VI                        130 /* Iceland, Tonga */
645 #define AMDGPU_FAMILY_CZ                        135 /* Carrizo */
646
647 #endif