i915_drv.h 42 KB

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