Home | History | Annotate | Download | only in libc2dcolorconvert
      1 /* Copyright (c) 2012 - 2013, 2015 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 C2D_ColorConverter_H_
     31 #define C2D_ColorConverter_H_
     32 
     33 #include <c2d2.h>
     34 #include <sys/types.h>
     35 
     36 typedef C2D_STATUS (*LINK_c2dCreateSurface)( uint32 *surface_id,
     37         uint32 surface_bits,
     38         C2D_SURFACE_TYPE surface_type,
     39         void *surface_definition );
     40 
     41 typedef C2D_STATUS (*LINK_c2dUpdateSurface)( uint32 surface_id,
     42         uint32 surface_bits,
     43         C2D_SURFACE_TYPE surface_type,
     44         void *surface_definition );
     45 
     46 typedef C2D_STATUS (*LINK_c2dReadSurface)( uint32 surface_id,
     47         C2D_SURFACE_TYPE surface_type,
     48         void *surface_definition,
     49         int32 x, int32 y );
     50 
     51 typedef C2D_STATUS (*LINK_c2dDraw)( uint32 target_id,
     52         uint32 target_config, C2D_RECT *target_scissor,
     53         uint32 target_mask_id, uint32 target_color_key,
     54         C2D_OBJECT *objects_list, uint32 num_objects );
     55 
     56 typedef C2D_STATUS (*LINK_c2dFlush)( uint32 target_id, c2d_ts_handle *timestamp);
     57 
     58 typedef C2D_STATUS (*LINK_c2dFinish)( uint32 target_id);
     59 
     60 typedef C2D_STATUS (*LINK_c2dWaitTimestamp)( c2d_ts_handle timestamp );
     61 
     62 typedef C2D_STATUS (*LINK_c2dDestroySurface)( uint32 surface_id );
     63 
     64 typedef C2D_STATUS (*LINK_c2dMapAddr)( int mem_fd, void * hostptr, uint32 len, uint32 offset, uint32 flags, void ** gpuaddr);
     65 
     66 typedef C2D_STATUS (*LINK_c2dUnMapAddr)(void * gpuaddr);
     67 
     68 typedef void (*LINK_AdrenoComputeAlignedWidthAndHeight) (int width, int height, int bpp, int tile_mode, int raster_mode,
     69                                                           int padding_threshold, int *aligned_width, int * aligned_height);
     70 
     71 namespace android {
     72 
     73 /*TODO: THIS NEEDS TO ENABLED FOR JB PLUS*/
     74 enum ColorConvertFormat {
     75     RGB565 = 1,
     76     YCbCr420Tile,
     77     YCbCr420SP,
     78     YCbCr420P,
     79     YCrCb420P,
     80     RGBA8888,
     81     NV12_2K,
     82     NV12_128m,
     83     NV12_UBWC,
     84 };
     85 
     86 typedef struct {
     87     int32_t numerator;
     88     int32_t denominator;
     89 } C2DBytesPerPixel;
     90 
     91 typedef struct {
     92   int32_t width;
     93   int32_t height;
     94   int32_t stride;
     95   int32_t sliceHeight;
     96   int32_t lumaAlign;
     97   int32_t sizeAlign;
     98   int32_t size;
     99   C2DBytesPerPixel bpp;
    100 } C2DBuffReq;
    101 
    102 typedef enum {
    103   C2D_INPUT = 0,
    104   C2D_OUTPUT,
    105 } C2D_PORT;
    106 
    107 class C2DColorConverterBase {
    108 
    109 public:
    110     virtual ~C2DColorConverterBase(){};
    111     virtual int convertC2D(int srcFd, void *srcBase, void * srcData, int dstFd, void *dstBase, void * dstData) = 0;
    112     virtual int32_t getBuffReq(int32_t port, C2DBuffReq *req) = 0;
    113     virtual int32_t dumpOutput(char * filename, char mode) = 0;
    114 };
    115 
    116 typedef C2DColorConverterBase* createC2DColorConverter_t(size_t srcWidth, size_t srcHeight, size_t dstWidth, size_t dstHeight, ColorConvertFormat srcFormat, ColorConvertFormat dstFormat, int32_t flags, size_t srcStride);
    117 typedef void destroyC2DColorConverter_t(C2DColorConverterBase*);
    118 
    119 }
    120 
    121 #endif  // C2D_ColorConverter_H_
    122