| 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 KHRN_INT_COMMON_H | 
|---|
| 29 | #define KHRN_INT_COMMON_H | 
|---|
| 30 | #ifdef __cplusplus | 
|---|
| 31 | extern "C"{ | 
|---|
| 32 | #endif\ | 
|---|
| 33 |  | 
|---|
| 34 | #include "helpers/v3d/v3d_ver.h" | 
|---|
| 35 |  | 
|---|
| 36 | #define VC_KHRN_VERSION 1 | 
|---|
| 37 | //#define KHRN_NOT_REALLY_DUALCORE   // Use dual core codebase but switch master thread to vpu1 | 
|---|
| 38 | //#define KHRN_SIMPLE_MULTISAMPLE | 
|---|
| 39 | //#define USE_CTRL_FOR_DATA | 
|---|
| 40 |  | 
|---|
| 41 | //#define GLXX_FORCE_MULTISAMPLE | 
|---|
| 42 |  | 
|---|
| 43 | //#define KHRN_COMMAND_MODE_DISPLAY    /* Platforms where we need to submit updates even for single-buffered surfaces */ | 
|---|
| 44 |  | 
|---|
| 45 | /* As BCG runs from cached memory, all allocations have to be the max of the CPU cache (calculated in the platform layer) and | 
|---|
| 46 | the size of the cache line on the L3 */ | 
|---|
| 47 | #define BCG_GCACHE_LINE_SIZE        256 | 
|---|
| 48 |  | 
|---|
| 49 | #ifdef _VIDEOCORE | 
|---|
| 50 | #define KHRN_VECTOR_CORE            /* have a vector core for image processing operations */ | 
|---|
| 51 | #define KHRN_HW_KICK_POWERMAN       /* khrn_hw_kick() kicks the clock using powerman */ | 
|---|
| 52 | #endif | 
|---|
| 53 |  | 
|---|
| 54 | #if defined(SIMPENROSE) || defined(KHRN_CARBON) | 
|---|
| 55 | /* for simplicity and determinism, the driver is single threaded when running | 
|---|
| 56 | * on simpenrose and carbon */ | 
|---|
| 57 | #define KHRN_SINGLE_THREADED | 
|---|
| 58 | #endif | 
|---|
| 59 |  | 
|---|
| 60 | #ifdef KHRN_SINGLE_THREADED | 
|---|
| 61 | #define KHRN_LLAT_NO_THREAD | 
|---|
| 62 | #define KHRN_WORKER_USE_LLAT | 
|---|
| 63 | #define EGL_DISP_USE_LLAT | 
|---|
| 64 | #else | 
|---|
| 65 | #if !VCOS_HAVE_RTOS | 
|---|
| 66 | #define KHRN_WORKER_USE_LLAT | 
|---|
| 67 | #endif | 
|---|
| 68 | #define EGL_DISP_USE_LLAT | 
|---|
| 69 | #endif | 
|---|
| 70 |  | 
|---|
| 71 | #define KHRN_LLAT_OTHER_CORE | 
|---|
| 72 | #ifndef V3D_LEAN | 
|---|
| 73 | #define KHRN_WORKER_OTHER_CORE | 
|---|
| 74 | #endif | 
|---|
| 75 |  | 
|---|
| 76 | #if defined(ANDROID) | 
|---|
| 77 | #define GL_GET_ERROR_ASYNC /* enabled with property brcm.graphics.async_errors "true" */ | 
|---|
| 78 | #endif | 
|---|
| 79 |  | 
|---|
| 80 | #if defined(ANDROID) | 
|---|
| 81 | #define KHDISPATCH_WORKSPACE_READAHEAD_BUFFERS 15 /* only VCHIQ */ | 
|---|
| 82 | #else | 
|---|
| 83 | #define KHDISPATCH_WORKSPACE_READAHEAD_BUFFERS 0 | 
|---|
| 84 | #endif | 
|---|
| 85 | #define KHDISPATCH_WORKSPACE_BUFFERS (KHDISPATCH_WORKSPACE_READAHEAD_BUFFERS + 1) | 
|---|
| 86 | #if defined(RPC_DIRECT) || defined(ANDROID) | 
|---|
| 87 | #include <limits.h> | 
|---|
| 88 | #define KHDISPATCH_WORKSPACE_SIZE (0x200000 / KHDISPATCH_WORKSPACE_BUFFERS) | 
|---|
| 89 | #else | 
|---|
| 90 | #define KHDISPATCH_WORKSPACE_SIZE ((1024 * 1024) / KHDISPATCH_WORKSPACE_BUFFERS) /* should be a multiple of 16, todo: how big does this need to be? (vg needs 8kB) */ | 
|---|
| 91 | #endif | 
|---|
| 92 |  | 
|---|
| 93 | #define KHDISPATCH_CTRL_THRESHOLD 2032 | 
|---|
| 94 | /* todo: use v3d_ver.h stuff... */ | 
|---|
| 95 |  | 
|---|
| 96 | #ifdef __BCM2708A0__ | 
|---|
| 97 | #define WORKAROUND_HW1297 | 
|---|
| 98 | #define WORKAROUND_HW1451 | 
|---|
| 99 | #define WORKAROUND_HW1632 | 
|---|
| 100 | #define WORKAROUND_HW1637 | 
|---|
| 101 | #define WORKAROUND_HW2038 | 
|---|
| 102 | #define WORKAROUND_HW2136 | 
|---|
| 103 | #define WORKAROUND_HW2187 | 
|---|
| 104 | #define WORKAROUND_HW2366 | 
|---|
| 105 | #define WORKAROUND_HW2384 | 
|---|
| 106 | #define WORKAROUND_HW2422 | 
|---|
| 107 | #define WORKAROUND_HW2479 | 
|---|
| 108 | #define WORKAROUND_HW2487 | 
|---|
| 109 | #define WORKAROUND_HW2488 | 
|---|
| 110 | #define WORKAROUND_HW2522 | 
|---|
| 111 | #define WORKAROUND_HW2781 | 
|---|
| 112 | #define KHRN_HW_SINGLE_TEXTURE_UNIT /* Only single texture unit available */ | 
|---|
| 113 | #endif | 
|---|
| 114 | #define WORKAROUND_HW2116 | 
|---|
| 115 | #define WORKAROUND_HW2806 | 
|---|
| 116 | #define WORKAROUND_HW2885 | 
|---|
| 117 | #define WORKAROUND_HW2903 | 
|---|
| 118 | #define WORKAROUND_HW2905 | 
|---|
| 119 | #define WORKAROUND_HW2924 | 
|---|
| 120 | #if !defined(KHRN_CARBON) /* hw-2959 fixed in latest rtl... */ | 
|---|
| 121 | #define WORKAROUND_HW2959 | 
|---|
| 122 | #define WORKAROUND_HW2989 | 
|---|
| 123 | #endif | 
|---|
| 124 |  | 
|---|
| 125 | #if !V3D_VER_AT_LEAST(3,0) | 
|---|
| 126 | #define WORKAROUND_GFXH30 | 
|---|
| 127 | #endif | 
|---|
| 128 |  | 
|---|
| 129 | #ifndef NULL | 
|---|
| 130 | # ifdef __cplusplus | 
|---|
| 131 | #  define NULL 0 | 
|---|
| 132 | # else | 
|---|
| 133 | #  define NULL ((void *)0) | 
|---|
| 134 | # endif | 
|---|
| 135 | #endif | 
|---|
| 136 |  | 
|---|
| 137 | #include "interface/vcos/vcos_assert.h" | 
|---|
| 138 | #include <string.h> /* size_t */ | 
|---|
| 139 |  | 
|---|
| 140 | #ifdef _MSC_VER | 
|---|
| 141 | #define INLINE __inline | 
|---|
| 142 | typedef unsigned long long uint64_t; | 
|---|
| 143 | #else | 
|---|
| 144 | #ifdef __GNUC__ | 
|---|
| 145 | /* Just using inline doesn't work for gcc (at least on MIPS), so use the gcc attribute. | 
|---|
| 146 | This gives a pretty decent performance boost */ | 
|---|
| 147 | #define INLINE inline __attribute__((always_inline)) | 
|---|
| 148 | #else | 
|---|
| 149 | #define INLINE inline | 
|---|
| 150 | #endif | 
|---|
| 151 | #endif | 
|---|
| 152 |  | 
|---|
| 153 | #include "interface/vcos/vcos_stdbool.h" | 
|---|
| 154 |  | 
|---|
| 155 | #ifdef NDEBUG | 
|---|
| 156 | #define verify(X) X | 
|---|
| 157 | #else | 
|---|
| 158 | #define verify(X) vcos_assert(X) | 
|---|
| 159 | #endif | 
|---|
| 160 | #define UNREACHABLE() vcos_assert(0) | 
|---|
| 161 |  | 
|---|
| 162 | #ifdef _MSC_VER | 
|---|
| 163 | #define UNUSED(X) X | 
|---|
| 164 | #else | 
|---|
| 165 | #define UNUSED(X) (void)(X) | 
|---|
| 166 | #endif | 
|---|
| 167 |  | 
|---|
| 168 | #define UNUSED_NDEBUG(X) UNUSED(X) | 
|---|
| 169 |  | 
|---|
| 170 | #define KHRN_NO_SEMAPHORE 0xffffffff | 
|---|
| 171 |  | 
|---|
| 172 | #ifdef __cplusplus | 
|---|
| 173 | } | 
|---|
| 174 | #endif | 
|---|
| 175 |  | 
|---|
| 176 | #endif | 
|---|
| 177 |  | 
|---|
| 178 |  | 
|---|