Lines Matching +full:- +full:- +full:with +full:- +full:dri +full:- +full:drivers
3 * Use of this source code is governed by a BSD-style license that can be
19 #include "dri.h"
54 if ((*extensions)->name && !strcmp((*extensions)->name, name) && in lookup_extension()
55 (*extensions)->version >= min_version) { in lookup_extension()
67 * The DRI GEM namespace may be different from the minigbm's driver GEM namespace. We have
70 static int import_into_minigbm(struct dri_driver *dri, struct bo *bo) in import_into_minigbm() argument
75 if (!dri->image_extension->queryImage(bo->priv, __DRI_IMAGE_ATTRIB_FD, &prime_fd)) in import_into_minigbm()
76 return -errno; in import_into_minigbm()
78 ret = drmPrimeFDToHandle(bo->drv->fd, prime_fd, &handle); in import_into_minigbm()
80 drv_log("drmPrimeFDToHandle failed with %s\n", strerror(errno)); in import_into_minigbm()
84 bo->handles[0].u32 = handle; in import_into_minigbm()
90 * The caller is responsible for setting drv->priv to a structure that derives from dri_driver.
98 struct dri_driver *dri = drv->priv; in dri_init() local
99 dri->driver_handle = dlopen(dri_so_path, RTLD_NOW | RTLD_GLOBAL); in dri_init()
100 if (!dri->driver_handle) in dri_init()
101 return -ENODEV; in dri_init()
104 get_extensions = dlsym(dri->driver_handle, fname); in dri_init()
108 dri->extensions = get_extensions(); in dri_init()
109 if (!dri->extensions) in dri_init()
112 if (!lookup_extension(dri->extensions, __DRI_CORE, 2, in dri_init()
113 (const __DRIextension **)&dri->core_extension)) in dri_init()
117 if (!lookup_extension(dri->extensions, __DRI_DRI2, 4, in dri_init()
118 (const __DRIextension **)&dri->dri2_extension)) in dri_init()
121 dri->device = dri->dri2_extension->createNewScreen2(0, drv_get_fd(drv), loader_extensions, in dri_init()
122 dri->extensions, &dri->configs, NULL); in dri_init()
123 if (!dri->device) in dri_init()
126 dri->context = in dri_init()
127 dri->dri2_extension->createNewContext(dri->device, *dri->configs, NULL, NULL); in dri_init()
129 if (!dri->context) in dri_init()
132 if (!lookup_extension(dri->core_extension->getExtensions(dri->device), __DRI_IMAGE, 12, in dri_init()
133 (const __DRIextension **)&dri->image_extension)) in dri_init()
136 if (!lookup_extension(dri->core_extension->getExtensions(dri->device), __DRI2_FLUSH, 4, in dri_init()
137 (const __DRIextension **)&dri->flush_extension)) in dri_init()
143 dri->core_extension->destroyContext(dri->context); in dri_init()
145 dri->core_extension->destroyScreen(dri->device); in dri_init()
147 dlclose(dri->driver_handle); in dri_init()
148 dri->driver_handle = NULL; in dri_init()
149 return -ENODEV; in dri_init()
153 * The caller is responsible for freeing drv->priv.
157 struct dri_driver *dri = drv->priv; in dri_close() local
159 dri->core_extension->destroyContext(dri->context); in dri_close()
160 dri->core_extension->destroyScreen(dri->device); in dri_close()
161 dlclose(dri->driver_handle); in dri_close()
162 dri->driver_handle = NULL; in dri_close()
170 struct dri_driver *dri = bo->drv->priv; in dri_bo_create() local
172 assert(bo->num_planes == 1); in dri_bo_create()
175 /* Gallium drivers require shared to get the handle and stride. */ in dri_bo_create()
184 bo->priv = dri->image_extension->createImage(dri->device, width, height, dri_format, in dri_bo_create()
186 if (!bo->priv) { in dri_bo_create()
187 ret = -errno; in dri_bo_create()
191 ret = import_into_minigbm(dri, bo); in dri_bo_create()
195 if (!dri->image_extension->queryImage(bo->priv, __DRI_IMAGE_ATTRIB_STRIDE, &stride)) { in dri_bo_create()
196 ret = -errno; in dri_bo_create()
200 if (!dri->image_extension->queryImage(bo->priv, __DRI_IMAGE_ATTRIB_OFFSET, &offset)) { in dri_bo_create()
201 ret = -errno; in dri_bo_create()
205 bo->strides[0] = stride; in dri_bo_create()
206 bo->sizes[0] = stride * height; in dri_bo_create()
207 bo->offsets[0] = offset; in dri_bo_create()
208 bo->total_size = offset + bo->sizes[0]; in dri_bo_create()
212 dri->image_extension->destroyImage(bo->priv); in dri_bo_create()
219 struct dri_driver *dri = bo->drv->priv; in dri_bo_import() local
221 assert(bo->num_planes == 1); in dri_bo_import()
223 // clang-format off in dri_bo_import()
224 bo->priv = dri->image_extension->createImageFromFds(dri->device, data->width, data->height, in dri_bo_import()
225 data->format, data->fds, bo->num_planes, in dri_bo_import()
226 (int *)data->strides, in dri_bo_import()
227 (int *)data->offsets, NULL); in dri_bo_import()
228 // clang-format on in dri_bo_import()
229 if (!bo->priv) in dri_bo_import()
230 return -errno; in dri_bo_import()
232 ret = import_into_minigbm(dri, bo); in dri_bo_import()
234 dri->image_extension->destroyImage(bo->priv); in dri_bo_import()
243 struct dri_driver *dri = bo->drv->priv; in dri_bo_destroy() local
245 assert(bo->priv); in dri_bo_destroy()
246 dri->image_extension->destroyImage(bo->priv); in dri_bo_destroy()
247 bo->priv = NULL; in dri_bo_destroy()
254 * This relies on the underlying driver to do a decompressing and/or de-tiling
257 * This function itself is not thread-safe; we rely on the fact that the caller
258 * locks a per-driver mutex.
262 struct dri_driver *dri = bo->drv->priv; in dri_bo_map() local
264 /* GBM flags and DRI flags are the same. */ in dri_bo_map()
265 vma->addr = in dri_bo_map()
266 dri->image_extension->mapImage(dri->context, bo->priv, 0, 0, bo->width, bo->height, in dri_bo_map()
267 map_flags, (int *)&vma->map_strides[plane], &vma->priv); in dri_bo_map()
268 if (!vma->addr) in dri_bo_map()
271 return vma->addr; in dri_bo_map()
276 struct dri_driver *dri = bo->drv->priv; in dri_bo_unmap() local
278 assert(vma->priv); in dri_bo_unmap()
279 dri->image_extension->unmapImage(dri->context, bo->priv, vma->priv); in dri_bo_unmap()
284 * "Not all DRI drivers use direct maps. They may queue up DMA operations in dri_bo_unmap()
289 dri->flush_extension->flush_with_flags(dri->context, NULL, __DRI2_FLUSH_CONTEXT, 0); in dri_bo_unmap()