1pub const G2D_VERSION_MAJOR: u32 = 2;
4pub const G2D_VERSION_MINOR: u32 = 5;
5pub const G2D_VERSION_PATCH: u32 = 0;
6pub const g2d_format_G2D_RGB565: g2d_format = 0;
7pub const g2d_format_G2D_RGBA8888: g2d_format = 1;
8pub const g2d_format_G2D_RGBX8888: g2d_format = 2;
9pub const g2d_format_G2D_BGRA8888: g2d_format = 3;
10pub const g2d_format_G2D_BGRX8888: g2d_format = 4;
11pub const g2d_format_G2D_BGR565: g2d_format = 5;
12pub const g2d_format_G2D_ARGB8888: g2d_format = 6;
13pub const g2d_format_G2D_ABGR8888: g2d_format = 7;
14pub const g2d_format_G2D_XRGB8888: g2d_format = 8;
15pub const g2d_format_G2D_XBGR8888: g2d_format = 9;
16pub const g2d_format_G2D_RGB888: g2d_format = 10;
17pub const g2d_format_G2D_BGR888: g2d_format = 11;
18pub const g2d_format_G2D_RGBA5551: g2d_format = 12;
19pub const g2d_format_G2D_RGBX5551: g2d_format = 13;
20pub const g2d_format_G2D_BGRA5551: g2d_format = 14;
21pub const g2d_format_G2D_BGRX5551: g2d_format = 15;
22pub const g2d_format_G2D_RGBA1010102: g2d_format = 16;
23pub const g2d_format_G2D_GRAY10: g2d_format = 18;
24pub const g2d_format_G2D_GRAY8: g2d_format = 19;
25pub const g2d_format_G2D_NV12: g2d_format = 20;
26pub const g2d_format_G2D_I420: g2d_format = 21;
27pub const g2d_format_G2D_YV12: g2d_format = 22;
28pub const g2d_format_G2D_NV21: g2d_format = 23;
29pub const g2d_format_G2D_YUYV: g2d_format = 24;
30pub const g2d_format_G2D_YVYU: g2d_format = 25;
31pub const g2d_format_G2D_UYVY: g2d_format = 26;
32pub const g2d_format_G2D_VYUY: g2d_format = 27;
33pub const g2d_format_G2D_NV16: g2d_format = 28;
34pub const g2d_format_G2D_NV61: g2d_format = 29;
35pub type g2d_format = ::std::os::raw::c_uint;
36pub const g2d_blend_func_G2D_ZERO: g2d_blend_func = 0;
37pub const g2d_blend_func_G2D_ONE: g2d_blend_func = 1;
38pub const g2d_blend_func_G2D_SRC_ALPHA: g2d_blend_func = 2;
39pub const g2d_blend_func_G2D_ONE_MINUS_SRC_ALPHA: g2d_blend_func = 3;
40pub const g2d_blend_func_G2D_DST_ALPHA: g2d_blend_func = 4;
41pub const g2d_blend_func_G2D_ONE_MINUS_DST_ALPHA: g2d_blend_func = 5;
42pub const g2d_blend_func_G2D_PRE_MULTIPLIED_ALPHA: g2d_blend_func = 16;
43pub const g2d_blend_func_G2D_DEMULTIPLY_OUT_ALPHA: g2d_blend_func = 32;
44pub type g2d_blend_func = ::std::os::raw::c_uint;
45pub const g2d_cap_mode_G2D_BLEND: g2d_cap_mode = 0;
46pub const g2d_cap_mode_G2D_DITHER: g2d_cap_mode = 1;
47pub const g2d_cap_mode_G2D_GLOBAL_ALPHA: g2d_cap_mode = 2;
48pub const g2d_cap_mode_G2D_BLEND_DIM: g2d_cap_mode = 3;
49pub const g2d_cap_mode_G2D_BLUR: g2d_cap_mode = 4;
50pub const g2d_cap_mode_G2D_YUV_BT_601: g2d_cap_mode = 5;
51pub const g2d_cap_mode_G2D_YUV_BT_709: g2d_cap_mode = 6;
52pub const g2d_cap_mode_G2D_YUV_BT_601FR: g2d_cap_mode = 7;
53pub const g2d_cap_mode_G2D_YUV_BT_709FR: g2d_cap_mode = 8;
54pub const g2d_cap_mode_G2D_WARPING: g2d_cap_mode = 9;
55pub type g2d_cap_mode = ::std::os::raw::c_uint;
56pub const g2d_feature_G2D_SCALING: g2d_feature = 0;
57pub const g2d_feature_G2D_ROTATION: g2d_feature = 1;
58pub const g2d_feature_G2D_SRC_YUV: g2d_feature = 2;
59pub const g2d_feature_G2D_DST_YUV: g2d_feature = 3;
60pub const g2d_feature_G2D_MULTI_SOURCE_BLT: g2d_feature = 4;
61pub const g2d_feature_G2D_FAST_CLEAR: g2d_feature = 5;
62pub const g2d_feature_G2D_WARP_DEWARP: g2d_feature = 6;
63pub type g2d_feature = ::std::os::raw::c_uint;
64pub const g2d_rotation_G2D_ROTATION_0: g2d_rotation = 0;
65pub const g2d_rotation_G2D_ROTATION_90: g2d_rotation = 1;
66pub const g2d_rotation_G2D_ROTATION_180: g2d_rotation = 2;
67pub const g2d_rotation_G2D_ROTATION_270: g2d_rotation = 3;
68pub const g2d_rotation_G2D_FLIP_H: g2d_rotation = 4;
69pub const g2d_rotation_G2D_FLIP_V: g2d_rotation = 5;
70pub type g2d_rotation = ::std::os::raw::c_uint;
71pub const g2d_cache_mode_G2D_CACHE_CLEAN: g2d_cache_mode = 0;
72pub const g2d_cache_mode_G2D_CACHE_FLUSH: g2d_cache_mode = 1;
73pub const g2d_cache_mode_G2D_CACHE_INVALIDATE: g2d_cache_mode = 2;
74pub type g2d_cache_mode = ::std::os::raw::c_uint;
75pub const g2d_hardware_type_G2D_HARDWARE_2D: g2d_hardware_type = 0;
76pub const g2d_hardware_type_G2D_HARDWARE_VG: g2d_hardware_type = 1;
77pub const g2d_hardware_type_G2D_HARDWARE_DPU_V1: g2d_hardware_type = 2;
78pub const g2d_hardware_type_G2D_HARDWARE_DPU_V2: g2d_hardware_type = 3;
79pub const g2d_hardware_type_G2D_HARDWARE_PXP_V1: g2d_hardware_type = 4;
80pub const g2d_hardware_type_G2D_HARDWARE_PXP_V2: g2d_hardware_type = 5;
81pub type g2d_hardware_type = ::std::os::raw::c_uint;
82pub const g2d_status_G2D_STATUS_FAIL: g2d_status = -1;
83pub const g2d_status_G2D_STATUS_OK: g2d_status = 0;
84pub const g2d_status_G2D_STATUS_NOT_SUPPORTED: g2d_status = 1;
85pub type g2d_status = ::std::os::raw::c_int;
86pub type g2d_phys_addr_t = ::std::os::raw::c_ulong;
87#[repr(C)]
88#[derive(Debug, Copy, Clone)]
89pub struct g2d_surface {
90 pub format: g2d_format,
91 pub planes: [g2d_phys_addr_t; 3usize],
92 pub left: ::std::os::raw::c_int,
93 pub top: ::std::os::raw::c_int,
94 pub right: ::std::os::raw::c_int,
95 pub bottom: ::std::os::raw::c_int,
96 #[doc = "< buffer stride, in Pixels"]
97 pub stride: ::std::os::raw::c_int,
98 #[doc = "< surface width, in Pixels"]
99 pub width: ::std::os::raw::c_int,
100 #[doc = "< surface height, in Pixels"]
101 pub height: ::std::os::raw::c_int,
102 #[doc = "< alpha blending parameters"]
103 pub blendfunc: g2d_blend_func,
104 #[doc = "< value is 0 ~ 255"]
105 pub global_alpha: ::std::os::raw::c_int,
106 pub clrcolor: ::std::os::raw::c_int,
107 pub rot: g2d_rotation,
108}
109#[repr(C)]
110#[derive(Debug, Copy, Clone)]
111pub struct g2d_surface_pair {
112 pub s: g2d_surface,
113 pub d: g2d_surface,
114}
115#[repr(C)]
116#[derive(Debug, Copy, Clone)]
117pub struct g2d_buf {
118 pub buf_handle: *mut ::std::os::raw::c_void,
119 pub buf_vaddr: *mut ::std::os::raw::c_void,
120 pub buf_paddr: g2d_phys_addr_t,
121 pub buf_size: ::std::os::raw::c_int,
122}
123#[derive(Debug)]
124pub struct g2d {
125 __library: ::libloading::Library,
126 pub g2d_open: Result<
127 unsafe extern "C" fn(handle: *mut *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
128 ::libloading::Error,
129 >,
130 pub g2d_close: Result<
131 unsafe extern "C" fn(handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
132 ::libloading::Error,
133 >,
134 pub g2d_make_current: Result<
135 unsafe extern "C" fn(
136 handle: *mut ::std::os::raw::c_void,
137 type_: g2d_hardware_type,
138 ) -> ::std::os::raw::c_int,
139 ::libloading::Error,
140 >,
141 pub g2d_clear: Result<
142 unsafe extern "C" fn(
143 handle: *mut ::std::os::raw::c_void,
144 area: *mut g2d_surface,
145 ) -> ::std::os::raw::c_int,
146 ::libloading::Error,
147 >,
148 pub g2d_blit: Result<
149 unsafe extern "C" fn(
150 handle: *mut ::std::os::raw::c_void,
151 src: *mut g2d_surface,
152 dst: *mut g2d_surface,
153 ) -> ::std::os::raw::c_int,
154 ::libloading::Error,
155 >,
156 pub g2d_copy: Result<
157 unsafe extern "C" fn(
158 handle: *mut ::std::os::raw::c_void,
159 d: *mut g2d_buf,
160 s: *mut g2d_buf,
161 size: ::std::os::raw::c_int,
162 ) -> ::std::os::raw::c_int,
163 ::libloading::Error,
164 >,
165 pub g2d_multi_blit: Result<
166 unsafe extern "C" fn(
167 handle: *mut ::std::os::raw::c_void,
168 sp: *mut *mut g2d_surface_pair,
169 layers: ::std::os::raw::c_int,
170 ) -> ::std::os::raw::c_int,
171 ::libloading::Error,
172 >,
173 pub g2d_query_hardware: Result<
174 unsafe extern "C" fn(
175 handle: *mut ::std::os::raw::c_void,
176 type_: g2d_hardware_type,
177 available: *mut ::std::os::raw::c_int,
178 ) -> ::std::os::raw::c_int,
179 ::libloading::Error,
180 >,
181 pub g2d_query_feature: Result<
182 unsafe extern "C" fn(
183 handle: *mut ::std::os::raw::c_void,
184 feature: g2d_feature,
185 available: *mut ::std::os::raw::c_int,
186 ) -> ::std::os::raw::c_int,
187 ::libloading::Error,
188 >,
189 pub g2d_query_cap: Result<
190 unsafe extern "C" fn(
191 handle: *mut ::std::os::raw::c_void,
192 cap: g2d_cap_mode,
193 enable: *mut ::std::os::raw::c_int,
194 ) -> ::std::os::raw::c_int,
195 ::libloading::Error,
196 >,
197 pub g2d_enable: Result<
198 unsafe extern "C" fn(
199 handle: *mut ::std::os::raw::c_void,
200 cap: g2d_cap_mode,
201 ) -> ::std::os::raw::c_int,
202 ::libloading::Error,
203 >,
204 pub g2d_disable: Result<
205 unsafe extern "C" fn(
206 handle: *mut ::std::os::raw::c_void,
207 cap: g2d_cap_mode,
208 ) -> ::std::os::raw::c_int,
209 ::libloading::Error,
210 >,
211 pub g2d_cache_op: Result<
212 unsafe extern "C" fn(buf: *mut g2d_buf, op: g2d_cache_mode) -> ::std::os::raw::c_int,
213 ::libloading::Error,
214 >,
215 pub g2d_alloc: Result<
216 unsafe extern "C" fn(
217 size: ::std::os::raw::c_int,
218 cacheable: ::std::os::raw::c_int,
219 ) -> *mut g2d_buf,
220 ::libloading::Error,
221 >,
222 pub g2d_free: Result<
223 unsafe extern "C" fn(buf: *mut g2d_buf) -> ::std::os::raw::c_int,
224 ::libloading::Error,
225 >,
226 pub g2d_flush: Result<
227 unsafe extern "C" fn(handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
228 ::libloading::Error,
229 >,
230 pub g2d_finish: Result<
231 unsafe extern "C" fn(handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
232 ::libloading::Error,
233 >,
234}
235impl g2d {
236 pub unsafe fn new<P>(path: P) -> Result<Self, ::libloading::Error>
237 where
238 P: AsRef<::std::ffi::OsStr>,
239 {
240 let library = ::libloading::Library::new(path)?;
241 Self::from_library(library)
242 }
243 pub unsafe fn from_library<L>(library: L) -> Result<Self, ::libloading::Error>
244 where
245 L: Into<::libloading::Library>,
246 {
247 let __library = library.into();
248 let g2d_open = __library.get(b"g2d_open\0").map(|sym| *sym);
249 let g2d_close = __library.get(b"g2d_close\0").map(|sym| *sym);
250 let g2d_make_current = __library.get(b"g2d_make_current\0").map(|sym| *sym);
251 let g2d_clear = __library.get(b"g2d_clear\0").map(|sym| *sym);
252 let g2d_blit = __library.get(b"g2d_blit\0").map(|sym| *sym);
253 let g2d_copy = __library.get(b"g2d_copy\0").map(|sym| *sym);
254 let g2d_multi_blit = __library.get(b"g2d_multi_blit\0").map(|sym| *sym);
255 let g2d_query_hardware = __library.get(b"g2d_query_hardware\0").map(|sym| *sym);
256 let g2d_query_feature = __library.get(b"g2d_query_feature\0").map(|sym| *sym);
257 let g2d_query_cap = __library.get(b"g2d_query_cap\0").map(|sym| *sym);
258 let g2d_enable = __library.get(b"g2d_enable\0").map(|sym| *sym);
259 let g2d_disable = __library.get(b"g2d_disable\0").map(|sym| *sym);
260 let g2d_cache_op = __library.get(b"g2d_cache_op\0").map(|sym| *sym);
261 let g2d_alloc = __library.get(b"g2d_alloc\0").map(|sym| *sym);
262 let g2d_free = __library.get(b"g2d_free\0").map(|sym| *sym);
263 let g2d_flush = __library.get(b"g2d_flush\0").map(|sym| *sym);
264 let g2d_finish = __library.get(b"g2d_finish\0").map(|sym| *sym);
265 Ok(g2d {
266 __library,
267 g2d_open,
268 g2d_close,
269 g2d_make_current,
270 g2d_clear,
271 g2d_blit,
272 g2d_copy,
273 g2d_multi_blit,
274 g2d_query_hardware,
275 g2d_query_feature,
276 g2d_query_cap,
277 g2d_enable,
278 g2d_disable,
279 g2d_cache_op,
280 g2d_alloc,
281 g2d_free,
282 g2d_flush,
283 g2d_finish,
284 })
285 }
286 pub unsafe fn g2d_open(
287 &self,
288 handle: *mut *mut ::std::os::raw::c_void,
289 ) -> ::std::os::raw::c_int {
290 (self
291 .g2d_open
292 .as_ref()
293 .expect("Expected function, got error."))(handle)
294 }
295 pub unsafe fn g2d_close(&self, handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int {
296 (self
297 .g2d_close
298 .as_ref()
299 .expect("Expected function, got error."))(handle)
300 }
301 pub unsafe fn g2d_make_current(
302 &self,
303 handle: *mut ::std::os::raw::c_void,
304 type_: g2d_hardware_type,
305 ) -> ::std::os::raw::c_int {
306 (self
307 .g2d_make_current
308 .as_ref()
309 .expect("Expected function, got error."))(handle, type_)
310 }
311 pub unsafe fn g2d_clear(
312 &self,
313 handle: *mut ::std::os::raw::c_void,
314 area: *mut g2d_surface,
315 ) -> ::std::os::raw::c_int {
316 (self
317 .g2d_clear
318 .as_ref()
319 .expect("Expected function, got error."))(handle, area)
320 }
321 pub unsafe fn g2d_blit(
322 &self,
323 handle: *mut ::std::os::raw::c_void,
324 src: *mut g2d_surface,
325 dst: *mut g2d_surface,
326 ) -> ::std::os::raw::c_int {
327 (self
328 .g2d_blit
329 .as_ref()
330 .expect("Expected function, got error."))(handle, src, dst)
331 }
332 pub unsafe fn g2d_copy(
333 &self,
334 handle: *mut ::std::os::raw::c_void,
335 d: *mut g2d_buf,
336 s: *mut g2d_buf,
337 size: ::std::os::raw::c_int,
338 ) -> ::std::os::raw::c_int {
339 (self
340 .g2d_copy
341 .as_ref()
342 .expect("Expected function, got error."))(handle, d, s, size)
343 }
344 pub unsafe fn g2d_multi_blit(
345 &self,
346 handle: *mut ::std::os::raw::c_void,
347 sp: *mut *mut g2d_surface_pair,
348 layers: ::std::os::raw::c_int,
349 ) -> ::std::os::raw::c_int {
350 (self
351 .g2d_multi_blit
352 .as_ref()
353 .expect("Expected function, got error."))(handle, sp, layers)
354 }
355 pub unsafe fn g2d_query_hardware(
356 &self,
357 handle: *mut ::std::os::raw::c_void,
358 type_: g2d_hardware_type,
359 available: *mut ::std::os::raw::c_int,
360 ) -> ::std::os::raw::c_int {
361 (self
362 .g2d_query_hardware
363 .as_ref()
364 .expect("Expected function, got error."))(handle, type_, available)
365 }
366 pub unsafe fn g2d_query_feature(
367 &self,
368 handle: *mut ::std::os::raw::c_void,
369 feature: g2d_feature,
370 available: *mut ::std::os::raw::c_int,
371 ) -> ::std::os::raw::c_int {
372 (self
373 .g2d_query_feature
374 .as_ref()
375 .expect("Expected function, got error."))(handle, feature, available)
376 }
377 pub unsafe fn g2d_query_cap(
378 &self,
379 handle: *mut ::std::os::raw::c_void,
380 cap: g2d_cap_mode,
381 enable: *mut ::std::os::raw::c_int,
382 ) -> ::std::os::raw::c_int {
383 (self
384 .g2d_query_cap
385 .as_ref()
386 .expect("Expected function, got error."))(handle, cap, enable)
387 }
388 pub unsafe fn g2d_enable(
389 &self,
390 handle: *mut ::std::os::raw::c_void,
391 cap: g2d_cap_mode,
392 ) -> ::std::os::raw::c_int {
393 (self
394 .g2d_enable
395 .as_ref()
396 .expect("Expected function, got error."))(handle, cap)
397 }
398 pub unsafe fn g2d_disable(
399 &self,
400 handle: *mut ::std::os::raw::c_void,
401 cap: g2d_cap_mode,
402 ) -> ::std::os::raw::c_int {
403 (self
404 .g2d_disable
405 .as_ref()
406 .expect("Expected function, got error."))(handle, cap)
407 }
408 pub unsafe fn g2d_cache_op(
409 &self,
410 buf: *mut g2d_buf,
411 op: g2d_cache_mode,
412 ) -> ::std::os::raw::c_int {
413 (self
414 .g2d_cache_op
415 .as_ref()
416 .expect("Expected function, got error."))(buf, op)
417 }
418 pub unsafe fn g2d_alloc(
419 &self,
420 size: ::std::os::raw::c_int,
421 cacheable: ::std::os::raw::c_int,
422 ) -> *mut g2d_buf {
423 (self
424 .g2d_alloc
425 .as_ref()
426 .expect("Expected function, got error."))(size, cacheable)
427 }
428 pub unsafe fn g2d_free(&self, buf: *mut g2d_buf) -> ::std::os::raw::c_int {
429 (self
430 .g2d_free
431 .as_ref()
432 .expect("Expected function, got error."))(buf)
433 }
434 pub unsafe fn g2d_flush(&self, handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int {
435 (self
436 .g2d_flush
437 .as_ref()
438 .expect("Expected function, got error."))(handle)
439 }
440 pub unsafe fn g2d_finish(&self, handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int {
441 (self
442 .g2d_finish
443 .as_ref()
444 .expect("Expected function, got error."))(handle)
445 }
446}