| 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 | // Typedefs and enums for the VideoCore III Display Manager |
| 29 | |
| 30 | #ifndef _DISPMANX_TYPES_H |
| 31 | #define _DISPMANX_TYPES_H |
| 32 | |
| 33 | #include "interface/vctypes/vc_image_types.h" |
| 34 | #include "interface/vctypes/vc_display_types.h" |
| 35 | |
| 36 | #define VC_DISPMANX_VERSION 1 |
| 37 | |
| 38 | /* Opaque handles */ |
| 39 | typedef uint32_t DISPMANX_DISPLAY_HANDLE_T; |
| 40 | typedef uint32_t DISPMANX_UPDATE_HANDLE_T; |
| 41 | typedef uint32_t DISPMANX_ELEMENT_HANDLE_T; |
| 42 | typedef uint32_t DISPMANX_RESOURCE_HANDLE_T; |
| 43 | |
| 44 | typedef uint32_t DISPMANX_PROTECTION_T; |
| 45 | |
| 46 | #define DISPMANX_NO_HANDLE 0 |
| 47 | |
| 48 | #define DISPMANX_PROTECTION_MAX 0x0f |
| 49 | #define DISPMANX_PROTECTION_NONE 0 |
| 50 | #define DISPMANX_PROTECTION_HDCP 11 // Derived from the WM DRM levels, 101-300 |
| 51 | |
| 52 | |
| 53 | |
| 54 | /* Default display IDs. |
| 55 | Note: if you overwrite with your own dispmanx_platform_init function, you |
| 56 | should use IDs you provided during dispmanx_display_attach. |
| 57 | */ |
| 58 | #define DISPMANX_ID_MAIN_LCD 0 |
| 59 | #define DISPMANX_ID_AUX_LCD 1 |
| 60 | #define DISPMANX_ID_HDMI0 2 |
| 61 | // deprecated, but support for backwards compatibility |
| 62 | #define DISPMANX_ID_HDMI DISPMANX_ID_HDMI0 |
| 63 | #define DISPMANX_ID_SDTV 3 |
| 64 | #define DISPMANX_ID_FORCE_LCD 4 |
| 65 | #define DISPMANX_ID_FORCE_TV 5 |
| 66 | #define DISPMANX_ID_FORCE_OTHER 6 /* non-default display */ |
| 67 | #define DISPMANX_ID_HDMI1 7 |
| 68 | #define DISPMANX_ID_FORCE_TV2 8 |
| 69 | |
| 70 | #define DISPMANX_ID_MAX DISPMANX_ID_FORCE_TV2 // should always be the last on. |
| 71 | |
| 72 | /* Return codes. Nonzero ones indicate failure. */ |
| 73 | typedef enum { |
| 74 | DISPMANX_SUCCESS = 0, |
| 75 | DISPMANX_INVALID = -1 |
| 76 | /* XXX others TBA */ |
| 77 | } DISPMANX_STATUS_T; |
| 78 | |
| 79 | typedef enum { |
| 80 | /* Bottom 2 bits sets the orientation */ |
| 81 | DISPMANX_NO_ROTATE = 0, |
| 82 | DISPMANX_ROTATE_90 = 1, |
| 83 | DISPMANX_ROTATE_180 = 2, |
| 84 | DISPMANX_ROTATE_270 = 3, |
| 85 | |
| 86 | DISPMANX_FLIP_HRIZ = 1 << 16, |
| 87 | DISPMANX_FLIP_VERT = 1 << 17, |
| 88 | |
| 89 | /* invert left/right images */ |
| 90 | DISPMANX_STEREOSCOPIC_INVERT = 1 << 19, |
| 91 | /* extra flags for controlling 3d duplication behaviour */ |
| 92 | DISPMANX_STEREOSCOPIC_NONE = 0 << 20, |
| 93 | DISPMANX_STEREOSCOPIC_MONO = 1 << 20, |
| 94 | DISPMANX_STEREOSCOPIC_SBS = 2 << 20, |
| 95 | DISPMANX_STEREOSCOPIC_TB = 3 << 20, |
| 96 | DISPMANX_STEREOSCOPIC_MASK = 15 << 20, |
| 97 | |
| 98 | /* extra flags for controlling snapshot behaviour */ |
| 99 | DISPMANX_SNAPSHOT_NO_YUV = 1 << 24, |
| 100 | DISPMANX_SNAPSHOT_NO_RGB = 1 << 25, |
| 101 | DISPMANX_SNAPSHOT_FILL = 1 << 26, |
| 102 | DISPMANX_SNAPSHOT_SWAP_RED_BLUE = 1 << 27, |
| 103 | DISPMANX_SNAPSHOT_PACK = 1 << 28 |
| 104 | } DISPMANX_TRANSFORM_T; |
| 105 | |
| 106 | typedef enum { |
| 107 | /* Bottom 2 bits sets the alpha mode */ |
| 108 | DISPMANX_FLAGS_ALPHA_FROM_SOURCE = 0, |
| 109 | DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS = 1, |
| 110 | DISPMANX_FLAGS_ALPHA_FIXED_NON_ZERO = 2, |
| 111 | DISPMANX_FLAGS_ALPHA_FIXED_EXCEED_0X07 = 3, |
| 112 | |
| 113 | DISPMANX_FLAGS_ALPHA_PREMULT = 1 << 16, |
| 114 | DISPMANX_FLAGS_ALPHA_MIX = 1 << 17, |
| 115 | DISPMANX_FLAGS_ALPHA_DISCARD_LOWER_LAYERS = 1 << 18, |
| 116 | } DISPMANX_FLAGS_ALPHA_T; |
| 117 | |
| 118 | typedef struct { |
| 119 | DISPMANX_FLAGS_ALPHA_T flags; |
| 120 | uint32_t opacity; |
| 121 | VC_IMAGE_T *mask; |
| 122 | } DISPMANX_ALPHA_T; |
| 123 | |
| 124 | typedef struct { |
| 125 | DISPMANX_FLAGS_ALPHA_T flags; |
| 126 | uint32_t opacity; |
| 127 | DISPMANX_RESOURCE_HANDLE_T mask; |
| 128 | } VC_DISPMANX_ALPHA_T; /* for use with vmcs_host */ |
| 129 | |
| 130 | typedef enum { |
| 131 | DISPMANX_FLAGS_CLAMP_NONE = 0, |
| 132 | DISPMANX_FLAGS_CLAMP_LUMA_TRANSPARENT = 1, |
| 133 | #if __VCCOREVER__ >= 0x04000000 |
| 134 | DISPMANX_FLAGS_CLAMP_TRANSPARENT = 2, |
| 135 | DISPMANX_FLAGS_CLAMP_REPLACE = 3 |
| 136 | #else |
| 137 | DISPMANX_FLAGS_CLAMP_CHROMA_TRANSPARENT = 2, |
| 138 | DISPMANX_FLAGS_CLAMP_TRANSPARENT = 3 |
| 139 | #endif |
| 140 | } DISPMANX_FLAGS_CLAMP_T; |
| 141 | |
| 142 | typedef enum { |
| 143 | DISPMANX_FLAGS_KEYMASK_OVERRIDE = 1, |
| 144 | DISPMANX_FLAGS_KEYMASK_SMOOTH = 1 << 1, |
| 145 | DISPMANX_FLAGS_KEYMASK_CR_INV = 1 << 2, |
| 146 | DISPMANX_FLAGS_KEYMASK_CB_INV = 1 << 3, |
| 147 | DISPMANX_FLAGS_KEYMASK_YY_INV = 1 << 4 |
| 148 | } DISPMANX_FLAGS_KEYMASK_T; |
| 149 | |
| 150 | typedef union { |
| 151 | struct { |
| 152 | uint8_t yy_upper; |
| 153 | uint8_t yy_lower; |
| 154 | uint8_t cr_upper; |
| 155 | uint8_t cr_lower; |
| 156 | uint8_t cb_upper; |
| 157 | uint8_t cb_lower; |
| 158 | } yuv; |
| 159 | struct { |
| 160 | uint8_t red_upper; |
| 161 | uint8_t red_lower; |
| 162 | uint8_t blue_upper; |
| 163 | uint8_t blue_lower; |
| 164 | uint8_t green_upper; |
| 165 | uint8_t green_lower; |
| 166 | } rgb; |
| 167 | } DISPMANX_CLAMP_KEYS_T; |
| 168 | |
| 169 | typedef struct { |
| 170 | DISPMANX_FLAGS_CLAMP_T mode; |
| 171 | DISPMANX_FLAGS_KEYMASK_T key_mask; |
| 172 | DISPMANX_CLAMP_KEYS_T key_value; |
| 173 | uint32_t replace_value; |
| 174 | } DISPMANX_CLAMP_T; |
| 175 | |
| 176 | typedef struct { |
| 177 | int32_t width; |
| 178 | int32_t height; |
| 179 | DISPMANX_TRANSFORM_T transform; |
| 180 | DISPLAY_INPUT_FORMAT_T input_format; |
| 181 | uint32_t display_num; |
| 182 | } DISPMANX_MODEINFO_T; |
| 183 | |
| 184 | /* Update callback. */ |
| 185 | typedef void (*DISPMANX_CALLBACK_FUNC_T)(DISPMANX_UPDATE_HANDLE_T u, void * arg); |
| 186 | |
| 187 | /* Progress callback */ |
| 188 | typedef void (*DISPMANX_PROGRESS_CALLBACK_FUNC_T)(DISPMANX_UPDATE_HANDLE_T u, |
| 189 | uint32_t line, |
| 190 | void * arg); |
| 191 | |
| 192 | /* Pluggable display interface */ |
| 193 | |
| 194 | typedef struct tag_DISPMANX_DISPLAY_FUNCS_T { |
| 195 | // Get essential HVS configuration to be passed to the HVS driver. Options |
| 196 | // is any combination of the following flags: HVS_ONESHOT, HVS_FIFOREG, |
| 197 | // HVS_FIFO32, HVS_AUTOHSTART, HVS_INTLACE; and if HVS_FIFOREG, one of; |
| 198 | // { HVS_FMT_RGB888, HVS_FMT_RGB565, HVS_FMT_RGB666, HVS_FMT_YUV }. |
| 199 | int32_t (*get_hvs_config)(void *instance, uint32_t *pchan, |
| 200 | uint32_t *poptions, DISPLAY_INFO_T *info, |
| 201 | uint32_t *bg_colour, uint32_t *test_mode); |
| 202 | |
| 203 | // Get optional HVS configuration for gamma tables, OLED matrix and dither controls. |
| 204 | // Set these function pointers to NULL if the relevant features are not required. |
| 205 | int32_t (*get_gamma_params)(void * instance, |
| 206 | int32_t gain[3], int32_t offset[3], int32_t gamma[3]); |
| 207 | int32_t (*get_oled_params)(void * instance, uint32_t * poffsets, |
| 208 | uint32_t coeffs[3]); |
| 209 | int32_t (*get_dither)(void * instance, uint32_t * dither_depth, uint32_t * dither_type); |
| 210 | |
| 211 | // Get mode information, which may be returned to the applications as a courtesy. |
| 212 | // Transform should be set to 0, and {width,height} should be final dimensions. |
| 213 | int32_t (*get_info)(void * instance, DISPMANX_MODEINFO_T * info); |
| 214 | |
| 215 | // Inform driver that the application refcount has become nonzero / zero |
| 216 | // These callbacks might perhaps be used for backlight and power management. |
| 217 | int32_t (*open)(void * instance); |
| 218 | int32_t (*close)(void * instance); |
| 219 | |
| 220 | // Display list updated callback. Primarily of use to a "one-shot" display. |
| 221 | // For convenience of the driver, we pass the register address of the HVS FIFO. |
| 222 | void (*dlist_updated)(void * instance, volatile uint32_t * fifo_reg); |
| 223 | |
| 224 | // End-of-field callback. This may occur in an interrupt context. |
| 225 | void (*eof_callback)(void * instance); |
| 226 | |
| 227 | // Return screen resolution format |
| 228 | DISPLAY_INPUT_FORMAT_T (*get_input_format)(void * instance); |
| 229 | |
| 230 | int32_t (*suspend_resume)(void *instance, int up); |
| 231 | |
| 232 | DISPLAY_3D_FORMAT_T (*get_3d_format)(void * instance); |
| 233 | } DISPMANX_DISPLAY_FUNCS_T; |
| 234 | |
| 235 | #endif /* ifndef _DISPMANX_TYPES_H */ |
| 236 | |