]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/mxc/gpu-viv/hal/kernel/arch/gc_hal_kernel_context.h
gpu: vivante: Update driver from Freescale 3.10.53-1.1-ga BSP
[karo-tx-linux.git] / drivers / mxc / gpu-viv / hal / kernel / arch / gc_hal_kernel_context.h
1 /****************************************************************************
2 *
3 *    Copyright (C) 2005 - 2014 by Vivante Corp.
4 *
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.
9 *
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.
14 *
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.
18 *
19 *****************************************************************************/
20
21
22 #ifndef __gc_hal_kernel_context_h_
23 #define __gc_hal_kernel_context_h_
24
25 #include "gc_hal_kernel_buffer.h"
26
27 /* Exprimental optimization. */
28 #define REMOVE_DUPLICATED_COPY_FROM_USER 1
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /* Maps state locations within the context buffer. */
35 typedef struct _gcsSTATE_MAP * gcsSTATE_MAP_PTR;
36 typedef struct _gcsSTATE_MAP
37 {
38     /* Index of the state in the context buffer. */
39     gctUINT                     index;
40
41     /* State mask. */
42     gctUINT32                   mask;
43 }
44 gcsSTATE_MAP;
45
46 /* Context buffer. */
47 typedef struct _gcsCONTEXT * gcsCONTEXT_PTR;
48 typedef struct _gcsCONTEXT
49 {
50     /* For debugging: the number of context buffer in the order of creation. */
51 #if gcmIS_DEBUG(gcdDEBUG_CODE)
52     gctUINT                     num;
53 #endif
54
55     /* Pointer to gckEVENT object. */
56     gckEVENT                    eventObj;
57
58     /* Context busy signal. */
59     gctSIGNAL                   signal;
60
61     /* Physical address of the context buffer. */
62     gctPHYS_ADDR                physical;
63
64     /* Logical address of the context buffer. */
65     gctUINT32_PTR               logical;
66
67     /* Hardware address of the context buffer. */
68     gctUINT32                   address;
69
70     /* Pointer to the LINK commands. */
71     gctPOINTER                  link2D;
72     gctPOINTER                  link3D;
73
74     /* The number of pending state deltas. */
75     gctUINT                     deltaCount;
76
77     /* Pointer to the first delta to be applied. */
78     gcsSTATE_DELTA_PTR          delta;
79
80     /* Next context buffer. */
81     gcsCONTEXT_PTR              next;
82 }
83 gcsCONTEXT;
84
85 typedef struct _gcsRECORD_ARRAY_MAP * gcsRECORD_ARRAY_MAP_PTR;
86 struct  _gcsRECORD_ARRAY_MAP
87 {
88     /* User pointer key. */
89     gctUINT64                   key;
90
91     /* Kernel memory buffer. */
92     gcsSTATE_DELTA_RECORD_PTR   kData;
93
94     /* Next map. */
95     gcsRECORD_ARRAY_MAP_PTR     next;
96
97 };
98
99 /* gckCONTEXT structure that hold the current context. */
100 struct _gckCONTEXT
101 {
102     /* Object. */
103     gcsOBJECT                   object;
104
105     /* Pointer to gckOS object. */
106     gckOS                       os;
107
108     /* Pointer to gckHARDWARE object. */
109     gckHARDWARE                 hardware;
110
111     /* Command buffer alignment. */
112     gctUINT32                   alignment;
113     gctUINT32                   reservedHead;
114     gctUINT32                   reservedTail;
115
116     /* Context buffer metrics. */
117     gctSIZE_T                   stateCount;
118     gctUINT32                   totalSize;
119     gctUINT32                   bufferSize;
120     gctUINT32                   linkIndex2D;
121     gctUINT32                   linkIndex3D;
122     gctUINT32                   linkIndexXD;
123     gctUINT32                   entryOffset3D;
124     gctUINT32                   entryOffsetXDFrom2D;
125     gctUINT32                   entryOffsetXDFrom3D;
126
127     /* Dirty flags. */
128     gctBOOL                     dirty;
129     gctBOOL                     dirty2D;
130     gctBOOL                     dirty3D;
131     gcsCONTEXT_PTR              dirtyBuffer;
132
133     /* State mapping. */
134     gcsSTATE_MAP_PTR            map;
135
136     /* List of context buffers. */
137     gcsCONTEXT_PTR              buffer;
138
139     /* A copy of the user record array. */
140     gctUINT                     recordArraySize;
141 #if REMOVE_DUPLICATED_COPY_FROM_USER
142     gcsRECORD_ARRAY_MAP_PTR     recordArrayMap;
143 #else
144     gcsSTATE_DELTA_RECORD_PTR   recordArray;
145 #endif
146
147     /* Requested pipe select for context. */
148     gcePIPE_SELECT              entryPipe;
149     gcePIPE_SELECT              exitPipe;
150
151     /* Variables used for building state buffer. */
152     gctUINT32                   lastAddress;
153     gctSIZE_T                   lastSize;
154     gctUINT32                   lastIndex;
155     gctBOOL                     lastFixed;
156
157     gctUINT32                   pipeSelectBytes;
158
159     /* Hint array. */
160 #if gcdSECURE_USER
161     gctBOOL_PTR                 hint;
162 #endif
163
164 #if VIVANTE_PROFILER_CONTEXT
165     gcsPROFILER_COUNTERS        latestProfiler;
166     gcsPROFILER_COUNTERS        histroyProfiler;
167     gctUINT32                   prevVSInstCount;
168     gctUINT32                   prevVSBranchInstCount;
169     gctUINT32                   prevVSTexInstCount;
170     gctUINT32                   prevVSVertexCount;
171     gctUINT32                   prevPSInstCount;
172     gctUINT32                   prevPSBranchInstCount;
173     gctUINT32                   prevPSTexInstCount;
174     gctUINT32                   prevPSPixelCount;
175 #endif
176 };
177
178 #ifdef __cplusplus
179 }
180 #endif
181
182 #endif /* __gc_hal_kernel_context_h_ */
183