Home | History | Annotate | Download | only in libcopybit
      1 /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
      2  *
      3  * Redistribution and use in source and binary forms, with or without
      4  * modification, are permitted provided that the following conditions are
      5  * met:
      6  *     * Redistributions of source code must retain the above copyright
      7  *       notice, this list of conditions and the following disclaimer.
      8  *     * Redistributions in binary form must reproduce the above
      9  *       copyright notice, this list of conditions and the following
     10  *       disclaimer in the documentation and/or other materials provided
     11  *       with the distribution.
     12  *     * Neither the name of The Linux Foundation. nor the names of its
     13  *       contributors may be used to endorse or promote products derived
     14  *       from this software without specific prior written permission.
     15  *
     16  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
     17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
     19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
     20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
     26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  *
     28  */
     29 
     30 #ifndef _C2DEXT_H_
     31 #define _C2DEXT_H_
     32 
     33 #ifdef __cplusplus
     34 extern "C" {
     35 #endif
     36 
     37 #include "c2d2.h"
     38 
     39 typedef enum {                                  /*!< lens correction type           */
     40     C2D_LENSCORRECT_AFFINE          = 0,        /*!< affine, default (3x2 matrix)   */
     41     C2D_LENSCORRECT_PERSPECTIVE     = (1 << 0), /*!< perspective bit  (3x3) matrix  */
     42     C2D_LENSCORRECT_BILINEAR        = (1 << 1), /*!< bilinear bit                   */
     43     C2D_LENSCORRECT_ORIGIN_IN_MIDDLE= (1 << 2), /*!< rotation origin for matrix is in the middle */
     44     C2D_LENSCORRECT_SOURCE_RECT     = (1 << 3), /*!< enables source_rect field. When set, client has to provide C2D_LENSCORRECT_OBJECT.source_rect
     45                                                      if not set source surface dimensions are used.*/
     46     C2D_LENSCORRECT_TARGET_RECT     = (1 << 4), /*!< enables target_rect field. When set, client has to provide C2D_LENSCORRECT_OBJECT.target_rect
     47                                                      if not set target surface dimensions are used. */
     48 } C2D_LENSCORRECT_TYPE;
     49 
     50 typedef struct C2D_LENSCORRECT_OBJ_STR {
     51     uint32   srcId;                     /*!< source surface */
     52     C2D_RECT blitSize;                  /*!< C2D_RECT for blit size */
     53     C2D_RECT gridSize;                  /*!< C2D_RECT for grid size */
     54     int32    offsetX;                   /*!< source x offset */
     55     int32    offsetY;                   /*!< source y offset */
     56     uint32   transformType;             /*!< (C2D_LENSCORRECT_AFFINE or C2D_LENSCORRECT_PERSPECTIVE) + C2D_LENSCORRECT_BILINEAR */
     57     float   *transformMatrices;         /*!<  transformMatrix array, 3x2 or 3x3 depending transformType  */
     58     C2D_RECT source_rect;               /*!< region of the source surface,   16.16 fp */
     59     C2D_RECT target_rect;               /*!< position and scaling in target, 16.16 fp */
     60 }C2D_LENSCORRECT_OBJECT;
     61 
     62 /* ------------------------------------------------------------------- *//*!
     63  * \external
     64  * \brief   Lens correction, affine or perspective
     65  *
     66  * \param    uint32 targetSurface
     67  * \param    C2D_LENSCORRECT_OBJECT sourceObject
     68  * \return  C2D_STATUS_OK on success
     69  *//* ------------------------------------------------------------------- */
     70 C2D_API C2D_STATUS c2dLensCorrection(
     71     uint32                  targetSurface,
     72     C2D_LENSCORRECT_OBJECT *sourceObject);
     73 
     74 /* ------------------------------------------------------------------- *//*!
     75  * \external
     76  * \brief   Locks surface and sets surfaces host pointer
     77  *
     78  * \param    uint32 surface
     79  * \param    void** pointer to void pointer where host address is returned
     80  * \return  C2D_STATUS_OK on success
     81  *//* ------------------------------------------------------------------- */
     82 C2D_API C2D_STATUS c2dLockSurface(
     83     uint32   a_surface,
     84     void   **y_pHostAddress,
     85     void   **u_pHostAddress,
     86     void   **v_pHostAddress);
     87 
     88 /* ------------------------------------------------------------------- *//*!
     89  * \external
     90  * \brief   Unlocks surface
     91  *
     92  * \param    uint32 surface
     93  * \return  C2D_STATUS_OK on success
     94  *//* ------------------------------------------------------------------- */
     95 C2D_API C2D_STATUS c2dUnlockSurface(
     96     uint32 a_surface);
     97 
     98 /* ------------------------------------------------------------------- *//*!
     99  * \external
    100  * \brief   Fills surface information parameters
    101  *
    102  * \param   uint32 surface
    103  * \param   uint32 *width
    104  * \param   uint32 *height
    105  * \param   uint32 *format
    106  * \return  C2D_STATUS_OK on success
    107  *//* ------------------------------------------------------------------- */
    108 C2D_API C2D_STATUS c2dGetSurfaceInfo(
    109     uint32  a_surface,
    110     uint32 *width,
    111     uint32 *height,
    112     uint32 *format );
    113 
    114 /* ------------------------------------------------------------------- *//*!
    115  * \external
    116  * \brief   Fills device information parameters
    117  *
    118  * \param    uint32 *count
    119  * \return  C2D_STATUS_OK on success
    120  *//* ------------------------------------------------------------------- */
    121 C2D_API C2D_STATUS c2dGetDeviceInfo(
    122     uint32 *count );
    123 
    124 
    125 //=============================================================================
    126 // C2D extension for adding shader support
    127 //=============================================================================
    128 typedef enum {                          /*!< C2D sampler type  enum         */
    129     C2D_SAMPLER_FRAG_SRC    = (1 << 0), /*!< Frag sampler for source surface*/
    130     C2D_SAMPLER_FRAG_DST    = (1 << 1), /*!< Frag sampler for target surface*/
    131     C2D_SAMPLER_FRAG_MASK   = (1 << 2)  /*!< Frag sampler for mask surface  */
    132 }C2D_SAMPLER_TYPE;
    133 
    134 
    135 struct c2d_sampler {                        /*!< C2D sampler structure      */
    136     char*               sampler_name;       /*!< sampler name               */
    137     uint32              sampler_name_len;   /*!< sampler name length        */
    138     C2D_SAMPLER_TYPE    sampler_type;       /*!< sampler type               */
    139 };
    140 
    141 
    142 struct c2d_uniform {                        /*!< C2D uniform structure      */
    143     char *              u_name;             /*!< uniform name               */
    144     int                 u_name_len;         /*!< uniform name length        */
    145     void*               u_data;             /*!< uniform data buffer        */
    146     uint32              u_data_len;         /*!< uniform data buffer length */
    147     uint32              u_item_size;        /*!< per item size in buffer    */
    148     uint32              u_item_count;       /*!< total item count in buffer */
    149 };
    150 
    151 
    152 struct c2d_program {                        /*!< C2D shader structure       */
    153     unsigned char*      program_binary;     /*!< shader binary (VS + FS)    */
    154     uint32              program_binary_len; /*!< shader binary length       */
    155     struct c2d_uniform* uniform_list;       /*!< uniform list in the shader */
    156     uint32              uniform_count;      /*!< uniform count in the shader*/
    157     struct c2d_sampler* sampler_list;       /*!< sampler list in the shader */
    158     uint32              sampler_count;      /*!< sampler count in the shader*/
    159 };
    160 
    161 
    162 /* ------------------------------------------------------------------- *//*!
    163  * \external
    164  * \brief   adding a user defined program in C2D that can be used later
    165  *
    166  * \param    struct c2d_program *   the program that user wants to Add
    167  * \return   uint32                 this is the id that will be used later
    168  *                                  to refer the program
    169  *
    170  *//* ------------------------------------------------------------------- */
    171 C2D_API uint32 c2dAddProgram(struct c2d_program* a_program);
    172 
    173 
    174 /* ------------------------------------------------------------------- *//*!
    175  * \external
    176  * \brief   Select a shader to be used
    177  *
    178  * \param   pid         this is the program id user want to remove
    179  * \return  C2D_STATUS  C2D_STATUS_OK on success
    180  *//* ------------------------------------------------------------------- */
    181 C2D_API C2D_STATUS c2dRemoveProgram(uint32 pid);
    182 
    183 
    184 /* ------------------------------------------------------------------- *//*!
    185  * \external
    186  * \brief   Select a program to be used by C2D.
    187  *
    188  * \param   pid             this is the program id user want to use
    189  * \return  C2D_STATUS      C2D_STATUS__OK on success
    190  *//* ------------------------------------------------------------------- */
    191 C2D_API C2D_STATUS c2dActivateProgram(uint32 pid);
    192 
    193 
    194 /* ------------------------------------------------------------------- *//*!
    195  * \external
    196  * \brief   Deselect a program to be used by C2D.
    197  *
    198  * \param   pid             this is the program id user want to deactivate
    199  * \return  C2D_STATUS      C2D_STATUS__OK on success
    200  *//* ------------------------------------------------------------------- */
    201 C2D_API C2D_STATUS c2dDeactivateProgram(uint32 pid);
    202 
    203 
    204 #ifdef __cplusplus
    205 }
    206 #endif
    207 
    208 #endif /* _C2DEXT_H_ */
    209