OSDN Git Service

minigbm: add bytes per pixel function
[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 {
19         struct driver *drv;
20         uint32_t width;
21         uint32_t height;
22         uint32_t format;
23         uint32_t tiling;
24         size_t num_planes;
25         union bo_handle handles[DRV_MAX_PLANES];
26         uint32_t offsets[DRV_MAX_PLANES];
27         uint32_t sizes[DRV_MAX_PLANES];
28         uint32_t strides[DRV_MAX_PLANES];
29         uint64_t format_modifiers[DRV_MAX_PLANES];
30         size_t total_size;
31         void *priv;
32 };
33
34 struct driver {
35         int fd;
36         struct backend *backend;
37         void *priv;
38         void *buffer_table;
39         void *map_table;
40         pthread_mutex_t driver_lock;
41 };
42
43 struct kms_item {
44         uint32_t format;
45         uint64_t modifier;
46         uint64_t usage;
47 };
48
49 struct format_metadata {
50         uint32_t priority;
51         uint32_t tiling;
52         uint64_t modifier;
53 };
54
55 struct combination {
56         uint32_t format;
57         struct format_metadata metadata;
58         uint64_t usage;
59 };
60
61 struct combinations {
62         struct combination *data;
63         uint32_t size;
64         uint32_t allocations;
65 };
66
67 struct backend
68 {
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,
73                          uint32_t format, uint32_t flags);
74         int (*bo_create_with_modifiers)(struct bo *bo,
75                                         uint32_t width, uint32_t height,
76                                         uint32_t format,
77                                         const uint64_t *modifiers,
78                                         uint32_t count);
79         int (*bo_destroy)(struct bo *bo);
80         int (*bo_import)(struct bo *bo, struct drv_import_fd_data *data);
81         void* (*bo_map)(struct bo *bo, struct map_info *data, size_t plane);
82         int (*bo_unmap)(struct bo *bo, struct map_info *data);
83         uint32_t (*resolve_format)(uint32_t format);
84         struct combinations combos;
85 };
86
87 #endif