i915_drv.h 42 KB

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