xref: /aosp_15_r20/external/minigbm/cros_gralloc/cros_gralloc_handle.h (revision d95af8df99a05bcb8679a54dc3ab8e5cd312b38e)
1 /*
2  * Copyright 2016 The Chromium OS Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6 
7 #ifndef CROS_GRALLOC_HANDLE_H
8 #define CROS_GRALLOC_HANDLE_H
9 
10 #include <cstdint>
11 #include <cutils/native_handle.h>
12 
13 #define DRV_MAX_PLANES 4
14 #define DRV_MAX_FDS (DRV_MAX_PLANES + 1)
15 
16 struct cros_gralloc_handle : public native_handle_t {
17 	/*
18 	 * File descriptors must immediately follow the native_handle_t base and used file
19 	 * descriptors must be packed at the beginning of this array to work with
20 	 * native_handle_clone().
21 	 *
22 	 * This field contains 'num_planes' plane file descriptors followed by an optional metadata
23 	 * reserved region file descriptor if 'reserved_region_size' is greater than zero.
24 	 */
25 	int32_t fds[DRV_MAX_FDS];
26 	uint32_t strides[DRV_MAX_PLANES];
27 	uint32_t offsets[DRV_MAX_PLANES];
28 	uint32_t sizes[DRV_MAX_PLANES];
29 	uint32_t id;
30 	uint32_t width;
31 	uint32_t height;
32 	uint32_t format; /* DRM format */
33 	uint32_t tiling;
34 	uint64_t format_modifier;
35 	uint64_t use_flags; /* Buffer creation flags */
36 	uint32_t magic;
37 	uint32_t pixel_stride;
38 	int32_t droid_format;
39 	int64_t usage; /* Android usage. */
40 	uint32_t num_planes;
41 	uint64_t reserved_region_size;
42 	uint64_t total_size; /* Total allocation size */
43 } __attribute__((packed));
44 
45 typedef const struct cros_gralloc_handle *cros_gralloc_handle_t;
46 
47 #endif
48