• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /*  --------------------------------------------------------------------------------------------------------
17  *  File:   platform_gralloc4.h
18  *
19  *  Desc:   声明对 buffer_handle_t 实例的 get metadata, import_buffer/free_buffer, lock_buffer/unlock_buffer 等接口.
20  *          这些接口都将基于 IMapper 4.0 (gralloc 4.0) 实现.
21  *
22  *          -----------------------------------------------------------------------------------
23  *          < 习语 和 缩略语 > :
24  *
25  *          -----------------------------------------------------------------------------------
26  *  Usage:
27  *
28  *  Note:
29  *
30  *  Author: ChenZhen
31  *
32  *  Log:
33  *      init.
34     ----Fri Aug 28 10:10:14 2020
35  *
36  *  --------------------------------------------------------------------------------------------------------
37  */
38 
39 
40 #ifndef __PLATFORM_GRALLOC4_H__
41 #define __PLATFORM_GRALLOC4_H__
42 
43 
44 /* ---------------------------------------------------------------------------------------------------------
45  *  Include Files
46  * ---------------------------------------------------------------------------------------------------------
47  */
48 #include <linux/kernel.h>
49 
50 #include <stdint.h>
51 
52 #include <cutils/native_handle.h>
53 #include <utils/Errors.h>
54 
55 #include <ui/PixelFormat.h>
56 
57 /* ---------------------------------------------------------------------------------------------------------
58  *  Macros Definition
59  * ---------------------------------------------------------------------------------------------------------
60  */
61 
62 
63 namespace gralloc4 {
64 /* ---------------------------------------------------------------------------------------------------------
65  *  Types and Structures Definition
66  * ---------------------------------------------------------------------------------------------------------
67  */
68 
69 
70 /* ---------------------------------------------------------------------------------------------------------
71  *  Global Functions' Prototype
72  * ---------------------------------------------------------------------------------------------------------
73  */
74 
75 /*
76  * 获取 'handle' 引用的 graphic_buffer 的 internal_format.
77  */
78 uint64_t get_internal_format(buffer_handle_t handle);
79 
80 int get_width(buffer_handle_t handle, uint64_t* width);
81 
82 int get_height(buffer_handle_t handle, uint64_t* height);
83 
84 int get_pixel_stride(buffer_handle_t handle, int* pixel_stride);
85 
86 int get_byte_stride(buffer_handle_t handle, int* byte_stride);
87 
88 int get_format_requested(buffer_handle_t handle, int* format_requested);
89 
90 int get_usage(buffer_handle_t handle, uint64_t* usage);
91 
92 int get_allocation_size(buffer_handle_t handle, uint64_t* usage);
93 
94 int get_share_fd(buffer_handle_t handle, int* share_fd);
95 
96 void unlock(buffer_handle_t bufferHandle);
97 
98 void freeBuffer(buffer_handle_t handle);
99 
100 /* ---------------------------------------------------------------------------------------------------------
101  *  Inline Functions Implementation
102  * ---------------------------------------------------------------------------------------------------------
103  */
104 }
105 
106 #endif /* __PLATFORM_GRALLOC4_H__ */
107