vmwgfx_driver.h revision 3bfa90b6
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 85typedef struct _modesettingRec 86{ 87 /* drm */ 88 int fd; 89 int drm_major; 90 int drm_minor; 91 int drm_patch; 92 93 /* X */ 94 EntPtr entityPrivate; 95 96 int Chipset; 97 EntityInfoPtr pEnt; 98 struct pci_device *PciInfo; 99 100 /* Accel */ 101 Bool accelerate_render; 102 MessageType from_render; 103 Bool rendercheck; 104 MessageType from_rendercheck; 105 Bool SWCursor; 106 CursorPtr cursor; 107 Bool enable_dri; 108 MessageType from_dri; 109 Bool direct_presents; 110 MessageType from_dp; 111 Bool only_hw_presents; 112 MessageType from_hwp; 113 Bool isMaster; 114 115 116 /* Broken-out options. */ 117 OptionInfoPtr Options; 118 119 ScreenBlockHandlerProcPtr saved_BlockHandler; 120 CreateScreenResourcesProcPtr saved_CreateScreenResources; 121 CloseScreenProcPtr saved_CloseScreen; 122 Bool (*saved_EnterVT)(VT_FUNC_ARGS_DECL); 123 void (*saved_LeaveVT)(VT_FUNC_ARGS_DECL); 124 void (*saved_AdjustFrame)(ADJUST_FRAME_ARGS_DECL); 125 Bool (*saved_UseHWCursor)(ScreenPtr, CursorPtr); 126 Bool (*saved_UseHWCursorARGB)(ScreenPtr, CursorPtr); 127 128 uint16_t lut_r[256], lut_g[256], lut_b[256]; 129 130 Bool check_fb_size; 131 size_t max_fb_size; 132 133 struct xa_tracker *xat; 134#ifdef DRI2 135 Bool dri2_available; 136 char dri2_device_name[VMWGFX_DRI_DEVICE_LEN]; 137#endif 138} modesettingRec, *modesettingPtr; 139 140#define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate)) 141 142void xorg_flush(ScreenPtr pScreen); 143/*********************************************************************** 144 * xorg_dri2.c 145 */ 146Bool 147xorg_dri2_init(ScreenPtr pScreen); 148 149void 150xorg_dri2_close(ScreenPtr pScreen); 151 152 153/*********************************************************************** 154 * xorg_crtc.c 155 */ 156void 157xorg_crtc_init(ScrnInfoPtr pScrn); 158 159void 160xorg_crtc_cursor_destroy(xf86CrtcPtr crtc); 161 162void 163vmwgfx_disable_scanout(ScrnInfoPtr pScrn); 164 165PixmapPtr 166crtc_get_scanout(xf86CrtcPtr crtc); 167 168 169/*********************************************************************** 170 * xorg_output.c 171 */ 172void 173xorg_output_init(ScrnInfoPtr pScrn); 174 175unsigned 176xorg_output_get_id(xf86OutputPtr output); 177 178Bool 179vmwgfx_output_explicit_overlap(ScrnInfoPtr pScrn); 180 181 182/*********************************************************************** 183 * xorg_xv.c 184 */ 185void 186xorg_xv_init(ScreenPtr pScreen); 187 188XF86VideoAdaptorPtr 189vmw_video_init_adaptor(ScrnInfoPtr pScrn); 190void 191vmw_video_free_adaptor(XF86VideoAdaptorPtr adaptor, Bool free_ports); 192 193void 194vmw_ctrl_ext_init(ScrnInfoPtr pScrn); 195 196#endif /* _XORG_TRACKER_H_ */ 197