OSDN Git Service

minigbm: pass in map flags to (*bo_map) callback
[android-x86/external-minigbm.git] / drv_priv.h
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 DRV_PRIV_H
8 #define DRV_PRIV_H
9
10 #include <pthread.h>
11 #include <stdint.h>
12 #include <stdlib.h>
13 #include <sys/types.h>
14
15 #include "drv.h"
16
17 struct bo {
18         struct driver *drv;
19         uint32_t width;
20         uint32_t height;
21         uint32_t format;
22         uint32_t tiling;
23         size_t num_planes;
24         union bo_handle handles[DRV_MAX_PLANES];
25         uint32_t offsets[DRV_MAX_PLANES];
26         uint32_t sizes[DRV_MAX_PLANES];
27         uint32_t strides[DRV_MAX_PLANES];
28         uint64_t format_modifiers[DRV_MAX_PLANES];
29         uint64_t use_flags;
30         size_t total_size;
31         void *priv;
32 };
33
34 struct kms_item {
35         uint32_t format;
36         uint64_t modifier;
37         uint64_t use_flags;
38 };
39
40 struct format_metadata {
41         uint32_t priority;
42         uint32_t tiling;
43         uint64_t modifier;
44 };
45
46 struct combination {
47         uint32_t format;
48         struct format_metadata metadata;
49         uint64_t use_flags;
50 };
51
52 struct combinations {
53         struct combination *data;
54         uint32_t size;
55         uint32_t allocations;
56 };
57
58 struct driver {
59         int fd;
60         struct backend *backend;
61         void *priv;
62         void *buffer_table;
63         void *map_table;
64         struct combinations combos;
65         pthread_mutex_t driver_lock;
66 };
67
68 struct backend {
69         char *name;
70         int (*init)(struct driver *drv);
71         void (*close)(struct driver *drv);
72         int (*bo_create)(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
73                          uint64_t use_flags);
74         int (*bo_create_with_modifiers)(struct bo *bo, uint32_t width, uint32_t height,
75                                         uint32_t format, const uint64_t *modifiers, uint32_t count);
76         int (*bo_destroy)(struct bo *bo);
77         int (*bo_import)(struct bo *bo, struct drv_import_fd_data *data);
78         void *(*bo_map)(struct bo *bo, struct map_info *data, size_t plane, uint32_t map_flags);
79         int (*bo_unmap)(struct bo *bo, struct map_info *data);
80         int (*bo_flush)(struct bo *bo, struct map_info *data);
81         uint32_t (*resolve_format)(uint32_t format, uint64_t use_flags);
82 };
83
84 // clang-format off
85 #define BO_USE_RENDER_MASK BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_RENDERSCRIPT | \
86                            BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | \
87                            BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE
88
89 #define BO_USE_TEXTURE_MASK BO_USE_LINEAR | BO_USE_RENDERSCRIPT | BO_USE_SW_READ_OFTEN | \
90                             BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | \
91                             BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE
92
93 #define LINEAR_METADATA (struct format_metadata) { 0, 1, DRM_FORMAT_MOD_NONE }
94 // clang-format on
95
96 #endif