1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef MM_LIB2D_H_
#define MM_LIB2D_H_
#include "cam_types.h"
#ifdef QCAMERA_REDEFINE_LOG
#ifndef CAM_MODULE
#define CAM_MODULE CAM_NO_MODULE
#endif
// Camera dependencies
#include "mm_camera_dbg.h"
#endif
/** lib2d_error
* @MM_LIB2D_SUCCESS: Success
* @MM_LIB2D_ERR_GENERAL: General Error
* @MM_LIB2D_ERR_MEMORY: Insufficient memory error
* @MM_LIB2D_ERR_BAD_PARAM: Bad params error
**/
typedef enum lib2d_error_t {
MM_LIB2D_SUCCESS,
MM_LIB2D_ERR_GENERAL,
MM_LIB2D_ERR_MEMORY,
MM_LIB2D_ERR_BAD_PARAM,
} lib2d_error;
/** lib2d_mode
* @MM_LIB2D_SYNC_MODE: Synchronous mode
* @MM_LIB2D_ASYNC_MODE: Asynchronous mode
**/
typedef enum mm_lib2d_mode_t {
MM_LIB2D_SYNC_MODE,
MM_LIB2D_ASYNC_MODE,
} lib2d_mode;
/** mm_lib2d_buffer_type
* @MM_LIB2D_BUFFER_TYPE_RGB: RGB Buffer type
* @MM_LIB2D_BUFFER_TYPE_YUV: YUV buffer type
**/
typedef enum mm_lib2d_buffer_type_t {
MM_LIB2D_BUFFER_TYPE_RGB,
MM_LIB2D_BUFFER_TYPE_YUV,
} mm_lib2d_buffer_type;
/** mm_lib2d_rgb_buffer
* @fd: handle to the buffer memory
* @format: RGB color format
* @width: defines width in pixels
* @height: defines height in pixels
* @buffer: pointer to the RGB buffer
* @phys: gpu mapped physical address
* @stride: defines stride in bytes
**/
typedef struct mm_lib2d_rgb_buffer_t {
int32_t fd;
cam_format_t format;
uint32_t width;
uint32_t height;
void *buffer;
void *phys;
int32_t stride;
} mm_lib2d_rgb_buffer;
/** mm_lib2d_yuv_buffer
* @fd: handle to the buffer memory
* @format: YUV color format
* @width: defines width in pixels
* @height: defines height in pixels
* @plane0: holds the whole buffer if YUV format is not planar
* @phys0: gpu mapped physical address
* @stride0: stride in bytes
* @plane1: holds UV or VU plane for planar interleaved
* @phys2: gpu mapped physical address
* @stride1: stride in bytes
* @plane2: holds the 3. plane, ignored if YUV format is not planar
* @phys2: gpu mapped physical address
* @stride2: stride in bytes
**/
typedef struct mm_lib2d_yuv_buffer_t {
int32_t fd;
cam_format_t format;
uint32_t width;
uint32_t height;
void *plane0;
void *phys0;
int32_t stride0;
void *plane1;
void *phys1;
int32_t stride1;
void *plane2;
void *phys2;
int32_t stride2;
} mm_lib2d_yuv_buffer;
/** mm_lib2d_buffer
* @buffer_type: Buffer type. whether RGB or YUV
* @rgb_buffer: RGB buffer handle
* @yuv_buffer: YUV buffer handle
**/
typedef struct mm_lib2d_buffer_t {
mm_lib2d_buffer_type buffer_type;
union {
mm_lib2d_rgb_buffer rgb_buffer;
mm_lib2d_yuv_buffer yuv_buffer;
};
} mm_lib2d_buffer;
/** lib2d_client_cb
* @userdata: App userdata
* @jobid: job id
**/
typedef lib2d_error (*lib2d_client_cb) (void *userdata, int jobid);
/**
* Function: mm_lib2d_init
*
* Description: Initialization function for Lib2D. src_format, dst_format
* are hints to the underlying component to initialize.
*
* Input parameters:
* mode - Mode (sync/async) in which App wants lib2d to run.
* src_format - source surface format
* dst_format - Destination surface format
* my_obj - handle that will be returned on succesful Init. App has to
* call other lib2d functions by passing this handle.
*
* Return values:
* MM_LIB2D_SUCCESS
* MM_LIB2D_ERR_MEMORY
* MM_LIB2D_ERR_BAD_PARAM
* MM_LIB2D_ERR_GENERAL
*
* Notes: none
**/
lib2d_error mm_lib2d_init(lib2d_mode mode, cam_format_t src_format,
cam_format_t dst_format, void **lib2d_obj_handle);
/**
* Function: mm_lib2d_deinit
*
* Description: De-Initialization function for Lib2D
*
* Input parameters:
* lib2d_obj_handle - handle tto the lib2d object
*
* Return values:
* MM_LIB2D_SUCCESS
* MM_LIB2D_ERR_GENERAL
*
* Notes: none
**/
lib2d_error mm_lib2d_deinit(void *lib2d_obj_handle);
/**
* Function: mm_lib2d_start_job
*
* Description: Start executing the job
*
* Input parameters:
* lib2d_obj_handle - handle tto the lib2d object
* src_buffer - pointer to the source buffer
* dst_buffer - pointer to the destination buffer
* jobid - job id of this request
* userdata - userdata that will be pass through callback function
* cb - callback function that will be called on completion of this job
* rotation - rotation to be applied
*
* Return values:
* MM_LIB2D_SUCCESS
* MM_LIB2D_ERR_MEMORY
* MM_LIB2D_ERR_GENERAL
*
* Notes: none
**/
lib2d_error mm_lib2d_start_job(void *lib2d_obj_handle,
mm_lib2d_buffer* src_buffer, mm_lib2d_buffer* dst_buffer,
int jobid, void *userdata, lib2d_client_cb cb, uint32_t rotation);
#endif /* MM_LIB2D_H_ */
|