Home | History | Annotate | Download | only in libc2dcolorconvert
      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 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 namespace android {
     69 
     70 /*TODO: THIS NEEDS TO ENABLED FOR JB PLUS*/
     71 enum ColorConvertFormat {
     72     RGB565 = 1,
     73     YCbCr420Tile,
     74     YCbCr420SP,
     75     YCbCr420P,
     76     YCrCb420P,
     77     RGBA8888,
     78     NV12_2K,
     79     NV12_128m,
     80 };
     81 
     82 typedef struct {
     83     int32_t numerator;
     84     int32_t denominator;
     85 } C2DBytesPerPixel;
     86 
     87 typedef struct {
     88   int32_t width;
     89   int32_t height;
     90   int32_t stride;
     91   int32_t sliceHeight;
     92   int32_t lumaAlign;
     93   int32_t sizeAlign;
     94   int32_t size;
     95   C2DBytesPerPixel bpp;
     96 } C2DBuffReq;
     97 
     98 typedef enum {
     99   C2D_INPUT = 0,
    100   C2D_OUTPUT,
    101 } C2D_PORT;
    102 
    103 class C2DColorConverterBase {
    104 
    105 public:
    106     virtual ~C2DColorConverterBase(){};
    107     virtual int convertC2D(int srcFd, void *srcBase, void * srcData, int dstFd, void *dstBase, void * dstData) = 0;
    108     virtual int32_t getBuffReq(int32_t port, C2DBuffReq *req) = 0;
    109     virtual int32_t dumpOutput(char * filename, char mode) = 0;
    110 };
    111 
    112 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);
    113 typedef void destroyC2DColorConverter_t(C2DColorConverterBase*);
    114 
    115 }
    116 
    117 #endif  // C2D_ColorConverter_H_
    118