diff options
author | Kristian Høgsberg <[email protected]> | 2014-03-28 10:17:11 -0700 |
---|---|---|
committer | Kristian Høgsberg <[email protected]> | 2014-04-01 12:27:26 -0700 |
commit | a43d286ef7ff65087b1f051d071b829ca7b02073 (patch) | |
tree | ca66de52ed5d0f42d7473167aef75086682e7ea4 /src/gbm/backends/dri | |
parent | f54f5891be24eea2af2d1c9864a3f74c1e7648fc (diff) |
gbm: Add import from fd
Add a new import type that lets us create a gbm bo from a
DMA-BUF file descriptor.
Signed-off-by: Kristian Høgsberg <[email protected]>
Diffstat (limited to 'src/gbm/backends/dri')
-rw-r--r-- | src/gbm/backends/dri/gbm_dri.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index a674036bf6f..50fa588ff39 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -448,7 +448,7 @@ gbm_dri_bo_import(struct gbm_device *gbm, if (!wb) return NULL; - image = wb->driver_buffer; + image = dri->image->dupImage(wb->driver_buffer, NULL); switch (wb->format) { case WL_DRM_FORMAT_XRGB8888: @@ -477,6 +477,7 @@ gbm_dri_bo_import(struct gbm_device *gbm, return NULL; image = dri->lookup_image(dri->screen, buffer, dri->lookup_user_data); + image = dri->image->dupImage(image, NULL); dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_FORMAT, &dri_format); gbm_format = gbm_dri_to_gbm_format(dri_format); if (gbm_format == 0) @@ -484,6 +485,22 @@ gbm_dri_bo_import(struct gbm_device *gbm, break; } + case GBM_BO_IMPORT_FD: + { + struct gbm_import_fd_data *fd_data = buffer; + int stride = fd_data->stride, offset = 0; + + image = dri->image->createImageFromFds(dri->screen, + fd_data->width, + fd_data->height, + fd_data->format, + &fd_data->fd, 1, + &stride, &offset, + NULL); + gbm_format = fd_data->format; + break; + } + default: return NULL; } @@ -493,7 +510,7 @@ gbm_dri_bo_import(struct gbm_device *gbm, if (bo == NULL) return NULL; - bo->image = dri->image->dupImage(image, NULL); + bo->image = image; if (usage & GBM_BO_USE_SCANOUT) dri_use |= __DRI_IMAGE_USE_SCANOUT; |