1/*
2 * va_drmcommon.h - Common utilities for DRM-based drivers
3 *
4 * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
5 *
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:
13 *
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.
17 *
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.
25 */
26
27#ifndef VA_DRM_COMMON_H
28#define VA_DRM_COMMON_H
29
30#include <stdint.h>
31
32
33/** \brief DRM authentication type. */
34enum {
35 /** \brief Disconnected. */
36 VA_DRM_AUTH_NONE = 0,
37 /**
38 * \brief Connected. Authenticated with DRI1 protocol.
39 *
40 * @deprecated
41 * This is a deprecated authentication type. All DRI-based drivers have
42 * been migrated to use the DRI2 protocol. Newly written drivers shall
43 * use DRI2 protocol only, or a custom authentication means. e.g. opt
44 * for authenticating on the VA driver side, instead of libva side.
45 */
46 VA_DRM_AUTH_DRI1 = 1,
47 /**
48 * \brief Connected. Authenticated with DRI2 protocol.
49 *
50 * This is only useful to VA/X11 drivers. The libva-x11 library provides
51 * a helper function VA_DRI2Authenticate() for authenticating the
52 * connection. However, DRI2 conformant drivers don't need to call that
53 * function since authentication happens on the libva side, implicitly.
54 */
55 VA_DRM_AUTH_DRI2 = 2,
56 /**
57 * \brief Connected. Authenticated with some alternate raw protocol.
58 *
59 * This authentication mode is mainly used in non-VA/X11 drivers.
60 * Authentication happens through some alternative method, at the
61 * discretion of the VA driver implementation.
62 */
63 VA_DRM_AUTH_CUSTOM = 3
64};
65
66/** \brief Base DRM state. */
67struct drm_state {
68 /** \brief DRM connection descriptor. */
69 int fd;
70 /** \brief DRM authentication type. */
71 int auth_type;
72 /** \brief Reserved bytes for future use, must be zero */
73 int va_reserved[8];
74};
75
76/** \brief Kernel DRM buffer memory type. */
77#define VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM 0x10000000
78/** \brief DRM PRIME memory type (old version)
79 *
80 * This supports only single objects with restricted memory layout.
81 * Used with VASurfaceAttribExternalBuffers.
82 */
83#define VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME 0x20000000
84/** \brief DRM PRIME memory type
85 *
86 * Used with VADRMPRIMESurfaceDescriptor.
87 */
88#define VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 0x40000000
89
90/**
91 * \brief External buffer descriptor for a DRM PRIME surface.
92 *
93 * For export, call vaExportSurfaceHandle() with mem_type set to
94 * VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 and pass a pointer to an
95 * instance of this structure to fill.
96 * If VA_EXPORT_SURFACE_SEPARATE_LAYERS is specified on export, each
97 * layer will contain exactly one plane. For example, an NV12
98 * surface will be exported as two layers, one of DRM_FORMAT_R8 and
99 * one of DRM_FORMAT_GR88.
100 * If VA_EXPORT_SURFACE_COMPOSED_LAYERS is specified on export,
101 * there will be exactly one layer.
102 *
103 * For import, call vaCreateSurfaces() with the MemoryType attribute
104 * set to VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 and the
105 * ExternalBufferDescriptor attribute set to point to an array of
106 * num_surfaces instances of this structure.
107 * The number of planes which need to be provided for a given layer
108 * is dependent on both the format and the format modifier used for
109 * the objects containing it. For example, the format DRM_FORMAT_RGBA
110 * normally requires one plane, but with the format modifier
111 * I915_FORMAT_MOD_Y_TILED_CCS it requires two planes - the first
112 * being the main data plane and the second containing the color
113 * control surface.
114 * Note that a given driver may only support a subset of possible
115 * representations of a particular format. For example, it may only
116 * support NV12 surfaces when they are contained within a single DRM
117 * object, and therefore fail to create such surfaces if the two
118 * planes are in different DRM objects.
119 * Note that backend driver will retrieve the resource represent by fd,
120 * and a valid surface ID is generated. Backend driver will not close
121 * the file descriptor. Application should handle the release of the fd.
122 * releasing the fd will not impact the existence of the surface.
123 */
124typedef struct _VADRMPRIMESurfaceDescriptor {
125 /** Pixel format fourcc of the whole surface (VA_FOURCC_*). */
126 uint32_t fourcc;
127 /** Width of the surface in pixels. */
128 uint32_t width;
129 /** Height of the surface in pixels. */
130 uint32_t height;
131 /** Number of distinct DRM objects making up the surface. */
132 uint32_t num_objects;
133 /** Description of each object. */
134 struct {
135 /** DRM PRIME file descriptor for this object. */
136 int fd;
137 /** Total size of this object (may include regions which are
138 * not part of the surface). */
139 uint32_t size;
140 /** Format modifier applied to this object. */
141 uint64_t drm_format_modifier;
142 } objects[4];
143 /** Number of layers making up the surface. */
144 uint32_t num_layers;
145 /** Description of each layer in the surface. */
146 struct {
147 /** DRM format fourcc of this layer (DRM_FOURCC_*). */
148 uint32_t drm_format;
149 /** Number of planes in this layer. */
150 uint32_t num_planes;
151 /** Index in the objects array of the object containing each
152 * plane. */
153 uint32_t object_index[4];
154 /** Offset within the object of each plane. */
155 uint32_t offset[4];
156 /** Pitch of each plane. */
157 uint32_t pitch[4];
158 } layers[4];
159} VADRMPRIMESurfaceDescriptor;
160
161/**
162 * \brief List of DRM format modifiers.
163 *
164 * To allocate surfaces with one of the modifiers specified in the array, call
165 * vaCreateSurfaces() with the VASurfaceAttribDRMFormatModifiers attribute set
166 * to point to an array of num_surfaces instances of this structure. The driver
167 * will select the optimal modifier in the list.
168 *
169 * DRM format modifiers are defined in drm_fourcc.h in the Linux kernel.
170 */
171typedef struct _VADRMFormatModifierList {
172 /** Number of modifiers. */
173 uint32_t num_modifiers;
174 /** Array of modifiers. */
175 uint64_t *modifiers;
176} VADRMFormatModifierList;
177
178
179#endif /* VA_DRM_COMMON_H */
180

source code of include/va/va_drmcommon.h