1 /****************************************************************************
3 * Copyright (C) 2005 - 2013 by Vivante Corp.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the license, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *****************************************************************************/
22 #ifndef __gc_hal_driver_h_
23 #define __gc_hal_driver_h_
25 #include "gc_hal_enum.h"
26 #include "gc_hal_types.h"
29 #include "gc_hal_driver_vg.h"
36 /******************************************************************************\
37 ******************************* I/O Control Codes ******************************
38 \******************************************************************************/
40 #define gcvHAL_CLASS "galcore"
41 #define IOCTL_GCHAL_INTERFACE 30000
42 #define IOCTL_GCHAL_KERNEL_INTERFACE 30001
43 #define IOCTL_GCHAL_TERMINATE 30002
45 /******************************************************************************\
46 ********************************* Command Codes ********************************
47 \******************************************************************************/
49 typedef enum _gceHAL_COMMAND_CODES
52 gcvHAL_QUERY_VIDEO_MEMORY,
53 gcvHAL_QUERY_CHIP_IDENTITY,
55 /* Contiguous memory. */
56 gcvHAL_ALLOCATE_NON_PAGED_MEMORY,
57 gcvHAL_FREE_NON_PAGED_MEMORY,
58 gcvHAL_ALLOCATE_CONTIGUOUS_MEMORY,
59 gcvHAL_FREE_CONTIGUOUS_MEMORY,
61 /* Video memory allocation. */
62 gcvHAL_ALLOCATE_VIDEO_MEMORY, /* Enforced alignment. */
63 gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY, /* No alignment. */
64 gcvHAL_FREE_VIDEO_MEMORY,
66 /* Physical-to-logical mapping. */
70 /* Logical-to-physical mapping. */
71 gcvHAL_MAP_USER_MEMORY,
72 gcvHAL_UNMAP_USER_MEMORY,
74 /* Surface lock/unlock. */
75 gcvHAL_LOCK_VIDEO_MEMORY,
76 gcvHAL_UNLOCK_VIDEO_MEMORY,
89 gcvHAL_WRITE_REGISTER,
91 gcvHAL_GET_PROFILE_SETTING,
92 gcvHAL_SET_PROFILE_SETTING,
94 gcvHAL_READ_ALL_PROFILE_REGISTERS,
95 gcvHAL_PROFILE_REGISTERS_2D,
96 #if VIVANTE_PROFILER_PERDRAW
97 gcvHAL_READ_PROFILER_REGISTER_SETTING,
100 /* Power management. */
101 gcvHAL_SET_POWER_MANAGEMENT_STATE,
102 gcvHAL_QUERY_POWER_MANAGEMENT_STATE,
104 gcvHAL_GET_BASE_ADDRESS,
106 gcvHAL_SET_IDLE, /* reserved */
109 gcvHAL_QUERY_KERNEL_SETTINGS,
114 /* Map physical address into handle. */
117 /* Debugger stuff. */
135 /* Process attaching/detaching. */
142 /* Set timeOut value */
145 /* Frame database. */
146 gcvHAL_GET_FRAME_INFO,
148 /* Shared info for each process */
149 gcvHAL_GET_SHARED_INFO,
150 gcvHAL_SET_SHARED_INFO,
151 gcvHAL_QUERY_COMMAND_BUFFER,
155 /* GPU and event dump */
156 gcvHAL_DUMP_GPU_STATE,
159 /* Virtual command buffer. */
160 gcvHAL_ALLOCATE_VIRTUAL_COMMAND_BUFFER,
161 gcvHAL_FREE_VIRTUAL_COMMAND_BUFFER,
164 gcvHAL_SET_FSCALE_VALUE,
165 gcvHAL_GET_FSCALE_VALUE,
167 /* Reset time stamp. */
168 gcvHAL_QUERY_RESET_TIME_STAMP,
170 /* Sync point operations. */
173 /* Create native fence and return its fd. */
174 gcvHAL_CREATE_NATIVE_FENCE,
176 /* Video memory database */
177 gcvHAL_VIDMEM_DATABASE,
179 gceHAL_COMMAND_CODES;
181 /******************************************************************************\
182 ****************************** Interface Structure *****************************
183 \******************************************************************************/
185 #define gcdMAX_PROFILE_FILE_NAME 128
187 /* Kernel settings. */
188 typedef struct _gcsKERNEL_SETTINGS
190 /* Used RealTime signal between kernel and user. */
196 /* gcvHAL_QUERY_CHIP_IDENTITY */
197 typedef struct _gcsHAL_QUERY_CHIP_IDENTITY * gcsHAL_QUERY_CHIP_IDENTITY_PTR;
198 typedef struct _gcsHAL_QUERY_CHIP_IDENTITY
202 gceCHIPMODEL chipModel;
205 gctUINT32 chipRevision;
207 /* Supported feature fields. */
208 gctUINT32 chipFeatures;
210 /* Supported minor feature fields. */
211 gctUINT32 chipMinorFeatures;
213 /* Supported minor feature 1 fields. */
214 gctUINT32 chipMinorFeatures1;
216 /* Supported minor feature 2 fields. */
217 gctUINT32 chipMinorFeatures2;
219 /* Supported minor feature 3 fields. */
220 gctUINT32 chipMinorFeatures3;
222 /* Supported minor feature 4 fields. */
223 gctUINT32 chipMinorFeatures4;
225 /* Number of streams supported. */
226 gctUINT32 streamCount;
228 /* Total number of temporary registers per thread. */
229 gctUINT32 registerMax;
231 /* Maximum number of threads. */
232 gctUINT32 threadCount;
234 /* Number of shader cores. */
235 gctUINT32 shaderCoreCount;
237 /* Size of the vertex cache. */
238 gctUINT32 vertexCacheSize;
240 /* Number of entries in the vertex output buffer. */
241 gctUINT32 vertexOutputBufferSize;
243 /* Number of pixel pipes. */
244 gctUINT32 pixelPipes;
246 /* Number of instructions. */
247 gctUINT32 instructionCount;
249 /* Number of constants. */
250 gctUINT32 numConstants;
253 gctUINT32 bufferSize;
255 /* Number of varyings */
256 gctUINT32 varyingsCount;
258 /* Supertile layout style in hardware */
259 gctUINT32 superTileMode;
261 gcsHAL_QUERY_CHIP_IDENTITY;
263 /* gcvHAL_COMPOSE. */
264 typedef struct _gcsHAL_COMPOSE * gcsHAL_COMPOSE_PTR;
265 typedef struct _gcsHAL_COMPOSE
267 /* Composition state buffer. */
273 /* Composition end signal. */
278 gctUINT64 userProcess;
279 gctUINT64 userSignal1;
280 gctUINT64 userSignal2;
282 #if defined(__QNXNTO__)
283 /* Client pulse side-channel connection ID. */
293 typedef struct _gcsHAL_INTERFACE
296 gceHAL_COMMAND_CODES command;
299 gceHARDWARE_TYPE hardwareType;
304 /* Handle to this interface channel. */
307 /* Pid of the client. */
310 /* Union of command structures. */
313 /* gcvHAL_GET_BASE_ADDRESS */
314 struct _gcsHAL_GET_BASE_ADDRESS
316 /* Physical memory address of internal memory. */
317 OUT gctUINT32 baseAddress;
321 /* gcvHAL_QUERY_VIDEO_MEMORY */
322 struct _gcsHAL_QUERY_VIDEO_MEMORY
324 /* Physical memory address of internal memory. Just a name. */
325 OUT gctUINT32 internalPhysical;
327 /* Size in bytes of internal memory. */
328 OUT gctUINT64 internalSize;
330 /* Physical memory address of external memory. Just a name. */
331 OUT gctUINT32 externalPhysical;
333 /* Size in bytes of external memory.*/
334 OUT gctUINT64 externalSize;
336 /* Physical memory address of contiguous memory. Just a name. */
337 OUT gctUINT32 contiguousPhysical;
339 /* Size in bytes of contiguous memory.*/
340 OUT gctUINT64 contiguousSize;
344 /* gcvHAL_QUERY_CHIP_IDENTITY */
345 gcsHAL_QUERY_CHIP_IDENTITY QueryChipIdentity;
347 /* gcvHAL_MAP_MEMORY */
348 struct _gcsHAL_MAP_MEMORY
350 /* Physical memory address to map. Just a name on Linux/Qnx. */
351 IN gctUINT32 physical;
353 /* Number of bytes in physical memory to map. */
356 /* Address of mapped memory. */
357 OUT gctUINT64 logical;
361 /* gcvHAL_UNMAP_MEMORY */
362 struct _gcsHAL_UNMAP_MEMORY
364 /* Physical memory address to unmap. Just a name on Linux/Qnx. */
365 IN gctUINT32 physical;
367 /* Number of bytes in physical memory to unmap. */
370 /* Address of mapped memory to unmap. */
371 IN gctUINT64 logical;
375 /* gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY */
376 struct _gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY
378 /* Number of bytes to allocate. */
379 IN OUT gctUINT bytes;
381 /* Buffer alignment. */
382 IN gctUINT alignment;
384 /* Type of allocation. */
385 IN gceSURF_TYPE type;
387 /* Memory pool to allocate from. */
390 /* Allocated video memory in gcuVIDMEM_NODE. */
393 AllocateLinearVideoMemory;
395 /* gcvHAL_ALLOCATE_VIDEO_MEMORY */
396 struct _gcsHAL_ALLOCATE_VIDEO_MEMORY
398 /* Width of rectangle to allocate. */
399 IN OUT gctUINT width;
401 /* Height of rectangle to allocate. */
402 IN OUT gctUINT height;
404 /* Depth of rectangle to allocate. */
407 /* Format rectangle to allocate in gceSURF_FORMAT. */
408 IN gceSURF_FORMAT format;
410 /* Type of allocation. */
411 IN gceSURF_TYPE type;
413 /* Memory pool to allocate from. */
416 /* Allocated video memory in gcuVIDMEM_NODE. */
421 /* gcvHAL_FREE_VIDEO_MEMORY */
422 struct _gcsHAL_FREE_VIDEO_MEMORY
424 /* Allocated video memory in gcuVIDMEM_NODE. */
428 /* TODO: This is part of the unlock - why is it here? */
429 /* Mapped logical address to unmap in user space. */
430 OUT gctUINT64 memory;
432 /* Number of bytes to allocated. */
438 /* gcvHAL_LOCK_VIDEO_MEMORY */
439 struct _gcsHAL_LOCK_VIDEO_MEMORY
441 /* Allocated video memory gcuVIDMEM_NODE gcuVIDMEM_NODE. */
444 /* Cache configuration. */
445 /* Only gcvPOOL_CONTIGUOUS and gcvPOOL_VIRUTAL
446 ** can be configured */
447 IN gctBOOL cacheable;
449 /* Hardware specific address. */
450 OUT gctUINT32 address;
452 /* Mapped logical address. */
453 OUT gctUINT64 memory;
457 /* gcvHAL_UNLOCK_VIDEO_MEMORY */
458 struct _gcsHAL_UNLOCK_VIDEO_MEMORY
460 /* Allocated video memory in gcuVIDMEM_NODE. */
463 /* Type of surface. */
464 IN gceSURF_TYPE type;
466 /* Flag to unlock surface asynchroneously. */
467 IN OUT gctBOOL asynchroneous;
471 /* gcvHAL_ALLOCATE_NON_PAGED_MEMORY */
472 struct _gcsHAL_ALLOCATE_NON_PAGED_MEMORY
474 /* Number of bytes to allocate. */
475 IN OUT gctUINT64 bytes;
477 /* Physical address of allocation. Just a name. */
478 OUT gctUINT32 physical;
480 /* Logical address of allocation. */
481 OUT gctUINT64 logical;
483 AllocateNonPagedMemory;
485 /* gcvHAL_FREE_NON_PAGED_MEMORY */
486 struct _gcsHAL_FREE_NON_PAGED_MEMORY
488 /* Number of bytes allocated. */
491 /* Physical address of allocation. Just a name. */
492 IN gctUINT32 physical;
494 /* Logical address of allocation. */
495 IN gctUINT64 logical;
499 /* gcvHAL_ALLOCATE_NON_PAGED_MEMORY */
500 struct _gcsHAL_ALLOCATE_VIRTUAL_COMMAND_BUFFER
502 /* Number of bytes to allocate. */
503 IN OUT gctUINT64 bytes;
505 /* Physical address of allocation. Just a name. */
506 OUT gctUINT32 physical;
508 /* Logical address of allocation. */
509 OUT gctUINT64 logical;
511 AllocateVirtualCommandBuffer;
513 /* gcvHAL_FREE_NON_PAGED_MEMORY */
514 struct _gcsHAL_FREE_VIRTUAL_COMMAND_BUFFER
516 /* Number of bytes allocated. */
519 /* Physical address of allocation. Just a name. */
520 IN gctUINT32 physical;
522 /* Logical address of allocation. */
523 IN gctUINT64 logical;
525 FreeVirtualCommandBuffer;
527 /* gcvHAL_EVENT_COMMIT. */
528 struct _gcsHAL_EVENT_COMMIT
530 /* Event queue in gcsQUEUE. */
536 struct _gcsHAL_COMMIT
538 /* Context buffer object gckCONTEXT. */
539 IN gctUINT64 context;
541 /* Command buffer gcoCMDBUF. */
542 IN gctUINT64 commandBuffer;
544 /* State delta buffer in gcsSTATE_DELTA. */
547 /* Event queue in gcsQUEUE. */
552 /* gcvHAL_MAP_USER_MEMORY */
553 struct _gcsHAL_MAP_USER_MEMORY
555 /* Base address of user memory to map. */
558 /* Physical address of user memory to map. */
559 IN gctUINT32 physical;
561 /* Size of user memory in bytes to map. */
564 /* Info record required by gcvHAL_UNMAP_USER_MEMORY. Just a name. */
567 /* Physical address of mapped memory. */
568 OUT gctUINT32 address;
572 /* gcvHAL_UNMAP_USER_MEMORY */
573 struct _gcsHAL_UNMAP_USER_MEMORY
575 /* Base address of user memory to unmap. */
578 /* Size of user memory in bytes to unmap. */
581 /* Info record returned by gcvHAL_MAP_USER_MEMORY. Just a name. */
584 /* Physical address of mapped memory as returned by
585 gcvHAL_MAP_USER_MEMORY. */
586 IN gctUINT32 address;
589 #if !USE_NEW_LINUX_SIGNAL
590 /* gcsHAL_USER_SIGNAL */
591 struct _gcsHAL_USER_SIGNAL
594 gceUSER_SIGNAL_COMMAND_CODES command;
600 IN gctBOOL manualReset;
612 struct _gcsHAL_SIGNAL
614 /* Signal handle to signal gctSIGNAL. */
617 /* Reserved gctSIGNAL. */
618 IN gctUINT64 auxSignal;
620 /* Process owning the signal gctHANDLE. */
621 IN gctUINT64 process;
623 #if defined(__QNXNTO__)
624 /* Client pulse side-channel connection ID. Set by client in gcoOS_CreateSignal. */
630 /* Event generated from where of pipeline */
631 IN gceKERNEL_WHERE fromWhere;
635 /* gcvHAL_WRITE_DATA. */
636 struct _gcsHAL_WRITE_DATA
638 /* Address to write data to. */
639 IN gctUINT32 address;
646 /* gcvHAL_ALLOCATE_CONTIGUOUS_MEMORY */
647 struct _gcsHAL_ALLOCATE_CONTIGUOUS_MEMORY
649 /* Number of bytes to allocate. */
650 IN OUT gctUINT64 bytes;
652 /* Hardware address of allocation. */
653 OUT gctUINT32 address;
655 /* Physical address of allocation. Just a name. */
656 OUT gctUINT32 physical;
658 /* Logical address of allocation. */
659 OUT gctUINT64 logical;
661 AllocateContiguousMemory;
663 /* gcvHAL_FREE_CONTIGUOUS_MEMORY */
664 struct _gcsHAL_FREE_CONTIGUOUS_MEMORY
666 /* Number of bytes allocated. */
669 /* Physical address of allocation. Just a name. */
670 IN gctUINT32 physical;
672 /* Logical address of allocation. */
673 IN gctUINT64 logical;
675 FreeContiguousMemory;
677 /* gcvHAL_READ_REGISTER */
678 struct _gcsHAL_READ_REGISTER
680 /* Logical address of memory to write data to. */
681 IN gctUINT32 address;
688 /* gcvHAL_WRITE_REGISTER */
689 struct _gcsHAL_WRITE_REGISTER
691 /* Logical address of memory to write data to. */
692 IN gctUINT32 address;
700 /* gcvHAL_GET_PROFILE_SETTING */
701 struct _gcsHAL_GET_PROFILE_SETTING
703 /* Enable profiling */
706 /* The profile file name */
707 OUT gctCHAR fileName[gcdMAX_PROFILE_FILE_NAME];
711 /* gcvHAL_SET_PROFILE_SETTING */
712 struct _gcsHAL_SET_PROFILE_SETTING
714 /* Enable profiling */
717 /* The profile file name */
718 IN gctCHAR fileName[gcdMAX_PROFILE_FILE_NAME];
722 #if VIVANTE_PROFILER_PERDRAW
723 /* gcvHAL_READ_PROFILER_REGISTER_SETTING */
724 struct _gcsHAL_READ_PROFILER_REGISTER_SETTING
726 /*Should Clear Register*/
729 SetProfilerRegisterClear;
732 /* gcvHAL_READ_ALL_PROFILE_REGISTERS */
733 struct _gcsHAL_READ_ALL_PROFILE_REGISTERS
735 #if VIVANTE_PROFILER_CONTEXT
736 /* Context buffer object gckCONTEXT. Just a name. */
737 IN gctUINT32 context;
740 OUT gcsPROFILER_COUNTERS counters;
744 /* gcvHAL_PROFILE_REGISTERS_2D */
745 struct _gcsHAL_PROFILE_REGISTERS_2D
747 /* Data read in gcs2D_PROFILE. */
748 OUT gctUINT64 hwProfile2D;
750 RegisterProfileData2D;
752 /* Power management. */
753 /* gcvHAL_SET_POWER_MANAGEMENT_STATE */
754 struct _gcsHAL_SET_POWER_MANAGEMENT
757 IN gceCHIPPOWERSTATE state;
761 /* gcvHAL_QUERY_POWER_MANAGEMENT_STATE */
762 struct _gcsHAL_QUERY_POWER_MANAGEMENT
765 OUT gceCHIPPOWERSTATE state;
770 QueryPowerManagement;
772 /* gcvHAL_QUERY_KERNEL_SETTINGS */
773 struct _gcsHAL_QUERY_KERNEL_SETTINGS
776 OUT gcsKERNEL_SETTINGS settings;
780 /* gcvHAL_MAP_PHYSICAL */
781 struct _gcsHAL_MAP_PHYSICAL
783 /* gcvTRUE to map, gcvFALSE to unmap. */
786 /* Physical address. */
787 IN OUT gctUINT64 physical;
794 /* If gcvTRUE, set the debug information. */
800 IN gceDEBUG_MESSAGE_TYPE type;
801 IN gctUINT32 messageSize;
803 /* Message to print if not empty. */
804 IN gctCHAR message[80];
811 IN gceCACHEOPERATION operation;
813 IN gctUINT64 process;
814 IN gctUINT64 logical;
816 /* gcuVIDMEM_NODE_PTR */
821 /* gcvHAL_TIMESTAMP */
822 struct _gcsHAL_TIMESTAMP
827 /* Timer request type (0-stop, 1-start, 2-send delta). */
828 IN gctUINT32 request;
830 /* Result of delta time in microseconds. */
831 OUT gctINT32 timeDelta;
835 /* gcvHAL_DATABASE */
836 struct _gcsHAL_DATABASE
838 /* Set to gcvTRUE if you want to query a particular process ID.
839 ** Set to gcvFALSE to query the last detached process. */
840 IN gctBOOL validProcessID;
842 /* Process ID to query. */
843 IN gctUINT32 processID;
846 OUT gcuDATABASE_INFO vidMem;
847 OUT gcuDATABASE_INFO nonPaged;
848 OUT gcuDATABASE_INFO contiguous;
849 OUT gcuDATABASE_INFO gpuIdle;
853 /* gcvHAL_VIDMEM_DATABASE */
854 struct _gcsHAL_VIDMEM_DATABASE
856 /* Set to gcvTRUE if you want to query a particular process ID.
857 ** Set to gcvFALSE to query the last detached process. */
858 IN gctBOOL validProcessID;
860 /* Process ID to query. */
861 IN gctUINT32 processID;
864 OUT gcuDATABASE_INFO vidMemResv;
865 OUT gcuDATABASE_INFO vidMemCont;
866 OUT gcuDATABASE_INFO vidMemVirt;
871 struct _gcsHAL_VERSION
873 /* Major version: N.n.n. */
876 /* Minor version: n.N.n. */
879 /* Patch version: n.n.N. */
887 /* gcvHAL_CHIP_INFO */
888 struct _gcsHAL_CHIP_INFO
894 OUT gceHARDWARE_TYPE types[gcdCHIP_COUNT];
899 struct _gcsHAL_ATTACH
901 /* Context buffer object gckCONTEXT. Just a name. */
902 OUT gctUINT32 context;
904 /* Number of states in the buffer. */
905 OUT gctUINT64 stateCount;
910 struct _gcsHAL_DETACH
912 /* Context buffer object gckCONTEXT. Just a name. */
913 IN gctUINT32 context;
917 /* gcvHAL_COMPOSE. */
918 gcsHAL_COMPOSE Compose;
920 /* gcvHAL_GET_FRAME_INFO. */
921 struct _gcsHAL_GET_FRAME_INFO
923 /* gcsHAL_FRAME_INFO* */
924 OUT gctUINT64 frameInfo;
928 /* gcvHAL_SET_TIME_OUT. */
929 struct _gcsHAL_SET_TIMEOUT
937 struct _gcsHAL_VGCOMMIT
939 /* Context buffer in gcsVGCONTEXT. */
940 IN gctUINT64 context;
942 /* Command queue in gcsVGCMDQUEUE. */
945 /* Number of entries in the queue. */
946 IN gctUINT entryCount;
948 /* Task table in gcsTASK_MASTER_TABLE. */
949 IN gctUINT64 taskTable;
953 /* gcvHAL_QUERY_COMMAND_BUFFER */
954 struct _gcsHAL_QUERY_COMMAND_BUFFER
956 /* Command buffer attributes. */
957 OUT gcsCOMMAND_BUFFER_INFO information;
963 struct _gcsHAL_GET_SHARED_INFO
974 /* Pointer to save the shared data. */
979 struct _gcsHAL_SET_SHARED_INFO
984 /* Data to be shared. */
992 struct _gcsHAL_SET_FSCALE_VALUE
998 struct _gcsHAL_GET_FSCALE_VALUE
1001 OUT gctUINT minValue;
1002 OUT gctUINT maxValue;
1006 struct _gcsHAL_QUERY_RESET_TIME_STAMP
1008 OUT gctUINT64 timeStamp;
1010 QueryResetTimeStamp;
1012 struct _gcsHAL_SYNC_POINT
1015 gceSYNC_POINT_COMMAND_CODES command;
1018 IN OUT gctUINT64 syncPoint;
1021 IN gceKERNEL_WHERE fromWhere;
1023 /* Signaled state. */
1028 struct _gcsHAL_CREATE_NATIVE_FENCE
1030 /* Signal id to dup. */
1031 IN gctUINT64 syncPoint;
1033 /* Native fence file descriptor. */
1048 #endif /* __gc_hal_driver_h_ */