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