OSDN Git Service

rockchip: Add support for AFBC buffers
[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 #include "list.h"
17
18 struct bo
19 {
20         struct driver *drv;
21         uint32_t width;
22         uint32_t height;
23         uint32_t format;
24         uint32_t tiling;
25         size_t num_planes;
26         union bo_handle handles[DRV_MAX_PLANES];
27         uint32_t offsets[DRV_MAX_PLANES];
28         uint32_t sizes[DRV_MAX_PLANES];
29         uint32_t strides[DRV_MAX_PLANES];
30         uint64_t format_modifiers[DRV_MAX_PLANES];
31         size_t total_size;
32         void *priv;
33 };
34
35 struct driver {
36         int fd;
37         struct backend *backend;
38         void *priv;
39         void *buffer_table;
40         void *map_table;
41         pthread_mutex_t driver_lock;
42 };
43
44 struct map_info {
45         void *addr;
46         size_t length;
47         uint32_t handle;
48         int32_t refcount;
49         void *priv;
50 };
51
52 struct supported_combination {
53         uint32_t format;
54         uint64_t modifier;
55         uint64_t usage;
56 };
57
58 struct combination_list_element {
59         struct supported_combination combination;
60         struct list_head link;
61 };
62
63 struct backend
64 {
65         char *name;
66         int (*init)(struct driver *drv);
67         void (*close)(struct driver *drv);
68         int (*bo_create)(struct bo *bo, uint32_t width, uint32_t height,
69                          uint32_t format, uint32_t flags);
70         int (*bo_create_with_modifiers)(struct bo *bo,
71                                         uint32_t width, uint32_t height,
72                                         uint32_t format,
73                                         const uint64_t *modifiers,
74                                         uint32_t count);
75         void* (*bo_map)(struct bo *bo, struct map_info *data, size_t plane);
76         int (*bo_unmap)(struct bo *bo, struct map_info *data);
77         int (*bo_destroy)(struct bo *bo);
78         uint32_t (*resolve_format)(uint32_t format);
79         struct list_head combinations;
80 };
81
82 #endif