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