Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / gtk / va_drmcommon.h
blobe16f244a466d9b4b26e325ad629925cbcdb3b9e7
1 /*
2 * va_drmcommon.h - Common utilities for DRM-based drivers
4 * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #ifndef VA_DRM_COMMON_H
28 #define VA_DRM_COMMON_H
30 #include <stdint.h>
32 /** \brief DRM authentication type. */
33 enum {
34 /** \brief Disconnected. */
35 VA_DRM_AUTH_NONE = 0,
36 /**
37 * \brief Connected. Authenticated with DRI1 protocol.
39 * @deprecated
40 * This is a deprecated authentication type. All DRI-based drivers have
41 * been migrated to use the DRI2 protocol. Newly written drivers shall
42 * use DRI2 protocol only, or a custom authentication means. e.g. opt
43 * for authenticating on the VA driver side, instead of libva side.
45 VA_DRM_AUTH_DRI1 = 1,
46 /**
47 * \brief Connected. Authenticated with DRI2 protocol.
49 * This is only useful to VA/X11 drivers. The libva-x11 library provides
50 * a helper function VA_DRI2Authenticate() for authenticating the
51 * connection. However, DRI2 conformant drivers don't need to call that
52 * function since authentication happens on the libva side, implicitly.
54 VA_DRM_AUTH_DRI2 = 2,
55 /**
56 * \brief Connected. Authenticated with some alternate raw protocol.
58 * This authentication mode is mainly used in non-VA/X11 drivers.
59 * Authentication happens through some alternative method, at the
60 * discretion of the VA driver implementation.
62 VA_DRM_AUTH_CUSTOM = 3
65 /** \brief Base DRM state. */
66 struct drm_state {
67 /** \brief DRM connection descriptor. */
68 int fd;
69 /** \brief DRM authentication type. */
70 int auth_type;
71 /** \brief Reserved bytes for future use, must be zero */
72 int va_reserved[8];
75 /** \brief Kernel DRM buffer memory type. */
76 #define VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM 0x10000000
77 /** \brief DRM PRIME memory type (old version)
79 * This supports only single objects with restricted memory layout.
80 * Used with VASurfaceAttribExternalBuffers.
82 #define VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME 0x20000000
83 /** \brief DRM PRIME memory type
85 * Used with VADRMPRIMESurfaceDescriptor.
87 #define VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 0x40000000
89 /**
90 * \brief External buffer descriptor for a DRM PRIME surface.
92 * For export, call vaExportSurfaceHandle() with mem_type set to
93 * VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 and pass a pointer to an
94 * instance of this structure to fill.
95 * If VA_EXPORT_SURFACE_SEPARATE_LAYERS is specified on export, each
96 * layer will contain exactly one plane. For example, an NV12
97 * surface will be exported as two layers, one of DRM_FORMAT_R8 and
98 * one of DRM_FORMAT_GR88.
99 * If VA_EXPORT_SURFACE_COMPOSED_LAYERS is specified on export,
100 * there will be exactly one layer.
102 * For import, call vaCreateSurfaces() with the MemoryType attribute
103 * set to VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 and the
104 * ExternalBufferDescriptor attribute set to point to an array of
105 * num_surfaces instances of this structure.
106 * The number of planes which need to be provided for a given layer
107 * is dependent on both the format and the format modifier used for
108 * the objects containing it. For example, the format DRM_FORMAT_RGBA
109 * normally requires one plane, but with the format modifier
110 * I915_FORMAT_MOD_Y_TILED_CCS it requires two planes - the first
111 * being the main data plane and the second containing the color
112 * control surface.
113 * Note that a given driver may only support a subset of possible
114 * representations of a particular format. For example, it may only
115 * support NV12 surfaces when they are contained within a single DRM
116 * object, and therefore fail to create such surfaces if the two
117 * planes are in different DRM objects.
119 typedef struct _VADRMPRIMESurfaceDescriptor {
120 /** Pixel format fourcc of the whole surface (VA_FOURCC_*). */
121 uint32_t fourcc;
122 /** Width of the surface in pixels. */
123 uint32_t width;
124 /** Height of the surface in pixels. */
125 uint32_t height;
126 /** Number of distinct DRM objects making up the surface. */
127 uint32_t num_objects;
128 /** Description of each object. */
129 struct {
130 /** DRM PRIME file descriptor for this object. */
131 int fd;
132 /** Total size of this object (may include regions which are
133 * not part of the surface). */
134 uint32_t size;
135 /** Format modifier applied to this object. */
136 uint64_t drm_format_modifier;
137 } objects[4];
138 /** Number of layers making up the surface. */
139 uint32_t num_layers;
140 /** Description of each layer in the surface. */
141 struct {
142 /** DRM format fourcc of this layer (DRM_FOURCC_*). */
143 uint32_t drm_format;
144 /** Number of planes in this layer. */
145 uint32_t num_planes;
146 /** Index in the objects array of the object containing each
147 * plane. */
148 uint32_t object_index[4];
149 /** Offset within the object of each plane. */
150 uint32_t offset[4];
151 /** Pitch of each plane. */
152 uint32_t pitch[4];
153 } layers[4];
154 } VADRMPRIMESurfaceDescriptor;
156 #endif /* VA_DRM_COMMON_H */