g2d-sys 1.2.0

Low-level FFI bindings for NXP i.MX G2D 2D graphics accelerator
Documentation
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
/* automatically generated by rust-bindgen 0.72.1 */

pub const G2D_VERSION_MAJOR: u32 = 2;
pub const G2D_VERSION_MINOR: u32 = 5;
pub const G2D_VERSION_PATCH: u32 = 0;
pub const g2d_format_G2D_RGB565: g2d_format = 0;
pub const g2d_format_G2D_RGBA8888: g2d_format = 1;
pub const g2d_format_G2D_RGBX8888: g2d_format = 2;
pub const g2d_format_G2D_BGRA8888: g2d_format = 3;
pub const g2d_format_G2D_BGRX8888: g2d_format = 4;
pub const g2d_format_G2D_BGR565: g2d_format = 5;
pub const g2d_format_G2D_ARGB8888: g2d_format = 6;
pub const g2d_format_G2D_ABGR8888: g2d_format = 7;
pub const g2d_format_G2D_XRGB8888: g2d_format = 8;
pub const g2d_format_G2D_XBGR8888: g2d_format = 9;
pub const g2d_format_G2D_RGB888: g2d_format = 10;
pub const g2d_format_G2D_BGR888: g2d_format = 11;
pub const g2d_format_G2D_RGBA5551: g2d_format = 12;
pub const g2d_format_G2D_RGBX5551: g2d_format = 13;
pub const g2d_format_G2D_BGRA5551: g2d_format = 14;
pub const g2d_format_G2D_BGRX5551: g2d_format = 15;
pub const g2d_format_G2D_RGBA1010102: g2d_format = 16;
pub const g2d_format_G2D_GRAY10: g2d_format = 18;
pub const g2d_format_G2D_GRAY8: g2d_format = 19;
pub const g2d_format_G2D_NV12: g2d_format = 20;
pub const g2d_format_G2D_I420: g2d_format = 21;
pub const g2d_format_G2D_YV12: g2d_format = 22;
pub const g2d_format_G2D_NV21: g2d_format = 23;
pub const g2d_format_G2D_YUYV: g2d_format = 24;
pub const g2d_format_G2D_YVYU: g2d_format = 25;
pub const g2d_format_G2D_UYVY: g2d_format = 26;
pub const g2d_format_G2D_VYUY: g2d_format = 27;
pub const g2d_format_G2D_NV16: g2d_format = 28;
pub const g2d_format_G2D_NV61: g2d_format = 29;
pub type g2d_format = ::std::os::raw::c_uint;
pub const g2d_blend_func_G2D_ZERO: g2d_blend_func = 0;
pub const g2d_blend_func_G2D_ONE: g2d_blend_func = 1;
pub const g2d_blend_func_G2D_SRC_ALPHA: g2d_blend_func = 2;
pub const g2d_blend_func_G2D_ONE_MINUS_SRC_ALPHA: g2d_blend_func = 3;
pub const g2d_blend_func_G2D_DST_ALPHA: g2d_blend_func = 4;
pub const g2d_blend_func_G2D_ONE_MINUS_DST_ALPHA: g2d_blend_func = 5;
pub const g2d_blend_func_G2D_PRE_MULTIPLIED_ALPHA: g2d_blend_func = 16;
pub const g2d_blend_func_G2D_DEMULTIPLY_OUT_ALPHA: g2d_blend_func = 32;
pub type g2d_blend_func = ::std::os::raw::c_uint;
pub const g2d_cap_mode_G2D_BLEND: g2d_cap_mode = 0;
pub const g2d_cap_mode_G2D_DITHER: g2d_cap_mode = 1;
pub const g2d_cap_mode_G2D_GLOBAL_ALPHA: g2d_cap_mode = 2;
pub const g2d_cap_mode_G2D_BLEND_DIM: g2d_cap_mode = 3;
pub const g2d_cap_mode_G2D_BLUR: g2d_cap_mode = 4;
pub const g2d_cap_mode_G2D_YUV_BT_601: g2d_cap_mode = 5;
pub const g2d_cap_mode_G2D_YUV_BT_709: g2d_cap_mode = 6;
pub const g2d_cap_mode_G2D_YUV_BT_601FR: g2d_cap_mode = 7;
pub const g2d_cap_mode_G2D_YUV_BT_709FR: g2d_cap_mode = 8;
pub const g2d_cap_mode_G2D_WARPING: g2d_cap_mode = 9;
pub type g2d_cap_mode = ::std::os::raw::c_uint;
pub const g2d_feature_G2D_SCALING: g2d_feature = 0;
pub const g2d_feature_G2D_ROTATION: g2d_feature = 1;
pub const g2d_feature_G2D_SRC_YUV: g2d_feature = 2;
pub const g2d_feature_G2D_DST_YUV: g2d_feature = 3;
pub const g2d_feature_G2D_MULTI_SOURCE_BLT: g2d_feature = 4;
pub const g2d_feature_G2D_FAST_CLEAR: g2d_feature = 5;
pub const g2d_feature_G2D_WARP_DEWARP: g2d_feature = 6;
pub type g2d_feature = ::std::os::raw::c_uint;
pub const g2d_rotation_G2D_ROTATION_0: g2d_rotation = 0;
pub const g2d_rotation_G2D_ROTATION_90: g2d_rotation = 1;
pub const g2d_rotation_G2D_ROTATION_180: g2d_rotation = 2;
pub const g2d_rotation_G2D_ROTATION_270: g2d_rotation = 3;
pub const g2d_rotation_G2D_FLIP_H: g2d_rotation = 4;
pub const g2d_rotation_G2D_FLIP_V: g2d_rotation = 5;
pub type g2d_rotation = ::std::os::raw::c_uint;
pub const g2d_cache_mode_G2D_CACHE_CLEAN: g2d_cache_mode = 0;
pub const g2d_cache_mode_G2D_CACHE_FLUSH: g2d_cache_mode = 1;
pub const g2d_cache_mode_G2D_CACHE_INVALIDATE: g2d_cache_mode = 2;
pub type g2d_cache_mode = ::std::os::raw::c_uint;
pub const g2d_hardware_type_G2D_HARDWARE_2D: g2d_hardware_type = 0;
pub const g2d_hardware_type_G2D_HARDWARE_VG: g2d_hardware_type = 1;
pub const g2d_hardware_type_G2D_HARDWARE_DPU_V1: g2d_hardware_type = 2;
pub const g2d_hardware_type_G2D_HARDWARE_DPU_V2: g2d_hardware_type = 3;
pub const g2d_hardware_type_G2D_HARDWARE_PXP_V1: g2d_hardware_type = 4;
pub const g2d_hardware_type_G2D_HARDWARE_PXP_V2: g2d_hardware_type = 5;
pub type g2d_hardware_type = ::std::os::raw::c_uint;
pub const g2d_status_G2D_STATUS_FAIL: g2d_status = -1;
pub const g2d_status_G2D_STATUS_OK: g2d_status = 0;
pub const g2d_status_G2D_STATUS_NOT_SUPPORTED: g2d_status = 1;
pub type g2d_status = ::std::os::raw::c_int;
pub type g2d_phys_addr_t = ::std::os::raw::c_ulong;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct g2d_surface {
    pub format: g2d_format,
    pub planes: [g2d_phys_addr_t; 3usize],
    pub left: ::std::os::raw::c_int,
    pub top: ::std::os::raw::c_int,
    pub right: ::std::os::raw::c_int,
    pub bottom: ::std::os::raw::c_int,
    #[doc = "< buffer stride, in Pixels"]
    pub stride: ::std::os::raw::c_int,
    #[doc = "< surface width, in Pixels"]
    pub width: ::std::os::raw::c_int,
    #[doc = "< surface height, in Pixels"]
    pub height: ::std::os::raw::c_int,
    #[doc = "< alpha blending parameters"]
    pub blendfunc: g2d_blend_func,
    #[doc = "< value is 0 ~ 255"]
    pub global_alpha: ::std::os::raw::c_int,
    pub clrcolor: ::std::os::raw::c_int,
    pub rot: g2d_rotation,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct g2d_surface_pair {
    pub s: g2d_surface,
    pub d: g2d_surface,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct g2d_buf {
    pub buf_handle: *mut ::std::os::raw::c_void,
    pub buf_vaddr: *mut ::std::os::raw::c_void,
    pub buf_paddr: g2d_phys_addr_t,
    pub buf_size: ::std::os::raw::c_int,
}
#[derive(Debug)]
pub struct g2d {
    __library: ::libloading::Library,
    pub g2d_open: Result<
        unsafe extern "C" fn(handle: *mut *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_close: Result<
        unsafe extern "C" fn(handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_make_current: Result<
        unsafe extern "C" fn(
            handle: *mut ::std::os::raw::c_void,
            type_: g2d_hardware_type,
        ) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_clear: Result<
        unsafe extern "C" fn(
            handle: *mut ::std::os::raw::c_void,
            area: *mut g2d_surface,
        ) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_blit: Result<
        unsafe extern "C" fn(
            handle: *mut ::std::os::raw::c_void,
            src: *mut g2d_surface,
            dst: *mut g2d_surface,
        ) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_copy: Result<
        unsafe extern "C" fn(
            handle: *mut ::std::os::raw::c_void,
            d: *mut g2d_buf,
            s: *mut g2d_buf,
            size: ::std::os::raw::c_int,
        ) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_multi_blit: Result<
        unsafe extern "C" fn(
            handle: *mut ::std::os::raw::c_void,
            sp: *mut *mut g2d_surface_pair,
            layers: ::std::os::raw::c_int,
        ) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_query_hardware: Result<
        unsafe extern "C" fn(
            handle: *mut ::std::os::raw::c_void,
            type_: g2d_hardware_type,
            available: *mut ::std::os::raw::c_int,
        ) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_query_feature: Result<
        unsafe extern "C" fn(
            handle: *mut ::std::os::raw::c_void,
            feature: g2d_feature,
            available: *mut ::std::os::raw::c_int,
        ) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_query_cap: Result<
        unsafe extern "C" fn(
            handle: *mut ::std::os::raw::c_void,
            cap: g2d_cap_mode,
            enable: *mut ::std::os::raw::c_int,
        ) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_enable: Result<
        unsafe extern "C" fn(
            handle: *mut ::std::os::raw::c_void,
            cap: g2d_cap_mode,
        ) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_disable: Result<
        unsafe extern "C" fn(
            handle: *mut ::std::os::raw::c_void,
            cap: g2d_cap_mode,
        ) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_cache_op: Result<
        unsafe extern "C" fn(buf: *mut g2d_buf, op: g2d_cache_mode) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_alloc: Result<
        unsafe extern "C" fn(
            size: ::std::os::raw::c_int,
            cacheable: ::std::os::raw::c_int,
        ) -> *mut g2d_buf,
        ::libloading::Error,
    >,
    pub g2d_free: Result<
        unsafe extern "C" fn(buf: *mut g2d_buf) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_flush: Result<
        unsafe extern "C" fn(handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
    pub g2d_finish: Result<
        unsafe extern "C" fn(handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
        ::libloading::Error,
    >,
}
impl g2d {
    pub unsafe fn new<P>(path: P) -> Result<Self, ::libloading::Error>
    where
        P: AsRef<::std::ffi::OsStr>,
    {
        let library = ::libloading::Library::new(path)?;
        Self::from_library(library)
    }
    pub unsafe fn from_library<L>(library: L) -> Result<Self, ::libloading::Error>
    where
        L: Into<::libloading::Library>,
    {
        let __library = library.into();
        let g2d_open = __library.get(b"g2d_open\0").map(|sym| *sym);
        let g2d_close = __library.get(b"g2d_close\0").map(|sym| *sym);
        let g2d_make_current = __library.get(b"g2d_make_current\0").map(|sym| *sym);
        let g2d_clear = __library.get(b"g2d_clear\0").map(|sym| *sym);
        let g2d_blit = __library.get(b"g2d_blit\0").map(|sym| *sym);
        let g2d_copy = __library.get(b"g2d_copy\0").map(|sym| *sym);
        let g2d_multi_blit = __library.get(b"g2d_multi_blit\0").map(|sym| *sym);
        let g2d_query_hardware = __library.get(b"g2d_query_hardware\0").map(|sym| *sym);
        let g2d_query_feature = __library.get(b"g2d_query_feature\0").map(|sym| *sym);
        let g2d_query_cap = __library.get(b"g2d_query_cap\0").map(|sym| *sym);
        let g2d_enable = __library.get(b"g2d_enable\0").map(|sym| *sym);
        let g2d_disable = __library.get(b"g2d_disable\0").map(|sym| *sym);
        let g2d_cache_op = __library.get(b"g2d_cache_op\0").map(|sym| *sym);
        let g2d_alloc = __library.get(b"g2d_alloc\0").map(|sym| *sym);
        let g2d_free = __library.get(b"g2d_free\0").map(|sym| *sym);
        let g2d_flush = __library.get(b"g2d_flush\0").map(|sym| *sym);
        let g2d_finish = __library.get(b"g2d_finish\0").map(|sym| *sym);
        Ok(g2d {
            __library,
            g2d_open,
            g2d_close,
            g2d_make_current,
            g2d_clear,
            g2d_blit,
            g2d_copy,
            g2d_multi_blit,
            g2d_query_hardware,
            g2d_query_feature,
            g2d_query_cap,
            g2d_enable,
            g2d_disable,
            g2d_cache_op,
            g2d_alloc,
            g2d_free,
            g2d_flush,
            g2d_finish,
        })
    }
    pub unsafe fn g2d_open(
        &self,
        handle: *mut *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int {
        (self
            .g2d_open
            .as_ref()
            .expect("Expected function, got error."))(handle)
    }
    pub unsafe fn g2d_close(&self, handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int {
        (self
            .g2d_close
            .as_ref()
            .expect("Expected function, got error."))(handle)
    }
    pub unsafe fn g2d_make_current(
        &self,
        handle: *mut ::std::os::raw::c_void,
        type_: g2d_hardware_type,
    ) -> ::std::os::raw::c_int {
        (self
            .g2d_make_current
            .as_ref()
            .expect("Expected function, got error."))(handle, type_)
    }
    pub unsafe fn g2d_clear(
        &self,
        handle: *mut ::std::os::raw::c_void,
        area: *mut g2d_surface,
    ) -> ::std::os::raw::c_int {
        (self
            .g2d_clear
            .as_ref()
            .expect("Expected function, got error."))(handle, area)
    }
    pub unsafe fn g2d_blit(
        &self,
        handle: *mut ::std::os::raw::c_void,
        src: *mut g2d_surface,
        dst: *mut g2d_surface,
    ) -> ::std::os::raw::c_int {
        (self
            .g2d_blit
            .as_ref()
            .expect("Expected function, got error."))(handle, src, dst)
    }
    pub unsafe fn g2d_copy(
        &self,
        handle: *mut ::std::os::raw::c_void,
        d: *mut g2d_buf,
        s: *mut g2d_buf,
        size: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int {
        (self
            .g2d_copy
            .as_ref()
            .expect("Expected function, got error."))(handle, d, s, size)
    }
    pub unsafe fn g2d_multi_blit(
        &self,
        handle: *mut ::std::os::raw::c_void,
        sp: *mut *mut g2d_surface_pair,
        layers: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int {
        (self
            .g2d_multi_blit
            .as_ref()
            .expect("Expected function, got error."))(handle, sp, layers)
    }
    pub unsafe fn g2d_query_hardware(
        &self,
        handle: *mut ::std::os::raw::c_void,
        type_: g2d_hardware_type,
        available: *mut ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int {
        (self
            .g2d_query_hardware
            .as_ref()
            .expect("Expected function, got error."))(handle, type_, available)
    }
    pub unsafe fn g2d_query_feature(
        &self,
        handle: *mut ::std::os::raw::c_void,
        feature: g2d_feature,
        available: *mut ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int {
        (self
            .g2d_query_feature
            .as_ref()
            .expect("Expected function, got error."))(handle, feature, available)
    }
    pub unsafe fn g2d_query_cap(
        &self,
        handle: *mut ::std::os::raw::c_void,
        cap: g2d_cap_mode,
        enable: *mut ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int {
        (self
            .g2d_query_cap
            .as_ref()
            .expect("Expected function, got error."))(handle, cap, enable)
    }
    pub unsafe fn g2d_enable(
        &self,
        handle: *mut ::std::os::raw::c_void,
        cap: g2d_cap_mode,
    ) -> ::std::os::raw::c_int {
        (self
            .g2d_enable
            .as_ref()
            .expect("Expected function, got error."))(handle, cap)
    }
    pub unsafe fn g2d_disable(
        &self,
        handle: *mut ::std::os::raw::c_void,
        cap: g2d_cap_mode,
    ) -> ::std::os::raw::c_int {
        (self
            .g2d_disable
            .as_ref()
            .expect("Expected function, got error."))(handle, cap)
    }
    pub unsafe fn g2d_cache_op(
        &self,
        buf: *mut g2d_buf,
        op: g2d_cache_mode,
    ) -> ::std::os::raw::c_int {
        (self
            .g2d_cache_op
            .as_ref()
            .expect("Expected function, got error."))(buf, op)
    }
    pub unsafe fn g2d_alloc(
        &self,
        size: ::std::os::raw::c_int,
        cacheable: ::std::os::raw::c_int,
    ) -> *mut g2d_buf {
        (self
            .g2d_alloc
            .as_ref()
            .expect("Expected function, got error."))(size, cacheable)
    }
    pub unsafe fn g2d_free(&self, buf: *mut g2d_buf) -> ::std::os::raw::c_int {
        (self
            .g2d_free
            .as_ref()
            .expect("Expected function, got error."))(buf)
    }
    pub unsafe fn g2d_flush(&self, handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int {
        (self
            .g2d_flush
            .as_ref()
            .expect("Expected function, got error."))(handle)
    }
    pub unsafe fn g2d_finish(&self, handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int {
        (self
            .g2d_finish
            .as_ref()
            .expect("Expected function, got error."))(handle)
    }
}