summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Negreanu <adrian.m.negreanu@intel.com>2012-07-16 12:00:16 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-07-16 13:05:17 +0200
commit598db9f90ab57460ccd68b67a9562e2966910169 (patch)
tree29eb7cd074934412b2279f25c95e5196a80d4641
parent2e11a7f8f6745d7103cf9f8e0087ae18199f14cf (diff)
drm: implement vaGetSurfaceBufferDRM().{merged}/11.drm
Signed-off-by: Adrian Negreanu <adrian.m.negreanu@intel.com> Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
-rw-r--r--src/Makefile.am5
-rw-r--r--src/i965_drv_video.c18
-rw-r--r--src/i965_output_drm.c129
-rw-r--r--src/i965_output_drm.h37
4 files changed, 189 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index a807406..55a50d4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -109,5 +109,10 @@ source_c += i965_output_dri.c
source_h += i965_output_dri.h
endif
+if USE_DRM
+source_c += i965_output_drm.c
+source_h += i965_output_drm.c
+endif
+
# Extra clean files so that maintainer-clean removes *everything*
MAINTAINERCLEANFILES = Makefile.in config.h.in
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index d091d35..3019a9a 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -37,6 +37,10 @@
# include "i965_output_dri.h"
#endif
+#ifdef HAVE_VA_DRM
+# include "i965_output_drm.h"
+#endif
+
#include "intel_driver.h"
#include "intel_memman.h"
#include "intel_batchbuffer.h"
@@ -80,6 +84,10 @@
#define IS_VA_X11(ctx) \
(((ctx)->display_type & VA_DISPLAY_MAJOR_MASK) == VA_DISPLAY_X11)
+/* Check whether we are using the VA/DRM API */
+#define IS_VA_DRM(ctx) \
+ (((ctx)->display_type & VA_DISPLAY_MAJOR_MASK) == VA_DISPLAY_DRM)
+
enum {
I965_SURFACETYPE_RGBA = 1,
I965_SURFACETYPE_YUV,
@@ -1598,6 +1606,11 @@ i965_Init(VADriverContextP ctx)
if (i965_render_init(ctx) == False)
return VA_STATUS_ERROR_UNKNOWN;
+#ifdef HAVE_VA_DRM
+ if (IS_VA_DRM(ctx) && !i965_output_drm_init(ctx))
+ return VA_STATUS_ERROR_UNKNOWN;
+#endif
+
#ifdef HAVE_VA_X11
if (IS_VA_X11(ctx) && !i965_output_dri_init(ctx))
return VA_STATUS_ERROR_UNKNOWN;
@@ -2325,6 +2338,11 @@ i965_Terminate(VADriverContextP ctx)
i965_output_dri_terminate(ctx);
#endif
+#ifdef HAVE_VA_DRM
+ if (IS_VA_DRM(ctx))
+ i965_output_drm_terminate(ctx);
+#endif
+
if (i965_render_terminate(ctx) == False)
return VA_STATUS_ERROR_UNKNOWN;
diff --git a/src/i965_output_drm.c b/src/i965_output_drm.c
new file mode 100644
index 0000000..376ccdc
--- /dev/null
+++ b/src/i965_output_drm.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "config.h"
+#include <assert.h>
+#include <va/va_drm.h>
+#include <va/va_backend_drm.h>
+#include "intel_driver.h"
+#include "i965_output_drm.h"
+#include "i965_drv_video.h"
+#include "i965_defines.h"
+
+static VAStatus
+va_GetSurfaceBufferDRM(
+ VADriverContextP ctx,
+ VASurfaceID surface,
+ VABufferInfoDRM *out_buffer_info
+)
+{
+ struct i965_driver_data * const i965 = i965_driver_data(ctx);
+ VABufferInfoDRM * const bi = out_buffer_info;
+ struct object_surface *obj_surface;
+ uint32_t name;
+
+ obj_surface = SURFACE(surface);
+ if (!obj_surface)
+ return VA_STATUS_ERROR_INVALID_SURFACE;
+
+ if (!out_buffer_info)
+ return VA_STATUS_ERROR_INVALID_PARAMETER;
+
+ if (drm_intel_bo_flink(obj_surface->bo, &name) != 0)
+ return VA_STATUS_ERROR_INVALID_SURFACE;
+
+ bi->handle = name;
+ switch (obj_surface->fourcc) {
+ case VA_FOURCC('N','V','1','2'):
+ bi->format = DRM_FORMAT_NV12;
+ bi->num_planes = 2;
+ bi->offsets[0] = 0;
+ bi->pitches[0] = obj_surface->width;
+ bi->offsets[1] = obj_surface->width * obj_surface->y_cb_offset;
+ bi->pitches[1] = obj_surface->cb_cr_pitch;
+ bi->offsets[2] = 0;
+ bi->pitches[2] = 0;
+ break;
+ case VA_FOURCC('Y','V','1','2'):
+ case VA_FOURCC('I','4','2','0'):
+ case VA_FOURCC('I','M','C','1'):
+ switch (obj_surface->subsampling) {
+ case SUBSAMPLE_YUV411:
+ bi->format = DRM_FORMAT_YUV411;
+ break;
+ case SUBSAMPLE_YUV420:
+ bi->format = DRM_FORMAT_YUV420;
+ break;
+ case SUBSAMPLE_YUV422H:
+ case SUBSAMPLE_YUV422V:
+ bi->format = DRM_FORMAT_YUV422;
+ break;
+ case SUBSAMPLE_YUV444:
+ bi->format = DRM_FORMAT_YUV444;
+ break;
+ default:
+ assert(0 && "unsupported subsampling");
+ return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
+ }
+ bi->offsets[0] = 0;
+ bi->pitches[0] = obj_surface->width;
+ bi->offsets[1] = obj_surface->width * obj_surface->y_cb_offset;
+ bi->pitches[1] = obj_surface->cb_cr_pitch;
+ bi->offsets[2] = obj_surface->width * obj_surface->y_cr_offset;
+ bi->pitches[2] = obj_surface->cb_cr_pitch;
+ break;
+ default:
+ assert(0 && "unsupported format");
+ return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
+ }
+ return VA_STATUS_SUCCESS;
+}
+
+static VAStatus
+va_GetImageBufferDRM(
+ VADriverContextP ctx,
+ VAImageID image,
+ VABufferInfoDRM *bi
+)
+{
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+bool
+i965_output_drm_init(VADriverContextP ctx)
+{
+ struct VADriverVTableDRM * const vtable = ctx->vtable_drm;
+
+ if (!vtable || vtable->version != VA_DRM_API_VERSION)
+ return false;
+
+ vtable->vaGetSurfaceBufferDRM = va_GetSurfaceBufferDRM;
+ vtable->vaGetImageBufferDRM = va_GetImageBufferDRM;
+ return true;
+}
+
+void
+i965_output_drm_terminate(VADriverContextP ctx)
+{
+}
diff --git a/src/i965_output_drm.h b/src/i965_output_drm.h
new file mode 100644
index 0000000..1e64f50
--- /dev/null
+++ b/src/i965_output_drm.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef I965_OUTPUT_DRM_H
+#define I965_OUTPUT_DRM_H
+
+#include <stdbool.h>
+#include <va/va_backend.h>
+
+bool
+i965_output_drm_init(VADriverContextP ctx);
+
+void
+i965_output_drm_terminate(VADriverContextP ctx);
+
+#endif /* I965_OUTPUT_DRM_H */