···11+/*22+ * Copyright 2013 Red Hat33+ * All Rights Reserved.44+ *55+ * Permission is hereby granted, free of charge, to any person obtaining a66+ * copy of this software and associated documentation files (the "Software"),77+ * to deal in the Software without restriction, including without limitation88+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,99+ * and/or sell copies of the Software, and to permit persons to whom the1010+ * Software is furnished to do so, subject to the following conditions:1111+ *1212+ * The above copyright notice and this permission notice (including the next1313+ * paragraph) shall be included in all copies or substantial portions of the1414+ * Software.1515+ *1616+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR1717+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,1818+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL1919+ * THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR2020+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,2121+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR2222+ * OTHER DEALINGS IN THE SOFTWARE.2323+ */2424+#ifndef VIRTGPU_DRM_H2525+#define VIRTGPU_DRM_H2626+2727+#include <stddef.h>2828+#include "drm/drm.h"2929+3030+/* Please note that modifications to all structs defined here are3131+ * subject to backwards-compatibility constraints.3232+ *3333+ * Do not use pointers, use uint64_t instead for 32 bit / 64 bit user/kernel3434+ * compatibility Keep fields aligned to their size3535+ */3636+3737+#define DRM_VIRTGPU_MAP 0x013838+#define DRM_VIRTGPU_EXECBUFFER 0x023939+#define DRM_VIRTGPU_GETPARAM 0x034040+#define DRM_VIRTGPU_RESOURCE_CREATE 0x044141+#define DRM_VIRTGPU_RESOURCE_INFO 0x054242+#define DRM_VIRTGPU_TRANSFER_FROM_HOST 0x064343+#define DRM_VIRTGPU_TRANSFER_TO_HOST 0x074444+#define DRM_VIRTGPU_WAIT 0x084545+#define DRM_VIRTGPU_GET_CAPS 0x094646+4747+struct drm_virtgpu_map {4848+ uint64_t offset; /* use for mmap system call */4949+ uint32_t handle;5050+ uint32_t pad;5151+};5252+5353+struct drm_virtgpu_execbuffer {5454+ uint32_t flags; /* for future use */5555+ uint32_t size;5656+ uint64_t command; /* void* */5757+ uint64_t bo_handles;5858+ uint32_t num_bo_handles;5959+ uint32_t pad;6060+};6161+6262+#define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */6363+6464+struct drm_virtgpu_getparam {6565+ uint64_t param;6666+ uint64_t value;6767+};6868+6969+/* NO_BO flags? NO resource flag? */7070+/* resource flag for y_0_top */7171+struct drm_virtgpu_resource_create {7272+ uint32_t target;7373+ uint32_t format;7474+ uint32_t bind;7575+ uint32_t width;7676+ uint32_t height;7777+ uint32_t depth;7878+ uint32_t array_size;7979+ uint32_t last_level;8080+ uint32_t nr_samples;8181+ uint32_t flags;8282+ uint32_t bo_handle; /* if this is set - recreate a new resource attached to this bo ? */8383+ uint32_t res_handle; /* returned by kernel */8484+ uint32_t size; /* validate transfer in the host */8585+ uint32_t stride; /* validate transfer in the host */8686+};8787+8888+struct drm_virtgpu_resource_info {8989+ uint32_t bo_handle;9090+ uint32_t res_handle;9191+ uint32_t size;9292+ uint32_t stride;9393+};9494+9595+struct drm_virtgpu_3d_box {9696+ uint32_t x;9797+ uint32_t y;9898+ uint32_t z;9999+ uint32_t w;100100+ uint32_t h;101101+ uint32_t d;102102+};103103+104104+struct drm_virtgpu_3d_transfer_to_host {105105+ uint32_t bo_handle;106106+ struct drm_virtgpu_3d_box box;107107+ uint32_t level;108108+ uint32_t offset;109109+};110110+111111+struct drm_virtgpu_3d_transfer_from_host {112112+ uint32_t bo_handle;113113+ struct drm_virtgpu_3d_box box;114114+ uint32_t level;115115+ uint32_t offset;116116+};117117+118118+#define VIRTGPU_WAIT_NOWAIT 1 /* like it */119119+struct drm_virtgpu_3d_wait {120120+ uint32_t handle; /* 0 is an invalid handle */121121+ uint32_t flags;122122+};123123+124124+struct drm_virtgpu_get_caps {125125+ uint32_t cap_set_id;126126+ uint32_t cap_set_ver;127127+ uint64_t addr;128128+ uint32_t size;129129+ uint32_t pad;130130+};131131+132132+#define DRM_IOCTL_VIRTGPU_MAP \133133+ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map)134134+135135+#define DRM_IOCTL_VIRTGPU_EXECBUFFER \136136+ DRM_IOW(DRM_COMMAND_BASE + DRM_VIRTGPU_EXECBUFFER,\137137+ struct drm_virtgpu_execbuffer)138138+139139+#define DRM_IOCTL_VIRTGPU_GETPARAM \140140+ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GETPARAM,\141141+ struct drm_virtgpu_getparam)142142+143143+#define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE \144144+ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE, \145145+ struct drm_virtgpu_resource_create)146146+147147+#define DRM_IOCTL_VIRTGPU_RESOURCE_INFO \148148+ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_INFO, \149149+ struct drm_virtgpu_resource_info)150150+151151+#define DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST \152152+ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_FROM_HOST, \153153+ struct drm_virtgpu_3d_transfer_from_host)154154+155155+#define DRM_IOCTL_VIRTGPU_TRANSFER_TO_HOST \156156+ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_TO_HOST, \157157+ struct drm_virtgpu_3d_transfer_to_host)158158+159159+#define DRM_IOCTL_VIRTGPU_WAIT \160160+ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_WAIT, \161161+ struct drm_virtgpu_3d_wait)162162+163163+#define DRM_IOCTL_VIRTGPU_GET_CAPS \164164+ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, \165165+ struct drm_virtgpu_get_caps)166166+167167+#endif