103b705cfSriastradh/************************************************************************** 203b705cfSriastradh 303b705cfSriastradhCopyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. 403b705cfSriastradhCopyright © 2002 David Dawes 503b705cfSriastradh 603b705cfSriastradhAll Rights Reserved. 703b705cfSriastradh 803b705cfSriastradhPermission is hereby granted, free of charge, to any person obtaining a 903b705cfSriastradhcopy of this software and associated documentation files (the 1003b705cfSriastradh"Software"), to deal in the Software without restriction, including 1103b705cfSriastradhwithout limitation the rights to use, copy, modify, merge, publish, 1203b705cfSriastradhdistribute, sub license, and/or sell copies of the Software, and to 1303b705cfSriastradhpermit persons to whom the Software is furnished to do so, subject to 1403b705cfSriastradhthe following conditions: 1503b705cfSriastradh 1603b705cfSriastradhThe above copyright notice and this permission notice (including the 1703b705cfSriastradhnext paragraph) shall be included in all copies or substantial portions 1803b705cfSriastradhof the Software. 1903b705cfSriastradh 2003b705cfSriastradhTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 2103b705cfSriastradhOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2203b705cfSriastradhMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 2303b705cfSriastradhIN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 2403b705cfSriastradhANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 2503b705cfSriastradhTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 2603b705cfSriastradhSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2703b705cfSriastradh 2803b705cfSriastradh**************************************************************************/ 2903b705cfSriastradh 3003b705cfSriastradh/* 3103b705cfSriastradh * Authors: 3203b705cfSriastradh * Keith Whitwell <keith@tungstengraphics.com> 3303b705cfSriastradh * David Dawes <dawes@xfree86.org> 3403b705cfSriastradh * 3503b705cfSriastradh */ 3603b705cfSriastradh 3703b705cfSriastradh#ifdef HAVE_CONFIG_H 3803b705cfSriastradh#include "config.h" 3903b705cfSriastradh#endif 4003b705cfSriastradh 4103b705cfSriastradh#if 0 4203b705cfSriastradh#define I830DEBUG 4303b705cfSriastradh#endif 4403b705cfSriastradh 4503b705cfSriastradh#include <stdint.h> 4603b705cfSriastradh 4703b705cfSriastradh#ifndef REMAP_RESERVED 4803b705cfSriastradh#define REMAP_RESERVED 0 4903b705cfSriastradh#endif 5003b705cfSriastradh 5103b705cfSriastradh#ifndef _I830_H_ 5203b705cfSriastradh#define _I830_H_ 5303b705cfSriastradh 5442542f5fSchristos#include "xorg-server.h" 5503b705cfSriastradh#include "xf86_OSproc.h" 5603b705cfSriastradh#include "compiler.h" 5703b705cfSriastradh#include "xf86Cursor.h" 5803b705cfSriastradh#include "xf86xv.h" 5903b705cfSriastradh#include "xf86Crtc.h" 6003b705cfSriastradh#include "xf86RandR12.h" 6103b705cfSriastradh 6203b705cfSriastradh#include "xorg-server.h" 6303b705cfSriastradh#include <pciaccess.h> 6403b705cfSriastradh 6503b705cfSriastradh#define _XF86DRI_SERVER_ 6642542f5fSchristos#include "drm.h" 6703b705cfSriastradh#include "dri2.h" 6803b705cfSriastradh#include "intel_bufmgr.h" 6903b705cfSriastradh#include "i915_drm.h" 7003b705cfSriastradh 7103b705cfSriastradh#include "intel_driver.h" 7203b705cfSriastradh#include "intel_options.h" 7303b705cfSriastradh#include "intel_list.h" 7403b705cfSriastradh#include "compat-api.h" 7503b705cfSriastradh 7603b705cfSriastradh#if HAVE_UDEV 7703b705cfSriastradh#include <libudev.h> 7803b705cfSriastradh#endif 7903b705cfSriastradh 8042542f5fSchristos#if HAVE_DRI3 8142542f5fSchristos#include "misync.h" 8242542f5fSchristos#endif 8342542f5fSchristos 8403b705cfSriastradh/* remain compatible to xorg-server 1.6 */ 8503b705cfSriastradh#ifndef MONITOR_EDID_COMPLETE_RAWDATA 8603b705cfSriastradh#define MONITOR_EDID_COMPLETE_RAWDATA EDID_COMPLETE_RAWDATA 8703b705cfSriastradh#endif 8803b705cfSriastradh 8903b705cfSriastradh#if XF86_CRTC_VERSION >= 5 9003b705cfSriastradh#define INTEL_PIXMAP_SHARING 1 9103b705cfSriastradh#endif 9203b705cfSriastradh 9342542f5fSchristos#define MAX_PIPES 4 /* consider making all users dynamic */ 9442542f5fSchristos 9503b705cfSriastradh#include "common.h" 9603b705cfSriastradh 9703b705cfSriastradh#define PITCH_NONE 0 9803b705cfSriastradh 9903b705cfSriastradh/** enumeration of 3d consumers so some can maintain invariant state. */ 10003b705cfSriastradhenum last_3d { 10103b705cfSriastradh LAST_3D_OTHER, 10203b705cfSriastradh LAST_3D_VIDEO, 10303b705cfSriastradh LAST_3D_RENDER, 10403b705cfSriastradh LAST_3D_ROTATION 10503b705cfSriastradh}; 10603b705cfSriastradh 10703b705cfSriastradhenum dri_type { 10803b705cfSriastradh DRI_DISABLED, 10903b705cfSriastradh DRI_NONE, 11042542f5fSchristos DRI_ACTIVE 11103b705cfSriastradh}; 11203b705cfSriastradh 11303b705cfSriastradhtypedef struct intel_screen_private { 11403b705cfSriastradh ScrnInfoPtr scrn; 115813957e3Ssnj struct intel_device *dev; 11603b705cfSriastradh int cpp; 11703b705cfSriastradh 11803b705cfSriastradh#define RENDER_BATCH I915_EXEC_RENDER 11903b705cfSriastradh#define BLT_BATCH I915_EXEC_BLT 12003b705cfSriastradh unsigned int current_batch; 12103b705cfSriastradh 12203b705cfSriastradh void *modes; 12303b705cfSriastradh drm_intel_bo *front_buffer, *back_buffer; 12403b705cfSriastradh long front_pitch, front_tiling; 12503b705cfSriastradh 12603b705cfSriastradh dri_bufmgr *bufmgr; 12703b705cfSriastradh 128813957e3Ssnj#if USE_UXA 12903b705cfSriastradh uint32_t batch_ptr[4096]; 13003b705cfSriastradh /** Byte offset in batch_ptr for the next dword to be emitted. */ 13103b705cfSriastradh unsigned int batch_used; 13203b705cfSriastradh /** Position in batch_ptr at the start of the current BEGIN_BATCH */ 13303b705cfSriastradh unsigned int batch_emit_start; 13403b705cfSriastradh /** Number of bytes to be emitted in the current BEGIN_BATCH. */ 13503b705cfSriastradh uint32_t batch_emitting; 13603b705cfSriastradh dri_bo *batch_bo, *last_batch_bo[2]; 13703b705cfSriastradh /** Whether we're in a section of code that can't tolerate flushing */ 13803b705cfSriastradh Bool in_batch_atomic; 13903b705cfSriastradh /** Ending batch_used that was verified by intel_start_batch_atomic() */ 14003b705cfSriastradh int batch_atomic_limit; 14103b705cfSriastradh struct list batch_pixmaps; 14203b705cfSriastradh drm_intel_bo *wa_scratch_bo; 14303b705cfSriastradh OsTimerPtr cache_expire; 144813957e3Ssnj#endif 14503b705cfSriastradh 14603b705cfSriastradh /* For Xvideo */ 14703b705cfSriastradh Bool use_overlay; 14803b705cfSriastradh#ifdef INTEL_XVMC 14903b705cfSriastradh /* For XvMC */ 15003b705cfSriastradh Bool XvMCEnabled; 15103b705cfSriastradh#endif 15203b705cfSriastradh 15303b705cfSriastradh CreateScreenResourcesProcPtr CreateScreenResources; 15403b705cfSriastradh 15503b705cfSriastradh Bool shadow_present; 15603b705cfSriastradh 15703b705cfSriastradh unsigned int tiling; 15803b705cfSriastradh#define INTEL_TILING_FB 0x1 15903b705cfSriastradh#define INTEL_TILING_2D 0x2 16003b705cfSriastradh#define INTEL_TILING_3D 0x4 16103b705cfSriastradh#define INTEL_TILING_ALL (~0) 16203b705cfSriastradh 16303b705cfSriastradh Bool swapbuffers_wait; 16403b705cfSriastradh Bool has_relaxed_fencing; 16503b705cfSriastradh 16603b705cfSriastradh int Chipset; 16703b705cfSriastradh EntityInfoPtr pEnt; 16803b705cfSriastradh const struct intel_device_info *info; 16903b705cfSriastradh 17003b705cfSriastradh unsigned int BR[20]; 17163ef14f0Smrg unsigned int BR_tiling[2]; 17203b705cfSriastradh 17303b705cfSriastradh CloseScreenProcPtr CloseScreen; 17403b705cfSriastradh 17503b705cfSriastradh void (*context_switch) (struct intel_screen_private *intel, 17603b705cfSriastradh int new_mode); 17703b705cfSriastradh void (*vertex_flush) (struct intel_screen_private *intel); 17803b705cfSriastradh void (*batch_flush) (struct intel_screen_private *intel); 17903b705cfSriastradh void (*batch_commit_notify) (struct intel_screen_private *intel); 18003b705cfSriastradh 181813957e3Ssnj#if USE_UXA 18203b705cfSriastradh struct _UxaDriver *uxa_driver; 18303b705cfSriastradh int uxa_flags; 184813957e3Ssnj#endif 18503b705cfSriastradh Bool need_sync; 18603b705cfSriastradh int accel_pixmap_offset_alignment; 18703b705cfSriastradh int accel_max_x; 18803b705cfSriastradh int accel_max_y; 18903b705cfSriastradh int max_bo_size; 19003b705cfSriastradh int max_gtt_map_size; 19103b705cfSriastradh int max_tiling_size; 19203b705cfSriastradh 19303b705cfSriastradh Bool XvDisabled; /* Xv disabled in PreInit. */ 19403b705cfSriastradh Bool XvEnabled; /* Xv enabled for this generation. */ 19503b705cfSriastradh Bool XvPreferOverlay; 19603b705cfSriastradh 19703b705cfSriastradh int colorKey; 19803b705cfSriastradh XF86VideoAdaptorPtr adaptor; 19963ef14f0Smrg#if !HAVE_NOTIFY_FD 20003b705cfSriastradh ScreenBlockHandlerProcPtr BlockHandler; 20163ef14f0Smrg#endif 20203b705cfSriastradh Bool overlayOn; 20303b705cfSriastradh 20403b705cfSriastradh struct { 20503b705cfSriastradh drm_intel_bo *gen4_vs_bo; 20603b705cfSriastradh drm_intel_bo *gen4_sf_bo; 20703b705cfSriastradh drm_intel_bo *gen4_wm_packed_bo; 20803b705cfSriastradh drm_intel_bo *gen4_wm_planar_bo; 20903b705cfSriastradh drm_intel_bo *gen4_cc_bo; 21003b705cfSriastradh drm_intel_bo *gen4_cc_vp_bo; 21103b705cfSriastradh drm_intel_bo *gen4_sampler_bo; 21203b705cfSriastradh drm_intel_bo *gen4_sip_kernel_bo; 21303b705cfSriastradh drm_intel_bo *wm_prog_packed_bo; 21403b705cfSriastradh drm_intel_bo *wm_prog_planar_bo; 21503b705cfSriastradh drm_intel_bo *gen6_blend_bo; 21603b705cfSriastradh drm_intel_bo *gen6_depth_stencil_bo; 21703b705cfSriastradh } video; 21803b705cfSriastradh 219813957e3Ssnj#if USE_UXA 22003b705cfSriastradh /* Render accel state */ 22103b705cfSriastradh float scale_units[2][2]; 22203b705cfSriastradh /** Transform pointers for src/mask, or NULL if identity */ 22303b705cfSriastradh PictTransform *transform[2]; 22403b705cfSriastradh 22503b705cfSriastradh PixmapPtr render_source, render_mask, render_dest; 22603b705cfSriastradh PicturePtr render_source_picture, render_mask_picture, render_dest_picture; 22703b705cfSriastradh Bool needs_3d_invariant; 22803b705cfSriastradh Bool needs_render_state_emit; 22903b705cfSriastradh Bool needs_render_vertex_emit; 23003b705cfSriastradh 23103b705cfSriastradh /* i830 render accel state */ 23203b705cfSriastradh uint32_t render_dest_format; 23303b705cfSriastradh uint32_t cblend, ablend, s8_blendctl; 23403b705cfSriastradh 23503b705cfSriastradh /* i915 render accel state */ 23603b705cfSriastradh PixmapPtr texture[2]; 23703b705cfSriastradh uint32_t mapstate[6]; 23803b705cfSriastradh uint32_t samplerstate[6]; 23903b705cfSriastradh 24003b705cfSriastradh struct { 24103b705cfSriastradh int op; 24203b705cfSriastradh uint32_t dst_format; 24303b705cfSriastradh } i915_render_state; 24403b705cfSriastradh 24503b705cfSriastradh struct { 24603b705cfSriastradh int num_sf_outputs; 24703b705cfSriastradh int drawrect; 24803b705cfSriastradh uint32_t blend; 24903b705cfSriastradh dri_bo *samplers; 25003b705cfSriastradh dri_bo *kernel; 25103b705cfSriastradh } gen6_render_state; 25203b705cfSriastradh 25303b705cfSriastradh uint32_t prim_offset; 25403b705cfSriastradh void (*prim_emit)(struct intel_screen_private *intel, 25503b705cfSriastradh int srcX, int srcY, 25603b705cfSriastradh int maskX, int maskY, 25703b705cfSriastradh int dstX, int dstY, 25803b705cfSriastradh int w, int h); 25903b705cfSriastradh int floats_per_vertex; 26003b705cfSriastradh int last_floats_per_vertex; 26103b705cfSriastradh uint16_t vertex_offset; 26203b705cfSriastradh uint16_t vertex_count; 26303b705cfSriastradh uint16_t vertex_index; 26403b705cfSriastradh uint16_t vertex_used; 26503b705cfSriastradh uint32_t vertex_id; 26603b705cfSriastradh float vertex_ptr[4*1024]; 26703b705cfSriastradh dri_bo *vertex_bo; 26803b705cfSriastradh 26903b705cfSriastradh uint8_t surface_data[16*1024]; 27003b705cfSriastradh uint16_t surface_used; 27103b705cfSriastradh uint16_t surface_table; 27203b705cfSriastradh uint32_t surface_reloc; 27303b705cfSriastradh dri_bo *surface_bo; 27403b705cfSriastradh 27503b705cfSriastradh /* 965 render acceleration state */ 27603b705cfSriastradh struct gen4_render_state *gen4_render_state; 277813957e3Ssnj#endif 27803b705cfSriastradh 27942542f5fSchristos /* DRI enabled this generation. */ 28042542f5fSchristos enum dri_type dri2, dri3; 28103b705cfSriastradh int drmSubFD; 28203b705cfSriastradh char *deviceName; 28303b705cfSriastradh 28403b705cfSriastradh Bool use_pageflipping; 28503b705cfSriastradh Bool use_triple_buffer; 28603b705cfSriastradh Bool force_fallback; 28703b705cfSriastradh Bool has_kernel_flush; 28803b705cfSriastradh Bool needs_flush; 28903b705cfSriastradh 29003b705cfSriastradh /* Broken-out options. */ 29103b705cfSriastradh OptionInfoPtr Options; 29203b705cfSriastradh 29303b705cfSriastradh /* Driver phase/state information */ 29403b705cfSriastradh Bool suspended; 29503b705cfSriastradh 29603b705cfSriastradh enum last_3d last_3d; 29703b705cfSriastradh 29803b705cfSriastradh /** 29903b705cfSriastradh * User option to print acceleration fallback info to the server log. 30003b705cfSriastradh */ 30103b705cfSriastradh Bool fallback_debug; 30203b705cfSriastradh unsigned debug_flush; 30303b705cfSriastradh#if HAVE_UDEV 30403b705cfSriastradh struct udev_monitor *uevent_monitor; 30542542f5fSchristos pointer uevent_handler; 30603b705cfSriastradh#endif 30703b705cfSriastradh Bool has_prime_vmap_flush; 30842542f5fSchristos 30942542f5fSchristos#if HAVE_DRI3 31042542f5fSchristos SyncScreenFuncsRec save_sync_screen_funcs; 31142542f5fSchristos#endif 31242542f5fSchristos void (*flush_rendering)(struct intel_screen_private *intel); 31303b705cfSriastradh} intel_screen_private; 31403b705cfSriastradh 31503b705cfSriastradh#define INTEL_INFO(intel) ((intel)->info) 31603b705cfSriastradh#define IS_GENx(intel, X) (INTEL_INFO(intel)->gen >= 8*(X) && INTEL_INFO(intel)->gen < 8*((X)+1)) 31703b705cfSriastradh#define IS_GEN1(intel) IS_GENx(intel, 1) 31803b705cfSriastradh#define IS_GEN2(intel) IS_GENx(intel, 2) 31903b705cfSriastradh#define IS_GEN3(intel) IS_GENx(intel, 3) 32003b705cfSriastradh#define IS_GEN4(intel) IS_GENx(intel, 4) 32103b705cfSriastradh#define IS_GEN5(intel) IS_GENx(intel, 5) 32203b705cfSriastradh#define IS_GEN6(intel) IS_GENx(intel, 6) 32303b705cfSriastradh#define IS_GEN7(intel) IS_GENx(intel, 7) 32403b705cfSriastradh#define IS_HSW(intel) (INTEL_INFO(intel)->gen == 075) 32503b705cfSriastradh 32603b705cfSriastradh/* Some chips have specific errata (or limits) that we need to workaround. */ 327813957e3Ssnj#define IS_I830(intel) (intel_get_device_id((intel)->dev) == PCI_CHIP_I830_M) 328813957e3Ssnj#define IS_845G(intel) (intel_get_device_id((intel)->dev) == PCI_CHIP_845_G) 329813957e3Ssnj#define IS_I865G(intel) (intel_get_device_id((intel)->dev) == PCI_CHIP_I865_G) 33003b705cfSriastradh 331813957e3Ssnj#define IS_I915G(pI810) (intel_get_device_id((intel)->dev) == PCI_CHIP_I915_G || intel_get_device_id((intel)->dev) == PCI_CHIP_E7221_G) 332813957e3Ssnj#define IS_I915GM(pI810) (intel_get_device_id((intel)->dev) == PCI_CHIP_I915_GM) 33303b705cfSriastradh 334813957e3Ssnj#define IS_965_Q(pI810) (intel_get_device_id((intel)->dev) == PCI_CHIP_I965_Q) 33503b705cfSriastradh 33603b705cfSriastradh/* supports Y tiled surfaces (pre-965 Mesa isn't ready yet) */ 33703b705cfSriastradh#define SUPPORTS_YTILING(pI810) (INTEL_INFO(intel)->gen >= 040) 33803b705cfSriastradh#define HAS_BLT(pI810) (INTEL_INFO(intel)->gen >= 060) 33903b705cfSriastradh 34003b705cfSriastradh#ifndef I915_PARAM_HAS_PRIME_VMAP_FLUSH 34103b705cfSriastradh#define I915_PARAM_HAS_PRIME_VMAP_FLUSH 21 34203b705cfSriastradh#endif 34303b705cfSriastradh 34403b705cfSriastradhenum { 34503b705cfSriastradh DEBUG_FLUSH_BATCHES = 0x1, 34603b705cfSriastradh DEBUG_FLUSH_CACHES = 0x2, 34703b705cfSriastradh DEBUG_FLUSH_WAIT = 0x4, 34803b705cfSriastradh}; 34903b705cfSriastradh 35003b705cfSriastradhextern Bool intel_mode_pre_init(ScrnInfoPtr pScrn, int fd, int cpp); 35103b705cfSriastradhextern void intel_mode_init(struct intel_screen_private *intel); 35203b705cfSriastradhextern void intel_mode_disable_unused_functions(ScrnInfoPtr scrn); 35303b705cfSriastradhextern void intel_mode_remove_fb(intel_screen_private *intel); 35403b705cfSriastradhextern void intel_mode_close(intel_screen_private *intel); 35503b705cfSriastradhextern void intel_mode_fini(intel_screen_private *intel); 35642542f5fSchristosextern int intel_mode_read_drm_events(intel_screen_private *intel); 35742542f5fSchristosextern void intel_mode_hotplug(intel_screen_private *intel); 35842542f5fSchristos 35942542f5fSchristostypedef void (*intel_drm_handler_proc)(ScrnInfoPtr scrn, 36042542f5fSchristos xf86CrtcPtr crtc, 36142542f5fSchristos uint64_t seq, 36242542f5fSchristos uint64_t usec, 36342542f5fSchristos void *data); 36442542f5fSchristos 36542542f5fSchristostypedef void (*intel_drm_abort_proc)(ScrnInfoPtr scrn, 36642542f5fSchristos xf86CrtcPtr crtc, 36742542f5fSchristos void *data); 36842542f5fSchristos 36942542f5fSchristosextern uint32_t intel_drm_queue_alloc(ScrnInfoPtr scrn, xf86CrtcPtr crtc, void *data, intel_drm_handler_proc handler, intel_drm_abort_proc abort); 37042542f5fSchristosextern void intel_drm_abort(ScrnInfoPtr scrn, Bool (*match)(void *data, void *match_data), void *match_data); 37163ef14f0Smrgextern void intel_drm_abort_seq(ScrnInfoPtr scrn, uint32_t seq); 37203b705cfSriastradh 37303b705cfSriastradhextern int intel_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, xf86CrtcPtr crtc); 37403b705cfSriastradhextern int intel_crtc_id(xf86CrtcPtr crtc); 37503b705cfSriastradhextern int intel_output_dpms_status(xf86OutputPtr output); 37603b705cfSriastradhextern void intel_copy_fb(ScrnInfoPtr scrn); 37703b705cfSriastradh 37842542f5fSchristosint 37942542f5fSchristosintel_get_crtc_msc_ust(ScrnInfoPtr scrn, xf86CrtcPtr crtc, uint64_t *msc, uint64_t *ust); 38042542f5fSchristos 38142542f5fSchristosuint32_t 38242542f5fSchristosintel_crtc_msc_to_sequence(ScrnInfoPtr scrn, xf86CrtcPtr crtc, uint64_t expect); 38342542f5fSchristos 38442542f5fSchristosuint64_t 38542542f5fSchristosintel_sequence_to_crtc_msc(xf86CrtcPtr crtc, uint32_t sequence); 38642542f5fSchristos 38703b705cfSriastradhenum DRI2FrameEventType { 38803b705cfSriastradh DRI2_SWAP, 38903b705cfSriastradh DRI2_SWAP_CHAIN, 39003b705cfSriastradh DRI2_FLIP, 39103b705cfSriastradh DRI2_WAITMSC, 39203b705cfSriastradh}; 39303b705cfSriastradh 39403b705cfSriastradh#if XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(1,7,99,3,0) 39503b705cfSriastradhtypedef void (*DRI2SwapEventPtr)(ClientPtr client, void *data, int type, 39603b705cfSriastradh CARD64 ust, CARD64 msc, CARD64 sbc); 39703b705cfSriastradh#endif 39803b705cfSriastradh 39942542f5fSchristostypedef void (*intel_pageflip_handler_proc) (uint64_t frame, 40042542f5fSchristos uint64_t usec, 40142542f5fSchristos void *data); 40242542f5fSchristos 40342542f5fSchristostypedef void (*intel_pageflip_abort_proc) (void *data); 40442542f5fSchristos 40503b705cfSriastradhtypedef struct _DRI2FrameEvent { 40603b705cfSriastradh struct intel_screen_private *intel; 40703b705cfSriastradh 40803b705cfSriastradh XID drawable_id; 40903b705cfSriastradh ClientPtr client; 41003b705cfSriastradh enum DRI2FrameEventType type; 41103b705cfSriastradh int frame; 41203b705cfSriastradh 41303b705cfSriastradh struct list drawable_resource, client_resource; 41403b705cfSriastradh 41503b705cfSriastradh /* for swaps & flips only */ 41603b705cfSriastradh DRI2SwapEventPtr event_complete; 41703b705cfSriastradh void *event_data; 41803b705cfSriastradh DRI2BufferPtr front; 41903b705cfSriastradh DRI2BufferPtr back; 42003b705cfSriastradh 42163ef14f0Smrg /* current scanout for triple buffer */ 42263ef14f0Smrg int old_width; 42363ef14f0Smrg int old_height; 42463ef14f0Smrg int old_pitch; 42563ef14f0Smrg int old_tiling; 42663ef14f0Smrg dri_bo *old_buffer; 42703b705cfSriastradh} DRI2FrameEventRec, *DRI2FrameEventPtr; 42803b705cfSriastradh 42903b705cfSriastradhextern Bool intel_do_pageflip(intel_screen_private *intel, 43003b705cfSriastradh dri_bo *new_front, 43142542f5fSchristos int ref_crtc_hw_id, 43242542f5fSchristos Bool async, 43342542f5fSchristos void *pageflip_data, 43442542f5fSchristos intel_pageflip_handler_proc pageflip_handler, 43542542f5fSchristos intel_pageflip_abort_proc pageflip_abort); 43603b705cfSriastradh 43703b705cfSriastradhstatic inline intel_screen_private * 43803b705cfSriastradhintel_get_screen_private(ScrnInfoPtr scrn) 43903b705cfSriastradh{ 44003b705cfSriastradh return (intel_screen_private *)(scrn->driverPrivate); 44103b705cfSriastradh} 44203b705cfSriastradh 44303b705cfSriastradh#ifndef ARRAY_SIZE 44403b705cfSriastradh#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) 44503b705cfSriastradh#endif 44603b705cfSriastradh 44703b705cfSriastradh#ifndef ALIGN 44803b705cfSriastradh#define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1)) 44903b705cfSriastradh#endif 45003b705cfSriastradh 45103b705cfSriastradh#ifndef MIN 45203b705cfSriastradh#define MIN(a,b) ((a) < (b) ? (a) : (b)) 45303b705cfSriastradh#endif 45403b705cfSriastradh 455813957e3Ssnjextern void intel_video_init(ScreenPtr pScreen); 456813957e3Ssnjextern void intel_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b); 457813957e3Ssnjextern void intel_crtc_box(xf86CrtcPtr crtc, BoxPtr crtc_box); 45803b705cfSriastradh 45903b705cfSriastradhextern xf86CrtcPtr intel_covering_crtc(ScrnInfoPtr scrn, BoxPtr box, 46003b705cfSriastradh xf86CrtcPtr desired, BoxPtr crtc_box_ret); 46103b705cfSriastradh 46203b705cfSriastradhBool I830DRI2ScreenInit(ScreenPtr pScreen); 46303b705cfSriastradhvoid I830DRI2CloseScreen(ScreenPtr pScreen); 46403b705cfSriastradh 46542542f5fSchristos/* intel_dri3.c */ 46642542f5fSchristosBool intel_dri3_screen_init(ScreenPtr screen); 46742542f5fSchristos 46803b705cfSriastradhextern Bool intel_crtc_on(xf86CrtcPtr crtc); 46903b705cfSriastradhint intel_crtc_to_pipe(xf86CrtcPtr crtc); 47003b705cfSriastradh 47103b705cfSriastradh/* intel_memory.c */ 47203b705cfSriastradhunsigned long intel_get_fence_size(intel_screen_private *intel, unsigned long size); 47303b705cfSriastradhunsigned long intel_get_fence_pitch(intel_screen_private *intel, unsigned long pitch, 47403b705cfSriastradh uint32_t tiling_mode); 47542542f5fSchristosBool intel_check_display_stride(ScrnInfoPtr scrn, int stride, Bool tiling); 47642542f5fSchristosvoid intel_set_gem_max_sizes(ScrnInfoPtr scrn); 47703b705cfSriastradh 478813957e3Ssnjunsigned int 479813957e3Ssnjintel_compute_size(struct intel_screen_private *intel, 480813957e3Ssnj int w, int h, int bpp, unsigned usage, 481813957e3Ssnj uint32_t *tiling, int *stride); 482813957e3Ssnj 48303b705cfSriastradhdrm_intel_bo *intel_allocate_framebuffer(ScrnInfoPtr scrn, 48442542f5fSchristos int width, int height, int cpp, 48542542f5fSchristos int *out_stride, 48642542f5fSchristos uint32_t *out_tiling); 48703b705cfSriastradh 48803b705cfSriastradhstatic inline PixmapPtr get_drawable_pixmap(DrawablePtr drawable) 48903b705cfSriastradh{ 49003b705cfSriastradh ScreenPtr screen = drawable->pScreen; 49103b705cfSriastradh 49203b705cfSriastradh if (drawable->type == DRAWABLE_PIXMAP) 49303b705cfSriastradh return (PixmapPtr) drawable; 49403b705cfSriastradh else 49503b705cfSriastradh return screen->GetWindowPixmap((WindowPtr) drawable); 49603b705cfSriastradh} 49703b705cfSriastradh 49803b705cfSriastradhstatic inline Bool pixmap_is_scanout(PixmapPtr pixmap) 49903b705cfSriastradh{ 50003b705cfSriastradh ScreenPtr screen = pixmap->drawable.pScreen; 50103b705cfSriastradh 50203b705cfSriastradh return pixmap == screen->GetScreenPixmap(screen); 50303b705cfSriastradh} 50403b705cfSriastradh 505813957e3Ssnjstatic inline int 506813957e3Ssnjintel_pixmap_pitch(PixmapPtr pixmap) 50703b705cfSriastradh{ 508813957e3Ssnj return (unsigned long)pixmap->devKind; 50903b705cfSriastradh} 51003b705cfSriastradh 511813957e3Ssnj/* 512813957e3Ssnj * intel_sync.c 513813957e3Ssnj */ 514813957e3Ssnj 51542542f5fSchristos#if HAVE_DRI3 51642542f5fSchristosBool intel_sync_init(ScreenPtr screen); 51742542f5fSchristosvoid intel_sync_close(ScreenPtr screen); 51842542f5fSchristos#else 51942542f5fSchristosstatic inline Bool intel_sync_init(ScreenPtr screen) { return 0; } 5209a906b70Schristosstatic inline void intel_sync_close(ScreenPtr screen) { } 52142542f5fSchristos#endif 52242542f5fSchristos 52342542f5fSchristos/* 52442542f5fSchristos * intel_present.c 52542542f5fSchristos */ 52642542f5fSchristos 52742542f5fSchristos#if 0 52842542f5fSchristos#define DebugPresent(x) ErrorF x 52942542f5fSchristos#else 53042542f5fSchristos#define DebugPresent(x) 53142542f5fSchristos#endif 53242542f5fSchristos 53342542f5fSchristos#if HAVE_PRESENT 53442542f5fSchristosBool intel_present_screen_init(ScreenPtr screen); 53542542f5fSchristos#else 53642542f5fSchristosstatic inline Bool intel_present_screen_init(ScreenPtr screen) { return 0; } 53742542f5fSchristos#endif 53842542f5fSchristos 539813957e3Ssnjdri_bo * 540813957e3Ssnjintel_get_pixmap_bo(PixmapPtr pixmap); 541813957e3Ssnj 542813957e3Ssnjvoid 543813957e3Ssnjintel_set_pixmap_bo(PixmapPtr pixmap, dri_bo *bo); 544813957e3Ssnj 545813957e3Ssnjvoid 546813957e3Ssnjintel_flush(intel_screen_private *intel); 547813957e3Ssnj 54803b705cfSriastradh#endif /* _I830_H_ */ 549