aboutsummaryrefslogtreecommitdiffstats
path: root/src/gbm/backends
diff options
context:
space:
mode:
authorLucas Stach <[email protected]>2017-06-08 20:56:17 +0200
committerEmil Velikov <[email protected]>2017-06-15 10:43:36 +0100
commit4026744fcb31f1d27c1b32e6945aadd4da415c6d (patch)
treedd1c3c8d0703e766b30f2e9b80859799b5bd015e /src/gbm/backends
parent71b78b6b0c8f42f09d4f9d3a0e72004bded4fbe8 (diff)
gbm: implement FD import with modifier
This implements a way to import FDs with modifiers on plain GBM devices, without the need to go through EGL. This is mostly to the benefit of gbm_gralloc, which can keep its dependencies low. Signed-off-by: Lucas Stach <[email protected]> Tested-by: Robert Foss <[email protected]> Reviewed-by: Daniel Stone <[email protected]>
Diffstat (limited to 'src/gbm/backends')
-rw-r--r--src/gbm/backends/dri/gbm_dri.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 7fb569078b2..19be440d48e 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -932,6 +932,60 @@ gbm_dri_bo_import(struct gbm_device *gbm,
break;
}
+ case GBM_BO_IMPORT_FD_MODIFIER:
+ {
+ struct gbm_import_fd_modifier_data *fd_data = buffer;
+ unsigned int error;
+ int fourcc;
+
+ /* Import with modifier requires createImageFromDmaBufs2 */
+ if (dri->image == NULL || dri->image->base.version < 15 ||
+ dri->image->createImageFromDmaBufs2 == NULL) {
+ errno = ENOSYS;
+ return NULL;
+ }
+
+ switch(fd_data->format) {
+ case GBM_FORMAT_RGB565:
+ fourcc = __DRI_IMAGE_FOURCC_RGB565;
+ break;
+ case GBM_FORMAT_ARGB8888:
+ case GBM_BO_FORMAT_ARGB8888:
+ fourcc = __DRI_IMAGE_FOURCC_ARGB8888;
+ break;
+ case GBM_FORMAT_XRGB8888:
+ case GBM_BO_FORMAT_XRGB8888:
+ fourcc = __DRI_IMAGE_FOURCC_XRGB8888;
+ break;
+ case GBM_FORMAT_ABGR8888:
+ fourcc = __DRI_IMAGE_FOURCC_ABGR8888;
+ break;
+ case GBM_FORMAT_XBGR8888:
+ fourcc = __DRI_IMAGE_FOURCC_XBGR8888;
+ break;
+ default:
+ errno = EINVAL;
+ return NULL;
+ }
+
+ image = dri->image->createImageFromDmaBufs2(dri->screen, fd_data->width,
+ fd_data->height, fourcc,
+ fd_data->modifier,
+ fd_data->fds,
+ fd_data->num_fds,
+ fd_data->strides,
+ fd_data->offsets,
+ 0, 0, 0, 0,
+ &error, NULL);
+ if (image == NULL) {
+ errno = ENOSYS;
+ return NULL;
+ }
+
+ gbm_format = fd_data->format;
+ break;
+ }
+
default:
errno = ENOSYS;
return NULL;