i915_drv.h 40 KB

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