VirtualBox

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

Last change on this file was 102990, checked in by vboxsync, 4 months ago

Additions: Linux: Introduce initial support for kernel 6.8, bugref:10584.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.5 KB
RevLine 
[58129]1/* $Id: vbox_drv.h 102990 2024-01-22 17:13:50Z vboxsync $ */
2/** @file
[48115]3 * VirtualBox Additions Linux kernel video driver
4 */
[48364]5
[48115]6/*
[98103]7 * Copyright (C) 2013-2023 Oracle and/or its affiliates.
[66544]8 * This file is based on ast_drv.h
[48355]9 * Copyright 2012 Red Hat Inc.
[48115]10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the
13 * "Software"), to deal in the Software without restriction, including
14 * without limitation the rights to use, copy, modify, merge, publish,
15 * distribute, sub license, and/or sell copies of the Software, and to
16 * permit persons to whom the Software is furnished to do so, subject to
17 * the following conditions:
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 *
27 * The above copyright notice and this permission notice (including the
28 * next paragraph) shall be included in all copies or substantial portions
29 * of the Software.
30 *
31 * Authors: Dave Airlie <airlied@redhat.com>
[66544]32 * Michael Thayer <michael.thayer@oracle.com,
33 * Hans de Goede <hdegoede@redhat.com>
[48115]34 */
[76534]35
[76563]36#ifndef GA_INCLUDED_SRC_linux_drm_vbox_drv_h
37#define GA_INCLUDED_SRC_linux_drm_vbox_drv_h
[76534]38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
[48115]41
[68848]42#include <linux/version.h>
[85704]43
44/* iprt/linux/version.h copy - start */
45/** @def RTLNX_VER_MIN
46 * Evaluates to true if the linux kernel version is equal or higher to the
47 * one specfied. */
48#define RTLNX_VER_MIN(a_Major, a_Minor, a_Patch) \
49 (LINUX_VERSION_CODE >= KERNEL_VERSION(a_Major, a_Minor, a_Patch))
50
51/** @def RTLNX_VER_MAX
52 * Evaluates to true if the linux kernel version is less to the one specfied
53 * (exclusive). */
54#define RTLNX_VER_MAX(a_Major, a_Minor, a_Patch) \
55 (LINUX_VERSION_CODE < KERNEL_VERSION(a_Major, a_Minor, a_Patch))
56
57/** @def RTLNX_VER_RANGE
58 * Evaluates to true if the linux kernel version is equal or higher to the given
59 * minimum version and less (but not equal) to the maximum version (exclusive). */
60#define RTLNX_VER_RANGE(a_MajorMin, a_MinorMin, a_PatchMin, a_MajorMax, a_MinorMax, a_PatchMax) \
61 ( LINUX_VERSION_CODE >= KERNEL_VERSION(a_MajorMin, a_MinorMin, a_PatchMin) \
62 && LINUX_VERSION_CODE < KERNEL_VERSION(a_MajorMax, a_MinorMax, a_PatchMax) )
63
64
65/** @def RTLNX_RHEL_MIN
66 * Require a minium RedHat release.
67 * @param a_iMajor The major release number (RHEL_MAJOR).
68 * @param a_iMinor The minor release number (RHEL_MINOR).
69 * @sa RTLNX_RHEL_MAX, RTLNX_RHEL_RANGE, RTLNX_RHEL_MAJ_PREREQ
70 */
71#if defined(RHEL_MAJOR) && defined(RHEL_MINOR)
72# define RTLNX_RHEL_MIN(a_iMajor, a_iMinor) \
73 ((RHEL_MAJOR) > (a_iMajor) || ((RHEL_MAJOR) == (a_iMajor) && (RHEL_MINOR) >= (a_iMinor)))
74#else
75# define RTLNX_RHEL_MIN(a_iMajor, a_iMinor) (0)
76#endif
77
78/** @def RTLNX_RHEL_MAX
79 * Require a maximum RedHat release, true for all RHEL versions below it.
80 * @param a_iMajor The major release number (RHEL_MAJOR).
81 * @param a_iMinor The minor release number (RHEL_MINOR).
82 * @sa RTLNX_RHEL_MIN, RTLNX_RHEL_RANGE, RTLNX_RHEL_MAJ_PREREQ
83 */
84#if defined(RHEL_MAJOR) && defined(RHEL_MINOR)
85# define RTLNX_RHEL_MAX(a_iMajor, a_iMinor) \
86 ((RHEL_MAJOR) < (a_iMajor) || ((RHEL_MAJOR) == (a_iMajor) && (RHEL_MINOR) < (a_iMinor)))
87#else
88# define RTLNX_RHEL_MAX(a_iMajor, a_iMinor) (0)
89#endif
90
[85708]91/** @def RTLNX_RHEL_RANGE
[85704]92 * Check that it's a RedHat kernel in the given version range.
93 * The max version is exclusive, the minimum inclusive.
94 * @sa RTLNX_RHEL_MIN, RTLNX_RHEL_MAX, RTLNX_RHEL_MAJ_PREREQ
95 */
96#if defined(RHEL_MAJOR) && defined(RHEL_MINOR)
97# define RTLNX_RHEL_RANGE(a_iMajorMin, a_iMinorMin, a_iMajorMax, a_iMinorMax) \
98 (RTLNX_RHEL_MIN(a_iMajorMin, a_iMinorMin) && RTLNX_RHEL_MAX(a_iMajorMax, a_iMinorMax))
99#else
100# define RTLNX_RHEL_RANGE(a_iMajorMin, a_iMinorMin, a_iMajorMax, a_iMinorMax) (0)
101#endif
102
103/** @def RTLNX_RHEL_MAJ_PREREQ
104 * Require a minimum minor release number for the given RedHat release.
105 * @param a_iMajor RHEL_MAJOR must _equal_ this.
106 * @param a_iMinor RHEL_MINOR must be greater or equal to this.
107 * @sa RTLNX_RHEL_MIN, RTLNX_RHEL_MAX
108 */
109#if defined(RHEL_MAJOR) && defined(RHEL_MINOR)
110# define RTLNX_RHEL_MAJ_PREREQ(a_iMajor, a_iMinor) ((RHEL_MAJOR) == (a_iMajor) && (RHEL_MINOR) >= (a_iMinor))
111#else
112# define RTLNX_RHEL_MAJ_PREREQ(a_iMajor, a_iMinor) (0)
113#endif
114
115
116/** @def RTLNX_SUSE_MAJ_PREREQ
117 * Require a minimum minor release number for the given SUSE release.
118 * @param a_iMajor CONFIG_SUSE_VERSION must _equal_ this.
119 * @param a_iMinor CONFIG_SUSE_PATCHLEVEL must be greater or equal to this.
120 */
121#if defined(CONFIG_SUSE_VERSION) && defined(CONFIG_SUSE_PATCHLEVEL)
122# define RTLNX_SUSE_MAJ_PREREQ(a_iMajor, a_iMinor) ((CONFIG_SUSE_VERSION) == (a_iMajor) && (CONFIG_SUSE_PATCHLEVEL) >= (a_iMinor))
123#else
124# define RTLNX_SUSE_MAJ_PREREQ(a_iMajor, a_iMinor) (0)
125#endif
126/* iprt/linux/version.h copy - end */
127
128#if RTLNX_VER_MAX(4,5,0)
[68848]129# include <linux/types.h>
130# include <linux/spinlock_types.h>
131#endif
[48115]132
[68848]133#include <linux/genalloc.h>
134#include <linux/io.h>
135#include <linux/string.h>
[83073]136#include <linux/pci.h>
[48115]137
[79025]138
[85705]139#if RTLNX_VER_MAX(3,14,0) || RTLNX_RHEL_MAJ_PREREQ(7,1)
[72638]140#define U8_MAX ((u8)~0U)
141#define S8_MAX ((s8)(U8_MAX>>1))
142#define S8_MIN ((s8)(-S8_MAX - 1))
143#define U16_MAX ((u16)~0U)
144#define S16_MAX ((s16)(U16_MAX>>1))
145#define S16_MIN ((s16)(-S16_MAX - 1))
146#define U32_MAX ((u32)~0U)
147#define S32_MAX ((s32)(U32_MAX>>1))
148#define S32_MIN ((s32)(-S32_MAX - 1))
149#define U64_MAX ((u64)~0ULL)
150#define S64_MAX ((s64)(U64_MAX>>1))
151#define S64_MIN ((s64)(-S64_MAX - 1))
152#endif
153
[89690]154#if RTLNX_VER_MIN(5,5,0) || RTLNX_RHEL_MIN(8,3) || RTLNX_SUSE_MAJ_PREREQ(15,3)
[85707]155# include <drm/drm_file.h>
156# include <drm/drm_drv.h>
157# include <drm/drm_device.h>
158# include <drm/drm_ioctl.h>
159# include <drm/drm_fourcc.h>
[100677]160# if RTLNX_VER_MAX(5,15,0) && !RTLNX_RHEL_RANGE(8,7, 8,99) && !RTLNX_RHEL_MAJ_PREREQ(9,1) && !RTLNX_SUSE_MAJ_PREREQ(15,5)
[91233]161# include <drm/drm_irq.h>
162# endif
[85707]163# include <drm/drm_vblank.h>
[89690]164#else /* < 5.5.0 || RHEL < 8.3 || SLES < 15-SP3 */
[86196]165# include <drm/drmP.h>
166#endif
[85705]167#if RTLNX_VER_MIN(4,11,0) || RTLNX_RHEL_MAJ_PREREQ(7,5)
[85707]168# include <drm/drm_encoder.h>
[74773]169#endif
170#include <drm/drm_fb_helper.h>
[85705]171#if RTLNX_VER_MIN(3,18,0) || RTLNX_RHEL_MAJ_PREREQ(7,2)
[85707]172# include <drm/drm_gem.h>
[56467]173#endif
174
[102874]175#if RTLNX_VER_MIN(6,3,0) || RTLNX_RHEL_RANGE(8,9, 8,99) || RTLNX_RHEL_RANGE(9,3, 9,99)
[98868]176# include <drm/ttm/ttm_bo.h>
177#else
178# include <drm/ttm/ttm_bo_api.h>
179# include <drm/ttm/ttm_bo_driver.h>
180#endif
[68848]181#include <drm/ttm/ttm_placement.h>
[94329]182#if RTLNX_VER_MAX(5,13,0) && !RTLNX_RHEL_RANGE(8,6, 8,99)
[89278]183# include <drm/ttm/ttm_memory.h>
184#endif
[90577]185#if RTLNX_VER_MAX(5,12,0) && !RTLNX_RHEL_MAJ_PREREQ(8,5)
[88274]186# include <drm/ttm/ttm_module.h>
187#endif
[87092]188#if RTLNX_VER_MIN(5,10,0)
189# include <drm/ttm/ttm_resource.h>
190#endif
[68848]191
[100677]192#if RTLNX_VER_MIN(6,0,0) || RTLNX_RHEL_RANGE(8,8, 8,99) || RTLNX_RHEL_MAJ_PREREQ(9,2) || RTLNX_SUSE_MAJ_PREREQ(15,5)
[96228]193# include <drm/drm_framebuffer.h>
194#endif
195
[68848]196#include "vboxvideo_guest.h"
197#include "vboxvideo_vbe.h"
198#include "hgsmi_ch_setup.h"
199
[48115]200#include "product-generated.h"
201
[85705]202#if RTLNX_VER_MAX(4,12,0) && !RTLNX_RHEL_MAJ_PREREQ(7,5)
[74882]203static inline void drm_gem_object_put_unlocked(struct drm_gem_object *obj)
204{
205 drm_gem_object_unreference_unlocked(obj);
206}
207#endif
208
[85705]209#if RTLNX_VER_MAX(4,12,0) && !RTLNX_RHEL_MAJ_PREREQ(7,5)
[77850]210static inline void drm_gem_object_put(struct drm_gem_object *obj)
211{
212 drm_gem_object_unreference(obj);
213}
214#endif
215
[48115]216#define DRIVER_AUTHOR VBOX_VENDOR
217
218#define DRIVER_NAME "vboxvideo"
219#define DRIVER_DESC VBOX_PRODUCT " Graphics Card"
220#define DRIVER_DATE "20130823"
221
222#define DRIVER_MAJOR 1
223#define DRIVER_MINOR 0
224#define DRIVER_PATCHLEVEL 0
225
[50902]226#define VBOX_MAX_CURSOR_WIDTH 64
227#define VBOX_MAX_CURSOR_HEIGHT 64
[67396]228#define CURSOR_PIXEL_COUNT (VBOX_MAX_CURSOR_WIDTH * VBOX_MAX_CURSOR_HEIGHT)
229#define CURSOR_DATA_SIZE (CURSOR_PIXEL_COUNT * 4 + CURSOR_PIXEL_COUNT / 8)
[50902]230
[62550]231#define VBOX_MAX_SCREENS 32
232
[67396]233#define GUEST_HEAP_OFFSET(vbox) ((vbox)->full_vram_size - \
234 VBVA_ADAPTER_INFORMATION_SIZE)
[66523]235#define GUEST_HEAP_SIZE VBVA_ADAPTER_INFORMATION_SIZE
236#define GUEST_HEAP_USABLE_SIZE (VBVA_ADAPTER_INFORMATION_SIZE - \
[67396]237 sizeof(HGSMIHOSTFLAGS))
[66523]238#define HOST_FLAGS_OFFSET GUEST_HEAP_USABLE_SIZE
239
[90499]240/** Field "pdev" of struct drm_device was removed in 5.14. This macro
[90498]241 * transparently handles this change. Input argument is a pointer
242 * to struct drm_device. */
[94330]243#if RTLNX_VER_MIN(5,14,0) || RTLNX_RHEL_RANGE(8,6, 8,99)
[90498]244# define VBOX_DRM_TO_PCI_DEV(_dev) to_pci_dev(_dev->dev)
245#else
246# define VBOX_DRM_TO_PCI_DEV(_dev) _dev->pdev
247#endif
248
[98034]249/** Field "num_pages" of struct ttm_resource was renamed to "size" in 6.2 and
250 * now represents number of bytes. This macro handles this change. Input
251 * argument is a pointer to struct ttm_resource. */
[102874]252#if RTLNX_VER_MIN(6,2,0) || RTLNX_RHEL_RANGE(8,9, 8,99) || RTLNX_RHEL_RANGE(9,3, 9,99)
[98034]253# define VBOX_BO_RESOURCE_NUM_PAGES(_resource) PFN_UP(_resource->size)
254#else
255# define VBOX_BO_RESOURCE_NUM_PAGES(_resource) _resource->num_pages
256#endif
257
[74581]258/** How frequently we refresh if the guest is not providing dirty rectangles. */
259#define VBOX_REFRESH_PERIOD (HZ / 2)
260
[85705]261#if RTLNX_VER_MAX(3,13,0) && !RTLNX_RHEL_MAJ_PREREQ(7,2)
[74773]262static inline void *devm_kcalloc(struct device *dev, size_t n, size_t size,
263 gfp_t flags)
264{
265 return devm_kzalloc(dev, n * size, flags);
266}
267#endif
268
[48115]269struct vbox_fbdev;
270
[59568]271struct vbox_private {
[67396]272 struct drm_device *dev;
[48115]273
[67396]274 u8 __iomem *guest_heap;
275 u8 __iomem *vbva_buffers;
276 struct gen_pool *guest_pool;
277 struct VBVABUFFERCONTEXT *vbva_info;
278 bool any_pitch;
[74773]279 u32 num_crtcs;
[67396]280 /** Amount of available VRAM, including space used for buffers. */
281 u32 full_vram_size;
282 /** Amount of available VRAM, not including space used for buffers. */
283 u32 available_vram_size;
284 /** Array of structures for receiving mode hints. */
285 VBVAMODEHINT *last_mode_hints;
[48115]286
[67396]287 struct vbox_fbdev *fbdev;
[48115]288
[67396]289 int fb_mtrr;
[48115]290
[67396]291 struct {
[85705]292#if RTLNX_VER_MAX(5,0,0) && !RTLNX_RHEL_MAJ_PREREQ(7,7) && !RTLNX_RHEL_MAJ_PREREQ(8,1)
[67396]293 struct drm_global_reference mem_global_ref;
294 struct ttm_bo_global_ref bo_global_ref;
[77850]295#endif
[94329]296#if RTLNX_VER_MIN(5,13,0) || RTLNX_RHEL_RANGE(8,6, 8,99)
[89278]297 struct ttm_device bdev;
298#else
[67396]299 struct ttm_bo_device bdev;
[89278]300#endif
[67396]301 bool mm_initialised;
302 } ttm;
[48115]303
[67396]304 struct mutex hw_mutex; /* protects modeset and accel/vbva accesses */
305 /**
306 * We decide whether or not user-space supports display hot-plug
307 * depending on whether they react to a hot-plug event after the initial
308 * mode query.
309 */
310 bool initial_mode_queried;
[74581]311 /**
312 * Do we know that the current user can send us dirty rectangle information?
313 * If not, do periodic refreshes until we do know.
314 */
315 bool need_refresh_timer;
316 /**
317 * As long as the user is not sending us dirty rectangle information,
318 * refresh the whole screen at regular intervals.
319 */
320 struct delayed_work refresh_work;
[67396]321 struct work_struct hotplug_work;
322 u32 input_mapping_width;
323 u32 input_mapping_height;
324 /**
325 * Is user-space using an X.Org-style layout of one large frame-buffer
326 * encompassing all screen ones or is the fbdev console active?
327 */
328 bool single_framebuffer;
329 u32 cursor_width;
330 u32 cursor_height;
331 u32 cursor_hot_x;
332 u32 cursor_hot_y;
333 size_t cursor_data_size;
334 u8 cursor_data[CURSOR_DATA_SIZE];
[48115]335};
336
[60300]337#undef CURSOR_PIXEL_COUNT
338#undef CURSOR_DATA_SIZE
339
[86196]340#if RTLNX_VER_MIN(4,19,0) || RTLNX_RHEL_MIN(8,3)
341int vbox_driver_load(struct drm_device *dev);
342#else
[48115]343int vbox_driver_load(struct drm_device *dev, unsigned long flags);
[76976]344#endif
[85705]345#if RTLNX_VER_MIN(4,11,0) || RTLNX_RHEL_MAJ_PREREQ(7,5)
[65992]346void vbox_driver_unload(struct drm_device *dev);
347#else
[48115]348int vbox_driver_unload(struct drm_device *dev);
[65992]349#endif
[59635]350void vbox_driver_lastclose(struct drm_device *dev);
[48115]351
352struct vbox_gem_object;
353
[59597]354#ifndef VGA_PORT_HGSMI_HOST
[67396]355#define VGA_PORT_HGSMI_HOST 0x3b0
356#define VGA_PORT_HGSMI_GUEST 0x3d0
[59597]357#endif
358
[59568]359struct vbox_connector {
[67396]360 struct drm_connector base;
361 char name[32];
362 struct vbox_crtc *vbox_crtc;
363 struct {
[76937]364 u32 width;
365 u32 height;
[67396]366 bool disconnected;
367 } mode_hint;
[48115]368};
369
[59568]370struct vbox_crtc {
[67396]371 struct drm_crtc base;
372 bool blanked;
373 bool disconnected;
374 unsigned int crtc_id;
375 u32 fb_offset;
376 bool cursor_enabled;
[69083]377 u32 x_hint;
378 u32 y_hint;
[48115]379};
380
[59568]381struct vbox_encoder {
[67396]382 struct drm_encoder base;
[48115]383};
384
[59568]385struct vbox_framebuffer {
[67396]386 struct drm_framebuffer base;
387 struct drm_gem_object *obj;
[48115]388};
389
[59568]390struct vbox_fbdev {
[67396]391 struct drm_fb_helper helper;
392 struct vbox_framebuffer afb;
393 int size;
394 struct ttm_bo_kmap_obj mapping;
395 int x1, y1, x2, y2; /* dirty rect */
396 spinlock_t dirty_lock;
[48115]397};
398
399#define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
400#define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
401#define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
402#define to_vbox_framebuffer(x) container_of(x, struct vbox_framebuffer, base)
403
[67396]404int vbox_mode_init(struct drm_device *dev);
405void vbox_mode_fini(struct drm_device *dev);
[48115]406
[85704]407#if RTLNX_VER_MAX(3,3,0)
[85707]408# define DRM_MODE_FB_CMD drm_mode_fb_cmd
[48115]409#else
[85707]410# define DRM_MODE_FB_CMD drm_mode_fb_cmd2
[48115]411#endif
412
[85705]413#if RTLNX_VER_MAX(3,15,0) && !RTLNX_RHEL_MAJ_PREREQ(7,1)
[85707]414# define CRTC_FB(crtc) ((crtc)->fb)
[52599]415#else
[85707]416# define CRTC_FB(crtc) ((crtc)->primary->fb)
[52599]417#endif
418
[59697]419void vbox_enable_accel(struct vbox_private *vbox);
420void vbox_disable_accel(struct vbox_private *vbox);
[63771]421void vbox_report_caps(struct vbox_private *vbox);
[59597]422
[49278]423void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb,
[67396]424 struct drm_clip_rect *rects,
425 unsigned int num_rects);
[49278]426
[48115]427int vbox_framebuffer_init(struct drm_device *dev,
[67396]428 struct vbox_framebuffer *vbox_fb,
[85705]429#if RTLNX_VER_MIN(4,5,0) || RTLNX_RHEL_MAJ_PREREQ(7,3)
[74773]430 const struct DRM_MODE_FB_CMD *mode_cmd,
431#else
432 struct DRM_MODE_FB_CMD *mode_cmd,
[60058]433#endif
[67396]434 struct drm_gem_object *obj);
[48115]435
436int vbox_fbdev_init(struct drm_device *dev);
437void vbox_fbdev_fini(struct drm_device *dev);
[74773]438void vbox_fbdev_set_base(struct vbox_private *vbox, unsigned long gpu_addr);
[48115]439
[59568]440struct vbox_bo {
[67396]441 struct ttm_buffer_object bo;
442 struct ttm_placement placement;
443 struct ttm_bo_kmap_obj kmap;
444 struct drm_gem_object gem;
[85705]445#if RTLNX_VER_MAX(3,18,0) && !RTLNX_RHEL_MAJ_PREREQ(7,2)
[67396]446 u32 placements[3];
[56467]447#else
[67396]448 struct ttm_place placements[3];
[56467]449#endif
[67396]450 int pin_count;
[48115]451};
[67396]452
[48115]453#define gem_to_vbox_bo(gobj) container_of((gobj), struct vbox_bo, gem)
454
[67396]455static inline struct vbox_bo *vbox_bo(struct ttm_buffer_object *bo)
[48115]456{
[67396]457 return container_of(bo, struct vbox_bo, bo);
[48115]458}
459
460#define to_vbox_obj(x) container_of(x, struct vbox_gem_object, base)
461
[67396]462int vbox_dumb_create(struct drm_file *file,
463 struct drm_device *dev,
464 struct drm_mode_create_dumb *args);
[85705]465#if RTLNX_VER_MAX(3,12,0) && !RTLNX_RHEL_MAJ_PREREQ(7,3)
[67396]466int vbox_dumb_destroy(struct drm_file *file,
467 struct drm_device *dev, u32 handle);
[59568]468#endif
[48115]469
[67396]470void vbox_gem_free_object(struct drm_gem_object *obj);
471int vbox_dumb_mmap_offset(struct drm_file *file,
472 struct drm_device *dev,
473 u32 handle, u64 *offset);
[48115]474
[60866]475#define DRM_FILE_PAGE_OFFSET (0x10000000ULL >> PAGE_SHIFT)
[48115]476
477int vbox_mm_init(struct vbox_private *vbox);
478void vbox_mm_fini(struct vbox_private *vbox);
479
480int vbox_bo_create(struct drm_device *dev, int size, int align,
[67396]481 u32 flags, struct vbox_bo **pvboxbo);
[48115]482
483int vbox_gem_create(struct drm_device *dev,
[67396]484 u32 size, bool iskernel, struct drm_gem_object **obj);
[48115]485
[87092]486#define VBOX_MEM_TYPE_VRAM 0x1
487#define VBOX_MEM_TYPE_SYSTEM 0x2
488
489int vbox_bo_pin(struct vbox_bo *bo, u32 mem_type, u64 *gpu_addr);
[48115]490int vbox_bo_unpin(struct vbox_bo *bo);
491
[59526]492static inline int vbox_bo_reserve(struct vbox_bo *bo, bool no_wait)
493{
[67396]494 int ret;
[59526]495
[85705]496#if RTLNX_VER_MIN(4,7,0) || RTLNX_RHEL_MAJ_PREREQ(7,4)
[67396]497 ret = ttm_bo_reserve(&bo->bo, true, no_wait, NULL);
[61431]498#else
[67396]499 ret = ttm_bo_reserve(&bo->bo, true, no_wait, false, 0);
[61431]500#endif
[67396]501 if (ret) {
502 if (ret != -ERESTARTSYS && ret != -EBUSY)
503 DRM_ERROR("reserve failed %p\n", bo);
504 return ret;
505 }
506 return 0;
[59526]507}
508
509static inline void vbox_bo_unreserve(struct vbox_bo *bo)
510{
[67396]511 ttm_bo_unreserve(&bo->bo);
[59526]512}
513
[87092]514void vbox_ttm_placement(struct vbox_bo *bo, u32 mem_type);
[48115]515int vbox_bo_push_sysram(struct vbox_bo *bo);
516int vbox_mmap(struct file *filp, struct vm_area_struct *vma);
[59597]517
[67396]518/* vbox_prime.c */
[66189]519int vbox_gem_prime_pin(struct drm_gem_object *obj);
520void vbox_gem_prime_unpin(struct drm_gem_object *obj);
521struct sg_table *vbox_gem_prime_get_sg_table(struct drm_gem_object *obj);
[85705]522#if RTLNX_VER_MAX(3,18,0) && !RTLNX_RHEL_MAJ_PREREQ(7,2)
[74773]523struct drm_gem_object *vbox_gem_prime_import_sg_table(
524 struct drm_device *dev, size_t size, struct sg_table *table);
[66189]525#else
[74773]526struct drm_gem_object *vbox_gem_prime_import_sg_table(
527 struct drm_device *dev, struct dma_buf_attachment *attach,
528 struct sg_table *table);
[66189]529#endif
530void *vbox_gem_prime_vmap(struct drm_gem_object *obj);
531void vbox_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
[102874]532#if RTLNX_VER_MAX(6,6,0) && !RTLNX_RHEL_RANGE(9,4, 9,99)
[66189]533int vbox_gem_prime_mmap(struct drm_gem_object *obj,
[67396]534 struct vm_area_struct *area);
[101079]535#endif
[66189]536
[59597]537/* vbox_irq.c */
538int vbox_irq_init(struct vbox_private *vbox);
539void vbox_irq_fini(struct vbox_private *vbox);
[60352]540void vbox_report_hotplug(struct vbox_private *vbox);
[59597]541irqreturn_t vbox_irq_handler(int irq, void *arg);
[67396]542
[68848]543/* vbox_hgsmi.c */
544void *hgsmi_buffer_alloc(struct gen_pool *guest_pool, size_t size,
[74773]545 u8 channel, u16 channel_info);
[68848]546void hgsmi_buffer_free(struct gen_pool *guest_pool, void *buf);
547int hgsmi_buffer_submit(struct gen_pool *guest_pool, void *buf);
548
549static inline void vbox_write_ioport(u16 index, u16 data)
550{
[74773]551 outw(index, VBE_DISPI_IOPORT_INDEX);
552 outw(data, VBE_DISPI_IOPORT_DATA);
[68848]553}
554
[76563]555#endif /* !GA_INCLUDED_SRC_linux_drm_vbox_drv_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use