headers: Sync up some header guard changes from drm-next.
[platform/upstream/libdrm.git] / include / drm / qxl_drm.h
1 /*
2  * Copyright 2013 Red Hat
3  * All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef QXL_DRM_H
25 #define QXL_DRM_H
26
27 #include <stddef.h>
28 #include "drm.h"
29
30 #if defined(__cplusplus)
31 extern "C" {
32 #endif
33
34 /* Please note that modifications to all structs defined here are
35  * subject to backwards-compatibility constraints.
36  *
37  * Do not use pointers, use uint64_t instead for 32 bit / 64 bit user/kernel
38  * compatibility Keep fields aligned to their size
39  */
40
41 #define QXL_GEM_DOMAIN_CPU 0
42 #define QXL_GEM_DOMAIN_VRAM 1
43 #define QXL_GEM_DOMAIN_SURFACE 2
44
45 #define DRM_QXL_ALLOC       0x00
46 #define DRM_QXL_MAP         0x01
47 #define DRM_QXL_EXECBUFFER  0x02
48 #define DRM_QXL_UPDATE_AREA 0x03
49 #define DRM_QXL_GETPARAM    0x04
50 #define DRM_QXL_CLIENTCAP   0x05
51
52 #define DRM_QXL_ALLOC_SURF  0x06
53
54 struct drm_qxl_alloc {
55         uint32_t size;
56         uint32_t handle; /* 0 is an invalid handle */
57 };
58
59 struct drm_qxl_map {
60         uint64_t offset; /* use for mmap system call */
61         uint32_t handle;
62         uint32_t pad;
63 };
64
65 /*
66  * dest is the bo we are writing the relocation into
67  * src is bo we are relocating.
68  * *(dest_handle.base_addr + dest_offset) = physical_address(src_handle.addr +
69  * src_offset)
70  */
71 #define QXL_RELOC_TYPE_BO 1
72 #define QXL_RELOC_TYPE_SURF 2
73
74 struct drm_qxl_reloc {
75         uint64_t src_offset; /* offset into src_handle or src buffer */
76         uint64_t dst_offset; /* offset in dest handle */
77         uint32_t src_handle; /* dest handle to compute address from */
78         uint32_t dst_handle; /* 0 if to command buffer */
79         uint32_t reloc_type;
80         uint32_t pad;
81 };
82
83 struct drm_qxl_command {
84         uint64_t         command; /* void* */
85         uint64_t         relocs; /* struct drm_qxl_reloc* */
86         uint32_t                type;
87         uint32_t                command_size;
88         uint32_t                relocs_num;
89         uint32_t                pad;
90 };
91
92 /* XXX: call it drm_qxl_commands? */
93 struct drm_qxl_execbuffer {
94         uint32_t                flags;          /* for future use */
95         uint32_t                commands_num;
96         uint64_t         commands;      /* struct drm_qxl_command* */
97 };
98
99 struct drm_qxl_update_area {
100         uint32_t handle;
101         uint32_t top;
102         uint32_t left;
103         uint32_t bottom;
104         uint32_t right;
105         uint32_t pad;
106 };
107
108 #define QXL_PARAM_NUM_SURFACES 1 /* rom->n_surfaces */
109 #define QXL_PARAM_MAX_RELOCS 2
110 struct drm_qxl_getparam {
111         uint64_t param;
112         uint64_t value;
113 };
114
115 /* these are one bit values */
116 struct drm_qxl_clientcap {
117         uint32_t index;
118         uint32_t pad;
119 };
120
121 struct drm_qxl_alloc_surf {
122         uint32_t format;
123         uint32_t width;
124         uint32_t height;
125         int32_t stride;
126         uint32_t handle;
127         uint32_t pad;
128 };
129
130 #define DRM_IOCTL_QXL_ALLOC \
131         DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC, struct drm_qxl_alloc)
132
133 #define DRM_IOCTL_QXL_MAP \
134         DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_MAP, struct drm_qxl_map)
135
136 #define DRM_IOCTL_QXL_EXECBUFFER \
137         DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_EXECBUFFER,\
138                 struct drm_qxl_execbuffer)
139
140 #define DRM_IOCTL_QXL_UPDATE_AREA \
141         DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_UPDATE_AREA,\
142                 struct drm_qxl_update_area)
143
144 #define DRM_IOCTL_QXL_GETPARAM \
145         DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_GETPARAM,\
146                 struct drm_qxl_getparam)
147
148 #define DRM_IOCTL_QXL_CLIENTCAP \
149         DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_CLIENTCAP,\
150                 struct drm_qxl_clientcap)
151
152 #define DRM_IOCTL_QXL_ALLOC_SURF \
153         DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC_SURF,\
154                 struct drm_qxl_alloc_surf)
155
156 #if defined(__cplusplus)
157 }
158 #endif
159
160 #endif