OSDN Git Service

a608bd6ab2f008bc7d8b9b2a87dbf9779cffe187
[android-x86/hardware-intel-common-libva.git] / va / va_drmcommon.h
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. */
34 enum {
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. */
67 struct 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  * This can currently only be used for export.
94  *
95  * For export, call vaExportSurfaceHandle() with mem_type set to
96  * VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 and pass a pointer to an
97  * instance of this structure to fill.
98  * If VA_EXPORT_SURFACE_SEPARATE_LAYERS is specified on export, each
99  * layer will contain exactly one plane.  For example, an NV12
100  * surface will be exported as two layers, one of DRM_FORMAT_R8 and
101  * one of DRM_FORMAT_GR88.
102  * If VA_EXPORT_SURFACE_COMPOSED_LAYERS is specified on export,
103  * there will be exactly one layer.
104  */
105 typedef struct _VADRMPRIMESurfaceDescriptor {
106     /** Pixel format fourcc of the whole surface (VA_FOURCC_*). */
107     uint32_t fourcc;
108     /** Width of the surface in pixels. */
109     uint32_t width;
110     /** Height of the surface in pixels. */
111     uint32_t height;
112     /** Number of distinct DRM objects making up the surface. */
113     uint32_t num_objects;
114     /** Description of each object. */
115     struct {
116         /** DRM PRIME file descriptor for this object. */
117         int fd;
118         /** Total size of this object (may include regions which are
119          *  not part of the surface). */
120         uint32_t size;
121         /** Format modifier applied to this object. */
122         uint64_t drm_format_modifier;
123     } objects[4];
124     /** Number of layers making up the surface. */
125     uint32_t num_layers;
126     /** Description of each layer in the surface. */
127     struct {
128         /** DRM format fourcc of this layer (DRM_FOURCC_*). */
129         uint32_t drm_format;
130         /** Number of planes in this layer. */
131         uint32_t num_planes;
132         /** Index in the objects array of the object containing each
133          *  plane. */
134         uint32_t object_index[4];
135         /** Offset within the object of each plane. */
136         uint32_t offset[4];
137         /** Pitch of each plane. */
138         uint32_t pitch[4];
139     } layers[4];
140 } VADRMPRIMESurfaceDescriptor;
141
142
143 #endif /* VA_DRM_COMMON_H */