1 /****************************************************************************
3 * Copyright (C) 2005 - 2011 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 *****************************************************************************/
24 #ifndef __gc_hal_driver_h_
25 #define __gc_hal_driver_h_
27 #include "gc_hal_enum.h"
28 #include "gc_hal_types.h"
31 #include "gc_hal_driver_vg.h"
38 /******************************************************************************\
39 ******************************* I/O Control Codes ******************************
40 \******************************************************************************/
42 #define gcvHAL_CLASS "galcore"
43 #define IOCTL_GCHAL_INTERFACE 30000
44 #define IOCTL_GCHAL_KERNEL_INTERFACE 30001
45 #define IOCTL_GCHAL_TERMINATE 30002
47 /******************************************************************************\
48 ********************************* Command Codes ********************************
49 \******************************************************************************/
51 typedef enum _gceHAL_COMMAND_CODES
54 gcvHAL_QUERY_VIDEO_MEMORY
,
55 gcvHAL_QUERY_CHIP_IDENTITY
,
57 /* Contiguous memory. */
58 gcvHAL_ALLOCATE_NON_PAGED_MEMORY
,
59 gcvHAL_FREE_NON_PAGED_MEMORY
,
60 gcvHAL_ALLOCATE_CONTIGUOUS_MEMORY
,
61 gcvHAL_FREE_CONTIGUOUS_MEMORY
,
63 /* Video memory allocation. */
64 gcvHAL_ALLOCATE_VIDEO_MEMORY
, /* Enforced alignment. */
65 gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY
, /* No alignment. */
66 gcvHAL_FREE_VIDEO_MEMORY
,
68 /* Physical-to-logical mapping. */
72 /* Logical-to-physical mapping. */
73 gcvHAL_MAP_USER_MEMORY
,
74 gcvHAL_UNMAP_USER_MEMORY
,
76 /* Surface lock/unlock. */
77 gcvHAL_LOCK_VIDEO_MEMORY
,
78 gcvHAL_UNLOCK_VIDEO_MEMORY
,
91 gcvHAL_WRITE_REGISTER
,
93 gcvHAL_GET_PROFILE_SETTING
,
94 gcvHAL_SET_PROFILE_SETTING
,
96 gcvHAL_READ_ALL_PROFILE_REGISTERS
,
97 gcvHAL_PROFILE_REGISTERS_2D
,
99 /* Power management. */
100 gcvHAL_SET_POWER_MANAGEMENT_STATE
,
101 gcvHAL_QUERY_POWER_MANAGEMENT_STATE
,
103 gcvHAL_GET_BASE_ADDRESS
,
105 gcvHAL_SET_IDLE
, /* reserved */
108 gcvHAL_QUERY_KERNEL_SETTINGS
,
113 /* Map physical address into handle. */
116 /* Debugger stuff. */
134 /* Process attaching/detaching. */
141 /* Set timeOut value */
144 /* Frame database. */
145 gcvHAL_GET_FRAME_INFO
,
147 #if gcdENABLE_SHARED_INFO
148 /* Shared info for each process */
149 gcvHAL_GET_SHARED_INFO
,
150 gcvHAL_SET_SHARED_INFO
,
152 gcvHAL_QUERY_COMMAND_BUFFER
154 gceHAL_COMMAND_CODES
;
156 /******************************************************************************\
157 ****************************** Interface Structure *****************************
158 \******************************************************************************/
160 #define gcdMAX_PROFILE_FILE_NAME 128
162 /* Kernel settings. */
163 typedef struct _gcsKERNEL_SETTINGS
165 /* Used RealTime signal between kernel and user. */
170 /* gcvHAL_COMPOSE. */
171 typedef struct _gcsHAL_COMPOSE
* gcsHAL_COMPOSE_PTR
;
172 typedef struct _gcsHAL_COMPOSE
174 /* Composition state buffer. */
176 IN gctPHYS_ADDR physical
;
177 IN gctPOINTER logical
;
179 /* Composition end signal. */
180 IN gctHANDLE process
;
184 IN gctHANDLE userProcess
;
185 IN gctSIGNAL userSignal1
;
186 IN gctSIGNAL userSignal2
;
188 #if defined(__QNXNTO__)
189 /* Client pulse side-channel connection ID. */
198 typedef struct _gcsHAL_INTERFACE
201 gceHAL_COMMAND_CODES command
;
204 gceHARDWARE_TYPE hardwareType
;
209 /* Handle to this interface channel. */
212 /* Pid of the client. */
215 /* Union of command structures. */
218 /* gcvHAL_GET_BASE_ADDRESS */
219 struct _gcsHAL_GET_BASE_ADDRESS
221 /* Physical memory address of internal memory. */
222 OUT gctUINT32 baseAddress
;
226 /* gcvHAL_QUERY_VIDEO_MEMORY */
227 struct _gcsHAL_QUERY_VIDEO_MEMORY
229 /* Physical memory address of internal memory. */
230 OUT gctPHYS_ADDR internalPhysical
;
232 /* Size in bytes of internal memory.*/
233 OUT gctSIZE_T internalSize
;
235 /* Physical memory address of external memory. */
236 OUT gctPHYS_ADDR externalPhysical
;
238 /* Size in bytes of external memory.*/
239 OUT gctSIZE_T externalSize
;
241 /* Physical memory address of contiguous memory. */
242 OUT gctPHYS_ADDR contiguousPhysical
;
244 /* Size in bytes of contiguous memory.*/
245 OUT gctSIZE_T contiguousSize
;
249 /* gcvHAL_QUERY_CHIP_IDENTITY */
250 struct _gcsHAL_QUERY_CHIP_IDENTITY
254 OUT gceCHIPMODEL chipModel
;
257 OUT gctUINT32 chipRevision
;
259 /* Supported feature fields. */
260 OUT gctUINT32 chipFeatures
;
262 /* Supported minor feature fields. */
263 OUT gctUINT32 chipMinorFeatures
;
265 /* Supported minor feature 1 fields. */
266 OUT gctUINT32 chipMinorFeatures1
;
268 /* Supported minor feature 2 fields. */
269 OUT gctUINT32 chipMinorFeatures2
;
271 /* Supported minor feature 3 fields. */
272 OUT gctUINT32 chipMinorFeatures3
;
274 /* Number of streams supported. */
275 OUT gctUINT32 streamCount
;
277 /* Total number of temporary registers per thread. */
278 OUT gctUINT32 registerMax
;
280 /* Maximum number of threads. */
281 OUT gctUINT32 threadCount
;
283 /* Number of shader cores. */
284 OUT gctUINT32 shaderCoreCount
;
286 /* Size of the vertex cache. */
287 OUT gctUINT32 vertexCacheSize
;
289 /* Number of entries in the vertex output buffer. */
290 OUT gctUINT32 vertexOutputBufferSize
;
292 /* Number of pixel pipes. */
293 OUT gctUINT32 pixelPipes
;
295 /* Number of instructions. */
296 OUT gctUINT32 instructionCount
;
298 /* Number of constants. */
299 OUT gctUINT32 numConstants
;
302 OUT gctUINT32 bufferSize
;
307 /* gcvHAL_MAP_MEMORY */
308 struct _gcsHAL_MAP_MEMORY
310 /* Physical memory address to map. */
311 IN gctPHYS_ADDR physical
;
313 /* Number of bytes in physical memory to map. */
316 /* Address of mapped memory. */
317 OUT gctPOINTER logical
;
321 /* gcvHAL_UNMAP_MEMORY */
322 struct _gcsHAL_UNMAP_MEMORY
324 /* Physical memory address to unmap. */
325 IN gctPHYS_ADDR physical
;
327 /* Number of bytes in physical memory to unmap. */
330 /* Address of mapped memory to unmap. */
331 IN gctPOINTER logical
;
335 /* gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY */
336 struct _gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY
338 /* Number of bytes to allocate. */
339 IN OUT gctUINT bytes
;
341 /* Buffer alignment. */
342 IN gctUINT alignment
;
344 /* Type of allocation. */
345 IN gceSURF_TYPE type
;
347 /* Memory pool to allocate from. */
350 /* Allocated video memory. */
351 OUT gcuVIDMEM_NODE_PTR node
;
353 AllocateLinearVideoMemory
;
355 /* gcvHAL_ALLOCATE_VIDEO_MEMORY */
356 struct _gcsHAL_ALLOCATE_VIDEO_MEMORY
358 /* Width of rectangle to allocate. */
359 IN OUT gctUINT width
;
361 /* Height of rectangle to allocate. */
362 IN OUT gctUINT height
;
364 /* Depth of rectangle to allocate. */
367 /* Format rectangle to allocate in gceSURF_FORMAT. */
368 IN gceSURF_FORMAT format
;
370 /* Type of allocation. */
371 IN gceSURF_TYPE type
;
373 /* Memory pool to allocate from. */
376 /* Allocated video memory. */
377 OUT gcuVIDMEM_NODE_PTR node
;
381 /* gcvHAL_FREE_VIDEO_MEMORY */
382 struct _gcsHAL_FREE_VIDEO_MEMORY
384 /* Allocated video memory. */
385 IN gcuVIDMEM_NODE_PTR node
;
388 /* TODO: This is part of the unlock - why is it here? */
389 /* Mapped logical address to unmap in user space. */
390 OUT gctPOINTER memory
;
392 /* Number of bytes to allocated. */
398 /* gcvHAL_LOCK_VIDEO_MEMORY */
399 struct _gcsHAL_LOCK_VIDEO_MEMORY
401 /* Allocated video memory. */
402 IN gcuVIDMEM_NODE_PTR node
;
404 /* Cache configuration. */
405 /* Only gcvPOOL_CONTIGUOUS and gcvPOOL_VIRUTAL
406 ** can be configured */
407 IN gctBOOL cacheable
;
409 /* Hardware specific address. */
410 OUT gctUINT32 address
;
412 /* Mapped logical address. */
413 OUT gctPOINTER memory
;
417 /* gcvHAL_UNLOCK_VIDEO_MEMORY */
418 struct _gcsHAL_UNLOCK_VIDEO_MEMORY
420 /* Allocated video memory. */
421 IN gcuVIDMEM_NODE_PTR node
;
423 /* Type of surface. */
424 IN gceSURF_TYPE type
;
426 /* Flag to unlock surface asynchroneously. */
427 IN OUT gctBOOL asynchroneous
;
431 /* gcvHAL_ALLOCATE_NON_PAGED_MEMORY */
432 struct _gcsHAL_ALLOCATE_NON_PAGED_MEMORY
434 /* Number of bytes to allocate. */
435 IN OUT gctSIZE_T bytes
;
437 /* Physical address of allocation. */
438 OUT gctPHYS_ADDR physical
;
440 /* Logical address of allocation. */
441 OUT gctPOINTER logical
;
443 AllocateNonPagedMemory
;
445 /* gcvHAL_FREE_NON_PAGED_MEMORY */
446 struct _gcsHAL_FREE_NON_PAGED_MEMORY
448 /* Number of bytes allocated. */
451 /* Physical address of allocation. */
452 IN gctPHYS_ADDR physical
;
454 /* Logical address of allocation. */
455 IN gctPOINTER logical
;
459 /* gcvHAL_EVENT_COMMIT. */
460 struct _gcsHAL_EVENT_COMMIT
463 IN gcsQUEUE_PTR queue
;
468 struct _gcsHAL_COMMIT
470 /* Context buffer object. */
471 IN gckCONTEXT context
;
473 /* Command buffer. */
474 IN gcoCMDBUF commandBuffer
;
476 /* State delta buffer. */
477 gcsSTATE_DELTA_PTR delta
;
480 IN gcsQUEUE_PTR queue
;
484 /* gcvHAL_MAP_USER_MEMORY */
485 struct _gcsHAL_MAP_USER_MEMORY
487 /* Base address of user memory to map. */
488 IN gctPOINTER memory
;
490 /* Size of user memory in bytes to map. */
493 /* Info record required by gcvHAL_UNMAP_USER_MEMORY. */
496 /* Physical address of mapped memory. */
497 OUT gctUINT32 address
;
501 /* gcvHAL_UNMAP_USER_MEMORY */
502 struct _gcsHAL_UNMAP_USER_MEMORY
504 /* Base address of user memory to unmap. */
505 IN gctPOINTER memory
;
507 /* Size of user memory in bytes to unmap. */
510 /* Info record returned by gcvHAL_MAP_USER_MEMORY. */
513 /* Physical address of mapped memory as returned by
514 gcvHAL_MAP_USER_MEMORY. */
515 IN gctUINT32 address
;
518 #if !USE_NEW_LINUX_SIGNAL
519 /* gcsHAL_USER_SIGNAL */
520 struct _gcsHAL_USER_SIGNAL
523 gceUSER_SIGNAL_COMMAND_CODES command
;
529 IN gctBOOL manualReset
;
541 struct _gcsHAL_SIGNAL
543 /* Signal handle to signal. */
547 IN gctSIGNAL auxSignal
;
549 /* Process owning the signal. */
550 IN gctHANDLE process
;
552 #if defined(__QNXNTO__)
553 /* Client pulse side-channel connection ID. Set by client in gcoOS_CreateSignal. */
559 /* Event generated from where of pipeline */
560 IN gceKERNEL_WHERE fromWhere
;
564 /* gcvHAL_WRITE_DATA. */
565 struct _gcsHAL_WRITE_DATA
567 /* Address to write data to. */
568 IN gctUINT32 address
;
575 /* gcvHAL_ALLOCATE_CONTIGUOUS_MEMORY */
576 struct _gcsHAL_ALLOCATE_CONTIGUOUS_MEMORY
578 /* Number of bytes to allocate. */
579 IN OUT gctSIZE_T bytes
;
581 /* Hardware address of allocation. */
582 OUT gctUINT32 address
;
584 /* Physical address of allocation. */
585 OUT gctPHYS_ADDR physical
;
587 /* Logical address of allocation. */
588 OUT gctPOINTER logical
;
590 AllocateContiguousMemory
;
592 /* gcvHAL_FREE_CONTIGUOUS_MEMORY */
593 struct _gcsHAL_FREE_CONTIGUOUS_MEMORY
595 /* Number of bytes allocated. */
598 /* Physical address of allocation. */
599 IN gctPHYS_ADDR physical
;
601 /* Logical address of allocation. */
602 IN gctPOINTER logical
;
604 FreeContiguousMemory
;
606 /* gcvHAL_READ_REGISTER */
607 struct _gcsHAL_READ_REGISTER
609 /* Logical address of memory to write data to. */
610 IN gctUINT32 address
;
617 /* gcvHAL_WRITE_REGISTER */
618 struct _gcsHAL_WRITE_REGISTER
620 /* Logical address of memory to write data to. */
621 IN gctUINT32 address
;
629 /* gcvHAL_GET_PROFILE_SETTING */
630 struct _gcsHAL_GET_PROFILE_SETTING
632 /* Enable profiling */
635 /* The profile file name */
636 OUT gctCHAR fileName
[gcdMAX_PROFILE_FILE_NAME
];
640 /* gcvHAL_SET_PROFILE_SETTING */
641 struct _gcsHAL_SET_PROFILE_SETTING
643 /* Enable profiling */
646 /* The profile file name */
647 IN gctCHAR fileName
[gcdMAX_PROFILE_FILE_NAME
];
651 /* gcvHAL_READ_ALL_PROFILE_REGISTERS */
652 struct _gcsHAL_READ_ALL_PROFILE_REGISTERS
655 OUT gcsPROFILER_COUNTERS counters
;
659 /* gcvHAL_PROFILE_REGISTERS_2D */
660 struct _gcsHAL_PROFILE_REGISTERS_2D
663 OUT gcs2D_PROFILE_PTR hwProfile2D
;
665 RegisterProfileData2D
;
667 /* Power management. */
668 /* gcvHAL_SET_POWER_MANAGEMENT_STATE */
669 struct _gcsHAL_SET_POWER_MANAGEMENT
672 IN gceCHIPPOWERSTATE state
;
676 /* gcvHAL_QUERY_POWER_MANAGEMENT_STATE */
677 struct _gcsHAL_QUERY_POWER_MANAGEMENT
680 OUT gceCHIPPOWERSTATE state
;
685 QueryPowerManagement
;
687 /* gcvHAL_QUERY_KERNEL_SETTINGS */
688 struct _gcsHAL_QUERY_KERNEL_SETTINGS
691 OUT gcsKERNEL_SETTINGS settings
;
695 /* gcvHAL_MAP_PHYSICAL */
696 struct _gcsHAL_MAP_PHYSICAL
698 /* gcvTRUE to map, gcvFALSE to unmap. */
701 /* Physical address. */
702 IN OUT gctPHYS_ADDR physical
;
709 /* If gcvTRUE, set the debug information. */
715 IN gceDEBUG_MESSAGE_TYPE type
;
716 IN gctUINT32 messageSize
;
718 /* Message to print if not empty. */
719 IN gctCHAR message
[80];
726 IN gceCACHEOPERATION operation
;
727 IN gctHANDLE process
;
728 IN gctPOINTER logical
;
730 IN gcuVIDMEM_NODE_PTR node
;
734 /* gcvHAL_TIMESTAMP */
735 struct _gcsHAL_TIMESTAMP
740 /* Timer request type (0-stop, 1-start, 2-send delta). */
741 IN gctUINT32 request
;
743 /* Result of delta time in microseconds. */
744 OUT gctINT32 timeDelta
;
748 /* gcvHAL_DATABASE */
749 struct _gcsHAL_DATABASE
751 /* Set to gcvTRUE if you want to query a particular process ID.
752 ** Set to gcvFALSE to query the last detached process. */
753 IN gctBOOL validProcessID
;
755 /* Process ID to query. */
756 IN gctUINT32 processID
;
759 OUT gcuDATABASE_INFO vidMem
;
760 OUT gcuDATABASE_INFO nonPaged
;
761 OUT gcuDATABASE_INFO contiguous
;
762 OUT gcuDATABASE_INFO gpuIdle
;
767 struct _gcsHAL_VERSION
769 /* Major version: N.n.n. */
772 /* Minor version: n.N.n. */
775 /* Patch version: n.n.N. */
783 /* gcvHAL_CHIP_INFO */
784 struct _gcsHAL_CHIP_INFO
790 OUT gceHARDWARE_TYPE types
[gcdCHIP_COUNT
];
795 struct _gcsHAL_ATTACH
797 /* Context buffer object. */
798 OUT gckCONTEXT context
;
800 /* Number of states in the buffer. */
801 OUT gctSIZE_T stateCount
;
806 struct _gcsHAL_DETACH
808 /* Context buffer object. */
809 IN gckCONTEXT context
;
813 /* gcvHAL_COMPOSE. */
814 gcsHAL_COMPOSE Compose
;
816 /* gcvHAL_GET_FRAME_INFO. */
817 struct _gcsHAL_GET_FRAME_INFO
819 OUT gcsHAL_FRAME_INFO
* frameInfo
;
823 /* gcvHAL_SET_TIME_OUT. */
824 struct _gcsHAL_SET_TIMEOUT
832 struct _gcsHAL_VGCOMMIT
834 /* Context buffer. */
835 IN gcsVGCONTEXT_PTR context
;
838 IN gcsVGCMDQUEUE_PTR queue
;
840 /* Number of entries in the queue. */
841 IN gctUINT entryCount
;
844 IN gcsTASK_MASTER_TABLE_PTR taskTable
;
848 /* gcvHAL_QUERY_COMMAND_BUFFER */
849 struct _gcsHAL_QUERY_COMMAND_BUFFER
851 /* Command buffer attributes. */
852 OUT gcsCOMMAND_BUFFER_INFO information
;
858 #if gcdENABLE_SHARED_INFO
859 struct _gcsHAL_GET_SHARED_INFO
863 IN gcuVIDMEM_NODE_PTR node
;
864 OUT gctUINT8_PTR data
;
866 OUT gctUINT8_PTR nodeData
;
871 struct _gcsHAL_SET_SHARED_INFO
874 IN gcuVIDMEM_NODE_PTR node
;
875 IN gctUINT8_PTR data
;
876 IN gctUINT8_PTR nodeData
;
891 #endif /* __gc_hal_driver_h_ */