1 /* 2 * Copyright (C) 2016-2020 Arm Limited. All rights reserved. 3 * 4 * Copyright (C) 2008 The Android Open Source Project 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef MALI_GRALLOC_BUFFERDESCRIPTOR_H_ 20 #define MALI_GRALLOC_BUFFERDESCRIPTOR_H_ 21 22 #include "mali_gralloc_buffer.h" 23 #include "mali_gralloc_formats.h" 24 #include <string> 25 26 typedef uint64_t gralloc_buffer_descriptor_t; 27 28 std::string describe_usage(uint64_t usage); 29 30 /* A buffer_descriptor contains the requested parameters for the buffer 31 * as well as the calculated parameters that are passed to the allocator. 32 */ 33 struct buffer_descriptor_t 34 { 35 /* For validation. */ 36 uint32_t signature; 37 38 /* Requested parameters from IAllocator. */ 39 uint32_t width; 40 uint32_t height; 41 uint64_t producer_usage; 42 uint64_t consumer_usage; 43 uint64_t hal_format; 44 uint32_t layer_count; 45 mali_gralloc_format_type format_type; 46 std::string name; 47 uint64_t reserved_size; 48 49 /* 50 * Calculated values that will be passed to the allocator in order to 51 * allocate the buffer. 52 */ 53 uint64_t alloc_sizes[MAX_PLANES]; 54 uint64_t pixel_stride; 55 uint64_t alloc_format; 56 uint32_t fd_count; 57 uint32_t plane_count; 58 plane_info_t plane_info[MAX_PLANES]; 59 buffer_descriptor_tbuffer_descriptor_t60 buffer_descriptor_t() : 61 signature(0), 62 width(0), 63 height(0), 64 producer_usage(0), 65 consumer_usage(0), 66 hal_format(0), 67 layer_count(0), 68 format_type(MALI_GRALLOC_FORMAT_TYPE_USAGE), 69 reserved_size(0), 70 pixel_stride(0), 71 alloc_format(0), 72 fd_count(1), 73 plane_count(1) 74 { 75 memset(plane_info, 0, sizeof(plane_info_t) * MAX_PLANES); 76 memset(alloc_sizes, 0, sizeof(alloc_sizes)); 77 } 78 dumpbuffer_descriptor_t79 void dump(const std::string &str) const { 80 ALOGI("buffer_descriptor: %s " 81 "wh(%u %u) " 82 "usage_pc(%s 0x%" PRIx64 " %s 0x%" PRIx64 ") " 83 "hal_format(0x%" PRIx64 ") " 84 "layer_count(%u) " 85 "format_type(%u) " 86 "name(%s)" 87 "reserved_size(%" PRIu64 ") " 88 "alloc_sizes(%" PRIu64 ", %" PRIu64 ", %" PRIu64 ")" 89 "pixel_stride(%" PRIu64 ") alloc_format(0x%" PRIx64 ") fd_count(%d) " 90 "plane_count(%u) " 91 "plane[0](offset %" PRId64 ", idx %u, size %" PRIu64 " byte_stride %" PRIu64 ", wh %" PRIu64 " %" PRIu64 ")" 92 "plane[1](offset %" PRId64 ", idx %u, size %" PRIu64 " byte_stride %" PRIu64 ", wh %" PRIu64 " %" PRIu64 ")" 93 "plane[2](offset %" PRId64 ", idx %u, size %" PRIu64 " byte_stride %" PRIu64 ", wh %" PRIu64 " %" PRIu64 ")" 94 "\n", 95 str.c_str(), 96 width, height, 97 describe_usage(producer_usage).c_str(), producer_usage, 98 describe_usage(consumer_usage).c_str(), consumer_usage, 99 hal_format, 100 layer_count, 101 format_type, 102 name.c_str(), 103 reserved_size, 104 alloc_sizes[0], alloc_sizes[1], alloc_sizes[2], 105 pixel_stride, alloc_format, fd_count, 106 plane_count, 107 plane_info[0].offset, plane_info[0].fd_idx, plane_info[0].size, plane_info[0].byte_stride, plane_info[0].alloc_width, plane_info[0].alloc_height, 108 plane_info[1].offset, plane_info[1].fd_idx, plane_info[1].size, plane_info[1].byte_stride, plane_info[1].alloc_width, plane_info[1].alloc_height, 109 plane_info[2].offset, plane_info[2].fd_idx, plane_info[2].size, plane_info[2].byte_stride, plane_info[2].alloc_width, plane_info[2].alloc_height 110 ); 111 } 112 }; 113 114 #endif /* MALI_GRALLOC_BUFFERDESCRIPTOR_H_ */ 115