vmwgfx_driver.h revision 591e32d7
1/* 2 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. 3 * Copyright 2011 VMWare, Inc. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright n<otice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 * 27 * Author: Alan Hourihane <alanh@tungstengraphics.com> 28 * Author: Jakob Bornecrantz <wallbraker@gmail.com> 29 * Author: Thomas Hellstrom <thellstrom@vmware.com> 30 */ 31 32#ifndef _VMWGFX_DRIVER_H_ 33#define _VMWGFX_DRIVER_H_ 34 35 36#include <stddef.h> 37#include <stdint.h> 38#include <errno.h> 39#include <drm.h> 40#include <xf86drm.h> 41#include <xf86drmMode.h> 42#include <xorg-server.h> 43#include <xf86.h> 44#include <xf86Crtc.h> 45#include <xf86xv.h> 46#include <xa_tracker.h> 47#include <xf86Module.h> 48 49#include "../src/compat-api.h" 50#ifdef DRI2 51#include <dri2.h> 52#if (!defined(DRI2INFOREC_VERSION) || (DRI2INFOREC_VERSION < 3)) 53#undef DRI2 54#endif 55#endif 56 57#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12 58#define _swapl(x, n) swapl(x,n) 59#define _swaps(x, n) swaps(x,n) 60#else 61#define _swapl(x, n) (void) n; swapl(x) 62#define _swaps(x, n) (void) n; swaps(x) 63#endif 64 65#define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg); 66#define debug_printf(...) 67 68#define VMWGFX_DRI_DEVICE_LEN 80 69 70typedef struct 71{ 72 int lastInstance; 73 int refCount; 74 ScrnInfoPtr pScrn_1; 75 ScrnInfoPtr pScrn_2; 76} EntRec, *EntPtr; 77 78#define XORG_NR_FENCES 3 79 80enum xorg_throttling_reason { 81 THROTTLE_RENDER, 82 THROTTLE_SWAP 83}; 84 85struct vmwgfx_hosted; 86struct xf86_platform_device; 87 88typedef struct _modesettingRec 89{ 90 /* drm */ 91 int fd; 92 int drm_major; 93 int drm_minor; 94 int drm_patch; 95 96 /* X */ 97 EntPtr entityPrivate; 98 99 int Chipset; 100 EntityInfoPtr pEnt; 101 struct pci_device *PciInfo; 102 struct xf86_platform_device *platform_dev; 103 104 /* Accel */ 105 Bool accelerate_render; 106 MessageType from_render; 107 Bool rendercheck; 108 MessageType from_rendercheck; 109 Bool SWCursor; 110 CursorPtr cursor; 111 Bool enable_dri; 112 MessageType from_dri; 113 Bool direct_presents; 114 MessageType from_dp; 115 Bool only_hw_presents; 116 MessageType from_hwp; 117 Bool isMaster; 118 119 120 /* Broken-out options. */ 121 OptionInfoPtr Options; 122 123 ScreenBlockHandlerProcPtr saved_BlockHandler; 124 CreateScreenResourcesProcPtr saved_CreateScreenResources; 125 CloseScreenProcPtr saved_CloseScreen; 126 Bool (*saved_EnterVT)(VT_FUNC_ARGS_DECL); 127 void (*saved_LeaveVT)(VT_FUNC_ARGS_DECL); 128 void (*saved_AdjustFrame)(ADJUST_FRAME_ARGS_DECL); 129 Bool (*saved_UseHWCursor)(ScreenPtr, CursorPtr); 130 Bool (*saved_UseHWCursorARGB)(ScreenPtr, CursorPtr); 131 132 uint16_t lut_r[256], lut_g[256], lut_b[256]; 133 134 Bool check_fb_size; 135 size_t max_fb_size; 136 137 struct xa_tracker *xat; 138 const struct vmwgfx_hosted_driver *hdriver; 139 struct vmwgfx_hosted *hosted; 140#ifdef DRI2 141 Bool dri2_available; 142 char dri2_device_name[VMWGFX_DRI_DEVICE_LEN]; 143#endif 144} modesettingRec, *modesettingPtr; 145 146#define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate)) 147 148void xorg_flush(ScreenPtr pScreen); 149/*********************************************************************** 150 * xorg_dri2.c 151 */ 152Bool 153xorg_dri2_init(ScreenPtr pScreen); 154 155void 156xorg_dri2_close(ScreenPtr pScreen); 157 158 159/*********************************************************************** 160 * xorg_crtc.c 161 */ 162void 163xorg_crtc_init(ScrnInfoPtr pScrn); 164 165void 166xorg_crtc_cursor_destroy(xf86CrtcPtr crtc); 167 168void 169vmwgfx_disable_scanout(ScrnInfoPtr pScrn); 170 171PixmapPtr 172crtc_get_scanout(xf86CrtcPtr crtc); 173 174 175/*********************************************************************** 176 * xorg_output.c 177 */ 178void 179xorg_output_init(ScrnInfoPtr pScrn); 180 181unsigned 182xorg_output_get_id(xf86OutputPtr output); 183 184Bool 185vmwgfx_output_explicit_overlap(ScrnInfoPtr pScrn); 186 187 188/*********************************************************************** 189 * xorg_xv.c 190 */ 191void 192xorg_xv_init(ScreenPtr pScreen); 193 194XF86VideoAdaptorPtr 195vmw_video_init_adaptor(ScrnInfoPtr pScrn); 196void 197vmw_video_free_adaptor(XF86VideoAdaptorPtr adaptor, Bool free_ports); 198 199void 200vmw_ctrl_ext_init(ScrnInfoPtr pScrn); 201 202#endif /* _XORG_TRACKER_H_ */ 203