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.
13 #include <sys/types.h>
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];
40 struct format_metadata {
48 struct format_metadata metadata;
54 const struct backend *backend;
57 struct drv_array *mappings;
58 struct drv_array *combos;
59 pthread_mutex_t driver_lock;
64 int (*init)(struct driver *drv);
65 void (*close)(struct driver *drv);
66 int (*bo_create)(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
68 int (*bo_create_with_modifiers)(struct bo *bo, uint32_t width, uint32_t height,
69 uint32_t format, const uint64_t *modifiers, uint32_t count);
70 int (*bo_destroy)(struct bo *bo);
71 int (*bo_import)(struct bo *bo, struct drv_import_fd_data *data);
72 void *(*bo_map)(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags);
73 int (*bo_unmap)(struct bo *bo, struct vma *vma);
74 int (*bo_invalidate)(struct bo *bo, struct mapping *mapping);
75 int (*bo_flush)(struct bo *bo, struct mapping *mapping);
76 uint32_t (*resolve_format)(uint32_t format, uint64_t use_flags);
80 #define BO_USE_RENDER_MASK BO_USE_LINEAR | BO_USE_PROTECTED | BO_USE_RENDERING | \
81 BO_USE_RENDERSCRIPT | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | \
82 BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE
84 #define BO_USE_TEXTURE_MASK BO_USE_LINEAR | BO_USE_PROTECTED | BO_USE_RENDERSCRIPT | \
85 BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | \
86 BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE
88 #define BO_USE_SW BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | \
89 BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY
91 #define BO_USE_SW_OFTEN BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN
93 #define BO_USE_SW_RARELY BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY
95 #ifndef DRM_FORMAT_MOD_LINEAR
96 #define DRM_FORMAT_MOD_LINEAR DRM_FORMAT_MOD_NONE
99 #define LINEAR_METADATA (struct format_metadata) { 1, 0, DRM_FORMAT_MOD_LINEAR }