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