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#ifndef __PLATFORM_GRALLOC4_H__ 40#define __PLATFORM_GRALLOC4_H__ 41 42/* --------------------------------------------------------------------------------------------------------- 43 * Include Files 44 * --------------------------------------------------------------------------------------------------------- 45 */ 46#include <linux/kernel.h> 47 48#include <stdint.h> 49 50#include <cutils/native_handle.h> 51#include <utils/Errors.h> 52 53#include <ui/PixelFormat.h> 54 55/* --------------------------------------------------------------------------------------------------------- 56 * Macros Definition 57 * --------------------------------------------------------------------------------------------------------- 58 */ 59 60namespace gralloc4 { 61 /* --------------------------------------------------------------------------------------------------------- 62 * Types and Structures Definition 63 * --------------------------------------------------------------------------------------------------------- 64 */ 65 66 /* --------------------------------------------------------------------------------------------------------- 67 * Global Functions' Prototype 68 * --------------------------------------------------------------------------------------------------------- 69 */ 70 71 /* 72 * 获取 'handle' 引用的 graphic_buffer 的 internal_format. 73 */ 74 uint64_t get_internal_format(buffer_handle_t handle); 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 void unlock(buffer_handle_t bufferHandle); 93 94 void freeBuffer(buffer_handle_t handle); 95 96 /* --------------------------------------------------------------------------------------------------------- 97 * Inline Functions Implementation 98 * --------------------------------------------------------------------------------------------------------- 99 */ 100} 101 102#endif /* __PLATFORM_GRALLOC4_H__ */ 103