| 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 WFC_INT_H |
| 29 | #define WFC_INT_H |
| 30 | |
| 31 | #include "interface/khronos/include/WF/wfc.h" |
| 32 | |
| 33 | //!@file wfc.h |
| 34 | //!@brief Standard OpenWF-C header file. Available from the |
| 35 | //! <a href="http://www.khronos.org/registry/wf/">Khronos OpenWF API Registry</a>. |
| 36 | |
| 37 | //============================================================================== |
| 38 | |
| 39 | //! Only valid value for attribute list (as of WF-C v1.0) |
| 40 | #define NO_ATTRIBUTES NULL |
| 41 | |
| 42 | //!@name |
| 43 | //! Values for rectangle types |
| 44 | //!@{ |
| 45 | #define WFC_RECT_X 0 |
| 46 | #define WFC_RECT_Y 1 |
| 47 | #define WFC_RECT_WIDTH 2 |
| 48 | #define WFC_RECT_HEIGHT 3 |
| 49 | |
| 50 | #define WFC_RECT_SIZE 4 |
| 51 | //!@} |
| 52 | |
| 53 | //!@name |
| 54 | //! Values for context background colour |
| 55 | //!@{ |
| 56 | #define WFC_BG_CLR_RED 0 |
| 57 | #define WFC_BG_CLR_GREEN 1 |
| 58 | #define WFC_BG_CLR_BLUE 2 |
| 59 | #define WFC_BG_CLR_ALPHA 3 |
| 60 | |
| 61 | #define WFC_BG_CLR_SIZE 4 |
| 62 | //!@} |
| 63 | |
| 64 | //============================================================================== |
| 65 | |
| 66 | //! Attributes associated with each element |
| 67 | typedef struct |
| 68 | { |
| 69 | WFCint dest_rect[WFC_RECT_SIZE];//< The destination region of the element in the context |
| 70 | WFCfloat src_rect[WFC_RECT_SIZE];//< The region of the source to be mapped to the destination |
| 71 | WFCboolean flip; //< If WFC_TRUE, the source is flipped about a horizontal axis through its centre |
| 72 | WFCRotation rotation; //< The rotation of the source, see WFCRotation |
| 73 | WFCScaleFilter scale_filter; //< The scaling filter, see WFCScaleFilter |
| 74 | WFCbitfield transparency_types; //< A combination of transparency types, see WFCTransparencyType |
| 75 | WFCfloat global_alpha; //< The global alpha for the element, if WFC_TRANSPARENCY_ELEMENT_GLOBAL_ALPHA is set |
| 76 | WFCNativeStreamType source_stream; //< The source stream handle or WFC_INVALID_HANDLE |
| 77 | WFCNativeStreamType mask_stream; //< The mask stream handle or WFC_INVALID_HANDLE |
| 78 | } WFC_ELEMENT_ATTRIB_T; |
| 79 | |
| 80 | //! Default values for elements |
| 81 | #define WFC_ELEMENT_ATTRIB_DEFAULT \ |
| 82 | { \ |
| 83 | {0, 0, 0, 0}, \ |
| 84 | {0.0, 0.0, 0.0, 0.0}, \ |
| 85 | WFC_FALSE, \ |
| 86 | WFC_ROTATION_0, \ |
| 87 | WFC_SCALE_FILTER_NONE, \ |
| 88 | WFC_TRANSPARENCY_NONE, \ |
| 89 | 1.0, \ |
| 90 | WFC_INVALID_HANDLE, \ |
| 91 | WFC_INVALID_HANDLE \ |
| 92 | } |
| 93 | |
| 94 | //! Attributes associated with a context which are fixed on creation |
| 95 | typedef struct |
| 96 | { |
| 97 | WFCContextType type; //!< The context type, either on- or off-screen |
| 98 | WFCint width; //!< The width of the context |
| 99 | WFCint height; //!< The height of the context |
| 100 | } WFC_CONTEXT_STATIC_ATTRIB_T; |
| 101 | |
| 102 | //! Default static values for contexts |
| 103 | #define WFC_CONTEXT_STATIC_ATTRIB_DEFAULT \ |
| 104 | { \ |
| 105 | WFC_CONTEXT_TYPE_ON_SCREEN, \ |
| 106 | 0, 0, \ |
| 107 | } |
| 108 | |
| 109 | // Attributes associated with a context that may change |
| 110 | typedef struct |
| 111 | { |
| 112 | WFCRotation rotation; //< The rotation to be applied to the whole context |
| 113 | WFCfloat background_clr[WFC_BG_CLR_SIZE]; //< The background colour of the context, in order RGBA, scaled from 0 to 1 |
| 114 | } WFC_CONTEXT_DYNAMIC_ATTRIB_T; |
| 115 | |
| 116 | //! Default dynamic values for contexts |
| 117 | #define WFC_CONTEXT_DYNAMIC_ATTRIB_DEFAULT \ |
| 118 | { \ |
| 119 | WFC_ROTATION_0, \ |
| 120 | {0.0, 0.0, 0.0, 1.0} \ |
| 121 | } |
| 122 | |
| 123 | //! Arbitrary maximum number of elements per scene |
| 124 | #define WFC_MAX_ELEMENTS_IN_SCENE 8 |
| 125 | |
| 126 | //! Arbitrary maximum number of WFC stream ids per client |
| 127 | #define WFC_MAX_STREAMS_PER_CLIENT 128 |
| 128 | |
| 129 | //! Data for a "scene" (i.e. context and element data associated with a commit). |
| 130 | typedef struct |
| 131 | { |
| 132 | WFC_CONTEXT_DYNAMIC_ATTRIB_T context; //!< Dynamic attributes for this scene's context |
| 133 | uint32_t commit_count; //!< Count of the scenes committed for this context |
| 134 | uint32_t element_count; //!< Number of elements to be committed |
| 135 | WFC_ELEMENT_ATTRIB_T elements[WFC_MAX_ELEMENTS_IN_SCENE]; //!< Attributes of committed elements |
| 136 | } WFC_SCENE_T; |
| 137 | |
| 138 | //definitions moved from wfc_server_stream.h so can be included on client |
| 139 | |
| 140 | typedef enum |
| 141 | { |
| 142 | WFC_IMAGE_NO_FLAGS = 0, |
| 143 | WFC_IMAGE_FLIP_VERT = (1 << 0), //< Vertically flip image |
| 144 | WFC_IMAGE_DISP_NOTHING = (1 << 1), //< Display nothing on screen |
| 145 | WFC_IMAGE_CB_ON_NO_CHANGE = (1 << 2), //< Callback, even if the image is the same |
| 146 | WFC_IMAGE_CB_ON_COMPOSE = (1 << 3), //< Callback on composition, instead of when not in use |
| 147 | WFC_IMAGE_PROTECTION_HDCP = (1 << 4), //< HDCP required if output to HDMI display |
| 148 | WFC_IMAGE_FLIP_HORZ = (1 << 5), //< Horizontally flip image |
| 149 | WFC_IMAGE_SENTINEL = 0x7FFFFFFF |
| 150 | } WFC_IMAGE_FLAGS_T; |
| 151 | |
| 152 | //! Define the type of generic WFC image |
| 153 | typedef enum |
| 154 | { |
| 155 | WFC_STREAM_IMAGE_TYPE_OPAQUE = 0, //< Handle to a multimedia opaque image |
| 156 | WFC_STREAM_IMAGE_TYPE_RAW, //< Handle to a raw pixel buffer in shared memory |
| 157 | WFC_STREAM_IMAGE_TYPE_EGL, //< Handle to an EGL storage |
| 158 | |
| 159 | WFC_STREAM_IMAGE_TYPE_SENTINEL = 0x7FFFFFFF |
| 160 | } WFC_STREAM_IMAGE_TYPE_T; |
| 161 | |
| 162 | //! DRM protection attributes for an image. Currently tis just maps to |
| 163 | //! WFC_IMAGE_PROTECTION_HDCP and DISPMANX_PROTECTION_HDCP but in future |
| 164 | //! could contain other options e.g. to down-sample output. |
| 165 | typedef enum |
| 166 | { |
| 167 | WFC_PROTECTION_NONE = 0, //< Image is unprotected |
| 168 | WFC_PROTECTION_HDCP = (1 << 0), //< HDCP required if output to HDMI display |
| 169 | |
| 170 | WFC_PROTECTION_SENTINEL = 0x7FFFFFFF |
| 171 | } WFC_PROTECTION_FLAGS_T; |
| 172 | |
| 173 | //! Horizontal and vertical flip combinations |
| 174 | typedef enum |
| 175 | { |
| 176 | WFC_STREAM_IMAGE_FLIP_NONE = 0, //< No flip |
| 177 | WFC_STREAM_IMAGE_FLIP_VERT, //< Vertical flip only |
| 178 | WFC_STREAM_IMAGE_FLIP_HORZ, //< Horizontal flip only |
| 179 | WFC_STREAM_IMAGE_FLIP_BOTH, //< Horizontal and vertical flip (180 degree rotation) |
| 180 | |
| 181 | WFC_STREAM_IMAGE_FLIP_SENTINEL = 0x7FFFFFFF |
| 182 | } WFC_STREAM_IMAGE_FLIP_T; |
| 183 | |
| 184 | //! Describes a generic buffer on the reloctable heap. |
| 185 | typedef struct |
| 186 | { |
| 187 | uint32_t length; //< The size of the structure passed in the message. Used for versioning. |
| 188 | WFC_STREAM_IMAGE_TYPE_T type; //< The type of the image buffer e.g. opaque. |
| 189 | uint32_t handle; //< The relocatable heap handle for the buffer |
| 190 | uint32_t width; //< Width of the image in pixels |
| 191 | uint32_t height; //< Height of the image in pixels |
| 192 | uint32_t format; //< The pixel format. Specific to type. |
| 193 | uint32_t pitch; //< The horizontal pitch of the image in bytes |
| 194 | uint32_t vpitch; //< The vertical pitch of the image in rows. Zero implies vpitch == height |
| 195 | WFC_PROTECTION_FLAGS_T protection; //< DRM protection |
| 196 | uint32_t offset; //< The starting offset within the heap handle for the buffer |
| 197 | uint32_t flags; //< Type-specific flags associated with the buffer |
| 198 | WFC_STREAM_IMAGE_FLIP_T flip; //< Flips to apply to the buffer for display |
| 199 | } WFC_STREAM_IMAGE_T; |
| 200 | |
| 201 | |
| 202 | //============================================================================== |
| 203 | // VideoCore-specific definitions |
| 204 | //============================================================================== |
| 205 | |
| 206 | //!@name |
| 207 | //! VideoCore standard display identifiers (c.f. vc_dispmanx_types.h). |
| 208 | //!@{ |
| 209 | #define WFC_ID_MAIN_LCD 0 |
| 210 | #define WFC_ID_AUX_LCD 1 |
| 211 | #define WFC_ID_HDMI 2 |
| 212 | #define WFC_ID_SDTV 3 |
| 213 | |
| 214 | #define WFC_ID_MAX_SCREENS 3 |
| 215 | //!@} |
| 216 | |
| 217 | //------------------------------------------------------------------------------ |
| 218 | // Non-standard definitions |
| 219 | |
| 220 | //!@brief WF-C assumes that images are pre-multiplied prior to blending. However, we |
| 221 | //! need to handle non-pre-multiplied ones. |
| 222 | #define WFC_TRANSPARENCY_SOURCE_VC_NON_PRE_MULT (1 << 31) |
| 223 | |
| 224 | //!@brief Raw pixel formats supported by the server |
| 225 | typedef enum |
| 226 | { |
| 227 | WFC_PIXEL_FORMAT_NONE, |
| 228 | WFC_PIXEL_FORMAT_YVU420PLANAR, |
| 229 | WFC_PIXEL_FORMAT_YUV420PLANAR, |
| 230 | WFC_PIXEL_FORMAT_FORCE_32BIT = 0x7FFFFFFF |
| 231 | } WFC_PIXEL_FORMAT_T; |
| 232 | |
| 233 | |
| 234 | |
| 235 | //------------------------------------------------------------------------------ |
| 236 | // Non-standard functions |
| 237 | |
| 238 | void wfc_set_deferral_stream(WFCDevice dev, WFCContext ctx, WFCNativeStreamType stream); |
| 239 | |
| 240 | //============================================================================== |
| 241 | |
| 242 | // Callback function types. |
| 243 | |
| 244 | /** Called when the buffer of a stream is no longer in use. |
| 245 | * |
| 246 | * @param The client stream handle. |
| 247 | * @param The value passed in when the buffer was set as the front buffer. |
| 248 | */ |
| 249 | typedef void (*WFC_SERVER_STREAM_CALLBACK_T)(WFCNativeStreamType stream, void *cb_data); |
| 250 | |
| 251 | //============================================================================== |
| 252 | |
| 253 | #endif /* WFC_INT_H */ |
| 254 | |