egldriver.h revision af69d88d
13464ebd5Sriastradh/**************************************************************************
23464ebd5Sriastradh *
3af69d88dSmrg * Copyright 2008 VMware, Inc.
43464ebd5Sriastradh * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
53464ebd5Sriastradh * Copyright 2010-2011 LunarG, Inc.
63464ebd5Sriastradh * All Rights Reserved.
73464ebd5Sriastradh *
83464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a
93464ebd5Sriastradh * copy of this software and associated documentation files (the
103464ebd5Sriastradh * "Software"), to deal in the Software without restriction, including
113464ebd5Sriastradh * without limitation the rights to use, copy, modify, merge, publish,
123464ebd5Sriastradh * distribute, sub license, and/or sell copies of the Software, and to
133464ebd5Sriastradh * permit persons to whom the Software is furnished to do so, subject to
143464ebd5Sriastradh * the following conditions:
153464ebd5Sriastradh *
163464ebd5Sriastradh * The above copyright notice and this permission notice (including the
173464ebd5Sriastradh * next paragraph) shall be included in all copies or substantial portions
183464ebd5Sriastradh * of the Software.
193464ebd5Sriastradh *
203464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
213464ebd5Sriastradh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
223464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
233464ebd5Sriastradh * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
243464ebd5Sriastradh * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
253464ebd5Sriastradh * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
263464ebd5Sriastradh * DEALINGS IN THE SOFTWARE.
273464ebd5Sriastradh *
283464ebd5Sriastradh **************************************************************************/
293464ebd5Sriastradh
303464ebd5Sriastradh
314a49301eSmrg#ifndef EGLDRIVER_INCLUDED
324a49301eSmrg#define EGLDRIVER_INCLUDED
334a49301eSmrg
344a49301eSmrg
354a49301eSmrg#include "egltypedefs.h"
364a49301eSmrg#include "eglapi.h"
373464ebd5Sriastradh#include <stddef.h>
384a49301eSmrg
39cdc920a0Smrg/**
40cdc920a0Smrg * Define an inline driver typecast function.
41cdc920a0Smrg *
42cdc920a0Smrg * Note that this macro defines a function and should not be ended with a
43cdc920a0Smrg * semicolon when used.
44cdc920a0Smrg */
45cdc920a0Smrg#define _EGL_DRIVER_TYPECAST(drvtype, egltype, code)           \
46cdc920a0Smrg   static INLINE struct drvtype *drvtype(const egltype *obj)   \
47cdc920a0Smrg   { return (struct drvtype *) code; }
48cdc920a0Smrg
49cdc920a0Smrg
50cdc920a0Smrg/**
51cdc920a0Smrg * Define the driver typecast functions for _EGLDriver, _EGLDisplay,
52cdc920a0Smrg * _EGLContext, _EGLSurface, and _EGLConfig.
53cdc920a0Smrg *
54cdc920a0Smrg * Note that this macro defines several functions and should not be ended with
55cdc920a0Smrg * a semicolon when used.
56cdc920a0Smrg */
57cdc920a0Smrg#define _EGL_DRIVER_STANDARD_TYPECASTS(drvname)                            \
58cdc920a0Smrg   _EGL_DRIVER_TYPECAST(drvname ## _driver, _EGLDriver, obj)               \
59cdc920a0Smrg   /* note that this is not a direct cast */                               \
60cdc920a0Smrg   _EGL_DRIVER_TYPECAST(drvname ## _display, _EGLDisplay, obj->DriverData) \
61cdc920a0Smrg   _EGL_DRIVER_TYPECAST(drvname ## _context, _EGLContext, obj)             \
62cdc920a0Smrg   _EGL_DRIVER_TYPECAST(drvname ## _surface, _EGLSurface, obj)             \
63cdc920a0Smrg   _EGL_DRIVER_TYPECAST(drvname ## _config, _EGLConfig, obj)
64cdc920a0Smrg
65cdc920a0Smrg
66cdc920a0Smrgtypedef _EGLDriver *(*_EGLMain_t)(const char *args);
67cdc920a0Smrg
68cdc920a0Smrg
694a49301eSmrg/**
704a49301eSmrg * Base class for device drivers.
714a49301eSmrg */
724a49301eSmrgstruct _egl_driver
734a49301eSmrg{
744a49301eSmrg   const char *Name;  /**< name of this driver */
75cdc920a0Smrg
76cdc920a0Smrg   /**
77cdc920a0Smrg    * Release the driver resource.
78cdc920a0Smrg    *
79cdc920a0Smrg    * It is called before dlclose().
80cdc920a0Smrg    */
814a49301eSmrg   void (*Unload)(_EGLDriver *drv);
824a49301eSmrg
834a49301eSmrg   _EGLAPI API;  /**< EGL API dispatch table */
844a49301eSmrg};
854a49301eSmrg
864a49301eSmrg
873464ebd5Sriastradhextern _EGLDriver *
883464ebd5Sriastradh_eglBuiltInDriverGALLIUM(const char *args);
893464ebd5Sriastradh
903464ebd5Sriastradh
913464ebd5Sriastradhextern _EGLDriver *
923464ebd5Sriastradh_eglBuiltInDriverDRI2(const char *args);
933464ebd5Sriastradh
943464ebd5Sriastradh
953464ebd5Sriastradhextern _EGLDriver *
963464ebd5Sriastradh_eglBuiltInDriverGLX(const char *args);
973464ebd5Sriastradh
983464ebd5Sriastradh
99cdc920a0SmrgPUBLIC _EGLDriver *
100cdc920a0Smrg_eglMain(const char *args);
1014a49301eSmrg
1024a49301eSmrg
1034a49301eSmrgextern _EGLDriver *
1043464ebd5Sriastradh_eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only);
1054a49301eSmrg
1064a49301eSmrg
1073464ebd5Sriastradhextern __eglMustCastToProperFunctionPointerType
1083464ebd5Sriastradh_eglGetDriverProc(const char *procname);
1094a49301eSmrg
1104a49301eSmrg
111cdc920a0Smrgextern void
1124a49301eSmrg_eglUnloadDrivers(void);
1134a49301eSmrg
1144a49301eSmrg
1153464ebd5Sriastradh/* defined in eglfallbacks.c */
116cdc920a0SmrgPUBLIC void
117cdc920a0Smrg_eglInitDriverFallbacks(_EGLDriver *drv);
1184a49301eSmrg
1194a49301eSmrg
120cdc920a0SmrgPUBLIC void
1213464ebd5Sriastradh_eglSearchPathForEach(EGLBoolean (*callback)(const char *, size_t, void *),
1223464ebd5Sriastradh                      void *callback_data);
1234a49301eSmrg
1244a49301eSmrg
1254a49301eSmrg#endif /* EGLDRIVER_INCLUDED */
126