qxl_drm.h revision 00a23bda
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
27e88f27b3Smrg#include <stddef.h>
28baaff307Smrg#include "drm.h"
29e88f27b3Smrg
3000a23bdaSmrg#if defined(__cplusplus)
3100a23bdaSmrgextern "C" {
3200a23bdaSmrg#endif
3300a23bdaSmrg
34e88f27b3Smrg/* Please note that modifications to all structs defined here are
35e88f27b3Smrg * subject to backwards-compatibility constraints.
36e88f27b3Smrg *
3700a23bdaSmrg * Do not use pointers, use __u64 instead for 32 bit / 64 bit user/kernel
38e88f27b3Smrg * compatibility Keep fields aligned to their size
39e88f27b3Smrg */
40e88f27b3Smrg
41e88f27b3Smrg#define QXL_GEM_DOMAIN_CPU 0
42e88f27b3Smrg#define QXL_GEM_DOMAIN_VRAM 1
43e88f27b3Smrg#define QXL_GEM_DOMAIN_SURFACE 2
44e88f27b3Smrg
45e88f27b3Smrg#define DRM_QXL_ALLOC       0x00
46e88f27b3Smrg#define DRM_QXL_MAP         0x01
47e88f27b3Smrg#define DRM_QXL_EXECBUFFER  0x02
48e88f27b3Smrg#define DRM_QXL_UPDATE_AREA 0x03
49e88f27b3Smrg#define DRM_QXL_GETPARAM    0x04
50e88f27b3Smrg#define DRM_QXL_CLIENTCAP   0x05
51e88f27b3Smrg
52e88f27b3Smrg#define DRM_QXL_ALLOC_SURF  0x06
53e88f27b3Smrg
54e88f27b3Smrgstruct drm_qxl_alloc {
5500a23bdaSmrg	__u32 size;
5600a23bdaSmrg	__u32 handle; /* 0 is an invalid handle */
57e88f27b3Smrg};
58e88f27b3Smrg
59e88f27b3Smrgstruct drm_qxl_map {
6000a23bdaSmrg	__u64 offset; /* use for mmap system call */
6100a23bdaSmrg	__u32 handle;
6200a23bdaSmrg	__u32 pad;
63e88f27b3Smrg};
64e88f27b3Smrg
65e88f27b3Smrg/*
66e88f27b3Smrg * dest is the bo we are writing the relocation into
67e88f27b3Smrg * src is bo we are relocating.
68e88f27b3Smrg * *(dest_handle.base_addr + dest_offset) = physical_address(src_handle.addr +
69e88f27b3Smrg * src_offset)
70e88f27b3Smrg */
71e88f27b3Smrg#define QXL_RELOC_TYPE_BO 1
72e88f27b3Smrg#define QXL_RELOC_TYPE_SURF 2
73e88f27b3Smrg
74e88f27b3Smrgstruct drm_qxl_reloc {
7500a23bdaSmrg	__u64 src_offset; /* offset into src_handle or src buffer */
7600a23bdaSmrg	__u64 dst_offset; /* offset in dest handle */
7700a23bdaSmrg	__u32 src_handle; /* dest handle to compute address from */
7800a23bdaSmrg	__u32 dst_handle; /* 0 if to command buffer */
7900a23bdaSmrg	__u32 reloc_type;
8000a23bdaSmrg	__u32 pad;
81e88f27b3Smrg};
82e88f27b3Smrg
83e88f27b3Smrgstruct drm_qxl_command {
8400a23bdaSmrg	__u64		command; /* void* */
8500a23bdaSmrg	__u64		relocs; /* struct drm_qxl_reloc* */
8600a23bdaSmrg	__u32		type;
8700a23bdaSmrg	__u32		command_size;
8800a23bdaSmrg	__u32		relocs_num;
8900a23bdaSmrg	__u32                pad;
90e88f27b3Smrg};
91e88f27b3Smrg
92e88f27b3Smrg/* XXX: call it drm_qxl_commands? */
93e88f27b3Smrgstruct drm_qxl_execbuffer {
9400a23bdaSmrg	__u32		flags;		/* for future use */
9500a23bdaSmrg	__u32		commands_num;
9600a23bdaSmrg	__u64		commands;	/* struct drm_qxl_command* */
97e88f27b3Smrg};
98e88f27b3Smrg
99e88f27b3Smrgstruct drm_qxl_update_area {
10000a23bdaSmrg	__u32 handle;
10100a23bdaSmrg	__u32 top;
10200a23bdaSmrg	__u32 left;
10300a23bdaSmrg	__u32 bottom;
10400a23bdaSmrg	__u32 right;
10500a23bdaSmrg	__u32 pad;
106e88f27b3Smrg};
107e88f27b3Smrg
108e88f27b3Smrg#define QXL_PARAM_NUM_SURFACES 1 /* rom->n_surfaces */
109e88f27b3Smrg#define QXL_PARAM_MAX_RELOCS 2
110e88f27b3Smrgstruct drm_qxl_getparam {
11100a23bdaSmrg	__u64 param;
11200a23bdaSmrg	__u64 value;
113e88f27b3Smrg};
114e88f27b3Smrg
115e88f27b3Smrg/* these are one bit values */
116e88f27b3Smrgstruct drm_qxl_clientcap {
11700a23bdaSmrg	__u32 index;
11800a23bdaSmrg	__u32 pad;
119e88f27b3Smrg};
120e88f27b3Smrg
121e88f27b3Smrgstruct drm_qxl_alloc_surf {
12200a23bdaSmrg	__u32 format;
12300a23bdaSmrg	__u32 width;
12400a23bdaSmrg	__u32 height;
12500a23bdaSmrg	__s32 stride;
12600a23bdaSmrg	__u32 handle;
12700a23bdaSmrg	__u32 pad;
128e88f27b3Smrg};
129e88f27b3Smrg
130e88f27b3Smrg#define DRM_IOCTL_QXL_ALLOC \
131e88f27b3Smrg	DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC, struct drm_qxl_alloc)
132e88f27b3Smrg
133e88f27b3Smrg#define DRM_IOCTL_QXL_MAP \
134e88f27b3Smrg	DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_MAP, struct drm_qxl_map)
135e88f27b3Smrg
136e88f27b3Smrg#define DRM_IOCTL_QXL_EXECBUFFER \
137e88f27b3Smrg	DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_EXECBUFFER,\
138e88f27b3Smrg		struct drm_qxl_execbuffer)
139e88f27b3Smrg
140e88f27b3Smrg#define DRM_IOCTL_QXL_UPDATE_AREA \
141e88f27b3Smrg	DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_UPDATE_AREA,\
142e88f27b3Smrg		struct drm_qxl_update_area)
143e88f27b3Smrg
144e88f27b3Smrg#define DRM_IOCTL_QXL_GETPARAM \
145e88f27b3Smrg	DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_GETPARAM,\
146e88f27b3Smrg		struct drm_qxl_getparam)
147e88f27b3Smrg
148e88f27b3Smrg#define DRM_IOCTL_QXL_CLIENTCAP \
149e88f27b3Smrg	DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_CLIENTCAP,\
150e88f27b3Smrg		struct drm_qxl_clientcap)
151e88f27b3Smrg
152e88f27b3Smrg#define DRM_IOCTL_QXL_ALLOC_SURF \
153e88f27b3Smrg	DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC_SURF,\
154e88f27b3Smrg		struct drm_qxl_alloc_surf)
155e88f27b3Smrg
15600a23bdaSmrg#if defined(__cplusplus)
15700a23bdaSmrg}
15800a23bdaSmrg#endif
15900a23bdaSmrg
160e88f27b3Smrg#endif
161