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