VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/drm2/vbox_drv.h@ 48115

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

Additions/linux/drm: re-working kernel mode-setting driver based on the Linux in-kernel "ast" driver.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1/** @file $Id: vbox_drv.h 48115 2013-08-28 07:28:12Z 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 *
23 * Permission is hereby granted, free of charge, to any person obtaining a
24 * copy of this software and associated documentation files (the
25 * "Software"), to deal in the Software without restriction, including
26 * without limitation the rights to use, copy, modify, merge, publish,
27 * distribute, sub license, and/or sell copies of the Software, and to
28 * permit persons to whom the Software is furnished to do so, subject to
29 * the following conditions:
30 *
31 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
34 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
35 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
36 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
37 * USE OR OTHER DEALINGS IN THE SOFTWARE.
38 *
39 * The above copyright notice and this permission notice (including the
40 * next paragraph) shall be included in all copies or substantial portions
41 * of the Software.
42 *
43 */
44/*
45 * Authors: Dave Airlie <[email protected]>
46 */
47#ifndef __VBOX_DRV_H__
48#define __VBOX_DRV_H__
49
50#include <drm/drm_fb_helper.h>
51
52#include <drm/ttm/ttm_bo_api.h>
53#include <drm/ttm/ttm_bo_driver.h>
54#include <drm/ttm/ttm_placement.h>
55#include <drm/ttm/ttm_memory.h>
56#include <drm/ttm/ttm_module.h>
57
58#include "vboxvideo.h"
59
60#include "product-generated.h"
61
62#define DRIVER_AUTHOR VBOX_VENDOR
63
64#define DRIVER_NAME "vboxvideo"
65#define DRIVER_DESC VBOX_PRODUCT " Graphics Card"
66#define DRIVER_DATE "20130823"
67
68#define DRIVER_MAJOR 1
69#define DRIVER_MINOR 0
70#define DRIVER_PATCHLEVEL 0
71
72struct vbox_fbdev;
73
74struct vbox_private {
75 struct drm_device *dev;
76
77 void __iomem *vram;
78 HGSMIGUESTCOMMANDCONTEXT Ctx;
79 bool fAnyX;
80 unsigned cCrtcs;
81 bool vga2_clone;
82 uint32_t vram_size;
83
84 struct vbox_fbdev *fbdev;
85
86 int fb_mtrr;
87
88 struct {
89 struct drm_global_reference mem_global_ref;
90 struct ttm_bo_global_ref bo_global_ref;
91 struct ttm_bo_device bdev;
92 } ttm;
93
94 struct drm_gem_object *cursor_cache;
95 uint64_t cursor_cache_gpu_addr;
96 struct ttm_bo_kmap_obj cache_kmap;
97 int next_cursor;
98};
99
100int vbox_driver_load(struct drm_device *dev, unsigned long flags);
101int vbox_driver_unload(struct drm_device *dev);
102
103struct vbox_gem_object;
104
105struct vbox_connector {
106 struct drm_connector base;
107};
108
109struct vbox_crtc {
110 struct drm_crtc base;
111 bool fBlanked;
112 struct drm_gem_object *cursor_bo;
113 uint64_t cursor_addr;
114 int cursor_width, cursor_height;
115 u8 offset_x, offset_y;
116};
117
118struct vbox_encoder {
119 struct drm_encoder base;
120};
121
122struct vbox_framebuffer {
123 struct drm_framebuffer base;
124 struct drm_gem_object *obj;
125};
126
127struct vbox_fbdev {
128 struct drm_fb_helper helper;
129 struct vbox_framebuffer afb;
130 struct list_head fbdev_list;
131 void *sysram;
132 int size;
133 struct ttm_bo_kmap_obj mapping;
134 int x1, y1, x2, y2; /* dirty rect */
135 spinlock_t dirty_lock;
136};
137
138#define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
139#define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
140#define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
141#define to_vbox_framebuffer(x) container_of(x, struct vbox_framebuffer, base)
142
143extern int vbox_mode_init(struct drm_device *dev);
144extern void vbox_mode_fini(struct drm_device *dev);
145
146#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
147# define DRM_MODE_FB_CMD drm_mode_fb_cmd
148#else
149# define DRM_MODE_FB_CMD drm_mode_fb_cmd2
150#endif
151
152int vbox_framebuffer_init(struct drm_device *dev,
153 struct vbox_framebuffer *vbox_fb,
154 struct DRM_MODE_FB_CMD *mode_cmd,
155 struct drm_gem_object *obj);
156
157int vbox_fbdev_init(struct drm_device *dev);
158void vbox_fbdev_fini(struct drm_device *dev);
159void vbox_fbdev_set_suspend(struct drm_device *dev, int state);
160
161struct vbox_bo {
162 struct ttm_buffer_object bo;
163 struct ttm_placement placement;
164 struct ttm_bo_kmap_obj kmap;
165 struct drm_gem_object gem;
166 u32 placements[3];
167 int pin_count;
168};
169#define gem_to_vbox_bo(gobj) container_of((gobj), struct vbox_bo, gem)
170
171static inline struct vbox_bo *
172vbox_bo(struct ttm_buffer_object *bo)
173{
174 return container_of(bo, struct vbox_bo, bo);
175}
176
177
178#define to_vbox_obj(x) container_of(x, struct vbox_gem_object, base)
179
180extern int vbox_dumb_create(struct drm_file *file,
181 struct drm_device *dev,
182 struct drm_mode_create_dumb *args);
183extern int vbox_dumb_destroy(struct drm_file *file,
184 struct drm_device *dev,
185 uint32_t handle);
186
187extern int vbox_gem_init_object(struct drm_gem_object *obj);
188extern void vbox_gem_free_object(struct drm_gem_object *obj);
189extern int vbox_dumb_mmap_offset(struct drm_file *file,
190 struct drm_device *dev,
191 uint32_t handle,
192 uint64_t *offset);
193
194#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
195
196int vbox_mm_init(struct vbox_private *vbox);
197void vbox_mm_fini(struct vbox_private *vbox);
198
199int vbox_bo_create(struct drm_device *dev, int size, int align,
200 uint32_t flags, struct vbox_bo **pvboxbo);
201
202int vbox_gem_create(struct drm_device *dev,
203 u32 size, bool iskernel,
204 struct drm_gem_object **obj);
205
206int vbox_bo_pin(struct vbox_bo *bo, u32 pl_flag, u64 *gpu_addr);
207int vbox_bo_unpin(struct vbox_bo *bo);
208
209int vbox_bo_reserve(struct vbox_bo *bo, bool no_wait);
210void vbox_bo_unreserve(struct vbox_bo *bo);
211void vbox_ttm_placement(struct vbox_bo *bo, int domain);
212int vbox_bo_push_sysram(struct vbox_bo *bo);
213int vbox_mmap(struct file *filp, struct vm_area_struct *vma);
214
215/* vbox post */
216void vbox_post_gpu(struct drm_device *dev);
217#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