i915_drv.h 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754
  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 <linux/i2c-algo-bit.h>
  37. #include <drm/intel-gtt.h>
  38. #include <linux/backlight.h>
  39. #include <linux/intel-iommu.h>
  40. #include <linux/kref.h>
  41. /* General customization:
  42. */
  43. #define DRIVER_AUTHOR "Tungsten Graphics, Inc."
  44. #define DRIVER_NAME "i915"
  45. #define DRIVER_DESC "Intel Graphics"
  46. #define DRIVER_DATE "20080730"
  47. enum pipe {
  48. PIPE_A = 0,
  49. PIPE_B,
  50. PIPE_C,
  51. I915_MAX_PIPES
  52. };
  53. #define pipe_name(p) ((p) + 'A')
  54. enum transcoder {
  55. TRANSCODER_A = 0,
  56. TRANSCODER_B,
  57. TRANSCODER_C,
  58. TRANSCODER_EDP = 0xF,
  59. };
  60. #define transcoder_name(t) ((t) + 'A')
  61. enum plane {
  62. PLANE_A = 0,
  63. PLANE_B,
  64. PLANE_C,
  65. };
  66. #define plane_name(p) ((p) + 'A')
  67. enum port {
  68. PORT_A = 0,
  69. PORT_B,
  70. PORT_C,
  71. PORT_D,
  72. PORT_E,
  73. I915_MAX_PORTS
  74. };
  75. #define port_name(p) ((p) + 'A')
  76. #define I915_GEM_GPU_DOMAINS \
  77. (I915_GEM_DOMAIN_RENDER | \
  78. I915_GEM_DOMAIN_SAMPLER | \
  79. I915_GEM_DOMAIN_COMMAND | \
  80. I915_GEM_DOMAIN_INSTRUCTION | \
  81. I915_GEM_DOMAIN_VERTEX)
  82. #define for_each_pipe(p) for ((p) = 0; (p) < dev_priv->num_pipe; (p)++)
  83. #define for_each_encoder_on_crtc(dev, __crtc, intel_encoder) \
  84. list_for_each_entry((intel_encoder), &(dev)->mode_config.encoder_list, base.head) \
  85. if ((intel_encoder)->base.crtc == (__crtc))
  86. struct intel_pch_pll {
  87. int refcount; /* count of number of CRTCs sharing this PLL */
  88. int active; /* count of number of active CRTCs (i.e. DPMS on) */
  89. bool on; /* is the PLL actually active? Disabled during modeset */
  90. int pll_reg;
  91. int fp0_reg;
  92. int fp1_reg;
  93. };
  94. #define I915_NUM_PLLS 2
  95. struct intel_ddi_plls {
  96. int spll_refcount;
  97. int wrpll1_refcount;
  98. int wrpll2_refcount;
  99. };
  100. /* Interface history:
  101. *
  102. * 1.1: Original.
  103. * 1.2: Add Power Management
  104. * 1.3: Add vblank support
  105. * 1.4: Fix cmdbuffer path, add heap destroy
  106. * 1.5: Add vblank pipe configuration
  107. * 1.6: - New ioctl for scheduling buffer swaps on vertical blank
  108. * - Support vertical blank on secondary display pipe
  109. */
  110. #define DRIVER_MAJOR 1
  111. #define DRIVER_MINOR 6
  112. #define DRIVER_PATCHLEVEL 0
  113. #define WATCH_COHERENCY 0
  114. #define WATCH_LISTS 0
  115. #define WATCH_GTT 0
  116. #define I915_GEM_PHYS_CURSOR_0 1
  117. #define I915_GEM_PHYS_CURSOR_1 2
  118. #define I915_GEM_PHYS_OVERLAY_REGS 3
  119. #define I915_MAX_PHYS_OBJECT (I915_GEM_PHYS_OVERLAY_REGS)
  120. struct drm_i915_gem_phys_object {
  121. int id;
  122. struct page **page_list;
  123. drm_dma_handle_t *handle;
  124. struct drm_i915_gem_object *cur_obj;
  125. };
  126. struct opregion_header;
  127. struct opregion_acpi;
  128. struct opregion_swsci;
  129. struct opregion_asle;
  130. struct drm_i915_private;
  131. struct intel_opregion {
  132. struct opregion_header __iomem *header;
  133. struct opregion_acpi __iomem *acpi;
  134. struct opregion_swsci __iomem *swsci;
  135. struct opregion_asle __iomem *asle;
  136. void __iomem *vbt;
  137. u32 __iomem *lid_state;
  138. };
  139. #define OPREGION_SIZE (8*1024)
  140. struct intel_overlay;
  141. struct intel_overlay_error_state;
  142. struct drm_i915_master_private {
  143. drm_local_map_t *sarea;
  144. struct _drm_i915_sarea *sarea_priv;
  145. };
  146. #define I915_FENCE_REG_NONE -1
  147. #define I915_MAX_NUM_FENCES 16
  148. /* 16 fences + sign bit for FENCE_REG_NONE */
  149. #define I915_MAX_NUM_FENCE_BITS 5
  150. struct drm_i915_fence_reg {
  151. struct list_head lru_list;
  152. struct drm_i915_gem_object *obj;
  153. int pin_count;
  154. };
  155. struct sdvo_device_mapping {
  156. u8 initialized;
  157. u8 dvo_port;
  158. u8 slave_addr;
  159. u8 dvo_wiring;
  160. u8 i2c_pin;
  161. u8 ddc_pin;
  162. };
  163. struct intel_display_error_state;
  164. struct drm_i915_error_state {
  165. struct kref ref;
  166. u32 eir;
  167. u32 pgtbl_er;
  168. u32 ier;
  169. u32 ccid;
  170. bool waiting[I915_NUM_RINGS];
  171. u32 pipestat[I915_MAX_PIPES];
  172. u32 tail[I915_NUM_RINGS];
  173. u32 head[I915_NUM_RINGS];
  174. u32 ipeir[I915_NUM_RINGS];
  175. u32 ipehr[I915_NUM_RINGS];
  176. u32 instdone[I915_NUM_RINGS];
  177. u32 acthd[I915_NUM_RINGS];
  178. u32 semaphore_mboxes[I915_NUM_RINGS][I915_NUM_RINGS - 1];
  179. u32 semaphore_seqno[I915_NUM_RINGS][I915_NUM_RINGS - 1];
  180. u32 rc_psmi[I915_NUM_RINGS]; /* sleep state */
  181. /* our own tracking of ring head and tail */
  182. u32 cpu_ring_head[I915_NUM_RINGS];
  183. u32 cpu_ring_tail[I915_NUM_RINGS];
  184. u32 error; /* gen6+ */
  185. u32 err_int; /* gen7 */
  186. u32 instpm[I915_NUM_RINGS];
  187. u32 instps[I915_NUM_RINGS];
  188. u32 extra_instdone[I915_NUM_INSTDONE_REG];
  189. u32 seqno[I915_NUM_RINGS];
  190. u64 bbaddr;
  191. u32 fault_reg[I915_NUM_RINGS];
  192. u32 done_reg;
  193. u32 faddr[I915_NUM_RINGS];
  194. u64 fence[I915_MAX_NUM_FENCES];
  195. struct timeval time;
  196. struct drm_i915_error_ring {
  197. struct drm_i915_error_object {
  198. int page_count;
  199. u32 gtt_offset;
  200. u32 *pages[0];
  201. } *ringbuffer, *batchbuffer;
  202. struct drm_i915_error_request {
  203. long jiffies;
  204. u32 seqno;
  205. u32 tail;
  206. } *requests;
  207. int num_requests;
  208. } ring[I915_NUM_RINGS];
  209. struct drm_i915_error_buffer {
  210. u32 size;
  211. u32 name;
  212. u32 rseqno, wseqno;
  213. u32 gtt_offset;
  214. u32 read_domains;
  215. u32 write_domain;
  216. s32 fence_reg:I915_MAX_NUM_FENCE_BITS;
  217. s32 pinned:2;
  218. u32 tiling:2;
  219. u32 dirty:1;
  220. u32 purgeable:1;
  221. s32 ring:4;
  222. u32 cache_level:2;
  223. } *active_bo, *pinned_bo;
  224. u32 active_bo_count, pinned_bo_count;
  225. struct intel_overlay_error_state *overlay;
  226. struct intel_display_error_state *display;
  227. };
  228. struct drm_i915_display_funcs {
  229. bool (*fbc_enabled)(struct drm_device *dev);
  230. void (*enable_fbc)(struct drm_crtc *crtc, unsigned long interval);
  231. void (*disable_fbc)(struct drm_device *dev);
  232. int (*get_display_clock_speed)(struct drm_device *dev);
  233. int (*get_fifo_size)(struct drm_device *dev, int plane);
  234. void (*update_wm)(struct drm_device *dev);
  235. void (*update_sprite_wm)(struct drm_device *dev, int pipe,
  236. uint32_t sprite_width, int pixel_size);
  237. void (*update_linetime_wm)(struct drm_device *dev, int pipe,
  238. struct drm_display_mode *mode);
  239. void (*modeset_global_resources)(struct drm_device *dev);
  240. int (*crtc_mode_set)(struct drm_crtc *crtc,
  241. struct drm_display_mode *mode,
  242. struct drm_display_mode *adjusted_mode,
  243. int x, int y,
  244. struct drm_framebuffer *old_fb);
  245. void (*crtc_enable)(struct drm_crtc *crtc);
  246. void (*crtc_disable)(struct drm_crtc *crtc);
  247. void (*off)(struct drm_crtc *crtc);
  248. void (*write_eld)(struct drm_connector *connector,
  249. struct drm_crtc *crtc);
  250. void (*fdi_link_train)(struct drm_crtc *crtc);
  251. void (*init_clock_gating)(struct drm_device *dev);
  252. int (*queue_flip)(struct drm_device *dev, struct drm_crtc *crtc,
  253. struct drm_framebuffer *fb,
  254. struct drm_i915_gem_object *obj);
  255. int (*update_plane)(struct drm_crtc *crtc, struct drm_framebuffer *fb,
  256. int x, int y);
  257. /* clock updates for mode set */
  258. /* cursor updates */
  259. /* render clock increase/decrease */
  260. /* display clock increase/decrease */
  261. /* pll clock increase/decrease */
  262. };
  263. struct drm_i915_gt_funcs {
  264. void (*force_wake_get)(struct drm_i915_private *dev_priv);
  265. void (*force_wake_put)(struct drm_i915_private *dev_priv);
  266. };
  267. #define DEV_INFO_FLAGS \
  268. DEV_INFO_FLAG(is_mobile) DEV_INFO_SEP \
  269. DEV_INFO_FLAG(is_i85x) DEV_INFO_SEP \
  270. DEV_INFO_FLAG(is_i915g) DEV_INFO_SEP \
  271. DEV_INFO_FLAG(is_i945gm) DEV_INFO_SEP \
  272. DEV_INFO_FLAG(is_g33) DEV_INFO_SEP \
  273. DEV_INFO_FLAG(need_gfx_hws) DEV_INFO_SEP \
  274. DEV_INFO_FLAG(is_g4x) DEV_INFO_SEP \
  275. DEV_INFO_FLAG(is_pineview) DEV_INFO_SEP \
  276. DEV_INFO_FLAG(is_broadwater) DEV_INFO_SEP \
  277. DEV_INFO_FLAG(is_crestline) DEV_INFO_SEP \
  278. DEV_INFO_FLAG(is_ivybridge) DEV_INFO_SEP \
  279. DEV_INFO_FLAG(is_valleyview) DEV_INFO_SEP \
  280. DEV_INFO_FLAG(is_haswell) DEV_INFO_SEP \
  281. DEV_INFO_FLAG(has_force_wake) DEV_INFO_SEP \
  282. DEV_INFO_FLAG(has_fbc) DEV_INFO_SEP \
  283. DEV_INFO_FLAG(has_pipe_cxsr) DEV_INFO_SEP \
  284. DEV_INFO_FLAG(has_hotplug) DEV_INFO_SEP \
  285. DEV_INFO_FLAG(cursor_needs_physical) DEV_INFO_SEP \
  286. DEV_INFO_FLAG(has_overlay) DEV_INFO_SEP \
  287. DEV_INFO_FLAG(overlay_needs_physical) DEV_INFO_SEP \
  288. DEV_INFO_FLAG(supports_tv) DEV_INFO_SEP \
  289. DEV_INFO_FLAG(has_bsd_ring) DEV_INFO_SEP \
  290. DEV_INFO_FLAG(has_blt_ring) DEV_INFO_SEP \
  291. DEV_INFO_FLAG(has_llc)
  292. struct intel_device_info {
  293. u8 gen;
  294. u8 is_mobile:1;
  295. u8 is_i85x:1;
  296. u8 is_i915g:1;
  297. u8 is_i945gm:1;
  298. u8 is_g33:1;
  299. u8 need_gfx_hws:1;
  300. u8 is_g4x:1;
  301. u8 is_pineview:1;
  302. u8 is_broadwater:1;
  303. u8 is_crestline:1;
  304. u8 is_ivybridge:1;
  305. u8 is_valleyview:1;
  306. u8 has_force_wake:1;
  307. u8 is_haswell:1;
  308. u8 has_fbc:1;
  309. u8 has_pipe_cxsr:1;
  310. u8 has_hotplug:1;
  311. u8 cursor_needs_physical:1;
  312. u8 has_overlay:1;
  313. u8 overlay_needs_physical:1;
  314. u8 supports_tv:1;
  315. u8 has_bsd_ring:1;
  316. u8 has_blt_ring:1;
  317. u8 has_llc:1;
  318. };
  319. #define I915_PPGTT_PD_ENTRIES 512
  320. #define I915_PPGTT_PT_ENTRIES 1024
  321. struct i915_hw_ppgtt {
  322. struct drm_device *dev;
  323. unsigned num_pd_entries;
  324. struct page **pt_pages;
  325. uint32_t pd_offset;
  326. dma_addr_t *pt_dma_addr;
  327. dma_addr_t scratch_page_dma_addr;
  328. };
  329. /* This must match up with the value previously used for execbuf2.rsvd1. */
  330. #define DEFAULT_CONTEXT_ID 0
  331. struct i915_hw_context {
  332. int id;
  333. bool is_initialized;
  334. struct drm_i915_file_private *file_priv;
  335. struct intel_ring_buffer *ring;
  336. struct drm_i915_gem_object *obj;
  337. };
  338. enum no_fbc_reason {
  339. FBC_NO_OUTPUT, /* no outputs enabled to compress */
  340. FBC_STOLEN_TOO_SMALL, /* not enough space to hold compressed buffers */
  341. FBC_UNSUPPORTED_MODE, /* interlace or doublescanned mode */
  342. FBC_MODE_TOO_LARGE, /* mode too large for compression */
  343. FBC_BAD_PLANE, /* fbc not supported on plane */
  344. FBC_NOT_TILED, /* buffer not tiled */
  345. FBC_MULTIPLE_PIPES, /* more than one pipe active */
  346. FBC_MODULE_PARAM,
  347. };
  348. enum intel_pch {
  349. PCH_NONE = 0, /* No PCH present */
  350. PCH_IBX, /* Ibexpeak PCH */
  351. PCH_CPT, /* Cougarpoint PCH */
  352. PCH_LPT, /* Lynxpoint PCH */
  353. };
  354. #define QUIRK_PIPEA_FORCE (1<<0)
  355. #define QUIRK_LVDS_SSC_DISABLE (1<<1)
  356. #define QUIRK_INVERT_BRIGHTNESS (1<<2)
  357. struct intel_fbdev;
  358. struct intel_fbc_work;
  359. struct intel_gmbus {
  360. struct i2c_adapter adapter;
  361. u32 force_bit;
  362. u32 reg0;
  363. u32 gpio_reg;
  364. struct i2c_algo_bit_data bit_algo;
  365. struct drm_i915_private *dev_priv;
  366. };
  367. struct i915_suspend_saved_registers {
  368. u8 saveLBB;
  369. u32 saveDSPACNTR;
  370. u32 saveDSPBCNTR;
  371. u32 saveDSPARB;
  372. u32 savePIPEACONF;
  373. u32 savePIPEBCONF;
  374. u32 savePIPEASRC;
  375. u32 savePIPEBSRC;
  376. u32 saveFPA0;
  377. u32 saveFPA1;
  378. u32 saveDPLL_A;
  379. u32 saveDPLL_A_MD;
  380. u32 saveHTOTAL_A;
  381. u32 saveHBLANK_A;
  382. u32 saveHSYNC_A;
  383. u32 saveVTOTAL_A;
  384. u32 saveVBLANK_A;
  385. u32 saveVSYNC_A;
  386. u32 saveBCLRPAT_A;
  387. u32 saveTRANSACONF;
  388. u32 saveTRANS_HTOTAL_A;
  389. u32 saveTRANS_HBLANK_A;
  390. u32 saveTRANS_HSYNC_A;
  391. u32 saveTRANS_VTOTAL_A;
  392. u32 saveTRANS_VBLANK_A;
  393. u32 saveTRANS_VSYNC_A;
  394. u32 savePIPEASTAT;
  395. u32 saveDSPASTRIDE;
  396. u32 saveDSPASIZE;
  397. u32 saveDSPAPOS;
  398. u32 saveDSPAADDR;
  399. u32 saveDSPASURF;
  400. u32 saveDSPATILEOFF;
  401. u32 savePFIT_PGM_RATIOS;
  402. u32 saveBLC_HIST_CTL;
  403. u32 saveBLC_PWM_CTL;
  404. u32 saveBLC_PWM_CTL2;
  405. u32 saveBLC_CPU_PWM_CTL;
  406. u32 saveBLC_CPU_PWM_CTL2;
  407. u32 saveFPB0;
  408. u32 saveFPB1;
  409. u32 saveDPLL_B;
  410. u32 saveDPLL_B_MD;
  411. u32 saveHTOTAL_B;
  412. u32 saveHBLANK_B;
  413. u32 saveHSYNC_B;
  414. u32 saveVTOTAL_B;
  415. u32 saveVBLANK_B;
  416. u32 saveVSYNC_B;
  417. u32 saveBCLRPAT_B;
  418. u32 saveTRANSBCONF;
  419. u32 saveTRANS_HTOTAL_B;
  420. u32 saveTRANS_HBLANK_B;
  421. u32 saveTRANS_HSYNC_B;
  422. u32 saveTRANS_VTOTAL_B;
  423. u32 saveTRANS_VBLANK_B;
  424. u32 saveTRANS_VSYNC_B;
  425. u32 savePIPEBSTAT;
  426. u32 saveDSPBSTRIDE;
  427. u32 saveDSPBSIZE;
  428. u32 saveDSPBPOS;
  429. u32 saveDSPBADDR;
  430. u32 saveDSPBSURF;
  431. u32 saveDSPBTILEOFF;
  432. u32 saveVGA0;
  433. u32 saveVGA1;
  434. u32 saveVGA_PD;
  435. u32 saveVGACNTRL;
  436. u32 saveADPA;
  437. u32 saveLVDS;
  438. u32 savePP_ON_DELAYS;
  439. u32 savePP_OFF_DELAYS;
  440. u32 saveDVOA;
  441. u32 saveDVOB;
  442. u32 saveDVOC;
  443. u32 savePP_ON;
  444. u32 savePP_OFF;
  445. u32 savePP_CONTROL;
  446. u32 savePP_DIVISOR;
  447. u32 savePFIT_CONTROL;
  448. u32 save_palette_a[256];
  449. u32 save_palette_b[256];
  450. u32 saveDPFC_CB_BASE;
  451. u32 saveFBC_CFB_BASE;
  452. u32 saveFBC_LL_BASE;
  453. u32 saveFBC_CONTROL;
  454. u32 saveFBC_CONTROL2;
  455. u32 saveIER;
  456. u32 saveIIR;
  457. u32 saveIMR;
  458. u32 saveDEIER;
  459. u32 saveDEIMR;
  460. u32 saveGTIER;
  461. u32 saveGTIMR;
  462. u32 saveFDI_RXA_IMR;
  463. u32 saveFDI_RXB_IMR;
  464. u32 saveCACHE_MODE_0;
  465. u32 saveMI_ARB_STATE;
  466. u32 saveSWF0[16];
  467. u32 saveSWF1[16];
  468. u32 saveSWF2[3];
  469. u8 saveMSR;
  470. u8 saveSR[8];
  471. u8 saveGR[25];
  472. u8 saveAR_INDEX;
  473. u8 saveAR[21];
  474. u8 saveDACMASK;
  475. u8 saveCR[37];
  476. uint64_t saveFENCE[I915_MAX_NUM_FENCES];
  477. u32 saveCURACNTR;
  478. u32 saveCURAPOS;
  479. u32 saveCURABASE;
  480. u32 saveCURBCNTR;
  481. u32 saveCURBPOS;
  482. u32 saveCURBBASE;
  483. u32 saveCURSIZE;
  484. u32 saveDP_B;
  485. u32 saveDP_C;
  486. u32 saveDP_D;
  487. u32 savePIPEA_GMCH_DATA_M;
  488. u32 savePIPEB_GMCH_DATA_M;
  489. u32 savePIPEA_GMCH_DATA_N;
  490. u32 savePIPEB_GMCH_DATA_N;
  491. u32 savePIPEA_DP_LINK_M;
  492. u32 savePIPEB_DP_LINK_M;
  493. u32 savePIPEA_DP_LINK_N;
  494. u32 savePIPEB_DP_LINK_N;
  495. u32 saveFDI_RXA_CTL;
  496. u32 saveFDI_TXA_CTL;
  497. u32 saveFDI_RXB_CTL;
  498. u32 saveFDI_TXB_CTL;
  499. u32 savePFA_CTL_1;
  500. u32 savePFB_CTL_1;
  501. u32 savePFA_WIN_SZ;
  502. u32 savePFB_WIN_SZ;
  503. u32 savePFA_WIN_POS;
  504. u32 savePFB_WIN_POS;
  505. u32 savePCH_DREF_CONTROL;
  506. u32 saveDISP_ARB_CTL;
  507. u32 savePIPEA_DATA_M1;
  508. u32 savePIPEA_DATA_N1;
  509. u32 savePIPEA_LINK_M1;
  510. u32 savePIPEA_LINK_N1;
  511. u32 savePIPEB_DATA_M1;
  512. u32 savePIPEB_DATA_N1;
  513. u32 savePIPEB_LINK_M1;
  514. u32 savePIPEB_LINK_N1;
  515. u32 saveMCHBAR_RENDER_STANDBY;
  516. u32 savePCH_PORT_HOTPLUG;
  517. };
  518. struct intel_gen6_power_mgmt {
  519. struct work_struct work;
  520. u32 pm_iir;
  521. /* lock - irqsave spinlock that protectects the work_struct and
  522. * pm_iir. */
  523. spinlock_t lock;
  524. /* The below variables an all the rps hw state are protected by
  525. * dev->struct mutext. */
  526. u8 cur_delay;
  527. u8 min_delay;
  528. u8 max_delay;
  529. struct delayed_work delayed_resume_work;
  530. /*
  531. * Protects RPS/RC6 register access and PCU communication.
  532. * Must be taken after struct_mutex if nested.
  533. */
  534. struct mutex hw_lock;
  535. };
  536. /* defined intel_pm.c */
  537. extern spinlock_t mchdev_lock;
  538. struct intel_ilk_power_mgmt {
  539. u8 cur_delay;
  540. u8 min_delay;
  541. u8 max_delay;
  542. u8 fmax;
  543. u8 fstart;
  544. u64 last_count1;
  545. unsigned long last_time1;
  546. unsigned long chipset_power;
  547. u64 last_count2;
  548. struct timespec last_time2;
  549. unsigned long gfx_power;
  550. u8 corr;
  551. int c_m;
  552. int r_t;
  553. struct drm_i915_gem_object *pwrctx;
  554. struct drm_i915_gem_object *renderctx;
  555. };
  556. struct i915_dri1_state {
  557. unsigned allow_batchbuffer : 1;
  558. u32 __iomem *gfx_hws_cpu_addr;
  559. unsigned int cpp;
  560. int back_offset;
  561. int front_offset;
  562. int current_page;
  563. int page_flipping;
  564. uint32_t counter;
  565. };
  566. struct intel_l3_parity {
  567. u32 *remap_info;
  568. struct work_struct error_work;
  569. };
  570. typedef struct drm_i915_private {
  571. struct drm_device *dev;
  572. struct kmem_cache *slab;
  573. const struct intel_device_info *info;
  574. int relative_constants_mode;
  575. void __iomem *regs;
  576. struct drm_i915_gt_funcs gt;
  577. /** gt_fifo_count and the subsequent register write are synchronized
  578. * with dev->struct_mutex. */
  579. unsigned gt_fifo_count;
  580. /** forcewake_count is protected by gt_lock */
  581. unsigned forcewake_count;
  582. /** gt_lock is also taken in irq contexts. */
  583. spinlock_t gt_lock;
  584. struct intel_gmbus gmbus[GMBUS_NUM_PORTS];
  585. /** gmbus_mutex protects against concurrent usage of the single hw gmbus
  586. * controller on different i2c buses. */
  587. struct mutex gmbus_mutex;
  588. /**
  589. * Base address of the gmbus and gpio block.
  590. */
  591. uint32_t gpio_mmio_base;
  592. struct pci_dev *bridge_dev;
  593. struct intel_ring_buffer ring[I915_NUM_RINGS];
  594. uint32_t next_seqno;
  595. drm_dma_handle_t *status_page_dmah;
  596. struct resource mch_res;
  597. atomic_t irq_received;
  598. /* protects the irq masks */
  599. spinlock_t irq_lock;
  600. /* DPIO indirect register protection */
  601. spinlock_t dpio_lock;
  602. /** Cached value of IMR to avoid reads in updating the bitfield */
  603. u32 pipestat[2];
  604. u32 irq_mask;
  605. u32 gt_irq_mask;
  606. u32 pch_irq_mask;
  607. u32 hotplug_supported_mask;
  608. struct work_struct hotplug_work;
  609. bool enable_hotplug_processing;
  610. int num_pipe;
  611. int num_pch_pll;
  612. /* For hangcheck timer */
  613. #define DRM_I915_HANGCHECK_PERIOD 1500 /* in ms */
  614. #define DRM_I915_HANGCHECK_JIFFIES msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD)
  615. struct timer_list hangcheck_timer;
  616. int hangcheck_count;
  617. uint32_t last_acthd[I915_NUM_RINGS];
  618. uint32_t prev_instdone[I915_NUM_INSTDONE_REG];
  619. unsigned int stop_rings;
  620. unsigned long cfb_size;
  621. unsigned int cfb_fb;
  622. enum plane cfb_plane;
  623. int cfb_y;
  624. struct intel_fbc_work *fbc_work;
  625. struct intel_opregion opregion;
  626. /* overlay */
  627. struct intel_overlay *overlay;
  628. bool sprite_scaling_enabled;
  629. /* LVDS info */
  630. int backlight_level; /* restore backlight to this value */
  631. bool backlight_enabled;
  632. struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */
  633. struct drm_display_mode *sdvo_lvds_vbt_mode; /* if any */
  634. /* Feature bits from the VBIOS */
  635. unsigned int int_tv_support:1;
  636. unsigned int lvds_dither:1;
  637. unsigned int lvds_vbt:1;
  638. unsigned int int_crt_support:1;
  639. unsigned int lvds_use_ssc:1;
  640. unsigned int display_clock_mode:1;
  641. int lvds_ssc_freq;
  642. unsigned int bios_lvds_val; /* initial [PCH_]LVDS reg val in VBIOS */
  643. struct {
  644. int rate;
  645. int lanes;
  646. int preemphasis;
  647. int vswing;
  648. bool initialized;
  649. bool support;
  650. int bpp;
  651. struct edp_power_seq pps;
  652. } edp;
  653. bool no_aux_handshake;
  654. int crt_ddc_pin;
  655. struct drm_i915_fence_reg fence_regs[I915_MAX_NUM_FENCES]; /* assume 965 */
  656. int fence_reg_start; /* 4 if userland hasn't ioctl'd us yet */
  657. int num_fence_regs; /* 8 on pre-965, 16 otherwise */
  658. unsigned int fsb_freq, mem_freq, is_ddr3;
  659. spinlock_t error_lock;
  660. /* Protected by dev->error_lock. */
  661. struct drm_i915_error_state *first_error;
  662. struct work_struct error_work;
  663. struct completion error_completion;
  664. struct workqueue_struct *wq;
  665. /* Display functions */
  666. struct drm_i915_display_funcs display;
  667. /* PCH chipset type */
  668. enum intel_pch pch_type;
  669. unsigned short pch_id;
  670. unsigned long quirks;
  671. /* Register state */
  672. bool modeset_on_lid;
  673. struct {
  674. /** Bridge to intel-gtt-ko */
  675. struct intel_gtt *gtt;
  676. /** Memory allocator for GTT stolen memory */
  677. struct drm_mm stolen;
  678. /** Memory allocator for GTT */
  679. struct drm_mm gtt_space;
  680. /** List of all objects in gtt_space. Used to restore gtt
  681. * mappings on resume */
  682. struct list_head bound_list;
  683. /**
  684. * List of objects which are not bound to the GTT (thus
  685. * are idle and not used by the GPU) but still have
  686. * (presumably uncached) pages still attached.
  687. */
  688. struct list_head unbound_list;
  689. /** Usable portion of the GTT for GEM */
  690. unsigned long gtt_start;
  691. unsigned long gtt_mappable_end;
  692. unsigned long gtt_end;
  693. unsigned long stolen_base; /* limited to low memory (32-bit) */
  694. struct io_mapping *gtt_mapping;
  695. phys_addr_t gtt_base_addr;
  696. int gtt_mtrr;
  697. /** PPGTT used for aliasing the PPGTT with the GTT */
  698. struct i915_hw_ppgtt *aliasing_ppgtt;
  699. struct shrinker inactive_shrinker;
  700. /**
  701. * List of objects currently involved in rendering.
  702. *
  703. * Includes buffers having the contents of their GPU caches
  704. * flushed, not necessarily primitives. last_rendering_seqno
  705. * represents when the rendering involved will be completed.
  706. *
  707. * A reference is held on the buffer while on this list.
  708. */
  709. struct list_head active_list;
  710. /**
  711. * LRU list of objects which are not in the ringbuffer and
  712. * are ready to unbind, but are still in the GTT.
  713. *
  714. * last_rendering_seqno is 0 while an object is in this list.
  715. *
  716. * A reference is not held on the buffer while on this list,
  717. * as merely being GTT-bound shouldn't prevent its being
  718. * freed, and we'll pull it off the list in the free path.
  719. */
  720. struct list_head inactive_list;
  721. /** LRU list of objects with fence regs on them. */
  722. struct list_head fence_list;
  723. /**
  724. * We leave the user IRQ off as much as possible,
  725. * but this means that requests will finish and never
  726. * be retired once the system goes idle. Set a timer to
  727. * fire periodically while the ring is running. When it
  728. * fires, go retire requests.
  729. */
  730. struct delayed_work retire_work;
  731. /**
  732. * Are we in a non-interruptible section of code like
  733. * modesetting?
  734. */
  735. bool interruptible;
  736. /**
  737. * Flag if the X Server, and thus DRM, is not currently in
  738. * control of the device.
  739. *
  740. * This is set between LeaveVT and EnterVT. It needs to be
  741. * replaced with a semaphore. It also needs to be
  742. * transitioned away from for kernel modesetting.
  743. */
  744. int suspended;
  745. /**
  746. * Flag if the hardware appears to be wedged.
  747. *
  748. * This is set when attempts to idle the device timeout.
  749. * It prevents command submission from occurring and makes
  750. * every pending request fail
  751. */
  752. atomic_t wedged;
  753. /** Bit 6 swizzling required for X tiling */
  754. uint32_t bit_6_swizzle_x;
  755. /** Bit 6 swizzling required for Y tiling */
  756. uint32_t bit_6_swizzle_y;
  757. /* storage for physical objects */
  758. struct drm_i915_gem_phys_object *phys_objs[I915_MAX_PHYS_OBJECT];
  759. /* accounting, useful for userland debugging */
  760. size_t gtt_total;
  761. size_t mappable_gtt_total;
  762. size_t object_memory;
  763. u32 object_count;
  764. } mm;
  765. /* Kernel Modesetting */
  766. struct sdvo_device_mapping sdvo_mappings[2];
  767. /* indicate whether the LVDS_BORDER should be enabled or not */
  768. unsigned int lvds_border_bits;
  769. /* Panel fitter placement and size for Ironlake+ */
  770. u32 pch_pf_pos, pch_pf_size;
  771. struct drm_crtc *plane_to_crtc_mapping[3];
  772. struct drm_crtc *pipe_to_crtc_mapping[3];
  773. wait_queue_head_t pending_flip_queue;
  774. struct intel_pch_pll pch_plls[I915_NUM_PLLS];
  775. struct intel_ddi_plls ddi_plls;
  776. /* Reclocking support */
  777. bool render_reclock_avail;
  778. bool lvds_downclock_avail;
  779. /* indicates the reduced downclock for LVDS*/
  780. int lvds_downclock;
  781. u16 orig_clock;
  782. int child_dev_num;
  783. struct child_device_config *child_dev;
  784. bool mchbar_need_disable;
  785. struct intel_l3_parity l3_parity;
  786. /* gen6+ rps state */
  787. struct intel_gen6_power_mgmt rps;
  788. /* ilk-only ips/rps state. Everything in here is protected by the global
  789. * mchdev_lock in intel_pm.c */
  790. struct intel_ilk_power_mgmt ips;
  791. enum no_fbc_reason no_fbc_reason;
  792. struct drm_mm_node *compressed_fb;
  793. struct drm_mm_node *compressed_llb;
  794. unsigned long last_gpu_reset;
  795. /* list of fbdev register on this device */
  796. struct intel_fbdev *fbdev;
  797. /*
  798. * The console may be contended at resume, but we don't
  799. * want it to block on it.
  800. */
  801. struct work_struct console_resume_work;
  802. struct backlight_device *backlight;
  803. struct drm_property *broadcast_rgb_property;
  804. struct drm_property *force_audio_property;
  805. bool hw_contexts_disabled;
  806. uint32_t hw_context_size;
  807. struct i915_suspend_saved_registers regfile;
  808. /* Old dri1 support infrastructure, beware the dragons ya fools entering
  809. * here! */
  810. struct i915_dri1_state dri1;
  811. } drm_i915_private_t;
  812. /* Iterate over initialised rings */
  813. #define for_each_ring(ring__, dev_priv__, i__) \
  814. for ((i__) = 0; (i__) < I915_NUM_RINGS; (i__)++) \
  815. if (((ring__) = &(dev_priv__)->ring[(i__)]), intel_ring_initialized((ring__)))
  816. enum hdmi_force_audio {
  817. HDMI_AUDIO_OFF_DVI = -2, /* no aux data for HDMI-DVI converter */
  818. HDMI_AUDIO_OFF, /* force turn off HDMI audio */
  819. HDMI_AUDIO_AUTO, /* trust EDID */
  820. HDMI_AUDIO_ON, /* force turn on HDMI audio */
  821. };
  822. enum i915_cache_level {
  823. I915_CACHE_NONE = 0,
  824. I915_CACHE_LLC,
  825. I915_CACHE_LLC_MLC, /* gen6+, in docs at least! */
  826. };
  827. #define I915_GTT_RESERVED ((struct drm_mm_node *)0x1)
  828. struct drm_i915_gem_object_ops {
  829. /* Interface between the GEM object and its backing storage.
  830. * get_pages() is called once prior to the use of the associated set
  831. * of pages before to binding them into the GTT, and put_pages() is
  832. * called after we no longer need them. As we expect there to be
  833. * associated cost with migrating pages between the backing storage
  834. * and making them available for the GPU (e.g. clflush), we may hold
  835. * onto the pages after they are no longer referenced by the GPU
  836. * in case they may be used again shortly (for example migrating the
  837. * pages to a different memory domain within the GTT). put_pages()
  838. * will therefore most likely be called when the object itself is
  839. * being released or under memory pressure (where we attempt to
  840. * reap pages for the shrinker).
  841. */
  842. int (*get_pages)(struct drm_i915_gem_object *);
  843. void (*put_pages)(struct drm_i915_gem_object *);
  844. };
  845. struct drm_i915_gem_object {
  846. struct drm_gem_object base;
  847. const struct drm_i915_gem_object_ops *ops;
  848. /** Current space allocated to this object in the GTT, if any. */
  849. struct drm_mm_node *gtt_space;
  850. /** Stolen memory for this object, instead of being backed by shmem. */
  851. struct drm_mm_node *stolen;
  852. struct list_head gtt_list;
  853. /** This object's place on the active/inactive lists */
  854. struct list_head ring_list;
  855. struct list_head mm_list;
  856. /** This object's place in the batchbuffer or on the eviction list */
  857. struct list_head exec_list;
  858. /**
  859. * This is set if the object is on the active lists (has pending
  860. * rendering and so a non-zero seqno), and is not set if it i s on
  861. * inactive (ready to be unbound) list.
  862. */
  863. unsigned int active:1;
  864. /**
  865. * This is set if the object has been written to since last bound
  866. * to the GTT
  867. */
  868. unsigned int dirty:1;
  869. /**
  870. * Fence register bits (if any) for this object. Will be set
  871. * as needed when mapped into the GTT.
  872. * Protected by dev->struct_mutex.
  873. */
  874. signed int fence_reg:I915_MAX_NUM_FENCE_BITS;
  875. /**
  876. * Advice: are the backing pages purgeable?
  877. */
  878. unsigned int madv:2;
  879. /**
  880. * Current tiling mode for the object.
  881. */
  882. unsigned int tiling_mode:2;
  883. /**
  884. * Whether the tiling parameters for the currently associated fence
  885. * register have changed. Note that for the purposes of tracking
  886. * tiling changes we also treat the unfenced register, the register
  887. * slot that the object occupies whilst it executes a fenced
  888. * command (such as BLT on gen2/3), as a "fence".
  889. */
  890. unsigned int fence_dirty:1;
  891. /** How many users have pinned this object in GTT space. The following
  892. * users can each hold at most one reference: pwrite/pread, pin_ioctl
  893. * (via user_pin_count), execbuffer (objects are not allowed multiple
  894. * times for the same batchbuffer), and the framebuffer code. When
  895. * switching/pageflipping, the framebuffer code has at most two buffers
  896. * pinned per crtc.
  897. *
  898. * In the worst case this is 1 + 1 + 1 + 2*2 = 7. That would fit into 3
  899. * bits with absolutely no headroom. So use 4 bits. */
  900. unsigned int pin_count:4;
  901. #define DRM_I915_GEM_OBJECT_MAX_PIN_COUNT 0xf
  902. /**
  903. * Is the object at the current location in the gtt mappable and
  904. * fenceable? Used to avoid costly recalculations.
  905. */
  906. unsigned int map_and_fenceable:1;
  907. /**
  908. * Whether the current gtt mapping needs to be mappable (and isn't just
  909. * mappable by accident). Track pin and fault separate for a more
  910. * accurate mappable working set.
  911. */
  912. unsigned int fault_mappable:1;
  913. unsigned int pin_mappable:1;
  914. /*
  915. * Is the GPU currently using a fence to access this buffer,
  916. */
  917. unsigned int pending_fenced_gpu_access:1;
  918. unsigned int fenced_gpu_access:1;
  919. unsigned int cache_level:2;
  920. unsigned int has_aliasing_ppgtt_mapping:1;
  921. unsigned int has_global_gtt_mapping:1;
  922. unsigned int has_dma_mapping:1;
  923. struct sg_table *pages;
  924. int pages_pin_count;
  925. /* prime dma-buf support */
  926. void *dma_buf_vmapping;
  927. int vmapping_count;
  928. /**
  929. * Used for performing relocations during execbuffer insertion.
  930. */
  931. struct hlist_node exec_node;
  932. unsigned long exec_handle;
  933. struct drm_i915_gem_exec_object2 *exec_entry;
  934. /**
  935. * Current offset of the object in GTT space.
  936. *
  937. * This is the same as gtt_space->start
  938. */
  939. uint32_t gtt_offset;
  940. struct intel_ring_buffer *ring;
  941. /** Breadcrumb of last rendering to the buffer. */
  942. uint32_t last_read_seqno;
  943. uint32_t last_write_seqno;
  944. /** Breadcrumb of last fenced GPU access to the buffer. */
  945. uint32_t last_fenced_seqno;
  946. /** Current tiling stride for the object, if it's tiled. */
  947. uint32_t stride;
  948. /** Record of address bit 17 of each page at last unbind. */
  949. unsigned long *bit_17;
  950. /** User space pin count and filp owning the pin */
  951. uint32_t user_pin_count;
  952. struct drm_file *pin_filp;
  953. /** for phy allocated objects */
  954. struct drm_i915_gem_phys_object *phys_obj;
  955. /**
  956. * Number of crtcs where this object is currently the fb, but
  957. * will be page flipped away on the next vblank. When it
  958. * reaches 0, dev_priv->pending_flip_queue will be woken up.
  959. */
  960. atomic_t pending_flip;
  961. };
  962. #define to_intel_bo(x) container_of(x, struct drm_i915_gem_object, base)
  963. /**
  964. * Request queue structure.
  965. *
  966. * The request queue allows us to note sequence numbers that have been emitted
  967. * and may be associated with active buffers to be retired.
  968. *
  969. * By keeping this list, we can avoid having to do questionable
  970. * sequence-number comparisons on buffer last_rendering_seqnos, and associate
  971. * an emission time with seqnos for tracking how far ahead of the GPU we are.
  972. */
  973. struct drm_i915_gem_request {
  974. /** On Which ring this request was generated */
  975. struct intel_ring_buffer *ring;
  976. /** GEM sequence number associated with this request. */
  977. uint32_t seqno;
  978. /** Postion in the ringbuffer of the end of the request */
  979. u32 tail;
  980. /** Time at which this request was emitted, in jiffies. */
  981. unsigned long emitted_jiffies;
  982. /** global list entry for this request */
  983. struct list_head list;
  984. struct drm_i915_file_private *file_priv;
  985. /** file_priv list entry for this request */
  986. struct list_head client_list;
  987. };
  988. struct drm_i915_file_private {
  989. struct {
  990. spinlock_t lock;
  991. struct list_head request_list;
  992. } mm;
  993. struct idr context_idr;
  994. };
  995. #define INTEL_INFO(dev) (((struct drm_i915_private *) (dev)->dev_private)->info)
  996. #define IS_I830(dev) ((dev)->pci_device == 0x3577)
  997. #define IS_845G(dev) ((dev)->pci_device == 0x2562)
  998. #define IS_I85X(dev) (INTEL_INFO(dev)->is_i85x)
  999. #define IS_I865G(dev) ((dev)->pci_device == 0x2572)
  1000. #define IS_I915G(dev) (INTEL_INFO(dev)->is_i915g)
  1001. #define IS_I915GM(dev) ((dev)->pci_device == 0x2592)
  1002. #define IS_I945G(dev) ((dev)->pci_device == 0x2772)
  1003. #define IS_I945GM(dev) (INTEL_INFO(dev)->is_i945gm)
  1004. #define IS_BROADWATER(dev) (INTEL_INFO(dev)->is_broadwater)
  1005. #define IS_CRESTLINE(dev) (INTEL_INFO(dev)->is_crestline)
  1006. #define IS_GM45(dev) ((dev)->pci_device == 0x2A42)
  1007. #define IS_G4X(dev) (INTEL_INFO(dev)->is_g4x)
  1008. #define IS_PINEVIEW_G(dev) ((dev)->pci_device == 0xa001)
  1009. #define IS_PINEVIEW_M(dev) ((dev)->pci_device == 0xa011)
  1010. #define IS_PINEVIEW(dev) (INTEL_INFO(dev)->is_pineview)
  1011. #define IS_G33(dev) (INTEL_INFO(dev)->is_g33)
  1012. #define IS_IRONLAKE_D(dev) ((dev)->pci_device == 0x0042)
  1013. #define IS_IRONLAKE_M(dev) ((dev)->pci_device == 0x0046)
  1014. #define IS_IVYBRIDGE(dev) (INTEL_INFO(dev)->is_ivybridge)
  1015. #define IS_IVB_GT1(dev) ((dev)->pci_device == 0x0156 || \
  1016. (dev)->pci_device == 0x0152 || \
  1017. (dev)->pci_device == 0x015a)
  1018. #define IS_VALLEYVIEW(dev) (INTEL_INFO(dev)->is_valleyview)
  1019. #define IS_HASWELL(dev) (INTEL_INFO(dev)->is_haswell)
  1020. #define IS_MOBILE(dev) (INTEL_INFO(dev)->is_mobile)
  1021. #define IS_ULT(dev) (IS_HASWELL(dev) && \
  1022. ((dev)->pci_device & 0xFF00) == 0x0A00)
  1023. /*
  1024. * The genX designation typically refers to the render engine, so render
  1025. * capability related checks should use IS_GEN, while display and other checks
  1026. * have their own (e.g. HAS_PCH_SPLIT for ILK+ display, IS_foo for particular
  1027. * chips, etc.).
  1028. */
  1029. #define IS_GEN2(dev) (INTEL_INFO(dev)->gen == 2)
  1030. #define IS_GEN3(dev) (INTEL_INFO(dev)->gen == 3)
  1031. #define IS_GEN4(dev) (INTEL_INFO(dev)->gen == 4)
  1032. #define IS_GEN5(dev) (INTEL_INFO(dev)->gen == 5)
  1033. #define IS_GEN6(dev) (INTEL_INFO(dev)->gen == 6)
  1034. #define IS_GEN7(dev) (INTEL_INFO(dev)->gen == 7)
  1035. #define HAS_BSD(dev) (INTEL_INFO(dev)->has_bsd_ring)
  1036. #define HAS_BLT(dev) (INTEL_INFO(dev)->has_blt_ring)
  1037. #define HAS_LLC(dev) (INTEL_INFO(dev)->has_llc)
  1038. #define I915_NEED_GFX_HWS(dev) (INTEL_INFO(dev)->need_gfx_hws)
  1039. #define HAS_HW_CONTEXTS(dev) (INTEL_INFO(dev)->gen >= 6)
  1040. #define HAS_ALIASING_PPGTT(dev) (INTEL_INFO(dev)->gen >=6 && !IS_VALLEYVIEW(dev))
  1041. #define HAS_OVERLAY(dev) (INTEL_INFO(dev)->has_overlay)
  1042. #define OVERLAY_NEEDS_PHYSICAL(dev) (INTEL_INFO(dev)->overlay_needs_physical)
  1043. /* With the 945 and later, Y tiling got adjusted so that it was 32 128-byte
  1044. * rows, which changed the alignment requirements and fence programming.
  1045. */
  1046. #define HAS_128_BYTE_Y_TILING(dev) (!IS_GEN2(dev) && !(IS_I915G(dev) || \
  1047. IS_I915GM(dev)))
  1048. #define SUPPORTS_DIGITAL_OUTPUTS(dev) (!IS_GEN2(dev) && !IS_PINEVIEW(dev))
  1049. #define SUPPORTS_INTEGRATED_HDMI(dev) (IS_G4X(dev) || IS_GEN5(dev))
  1050. #define SUPPORTS_INTEGRATED_DP(dev) (IS_G4X(dev) || IS_GEN5(dev))
  1051. #define SUPPORTS_EDP(dev) (IS_IRONLAKE_M(dev))
  1052. #define SUPPORTS_TV(dev) (INTEL_INFO(dev)->supports_tv)
  1053. #define I915_HAS_HOTPLUG(dev) (INTEL_INFO(dev)->has_hotplug)
  1054. /* dsparb controlled by hw only */
  1055. #define DSPARB_HWCONTROL(dev) (IS_G4X(dev) || IS_IRONLAKE(dev))
  1056. #define HAS_FW_BLC(dev) (INTEL_INFO(dev)->gen > 2)
  1057. #define HAS_PIPE_CXSR(dev) (INTEL_INFO(dev)->has_pipe_cxsr)
  1058. #define I915_HAS_FBC(dev) (INTEL_INFO(dev)->has_fbc)
  1059. #define HAS_PIPE_CONTROL(dev) (INTEL_INFO(dev)->gen >= 5)
  1060. #define HAS_DDI(dev) (IS_HASWELL(dev))
  1061. #define INTEL_PCH_DEVICE_ID_MASK 0xff00
  1062. #define INTEL_PCH_IBX_DEVICE_ID_TYPE 0x3b00
  1063. #define INTEL_PCH_CPT_DEVICE_ID_TYPE 0x1c00
  1064. #define INTEL_PCH_PPT_DEVICE_ID_TYPE 0x1e00
  1065. #define INTEL_PCH_LPT_DEVICE_ID_TYPE 0x8c00
  1066. #define INTEL_PCH_LPT_LP_DEVICE_ID_TYPE 0x9c00
  1067. #define INTEL_PCH_TYPE(dev) (((struct drm_i915_private *)(dev)->dev_private)->pch_type)
  1068. #define HAS_PCH_LPT(dev) (INTEL_PCH_TYPE(dev) == PCH_LPT)
  1069. #define HAS_PCH_CPT(dev) (INTEL_PCH_TYPE(dev) == PCH_CPT)
  1070. #define HAS_PCH_IBX(dev) (INTEL_PCH_TYPE(dev) == PCH_IBX)
  1071. #define HAS_PCH_SPLIT(dev) (INTEL_PCH_TYPE(dev) != PCH_NONE)
  1072. #define HAS_FORCE_WAKE(dev) (INTEL_INFO(dev)->has_force_wake)
  1073. #define HAS_L3_GPU_CACHE(dev) (IS_IVYBRIDGE(dev) || IS_HASWELL(dev))
  1074. #define GT_FREQUENCY_MULTIPLIER 50
  1075. #include "i915_trace.h"
  1076. /**
  1077. * RC6 is a special power stage which allows the GPU to enter an very
  1078. * low-voltage mode when idle, using down to 0V while at this stage. This
  1079. * stage is entered automatically when the GPU is idle when RC6 support is
  1080. * enabled, and as soon as new workload arises GPU wakes up automatically as well.
  1081. *
  1082. * There are different RC6 modes available in Intel GPU, which differentiate
  1083. * among each other with the latency required to enter and leave RC6 and
  1084. * voltage consumed by the GPU in different states.
  1085. *
  1086. * The combination of the following flags define which states GPU is allowed
  1087. * to enter, while RC6 is the normal RC6 state, RC6p is the deep RC6, and
  1088. * RC6pp is deepest RC6. Their support by hardware varies according to the
  1089. * GPU, BIOS, chipset and platform. RC6 is usually the safest one and the one
  1090. * which brings the most power savings; deeper states save more power, but
  1091. * require higher latency to switch to and wake up.
  1092. */
  1093. #define INTEL_RC6_ENABLE (1<<0)
  1094. #define INTEL_RC6p_ENABLE (1<<1)
  1095. #define INTEL_RC6pp_ENABLE (1<<2)
  1096. extern struct drm_ioctl_desc i915_ioctls[];
  1097. extern int i915_max_ioctl;
  1098. extern unsigned int i915_fbpercrtc __always_unused;
  1099. extern int i915_panel_ignore_lid __read_mostly;
  1100. extern unsigned int i915_powersave __read_mostly;
  1101. extern int i915_semaphores __read_mostly;
  1102. extern unsigned int i915_lvds_downclock __read_mostly;
  1103. extern int i915_lvds_channel_mode __read_mostly;
  1104. extern int i915_panel_use_ssc __read_mostly;
  1105. extern int i915_vbt_sdvo_panel_type __read_mostly;
  1106. extern int i915_enable_rc6 __read_mostly;
  1107. extern int i915_enable_fbc __read_mostly;
  1108. extern bool i915_enable_hangcheck __read_mostly;
  1109. extern int i915_enable_ppgtt __read_mostly;
  1110. extern unsigned int i915_preliminary_hw_support __read_mostly;
  1111. extern int i915_suspend(struct drm_device *dev, pm_message_t state);
  1112. extern int i915_resume(struct drm_device *dev);
  1113. extern int i915_master_create(struct drm_device *dev, struct drm_master *master);
  1114. extern void i915_master_destroy(struct drm_device *dev, struct drm_master *master);
  1115. /* i915_dma.c */
  1116. void i915_update_dri1_breadcrumb(struct drm_device *dev);
  1117. extern void i915_kernel_lost_context(struct drm_device * dev);
  1118. extern int i915_driver_load(struct drm_device *, unsigned long flags);
  1119. extern int i915_driver_unload(struct drm_device *);
  1120. extern int i915_driver_open(struct drm_device *dev, struct drm_file *file_priv);
  1121. extern void i915_driver_lastclose(struct drm_device * dev);
  1122. extern void i915_driver_preclose(struct drm_device *dev,
  1123. struct drm_file *file_priv);
  1124. extern void i915_driver_postclose(struct drm_device *dev,
  1125. struct drm_file *file_priv);
  1126. extern int i915_driver_device_is_agp(struct drm_device * dev);
  1127. #ifdef CONFIG_COMPAT
  1128. extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
  1129. unsigned long arg);
  1130. #endif
  1131. extern int i915_emit_box(struct drm_device *dev,
  1132. struct drm_clip_rect *box,
  1133. int DR1, int DR4);
  1134. extern int intel_gpu_reset(struct drm_device *dev);
  1135. extern int i915_reset(struct drm_device *dev);
  1136. extern unsigned long i915_chipset_val(struct drm_i915_private *dev_priv);
  1137. extern unsigned long i915_mch_val(struct drm_i915_private *dev_priv);
  1138. extern unsigned long i915_gfx_val(struct drm_i915_private *dev_priv);
  1139. extern void i915_update_gfx_val(struct drm_i915_private *dev_priv);
  1140. extern void intel_console_resume(struct work_struct *work);
  1141. /* i915_irq.c */
  1142. void i915_hangcheck_elapsed(unsigned long data);
  1143. void i915_handle_error(struct drm_device *dev, bool wedged);
  1144. extern void intel_irq_init(struct drm_device *dev);
  1145. extern void intel_gt_init(struct drm_device *dev);
  1146. extern void intel_gt_reset(struct drm_device *dev);
  1147. void i915_error_state_free(struct kref *error_ref);
  1148. void
  1149. i915_enable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask);
  1150. void
  1151. i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask);
  1152. void intel_enable_asle(struct drm_device *dev);
  1153. #ifdef CONFIG_DEBUG_FS
  1154. extern void i915_destroy_error_state(struct drm_device *dev);
  1155. #else
  1156. #define i915_destroy_error_state(x)
  1157. #endif
  1158. /* i915_gem.c */
  1159. int i915_gem_init_ioctl(struct drm_device *dev, void *data,
  1160. struct drm_file *file_priv);
  1161. int i915_gem_create_ioctl(struct drm_device *dev, void *data,
  1162. struct drm_file *file_priv);
  1163. int i915_gem_pread_ioctl(struct drm_device *dev, void *data,
  1164. struct drm_file *file_priv);
  1165. int i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
  1166. struct drm_file *file_priv);
  1167. int i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
  1168. struct drm_file *file_priv);
  1169. int i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
  1170. struct drm_file *file_priv);
  1171. int i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
  1172. struct drm_file *file_priv);
  1173. int i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
  1174. struct drm_file *file_priv);
  1175. int i915_gem_execbuffer(struct drm_device *dev, void *data,
  1176. struct drm_file *file_priv);
  1177. int i915_gem_execbuffer2(struct drm_device *dev, void *data,
  1178. struct drm_file *file_priv);
  1179. int i915_gem_pin_ioctl(struct drm_device *dev, void *data,
  1180. struct drm_file *file_priv);
  1181. int i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
  1182. struct drm_file *file_priv);
  1183. int i915_gem_busy_ioctl(struct drm_device *dev, void *data,
  1184. struct drm_file *file_priv);
  1185. int i915_gem_get_caching_ioctl(struct drm_device *dev, void *data,
  1186. struct drm_file *file);
  1187. int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
  1188. struct drm_file *file);
  1189. int i915_gem_throttle_ioctl(struct drm_device *dev, void *data,
  1190. struct drm_file *file_priv);
  1191. int i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
  1192. struct drm_file *file_priv);
  1193. int i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
  1194. struct drm_file *file_priv);
  1195. int i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
  1196. struct drm_file *file_priv);
  1197. int i915_gem_set_tiling(struct drm_device *dev, void *data,
  1198. struct drm_file *file_priv);
  1199. int i915_gem_get_tiling(struct drm_device *dev, void *data,
  1200. struct drm_file *file_priv);
  1201. int i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
  1202. struct drm_file *file_priv);
  1203. int i915_gem_wait_ioctl(struct drm_device *dev, void *data,
  1204. struct drm_file *file_priv);
  1205. void i915_gem_load(struct drm_device *dev);
  1206. void *i915_gem_object_alloc(struct drm_device *dev);
  1207. void i915_gem_object_free(struct drm_i915_gem_object *obj);
  1208. int i915_gem_init_object(struct drm_gem_object *obj);
  1209. void i915_gem_object_init(struct drm_i915_gem_object *obj,
  1210. const struct drm_i915_gem_object_ops *ops);
  1211. struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
  1212. size_t size);
  1213. void i915_gem_free_object(struct drm_gem_object *obj);
  1214. int __must_check i915_gem_object_pin(struct drm_i915_gem_object *obj,
  1215. uint32_t alignment,
  1216. bool map_and_fenceable,
  1217. bool nonblocking);
  1218. void i915_gem_object_unpin(struct drm_i915_gem_object *obj);
  1219. int __must_check i915_gem_object_unbind(struct drm_i915_gem_object *obj);
  1220. void i915_gem_release_mmap(struct drm_i915_gem_object *obj);
  1221. void i915_gem_lastclose(struct drm_device *dev);
  1222. int __must_check i915_gem_object_get_pages(struct drm_i915_gem_object *obj);
  1223. static inline struct page *i915_gem_object_get_page(struct drm_i915_gem_object *obj, int n)
  1224. {
  1225. struct scatterlist *sg = obj->pages->sgl;
  1226. int nents = obj->pages->nents;
  1227. while (nents > SG_MAX_SINGLE_ALLOC) {
  1228. if (n < SG_MAX_SINGLE_ALLOC - 1)
  1229. break;
  1230. sg = sg_chain_ptr(sg + SG_MAX_SINGLE_ALLOC - 1);
  1231. n -= SG_MAX_SINGLE_ALLOC - 1;
  1232. nents -= SG_MAX_SINGLE_ALLOC - 1;
  1233. }
  1234. return sg_page(sg+n);
  1235. }
  1236. static inline void i915_gem_object_pin_pages(struct drm_i915_gem_object *obj)
  1237. {
  1238. BUG_ON(obj->pages == NULL);
  1239. obj->pages_pin_count++;
  1240. }
  1241. static inline void i915_gem_object_unpin_pages(struct drm_i915_gem_object *obj)
  1242. {
  1243. BUG_ON(obj->pages_pin_count == 0);
  1244. obj->pages_pin_count--;
  1245. }
  1246. int __must_check i915_mutex_lock_interruptible(struct drm_device *dev);
  1247. int i915_gem_object_sync(struct drm_i915_gem_object *obj,
  1248. struct intel_ring_buffer *to);
  1249. void i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
  1250. struct intel_ring_buffer *ring);
  1251. int i915_gem_dumb_create(struct drm_file *file_priv,
  1252. struct drm_device *dev,
  1253. struct drm_mode_create_dumb *args);
  1254. int i915_gem_mmap_gtt(struct drm_file *file_priv, struct drm_device *dev,
  1255. uint32_t handle, uint64_t *offset);
  1256. int i915_gem_dumb_destroy(struct drm_file *file_priv, struct drm_device *dev,
  1257. uint32_t handle);
  1258. /**
  1259. * Returns true if seq1 is later than seq2.
  1260. */
  1261. static inline bool
  1262. i915_seqno_passed(uint32_t seq1, uint32_t seq2)
  1263. {
  1264. return (int32_t)(seq1 - seq2) >= 0;
  1265. }
  1266. extern int i915_gem_get_seqno(struct drm_device *dev, u32 *seqno);
  1267. int __must_check i915_gem_object_get_fence(struct drm_i915_gem_object *obj);
  1268. int __must_check i915_gem_object_put_fence(struct drm_i915_gem_object *obj);
  1269. static inline bool
  1270. i915_gem_object_pin_fence(struct drm_i915_gem_object *obj)
  1271. {
  1272. if (obj->fence_reg != I915_FENCE_REG_NONE) {
  1273. struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
  1274. dev_priv->fence_regs[obj->fence_reg].pin_count++;
  1275. return true;
  1276. } else
  1277. return false;
  1278. }
  1279. static inline void
  1280. i915_gem_object_unpin_fence(struct drm_i915_gem_object *obj)
  1281. {
  1282. if (obj->fence_reg != I915_FENCE_REG_NONE) {
  1283. struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
  1284. dev_priv->fence_regs[obj->fence_reg].pin_count--;
  1285. }
  1286. }
  1287. void i915_gem_retire_requests(struct drm_device *dev);
  1288. void i915_gem_retire_requests_ring(struct intel_ring_buffer *ring);
  1289. int __must_check i915_gem_check_wedge(struct drm_i915_private *dev_priv,
  1290. bool interruptible);
  1291. void i915_gem_reset(struct drm_device *dev);
  1292. void i915_gem_clflush_object(struct drm_i915_gem_object *obj);
  1293. int __must_check i915_gem_object_set_domain(struct drm_i915_gem_object *obj,
  1294. uint32_t read_domains,
  1295. uint32_t write_domain);
  1296. int __must_check i915_gem_object_finish_gpu(struct drm_i915_gem_object *obj);
  1297. int __must_check i915_gem_init(struct drm_device *dev);
  1298. int __must_check i915_gem_init_hw(struct drm_device *dev);
  1299. void i915_gem_l3_remap(struct drm_device *dev);
  1300. void i915_gem_init_swizzling(struct drm_device *dev);
  1301. void i915_gem_init_ppgtt(struct drm_device *dev);
  1302. void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
  1303. int __must_check i915_gpu_idle(struct drm_device *dev);
  1304. int __must_check i915_gem_idle(struct drm_device *dev);
  1305. int i915_add_request(struct intel_ring_buffer *ring,
  1306. struct drm_file *file,
  1307. u32 *seqno);
  1308. int __must_check i915_wait_seqno(struct intel_ring_buffer *ring,
  1309. uint32_t seqno);
  1310. int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
  1311. int __must_check
  1312. i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj,
  1313. bool write);
  1314. int __must_check
  1315. i915_gem_object_set_to_cpu_domain(struct drm_i915_gem_object *obj, bool write);
  1316. int __must_check
  1317. i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
  1318. u32 alignment,
  1319. struct intel_ring_buffer *pipelined);
  1320. int i915_gem_attach_phys_object(struct drm_device *dev,
  1321. struct drm_i915_gem_object *obj,
  1322. int id,
  1323. int align);
  1324. void i915_gem_detach_phys_object(struct drm_device *dev,
  1325. struct drm_i915_gem_object *obj);
  1326. void i915_gem_free_all_phys_object(struct drm_device *dev);
  1327. void i915_gem_release(struct drm_device *dev, struct drm_file *file);
  1328. uint32_t
  1329. i915_gem_get_unfenced_gtt_alignment(struct drm_device *dev,
  1330. uint32_t size,
  1331. int tiling_mode);
  1332. int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
  1333. enum i915_cache_level cache_level);
  1334. struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev,
  1335. struct dma_buf *dma_buf);
  1336. struct dma_buf *i915_gem_prime_export(struct drm_device *dev,
  1337. struct drm_gem_object *gem_obj, int flags);
  1338. /* i915_gem_context.c */
  1339. void i915_gem_context_init(struct drm_device *dev);
  1340. void i915_gem_context_fini(struct drm_device *dev);
  1341. void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
  1342. int i915_switch_context(struct intel_ring_buffer *ring,
  1343. struct drm_file *file, int to_id);
  1344. int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
  1345. struct drm_file *file);
  1346. int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
  1347. struct drm_file *file);
  1348. /* i915_gem_gtt.c */
  1349. int __must_check i915_gem_init_aliasing_ppgtt(struct drm_device *dev);
  1350. void i915_gem_cleanup_aliasing_ppgtt(struct drm_device *dev);
  1351. void i915_ppgtt_bind_object(struct i915_hw_ppgtt *ppgtt,
  1352. struct drm_i915_gem_object *obj,
  1353. enum i915_cache_level cache_level);
  1354. void i915_ppgtt_unbind_object(struct i915_hw_ppgtt *ppgtt,
  1355. struct drm_i915_gem_object *obj);
  1356. void i915_gem_restore_gtt_mappings(struct drm_device *dev);
  1357. int __must_check i915_gem_gtt_prepare_object(struct drm_i915_gem_object *obj);
  1358. void i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj,
  1359. enum i915_cache_level cache_level);
  1360. void i915_gem_gtt_unbind_object(struct drm_i915_gem_object *obj);
  1361. void i915_gem_gtt_finish_object(struct drm_i915_gem_object *obj);
  1362. void i915_gem_init_global_gtt(struct drm_device *dev,
  1363. unsigned long start,
  1364. unsigned long mappable_end,
  1365. unsigned long end);
  1366. int i915_gem_gtt_init(struct drm_device *dev);
  1367. void i915_gem_gtt_fini(struct drm_device *dev);
  1368. static inline void i915_gem_chipset_flush(struct drm_device *dev)
  1369. {
  1370. if (INTEL_INFO(dev)->gen < 6)
  1371. intel_gtt_chipset_flush();
  1372. }
  1373. /* i915_gem_evict.c */
  1374. int __must_check i915_gem_evict_something(struct drm_device *dev, int min_size,
  1375. unsigned alignment,
  1376. unsigned cache_level,
  1377. bool mappable,
  1378. bool nonblock);
  1379. int i915_gem_evict_everything(struct drm_device *dev);
  1380. /* i915_gem_stolen.c */
  1381. int i915_gem_init_stolen(struct drm_device *dev);
  1382. int i915_gem_stolen_setup_compression(struct drm_device *dev, int size);
  1383. void i915_gem_stolen_cleanup_compression(struct drm_device *dev);
  1384. void i915_gem_cleanup_stolen(struct drm_device *dev);
  1385. struct drm_i915_gem_object *
  1386. i915_gem_object_create_stolen(struct drm_device *dev, u32 size);
  1387. void i915_gem_object_release_stolen(struct drm_i915_gem_object *obj);
  1388. /* i915_gem_tiling.c */
  1389. void i915_gem_detect_bit_6_swizzle(struct drm_device *dev);
  1390. void i915_gem_object_do_bit_17_swizzle(struct drm_i915_gem_object *obj);
  1391. void i915_gem_object_save_bit_17_swizzle(struct drm_i915_gem_object *obj);
  1392. /* i915_gem_debug.c */
  1393. void i915_gem_dump_object(struct drm_i915_gem_object *obj, int len,
  1394. const char *where, uint32_t mark);
  1395. #if WATCH_LISTS
  1396. int i915_verify_lists(struct drm_device *dev);
  1397. #else
  1398. #define i915_verify_lists(dev) 0
  1399. #endif
  1400. void i915_gem_object_check_coherency(struct drm_i915_gem_object *obj,
  1401. int handle);
  1402. void i915_gem_dump_object(struct drm_i915_gem_object *obj, int len,
  1403. const char *where, uint32_t mark);
  1404. /* i915_debugfs.c */
  1405. int i915_debugfs_init(struct drm_minor *minor);
  1406. void i915_debugfs_cleanup(struct drm_minor *minor);
  1407. /* i915_suspend.c */
  1408. extern int i915_save_state(struct drm_device *dev);
  1409. extern int i915_restore_state(struct drm_device *dev);
  1410. /* i915_suspend.c */
  1411. extern int i915_save_state(struct drm_device *dev);
  1412. extern int i915_restore_state(struct drm_device *dev);
  1413. /* i915_sysfs.c */
  1414. void i915_setup_sysfs(struct drm_device *dev_priv);
  1415. void i915_teardown_sysfs(struct drm_device *dev_priv);
  1416. /* intel_i2c.c */
  1417. extern int intel_setup_gmbus(struct drm_device *dev);
  1418. extern void intel_teardown_gmbus(struct drm_device *dev);
  1419. extern inline bool intel_gmbus_is_port_valid(unsigned port)
  1420. {
  1421. return (port >= GMBUS_PORT_SSC && port <= GMBUS_PORT_DPD);
  1422. }
  1423. extern struct i2c_adapter *intel_gmbus_get_adapter(
  1424. struct drm_i915_private *dev_priv, unsigned port);
  1425. extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
  1426. extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
  1427. extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
  1428. {
  1429. return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
  1430. }
  1431. extern void intel_i2c_reset(struct drm_device *dev);
  1432. /* intel_opregion.c */
  1433. extern int intel_opregion_setup(struct drm_device *dev);
  1434. #ifdef CONFIG_ACPI
  1435. extern void intel_opregion_init(struct drm_device *dev);
  1436. extern void intel_opregion_fini(struct drm_device *dev);
  1437. extern void intel_opregion_asle_intr(struct drm_device *dev);
  1438. extern void intel_opregion_gse_intr(struct drm_device *dev);
  1439. extern void intel_opregion_enable_asle(struct drm_device *dev);
  1440. #else
  1441. static inline void intel_opregion_init(struct drm_device *dev) { return; }
  1442. static inline void intel_opregion_fini(struct drm_device *dev) { return; }
  1443. static inline void intel_opregion_asle_intr(struct drm_device *dev) { return; }
  1444. static inline void intel_opregion_gse_intr(struct drm_device *dev) { return; }
  1445. static inline void intel_opregion_enable_asle(struct drm_device *dev) { return; }
  1446. #endif
  1447. /* intel_acpi.c */
  1448. #ifdef CONFIG_ACPI
  1449. extern void intel_register_dsm_handler(void);
  1450. extern void intel_unregister_dsm_handler(void);
  1451. #else
  1452. static inline void intel_register_dsm_handler(void) { return; }
  1453. static inline void intel_unregister_dsm_handler(void) { return; }
  1454. #endif /* CONFIG_ACPI */
  1455. /* modesetting */
  1456. extern void intel_modeset_init_hw(struct drm_device *dev);
  1457. extern void intel_modeset_init(struct drm_device *dev);
  1458. extern void intel_modeset_gem_init(struct drm_device *dev);
  1459. extern void intel_modeset_cleanup(struct drm_device *dev);
  1460. extern int intel_modeset_vga_set_state(struct drm_device *dev, bool state);
  1461. extern void intel_modeset_setup_hw_state(struct drm_device *dev,
  1462. bool force_restore);
  1463. extern bool intel_fbc_enabled(struct drm_device *dev);
  1464. extern void intel_disable_fbc(struct drm_device *dev);
  1465. extern bool ironlake_set_drps(struct drm_device *dev, u8 val);
  1466. extern void ironlake_init_pch_refclk(struct drm_device *dev);
  1467. extern void gen6_set_rps(struct drm_device *dev, u8 val);
  1468. extern void intel_detect_pch(struct drm_device *dev);
  1469. extern int intel_trans_dp_port_sel(struct drm_crtc *crtc);
  1470. extern int intel_enable_rc6(const struct drm_device *dev);
  1471. extern bool i915_semaphore_is_enabled(struct drm_device *dev);
  1472. int i915_reg_read_ioctl(struct drm_device *dev, void *data,
  1473. struct drm_file *file);
  1474. /* overlay */
  1475. #ifdef CONFIG_DEBUG_FS
  1476. extern struct intel_overlay_error_state *intel_overlay_capture_error_state(struct drm_device *dev);
  1477. extern void intel_overlay_print_error_state(struct seq_file *m, struct intel_overlay_error_state *error);
  1478. extern struct intel_display_error_state *intel_display_capture_error_state(struct drm_device *dev);
  1479. extern void intel_display_print_error_state(struct seq_file *m,
  1480. struct drm_device *dev,
  1481. struct intel_display_error_state *error);
  1482. #endif
  1483. /* On SNB platform, before reading ring registers forcewake bit
  1484. * must be set to prevent GT core from power down and stale values being
  1485. * returned.
  1486. */
  1487. void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv);
  1488. void gen6_gt_force_wake_put(struct drm_i915_private *dev_priv);
  1489. int __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv);
  1490. int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u8 mbox, u32 *val);
  1491. int sandybridge_pcode_write(struct drm_i915_private *dev_priv, u8 mbox, u32 val);
  1492. #define __i915_read(x, y) \
  1493. u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg);
  1494. __i915_read(8, b)
  1495. __i915_read(16, w)
  1496. __i915_read(32, l)
  1497. __i915_read(64, q)
  1498. #undef __i915_read
  1499. #define __i915_write(x, y) \
  1500. void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val);
  1501. __i915_write(8, b)
  1502. __i915_write(16, w)
  1503. __i915_write(32, l)
  1504. __i915_write(64, q)
  1505. #undef __i915_write
  1506. #define I915_READ8(reg) i915_read8(dev_priv, (reg))
  1507. #define I915_WRITE8(reg, val) i915_write8(dev_priv, (reg), (val))
  1508. #define I915_READ16(reg) i915_read16(dev_priv, (reg))
  1509. #define I915_WRITE16(reg, val) i915_write16(dev_priv, (reg), (val))
  1510. #define I915_READ16_NOTRACE(reg) readw(dev_priv->regs + (reg))
  1511. #define I915_WRITE16_NOTRACE(reg, val) writew(val, dev_priv->regs + (reg))
  1512. #define I915_READ(reg) i915_read32(dev_priv, (reg))
  1513. #define I915_WRITE(reg, val) i915_write32(dev_priv, (reg), (val))
  1514. #define I915_READ_NOTRACE(reg) readl(dev_priv->regs + (reg))
  1515. #define I915_WRITE_NOTRACE(reg, val) writel(val, dev_priv->regs + (reg))
  1516. #define I915_WRITE64(reg, val) i915_write64(dev_priv, (reg), (val))
  1517. #define I915_READ64(reg) i915_read64(dev_priv, (reg))
  1518. #define POSTING_READ(reg) (void)I915_READ_NOTRACE(reg)
  1519. #define POSTING_READ16(reg) (void)I915_READ16_NOTRACE(reg)
  1520. #endif