Home | History | Annotate | Download | only in libqdutils
      1 /*
      2  * Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * 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
     10  *       copyright notice, this list of conditions and the following
     11  *       disclaimer in the documentation and/or other materials provided
     12  *       with the distribution.
     13  *     * Neither the name of The Linux Foundation nor the names of its
     14  *       contributors may be used to endorse or promote products derived
     15  *       from this software without specific prior written permission.
     16  *
     17  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
     18  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
     20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
     21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     24  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     25  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     26  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
     27  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  */
     29 
     30 #ifndef _QDMETADATA_H
     31 #define _QDMETADATA_H
     32 
     33 #ifdef USE_COLOR_METADATA
     34 #include <color_metadata.h>
     35 #endif
     36 
     37 #ifdef __cplusplus
     38 extern "C" {
     39 #endif
     40 
     41 #define MAX_UBWC_STATS_LENGTH 32
     42 
     43 enum ColorSpace_t{
     44     ITU_R_601,
     45     ITU_R_601_FR,
     46     ITU_R_709,
     47     ITU_R_2020,
     48     ITU_R_2020_FR,
     49 };
     50 
     51 enum IGC_t {
     52     IGC_NotSpecified,
     53     IGC_sRGB,
     54 };
     55 
     56 struct HSICData_t {
     57     int32_t hue;
     58     float   saturation;
     59     int32_t intensity;
     60     float   contrast;
     61 };
     62 
     63 struct BufferDim_t {
     64     int32_t sliceWidth;
     65     int32_t sliceHeight;
     66 };
     67 
     68 enum UBWC_Version {
     69     UBWC_UNUSED      = 0,
     70     UBWC_1_0         = 0x1,
     71     UBWC_2_0         = 0x2,
     72     UBWC_MAX_VERSION = 0xFF,
     73 };
     74 
     75 struct UBWC_2_0_Stats {
     76     uint32_t nCRStatsTile32;  /**< UBWC Stats info for  32 Byte Tile */
     77     uint32_t nCRStatsTile64;  /**< UBWC Stats info for  64 Byte Tile */
     78     uint32_t nCRStatsTile96;  /**< UBWC Stats info for  96 Byte Tile */
     79     uint32_t nCRStatsTile128; /**< UBWC Stats info for 128 Byte Tile */
     80     uint32_t nCRStatsTile160; /**< UBWC Stats info for 160 Byte Tile */
     81     uint32_t nCRStatsTile192; /**< UBWC Stats info for 192 Byte Tile */
     82     uint32_t nCRStatsTile256; /**< UBWC Stats info for 256 Byte Tile */
     83 };
     84 
     85 struct UBWCStats {
     86     enum UBWC_Version version; /* Union depends on this version. */
     87     uint8_t bDataValid;      /* If [non-zero], CR Stats data is valid.
     88                                * Consumers may use stats data.
     89                                * If [zero], CR Stats data is invalid.
     90                                * Consumers *Shall* not use stats data */
     91     union {
     92         struct UBWC_2_0_Stats ubwc_stats;
     93         uint32_t reserved[MAX_UBWC_STATS_LENGTH]; /* This is for future */
     94     };
     95 };
     96 
     97 struct S3DGpuComp_t {
     98     int32_t displayId; /* on which display S3D is composed by client */
     99     uint32_t s3dMode; /* the S3D format of this layer to be accessed by client */
    100 };
    101 
    102 struct MetaData_t {
    103     int32_t operation;
    104     int32_t interlaced;
    105     struct BufferDim_t bufferDim;
    106     float refreshrate;
    107     enum ColorSpace_t colorSpace;
    108     enum IGC_t igc;
    109      /* Gralloc sets PRIV_SECURE_BUFFER flag to inform that the buffers are from
    110       * ION_SECURE. which should not be mapped. However, for GPU post proc
    111       * feature, GFX needs to map this buffer, in the client context and in SF
    112       * context, it should not. Hence to differentiate, add this metadata field
    113       * for clients to set, and GPU will to read and know when to map the
    114       * SECURE_BUFFER(ION) */
    115     int32_t mapSecureBuffer;
    116     /* The supported formats are defined in gralloc_priv.h to
    117      * support legacy code*/
    118     uint32_t s3dFormat;
    119     /* VENUS output buffer is linear for UBWC Interlaced video */
    120     uint32_t linearFormat;
    121     /* Set by graphics to indicate that this buffer will be written to but not
    122      * swapped out */
    123     uint32_t isSingleBufferMode;
    124     /* Indicate GPU to draw S3D layer on dedicate display device */
    125     struct S3DGpuComp_t s3dComp;
    126 
    127     /* Set by camera to program the VT Timestamp */
    128     uint64_t vtTimeStamp;
    129 #ifdef USE_COLOR_METADATA
    130     /* Color Aspects + HDR info */
    131     ColorMetaData color;
    132 #endif
    133     /* Consumer should read this data as follows based on
    134      * Gralloc flag "interlaced" listed above.
    135      * [0] : If it is progressive.
    136      * [0] : Top field, if it is interlaced.
    137      * [1] : Do not read, if it is progressive.
    138      * [1] : Bottom field, if it is interlaced.
    139      */
    140     struct UBWCStats ubwcCRStats[2];
    141 };
    142 
    143 enum DispParamType {
    144     SET_VT_TIMESTAMP         = 0x0001,
    145     COLOR_METADATA           = 0x0002,
    146     PP_PARAM_INTERLACED      = 0x0004,
    147     UNUSED2                  = 0x0008,
    148     UNUSED3                  = 0x0010,
    149     UNUSED4                  = 0x0020,
    150     SET_UBWC_CR_STATS_INFO   = 0x0040,
    151     UPDATE_BUFFER_GEOMETRY   = 0x0080,
    152     UPDATE_REFRESH_RATE      = 0x0100,
    153     UPDATE_COLOR_SPACE       = 0x0200,
    154     MAP_SECURE_BUFFER        = 0x0400,
    155     S3D_FORMAT               = 0x0800,
    156     LINEAR_FORMAT            = 0x1000,
    157     SET_IGC                  = 0x2000,
    158     SET_SINGLE_BUFFER_MODE   = 0x4000,
    159     SET_S3D_COMP             = 0x8000,
    160 };
    161 
    162 enum DispFetchParamType {
    163     GET_VT_TIMESTAMP         = 0x0001,
    164     GET_COLOR_METADATA       = 0x0002,
    165     GET_PP_PARAM_INTERLACED  = 0x0004,
    166     GET_UBWC_CR_STATS_INFO   = 0x0040,
    167     GET_BUFFER_GEOMETRY      = 0x0080,
    168     GET_REFRESH_RATE         = 0x0100,
    169     GET_COLOR_SPACE          = 0x0200,
    170     GET_MAP_SECURE_BUFFER    = 0x0400,
    171     GET_S3D_FORMAT           = 0x0800,
    172     GET_LINEAR_FORMAT        = 0x1000,
    173     GET_IGC                  = 0x2000,
    174     GET_SINGLE_BUFFER_MODE   = 0x4000,
    175     GET_S3D_COMP             = 0x8000,
    176 };
    177 
    178 struct private_handle_t;
    179 int setMetaData(struct private_handle_t *handle, enum DispParamType paramType,
    180                 void *param);
    181 int setMetaDataVa(struct MetaData_t* data, enum DispParamType paramType,
    182                   void *param);
    183 
    184 int getMetaData(struct private_handle_t *handle,
    185                 enum DispFetchParamType paramType,
    186                 void *param);
    187 int getMetaDataVa(struct MetaData_t* data, enum DispFetchParamType paramType,
    188                   void *param);
    189 
    190 int copyMetaData(struct private_handle_t *src, struct private_handle_t *dst);
    191 int copyMetaDataVaToHandle(struct MetaData_t *src, struct private_handle_t *dst);
    192 int copyMetaDataHandleToVa(struct private_handle_t* src, struct MetaData_t *dst);
    193 int copyMetaDataVaToVa(struct MetaData_t *src, struct MetaData_t *dst);
    194 
    195 int clearMetaData(struct private_handle_t *handle, enum DispParamType paramType);
    196 int clearMetaDataVa(struct MetaData_t *data, enum DispParamType paramType);
    197 
    198 unsigned long getMetaDataSize();
    199 
    200 #ifdef __cplusplus
    201 }
    202 #endif
    203 
    204 #endif /* _QDMETADATA_H */
    205 
    206