• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2015-2016, 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 MM_LIB2D_H_
31 #define MM_LIB2D_H_
32 
33 #include "cam_types.h"
34 #ifdef QCAMERA_REDEFINE_LOG
35 #define CAM_MODULE CAM_NO_MODULE
36 
37 // Camera dependencies
38 extern "C" {
39 #include "mm_camera_dbg.h"
40 }
41 #endif
42 
43 /** lib2d_error
44  * @MM_LIB2D_SUCCESS: Success
45  * @MM_LIB2D_ERR_GENERAL: General Error
46  * @MM_LIB2D_ERR_MEMORY: Insufficient memory error
47  * @MM_LIB2D_ERR_BAD_PARAM: Bad params error
48 **/
49 typedef enum lib2d_error_t {
50   MM_LIB2D_SUCCESS,
51   MM_LIB2D_ERR_GENERAL,
52   MM_LIB2D_ERR_MEMORY,
53   MM_LIB2D_ERR_BAD_PARAM,
54 } lib2d_error;
55 
56 /** lib2d_mode
57  * @MM_LIB2D_SYNC_MODE: Synchronous mode
58  * @MM_LIB2D_ASYNC_MODE: Asynchronous mode
59 **/
60 typedef enum mm_lib2d_mode_t {
61   MM_LIB2D_SYNC_MODE,
62   MM_LIB2D_ASYNC_MODE,
63 } lib2d_mode;
64 
65 /** mm_lib2d_buffer_type
66  * @MM_LIB2D_BUFFER_TYPE_RGB: RGB Buffer type
67  * @MM_LIB2D_BUFFER_TYPE_YUV: YUV buffer type
68 **/
69 typedef enum mm_lib2d_buffer_type_t {
70   MM_LIB2D_BUFFER_TYPE_RGB,
71   MM_LIB2D_BUFFER_TYPE_YUV,
72 } mm_lib2d_buffer_type;
73 
74 /** mm_lib2d_rgb_buffer
75  * @fd: handle to the buffer memory
76  * @format: RGB color format
77  * @width: defines width in pixels
78  * @height: defines height in pixels
79  * @buffer: pointer to the RGB buffer
80  * @phys: gpu mapped physical address
81  * @stride: defines stride in bytes
82 **/
83 typedef struct mm_lib2d_rgb_buffer_t {
84   int32_t      fd;
85   cam_format_t format;
86   uint32_t     width;
87   uint32_t     height;
88   void        *buffer;
89   void        *phys;
90   int32_t      stride;
91 } mm_lib2d_rgb_buffer;
92 
93 /** mm_lib2d_yuv_buffer
94  * @fd: handle to the buffer memory
95  * @format: YUV color format
96  * @width: defines width in pixels
97  * @height: defines height in pixels
98  * @plane0: holds the whole buffer if YUV format is not planar
99  * @phys0: gpu mapped physical address
100  * @stride0: stride in bytes
101  * @plane1: holds UV or VU plane for planar interleaved
102  * @phys2: gpu mapped physical address
103  * @stride1: stride in bytes
104  * @plane2: holds the 3. plane, ignored if YUV format is not planar
105  * @phys2: gpu mapped physical address
106  * @stride2: stride in bytes
107 **/
108 typedef struct mm_lib2d_yuv_buffer_t {
109   int32_t      fd;
110   cam_format_t format;
111   uint32_t     width;
112   uint32_t     height;
113   void        *plane0;
114   void        *phys0;
115   int32_t      stride0;
116   void        *plane1;
117   void        *phys1;
118   int32_t      stride1;
119   void        *plane2;
120   void        *phys2;
121   int32_t      stride2;
122 } mm_lib2d_yuv_buffer;
123 
124 /** mm_lib2d_buffer
125  * @buffer_type: Buffer type. whether RGB or YUV
126  * @rgb_buffer: RGB buffer handle
127  * @yuv_buffer: YUV buffer handle
128 **/
129 typedef struct mm_lib2d_buffer_t {
130   mm_lib2d_buffer_type buffer_type;
131   union {
132     mm_lib2d_rgb_buffer rgb_buffer;
133     mm_lib2d_yuv_buffer yuv_buffer;
134   };
135 } mm_lib2d_buffer;
136 
137 /** lib2d_client_cb
138  * @userdata: App userdata
139  * @jobid: job id
140 **/
141 typedef lib2d_error (*lib2d_client_cb) (void *userdata, int jobid);
142 
143 /**
144  * Function: mm_lib2d_init
145  *
146  * Description: Initialization function for Lib2D. src_format, dst_format
147  *     are hints to the underlying component to initialize.
148  *
149  * Input parameters:
150  *   mode - Mode (sync/async) in which App wants lib2d to run.
151  *   src_format - source surface format
152  *   dst_format - Destination surface format
153  *   my_obj - handle that will be returned on succesful Init. App has to
154  *       call other lib2d functions by passing this handle.
155  *
156  * Return values:
157  *   MM_LIB2D_SUCCESS
158  *   MM_LIB2D_ERR_MEMORY
159  *   MM_LIB2D_ERR_BAD_PARAM
160  *   MM_LIB2D_ERR_GENERAL
161  *
162  * Notes: none
163  **/
164 lib2d_error mm_lib2d_init(lib2d_mode mode, cam_format_t src_format,
165   cam_format_t dst_format, void **lib2d_obj_handle);
166 
167 /**
168  * Function: mm_lib2d_deinit
169  *
170  * Description: De-Initialization function for Lib2D
171  *
172  * Input parameters:
173  *   lib2d_obj_handle - handle tto the lib2d object
174  *
175  * Return values:
176  *   MM_LIB2D_SUCCESS
177  *   MM_LIB2D_ERR_GENERAL
178  *
179  * Notes: none
180  **/
181 lib2d_error mm_lib2d_deinit(void *lib2d_obj_handle);
182 
183 /**
184  * Function: mm_lib2d_start_job
185  *
186  * Description: Start executing the job
187  *
188  * Input parameters:
189  *   lib2d_obj_handle - handle tto the lib2d object
190  *   src_buffer - pointer to the source buffer
191  *   dst_buffer - pointer to the destination buffer
192  *   jobid - job id of this request
193  *   userdata - userdata that will be pass through callback function
194  *   cb - callback function that will be called on completion of this job
195  *
196  * Return values:
197  *   MM_LIB2D_SUCCESS
198  *   MM_LIB2D_ERR_MEMORY
199  *   MM_LIB2D_ERR_GENERAL
200  *
201  * Notes: none
202  **/
203 lib2d_error mm_lib2d_start_job(void *lib2d_obj_handle,
204     mm_lib2d_buffer* src_buffer, mm_lib2d_buffer* dst_buffer,
205     int jobid, void *userdata, lib2d_client_cb cb);
206 
207 #endif /* MM_LIB2D_H_ */
208 
209 
210