i915_drv.h 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418
  1. /* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
  2. */
  3. /*
  4. *
  5. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
  6. * All Rights Reserved.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a
  9. * copy of this software and associated documentation files (the
  10. * "Software"), to deal in the Software without restriction, including
  11. * without limitation the rights to use, copy, modify, merge, publish,
  12. * distribute, sub license, and/or sell copies of the Software, and to
  13. * permit persons to whom the Software is furnished to do so, subject to
  14. * the following conditions:
  15. *
  16. * The above copyright notice and this permission notice (including the
  17. * next paragraph) shall be included in all copies or substantial portions
  18. * of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  23. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  24. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. *
  28. */
  29. #ifndef _I915_DRV_H_
  30. #define _I915_DRV_H_
  31. #include "i915_reg.h"
  32. #include "intel_bios.h"
  33. #include "intel_ringbuffer.h"
  34. #include <linux/io-mapping.h>
  35. #include <linux/i2c.h>
  36. #include <drm/intel-gtt.h>
  37. #include <linux/backlight.h>
  38. /* General customization:
  39. */
  40. #define DRIVER_AUTHOR "Tungsten Graphics, Inc."
  41. #define DRIVER_NAME "i915"
  42. #define DRIVER_DESC "Intel Graphics"
  43. #define DRIVER_DATE "20080730"
  44. enum pipe {
  45. PIPE_A = 0,
  46. PIPE_B,
  47. PIPE_C,
  48. I915_MAX_PIPES
  49. };
  50. #define pipe_name(p) ((p) + 'A')
  51. enum plane {
  52. PLANE_A = 0,
  53. PLANE_B,
  54. PLANE_C,
  55. };
  56. #define plane_name(p) ((p) + 'A')
  57. #define I915_GEM_GPU_DOMAINS (~(I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT))
  58. #define for_each_pipe(p) for ((p) = 0; (p) < dev_priv->num_pipe; (p)++)
  59. /* Interface history:
  60. *
  61. * 1.1: Original.
  62. * 1.2: Add Power Management
  63. * 1.3: Add vblank support
  64. * 1.4: Fix cmdbuffer path, add heap destroy
  65. * 1.5: Add vblank pipe configuration
  66. * 1.6: - New ioctl for scheduling buffer swaps on vertical blank
  67. * - Support vertical blank on secondary display pipe
  68. */
  69. #define DRIVER_MAJOR 1
  70. #define DRIVER_MINOR 6
  71. #define DRIVER_PATCHLEVEL 0
  72. #define WATCH_COHERENCY 0
  73. #define WATCH_LISTS 0
  74. #define I915_GEM_PHYS_CURSOR_0 1
  75. #define I915_GEM_PHYS_CURSOR_1 2
  76. #define I915_GEM_PHYS_OVERLAY_REGS 3
  77. #define I915_MAX_PHYS_OBJECT (I915_GEM_PHYS_OVERLAY_REGS)
  78. struct drm_i915_gem_phys_object {
  79. int id;
  80. struct page **page_list;
  81. drm_dma_handle_t *handle;
  82. struct drm_i915_gem_object *cur_obj;
  83. };
  84. struct mem_block {
  85. struct mem_block *next;
  86. struct mem_block *prev;
  87. int start;
  88. int size;
  89. struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
  90. };
  91. struct opregion_header;
  92. struct opregion_acpi;
  93. struct opregion_swsci;
  94. struct opregion_asle;
  95. struct drm_i915_private;
  96. struct intel_opregion {
  97. struct opregion_header *header;
  98. struct opregion_acpi *acpi;
  99. struct opregion_swsci *swsci;
  100. struct opregion_asle *asle;
  101. void *vbt;
  102. u32 __iomem *lid_state;
  103. };
  104. #define OPREGION_SIZE (8*1024)
  105. struct intel_overlay;
  106. struct intel_overlay_error_state;
  107. struct drm_i915_master_private {
  108. drm_local_map_t *sarea;
  109. struct _drm_i915_sarea *sarea_priv;
  110. };
  111. #define I915_FENCE_REG_NONE -1
  112. #define I915_MAX_NUM_FENCES 16
  113. /* 16 fences + sign bit for FENCE_REG_NONE */
  114. #define I915_MAX_NUM_FENCE_BITS 5
  115. struct drm_i915_fence_reg {
  116. struct list_head lru_list;
  117. struct drm_i915_gem_object *obj;
  118. uint32_t setup_seqno;
  119. int pin_count;
  120. };
  121. struct sdvo_device_mapping {
  122. u8 initialized;
  123. u8 dvo_port;
  124. u8 slave_addr;
  125. u8 dvo_wiring;
  126. u8 i2c_pin;
  127. u8 ddc_pin;
  128. };
  129. struct intel_display_error_state;
  130. struct drm_i915_error_state {
  131. u32 eir;
  132. u32 pgtbl_er;
  133. u32 pipestat[I915_MAX_PIPES];
  134. u32 tail[I915_NUM_RINGS];
  135. u32 head[I915_NUM_RINGS];
  136. u32 ipeir[I915_NUM_RINGS];
  137. u32 ipehr[I915_NUM_RINGS];
  138. u32 instdone[I915_NUM_RINGS];
  139. u32 acthd[I915_NUM_RINGS];
  140. u32 error; /* gen6+ */
  141. u32 instpm[I915_NUM_RINGS];
  142. u32 instps[I915_NUM_RINGS];
  143. u32 instdone1;
  144. u32 seqno[I915_NUM_RINGS];
  145. u64 bbaddr;
  146. u32 fault_reg[I915_NUM_RINGS];
  147. u32 done_reg;
  148. u32 faddr[I915_NUM_RINGS];
  149. u64 fence[I915_MAX_NUM_FENCES];
  150. struct timeval time;
  151. struct drm_i915_error_object {
  152. int page_count;
  153. u32 gtt_offset;
  154. u32 *pages[0];
  155. } *ringbuffer[I915_NUM_RINGS], *batchbuffer[I915_NUM_RINGS];
  156. struct drm_i915_error_buffer {
  157. u32 size;
  158. u32 name;
  159. u32 seqno;
  160. u32 gtt_offset;
  161. u32 read_domains;
  162. u32 write_domain;
  163. s32 fence_reg:I915_MAX_NUM_FENCE_BITS;
  164. s32 pinned:2;
  165. u32 tiling:2;
  166. u32 dirty:1;
  167. u32 purgeable:1;
  168. u32 ring:4;
  169. u32 cache_level:2;
  170. } *active_bo, *pinned_bo;
  171. u32 active_bo_count, pinned_bo_count;
  172. struct intel_overlay_error_state *overlay;
  173. struct intel_display_error_state *display;
  174. };
  175. struct drm_i915_display_funcs {
  176. void (*dpms)(struct drm_crtc *crtc, int mode);
  177. bool (*fbc_enabled)(struct drm_device *dev);
  178. void (*enable_fbc)(struct drm_crtc *crtc, unsigned long interval);
  179. void (*disable_fbc)(struct drm_device *dev);
  180. int (*get_display_clock_speed)(struct drm_device *dev);
  181. int (*get_fifo_size)(struct drm_device *dev, int plane);
  182. void (*update_wm)(struct drm_device *dev);
  183. void (*update_sprite_wm)(struct drm_device *dev, int pipe,
  184. uint32_t sprite_width, int pixel_size);
  185. int (*crtc_mode_set)(struct drm_crtc *crtc,
  186. struct drm_display_mode *mode,
  187. struct drm_display_mode *adjusted_mode,
  188. int x, int y,
  189. struct drm_framebuffer *old_fb);
  190. void (*write_eld)(struct drm_connector *connector,
  191. struct drm_crtc *crtc);
  192. void (*fdi_link_train)(struct drm_crtc *crtc);
  193. void (*init_clock_gating)(struct drm_device *dev);
  194. void (*init_pch_clock_gating)(struct drm_device *dev);
  195. int (*queue_flip)(struct drm_device *dev, struct drm_crtc *crtc,
  196. struct drm_framebuffer *fb,
  197. struct drm_i915_gem_object *obj);
  198. int (*update_plane)(struct drm_crtc *crtc, struct drm_framebuffer *fb,
  199. int x, int y);
  200. void (*force_wake_get)(struct drm_i915_private *dev_priv);
  201. void (*force_wake_put)(struct drm_i915_private *dev_priv);
  202. /* clock updates for mode set */
  203. /* cursor updates */
  204. /* render clock increase/decrease */
  205. /* display clock increase/decrease */
  206. /* pll clock increase/decrease */
  207. };
  208. struct intel_device_info {
  209. u8 gen;
  210. u8 is_mobile:1;
  211. u8 is_i85x:1;
  212. u8 is_i915g:1;
  213. u8 is_i945gm:1;
  214. u8 is_g33:1;
  215. u8 need_gfx_hws:1;
  216. u8 is_g4x:1;
  217. u8 is_pineview:1;
  218. u8 is_broadwater:1;
  219. u8 is_crestline:1;
  220. u8 is_ivybridge:1;
  221. u8 has_fbc:1;
  222. u8 has_pipe_cxsr:1;
  223. u8 has_hotplug:1;
  224. u8 cursor_needs_physical:1;
  225. u8 has_overlay:1;
  226. u8 overlay_needs_physical:1;
  227. u8 supports_tv:1;
  228. u8 has_bsd_ring:1;
  229. u8 has_blt_ring:1;
  230. u8 has_llc:1;
  231. };
  232. enum no_fbc_reason {
  233. FBC_NO_OUTPUT, /* no outputs enabled to compress */
  234. FBC_STOLEN_TOO_SMALL, /* not enough space to hold compressed buffers */
  235. FBC_UNSUPPORTED_MODE, /* interlace or doublescanned mode */
  236. FBC_MODE_TOO_LARGE, /* mode too large for compression */
  237. FBC_BAD_PLANE, /* fbc not supported on plane */
  238. FBC_NOT_TILED, /* buffer not tiled */
  239. FBC_MULTIPLE_PIPES, /* more than one pipe active */
  240. FBC_MODULE_PARAM,
  241. };
  242. enum intel_pch {
  243. PCH_IBX, /* Ibexpeak PCH */
  244. PCH_CPT, /* Cougarpoint PCH */
  245. };
  246. #define QUIRK_PIPEA_FORCE (1<<0)
  247. #define QUIRK_LVDS_SSC_DISABLE (1<<1)
  248. struct intel_fbdev;
  249. struct intel_fbc_work;
  250. typedef struct drm_i915_private {
  251. struct drm_device *dev;
  252. const struct intel_device_info *info;
  253. int has_gem;
  254. int relative_constants_mode;
  255. void __iomem *regs;
  256. /** gt_fifo_count and the subsequent register write are synchronized
  257. * with dev->struct_mutex. */
  258. unsigned gt_fifo_count;
  259. /** forcewake_count is protected by gt_lock */
  260. unsigned forcewake_count;
  261. /** gt_lock is also taken in irq contexts. */
  262. struct spinlock gt_lock;
  263. struct intel_gmbus {
  264. struct i2c_adapter adapter;
  265. struct i2c_adapter *force_bit;
  266. u32 reg0;
  267. } *gmbus;
  268. struct pci_dev *bridge_dev;
  269. struct intel_ring_buffer ring[I915_NUM_RINGS];
  270. uint32_t next_seqno;
  271. drm_dma_handle_t *status_page_dmah;
  272. uint32_t counter;
  273. drm_local_map_t hws_map;
  274. struct drm_i915_gem_object *pwrctx;
  275. struct drm_i915_gem_object *renderctx;
  276. struct resource mch_res;
  277. unsigned int cpp;
  278. int back_offset;
  279. int front_offset;
  280. int current_page;
  281. int page_flipping;
  282. atomic_t irq_received;
  283. /* protects the irq masks */
  284. spinlock_t irq_lock;
  285. /** Cached value of IMR to avoid reads in updating the bitfield */
  286. u32 pipestat[2];
  287. u32 irq_mask;
  288. u32 gt_irq_mask;
  289. u32 pch_irq_mask;
  290. u32 hotplug_supported_mask;
  291. struct work_struct hotplug_work;
  292. int tex_lru_log_granularity;
  293. int allow_batchbuffer;
  294. unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
  295. int vblank_pipe;
  296. int num_pipe;
  297. /* For hangcheck timer */
  298. #define DRM_I915_HANGCHECK_PERIOD 1500 /* in ms */
  299. struct timer_list hangcheck_timer;
  300. int hangcheck_count;
  301. uint32_t last_acthd;
  302. uint32_t last_acthd_bsd;
  303. uint32_t last_acthd_blt;
  304. uint32_t last_instdone;
  305. uint32_t last_instdone1;
  306. unsigned long cfb_size;
  307. unsigned int cfb_fb;
  308. enum plane cfb_plane;
  309. int cfb_y;
  310. struct intel_fbc_work *fbc_work;
  311. struct intel_opregion opregion;
  312. /* overlay */
  313. struct intel_overlay *overlay;
  314. bool sprite_scaling_enabled;
  315. /* LVDS info */
  316. int backlight_level; /* restore backlight to this value */
  317. bool backlight_enabled;
  318. struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */
  319. struct drm_display_mode *sdvo_lvds_vbt_mode; /* if any */
  320. /* Feature bits from the VBIOS */
  321. unsigned int int_tv_support:1;
  322. unsigned int lvds_dither:1;
  323. unsigned int lvds_vbt:1;
  324. unsigned int int_crt_support:1;
  325. unsigned int lvds_use_ssc:1;
  326. unsigned int display_clock_mode:1;
  327. int lvds_ssc_freq;
  328. struct {
  329. int rate;
  330. int lanes;
  331. int preemphasis;
  332. int vswing;
  333. bool initialized;
  334. bool support;
  335. int bpp;
  336. struct edp_power_seq pps;
  337. } edp;
  338. bool no_aux_handshake;
  339. struct notifier_block lid_notifier;
  340. int crt_ddc_pin;
  341. struct drm_i915_fence_reg fence_regs[I915_MAX_NUM_FENCES]; /* assume 965 */
  342. int fence_reg_start; /* 4 if userland hasn't ioctl'd us yet */
  343. int num_fence_regs; /* 8 on pre-965, 16 otherwise */
  344. unsigned int fsb_freq, mem_freq, is_ddr3;
  345. spinlock_t error_lock;
  346. struct drm_i915_error_state *first_error;
  347. struct work_struct error_work;
  348. struct completion error_completion;
  349. struct workqueue_struct *wq;
  350. /* Display functions */
  351. struct drm_i915_display_funcs display;
  352. /* PCH chipset type */
  353. enum intel_pch pch_type;
  354. unsigned long quirks;
  355. /* Register state */
  356. bool modeset_on_lid;
  357. u8 saveLBB;
  358. u32 saveDSPACNTR;
  359. u32 saveDSPBCNTR;
  360. u32 saveDSPARB;
  361. u32 saveHWS;
  362. u32 savePIPEACONF;
  363. u32 savePIPEBCONF;
  364. u32 savePIPEASRC;
  365. u32 savePIPEBSRC;
  366. u32 saveFPA0;
  367. u32 saveFPA1;
  368. u32 saveDPLL_A;
  369. u32 saveDPLL_A_MD;
  370. u32 saveHTOTAL_A;
  371. u32 saveHBLANK_A;
  372. u32 saveHSYNC_A;
  373. u32 saveVTOTAL_A;
  374. u32 saveVBLANK_A;
  375. u32 saveVSYNC_A;
  376. u32 saveBCLRPAT_A;
  377. u32 saveTRANSACONF;
  378. u32 saveTRANS_HTOTAL_A;
  379. u32 saveTRANS_HBLANK_A;
  380. u32 saveTRANS_HSYNC_A;
  381. u32 saveTRANS_VTOTAL_A;
  382. u32 saveTRANS_VBLANK_A;
  383. u32 saveTRANS_VSYNC_A;
  384. u32 savePIPEASTAT;
  385. u32 saveDSPASTRIDE;
  386. u32 saveDSPASIZE;
  387. u32 saveDSPAPOS;
  388. u32 saveDSPAADDR;
  389. u32 saveDSPASURF;
  390. u32 saveDSPATILEOFF;
  391. u32 savePFIT_PGM_RATIOS;
  392. u32 saveBLC_HIST_CTL;
  393. u32 saveBLC_PWM_CTL;
  394. u32 saveBLC_PWM_CTL2;
  395. u32 saveBLC_CPU_PWM_CTL;
  396. u32 saveBLC_CPU_PWM_CTL2;
  397. u32 saveFPB0;
  398. u32 saveFPB1;
  399. u32 saveDPLL_B;
  400. u32 saveDPLL_B_MD;
  401. u32 saveHTOTAL_B;
  402. u32 saveHBLANK_B;
  403. u32 saveHSYNC_B;
  404. u32 saveVTOTAL_B;
  405. u32 saveVBLANK_B;
  406. u32 saveVSYNC_B;
  407. u32 saveBCLRPAT_B;
  408. u32 saveTRANSBCONF;
  409. u32 saveTRANS_HTOTAL_B;
  410. u32 saveTRANS_HBLANK_B;
  411. u32 saveTRANS_HSYNC_B;
  412. u32 saveTRANS_VTOTAL_B;
  413. u32 saveTRANS_VBLANK_B;
  414. u32 saveTRANS_VSYNC_B;
  415. u32 savePIPEBSTAT;
  416. u32 saveDSPBSTRIDE;
  417. u32 saveDSPBSIZE;
  418. u32 saveDSPBPOS;
  419. u32 saveDSPBADDR;
  420. u32 saveDSPBSURF;
  421. u32 saveDSPBTILEOFF;
  422. u32 saveVGA0;
  423. u32 saveVGA1;
  424. u32 saveVGA_PD;
  425. u32 saveVGACNTRL;
  426. u32 saveADPA;
  427. u32 saveLVDS;
  428. u32 savePP_ON_DELAYS;
  429. u32 savePP_OFF_DELAYS;
  430. u32 saveDVOA;
  431. u32 saveDVOB;
  432. u32 saveDVOC;
  433. u32 savePP_ON;
  434. u32 savePP_OFF;
  435. u32 savePP_CONTROL;
  436. u32 savePP_DIVISOR;
  437. u32 savePFIT_CONTROL;
  438. u32 save_palette_a[256];
  439. u32 save_palette_b[256];
  440. u32 saveDPFC_CB_BASE;
  441. u32 saveFBC_CFB_BASE;
  442. u32 saveFBC_LL_BASE;
  443. u32 saveFBC_CONTROL;
  444. u32 saveFBC_CONTROL2;
  445. u32 saveIER;
  446. u32 saveIIR;
  447. u32 saveIMR;
  448. u32 saveDEIER;
  449. u32 saveDEIMR;
  450. u32 saveGTIER;
  451. u32 saveGTIMR;
  452. u32 saveFDI_RXA_IMR;
  453. u32 saveFDI_RXB_IMR;
  454. u32 saveCACHE_MODE_0;
  455. u32 saveMI_ARB_STATE;
  456. u32 saveSWF0[16];
  457. u32 saveSWF1[16];
  458. u32 saveSWF2[3];
  459. u8 saveMSR;
  460. u8 saveSR[8];
  461. u8 saveGR[25];
  462. u8 saveAR_INDEX;
  463. u8 saveAR[21];
  464. u8 saveDACMASK;
  465. u8 saveCR[37];
  466. uint64_t saveFENCE[I915_MAX_NUM_FENCES];
  467. u32 saveCURACNTR;
  468. u32 saveCURAPOS;
  469. u32 saveCURABASE;
  470. u32 saveCURBCNTR;
  471. u32 saveCURBPOS;
  472. u32 saveCURBBASE;
  473. u32 saveCURSIZE;
  474. u32 saveDP_B;
  475. u32 saveDP_C;
  476. u32 saveDP_D;
  477. u32 savePIPEA_GMCH_DATA_M;
  478. u32 savePIPEB_GMCH_DATA_M;
  479. u32 savePIPEA_GMCH_DATA_N;
  480. u32 savePIPEB_GMCH_DATA_N;
  481. u32 savePIPEA_DP_LINK_M;
  482. u32 savePIPEB_DP_LINK_M;
  483. u32 savePIPEA_DP_LINK_N;
  484. u32 savePIPEB_DP_LINK_N;
  485. u32 saveFDI_RXA_CTL;
  486. u32 saveFDI_TXA_CTL;
  487. u32 saveFDI_RXB_CTL;
  488. u32 saveFDI_TXB_CTL;
  489. u32 savePFA_CTL_1;
  490. u32 savePFB_CTL_1;
  491. u32 savePFA_WIN_SZ;
  492. u32 savePFB_WIN_SZ;
  493. u32 savePFA_WIN_POS;
  494. u32 savePFB_WIN_POS;
  495. u32 savePCH_DREF_CONTROL;
  496. u32 saveDISP_ARB_CTL;
  497. u32 savePIPEA_DATA_M1;
  498. u32 savePIPEA_DATA_N1;
  499. u32 savePIPEA_LINK_M1;
  500. u32 savePIPEA_LINK_N1;
  501. u32 savePIPEB_DATA_M1;
  502. u32 savePIPEB_DATA_N1;
  503. u32 savePIPEB_LINK_M1;
  504. u32 savePIPEB_LINK_N1;
  505. u32 saveMCHBAR_RENDER_STANDBY;
  506. u32 savePCH_PORT_HOTPLUG;
  507. struct {
  508. /** Bridge to intel-gtt-ko */
  509. const struct intel_gtt *gtt;
  510. /** Memory allocator for GTT stolen memory */
  511. struct drm_mm stolen;
  512. /** Memory allocator for GTT */
  513. struct drm_mm gtt_space;
  514. /** List of all objects in gtt_space. Used to restore gtt
  515. * mappings on resume */
  516. struct list_head gtt_list;
  517. /** Usable portion of the GTT for GEM */
  518. unsigned long gtt_start;
  519. unsigned long gtt_mappable_end;
  520. unsigned long gtt_end;
  521. struct io_mapping *gtt_mapping;
  522. int gtt_mtrr;
  523. struct shrinker inactive_shrinker;
  524. /**
  525. * List of objects currently involved in rendering.
  526. *
  527. * Includes buffers having the contents of their GPU caches
  528. * flushed, not necessarily primitives. last_rendering_seqno
  529. * represents when the rendering involved will be completed.
  530. *
  531. * A reference is held on the buffer while on this list.
  532. */
  533. struct list_head active_list;
  534. /**
  535. * List of objects which are not in the ringbuffer but which
  536. * still have a write_domain which needs to be flushed before
  537. * unbinding.
  538. *
  539. * last_rendering_seqno is 0 while an object is in this list.
  540. *
  541. * A reference is held on the buffer while on this list.
  542. */
  543. struct list_head flushing_list;
  544. /**
  545. * LRU list of objects which are not in the ringbuffer and
  546. * are ready to unbind, but are still in the GTT.
  547. *
  548. * last_rendering_seqno is 0 while an object is in this list.
  549. *
  550. * A reference is not held on the buffer while on this list,
  551. * as merely being GTT-bound shouldn't prevent its being
  552. * freed, and we'll pull it off the list in the free path.
  553. */
  554. struct list_head inactive_list;
  555. /**
  556. * LRU list of objects which are not in the ringbuffer but
  557. * are still pinned in the GTT.
  558. */
  559. struct list_head pinned_list;
  560. /** LRU list of objects with fence regs on them. */
  561. struct list_head fence_list;
  562. /**
  563. * List of objects currently pending being freed.
  564. *
  565. * These objects are no longer in use, but due to a signal
  566. * we were prevented from freeing them at the appointed time.
  567. */
  568. struct list_head deferred_free_list;
  569. /**
  570. * We leave the user IRQ off as much as possible,
  571. * but this means that requests will finish and never
  572. * be retired once the system goes idle. Set a timer to
  573. * fire periodically while the ring is running. When it
  574. * fires, go retire requests.
  575. */
  576. struct delayed_work retire_work;
  577. /**
  578. * Are we in a non-interruptible section of code like
  579. * modesetting?
  580. */
  581. bool interruptible;
  582. /**
  583. * Flag if the X Server, and thus DRM, is not currently in
  584. * control of the device.
  585. *
  586. * This is set between LeaveVT and EnterVT. It needs to be
  587. * replaced with a semaphore. It also needs to be
  588. * transitioned away from for kernel modesetting.
  589. */
  590. int suspended;
  591. /**
  592. * Flag if the hardware appears to be wedged.
  593. *
  594. * This is set when attempts to idle the device timeout.
  595. * It prevents command submission from occurring and makes
  596. * every pending request fail
  597. */
  598. atomic_t wedged;
  599. /** Bit 6 swizzling required for X tiling */
  600. uint32_t bit_6_swizzle_x;
  601. /** Bit 6 swizzling required for Y tiling */
  602. uint32_t bit_6_swizzle_y;
  603. /* storage for physical objects */
  604. struct drm_i915_gem_phys_object *phys_objs[I915_MAX_PHYS_OBJECT];
  605. /* accounting, useful for userland debugging */
  606. size_t gtt_total;
  607. size_t mappable_gtt_total;
  608. size_t object_memory;
  609. u32 object_count;
  610. } mm;
  611. struct sdvo_device_mapping sdvo_mappings[2];
  612. /* indicate whether the LVDS_BORDER should be enabled or not */
  613. unsigned int lvds_border_bits;
  614. /* Panel fitter placement and size for Ironlake+ */
  615. u32 pch_pf_pos, pch_pf_size;
  616. struct drm_crtc *plane_to_crtc_mapping[3];
  617. struct drm_crtc *pipe_to_crtc_mapping[3];
  618. wait_queue_head_t pending_flip_queue;
  619. bool flip_pending_is_done;
  620. /* Reclocking support */
  621. bool render_reclock_avail;
  622. bool lvds_downclock_avail;
  623. /* indicates the reduced downclock for LVDS*/
  624. int lvds_downclock;
  625. struct work_struct idle_work;
  626. struct timer_list idle_timer;
  627. bool busy;
  628. u16 orig_clock;
  629. int child_dev_num;
  630. struct child_device_config *child_dev;
  631. struct drm_connector *int_lvds_connector;
  632. struct drm_connector *int_edp_connector;
  633. bool mchbar_need_disable;
  634. struct work_struct rps_work;
  635. spinlock_t rps_lock;
  636. u32 pm_iir;
  637. u8 cur_delay;
  638. u8 min_delay;
  639. u8 max_delay;
  640. u8 fmax;
  641. u8 fstart;
  642. u64 last_count1;
  643. unsigned long last_time1;
  644. unsigned long chipset_power;
  645. u64 last_count2;
  646. struct timespec last_time2;
  647. unsigned long gfx_power;
  648. int c_m;
  649. int r_t;
  650. u8 corr;
  651. spinlock_t *mchdev_lock;
  652. enum no_fbc_reason no_fbc_reason;
  653. struct drm_mm_node *compressed_fb;
  654. struct drm_mm_node *compressed_llb;
  655. unsigned long last_gpu_reset;
  656. /* list of fbdev register on this device */
  657. struct intel_fbdev *fbdev;
  658. struct backlight_device *backlight;
  659. struct drm_property *broadcast_rgb_property;
  660. struct drm_property *force_audio_property;
  661. } drm_i915_private_t;
  662. enum i915_cache_level {
  663. I915_CACHE_NONE,
  664. I915_CACHE_LLC,
  665. I915_CACHE_LLC_MLC, /* gen6+ */
  666. };
  667. struct drm_i915_gem_object {
  668. struct drm_gem_object base;
  669. /** Current space allocated to this object in the GTT, if any. */
  670. struct drm_mm_node *gtt_space;
  671. struct list_head gtt_list;
  672. /** This object's place on the active/flushing/inactive lists */
  673. struct list_head ring_list;
  674. struct list_head mm_list;
  675. /** This object's place on GPU write list */
  676. struct list_head gpu_write_list;
  677. /** This object's place in the batchbuffer or on the eviction list */
  678. struct list_head exec_list;
  679. /**
  680. * This is set if the object is on the active or flushing lists
  681. * (has pending rendering), and is not set if it's on inactive (ready
  682. * to be unbound).
  683. */
  684. unsigned int active:1;
  685. /**
  686. * This is set if the object has been written to since last bound
  687. * to the GTT
  688. */
  689. unsigned int dirty:1;
  690. /**
  691. * This is set if the object has been written to since the last
  692. * GPU flush.
  693. */
  694. unsigned int pending_gpu_write:1;
  695. /**
  696. * Fence register bits (if any) for this object. Will be set
  697. * as needed when mapped into the GTT.
  698. * Protected by dev->struct_mutex.
  699. */
  700. signed int fence_reg:I915_MAX_NUM_FENCE_BITS;
  701. /**
  702. * Advice: are the backing pages purgeable?
  703. */
  704. unsigned int madv:2;
  705. /**
  706. * Current tiling mode for the object.
  707. */
  708. unsigned int tiling_mode:2;
  709. unsigned int tiling_changed:1;
  710. /** How many users have pinned this object in GTT space. The following
  711. * users can each hold at most one reference: pwrite/pread, pin_ioctl
  712. * (via user_pin_count), execbuffer (objects are not allowed multiple
  713. * times for the same batchbuffer), and the framebuffer code. When
  714. * switching/pageflipping, the framebuffer code has at most two buffers
  715. * pinned per crtc.
  716. *
  717. * In the worst case this is 1 + 1 + 1 + 2*2 = 7. That would fit into 3
  718. * bits with absolutely no headroom. So use 4 bits. */
  719. unsigned int pin_count:4;
  720. #define DRM_I915_GEM_OBJECT_MAX_PIN_COUNT 0xf
  721. /**
  722. * Is the object at the current location in the gtt mappable and
  723. * fenceable? Used to avoid costly recalculations.
  724. */
  725. unsigned int map_and_fenceable:1;
  726. /**
  727. * Whether the current gtt mapping needs to be mappable (and isn't just
  728. * mappable by accident). Track pin and fault separate for a more
  729. * accurate mappable working set.
  730. */
  731. unsigned int fault_mappable:1;
  732. unsigned int pin_mappable:1;
  733. /*
  734. * Is the GPU currently using a fence to access this buffer,
  735. */
  736. unsigned int pending_fenced_gpu_access:1;
  737. unsigned int fenced_gpu_access:1;
  738. unsigned int cache_level:2;
  739. struct page **pages;
  740. /**
  741. * DMAR support
  742. */
  743. struct scatterlist *sg_list;
  744. int num_sg;
  745. /**
  746. * Used for performing relocations during execbuffer insertion.
  747. */
  748. struct hlist_node exec_node;
  749. unsigned long exec_handle;
  750. struct drm_i915_gem_exec_object2 *exec_entry;
  751. /**
  752. * Current offset of the object in GTT space.
  753. *
  754. * This is the same as gtt_space->start
  755. */
  756. uint32_t gtt_offset;
  757. /** Breadcrumb of last rendering to the buffer. */
  758. uint32_t last_rendering_seqno;
  759. struct intel_ring_buffer *ring;
  760. /** Breadcrumb of last fenced GPU access to the buffer. */
  761. uint32_t last_fenced_seqno;
  762. struct intel_ring_buffer *last_fenced_ring;
  763. /** Current tiling stride for the object, if it's tiled. */
  764. uint32_t stride;
  765. /** Record of address bit 17 of each page at last unbind. */
  766. unsigned long *bit_17;
  767. /**
  768. * If present, while GEM_DOMAIN_CPU is in the read domain this array
  769. * flags which individual pages are valid.
  770. */
  771. uint8_t *page_cpu_valid;
  772. /** User space pin count and filp owning the pin */
  773. uint32_t user_pin_count;
  774. struct drm_file *pin_filp;
  775. /** for phy allocated objects */
  776. struct drm_i915_gem_phys_object *phys_obj;
  777. /**
  778. * Number of crtcs where this object is currently the fb, but
  779. * will be page flipped away on the next vblank. When it
  780. * reaches 0, dev_priv->pending_flip_queue will be woken up.
  781. */
  782. atomic_t pending_flip;
  783. };
  784. #define to_intel_bo(x) container_of(x, struct drm_i915_gem_object, base)
  785. /**
  786. * Request queue structure.
  787. *
  788. * The request queue allows us to note sequence numbers that have been emitted
  789. * and may be associated with active buffers to be retired.
  790. *
  791. * By keeping this list, we can avoid having to do questionable
  792. * sequence-number comparisons on buffer last_rendering_seqnos, and associate
  793. * an emission time with seqnos for tracking how far ahead of the GPU we are.
  794. */
  795. struct drm_i915_gem_request {
  796. /** On Which ring this request was generated */
  797. struct intel_ring_buffer *ring;
  798. /** GEM sequence number associated with this request. */
  799. uint32_t seqno;
  800. /** Time at which this request was emitted, in jiffies. */
  801. unsigned long emitted_jiffies;
  802. /** global list entry for this request */
  803. struct list_head list;
  804. struct drm_i915_file_private *file_priv;
  805. /** file_priv list entry for this request */
  806. struct list_head client_list;
  807. };
  808. struct drm_i915_file_private {
  809. struct {
  810. struct spinlock lock;
  811. struct list_head request_list;
  812. } mm;
  813. };
  814. #define INTEL_INFO(dev) (((struct drm_i915_private *) (dev)->dev_private)->info)
  815. #define IS_I830(dev) ((dev)->pci_device == 0x3577)
  816. #define IS_845G(dev) ((dev)->pci_device == 0x2562)
  817. #define IS_I85X(dev) (INTEL_INFO(dev)->is_i85x)
  818. #define IS_I865G(dev) ((dev)->pci_device == 0x2572)
  819. #define IS_I915G(dev) (INTEL_INFO(dev)->is_i915g)
  820. #define IS_I915GM(dev) ((dev)->pci_device == 0x2592)
  821. #define IS_I945G(dev) ((dev)->pci_device == 0x2772)
  822. #define IS_I945GM(dev) (INTEL_INFO(dev)->is_i945gm)
  823. #define IS_BROADWATER(dev) (INTEL_INFO(dev)->is_broadwater)
  824. #define IS_CRESTLINE(dev) (INTEL_INFO(dev)->is_crestline)
  825. #define IS_GM45(dev) ((dev)->pci_device == 0x2A42)
  826. #define IS_G4X(dev) (INTEL_INFO(dev)->is_g4x)
  827. #define IS_PINEVIEW_G(dev) ((dev)->pci_device == 0xa001)
  828. #define IS_PINEVIEW_M(dev) ((dev)->pci_device == 0xa011)
  829. #define IS_PINEVIEW(dev) (INTEL_INFO(dev)->is_pineview)
  830. #define IS_G33(dev) (INTEL_INFO(dev)->is_g33)
  831. #define IS_IRONLAKE_D(dev) ((dev)->pci_device == 0x0042)
  832. #define IS_IRONLAKE_M(dev) ((dev)->pci_device == 0x0046)
  833. #define IS_IVYBRIDGE(dev) (INTEL_INFO(dev)->is_ivybridge)
  834. #define IS_MOBILE(dev) (INTEL_INFO(dev)->is_mobile)
  835. /*
  836. * The genX designation typically refers to the render engine, so render
  837. * capability related checks should use IS_GEN, while display and other checks
  838. * have their own (e.g. HAS_PCH_SPLIT for ILK+ display, IS_foo for particular
  839. * chips, etc.).
  840. */
  841. #define IS_GEN2(dev) (INTEL_INFO(dev)->gen == 2)
  842. #define IS_GEN3(dev) (INTEL_INFO(dev)->gen == 3)
  843. #define IS_GEN4(dev) (INTEL_INFO(dev)->gen == 4)
  844. #define IS_GEN5(dev) (INTEL_INFO(dev)->gen == 5)
  845. #define IS_GEN6(dev) (INTEL_INFO(dev)->gen == 6)
  846. #define IS_GEN7(dev) (INTEL_INFO(dev)->gen == 7)
  847. #define HAS_BSD(dev) (INTEL_INFO(dev)->has_bsd_ring)
  848. #define HAS_BLT(dev) (INTEL_INFO(dev)->has_blt_ring)
  849. #define HAS_LLC(dev) (INTEL_INFO(dev)->has_llc)
  850. #define I915_NEED_GFX_HWS(dev) (INTEL_INFO(dev)->need_gfx_hws)
  851. #define HAS_OVERLAY(dev) (INTEL_INFO(dev)->has_overlay)
  852. #define OVERLAY_NEEDS_PHYSICAL(dev) (INTEL_INFO(dev)->overlay_needs_physical)
  853. /* With the 945 and later, Y tiling got adjusted so that it was 32 128-byte
  854. * rows, which changed the alignment requirements and fence programming.
  855. */
  856. #define HAS_128_BYTE_Y_TILING(dev) (!IS_GEN2(dev) && !(IS_I915G(dev) || \
  857. IS_I915GM(dev)))
  858. #define SUPPORTS_DIGITAL_OUTPUTS(dev) (!IS_GEN2(dev) && !IS_PINEVIEW(dev))
  859. #define SUPPORTS_INTEGRATED_HDMI(dev) (IS_G4X(dev) || IS_GEN5(dev))
  860. #define SUPPORTS_INTEGRATED_DP(dev) (IS_G4X(dev) || IS_GEN5(dev))
  861. #define SUPPORTS_EDP(dev) (IS_IRONLAKE_M(dev))
  862. #define SUPPORTS_TV(dev) (INTEL_INFO(dev)->supports_tv)
  863. #define I915_HAS_HOTPLUG(dev) (INTEL_INFO(dev)->has_hotplug)
  864. /* dsparb controlled by hw only */
  865. #define DSPARB_HWCONTROL(dev) (IS_G4X(dev) || IS_IRONLAKE(dev))
  866. #define HAS_FW_BLC(dev) (INTEL_INFO(dev)->gen > 2)
  867. #define HAS_PIPE_CXSR(dev) (INTEL_INFO(dev)->has_pipe_cxsr)
  868. #define I915_HAS_FBC(dev) (INTEL_INFO(dev)->has_fbc)
  869. #define HAS_PCH_SPLIT(dev) (IS_GEN5(dev) || IS_GEN6(dev) || IS_IVYBRIDGE(dev))
  870. #define HAS_PIPE_CONTROL(dev) (INTEL_INFO(dev)->gen >= 5)
  871. #define INTEL_PCH_TYPE(dev) (((struct drm_i915_private *)(dev)->dev_private)->pch_type)
  872. #define HAS_PCH_CPT(dev) (INTEL_PCH_TYPE(dev) == PCH_CPT)
  873. #define HAS_PCH_IBX(dev) (INTEL_PCH_TYPE(dev) == PCH_IBX)
  874. #include "i915_trace.h"
  875. extern struct drm_ioctl_desc i915_ioctls[];
  876. extern int i915_max_ioctl;
  877. extern unsigned int i915_fbpercrtc __always_unused;
  878. extern int i915_panel_ignore_lid __read_mostly;
  879. extern unsigned int i915_powersave __read_mostly;
  880. extern int i915_semaphores __read_mostly;
  881. extern unsigned int i915_lvds_downclock __read_mostly;
  882. extern int i915_panel_use_ssc __read_mostly;
  883. extern int i915_vbt_sdvo_panel_type __read_mostly;
  884. extern int i915_enable_rc6 __read_mostly;
  885. extern int i915_enable_fbc __read_mostly;
  886. extern bool i915_enable_hangcheck __read_mostly;
  887. extern int i915_suspend(struct drm_device *dev, pm_message_t state);
  888. extern int i915_resume(struct drm_device *dev);
  889. extern int i915_master_create(struct drm_device *dev, struct drm_master *master);
  890. extern void i915_master_destroy(struct drm_device *dev, struct drm_master *master);
  891. /* i915_dma.c */
  892. extern void i915_kernel_lost_context(struct drm_device * dev);
  893. extern int i915_driver_load(struct drm_device *, unsigned long flags);
  894. extern int i915_driver_unload(struct drm_device *);
  895. extern int i915_driver_open(struct drm_device *dev, struct drm_file *file_priv);
  896. extern void i915_driver_lastclose(struct drm_device * dev);
  897. extern void i915_driver_preclose(struct drm_device *dev,
  898. struct drm_file *file_priv);
  899. extern void i915_driver_postclose(struct drm_device *dev,
  900. struct drm_file *file_priv);
  901. extern int i915_driver_device_is_agp(struct drm_device * dev);
  902. extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
  903. unsigned long arg);
  904. extern int i915_emit_box(struct drm_device *dev,
  905. struct drm_clip_rect *box,
  906. int DR1, int DR4);
  907. extern int i915_reset(struct drm_device *dev, u8 flags);
  908. extern unsigned long i915_chipset_val(struct drm_i915_private *dev_priv);
  909. extern unsigned long i915_mch_val(struct drm_i915_private *dev_priv);
  910. extern unsigned long i915_gfx_val(struct drm_i915_private *dev_priv);
  911. extern void i915_update_gfx_val(struct drm_i915_private *dev_priv);
  912. /* i915_irq.c */
  913. void i915_hangcheck_elapsed(unsigned long data);
  914. void i915_handle_error(struct drm_device *dev, bool wedged);
  915. extern int i915_irq_emit(struct drm_device *dev, void *data,
  916. struct drm_file *file_priv);
  917. extern int i915_irq_wait(struct drm_device *dev, void *data,
  918. struct drm_file *file_priv);
  919. extern void intel_irq_init(struct drm_device *dev);
  920. extern int i915_vblank_pipe_set(struct drm_device *dev, void *data,
  921. struct drm_file *file_priv);
  922. extern int i915_vblank_pipe_get(struct drm_device *dev, void *data,
  923. struct drm_file *file_priv);
  924. extern int i915_vblank_swap(struct drm_device *dev, void *data,
  925. struct drm_file *file_priv);
  926. void
  927. i915_enable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask);
  928. void
  929. i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask);
  930. void intel_enable_asle(struct drm_device *dev);
  931. #ifdef CONFIG_DEBUG_FS
  932. extern void i915_destroy_error_state(struct drm_device *dev);
  933. #else
  934. #define i915_destroy_error_state(x)
  935. #endif
  936. /* i915_gem.c */
  937. int i915_gem_init_ioctl(struct drm_device *dev, void *data,
  938. struct drm_file *file_priv);
  939. int i915_gem_create_ioctl(struct drm_device *dev, void *data,
  940. struct drm_file *file_priv);
  941. int i915_gem_pread_ioctl(struct drm_device *dev, void *data,
  942. struct drm_file *file_priv);
  943. int i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
  944. struct drm_file *file_priv);
  945. int i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
  946. struct drm_file *file_priv);
  947. int i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
  948. struct drm_file *file_priv);
  949. int i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
  950. struct drm_file *file_priv);
  951. int i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
  952. struct drm_file *file_priv);
  953. int i915_gem_execbuffer(struct drm_device *dev, void *data,
  954. struct drm_file *file_priv);
  955. int i915_gem_execbuffer2(struct drm_device *dev, void *data,
  956. struct drm_file *file_priv);
  957. int i915_gem_pin_ioctl(struct drm_device *dev, void *data,
  958. struct drm_file *file_priv);
  959. int i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
  960. struct drm_file *file_priv);
  961. int i915_gem_busy_ioctl(struct drm_device *dev, void *data,
  962. struct drm_file *file_priv);
  963. int i915_gem_throttle_ioctl(struct drm_device *dev, void *data,
  964. struct drm_file *file_priv);
  965. int i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
  966. struct drm_file *file_priv);
  967. int i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
  968. struct drm_file *file_priv);
  969. int i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
  970. struct drm_file *file_priv);
  971. int i915_gem_set_tiling(struct drm_device *dev, void *data,
  972. struct drm_file *file_priv);
  973. int i915_gem_get_tiling(struct drm_device *dev, void *data,
  974. struct drm_file *file_priv);
  975. int i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
  976. struct drm_file *file_priv);
  977. void i915_gem_load(struct drm_device *dev);
  978. int i915_gem_init_object(struct drm_gem_object *obj);
  979. int __must_check i915_gem_flush_ring(struct intel_ring_buffer *ring,
  980. uint32_t invalidate_domains,
  981. uint32_t flush_domains);
  982. struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
  983. size_t size);
  984. void i915_gem_free_object(struct drm_gem_object *obj);
  985. int __must_check i915_gem_object_pin(struct drm_i915_gem_object *obj,
  986. uint32_t alignment,
  987. bool map_and_fenceable);
  988. void i915_gem_object_unpin(struct drm_i915_gem_object *obj);
  989. int __must_check i915_gem_object_unbind(struct drm_i915_gem_object *obj);
  990. void i915_gem_release_mmap(struct drm_i915_gem_object *obj);
  991. void i915_gem_lastclose(struct drm_device *dev);
  992. int __must_check i915_mutex_lock_interruptible(struct drm_device *dev);
  993. int __must_check i915_gem_object_wait_rendering(struct drm_i915_gem_object *obj);
  994. void i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
  995. struct intel_ring_buffer *ring,
  996. u32 seqno);
  997. int i915_gem_dumb_create(struct drm_file *file_priv,
  998. struct drm_device *dev,
  999. struct drm_mode_create_dumb *args);
  1000. int i915_gem_mmap_gtt(struct drm_file *file_priv, struct drm_device *dev,
  1001. uint32_t handle, uint64_t *offset);
  1002. int i915_gem_dumb_destroy(struct drm_file *file_priv, struct drm_device *dev,
  1003. uint32_t handle);
  1004. /**
  1005. * Returns true if seq1 is later than seq2.
  1006. */
  1007. static inline bool
  1008. i915_seqno_passed(uint32_t seq1, uint32_t seq2)
  1009. {
  1010. return (int32_t)(seq1 - seq2) >= 0;
  1011. }
  1012. static inline u32
  1013. i915_gem_next_request_seqno(struct intel_ring_buffer *ring)
  1014. {
  1015. drm_i915_private_t *dev_priv = ring->dev->dev_private;
  1016. return ring->outstanding_lazy_request = dev_priv->next_seqno;
  1017. }
  1018. int __must_check i915_gem_object_get_fence(struct drm_i915_gem_object *obj,
  1019. struct intel_ring_buffer *pipelined);
  1020. int __must_check i915_gem_object_put_fence(struct drm_i915_gem_object *obj);
  1021. static inline void
  1022. i915_gem_object_pin_fence(struct drm_i915_gem_object *obj)
  1023. {
  1024. if (obj->fence_reg != I915_FENCE_REG_NONE) {
  1025. struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
  1026. dev_priv->fence_regs[obj->fence_reg].pin_count++;
  1027. }
  1028. }
  1029. static inline void
  1030. i915_gem_object_unpin_fence(struct drm_i915_gem_object *obj)
  1031. {
  1032. if (obj->fence_reg != I915_FENCE_REG_NONE) {
  1033. struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
  1034. dev_priv->fence_regs[obj->fence_reg].pin_count--;
  1035. }
  1036. }
  1037. void i915_gem_retire_requests(struct drm_device *dev);
  1038. void i915_gem_reset(struct drm_device *dev);
  1039. void i915_gem_clflush_object(struct drm_i915_gem_object *obj);
  1040. int __must_check i915_gem_object_set_domain(struct drm_i915_gem_object *obj,
  1041. uint32_t read_domains,
  1042. uint32_t write_domain);
  1043. int __must_check i915_gem_object_finish_gpu(struct drm_i915_gem_object *obj);
  1044. int __must_check i915_gem_init_ringbuffer(struct drm_device *dev);
  1045. void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
  1046. void i915_gem_do_init(struct drm_device *dev,
  1047. unsigned long start,
  1048. unsigned long mappable_end,
  1049. unsigned long end);
  1050. int __must_check i915_gpu_idle(struct drm_device *dev, bool do_retire);
  1051. int __must_check i915_gem_idle(struct drm_device *dev);
  1052. int __must_check i915_add_request(struct intel_ring_buffer *ring,
  1053. struct drm_file *file,
  1054. struct drm_i915_gem_request *request);
  1055. int __must_check i915_wait_request(struct intel_ring_buffer *ring,
  1056. uint32_t seqno,
  1057. bool do_retire);
  1058. int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
  1059. int __must_check
  1060. i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj,
  1061. bool write);
  1062. int __must_check
  1063. i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
  1064. u32 alignment,
  1065. struct intel_ring_buffer *pipelined);
  1066. int i915_gem_attach_phys_object(struct drm_device *dev,
  1067. struct drm_i915_gem_object *obj,
  1068. int id,
  1069. int align);
  1070. void i915_gem_detach_phys_object(struct drm_device *dev,
  1071. struct drm_i915_gem_object *obj);
  1072. void i915_gem_free_all_phys_object(struct drm_device *dev);
  1073. void i915_gem_release(struct drm_device *dev, struct drm_file *file);
  1074. uint32_t
  1075. i915_gem_get_unfenced_gtt_alignment(struct drm_device *dev,
  1076. uint32_t size,
  1077. int tiling_mode);
  1078. int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
  1079. enum i915_cache_level cache_level);
  1080. /* i915_gem_gtt.c */
  1081. void i915_gem_restore_gtt_mappings(struct drm_device *dev);
  1082. int __must_check i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj);
  1083. void i915_gem_gtt_rebind_object(struct drm_i915_gem_object *obj,
  1084. enum i915_cache_level cache_level);
  1085. void i915_gem_gtt_unbind_object(struct drm_i915_gem_object *obj);
  1086. /* i915_gem_evict.c */
  1087. int __must_check i915_gem_evict_something(struct drm_device *dev, int min_size,
  1088. unsigned alignment, bool mappable);
  1089. int __must_check i915_gem_evict_everything(struct drm_device *dev,
  1090. bool purgeable_only);
  1091. int __must_check i915_gem_evict_inactive(struct drm_device *dev,
  1092. bool purgeable_only);
  1093. /* i915_gem_tiling.c */
  1094. void i915_gem_detect_bit_6_swizzle(struct drm_device *dev);
  1095. void i915_gem_object_do_bit_17_swizzle(struct drm_i915_gem_object *obj);
  1096. void i915_gem_object_save_bit_17_swizzle(struct drm_i915_gem_object *obj);
  1097. /* i915_gem_debug.c */
  1098. void i915_gem_dump_object(struct drm_i915_gem_object *obj, int len,
  1099. const char *where, uint32_t mark);
  1100. #if WATCH_LISTS
  1101. int i915_verify_lists(struct drm_device *dev);
  1102. #else
  1103. #define i915_verify_lists(dev) 0
  1104. #endif
  1105. void i915_gem_object_check_coherency(struct drm_i915_gem_object *obj,
  1106. int handle);
  1107. void i915_gem_dump_object(struct drm_i915_gem_object *obj, int len,
  1108. const char *where, uint32_t mark);
  1109. /* i915_debugfs.c */
  1110. int i915_debugfs_init(struct drm_minor *minor);
  1111. void i915_debugfs_cleanup(struct drm_minor *minor);
  1112. /* i915_suspend.c */
  1113. extern int i915_save_state(struct drm_device *dev);
  1114. extern int i915_restore_state(struct drm_device *dev);
  1115. /* i915_suspend.c */
  1116. extern int i915_save_state(struct drm_device *dev);
  1117. extern int i915_restore_state(struct drm_device *dev);
  1118. /* intel_i2c.c */
  1119. extern int intel_setup_gmbus(struct drm_device *dev);
  1120. extern void intel_teardown_gmbus(struct drm_device *dev);
  1121. extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
  1122. extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
  1123. extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
  1124. {
  1125. return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
  1126. }
  1127. extern void intel_i2c_reset(struct drm_device *dev);
  1128. /* intel_opregion.c */
  1129. extern int intel_opregion_setup(struct drm_device *dev);
  1130. #ifdef CONFIG_ACPI
  1131. extern void intel_opregion_init(struct drm_device *dev);
  1132. extern void intel_opregion_fini(struct drm_device *dev);
  1133. extern void intel_opregion_asle_intr(struct drm_device *dev);
  1134. extern void intel_opregion_gse_intr(struct drm_device *dev);
  1135. extern void intel_opregion_enable_asle(struct drm_device *dev);
  1136. #else
  1137. static inline void intel_opregion_init(struct drm_device *dev) { return; }
  1138. static inline void intel_opregion_fini(struct drm_device *dev) { return; }
  1139. static inline void intel_opregion_asle_intr(struct drm_device *dev) { return; }
  1140. static inline void intel_opregion_gse_intr(struct drm_device *dev) { return; }
  1141. static inline void intel_opregion_enable_asle(struct drm_device *dev) { return; }
  1142. #endif
  1143. /* intel_acpi.c */
  1144. #ifdef CONFIG_ACPI
  1145. extern void intel_register_dsm_handler(void);
  1146. extern void intel_unregister_dsm_handler(void);
  1147. #else
  1148. static inline void intel_register_dsm_handler(void) { return; }
  1149. static inline void intel_unregister_dsm_handler(void) { return; }
  1150. #endif /* CONFIG_ACPI */
  1151. /* modesetting */
  1152. extern void intel_modeset_init(struct drm_device *dev);
  1153. extern void intel_modeset_gem_init(struct drm_device *dev);
  1154. extern void intel_modeset_cleanup(struct drm_device *dev);
  1155. extern int intel_modeset_vga_set_state(struct drm_device *dev, bool state);
  1156. extern bool intel_fbc_enabled(struct drm_device *dev);
  1157. extern void intel_disable_fbc(struct drm_device *dev);
  1158. extern bool ironlake_set_drps(struct drm_device *dev, u8 val);
  1159. extern void ironlake_init_pch_refclk(struct drm_device *dev);
  1160. extern void ironlake_enable_rc6(struct drm_device *dev);
  1161. extern void gen6_set_rps(struct drm_device *dev, u8 val);
  1162. extern void intel_detect_pch(struct drm_device *dev);
  1163. extern int intel_trans_dp_port_sel(struct drm_crtc *crtc);
  1164. extern void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv);
  1165. extern void __gen6_gt_force_wake_mt_get(struct drm_i915_private *dev_priv);
  1166. extern void __gen6_gt_force_wake_put(struct drm_i915_private *dev_priv);
  1167. extern void __gen6_gt_force_wake_mt_put(struct drm_i915_private *dev_priv);
  1168. /* overlay */
  1169. #ifdef CONFIG_DEBUG_FS
  1170. extern struct intel_overlay_error_state *intel_overlay_capture_error_state(struct drm_device *dev);
  1171. extern void intel_overlay_print_error_state(struct seq_file *m, struct intel_overlay_error_state *error);
  1172. extern struct intel_display_error_state *intel_display_capture_error_state(struct drm_device *dev);
  1173. extern void intel_display_print_error_state(struct seq_file *m,
  1174. struct drm_device *dev,
  1175. struct intel_display_error_state *error);
  1176. #endif
  1177. #define LP_RING(d) (&((struct drm_i915_private *)(d))->ring[RCS])
  1178. #define BEGIN_LP_RING(n) \
  1179. intel_ring_begin(LP_RING(dev_priv), (n))
  1180. #define OUT_RING(x) \
  1181. intel_ring_emit(LP_RING(dev_priv), x)
  1182. #define ADVANCE_LP_RING() \
  1183. intel_ring_advance(LP_RING(dev_priv))
  1184. /**
  1185. * Lock test for when it's just for synchronization of ring access.
  1186. *
  1187. * In that case, we don't need to do it when GEM is initialized as nobody else
  1188. * has access to the ring.
  1189. */
  1190. #define RING_LOCK_TEST_WITH_RETURN(dev, file) do { \
  1191. if (LP_RING(dev->dev_private)->obj == NULL) \
  1192. LOCK_TEST_WITH_RETURN(dev, file); \
  1193. } while (0)
  1194. /* On SNB platform, before reading ring registers forcewake bit
  1195. * must be set to prevent GT core from power down and stale values being
  1196. * returned.
  1197. */
  1198. void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv);
  1199. void gen6_gt_force_wake_put(struct drm_i915_private *dev_priv);
  1200. void __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv);
  1201. /* We give fast paths for the really cool registers */
  1202. #define NEEDS_FORCE_WAKE(dev_priv, reg) \
  1203. (((dev_priv)->info->gen >= 6) && \
  1204. ((reg) < 0x40000) && \
  1205. ((reg) != FORCEWAKE))
  1206. #define __i915_read(x, y) \
  1207. u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg);
  1208. __i915_read(8, b)
  1209. __i915_read(16, w)
  1210. __i915_read(32, l)
  1211. __i915_read(64, q)
  1212. #undef __i915_read
  1213. #define __i915_write(x, y) \
  1214. void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val);
  1215. __i915_write(8, b)
  1216. __i915_write(16, w)
  1217. __i915_write(32, l)
  1218. __i915_write(64, q)
  1219. #undef __i915_write
  1220. #define I915_READ8(reg) i915_read8(dev_priv, (reg))
  1221. #define I915_WRITE8(reg, val) i915_write8(dev_priv, (reg), (val))
  1222. #define I915_READ16(reg) i915_read16(dev_priv, (reg))
  1223. #define I915_WRITE16(reg, val) i915_write16(dev_priv, (reg), (val))
  1224. #define I915_READ16_NOTRACE(reg) readw(dev_priv->regs + (reg))
  1225. #define I915_WRITE16_NOTRACE(reg, val) writew(val, dev_priv->regs + (reg))
  1226. #define I915_READ(reg) i915_read32(dev_priv, (reg))
  1227. #define I915_WRITE(reg, val) i915_write32(dev_priv, (reg), (val))
  1228. #define I915_READ_NOTRACE(reg) readl(dev_priv->regs + (reg))
  1229. #define I915_WRITE_NOTRACE(reg, val) writel(val, dev_priv->regs + (reg))
  1230. #define I915_WRITE64(reg, val) i915_write64(dev_priv, (reg), (val))
  1231. #define I915_READ64(reg) i915_read64(dev_priv, (reg))
  1232. #define POSTING_READ(reg) (void)I915_READ_NOTRACE(reg)
  1233. #define POSTING_READ16(reg) (void)I915_READ16_NOTRACE(reg)
  1234. #endif