aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/intel/intel_screen.c
diff options
context:
space:
mode:
authorKristian Høgsberg <[email protected]>2013-02-02 08:38:07 -0500
committerKristian Høgsberg <[email protected]>2013-03-18 21:03:54 -0400
commit2356e28452454ed3b584af9b4d28c553c2a80769 (patch)
tree26c5e7dcf720f8b4f219236dfcd3d8259cc605b9 /src/mesa/drivers/dri/intel/intel_screen.c
parent664fe6dc844358dbc5474aa4e936c6180e86f144 (diff)
Add dri image entry point for creating image from fd
Reviewed-by: Ander Conselvan de Oliveira <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/intel/intel_screen.c')
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.c59
1 files changed, 55 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 0d39b9d3b30..32e92594c08 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -546,6 +546,10 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
return false;
*value = image->planar_format->components;
return true;
+ case __DRI_IMAGE_ATTRIB_FD:
+ if (drm_intel_bo_gem_export_to_prime(image->region->bo, value) == 0)
+ return true;
+ return false;
default:
return false;
}
@@ -623,8 +627,8 @@ intel_create_image_from_names(__DRIscreen *screen,
names[0], strides[0],
loaderPrivate);
- if (image == NULL)
- return NULL;
+ if (image == NULL)
+ return NULL;
image->planar_format = f;
for (i = 0; i < f->nplanes; i++) {
@@ -637,6 +641,52 @@ intel_create_image_from_names(__DRIscreen *screen,
}
static __DRIimage *
+intel_create_image_from_fds(__DRIscreen *screen,
+ int width, int height, int fourcc,
+ int *fds, int num_fds, int *strides, int *offsets,
+ void *loaderPrivate)
+{
+ struct intel_screen *intelScreen = screen->driverPrivate;
+ struct intel_image_format *f = NULL;
+ __DRIimage *image;
+ int i, index;
+
+ if (fds == NULL || num_fds != 1)
+ return NULL;
+
+ for (i = 0; i < ARRAY_SIZE(intel_image_formats); i++) {
+ if (intel_image_formats[i].fourcc == fourcc) {
+ f = &intel_image_formats[i];
+ }
+ }
+
+ if (f == NULL)
+ return NULL;
+
+ image = intel_allocate_image(__DRI_IMAGE_FORMAT_NONE, loaderPrivate);
+ if (image == NULL)
+ return NULL;
+
+ image->region = intel_region_alloc_for_fd(intelScreen,
+ 1, width, height,
+ strides[0], fds[0], "image");
+ if (image->region == NULL) {
+ free(image);
+ return NULL;
+ }
+
+ image->planar_format = f;
+ for (i = 0; i < f->nplanes; i++) {
+ index = f->planes[i].buffer_index;
+ image->offsets[index] = offsets[index];
+ image->strides[index] = strides[index];
+ }
+
+ return image;
+}
+
+
+static __DRIimage *
intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
{
int width, height, offset, stride, dri_format, index;
@@ -692,7 +742,7 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
}
static struct __DRIimageExtensionRec intelImageExtension = {
- .base = { __DRI_IMAGE, 6 },
+ .base = { __DRI_IMAGE, 7 },
.createImageFromName = intel_create_image_from_name,
.createImageFromRenderbuffer = intel_create_image_from_renderbuffer,
@@ -703,7 +753,8 @@ static struct __DRIimageExtensionRec intelImageExtension = {
.validateUsage = intel_validate_usage,
.createImageFromNames = intel_create_image_from_names,
.fromPlanar = intel_from_planar,
- .createImageFromTexture = intel_create_image_from_texture
+ .createImageFromTexture = intel_create_image_from_texture,
+ .createImageFromFds = intel_create_image_from_fds
};
static const __DRIextension *intelScreenExtensions[] = {