]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_eglplatform.h
ENGR00284988 gpu:Sync gpu kernel driver code
[karo-tx-linux.git] / drivers / mxc / gpu-viv / hal / kernel / inc / gc_hal_eglplatform.h
1 /****************************************************************************
2 *
3 *    Copyright (C) 2005 - 2013 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 #ifndef __gc_hal_eglplatform_h_
22 #define __gc_hal_eglplatform_h_
23
24 /* Include VDK types. */
25 #include "gc_hal_types.h"
26 #include "gc_hal_base.h"
27 #include "gc_hal_eglplatform_type.h"
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32
33 #if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
34 /* Win32 and Windows CE platforms. */
35 #include <windows.h>
36 typedef HDC             HALNativeDisplayType;
37 typedef HWND            HALNativeWindowType;
38 typedef HBITMAP         HALNativePixmapType;
39
40 typedef struct __BITFIELDINFO{
41     BITMAPINFO    bmi;
42     RGBQUAD       bmiColors[2];
43 } BITFIELDINFO;
44
45 #elif defined(LINUX) && defined(EGL_API_DFB) && !defined(__APPLE__)
46 #include <directfb.h>
47 typedef struct _DFBDisplay * HALNativeDisplayType;
48 typedef struct _DFBWindow *  HALNativeWindowType;
49 typedef struct _DFBPixmap *  HALNativePixmapType;
50
51 #elif defined(LINUX) && defined(EGL_API_FB) && !defined(__APPLE__)
52
53 #if defined(EGL_API_WL)
54 /* Wayland platform. */
55 #include "wayland-server.h"
56 #include <wayland-egl.h>
57
58 #define WL_EGL_NUM_BACKBUFFERS 2
59
60 typedef struct _gcsWL_VIV_BUFFER
61 {
62    struct wl_buffer wl_buffer;
63    gcoSURF surface;
64 } gcsWL_VIV_BUFFER;
65
66 typedef struct _gcsWL_EGL_DISPLAY
67 {
68    struct wl_display* wl_display;
69    struct wl_viv* wl_viv;
70 } gcsWL_EGL_DISPLAY;
71
72 typedef struct _gcsWL_EGL_BUFFER_INFO
73 {
74    gctINT32 width;
75    gctINT32 height;
76    gctINT32 stride;
77    gceSURF_FORMAT format;
78    gcuVIDMEM_NODE_PTR node;
79    gcePOOL pool;
80    gctUINT bytes;
81    gcoSURF surface;
82 } gcsWL_EGL_BUFFER_INFO;
83
84 typedef struct _gcsWL_EGL_BUFFER
85 {
86    struct wl_buffer* wl_buffer;
87    gcsWL_EGL_BUFFER_INFO info;
88 } gcsWL_EGL_BUFFER;
89
90 typedef struct _gcsWL_EGL_WINDOW_INFO
91 {
92    gctUINT width;
93    gctUINT height;
94    gceSURF_FORMAT format;
95    gctUINT bpp;
96 } gcsWL_EGL_WINDOW_INFO;
97
98 struct wl_egl_window
99 {
100    gcsWL_EGL_BUFFER backbuffers[WL_EGL_NUM_BACKBUFFERS];
101    gcsWL_EGL_WINDOW_INFO info;
102    gctUINT current;
103    struct wl_surface* surface;
104    struct wl_callback* pending;
105 };
106
107 typedef void*   HALNativeDisplayType;
108 typedef void*   HALNativeWindowType;
109 typedef void*   HALNativePixmapType;
110 #else
111 /* Linux platform for FBDEV. */
112 typedef struct _FBDisplay * HALNativeDisplayType;
113 typedef struct _FBWindow *  HALNativeWindowType;
114 typedef struct _FBPixmap *  HALNativePixmapType;
115 #endif
116 #elif defined(__ANDROID__) || defined(ANDROID)
117
118 struct egl_native_pixmap_t;
119
120 #if ANDROID_SDK_VERSION >= 9
121     #include <android/native_window.h>
122
123     typedef struct ANativeWindow*           HALNativeWindowType;
124     typedef struct egl_native_pixmap_t*     HALNativePixmapType;
125     typedef void*                           HALNativeDisplayType;
126 #else
127     struct android_native_window_t;
128     typedef struct android_native_window_t*    HALNativeWindowType;
129     typedef struct egl_native_pixmap_t *        HALNativePixmapType;
130     typedef void*                               HALNativeDisplayType;
131 #endif
132
133 #elif defined(LINUX) || defined(__APPLE__)
134 /* X11 platform. */
135 #include <X11/Xlib.h>
136 #include <X11/Xutil.h>
137
138 typedef Display *   HALNativeDisplayType;
139 typedef Window      HALNativeWindowType;
140
141 #ifdef CUSTOM_PIXMAP
142 typedef void *      HALNativePixmapType;
143 #else
144 typedef Pixmap      HALNativePixmapType;
145 #endif /* CUSTOM_PIXMAP */
146
147 /* Rename some badly named X defines. */
148 #ifdef Status
149 #   define XStatus      int
150 #   undef Status
151 #endif
152 #ifdef Always
153 #   define XAlways      2
154 #   undef Always
155 #endif
156 #ifdef CurrentTime
157 #   undef CurrentTime
158 #   define XCurrentTime 0
159 #endif
160
161 #elif defined(__QNXNTO__)
162 #include <screen/screen.h>
163
164 /* VOID */
165 typedef int              HALNativeDisplayType;
166 typedef screen_window_t  HALNativeWindowType;
167 typedef screen_pixmap_t  HALNativePixmapType;
168
169 #else
170
171 #error "Platform not recognized"
172
173 /* VOID */
174 typedef void *  HALNativeDisplayType;
175 typedef void *  HALNativeWindowType;
176 typedef void *  HALNativePixmapType;
177
178 #endif
179
180 /* define DUMMY according to the system */
181 #if defined(EGL_API_WL)
182 #   define WL_DUMMY (31415926)
183 #   define EGL_DUMMY WL_DUMMY
184 #elif defined(__ANDROID__) || defined(ANDROID)
185 #   define ANDROID_DUMMY (31415926)
186 #   define EGL_DUMMY ANDROID_DUMMY
187 #else
188 #   define EGL_DUMMY (31415926)
189 #endif
190
191 /*******************************************************************************
192 ** Display. ********************************************************************
193 */
194
195 gceSTATUS
196 gcoOS_GetDisplay(
197     OUT HALNativeDisplayType * Display,
198     IN gctPOINTER Context
199     );
200
201 gceSTATUS
202 gcoOS_GetDisplayByIndex(
203     IN gctINT DisplayIndex,
204     OUT HALNativeDisplayType * Display,
205     IN gctPOINTER Context
206     );
207
208 gceSTATUS
209 gcoOS_GetDisplayInfo(
210     IN HALNativeDisplayType Display,
211     OUT gctINT * Width,
212     OUT gctINT * Height,
213     OUT gctSIZE_T * Physical,
214     OUT gctINT * Stride,
215     OUT gctINT * BitsPerPixel
216     );
217
218
219
220 gceSTATUS
221 gcoOS_GetDisplayInfoEx(
222     IN HALNativeDisplayType Display,
223     IN HALNativeWindowType Window,
224     IN gctUINT DisplayInfoSize,
225     OUT halDISPLAY_INFO * DisplayInfo
226     );
227
228 gceSTATUS
229 gcoOS_GetNextDisplayInfoExByIndex(
230     IN gctINT Index,
231     IN HALNativeDisplayType Display,
232     IN HALNativeWindowType Window,
233     IN gctUINT DisplayInfoSize,
234     OUT halDISPLAY_INFO * DisplayInfo
235     );
236
237 gceSTATUS
238 gcoOS_GetDisplayVirtual(
239     IN HALNativeDisplayType Display,
240     OUT gctINT * Width,
241     OUT gctINT * Height
242     );
243
244 gceSTATUS
245 gcoOS_GetDisplayBackbuffer(
246     IN HALNativeDisplayType Display,
247     IN HALNativeWindowType Window,
248     OUT gctPOINTER  *  context,
249     OUT gcoSURF     *  surface,
250     OUT gctUINT * Offset,
251     OUT gctINT * X,
252     OUT gctINT * Y
253     );
254
255 gceSTATUS
256 gcoOS_SetDisplayVirtual(
257     IN HALNativeDisplayType Display,
258     IN HALNativeWindowType Window,
259     IN gctUINT Offset,
260     IN gctINT X,
261     IN gctINT Y
262     );
263
264 gceSTATUS
265 gcoOS_SetDisplayVirtualEx(
266     IN HALNativeDisplayType Display,
267     IN HALNativeWindowType Window,
268     IN gctPOINTER Context,
269     IN gcoSURF Surface,
270     IN gctUINT Offset,
271     IN gctINT X,
272     IN gctINT Y
273     );
274
275 gceSTATUS
276 gcoOS_SetSwapInterval(
277     IN HALNativeDisplayType Display,
278     IN gctINT Interval
279 );
280
281 gceSTATUS
282 gcoOS_GetSwapInterval(
283     IN HALNativeDisplayType Display,
284     IN gctINT_PTR Min,
285     IN gctINT_PTR Max
286 );
287
288 gceSTATUS
289 gcoOS_DisplayBufferRegions(
290     IN HALNativeDisplayType Display,
291     IN HALNativeWindowType Window,
292     IN gctINT NumRects,
293     IN gctINT_PTR Rects
294     );
295
296 gceSTATUS
297 gcoOS_DestroyDisplay(
298     IN HALNativeDisplayType Display
299     );
300
301 gceSTATUS
302 gcoOS_InitLocalDisplayInfo(
303     IN HALNativeDisplayType Display,
304     IN OUT gctPOINTER * localDisplay
305     );
306
307 gceSTATUS
308 gcoOS_DeinitLocalDisplayInfo(
309     IN HALNativeDisplayType Display,
310     IN OUT gctPOINTER * localDisplay
311     );
312
313 gceSTATUS
314 gcoOS_GetDisplayInfoEx2(
315     IN HALNativeDisplayType Display,
316     IN HALNativeWindowType Window,
317     IN gctPOINTER  localDisplay,
318     IN gctUINT DisplayInfoSize,
319     OUT halDISPLAY_INFO * DisplayInfo
320     );
321
322 gceSTATUS
323 gcoOS_GetDisplayBackbufferEx(
324     IN HALNativeDisplayType Display,
325     IN HALNativeWindowType Window,
326     IN gctPOINTER  localDisplay,
327     OUT gctPOINTER  *  context,
328     OUT gcoSURF     *  surface,
329     OUT gctUINT * Offset,
330     OUT gctINT * X,
331     OUT gctINT * Y
332     );
333
334 gceSTATUS
335 gcoOS_IsValidDisplay(
336     IN HALNativeDisplayType Display
337     );
338
339 gceSTATUS
340 gcoOS_GetNativeVisualId(
341     IN HALNativeDisplayType Display,
342     OUT gctINT* nativeVisualId
343     );
344
345 gctBOOL
346 gcoOS_SynchronousFlip(
347     IN HALNativeDisplayType Display
348     );
349
350 /*******************************************************************************
351 ** Windows. ********************************************************************
352 */
353
354 gceSTATUS
355 gcoOS_CreateWindow(
356     IN HALNativeDisplayType Display,
357     IN gctINT X,
358     IN gctINT Y,
359     IN gctINT Width,
360     IN gctINT Height,
361     OUT HALNativeWindowType * Window
362     );
363
364 gceSTATUS
365 gcoOS_GetWindowInfo(
366     IN HALNativeDisplayType Display,
367     IN HALNativeWindowType Window,
368     OUT gctINT * X,
369     OUT gctINT * Y,
370     OUT gctINT * Width,
371     OUT gctINT * Height,
372     OUT gctINT * BitsPerPixel,
373     OUT gctUINT * Offset
374     );
375
376 gceSTATUS
377 gcoOS_DestroyWindow(
378     IN HALNativeDisplayType Display,
379     IN HALNativeWindowType Window
380     );
381
382 gceSTATUS
383 gcoOS_DrawImage(
384     IN HALNativeDisplayType Display,
385     IN HALNativeWindowType Window,
386     IN gctINT Left,
387     IN gctINT Top,
388     IN gctINT Right,
389     IN gctINT Bottom,
390     IN gctINT Width,
391     IN gctINT Height,
392     IN gctINT BitsPerPixel,
393     IN gctPOINTER Bits
394     );
395
396 gceSTATUS
397 gcoOS_GetImage(
398     IN HALNativeWindowType Window,
399     IN gctINT Left,
400     IN gctINT Top,
401     IN gctINT Right,
402     IN gctINT Bottom,
403     OUT gctINT * BitsPerPixel,
404     OUT gctPOINTER * Bits
405     );
406
407 gceSTATUS
408 gcoOS_GetWindowInfoEx(
409     IN HALNativeDisplayType Display,
410     IN HALNativeWindowType Window,
411     OUT gctINT * X,
412     OUT gctINT * Y,
413     OUT gctINT * Width,
414     OUT gctINT * Height,
415     OUT gctINT * BitsPerPixel,
416     OUT gctUINT * Offset,
417     OUT gceSURF_FORMAT * Format
418     );
419
420 gceSTATUS
421 gcoOS_DrawImageEx(
422     IN HALNativeDisplayType Display,
423     IN HALNativeWindowType Window,
424     IN gctINT Left,
425     IN gctINT Top,
426     IN gctINT Right,
427     IN gctINT Bottom,
428     IN gctINT Width,
429     IN gctINT Height,
430     IN gctINT BitsPerPixel,
431     IN gctPOINTER Bits,
432     IN gceSURF_FORMAT  Format
433     );
434
435 /*******************************************************************************
436 ** Pixmaps. ********************************************************************
437 */
438
439 gceSTATUS
440 gcoOS_CreatePixmap(
441     IN HALNativeDisplayType Display,
442     IN gctINT Width,
443     IN gctINT Height,
444     IN gctINT BitsPerPixel,
445     OUT HALNativePixmapType * Pixmap
446     );
447
448 gceSTATUS
449 gcoOS_GetPixmapInfo(
450     IN HALNativeDisplayType Display,
451     IN HALNativePixmapType Pixmap,
452     OUT gctINT * Width,
453     OUT gctINT * Height,
454     OUT gctINT * BitsPerPixel,
455     OUT gctINT * Stride,
456     OUT gctPOINTER * Bits
457     );
458
459 gceSTATUS
460 gcoOS_DrawPixmap(
461     IN HALNativeDisplayType Display,
462     IN HALNativePixmapType Pixmap,
463     IN gctINT Left,
464     IN gctINT Top,
465     IN gctINT Right,
466     IN gctINT Bottom,
467     IN gctINT Width,
468     IN gctINT Height,
469     IN gctINT BitsPerPixel,
470     IN gctPOINTER Bits
471     );
472
473 gceSTATUS
474 gcoOS_DestroyPixmap(
475     IN HALNativeDisplayType Display,
476     IN HALNativePixmapType Pixmap
477     );
478
479 gceSTATUS
480 gcoOS_GetPixmapInfoEx(
481     IN HALNativeDisplayType Display,
482     IN HALNativePixmapType Pixmap,
483     OUT gctINT * Width,
484     OUT gctINT * Height,
485     OUT gctINT * BitsPerPixel,
486     OUT gctINT * Stride,
487     OUT gctPOINTER * Bits,
488     OUT gceSURF_FORMAT * Format
489     );
490
491 gceSTATUS
492 gcoOS_CopyPixmapBits(
493     IN HALNativeDisplayType Display,
494     IN HALNativePixmapType Pixmap,
495     IN gctUINT DstWidth,
496     IN gctUINT DstHeight,
497     IN gctINT DstStride,
498     IN gceSURF_FORMAT DstFormat,
499     OUT gctPOINTER DstBits
500     );
501
502 /*******************************************************************************
503 ** OS relative. ****************************************************************
504 */
505 gceSTATUS
506 gcoOS_LoadEGLLibrary(
507     OUT gctHANDLE * Handle
508     );
509
510 gceSTATUS
511 gcoOS_FreeEGLLibrary(
512     IN gctHANDLE Handle
513     );
514
515 gceSTATUS
516 gcoOS_ShowWindow(
517     IN HALNativeDisplayType Display,
518     IN HALNativeWindowType Window
519     );
520
521 gceSTATUS
522 gcoOS_HideWindow(
523     IN HALNativeDisplayType Display,
524     IN HALNativeWindowType Window
525     );
526
527 gceSTATUS
528 gcoOS_SetWindowTitle(
529     IN HALNativeDisplayType Display,
530     IN HALNativeWindowType Window,
531     IN gctCONST_STRING Title
532     );
533
534 gceSTATUS
535 gcoOS_CapturePointer(
536     IN HALNativeDisplayType Display,
537     IN HALNativeWindowType Window
538     );
539
540 gceSTATUS
541 gcoOS_GetEvent(
542     IN HALNativeDisplayType Display,
543     IN HALNativeWindowType Window,
544     OUT halEvent * Event
545     );
546
547 gceSTATUS
548 gcoOS_CreateClientBuffer(
549     IN gctINT Width,
550     IN gctINT Height,
551     IN gctINT Format,
552     IN gctINT Type,
553     OUT gctPOINTER * ClientBuffer
554     );
555
556 gceSTATUS
557 gcoOS_GetClientBufferInfo(
558     IN gctPOINTER ClientBuffer,
559     OUT gctINT * Width,
560     OUT gctINT * Height,
561     OUT gctINT * Stride,
562     OUT gctPOINTER * Bits
563     );
564
565 gceSTATUS
566 gcoOS_DestroyClientBuffer(
567     IN gctPOINTER ClientBuffer
568     );
569
570 gceSTATUS
571 gcoOS_DestroyContext(
572     IN gctPOINTER Display,
573     IN gctPOINTER Context
574     );
575
576 gceSTATUS
577 gcoOS_CreateContext(
578     IN gctPOINTER LocalDisplay,
579     IN gctPOINTER Context
580     );
581
582 gceSTATUS
583 gcoOS_MakeCurrent(
584     IN gctPOINTER LocalDisplay,
585     IN HALNativeWindowType DrawDrawable,
586     IN HALNativeWindowType ReadDrawable,
587     IN gctPOINTER Context,
588     IN gcoSURF ResolveTarget
589     );
590
591 gceSTATUS
592 gcoOS_CreateDrawable(
593     IN gctPOINTER LocalDisplay,
594     IN HALNativeWindowType Drawable
595     );
596
597 gceSTATUS
598 gcoOS_DestroyDrawable(
599     IN gctPOINTER LocalDisplay,
600     IN HALNativeWindowType Drawable
601     );
602 gceSTATUS
603 gcoOS_SwapBuffers(
604     IN gctPOINTER LocalDisplay,
605     IN HALNativeWindowType Drawable,
606     IN gcoSURF RenderTarget,
607     IN gcoSURF ResolveTarget,
608     IN gctPOINTER ResolveBits,
609     OUT gctUINT *Width,
610     OUT gctUINT *Height
611     );
612 #ifdef __cplusplus
613 }
614 #endif
615
616 #endif /* __gc_hal_eglplatform_h_ */