layer_buffer.h revision d68a2e45260f864503d7bd6da93fd29589afd89e
1/* 2* Copyright (c) 2014, The Linux Foundation. All rights reserved. 3* 4* Redistribution and use in source and binary forms, with or without modification, are permitted 5* provided that the following conditions are met: 6* * Redistributions of source code must retain the above copyright notice, this list of 7* conditions and the following disclaimer. 8* * Redistributions in binary form must reproduce the above copyright notice, this list of 9* conditions and the following disclaimer in the documentation and/or other materials provided 10* with the distribution. 11* * Neither the name of The Linux Foundation nor the names of its contributors may be used to 12* endorse or promote products derived from this software without specific prior written 13* permission. 14* 15* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 18* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 19* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 21* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23*/ 24 25/*! @file layer_buffer.h 26 @brief File for layer buffer structure. 27 28*/ 29#ifndef __LAYER_BUFFER_H__ 30#define __LAYER_BUFFER_H__ 31 32#include <stdint.h> 33 34#include "sdm_types.h" 35 36namespace sdm { 37 38/*! @brief This enum represents different buffer formats supported by display manager. 39 40 @sa LayerBuffer 41*/ 42enum LayerBufferFormat { 43 /* All RGB formats, Any new format will be added towards end of this group to maintain backward 44 compatibility. 45 */ 46 kFormatARGB8888, //!< 8-bits Alpha, Red, Green, Blue interleaved in ARGB order. 47 kFormatRGBA8888, //!< 8-bits Red, Green, Blue, Alpha interleaved in RGBA order. 48 kFormatBGRA8888, //!< 8-bits Blue, Green, Red, Alpha interleaved in BGRA order. 49 kFormatXRGB8888, //!< 8-bits Padding, Red, Green, Blue interleaved in XRGB order. No Alpha. 50 kFormatRGBX8888, //!< 8-bits Red, Green, Blue, Padding interleaved in RGBX order. No Alpha. 51 kFormatBGRX8888, //!< 8-bits Blue, Green, Red, Padding interleaved in BGRX order. No Alpha. 52 kFormatRGBA5551, //!< 5-bits Red, Green, Blue, and 1 bit Alpha interleaved in RGBA order. 53 kFormatRGBA4444, //!< 4-bits Red, Green, Blue, Alpha interleaved in RGBA order. 54 kFormatRGB888, //!< 8-bits Red, Green, Blue interleaved in RGB order. No Alpha. 55 kFormatBGR888, //!< 8-bits Blue, Green, Red interleaved in BGR order. No Alpha. 56 kFormatRGB565, //!< 5-bit Red, 6-bit Green, 5-bit Blue interleaved in RGB order. No Alpha. 57 kFormatBGR565, //!< 5-bit Blue, 6-bit Green, 5-bit Red interleaved in BGR order. No Alpha. 58 kFormatRGBA8888Ubwc, //!< UBWC aligned RGBA8888 format 59 kFormatRGBX8888Ubwc, //!< UBWC aligned RGBX8888 format 60 kFormatBGR565Ubwc, //!< UBWC aligned BGR565 format 61 62 /* All YUV-Planar formats, Any new format will be added towards end of this group to maintain 63 backward compatibility. 64 */ 65 kFormatYCbCr420Planar = 0x100, //!< Y-plane: y(0), y(1), y(2) ... y(n) 66 //!< 2x2 subsampled U-plane: u(0), u(2) ... u(n-1) 67 //!< 2x2 subsampled V-plane: v(0), v(2) ... v(n-1) 68 69 kFormatYCrCb420Planar, //!< Y-plane: y(0), y(1), y(2) ... y(n) 70 //!< 2x2 subsampled V-plane: v(0), v(2) ... v(n-1) 71 //!< 2x2 subsampled U-plane: u(0), u(2) ... u(n-1) 72 73 kFormatYCrCb420PlanarStride16, //!< kFormatYCrCb420Planar with stride aligned to 16 bytes 74 75 /* All YUV-Semiplanar formats, Any new format will be added towards end of this group to 76 maintain backward compatibility. 77 */ 78 kFormatYCbCr420SemiPlanar = 0x200, //!< Y-plane: y(0), y(1), y(2) ... y(n) 79 //!< 2x2 subsampled interleaved UV-plane: 80 //!< u(0), v(0), u(2), v(2) ... u(n-1), v(n-1) 81 //!< aka NV12. 82 83 kFormatYCrCb420SemiPlanar, //!< Y-plane: y(0), y(1), y(2) ... y(n) 84 //!< 2x2 subsampled interleaved VU-plane: 85 //!< v(0), u(0), v(2), u(2) ... v(n-1), u(n-1) 86 //!< aka NV21. 87 88 kFormatYCbCr420SemiPlanarVenus, //!< Y-plane: y(0), y(1), y(2) ... y(n) 89 //!< 2x2 subsampled interleaved UV-plane: 90 //!< u(0), v(0), u(2), v(2) ... u(n-1), v(n-1) 91 92 kFormatYCbCr422H1V2SemiPlanar, //!< Y-plane: y(0), y(1), y(2) ... y(n) 93 //!< vertically subsampled interleaved UV-plane: 94 //!< u(0), v(1), u(2), v(3) ... u(n-1), v(n) 95 96 kFormatYCrCb422H1V2SemiPlanar, //!< Y-plane: y(0), y(1), y(2) ... y(n) 97 //!< vertically subsampled interleaved VU-plane: 98 //!< v(0), u(1), v(2), u(3) ... v(n-1), u(n) 99 100 kFormatYCbCr422H2V1SemiPlanar, //!< Y-plane: y(0), y(1), y(2) ... y(n) 101 //!< horizontally subsampled interleaved UV-plane: 102 //!< u(0), v(1), u(2), v(3) ... u(n-1), v(n) 103 104 kFormatYCrCb422H2V1SemiPlanar, //!< Y-plane: y(0), y(1), y(2) ... y(n) 105 //!< horizontally subsampled interleaved VU-plane: 106 //!< v(0), u(1), v(2), u(3) ... v(n-1), u(n) 107 108 kFormatYCbCr420SPVenusUbwc, //!< UBWC aligned YCbCr420SemiPlanarVenus format 109 110 /* All YUV-Packed formats, Any new format will be added towards end of this group to maintain 111 backward compatibility. 112 */ 113 kFormatYCbCr422H2V1Packed = 0x300, //!< Y-plane interleaved with horizontally subsampled U/V by 114 //!< factor of 2 115 //!< y(0), u(0), y(1), v(0), y(2), u(2), y(3), v(2) 116 //!< y(n-1), u(n-1), y(n), v(n-1) 117 118 kFormatInvalid = 0xFFFFFFFF, 119}; 120 121/*! @brief This structure defines a color sample plane belonging to a buffer format. RGB buffer 122 formats have 1 plane whereas YUV buffer formats may have upto 4 planes. 123 124 @sa LayerBuffer 125*/ 126struct LayerBufferPlane { 127 int fd = -1; //!< File descriptor referring to the buffer associated with this plane. 128 uint32_t offset = 0; //!< Offset of the plane in bytes from beginning of the buffer. 129 uint32_t stride = 0; //!< Stride in bytes i.e. length of a scanline including padding. 130}; 131 132/*! @brief This structure defines flags associated with a layer buffer. The 1-bit flag can be set 133 to ON(1) or OFF(0). 134 135 @sa LayerBuffer 136*/ 137struct LayerBufferFlags { 138 union { 139 struct { 140 uint32_t secure : 1; //!< This flag shall be set by client to indicate that the 141 //!< buffer need to be handled securely. 142 143 uint32_t video : 1; //!< This flag shall be set by client to indicate that the 144 //!< buffer is video/ui buffer. 145 146 uint32_t macro_tile : 1; //!< This flag shall be set by client to indicate that the 147 //!< buffer format is macro tiled. 148 149 uint32_t interlace : 1; //!< This flag shall be set by the client to indicate that 150 //!< the buffer has interlaced content. 151 152 uint32_t secure_display : 1; 153 //!< This flag shall be set by the client to indicate that the 154 //!< secure display session is in progress. Secure display 155 //!< session can not coexist with non-secure session. 156 }; 157 158 uint32_t flags = 0; //!< For initialization purpose only. 159 //!< Client shall not refer to it directly. 160 }; 161}; 162 163/*! @brief This structure defines a layer buffer handle which contains raw buffer and its associated 164 properties. 165 166 @sa LayerBuffer 167 @sa LayerStack 168*/ 169struct LayerBuffer { 170 uint32_t width = 0; //!< Actual width of the Layer that this buffer is for. 171 uint32_t height = 0; //!< Actual height of the Layer that this buffer is for. 172 LayerBufferFormat format = kFormatRGBA8888; //!< Format of the buffer content. 173 LayerBufferPlane planes[4]; //!< Array of planes that this buffer contains. RGB buffer formats 174 //!< have 1 plane whereas YUV buffer formats may have upto 4 planes. 175 //!< Total number of planes for the buffer will be interpreted based 176 //!< on the buffer format specified. 177 178 int acquire_fence_fd = -1; //!< File descriptor referring to a sync fence object which will be 179 //!< signaled when buffer can be read/write by display manager. 180 //!< This fence object is set by the client during Commit(). For 181 //!< input buffers client shall signal this fence when buffer 182 //!< content is available and can be read by display manager. For 183 //!< output buffers, client shall signal fence when buffer is ready 184 //!< to be written by display manager. 185 186 //!< This field is used only during Commit() and shall be set to -1 187 //!< by the client when buffer is already available for read/write. 188 189 int release_fence_fd = -1; //!< File descriptor referring to a sync fence object which will be 190 //!< signaled when buffer has been read/written by display manager. 191 //!< This fence object is set by display manager during Commit(). 192 //!< For input buffers display manager will signal this fence when 193 //!< buffer has been consumed. For output buffers, display manager 194 //!< will signal this fence when buffer is produced. 195 196 //!< This field is used only during Commit() and will be set to -1 197 //!< by display manager when buffer is already available for 198 //!< read/write. 199 200 LayerBufferFlags flags; //!< Flags associated with this buffer. 201}; 202 203} // namespace sdm 204 205#endif // __LAYER_BUFFER_H__ 206 207