[Mesa-dev,1/2] dri: add initial support for R8 and {RG, GR}88 image formats.

Submitted by Gwenole Beauchesne on March 10, 2014, 4:35 p.m.

Details

Message ID 1394469360-14056-2-git-send-email-gwenole.beauchesne@intel.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Gwenole Beauchesne March 10, 2014, 4:35 p.m.
In order to support mapping of planar YUV surfaces on a per-plane basis,
it looks convenient to consider those planes as a buffer of red (8-bit),
resp. red/green (16-bit), components.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
---
 include/GL/internal/dri_interface.h |    4 ++++
 src/egl/drivers/dri2/egl_dri2.c     |   15 +++++++++++++++
 2 files changed, 19 insertions(+)

Patch hide | download patch | download mbox

diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index d028d05..3a946c3 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1060,6 +1060,8 @@  struct __DRIdri2ExtensionRec {
 #define __DRI_IMAGE_FOURCC_NV12		0x3231564e
 #define __DRI_IMAGE_FOURCC_NV16		0x3631564e
 #define __DRI_IMAGE_FOURCC_YUYV		0x56595559
+#define __DRI_IMAGE_FOURCC_R8		0x20203852
+#define __DRI_IMAGE_FOURCC_RG88		0x38384752
 
 
 /**
@@ -1080,6 +1082,8 @@  struct __DRIdri2ExtensionRec {
 #define __DRI_IMAGE_COMPONENTS_Y_U_V	0x3003
 #define __DRI_IMAGE_COMPONENTS_Y_UV	0x3004
 #define __DRI_IMAGE_COMPONENTS_Y_XUXV	0x3005
+#define __DRI_IMAGE_COMPONENTS_R	0x3006
+#define __DRI_IMAGE_COMPONENTS_RG	0x3007
 
 
 /**
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 892f1f4..7f389f6 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1430,6 +1430,16 @@  dri2_check_dma_buf_attribs(const _EGLImageAttribs *attrs)
    return EGL_TRUE;
 }
 
+#ifndef DRM_FORMAT_R8
+#define DRM_FORMAT_R8   fourcc_code('R','8',' ',' ') /* [7:0] R */
+#endif
+#ifndef DRM_FORMAT_RG88
+#define DRM_FORMAT_RG88 fourcc_code('R','G','8','8') /* [15:0] R:G 8:8 litte endian */
+#endif
+#ifndef DRM_FORMAT_GR88
+#define DRM_FORMAT_GR88 fourcc_code('G','R','8','8') /* [15:0] G:R 8:8 little endian */
+#endif
+
 /* Returns the total number of file descriptors. Zero indicates an error. */
 static unsigned
 dri2_check_dma_buf_format(const _EGLImageAttribs *attrs)
@@ -1499,6 +1509,11 @@  dri2_check_dma_buf_format(const _EGLImageAttribs *attrs)
    case DRM_FORMAT_YVU444:
       plane_n = 3;
       break;
+   case DRM_FORMAT_R8:
+   case DRM_FORMAT_RG88:
+   case DRM_FORMAT_GR88:
+      plane_n = 1;
+      break;
    default:
       _eglError(EGL_BAD_ATTRIBUTE, "invalid format");
       return 0;