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 int 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 name("Unnamed"), 70 reserved_size(0), 71 pixel_stride(0), 72 alloc_format(0), 73 fd_count(1), 74 plane_count(1) 75 { 76 memset(plane_info, 0, sizeof(plane_info_t) * MAX_PLANES); 77 memset(alloc_sizes, 0, sizeof(alloc_sizes)); 78 } 79 dumpbuffer_descriptor_t80 void dump(const std::string &str) const { 81 ALOGI("buffer_descriptor: %s " 82 "wh(%u %u) " 83 "usage_pc(%s 0x%" PRIx64 " %s 0x%" PRIx64 ") " 84 "hal_format(0x%" PRIx64 ") " 85 "layer_count(%u) " 86 "format_type(%u) " 87 "name(%s)" 88 "reserved_size(%" PRIu64 ") " 89 "alloc_sizes(%" PRIu64 ", %" PRIu64 ", %" PRIu64 ")" 90 "pixel_stride(%d) alloc_format(0x%" PRIx64 ") fd_count(%d) " 91 "plane_count(%u) " 92 "plane[0](offset %" PRId64 ", idx %u, size %" PRIu64 " byte_stride %u, wh %u %u)" 93 "plane[1](offset %" PRId64 ", idx %u, size %" PRIu64 " byte_stride %u, wh %u %u)" 94 "plane[2](offset %" PRId64 ", idx %u, size %" PRIu64 " byte_stride %u, wh %u %u)" 95 "\n", 96 str.c_str(), 97 width, height, 98 describe_usage(producer_usage).c_str(), producer_usage, 99 describe_usage(consumer_usage).c_str(), consumer_usage, 100 hal_format, 101 layer_count, 102 format_type, 103 name.c_str(), 104 reserved_size, 105 alloc_sizes[0], alloc_sizes[1], alloc_sizes[2], 106 pixel_stride, alloc_format, fd_count, 107 plane_count, 108 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, 109 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, 110 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 111 ); 112 } 113 }; 114 115 #endif /* MALI_GRALLOC_BUFFERDESCRIPTOR_H_ */ 116