| 1 | /* |
| 2 | Copyright (c) 2012, Broadcom Europe Ltd |
| 3 | All rights reserved. |
| 4 | |
| 5 | Redistribution and use in source and binary forms, with or without |
| 6 | modification, are permitted provided that the following conditions are met: |
| 7 | * Redistributions of source code must retain the above copyright |
| 8 | notice, this list of conditions and the following disclaimer. |
| 9 | * Redistributions in binary form must reproduce the above copyright |
| 10 | notice, this list of conditions and the following disclaimer in the |
| 11 | documentation and/or other materials provided with the distribution. |
| 12 | * Neither the name of the copyright holder nor the |
| 13 | names of its contributors may be used to endorse or promote products |
| 14 | derived from this software without specific prior written permission. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
| 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef EGL_CLIENT_CONFIG_H |
| 29 | #define EGL_CLIENT_CONFIG_H |
| 30 | |
| 31 | #include "interface/khronos/common/khrn_client_platform.h" |
| 32 | |
| 33 | #include "interface/khronos/include/EGL/egl.h" |
| 34 | #include "interface/khronos/include/EGL/eglext.h" |
| 35 | |
| 36 | #include "interface/khronos/common/khrn_int_image.h" |
| 37 | |
| 38 | #include "interface/khronos/egl/egl_int_config.h" |
| 39 | |
| 40 | #if defined(__BCM2708A0__) || defined(__BCM35230A0__) |
| 41 | #define EGL_NO_ALPHA_MASK_CONFIGS |
| 42 | #endif |
| 43 | |
| 44 | #ifdef EGL_NO_ALPHA_MASK_CONFIGS |
| 45 | #define EGL_MAX_CONFIGS 25 |
| 46 | #else |
| 47 | #define EGL_MAX_CONFIGS 28 |
| 48 | #endif |
| 49 | |
| 50 | /* |
| 51 | EGL_CONFIG_MIN_SWAP_INTERVAL |
| 52 | |
| 53 | Khronos config attrib name: EGL_MIN_SWAP_INTERVAL |
| 54 | |
| 55 | 0 <= EGL_CONFIG_MIN_SWAP_INTERVAL <= 1 |
| 56 | */ |
| 57 | #define EGL_CONFIG_MIN_SWAP_INTERVAL 0 |
| 58 | |
| 59 | /* |
| 60 | EGL_CONFIG_MAX_SWAP_INTERVAL |
| 61 | |
| 62 | Khronos config attrib name: EGL_MAX_SWAP_INTERVAL |
| 63 | |
| 64 | 1 <= EGL_CONFIG_MAX_SWAP_INTERVAL |
| 65 | EGL_CONFIG_MIN_SWAP_INTERVAL <= EGL_CONFIG_MAX_SWAP_INTERVAL |
| 66 | */ |
| 67 | #define EGL_CONFIG_MAX_SWAP_INTERVAL 0x7fffffff |
| 68 | /* |
| 69 | EGL_CONFIG_MAX_WIDTH |
| 70 | |
| 71 | Khronos config attrib name: EGL_MAX_PBUFFER_WIDTH |
| 72 | |
| 73 | EGL_CONFIG_MAX_WIDTH > 0 |
| 74 | */ |
| 75 | #define EGL_CONFIG_MAX_WIDTH 2048 |
| 76 | /* |
| 77 | EGL_CONFIG_MAX_HEIGHT |
| 78 | |
| 79 | Khronos config attrib name: EGL_MAX_PBUFFER_HEIGHT |
| 80 | |
| 81 | EGL_CONFIG_MAX_HEIGHT > 0 |
| 82 | */ |
| 83 | #define EGL_CONFIG_MAX_HEIGHT 2048 |
| 84 | |
| 85 | /* |
| 86 | EGLConfig egl_config_from_id(int id) |
| 87 | |
| 88 | Converts between our internally-used index and EGLConfig (by adding 1). |
| 89 | |
| 90 | Preconditions: |
| 91 | |
| 92 | 0 <= id < EGL_MAX_CONFIGS |
| 93 | |
| 94 | Postconditions: |
| 95 | |
| 96 | Return value is a valid EGLConfig |
| 97 | */ |
| 98 | |
| 99 | static INLINE EGLConfig egl_config_from_id(int id) |
| 100 | { |
| 101 | return (EGLConfig)(size_t)(id + 1); |
| 102 | } |
| 103 | |
| 104 | /* |
| 105 | int egl_config_to_id(EGLConfig config) |
| 106 | |
| 107 | Inverse of egl_config_from_id |
| 108 | |
| 109 | Preconditions: |
| 110 | |
| 111 | config is a valid EGLConfig |
| 112 | |
| 113 | Postconditions: |
| 114 | |
| 115 | 0 <= result < EGL_MAX_CONFIGS |
| 116 | |
| 117 | */ |
| 118 | |
| 119 | static INLINE int egl_config_to_id(EGLConfig config) |
| 120 | { |
| 121 | return (int)(size_t)config - 1; |
| 122 | } |
| 123 | |
| 124 | extern void egl_config_sort(int *ids, bool use_red, bool use_green, bool use_blue, bool use_alpha); |
| 125 | extern bool egl_config_check_attribs(const EGLint *attrib_list, bool *use_red, bool *use_green, bool *use_blue, bool *use_alpha); |
| 126 | extern bool egl_config_filter(int id, const EGLint *attrib_list); |
| 127 | extern bool egl_config_get_attrib(int id, EGLint attrib, EGLint *value); |
| 128 | extern void egl_config_install_configs(int type); |
| 129 | |
| 130 | extern KHRN_IMAGE_FORMAT_T egl_config_get_color_format(int id); |
| 131 | extern KHRN_IMAGE_FORMAT_T egl_config_get_depth_format(int id); |
| 132 | extern KHRN_IMAGE_FORMAT_T egl_config_get_mask_format(int id); |
| 133 | extern KHRN_IMAGE_FORMAT_T egl_config_get_multisample_format(int id); |
| 134 | extern bool egl_config_get_multisample(int id); |
| 135 | extern bool egl_config_bindable(int id, EGLenum format); |
| 136 | extern bool egl_config_match_pixmap_info(int id, KHRN_IMAGE_WRAP_T *image); |
| 137 | extern uint32_t egl_config_get_api_support(int id); |
| 138 | extern bool egl_config_bpps_match(int id0, int id1); /* bpps of all buffers match */ |
| 139 | extern uint32_t egl_config_get_api_conformance(int id); |
| 140 | |
| 141 | #if EGL_KHR_lock_surface |
| 142 | extern KHRN_IMAGE_FORMAT_T egl_config_get_mapped_format(int id); |
| 143 | extern bool egl_config_is_lockable(int id); |
| 144 | #endif |
| 145 | |
| 146 | #endif |
| 147 | |