1e88f27b3Smrg/*
2e88f27b3Smrg * Copyright 2013 Red Hat
3e88f27b3Smrg * All Rights Reserved.
4e88f27b3Smrg *
5e88f27b3Smrg * Permission is hereby granted, free of charge, to any person obtaining a
6e88f27b3Smrg * copy of this software and associated documentation files (the "Software"),
7e88f27b3Smrg * to deal in the Software without restriction, including without limitation
8e88f27b3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9e88f27b3Smrg * and/or sell copies of the Software, and to permit persons to whom the
10e88f27b3Smrg * Software is furnished to do so, subject to the following conditions:
11e88f27b3Smrg *
12e88f27b3Smrg * The above copyright notice and this permission notice (including the next
13e88f27b3Smrg * paragraph) shall be included in all copies or substantial portions of the
14e88f27b3Smrg * Software.
15e88f27b3Smrg *
16e88f27b3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17e88f27b3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18e88f27b3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19e88f27b3Smrg * THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20e88f27b3Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21e88f27b3Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22e88f27b3Smrg * OTHER DEALINGS IN THE SOFTWARE.
23e88f27b3Smrg */
24e88f27b3Smrg#ifndef QXL_DRM_H
25e88f27b3Smrg#define QXL_DRM_H
26e88f27b3Smrg
27baaff307Smrg#include "drm.h"
28e88f27b3Smrg
2900a23bdaSmrg#if defined(__cplusplus)
3000a23bdaSmrgextern "C" {
3100a23bdaSmrg#endif
3200a23bdaSmrg
33e88f27b3Smrg/* Please note that modifications to all structs defined here are
34e88f27b3Smrg * subject to backwards-compatibility constraints.
35e88f27b3Smrg *
3600a23bdaSmrg * Do not use pointers, use __u64 instead for 32 bit / 64 bit user/kernel
37e88f27b3Smrg * compatibility Keep fields aligned to their size
38e88f27b3Smrg */
39e88f27b3Smrg
40e88f27b3Smrg#define QXL_GEM_DOMAIN_CPU 0
41e88f27b3Smrg#define QXL_GEM_DOMAIN_VRAM 1
42e88f27b3Smrg#define QXL_GEM_DOMAIN_SURFACE 2
43e88f27b3Smrg
44e88f27b3Smrg#define DRM_QXL_ALLOC       0x00
45e88f27b3Smrg#define DRM_QXL_MAP         0x01
46e88f27b3Smrg#define DRM_QXL_EXECBUFFER  0x02
47e88f27b3Smrg#define DRM_QXL_UPDATE_AREA 0x03
48e88f27b3Smrg#define DRM_QXL_GETPARAM    0x04
49e88f27b3Smrg#define DRM_QXL_CLIENTCAP   0x05
50e88f27b3Smrg
51e88f27b3Smrg#define DRM_QXL_ALLOC_SURF  0x06
52e88f27b3Smrg
53e88f27b3Smrgstruct drm_qxl_alloc {
5400a23bdaSmrg	__u32 size;
5500a23bdaSmrg	__u32 handle; /* 0 is an invalid handle */
56e88f27b3Smrg};
57e88f27b3Smrg
58e88f27b3Smrgstruct drm_qxl_map {
5900a23bdaSmrg	__u64 offset; /* use for mmap system call */
6000a23bdaSmrg	__u32 handle;
6100a23bdaSmrg	__u32 pad;
62e88f27b3Smrg};
63e88f27b3Smrg
64e88f27b3Smrg/*
65e88f27b3Smrg * dest is the bo we are writing the relocation into
66e88f27b3Smrg * src is bo we are relocating.
67e88f27b3Smrg * *(dest_handle.base_addr + dest_offset) = physical_address(src_handle.addr +
68e88f27b3Smrg * src_offset)
69e88f27b3Smrg */
70e88f27b3Smrg#define QXL_RELOC_TYPE_BO 1
71e88f27b3Smrg#define QXL_RELOC_TYPE_SURF 2
72e88f27b3Smrg
73e88f27b3Smrgstruct drm_qxl_reloc {
7400a23bdaSmrg	__u64 src_offset; /* offset into src_handle or src buffer */
7500a23bdaSmrg	__u64 dst_offset; /* offset in dest handle */
7600a23bdaSmrg	__u32 src_handle; /* dest handle to compute address from */
7700a23bdaSmrg	__u32 dst_handle; /* 0 if to command buffer */
7800a23bdaSmrg	__u32 reloc_type;
7900a23bdaSmrg	__u32 pad;
80e88f27b3Smrg};
81e88f27b3Smrg
82e88f27b3Smrgstruct drm_qxl_command {
8300a23bdaSmrg	__u64		command; /* void* */
8400a23bdaSmrg	__u64		relocs; /* struct drm_qxl_reloc* */
8500a23bdaSmrg	__u32		type;
8600a23bdaSmrg	__u32		command_size;
8700a23bdaSmrg	__u32		relocs_num;
8800a23bdaSmrg	__u32                pad;
89e88f27b3Smrg};
90e88f27b3Smrg
91e88f27b3Smrgstruct drm_qxl_execbuffer {
9200a23bdaSmrg	__u32		flags;		/* for future use */
9300a23bdaSmrg	__u32		commands_num;
9400a23bdaSmrg	__u64		commands;	/* struct drm_qxl_command* */
95e88f27b3Smrg};
96e88f27b3Smrg
97e88f27b3Smrgstruct drm_qxl_update_area {
9800a23bdaSmrg	__u32 handle;
9900a23bdaSmrg	__u32 top;
10000a23bdaSmrg	__u32 left;
10100a23bdaSmrg	__u32 bottom;
10200a23bdaSmrg	__u32 right;
10300a23bdaSmrg	__u32 pad;
104e88f27b3Smrg};
105e88f27b3Smrg
106e88f27b3Smrg#define QXL_PARAM_NUM_SURFACES 1 /* rom->n_surfaces */
107e88f27b3Smrg#define QXL_PARAM_MAX_RELOCS 2
108e88f27b3Smrgstruct drm_qxl_getparam {
10900a23bdaSmrg	__u64 param;
11000a23bdaSmrg	__u64 value;
111e88f27b3Smrg};
112e88f27b3Smrg
113e88f27b3Smrg/* these are one bit values */
114e88f27b3Smrgstruct drm_qxl_clientcap {
11500a23bdaSmrg	__u32 index;
11600a23bdaSmrg	__u32 pad;
117e88f27b3Smrg};
118e88f27b3Smrg
119e88f27b3Smrgstruct drm_qxl_alloc_surf {
12000a23bdaSmrg	__u32 format;
12100a23bdaSmrg	__u32 width;
12200a23bdaSmrg	__u32 height;
12300a23bdaSmrg	__s32 stride;
12400a23bdaSmrg	__u32 handle;
12500a23bdaSmrg	__u32 pad;
126e88f27b3Smrg};
127e88f27b3Smrg
128e88f27b3Smrg#define DRM_IOCTL_QXL_ALLOC \
129e88f27b3Smrg	DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC, struct drm_qxl_alloc)
130e88f27b3Smrg
131e88f27b3Smrg#define DRM_IOCTL_QXL_MAP \
132e88f27b3Smrg	DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_MAP, struct drm_qxl_map)
133e88f27b3Smrg
134e88f27b3Smrg#define DRM_IOCTL_QXL_EXECBUFFER \
135e88f27b3Smrg	DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_EXECBUFFER,\
136e88f27b3Smrg		struct drm_qxl_execbuffer)
137e88f27b3Smrg
138e88f27b3Smrg#define DRM_IOCTL_QXL_UPDATE_AREA \
139e88f27b3Smrg	DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_UPDATE_AREA,\
140e88f27b3Smrg		struct drm_qxl_update_area)
141e88f27b3Smrg
142e88f27b3Smrg#define DRM_IOCTL_QXL_GETPARAM \
143e88f27b3Smrg	DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_GETPARAM,\
144e88f27b3Smrg		struct drm_qxl_getparam)
145e88f27b3Smrg
146e88f27b3Smrg#define DRM_IOCTL_QXL_CLIENTCAP \
147e88f27b3Smrg	DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_CLIENTCAP,\
148e88f27b3Smrg		struct drm_qxl_clientcap)
149e88f27b3Smrg
150e88f27b3Smrg#define DRM_IOCTL_QXL_ALLOC_SURF \
151e88f27b3Smrg	DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC_SURF,\
152e88f27b3Smrg		struct drm_qxl_alloc_surf)
153e88f27b3Smrg
15400a23bdaSmrg#if defined(__cplusplus)
15500a23bdaSmrg}
15600a23bdaSmrg#endif
15700a23bdaSmrg
158e88f27b3Smrg#endif
159