summaryrefslogtreecommitdiff
path: root/gralloc4/src/core/mali_gralloc_bufferdescriptor.h
blob: 826af79e3ddf617e6b9e9575da2d46152073ba21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 * Copyright (C) 2016-2020 Arm Limited. All rights reserved.
 *
 * Copyright (C) 2008 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef MALI_GRALLOC_BUFFERDESCRIPTOR_H_
#define MALI_GRALLOC_BUFFERDESCRIPTOR_H_

#include "mali_gralloc_buffer.h"
#include "mali_gralloc_formats.h"
#include <string>

typedef uint64_t gralloc_buffer_descriptor_t;

std::string describe_usage(uint64_t usage);

/* A buffer_descriptor contains the requested parameters for the buffer
 * as well as the calculated parameters that are passed to the allocator.
 */
struct buffer_descriptor_t
{
	/* For validation. */
	uint32_t signature;

	/* Requested parameters from IAllocator. */
	uint32_t width;
	uint32_t height;
	uint64_t producer_usage;
	uint64_t consumer_usage;
	uint64_t hal_format;
	uint32_t layer_count;
	mali_gralloc_format_type format_type;
	std::string name;
	uint64_t reserved_size;

	/*
	 * Calculated values that will be passed to the allocator in order to
	 * allocate the buffer.
	 */
	uint64_t alloc_sizes[MAX_PLANES];
	int pixel_stride;
	uint64_t alloc_format;
	uint32_t fd_count;
	uint32_t plane_count;
	plane_info_t plane_info[MAX_PLANES];

	buffer_descriptor_t() :
	    signature(0),
	    width(0),
	    height(0),
	    producer_usage(0),
	    consumer_usage(0),
	    hal_format(0),
	    layer_count(0),
	    format_type(MALI_GRALLOC_FORMAT_TYPE_USAGE),
	    reserved_size(0),
	    pixel_stride(0),
	    alloc_format(0),
	    fd_count(1),
	    plane_count(1)
	{
		memset(plane_info, 0, sizeof(plane_info_t) * MAX_PLANES);
		memset(alloc_sizes, 0, sizeof(alloc_sizes));
	}

	void dump(const std::string &str) const {
		ALOGI("buffer_descriptor: %s "
			"wh(%u %u) "
			"usage_pc(%s 0x%" PRIx64 " %s 0x%" PRIx64 ") "
			"hal_format(0x%" PRIx64 ") "
			"layer_count(%u) "
			"format_type(%u) "
			"name(%s)"
			"reserved_size(%" PRIu64 ") "
			"alloc_sizes(%" PRIu64 ", %" PRIu64 ", %" PRIu64 ")"
			"pixel_stride(%d) alloc_format(0x%" PRIx64 ") fd_count(%d) "
			"plane_count(%u) "
			"plane[0](offset %" PRId64 ", idx %u, size %" PRIu64 " byte_stride %u, wh %u %u)"
			"plane[1](offset %" PRId64 ", idx %u, size %" PRIu64 " byte_stride %u, wh %u %u)"
			"plane[2](offset %" PRId64 ", idx %u, size %" PRIu64 " byte_stride %u, wh %u %u)"
			"\n",
			str.c_str(),
			width, height,
			describe_usage(producer_usage).c_str(), producer_usage,
			describe_usage(consumer_usage).c_str(), consumer_usage,
			hal_format,
			layer_count,
			format_type,
			name.c_str(),
			reserved_size,
			alloc_sizes[0], alloc_sizes[1], alloc_sizes[2],
			pixel_stride, alloc_format, fd_count,
			plane_count,
			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,
			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,
			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
		);
	}
};

#endif /* MALI_GRALLOC_BUFFERDESCRIPTOR_H_ */