162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright 2013 Red Hat
362306a36Sopenharmony_ci * All Rights Reserved.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
662306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
762306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation
862306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
962306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
1062306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci * The above copyright notice and this permission notice (including the next
1362306a36Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
1462306a36Sopenharmony_ci * Software.
1562306a36Sopenharmony_ci *
1662306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1762306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1862306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1962306a36Sopenharmony_ci * THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
2062306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2162306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2262306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
2362306a36Sopenharmony_ci */
2462306a36Sopenharmony_ci#ifndef QXL_DRM_H
2562306a36Sopenharmony_ci#define QXL_DRM_H
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#include "drm.h"
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci#if defined(__cplusplus)
3062306a36Sopenharmony_ciextern "C" {
3162306a36Sopenharmony_ci#endif
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/* Please note that modifications to all structs defined here are
3462306a36Sopenharmony_ci * subject to backwards-compatibility constraints.
3562306a36Sopenharmony_ci *
3662306a36Sopenharmony_ci * Do not use pointers, use __u64 instead for 32 bit / 64 bit user/kernel
3762306a36Sopenharmony_ci * compatibility Keep fields aligned to their size
3862306a36Sopenharmony_ci */
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#define QXL_GEM_DOMAIN_CPU 0
4162306a36Sopenharmony_ci#define QXL_GEM_DOMAIN_VRAM 1
4262306a36Sopenharmony_ci#define QXL_GEM_DOMAIN_SURFACE 2
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci#define DRM_QXL_ALLOC       0x00
4562306a36Sopenharmony_ci#define DRM_QXL_MAP         0x01
4662306a36Sopenharmony_ci#define DRM_QXL_EXECBUFFER  0x02
4762306a36Sopenharmony_ci#define DRM_QXL_UPDATE_AREA 0x03
4862306a36Sopenharmony_ci#define DRM_QXL_GETPARAM    0x04
4962306a36Sopenharmony_ci#define DRM_QXL_CLIENTCAP   0x05
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci#define DRM_QXL_ALLOC_SURF  0x06
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_cistruct drm_qxl_alloc {
5462306a36Sopenharmony_ci	__u32 size;
5562306a36Sopenharmony_ci	__u32 handle; /* 0 is an invalid handle */
5662306a36Sopenharmony_ci};
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_cistruct drm_qxl_map {
5962306a36Sopenharmony_ci	__u64 offset; /* use for mmap system call */
6062306a36Sopenharmony_ci	__u32 handle;
6162306a36Sopenharmony_ci	__u32 pad;
6262306a36Sopenharmony_ci};
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci/*
6562306a36Sopenharmony_ci * dest is the bo we are writing the relocation into
6662306a36Sopenharmony_ci * src is bo we are relocating.
6762306a36Sopenharmony_ci * *(dest_handle.base_addr + dest_offset) = physical_address(src_handle.addr +
6862306a36Sopenharmony_ci * src_offset)
6962306a36Sopenharmony_ci */
7062306a36Sopenharmony_ci#define QXL_RELOC_TYPE_BO 1
7162306a36Sopenharmony_ci#define QXL_RELOC_TYPE_SURF 2
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_cistruct drm_qxl_reloc {
7462306a36Sopenharmony_ci	__u64 src_offset; /* offset into src_handle or src buffer */
7562306a36Sopenharmony_ci	__u64 dst_offset; /* offset in dest handle */
7662306a36Sopenharmony_ci	__u32 src_handle; /* dest handle to compute address from */
7762306a36Sopenharmony_ci	__u32 dst_handle; /* 0 if to command buffer */
7862306a36Sopenharmony_ci	__u32 reloc_type;
7962306a36Sopenharmony_ci	__u32 pad;
8062306a36Sopenharmony_ci};
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_cistruct drm_qxl_command {
8362306a36Sopenharmony_ci	__u64		command; /* void* */
8462306a36Sopenharmony_ci	__u64		relocs; /* struct drm_qxl_reloc* */
8562306a36Sopenharmony_ci	__u32		type;
8662306a36Sopenharmony_ci	__u32		command_size;
8762306a36Sopenharmony_ci	__u32		relocs_num;
8862306a36Sopenharmony_ci	__u32                pad;
8962306a36Sopenharmony_ci};
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_cistruct drm_qxl_execbuffer {
9262306a36Sopenharmony_ci	__u32		flags;		/* for future use */
9362306a36Sopenharmony_ci	__u32		commands_num;
9462306a36Sopenharmony_ci	__u64		commands;	/* struct drm_qxl_command* */
9562306a36Sopenharmony_ci};
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_cistruct drm_qxl_update_area {
9862306a36Sopenharmony_ci	__u32 handle;
9962306a36Sopenharmony_ci	__u32 top;
10062306a36Sopenharmony_ci	__u32 left;
10162306a36Sopenharmony_ci	__u32 bottom;
10262306a36Sopenharmony_ci	__u32 right;
10362306a36Sopenharmony_ci	__u32 pad;
10462306a36Sopenharmony_ci};
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci#define QXL_PARAM_NUM_SURFACES 1 /* rom->n_surfaces */
10762306a36Sopenharmony_ci#define QXL_PARAM_MAX_RELOCS 2
10862306a36Sopenharmony_cistruct drm_qxl_getparam {
10962306a36Sopenharmony_ci	__u64 param;
11062306a36Sopenharmony_ci	__u64 value;
11162306a36Sopenharmony_ci};
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci/* these are one bit values */
11462306a36Sopenharmony_cistruct drm_qxl_clientcap {
11562306a36Sopenharmony_ci	__u32 index;
11662306a36Sopenharmony_ci	__u32 pad;
11762306a36Sopenharmony_ci};
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_cistruct drm_qxl_alloc_surf {
12062306a36Sopenharmony_ci	__u32 format;
12162306a36Sopenharmony_ci	__u32 width;
12262306a36Sopenharmony_ci	__u32 height;
12362306a36Sopenharmony_ci	__s32 stride;
12462306a36Sopenharmony_ci	__u32 handle;
12562306a36Sopenharmony_ci	__u32 pad;
12662306a36Sopenharmony_ci};
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci#define DRM_IOCTL_QXL_ALLOC \
12962306a36Sopenharmony_ci	DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC, struct drm_qxl_alloc)
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci#define DRM_IOCTL_QXL_MAP \
13262306a36Sopenharmony_ci	DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_MAP, struct drm_qxl_map)
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci#define DRM_IOCTL_QXL_EXECBUFFER \
13562306a36Sopenharmony_ci	DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_EXECBUFFER,\
13662306a36Sopenharmony_ci		struct drm_qxl_execbuffer)
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci#define DRM_IOCTL_QXL_UPDATE_AREA \
13962306a36Sopenharmony_ci	DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_UPDATE_AREA,\
14062306a36Sopenharmony_ci		struct drm_qxl_update_area)
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci#define DRM_IOCTL_QXL_GETPARAM \
14362306a36Sopenharmony_ci	DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_GETPARAM,\
14462306a36Sopenharmony_ci		struct drm_qxl_getparam)
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci#define DRM_IOCTL_QXL_CLIENTCAP \
14762306a36Sopenharmony_ci	DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_CLIENTCAP,\
14862306a36Sopenharmony_ci		struct drm_qxl_clientcap)
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci#define DRM_IOCTL_QXL_ALLOC_SURF \
15162306a36Sopenharmony_ci	DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC_SURF,\
15262306a36Sopenharmony_ci		struct drm_qxl_alloc_surf)
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci#if defined(__cplusplus)
15562306a36Sopenharmony_ci}
15662306a36Sopenharmony_ci#endif
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci#endif
159