Home | History | Annotate | Download | only in hal
      1 /* Copyright (c) Imagination Technologies Ltd.
      2  *
      3  * The contents of this file are subject to the MIT license as set out below.
      4  *
      5  * Permission is hereby granted, free of charge, to any person obtaining a copy
      6  * of this software and associated documentation files (the "Software"), to deal
      7  * in the Software without restriction, including without limitation the rights
      8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      9  * copies of the Software, and to permit persons to whom the Software is
     10  * furnished to do so, subject to the following conditions:
     11  *
     12  * The above copyright notice and this permission notice shall be included in
     13  * all copies or substantial portions of the Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     21  * THE SOFTWARE.
     22  */
     23 
     24 #ifndef IMG_GRALLOC_H
     25 #define IMG_GRALLOC_H
     26 
     27 #include <hardware/gralloc.h>
     28 
     29 /* for gralloc1_rect_t */
     30 #include <hardware/gralloc1.h>
     31 
     32 static inline int gralloc0_register_img
     33 	(const gralloc_module_t *g, buffer_handle_t handle)
     34 {
     35 	return g->registerBuffer(g, handle);
     36 }
     37 
     38 static inline int gralloc0_unregister_img
     39 	(const gralloc_module_t *g, buffer_handle_t handle)
     40 {
     41 	return g->unregisterBuffer(g, handle);
     42 }
     43 
     44 static inline int gralloc0_device_alloc_img
     45 	(alloc_device_t *d, int w, int h, int format, int usage,
     46 	 buffer_handle_t *handle, int *stride)
     47 {
     48 	return d->alloc(d, w, h, format, usage, handle, stride);
     49 }
     50 
     51 static inline int gralloc0_device_free_img
     52 	(alloc_device_t *d, buffer_handle_t handle)
     53 {
     54 	return d->free(d, handle);
     55 }
     56 
     57 static inline int gralloc0_lock_async_img
     58 	(const gralloc_module_t *g, buffer_handle_t handle, int usage,
     59 	 const gralloc1_rect_t *r, void **vaddr, int acquireFence)
     60 {
     61 	return g->lockAsync(g, handle, usage,
     62 						r->left, r->top, r->width, r->height,
     63 						vaddr, acquireFence);
     64 }
     65 
     66 static inline int gralloc0_unlock_async_img
     67 	(const gralloc_module_t *g, buffer_handle_t handle, int *releaseFence)
     68 {
     69 	return g->unlockAsync(g, handle, releaseFence);
     70 }
     71 
     72 static inline int gralloc0_blit_handle_to_handle_img
     73 	(const gralloc_module_t *g, buffer_handle_t src, buffer_handle_t dest,
     74 	 int w, int h, int x, int y, int transform, int input_fence,
     75 	 int *output_fence)
     76 {
     77 	return g->perform(g, GRALLOC_BLIT_HANDLE_TO_HANDLE_IMG, src, dest, w, h,
     78 					  x, y, transform, input_fence, output_fence);
     79 }
     80 
     81 static inline int gralloc0_get_buffer_cpu_addresses_img
     82 	(const gralloc_module_t *g, buffer_handle_t handle, void **vaddrs,
     83 	 size_t *sizes)
     84 {
     85 	return g->perform(g, GRALLOC_GET_BUFFER_CPU_ADDRESSES_IMG, handle, vaddrs,
     86 					  sizes);
     87 }
     88 
     89 static inline int gralloc0_put_buffer_cpu_addresses_img
     90 	(const gralloc_module_t *g, buffer_handle_t handle)
     91 {
     92 	return g->perform(g, GRALLOC_PUT_BUFFER_CPU_ADDRESSES_IMG, handle);
     93 }
     94 
     95 static inline int gralloc0_get_display_device_img
     96 	(const gralloc_module_t *g, void **ppvDispDev)
     97 {
     98 	return g->perform(g, GRALLOC_GET_DISPLAY_DEVICE_IMG, ppvDispDev);
     99 }
    100 
    101 static inline int gralloc0_get_display_status_img
    102 	(const gralloc_module_t *g, buffer_handle_t handle, uint32_t *pui32Status)
    103 {
    104 	return g->perform(g, GRALLOC_GET_DISPLAY_STATUS_IMG, handle, pui32Status);
    105 }
    106 
    107 #endif /* IMG_GRALLOC_H */
    108