From 117453b947da0d51b45222c4b39a6ab9639f5a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Thu, 20 Aug 2020 13:49:33 +0200 Subject: [PATCH] va: allocator: export composed layer for YUY2 and UYVY This is a result of an error reported by i965 driver which only can export composed layer for these formats. This seems to work too with iHD. These formats are not exposed as native surfaces in Gallium. Part-of: --- sys/va/gstvaallocator.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sys/va/gstvaallocator.c b/sys/va/gstvaallocator.c index 7bf3d76fc1..a065a7b385 100644 --- a/sys/va/gstvaallocator.c +++ b/sys/va/gstvaallocator.c @@ -476,6 +476,8 @@ gst_va_memory_dispose (GstMiniObject * mini_object) return TRUE; } +/* creates an exported VASurface and adds it as @buffer's memories + * qdata */ gboolean gst_va_dmabuf_setup_buffer (GstAllocator * allocator, GstBuffer * buffer, GstVaAllocationParams * params) @@ -505,10 +507,19 @@ gst_va_dmabuf_setup_buffer (GstAllocator * allocator, GstBuffer * buffer, &surface, 1)) return FALSE; - /* Each layer will contain exactly one plane. For example, an NV12 - * surface will be exported as two layers */ - export_flags = VA_EXPORT_SURFACE_SEPARATE_LAYERS - | VA_EXPORT_SURFACE_READ_WRITE; + /* FIXME(victor): find a better way since this is just a hack for + * i965 driver */ + if (fourcc == VA_FOURCC_YUY2 || fourcc == VA_FOURCC_UYVY) { + /* These are not representable as separate planes */ + export_flags = VA_EXPORT_SURFACE_COMPOSED_LAYERS; + } else { + /* Each layer will contain exactly one plane. For example, an NV12 + * surface will be exported as two layers */ + export_flags = VA_EXPORT_SURFACE_SEPARATE_LAYERS; + } + + export_flags |= VA_EXPORT_SURFACE_READ_WRITE; + if (!_export_surface_to_dmabuf (self->display, surface, export_flags, &desc)) goto failed;