1
2
3
4
5
6
7
8
9
10#ifndef __VBOX_DRV_H__
11#define __VBOX_DRV_H__
12
13#include <linux/genalloc.h>
14#include <linux/io.h>
15#include <linux/irqreturn.h>
16#include <linux/string.h>
17
18#include <drm/drm_encoder.h>
19#include <drm/drm_gem.h>
20#include <drm/drm_gem_vram_helper.h>
21
22#include "vboxvideo_guest.h"
23#include "vboxvideo_vbe.h"
24#include "hgsmi_ch_setup.h"
25
26#define DRIVER_NAME "vboxvideo"
27#define DRIVER_DESC "Oracle VM VirtualBox Graphics Card"
28#define DRIVER_DATE "20130823"
29
30#define DRIVER_MAJOR 1
31#define DRIVER_MINOR 0
32#define DRIVER_PATCHLEVEL 0
33
34#define VBOX_MAX_CURSOR_WIDTH 64
35#define VBOX_MAX_CURSOR_HEIGHT 64
36#define CURSOR_PIXEL_COUNT (VBOX_MAX_CURSOR_WIDTH * VBOX_MAX_CURSOR_HEIGHT)
37#define CURSOR_DATA_SIZE (CURSOR_PIXEL_COUNT * 4 + CURSOR_PIXEL_COUNT / 8)
38
39#define VBOX_MAX_SCREENS 32
40
41#define GUEST_HEAP_OFFSET(vbox) ((vbox)->full_vram_size - \
42 VBVA_ADAPTER_INFORMATION_SIZE)
43#define GUEST_HEAP_SIZE VBVA_ADAPTER_INFORMATION_SIZE
44#define GUEST_HEAP_USABLE_SIZE (VBVA_ADAPTER_INFORMATION_SIZE - \
45 sizeof(struct hgsmi_host_flags))
46#define HOST_FLAGS_OFFSET GUEST_HEAP_USABLE_SIZE
47
48struct vbox_private {
49
50 struct drm_device ddev;
51
52 u8 __iomem *guest_heap;
53 u8 __iomem *vbva_buffers;
54 struct gen_pool *guest_pool;
55 struct vbva_buf_ctx *vbva_info;
56 bool any_pitch;
57 u32 num_crtcs;
58
59 u32 full_vram_size;
60
61 u32 available_vram_size;
62
63 struct vbva_modehint *last_mode_hints;
64
65 int fb_mtrr;
66
67 struct mutex hw_mutex;
68 struct work_struct hotplug_work;
69 u32 input_mapping_width;
70 u32 input_mapping_height;
71
72
73
74
75 bool single_framebuffer;
76 u8 cursor_data[CURSOR_DATA_SIZE];
77};
78
79#undef CURSOR_PIXEL_COUNT
80#undef CURSOR_DATA_SIZE
81
82struct vbox_connector {
83 struct drm_connector base;
84 char name[32];
85 struct vbox_crtc *vbox_crtc;
86 struct {
87 u32 width;
88 u32 height;
89 bool disconnected;
90 } mode_hint;
91};
92
93struct vbox_crtc {
94 struct drm_crtc base;
95 bool disconnected;
96 unsigned int crtc_id;
97 u32 fb_offset;
98 bool cursor_enabled;
99 u32 x_hint;
100 u32 y_hint;
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117 u32 width;
118 u32 height;
119 u32 x;
120 u32 y;
121};
122
123struct vbox_encoder {
124 struct drm_encoder base;
125};
126
127#define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
128#define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
129#define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
130#define to_vbox_dev(x) container_of(x, struct vbox_private, ddev)
131
132bool vbox_check_supported(u16 id);
133int vbox_hw_init(struct vbox_private *vbox);
134void vbox_hw_fini(struct vbox_private *vbox);
135
136int vbox_mode_init(struct vbox_private *vbox);
137void vbox_mode_fini(struct vbox_private *vbox);
138
139void vbox_report_caps(struct vbox_private *vbox);
140
141int vbox_mm_init(struct vbox_private *vbox);
142void vbox_mm_fini(struct vbox_private *vbox);
143
144
145int vbox_irq_init(struct vbox_private *vbox);
146void vbox_irq_fini(struct vbox_private *vbox);
147void vbox_report_hotplug(struct vbox_private *vbox);
148irqreturn_t vbox_irq_handler(int irq, void *arg);
149
150
151void *hgsmi_buffer_alloc(struct gen_pool *guest_pool, size_t size,
152 u8 channel, u16 channel_info);
153void hgsmi_buffer_free(struct gen_pool *guest_pool, void *buf);
154int hgsmi_buffer_submit(struct gen_pool *guest_pool, void *buf);
155
156static inline void vbox_write_ioport(u16 index, u16 data)
157{
158 outw(index, VBE_DISPI_IOPORT_INDEX);
159 outw(data, VBE_DISPI_IOPORT_DATA);
160}
161
162#endif
163