Lines Matching full:dri
70 struct gbm_dri_device *dri = data; in dri_lookup_egl_image() local
72 if (dri->lookup_image == NULL) in dri_lookup_egl_image()
75 return dri->lookup_image(screen, image, dri->lookup_user_data); in dri_lookup_egl_image()
85 struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm); in dri_get_buffers() local
87 if (dri->get_buffers == NULL) in dri_get_buffers()
90 return dri->get_buffers(driDrawable, width, height, attachments, in dri_get_buffers()
98 struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm); in dri_flush_front_buffer() local
100 if (dri->flush_front_buffer != NULL) in dri_flush_front_buffer()
101 dri->flush_front_buffer(driDrawable, surf->dri_private); in dri_flush_front_buffer()
111 struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm); in dri_get_buffers_with_format() local
113 if (dri->get_buffers_with_format == NULL) in dri_get_buffers_with_format()
117 dri->get_buffers_with_format(driDrawable, width, height, attachments, in dri_get_buffers_with_format()
130 struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm); in image_get_buffers() local
132 if (dri->image_get_buffers == NULL) in image_get_buffers()
135 return dri->image_get_buffers(driDrawable, format, stamp, in image_get_buffers()
167 struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm); in swrast_put_image2() local
169 dri->swrast_put_image2(driDrawable, in swrast_put_image2()
199 struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm); in swrast_get_image() local
201 dri->swrast_get_image(driDrawable, in swrast_get_image()
277 dri_bind_extensions(struct gbm_dri_device *dri, in dri_bind_extensions() argument
288 field = ((char *) dri + matches[j].offset); in dri_bind_extensions()
295 field = ((char *) dri + matches[j].offset); in dri_bind_extensions()
305 dri_open_driver(struct gbm_dri_device *dri) in dri_open_driver() argument
329 /* Temporarily work around dri driver libs that need symbols in libglapi in dri_open_driver()
337 dri->driver = NULL; in dri_open_driver()
339 for (p = search_paths; p < end && dri->driver == NULL; p = next + 1) { in dri_open_driver()
348 "%.*s/tls/%s_dri.so", len, p, dri->driver_name); in dri_open_driver()
349 dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); in dri_open_driver()
351 if (dri->driver == NULL) { in dri_open_driver()
353 "%.*s/%s_dri.so", len, p, dri->driver_name); in dri_open_driver()
354 dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); in dri_open_driver()
357 if (dri->driver != NULL) in dri_open_driver()
361 if (dri->driver == NULL) { in dri_open_driver()
368 get_extensions_name = loader_get_extensions_name(dri->driver_name); in dri_open_driver()
372 get_extensions = dlsym(dri->driver, get_extensions_name); in dri_open_driver()
380 extensions = dlsym(dri->driver, __DRI_DRIVER_EXTENSIONS); in dri_open_driver()
383 dlclose(dri->driver); in dri_open_driver()
390 dri_load_driver(struct gbm_dri_device *dri) in dri_load_driver() argument
394 extensions = dri_open_driver(dri); in dri_load_driver()
398 if (dri_bind_extensions(dri, gbm_dri_device_extensions, extensions) < 0) { in dri_load_driver()
399 dlclose(dri->driver); in dri_load_driver()
404 dri->driver_extensions = extensions; in dri_load_driver()
410 dri_load_driver_swrast(struct gbm_dri_device *dri) in dri_load_driver_swrast() argument
414 extensions = dri_open_driver(dri); in dri_load_driver_swrast()
418 if (dri_bind_extensions(dri, gbm_swrast_device_extensions, extensions) < 0) { in dri_load_driver_swrast()
419 dlclose(dri->driver); in dri_load_driver_swrast()
424 dri->driver_extensions = extensions; in dri_load_driver_swrast()
430 dri_screen_create_dri2(struct gbm_dri_device *dri, char *driver_name) in dri_screen_create_dri2() argument
435 dri->driver_name = driver_name; in dri_screen_create_dri2()
436 if (dri->driver_name == NULL) in dri_screen_create_dri2()
439 ret = dri_load_driver(dri); in dri_screen_create_dri2()
441 fprintf(stderr, "failed to load driver: %s\n", dri->driver_name); in dri_screen_create_dri2()
445 dri->loader_extensions = gbm_dri_screen_extensions; in dri_screen_create_dri2()
447 if (dri->dri2 == NULL) in dri_screen_create_dri2()
450 if (dri->dri2->base.version >= 4) { in dri_screen_create_dri2()
451 dri->screen = dri->dri2->createNewScreen2(0, dri->base.fd, in dri_screen_create_dri2()
452 dri->loader_extensions, in dri_screen_create_dri2()
453 dri->driver_extensions, in dri_screen_create_dri2()
454 &dri->driver_configs, dri); in dri_screen_create_dri2()
456 dri->screen = dri->dri2->createNewScreen(0, dri->base.fd, in dri_screen_create_dri2()
457 dri->loader_extensions, in dri_screen_create_dri2()
458 &dri->driver_configs, dri); in dri_screen_create_dri2()
460 if (dri->screen == NULL) in dri_screen_create_dri2()
463 extensions = dri->core->getExtensions(dri->screen); in dri_screen_create_dri2()
464 if (dri_bind_extensions(dri, dri_core_extensions, extensions) < 0) { in dri_screen_create_dri2()
469 dri->lookup_image = NULL; in dri_screen_create_dri2()
470 dri->lookup_user_data = NULL; in dri_screen_create_dri2()
475 dri->core->destroyScreen(dri->screen); in dri_screen_create_dri2()
481 dri_screen_create_swrast(struct gbm_dri_device *dri) in dri_screen_create_swrast() argument
485 dri->driver_name = strdup("swrast"); in dri_screen_create_swrast()
486 if (dri->driver_name == NULL) in dri_screen_create_swrast()
489 ret = dri_load_driver_swrast(dri); in dri_screen_create_swrast()
495 dri->loader_extensions = gbm_dri_screen_extensions; in dri_screen_create_swrast()
497 if (dri->swrast == NULL) in dri_screen_create_swrast()
500 if (dri->swrast->base.version >= 4) { in dri_screen_create_swrast()
501 dri->screen = dri->swrast->createNewScreen2(0, dri->loader_extensions, in dri_screen_create_swrast()
502 dri->driver_extensions, in dri_screen_create_swrast()
503 &dri->driver_configs, dri); in dri_screen_create_swrast()
505 dri->screen = dri->swrast->createNewScreen(0, dri->loader_extensions, in dri_screen_create_swrast()
506 &dri->driver_configs, dri); in dri_screen_create_swrast()
508 if (dri->screen == NULL) in dri_screen_create_swrast()
511 dri->lookup_image = NULL; in dri_screen_create_swrast()
512 dri->lookup_user_data = NULL; in dri_screen_create_swrast()
518 dri_screen_create(struct gbm_dri_device *dri) in dri_screen_create() argument
522 driver_name = loader_get_driver_for_fd(dri->base.fd); in dri_screen_create()
526 return dri_screen_create_dri2(dri, driver_name); in dri_screen_create()
530 dri_screen_create_sw(struct gbm_dri_device *dri) in dri_screen_create_sw() argument
539 ret = dri_screen_create_dri2(dri, driver_name); in dri_screen_create_sw()
543 return dri_screen_create_swrast(dri); in dri_screen_create_sw()
609 struct gbm_dri_device *dri = gbm_dri_device(gbm); in gbm_dri_is_format_supported() local
621 if (dri->image->base.version <= 15 || !dri->image->queryDmaBufModifiers) { in gbm_dri_is_format_supported()
635 if (!dri->image->queryDmaBufModifiers(dri->screen, format, 0, NULL, NULL, in gbm_dri_is_format_supported()
647 struct gbm_dri_device *dri = gbm_dri_device(gbm); in gbm_dri_get_format_modifier_plane_count() local
650 if (dri->image->base.version < 16 || in gbm_dri_get_format_modifier_plane_count()
651 !dri->image->queryDmaBufFormatModifierAttribs) in gbm_dri_get_format_modifier_plane_count()
658 if (!dri->image->queryDmaBufFormatModifierAttribs( in gbm_dri_get_format_modifier_plane_count()
659 dri->screen, format, modifier, in gbm_dri_get_format_modifier_plane_count()
684 struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm); in gbm_dri_bo_get_fd() local
691 if (!dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_FD, &fd)) in gbm_dri_bo_get_fd()
698 get_number_planes(struct gbm_dri_device *dri, __DRIimage *image) in get_number_planes() argument
706 dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_NUM_PLANES, &num_planes); in get_number_planes()
717 struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm); in gbm_dri_bo_get_planes() local
720 return get_number_planes(dri, bo->image); in gbm_dri_bo_get_planes()
726 struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm); in gbm_dri_bo_get_handle_for_plane() local
731 if (!dri->image || dri->image->base.version < 13 || !dri->image->fromPlanar) { in gbm_dri_bo_get_handle_for_plane()
736 if (plane >= get_number_planes(dri, bo->image)) { in gbm_dri_bo_get_handle_for_plane()
748 __DRIimage *image = dri->image->fromPlanar(bo->image, plane, NULL); in gbm_dri_bo_get_handle_for_plane()
750 dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_HANDLE, &ret.s32); in gbm_dri_bo_get_handle_for_plane()
751 dri->image->destroyImage(image); in gbm_dri_bo_get_handle_for_plane()
754 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HANDLE, &ret.s32); in gbm_dri_bo_get_handle_for_plane()
763 struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm); in gbm_dri_bo_get_stride() local
768 if (!dri->image || dri->image->base.version < 11 || !dri->image->fromPlanar) { in gbm_dri_bo_get_stride()
777 if (plane >= get_number_planes(dri, bo->image)) { in gbm_dri_bo_get_stride()
787 image = dri->image->fromPlanar(bo->image, plane, NULL); in gbm_dri_bo_get_stride()
789 dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_STRIDE, &stride); in gbm_dri_bo_get_stride()
790 dri->image->destroyImage(image); in gbm_dri_bo_get_stride()
793 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE, &stride); in gbm_dri_bo_get_stride()
802 struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm); in gbm_dri_bo_get_offset() local
811 if (!dri->image || dri->image->base.version < 13 || !dri->image->fromPlanar) in gbm_dri_bo_get_offset()
814 if (plane >= get_number_planes(dri, bo->image)) in gbm_dri_bo_get_offset()
823 __DRIimage *image = dri->image->fromPlanar(bo->image, plane, NULL); in gbm_dri_bo_get_offset()
825 dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_OFFSET, &offset); in gbm_dri_bo_get_offset()
826 dri->image->destroyImage(image); in gbm_dri_bo_get_offset()
828 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_OFFSET, &offset); in gbm_dri_bo_get_offset()
837 struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm); in gbm_dri_bo_get_modifier() local
840 if (!dri->image || dri->image->base.version < 14) { in gbm_dri_bo_get_modifier()
851 if (!dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_MODIFIER_UPPER, in gbm_dri_bo_get_modifier()
857 if (!dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_MODIFIER_LOWER, in gbm_dri_bo_get_modifier()
869 struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm); in gbm_dri_bo_destroy() local
874 dri->image->destroyImage(bo->image); in gbm_dri_bo_destroy()
879 drmIoctl(dri->base.fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg); in gbm_dri_bo_destroy()
889 struct gbm_dri_device *dri = gbm_dri_device(gbm); in gbm_dri_bo_import() local
896 if (dri->image == NULL || dri->image->base.version < 4) { in gbm_dri_bo_import()
907 if (!dri->wl_drm) { in gbm_dri_bo_import()
912 wb = wayland_drm_buffer_get(dri->wl_drm, (struct wl_resource *) buffer); in gbm_dri_bo_import()
918 image = dri->image->dupImage(wb->driver_buffer, NULL); in gbm_dri_bo_import()
930 if (dri->lookup_image == NULL) { in gbm_dri_bo_import()
935 image = dri->lookup_image(dri->screen, buffer, dri->lookup_user_data); in gbm_dri_bo_import()
936 image = dri->image->dupImage(image, NULL); in gbm_dri_bo_import()
937 dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_FORMAT, &dri_format); in gbm_dri_bo_import()
941 dri->image->destroyImage(image); in gbm_dri_bo_import()
953 /* GBM's GBM_FORMAT_* tokens are a strict superset of the DRI FourCC in gbm_dri_bo_import()
958 image = dri->image->createImageFromFds(dri->screen, in gbm_dri_bo_import()
980 if (dri->image == NULL || dri->image->base.version < 15 || in gbm_dri_bo_import()
981 dri->image->createImageFromDmaBufs2 == NULL) { in gbm_dri_bo_import()
986 /* GBM's GBM_FORMAT_* tokens are a strict superset of the DRI FourCC in gbm_dri_bo_import()
991 image = dri->image->createImageFromDmaBufs2(dri->screen, fd_data->width, in gbm_dri_bo_import()
1017 dri->image->destroyImage(image); in gbm_dri_bo_import()
1027 if (dri->image->base.version >= 2 && in gbm_dri_bo_import()
1028 !dri->image->validateUsage(bo->image, dri_use)) { in gbm_dri_bo_import()
1030 dri->image->destroyImage(bo->image); in gbm_dri_bo_import()
1038 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_WIDTH, in gbm_dri_bo_import()
1040 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HEIGHT, in gbm_dri_bo_import()
1042 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE, in gbm_dri_bo_import()
1044 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HANDLE, in gbm_dri_bo_import()
1055 struct gbm_dri_device *dri = gbm_dri_device(gbm); in create_dumb() local
1080 ret = drmIoctl(dri->base.fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_arg); in create_dumb()
1101 drmIoctl(dri->base.fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_arg); in create_dumb()
1115 struct gbm_dri_device *dri = gbm_dri_device(gbm); in gbm_dri_bo_create() local
1120 /* Callers of this may specify a modifier, or a dri usage, but not both. The in gbm_dri_bo_create()
1127 if (usage & GBM_BO_USE_WRITE || dri->image == NULL) in gbm_dri_bo_create()
1156 if (!dri->image || dri->image->base.version < 14 || in gbm_dri_bo_create()
1157 !dri->image->createImageWithModifiers) { in gbm_dri_bo_create()
1158 fprintf(stderr, "Modifiers specified, but DRI is too old\n"); in gbm_dri_bo_create()
1176 dri->image->createImageWithModifiers(dri->screen, in gbm_dri_bo_create()
1187 bo->image = dri->image->createImage(dri->screen, width, height, in gbm_dri_bo_create()
1194 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HANDLE, in gbm_dri_bo_create()
1196 dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE, in gbm_dri_bo_create()
1212 struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm); in gbm_dri_bo_map() local
1222 if (!dri->image || dri->image->base.version < 12 || !dri->image->mapImage) { in gbm_dri_bo_map()
1227 mtx_lock(&dri->mutex); in gbm_dri_bo_map()
1228 if (!dri->context) in gbm_dri_bo_map()
1229 dri->context = dri->dri2->createNewContext(dri->screen, NULL, in gbm_dri_bo_map()
1231 assert(dri->context); in gbm_dri_bo_map()
1232 mtx_unlock(&dri->mutex); in gbm_dri_bo_map()
1234 /* GBM flags and DRI flags are the same, so just pass them on */ in gbm_dri_bo_map()
1235 return dri->image->mapImage(dri->context, bo->image, x, y, in gbm_dri_bo_map()
1243 struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm); in gbm_dri_bo_unmap() local
1253 if (!dri->context || !dri->image || in gbm_dri_bo_unmap()
1254 dri->image->base.version < 12 || !dri->image->unmapImage) in gbm_dri_bo_unmap()
1257 dri->image->unmapImage(dri->context, bo->image, map_data); in gbm_dri_bo_unmap()
1260 * Not all DRI drivers use direct maps. They may queue up DMA operations in gbm_dri_bo_unmap()
1264 if (dri->flush->base.version >= 4) in gbm_dri_bo_unmap()
1265 dri->flush->flush_with_flags(dri->context, NULL, __DRI2_FLUSH_CONTEXT, 0); in gbm_dri_bo_unmap()
1275 struct gbm_dri_device *dri = gbm_dri_device(gbm); in gbm_dri_surface_create() local
1279 (!dri->image || dri->image->base.version < 14 || in gbm_dri_surface_create()
1280 !dri->image->createImageWithModifiers)) { in gbm_dri_surface_create()
1344 struct gbm_dri_device *dri = gbm_dri_device(gbm); in dri_destroy() local
1347 if (dri->context) in dri_destroy()
1348 dri->core->destroyContext(dri->context); in dri_destroy()
1350 dri->core->destroyScreen(dri->screen); in dri_destroy()
1351 for (i = 0; dri->driver_configs[i]; i++) in dri_destroy()
1352 free((__DRIconfig *) dri->driver_configs[i]); in dri_destroy()
1353 free(dri->driver_configs); in dri_destroy()
1354 dlclose(dri->driver); in dri_destroy()
1355 free(dri->driver_name); in dri_destroy()
1357 free(dri); in dri_destroy()
1363 struct gbm_dri_device *dri; in dri_device_create() local
1367 dri = calloc(1, sizeof *dri); in dri_device_create()
1368 if (!dri) in dri_device_create()
1371 dri->base.fd = fd; in dri_device_create()
1372 dri->base.bo_create = gbm_dri_bo_create; in dri_device_create()
1373 dri->base.bo_import = gbm_dri_bo_import; in dri_device_create()
1374 dri->base.bo_map = gbm_dri_bo_map; in dri_device_create()
1375 dri->base.bo_unmap = gbm_dri_bo_unmap; in dri_device_create()
1376 dri->base.is_format_supported = gbm_dri_is_format_supported; in dri_device_create()
1377 dri->base.get_format_modifier_plane_count = in dri_device_create()
1379 dri->base.bo_write = gbm_dri_bo_write; in dri_device_create()
1380 dri->base.bo_get_fd = gbm_dri_bo_get_fd; in dri_device_create()
1381 dri->base.bo_get_planes = gbm_dri_bo_get_planes; in dri_device_create()
1382 dri->base.bo_get_handle = gbm_dri_bo_get_handle_for_plane; in dri_device_create()
1383 dri->base.bo_get_stride = gbm_dri_bo_get_stride; in dri_device_create()
1384 dri->base.bo_get_offset = gbm_dri_bo_get_offset; in dri_device_create()
1385 dri->base.bo_get_modifier = gbm_dri_bo_get_modifier; in dri_device_create()
1386 dri->base.bo_destroy = gbm_dri_bo_destroy; in dri_device_create()
1387 dri->base.destroy = dri_destroy; in dri_device_create()
1388 dri->base.surface_create = gbm_dri_surface_create; in dri_device_create()
1389 dri->base.surface_destroy = gbm_dri_surface_destroy; in dri_device_create()
1391 dri->base.name = "drm"; in dri_device_create()
1393 mtx_init(&dri->mutex, mtx_plain); in dri_device_create()
1397 ret = dri_screen_create(dri); in dri_device_create()
1399 ret = dri_screen_create_sw(dri); in dri_device_create()
1401 ret = dri_screen_create_sw(dri); in dri_device_create()
1407 return &dri->base; in dri_device_create()
1410 free(dri); in dri_device_create()
1416 .backend_name = "dri",