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.
14 #include <sys/types.h>
24 uint32_t offsets[DRV_MAX_PLANES];
25 uint32_t sizes[DRV_MAX_PLANES];
26 uint32_t strides[DRV_MAX_PLANES];
27 uint64_t format_modifiers[DRV_MAX_PLANES];
34 struct bo_metadata meta;
36 union bo_handle handles[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;
65 int (*init)(struct driver *drv);
66 void (*close)(struct driver *drv);
67 int (*bo_create)(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
69 int (*bo_create_with_modifiers)(struct bo *bo, uint32_t width, uint32_t height,
70 uint32_t format, const uint64_t *modifiers, uint32_t count);
71 // Either both or neither _metadata functions must be implemented.
72 // If the functions are implemented, bo_create and bo_create_with_modifiers must not be.
73 int (*bo_compute_metadata)(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
74 uint64_t use_flags, const uint64_t *modifiers, uint32_t count);
75 int (*bo_create_from_metadata)(struct bo *bo);
76 int (*bo_get_plane_fd)(struct bo *bo, size_t plane);
77 int (*bo_destroy)(struct bo *bo);
78 int (*bo_import)(struct bo *bo, struct drv_import_fd_data *data);
79 void *(*bo_map)(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags);
80 int (*bo_unmap)(struct bo *bo, struct vma *vma);
81 int (*bo_invalidate)(struct bo *bo, struct mapping *mapping);
82 int (*bo_flush)(struct bo *bo, struct mapping *mapping);
83 uint32_t (*resolve_format)(struct driver *drv, uint32_t format, uint64_t use_flags);
84 size_t (*num_planes_from_modifier)(struct driver *drv, uint32_t format, uint64_t modifier);
85 int (*resource_info)(struct bo *bo, uint32_t strides[DRV_MAX_PLANES],
86 uint32_t offsets[DRV_MAX_PLANES]);
90 #define BO_USE_RENDER_MASK (BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_RENDERSCRIPT | \
91 BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | \
92 BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE)
94 #define BO_USE_TEXTURE_MASK (BO_USE_LINEAR | BO_USE_RENDERSCRIPT | BO_USE_SW_READ_OFTEN | \
95 BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | \
96 BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE)
98 #define BO_USE_SW_MASK (BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | \
99 BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY)
101 #define BO_USE_NON_GPU_HW (BO_USE_SCANOUT | BO_USE_CAMERA_WRITE | BO_USE_CAMERA_READ | \
102 BO_USE_HW_VIDEO_ENCODER | BO_USE_HW_VIDEO_DECODER)
104 #ifndef DRM_FORMAT_MOD_LINEAR
105 #define DRM_FORMAT_MOD_LINEAR DRM_FORMAT_MOD_NONE
108 #define LINEAR_METADATA (struct format_metadata) { 1, 0, DRM_FORMAT_MOD_LINEAR }