VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/drm/vbox_drv.h@ 52564

Last change on this file since 52564 was 50902, checked in by vboxsync, 11 years ago

Additions/linux/drm: add host mouse cursor support to the kernel video driver.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/** @file $Id: vbox_drv.h 50902 2014-03-26 22:05:24Z vboxsync $
2 *
3 * VirtualBox Additions Linux kernel video driver
4 */
5
6/*
7 * Copyright (C) 2013 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 * --------------------------------------------------------------------
17 *
18 * This code is based on
19 * ast_drv.h
20 * with the following copyright and permission notice:
21 *
22 * Copyright 2012 Red Hat Inc.
23 *
24 * Permission is hereby granted, free of charge, to any person obtaining a
25 * copy of this software and associated documentation files (the
26 * "Software"), to deal in the Software without restriction, including
27 * without limitation the rights to use, copy, modify, merge, publish,
28 * distribute, sub license, and/or sell copies of the Software, and to
29 * permit persons to whom the Software is furnished to do so, subject to
30 * the following conditions:
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
35 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
36 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
37 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
38 * USE OR OTHER DEALINGS IN THE SOFTWARE.
39 *
40 * The above copyright notice and this permission notice (including the
41 * next paragraph) shall be included in all copies or substantial portions
42 * of the Software.
43 *
44 */
45/*
46 * Authors: Dave Airlie <airlied@redhat.com>
47 */
48#ifndef __VBOX_DRV_H__
49#define __VBOX_DRV_H__
50
51#include <VBox/VBoxVideoGuest.h>
52
53#include <iprt/log.h>
54
55#include "the-linux-kernel.h"
56
57#include <drm/drmP.h>
58#include <drm/drm_fb_helper.h>
59
60#include <drm/ttm/ttm_bo_api.h>
61#include <drm/ttm/ttm_bo_driver.h>
62#include <drm/ttm/ttm_placement.h>
63#include <drm/ttm/ttm_memory.h>
64#include <drm/ttm/ttm_module.h>
65
66/* #include "vboxvideo.h" */
67
68#include "product-generated.h"
69
70#define DRIVER_AUTHOR VBOX_VENDOR
71
72#define DRIVER_NAME "vboxvideo"
73#define DRIVER_DESC VBOX_PRODUCT " Graphics Card"
74#define DRIVER_DATE "20130823"
75
76#define DRIVER_MAJOR 1
77#define DRIVER_MINOR 0
78#define DRIVER_PATCHLEVEL 0
79
80#define VBOX_MAX_CURSOR_WIDTH 64
81#define VBOX_MAX_CURSOR_HEIGHT 64
82
83struct vbox_fbdev;
84
85struct vbox_private
86{
87 struct drm_device *dev;
88
89 void __iomem *vram;
90 HGSMIGUESTCOMMANDCONTEXT Ctx;
91 struct VBVABUFFERCONTEXT *paVBVACtx;
92 bool fAnyX;
93 unsigned cCrtcs;
94 bool vga2_clone;
95 /** Amount of available VRAM, including space used for buffers. */
96 uint32_t full_vram_size;
97 /** Amount of available VRAM, not including space used for buffers. */
98 uint32_t vram_size;
99 /** Is HGSMI currently disabled? */
100 bool fDisableHGSMI;
101
102 struct vbox_fbdev *fbdev;
103
104 int fb_mtrr;
105
106 struct
107 {
108 struct drm_global_reference mem_global_ref;
109 struct ttm_bo_global_ref bo_global_ref;
110 struct ttm_bo_device bdev;
111 } ttm;
112
113 spinlock_t dev_lock;
114};
115
116int vbox_driver_load(struct drm_device *dev, unsigned long flags);
117int vbox_driver_unload(struct drm_device *dev);
118
119struct vbox_gem_object;
120
121struct vbox_connector
122{
123 struct drm_connector base;
124 /** Property for receiving mode hints from user space. */
125 struct drm_property *pModeHintProp;
126 struct
127 {
128 uint16_t cX;
129 uint16_t cY;
130 } modeHint;
131};
132
133struct vbox_crtc
134{
135 struct drm_crtc base;
136 bool fBlanked;
137 unsigned crtc_id;
138 uint32_t offFB;
139 struct drm_gem_object *cursor_bo;
140 uint64_t cursor_addr;
141 int cursor_width, cursor_height;
142 u8 offset_x, offset_y;
143};
144
145struct vbox_encoder
146{
147 struct drm_encoder base;
148};
149
150struct vbox_framebuffer
151{
152 struct drm_framebuffer base;
153 struct drm_gem_object *obj;
154};
155
156struct vbox_fbdev
157{
158 struct drm_fb_helper helper;
159 struct vbox_framebuffer afb;
160 struct list_head fbdev_list;
161 void *sysram;
162 int size;
163 struct ttm_bo_kmap_obj mapping;
164 int x1, y1, x2, y2; /* dirty rect */
165};
166
167#define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
168#define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
169#define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
170#define to_vbox_framebuffer(x) container_of(x, struct vbox_framebuffer, base)
171
172extern int vbox_mode_init(struct drm_device *dev);
173extern void vbox_mode_fini(struct drm_device *dev);
174extern void VBoxRefreshModes(struct drm_device *pDev);
175
176#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
177# define DRM_MODE_FB_CMD drm_mode_fb_cmd
178#else
179# define DRM_MODE_FB_CMD drm_mode_fb_cmd2
180#endif
181
182void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb,
183 struct drm_clip_rect *pRects,
184 unsigned cRects);
185
186int vbox_framebuffer_init(struct drm_device *dev,
187 struct vbox_framebuffer *vbox_fb,
188 struct DRM_MODE_FB_CMD *mode_cmd,
189 struct drm_gem_object *obj);
190
191int vbox_fbdev_init(struct drm_device *dev);
192void vbox_fbdev_fini(struct drm_device *dev);
193void vbox_fbdev_set_suspend(struct drm_device *dev, int state);
194
195struct vbox_bo
196{
197 struct ttm_buffer_object bo;
198 struct ttm_placement placement;
199 struct ttm_bo_kmap_obj kmap;
200 struct drm_gem_object gem;
201 u32 placements[3];
202 int pin_count;
203};
204#define gem_to_vbox_bo(gobj) container_of((gobj), struct vbox_bo, gem)
205
206static inline struct vbox_bo * vbox_bo(struct ttm_buffer_object *bo)
207{
208 return container_of(bo, struct vbox_bo, bo);
209}
210
211
212#define to_vbox_obj(x) container_of(x, struct vbox_gem_object, base)
213
214extern int vbox_dumb_create(struct drm_file *file,
215 struct drm_device *dev,
216 struct drm_mode_create_dumb *args);
217extern int vbox_dumb_destroy(struct drm_file *file,
218 struct drm_device *dev,
219 uint32_t handle);
220
221extern int vbox_gem_init_object(struct drm_gem_object *obj);
222extern void vbox_gem_free_object(struct drm_gem_object *obj);
223extern int vbox_dumb_mmap_offset(struct drm_file *file,
224 struct drm_device *dev,
225 uint32_t handle,
226 uint64_t *offset);
227
228#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
229
230int vbox_mm_init(struct vbox_private *vbox);
231void vbox_mm_fini(struct vbox_private *vbox);
232
233int vbox_bo_create(struct drm_device *dev, int size, int align,
234 uint32_t flags, struct vbox_bo **pvboxbo);
235
236/** IOCtl handler to stop this driver using HGSMI so that user space can. */
237extern int VBoxDisableHGSMI(struct drm_device *dev, void *data,
238 struct drm_file *file_priv);
239/** IOCtl handler to start this driver using HGSMI again. */
240extern int VBoxEnableHGSMI(struct drm_device *dev, void *data,
241 struct drm_file *file_priv);
242
243int vbox_gem_create(struct drm_device *dev,
244 u32 size, bool iskernel,
245 struct drm_gem_object **obj);
246
247int vbox_bo_pin(struct vbox_bo *bo, u32 pl_flag, u64 *gpu_addr);
248int vbox_bo_unpin(struct vbox_bo *bo);
249
250int vbox_bo_reserve(struct vbox_bo *bo, bool no_wait);
251void vbox_bo_unreserve(struct vbox_bo *bo);
252void vbox_ttm_placement(struct vbox_bo *bo, int domain);
253int vbox_bo_push_sysram(struct vbox_bo *bo);
254int vbox_mmap(struct file *filp, struct vm_area_struct *vma);
255
256/* vbox post */
257void vbox_post_gpu(struct drm_device *dev);
258#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette