aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDave Airlie <airlied@gmail.com>2013-09-08 20:02:56 -0400
committerGerd Hoffmann <kraxel@redhat.com>2015-06-03 08:17:38 -0400
commitdc5698e80cf724770283e10414054662bdf6ccfa (patch)
tree9c70288526995f4bb2aa3109e9b49058a2cbdef4 /include
parent16e3247da7f71f8c31f4330f739f6192a00c8b51 (diff)
Add virtio gpu driver.
This patch adds a kms driver for the virtio gpu. The xorg modesetting driver can handle the device just fine, the framebuffer for fbcon is there too. Qemu patches for the host side are under review currently. The pci version of the device comes in two variants: with and without vga compatibility. The former has a extra memory bar for the vga framebuffer, the later is a pure virtio device. The only concern for this driver is that in the virtio-vga case we have to kick out the firmware framebuffer. Initial revision has only 2d support, 3d (virgl) support requires some more work on the qemu side and will be added later. Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/drm/drmP.h1
-rw-r--r--include/uapi/linux/Kbuild1
-rw-r--r--include/uapi/linux/virtio_gpu.h204
-rw-r--r--include/uapi/linux/virtio_ids.h1
4 files changed, 207 insertions, 0 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index df6d9970d9a4..59ce5587ed90 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -814,6 +814,7 @@ struct drm_device {
814#endif 814#endif
815 815
816 struct platform_device *platformdev; /**< Platform device struture */ 816 struct platform_device *platformdev; /**< Platform device struture */
817 struct virtio_device *virtdev;
817 818
818 struct drm_sg_mem *sg; /**< Scatter gather memory */ 819 struct drm_sg_mem *sg; /**< Scatter gather memory */
819 unsigned int num_crtcs; /**< Number of CRTCs on this device */ 820 unsigned int num_crtcs; /**< Number of CRTCs on this device */
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index 1a0006a76b00..4460e5820b0e 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -430,6 +430,7 @@ header-y += virtio_balloon.h
430header-y += virtio_blk.h 430header-y += virtio_blk.h
431header-y += virtio_config.h 431header-y += virtio_config.h
432header-y += virtio_console.h 432header-y += virtio_console.h
433header-y += virtio_gpu.h
433header-y += virtio_ids.h 434header-y += virtio_ids.h
434header-y += virtio_input.h 435header-y += virtio_input.h
435header-y += virtio_net.h 436header-y += virtio_net.h
diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h
new file mode 100644
index 000000000000..571c4cbd3f93
--- /dev/null
+++ b/include/uapi/linux/virtio_gpu.h
@@ -0,0 +1,204 @@
1/*
2 * Virtio GPU Device
3 *
4 * Copyright Red Hat, Inc. 2013-2014
5 *
6 * Authors:
7 * Dave Airlie <airlied@redhat.com>
8 * Gerd Hoffmann <kraxel@redhat.com>
9 *
10 * This header is BSD licensed so anyone can use the definitions
11 * to implement compatible drivers/servers:
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of IBM nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
31 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
34 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 */
37
38#ifndef VIRTIO_GPU_HW_H
39#define VIRTIO_GPU_HW_H
40
41enum virtio_gpu_ctrl_type {
42 VIRTIO_GPU_UNDEFINED = 0,
43
44 /* 2d commands */
45 VIRTIO_GPU_CMD_GET_DISPLAY_INFO = 0x0100,
46 VIRTIO_GPU_CMD_RESOURCE_CREATE_2D,
47 VIRTIO_GPU_CMD_RESOURCE_UNREF,
48 VIRTIO_GPU_CMD_SET_SCANOUT,
49 VIRTIO_GPU_CMD_RESOURCE_FLUSH,
50 VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D,
51 VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING,
52 VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING,
53
54 /* cursor commands */
55 VIRTIO_GPU_CMD_UPDATE_CURSOR = 0x0300,
56 VIRTIO_GPU_CMD_MOVE_CURSOR,
57
58 /* success responses */
59 VIRTIO_GPU_RESP_OK_NODATA = 0x1100,
60 VIRTIO_GPU_RESP_OK_DISPLAY_INFO,
61
62 /* error responses */
63 VIRTIO_GPU_RESP_ERR_UNSPEC = 0x1200,
64 VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY,
65 VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID,
66 VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID,
67 VIRTIO_GPU_RESP_ERR_INVALID_CONTEXT_ID,
68 VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER,
69};
70
71#define VIRTIO_GPU_FLAG_FENCE (1 << 0)
72
73struct virtio_gpu_ctrl_hdr {
74 __le32 type;
75 __le32 flags;
76 __le64 fence_id;
77 __le32 ctx_id;
78 __le32 padding;
79};
80
81/* data passed in the cursor vq */
82
83struct virtio_gpu_cursor_pos {
84 __le32 scanout_id;
85 __le32 x;
86 __le32 y;
87 __le32 padding;
88};
89
90/* VIRTIO_GPU_CMD_UPDATE_CURSOR, VIRTIO_GPU_CMD_MOVE_CURSOR */
91struct virtio_gpu_update_cursor {
92 struct virtio_gpu_ctrl_hdr hdr;
93 struct virtio_gpu_cursor_pos pos; /* update & move */
94 __le32 resource_id; /* update only */
95 __le32 hot_x; /* update only */
96 __le32 hot_y; /* update only */
97 __le32 padding;
98};
99
100/* data passed in the control vq, 2d related */
101
102struct virtio_gpu_rect {
103 __le32 x;
104 __le32 y;
105 __le32 width;
106 __le32 height;
107};
108
109/* VIRTIO_GPU_CMD_RESOURCE_UNREF */
110struct virtio_gpu_resource_unref {
111 struct virtio_gpu_ctrl_hdr hdr;
112 __le32 resource_id;
113 __le32 padding;
114};
115
116/* VIRTIO_GPU_CMD_RESOURCE_CREATE_2D: create a 2d resource with a format */
117struct virtio_gpu_resource_create_2d {
118 struct virtio_gpu_ctrl_hdr hdr;
119 __le32 resource_id;
120 __le32 format;
121 __le32 width;
122 __le32 height;
123};
124
125/* VIRTIO_GPU_CMD_SET_SCANOUT */
126struct virtio_gpu_set_scanout {
127 struct virtio_gpu_ctrl_hdr hdr;
128 struct virtio_gpu_rect r;
129 __le32 scanout_id;
130 __le32 resource_id;
131};
132
133/* VIRTIO_GPU_CMD_RESOURCE_FLUSH */
134struct virtio_gpu_resource_flush {
135 struct virtio_gpu_ctrl_hdr hdr;
136 struct virtio_gpu_rect r;
137 __le32 resource_id;
138 __le32 padding;
139};
140
141/* VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D: simple transfer to_host */
142struct virtio_gpu_transfer_to_host_2d {
143 struct virtio_gpu_ctrl_hdr hdr;
144 struct virtio_gpu_rect r;
145 __le64 offset;
146 __le32 resource_id;
147 __le32 padding;
148};
149
150struct virtio_gpu_mem_entry {
151 __le64 addr;
152 __le32 length;
153 __le32 padding;
154};
155
156/* VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING */
157struct virtio_gpu_resource_attach_backing {
158 struct virtio_gpu_ctrl_hdr hdr;
159 __le32 resource_id;
160 __le32 nr_entries;
161};
162
163/* VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING */
164struct virtio_gpu_resource_detach_backing {
165 struct virtio_gpu_ctrl_hdr hdr;
166 __le32 resource_id;
167 __le32 padding;
168};
169
170/* VIRTIO_GPU_RESP_OK_DISPLAY_INFO */
171#define VIRTIO_GPU_MAX_SCANOUTS 16
172struct virtio_gpu_resp_display_info {
173 struct virtio_gpu_ctrl_hdr hdr;
174 struct virtio_gpu_display_one {
175 struct virtio_gpu_rect r;
176 __le32 enabled;
177 __le32 flags;
178 } pmodes[VIRTIO_GPU_MAX_SCANOUTS];
179};
180
181#define VIRTIO_GPU_EVENT_DISPLAY (1 << 0)
182
183struct virtio_gpu_config {
184 __u32 events_read;
185 __u32 events_clear;
186 __u32 num_scanouts;
187 __u32 reserved;
188};
189
190/* simple formats for fbcon/X use */
191enum virtio_gpu_formats {
192 VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM = 1,
193 VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM = 2,
194 VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM = 3,
195 VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM = 4,
196
197 VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM = 67,
198 VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM = 68,
199
200 VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM = 121,
201 VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM = 134,
202};
203
204#endif
diff --git a/include/uapi/linux/virtio_ids.h b/include/uapi/linux/virtio_ids.h
index 5f60aa4be50a..77925f587b15 100644
--- a/include/uapi/linux/virtio_ids.h
+++ b/include/uapi/linux/virtio_ids.h
@@ -39,6 +39,7 @@
39#define VIRTIO_ID_9P 9 /* 9p virtio console */ 39#define VIRTIO_ID_9P 9 /* 9p virtio console */
40#define VIRTIO_ID_RPROC_SERIAL 11 /* virtio remoteproc serial link */ 40#define VIRTIO_ID_RPROC_SERIAL 11 /* virtio remoteproc serial link */
41#define VIRTIO_ID_CAIF 12 /* Virtio caif */ 41#define VIRTIO_ID_CAIF 12 /* Virtio caif */
42#define VIRTIO_ID_GPU 16 /* virtio GPU */
42#define VIRTIO_ID_INPUT 18 /* virtio input */ 43#define VIRTIO_ID_INPUT 18 /* virtio input */
43 44
44#endif /* _LINUX_VIRTIO_IDS_H */ 45#endif /* _LINUX_VIRTIO_IDS_H */