i915_drv.h 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142
  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. /* General customization:
  32. */
  33. #define DRIVER_AUTHOR "Tungsten Graphics, Inc."
  34. #define DRIVER_NAME "i915"
  35. #define DRIVER_DESC "Intel Graphics"
  36. #define DRIVER_DATE "20060119"
  37. /* Interface history:
  38. *
  39. * 1.1: Original.
  40. * 1.2: Add Power Management
  41. * 1.3: Add vblank support
  42. * 1.4: Fix cmdbuffer path, add heap destroy
  43. * 1.5: Add vblank pipe configuration
  44. * 1.6: - New ioctl for scheduling buffer swaps on vertical blank
  45. * - Support vertical blank on secondary display pipe
  46. */
  47. #define DRIVER_MAJOR 1
  48. #define DRIVER_MINOR 6
  49. #define DRIVER_PATCHLEVEL 0
  50. typedef struct _drm_i915_ring_buffer {
  51. int tail_mask;
  52. unsigned long Start;
  53. unsigned long End;
  54. unsigned long Size;
  55. u8 *virtual_start;
  56. int head;
  57. int tail;
  58. int space;
  59. drm_local_map_t map;
  60. } drm_i915_ring_buffer_t;
  61. struct mem_block {
  62. struct mem_block *next;
  63. struct mem_block *prev;
  64. int start;
  65. int size;
  66. struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
  67. };
  68. typedef struct _drm_i915_vbl_swap {
  69. struct list_head head;
  70. drm_drawable_t drw_id;
  71. unsigned int pipe;
  72. unsigned int sequence;
  73. } drm_i915_vbl_swap_t;
  74. typedef struct drm_i915_private {
  75. drm_local_map_t *sarea;
  76. drm_local_map_t *mmio_map;
  77. drm_i915_sarea_t *sarea_priv;
  78. drm_i915_ring_buffer_t ring;
  79. drm_dma_handle_t *status_page_dmah;
  80. void *hw_status_page;
  81. dma_addr_t dma_status_page;
  82. unsigned long counter;
  83. unsigned int status_gfx_addr;
  84. drm_local_map_t hws_map;
  85. unsigned int cpp;
  86. int back_offset;
  87. int front_offset;
  88. int current_page;
  89. int page_flipping;
  90. int use_mi_batchbuffer_start;
  91. wait_queue_head_t irq_queue;
  92. atomic_t irq_received;
  93. atomic_t irq_emitted;
  94. int tex_lru_log_granularity;
  95. int allow_batchbuffer;
  96. struct mem_block *agp_heap;
  97. unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
  98. int vblank_pipe;
  99. spinlock_t swaps_lock;
  100. drm_i915_vbl_swap_t vbl_swaps;
  101. unsigned int swaps_pending;
  102. /* Register state */
  103. u8 saveLBB;
  104. u32 saveDSPACNTR;
  105. u32 saveDSPBCNTR;
  106. u32 saveDSPARB;
  107. u32 savePIPEACONF;
  108. u32 savePIPEBCONF;
  109. u32 savePIPEASRC;
  110. u32 savePIPEBSRC;
  111. u32 saveFPA0;
  112. u32 saveFPA1;
  113. u32 saveDPLL_A;
  114. u32 saveDPLL_A_MD;
  115. u32 saveHTOTAL_A;
  116. u32 saveHBLANK_A;
  117. u32 saveHSYNC_A;
  118. u32 saveVTOTAL_A;
  119. u32 saveVBLANK_A;
  120. u32 saveVSYNC_A;
  121. u32 saveBCLRPAT_A;
  122. u32 savePIPEASTAT;
  123. u32 saveDSPASTRIDE;
  124. u32 saveDSPASIZE;
  125. u32 saveDSPAPOS;
  126. u32 saveDSPABASE;
  127. u32 saveDSPASURF;
  128. u32 saveDSPATILEOFF;
  129. u32 savePFIT_PGM_RATIOS;
  130. u32 saveBLC_PWM_CTL;
  131. u32 saveBLC_PWM_CTL2;
  132. u32 saveFPB0;
  133. u32 saveFPB1;
  134. u32 saveDPLL_B;
  135. u32 saveDPLL_B_MD;
  136. u32 saveHTOTAL_B;
  137. u32 saveHBLANK_B;
  138. u32 saveHSYNC_B;
  139. u32 saveVTOTAL_B;
  140. u32 saveVBLANK_B;
  141. u32 saveVSYNC_B;
  142. u32 saveBCLRPAT_B;
  143. u32 savePIPEBSTAT;
  144. u32 saveDSPBSTRIDE;
  145. u32 saveDSPBSIZE;
  146. u32 saveDSPBPOS;
  147. u32 saveDSPBBASE;
  148. u32 saveDSPBSURF;
  149. u32 saveDSPBTILEOFF;
  150. u32 saveVCLK_DIVISOR_VGA0;
  151. u32 saveVCLK_DIVISOR_VGA1;
  152. u32 saveVCLK_POST_DIV;
  153. u32 saveVGACNTRL;
  154. u32 saveADPA;
  155. u32 saveLVDS;
  156. u32 saveLVDSPP_ON;
  157. u32 saveLVDSPP_OFF;
  158. u32 saveDVOA;
  159. u32 saveDVOB;
  160. u32 saveDVOC;
  161. u32 savePP_ON;
  162. u32 savePP_OFF;
  163. u32 savePP_CONTROL;
  164. u32 savePP_CYCLE;
  165. u32 savePFIT_CONTROL;
  166. u32 save_palette_a[256];
  167. u32 save_palette_b[256];
  168. u32 saveFBC_CFB_BASE;
  169. u32 saveFBC_LL_BASE;
  170. u32 saveFBC_CONTROL;
  171. u32 saveFBC_CONTROL2;
  172. u32 saveIER;
  173. u32 saveIIR;
  174. u32 saveIMR;
  175. u32 saveCACHE_MODE_0;
  176. u32 saveD_STATE;
  177. u32 saveDSPCLK_GATE_D;
  178. u32 saveMI_ARB_STATE;
  179. u32 saveSWF0[16];
  180. u32 saveSWF1[16];
  181. u32 saveSWF2[3];
  182. u8 saveMSR;
  183. u8 saveSR[8];
  184. u8 saveGR[25];
  185. u8 saveAR_INDEX;
  186. u8 saveAR[21];
  187. u8 saveDACMASK;
  188. u8 saveDACDATA[256*3]; /* 256 3-byte colors */
  189. u8 saveCR[37];
  190. } drm_i915_private_t;
  191. extern struct drm_ioctl_desc i915_ioctls[];
  192. extern int i915_max_ioctl;
  193. /* i915_dma.c */
  194. extern void i915_kernel_lost_context(struct drm_device * dev);
  195. extern int i915_driver_load(struct drm_device *, unsigned long flags);
  196. extern int i915_driver_unload(struct drm_device *);
  197. extern void i915_driver_lastclose(struct drm_device * dev);
  198. extern void i915_driver_preclose(struct drm_device *dev,
  199. struct drm_file *file_priv);
  200. extern int i915_driver_device_is_agp(struct drm_device * dev);
  201. extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
  202. unsigned long arg);
  203. /* i915_irq.c */
  204. extern int i915_irq_emit(struct drm_device *dev, void *data,
  205. struct drm_file *file_priv);
  206. extern int i915_irq_wait(struct drm_device *dev, void *data,
  207. struct drm_file *file_priv);
  208. extern int i915_driver_vblank_wait(struct drm_device *dev, unsigned int *sequence);
  209. extern int i915_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence);
  210. extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
  211. extern void i915_driver_irq_preinstall(struct drm_device * dev);
  212. extern void i915_driver_irq_postinstall(struct drm_device * dev);
  213. extern void i915_driver_irq_uninstall(struct drm_device * dev);
  214. extern int i915_vblank_pipe_set(struct drm_device *dev, void *data,
  215. struct drm_file *file_priv);
  216. extern int i915_vblank_pipe_get(struct drm_device *dev, void *data,
  217. struct drm_file *file_priv);
  218. extern int i915_vblank_swap(struct drm_device *dev, void *data,
  219. struct drm_file *file_priv);
  220. /* i915_mem.c */
  221. extern int i915_mem_alloc(struct drm_device *dev, void *data,
  222. struct drm_file *file_priv);
  223. extern int i915_mem_free(struct drm_device *dev, void *data,
  224. struct drm_file *file_priv);
  225. extern int i915_mem_init_heap(struct drm_device *dev, void *data,
  226. struct drm_file *file_priv);
  227. extern int i915_mem_destroy_heap(struct drm_device *dev, void *data,
  228. struct drm_file *file_priv);
  229. extern void i915_mem_takedown(struct mem_block **heap);
  230. extern void i915_mem_release(struct drm_device * dev,
  231. struct drm_file *file_priv, struct mem_block *heap);
  232. #define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg))
  233. #define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
  234. #define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, (reg))
  235. #define I915_WRITE16(reg,val) DRM_WRITE16(dev_priv->mmio_map, (reg), (val))
  236. #define I915_VERBOSE 0
  237. #define RING_LOCALS unsigned int outring, ringmask, outcount; \
  238. volatile char *virt;
  239. #define BEGIN_LP_RING(n) do { \
  240. if (I915_VERBOSE) \
  241. DRM_DEBUG("BEGIN_LP_RING(%d)\n", (n)); \
  242. if (dev_priv->ring.space < (n)*4) \
  243. i915_wait_ring(dev, (n)*4, __func__); \
  244. outcount = 0; \
  245. outring = dev_priv->ring.tail; \
  246. ringmask = dev_priv->ring.tail_mask; \
  247. virt = dev_priv->ring.virtual_start; \
  248. } while (0)
  249. #define OUT_RING(n) do { \
  250. if (I915_VERBOSE) DRM_DEBUG(" OUT_RING %x\n", (int)(n)); \
  251. *(volatile unsigned int *)(virt + outring) = (n); \
  252. outcount++; \
  253. outring += 4; \
  254. outring &= ringmask; \
  255. } while (0)
  256. #define ADVANCE_LP_RING() do { \
  257. if (I915_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING %x\n", outring); \
  258. dev_priv->ring.tail = outring; \
  259. dev_priv->ring.space -= outcount * 4; \
  260. I915_WRITE(LP_RING + RING_TAIL, outring); \
  261. } while(0)
  262. extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
  263. /* Extended config space */
  264. #define LBB 0xf4
  265. /* VGA stuff */
  266. #define VGA_ST01_MDA 0x3ba
  267. #define VGA_ST01_CGA 0x3da
  268. #define VGA_MSR_WRITE 0x3c2
  269. #define VGA_MSR_READ 0x3cc
  270. #define VGA_MSR_MEM_EN (1<<1)
  271. #define VGA_MSR_CGA_MODE (1<<0)
  272. #define VGA_SR_INDEX 0x3c4
  273. #define VGA_SR_DATA 0x3c5
  274. #define VGA_AR_INDEX 0x3c0
  275. #define VGA_AR_VID_EN (1<<5)
  276. #define VGA_AR_DATA_WRITE 0x3c0
  277. #define VGA_AR_DATA_READ 0x3c1
  278. #define VGA_GR_INDEX 0x3ce
  279. #define VGA_GR_DATA 0x3cf
  280. /* GR05 */
  281. #define VGA_GR_MEM_READ_MODE_SHIFT 3
  282. #define VGA_GR_MEM_READ_MODE_PLANE 1
  283. /* GR06 */
  284. #define VGA_GR_MEM_MODE_MASK 0xc
  285. #define VGA_GR_MEM_MODE_SHIFT 2
  286. #define VGA_GR_MEM_A0000_AFFFF 0
  287. #define VGA_GR_MEM_A0000_BFFFF 1
  288. #define VGA_GR_MEM_B0000_B7FFF 2
  289. #define VGA_GR_MEM_B0000_BFFFF 3
  290. #define VGA_DACMASK 0x3c6
  291. #define VGA_DACRX 0x3c7
  292. #define VGA_DACWX 0x3c8
  293. #define VGA_DACDATA 0x3c9
  294. #define VGA_CR_INDEX_MDA 0x3b4
  295. #define VGA_CR_DATA_MDA 0x3b5
  296. #define VGA_CR_INDEX_CGA 0x3d4
  297. #define VGA_CR_DATA_CGA 0x3d5
  298. #define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
  299. #define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23))
  300. #define CMD_REPORT_HEAD (7<<23)
  301. #define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1)
  302. #define CMD_OP_BATCH_BUFFER ((0x0<<29)|(0x30<<23)|0x1)
  303. #define INST_PARSER_CLIENT 0x00000000
  304. #define INST_OP_FLUSH 0x02000000
  305. #define INST_FLUSH_MAP_CACHE 0x00000001
  306. #define BB1_START_ADDR_MASK (~0x7)
  307. #define BB1_PROTECTED (1<<0)
  308. #define BB1_UNPROTECTED (0<<0)
  309. #define BB2_END_ADDR_MASK (~0x7)
  310. /* Framebuffer compression */
  311. #define FBC_CFB_BASE 0x03200 /* 4k page aligned */
  312. #define FBC_LL_BASE 0x03204 /* 4k page aligned */
  313. #define FBC_CONTROL 0x03208
  314. #define FBC_CTL_EN (1<<31)
  315. #define FBC_CTL_PERIODIC (1<<30)
  316. #define FBC_CTL_INTERVAL_SHIFT (16)
  317. #define FBC_CTL_UNCOMPRESSIBLE (1<<14)
  318. #define FBC_CTL_STRIDE_SHIFT (5)
  319. #define FBC_CTL_FENCENO (1<<0)
  320. #define FBC_COMMAND 0x0320c
  321. #define FBC_CMD_COMPRESS (1<<0)
  322. #define FBC_STATUS 0x03210
  323. #define FBC_STAT_COMPRESSING (1<<31)
  324. #define FBC_STAT_COMPRESSED (1<<30)
  325. #define FBC_STAT_MODIFIED (1<<29)
  326. #define FBC_STAT_CURRENT_LINE (1<<0)
  327. #define FBC_CONTROL2 0x03214
  328. #define FBC_CTL_FENCE_DBL (0<<4)
  329. #define FBC_CTL_IDLE_IMM (0<<2)
  330. #define FBC_CTL_IDLE_FULL (1<<2)
  331. #define FBC_CTL_IDLE_LINE (2<<2)
  332. #define FBC_CTL_IDLE_DEBUG (3<<2)
  333. #define FBC_CTL_CPU_FENCE (1<<1)
  334. #define FBC_CTL_PLANEA (0<<0)
  335. #define FBC_CTL_PLANEB (1<<0)
  336. #define FBC_FENCE_OFF 0x0321b
  337. #define FBC_LL_SIZE (1536)
  338. #define FBC_LL_PAD (32)
  339. /* Interrupt bits:
  340. */
  341. #define USER_INT_FLAG (1<<1)
  342. #define VSYNC_PIPEB_FLAG (1<<5)
  343. #define VSYNC_PIPEA_FLAG (1<<7)
  344. #define HWB_OOM_FLAG (1<<13) /* binner out of memory */
  345. #define I915REG_HWSTAM 0x02098
  346. #define I915REG_INT_IDENTITY_R 0x020a4
  347. #define I915REG_INT_MASK_R 0x020a8
  348. #define I915REG_INT_ENABLE_R 0x020a0
  349. #define I915REG_PIPEASTAT 0x70024
  350. #define I915REG_PIPEBSTAT 0x71024
  351. #define I915_VBLANK_INTERRUPT_ENABLE (1UL<<17)
  352. #define I915_VBLANK_CLEAR (1UL<<1)
  353. #define SRX_INDEX 0x3c4
  354. #define SRX_DATA 0x3c5
  355. #define SR01 1
  356. #define SR01_SCREEN_OFF (1<<5)
  357. #define PPCR 0x61204
  358. #define PPCR_ON (1<<0)
  359. #define DVOB 0x61140
  360. #define DVOB_ON (1<<31)
  361. #define DVOC 0x61160
  362. #define DVOC_ON (1<<31)
  363. #define LVDS 0x61180
  364. #define LVDS_ON (1<<31)
  365. #define ADPA 0x61100
  366. #define ADPA_DPMS_MASK (~(3<<10))
  367. #define ADPA_DPMS_ON (0<<10)
  368. #define ADPA_DPMS_SUSPEND (1<<10)
  369. #define ADPA_DPMS_STANDBY (2<<10)
  370. #define ADPA_DPMS_OFF (3<<10)
  371. #define NOPID 0x2094
  372. #define LP_RING 0x2030
  373. #define HP_RING 0x2040
  374. /* The binner has its own ring buffer:
  375. */
  376. #define HWB_RING 0x2400
  377. #define RING_TAIL 0x00
  378. #define TAIL_ADDR 0x001FFFF8
  379. #define RING_HEAD 0x04
  380. #define HEAD_WRAP_COUNT 0xFFE00000
  381. #define HEAD_WRAP_ONE 0x00200000
  382. #define HEAD_ADDR 0x001FFFFC
  383. #define RING_START 0x08
  384. #define START_ADDR 0x0xFFFFF000
  385. #define RING_LEN 0x0C
  386. #define RING_NR_PAGES 0x001FF000
  387. #define RING_REPORT_MASK 0x00000006
  388. #define RING_REPORT_64K 0x00000002
  389. #define RING_REPORT_128K 0x00000004
  390. #define RING_NO_REPORT 0x00000000
  391. #define RING_VALID_MASK 0x00000001
  392. #define RING_VALID 0x00000001
  393. #define RING_INVALID 0x00000000
  394. /* Instruction parser error reg:
  395. */
  396. #define IPEIR 0x2088
  397. /* Scratch pad debug 0 reg:
  398. */
  399. #define SCPD0 0x209c
  400. /* Error status reg:
  401. */
  402. #define ESR 0x20b8
  403. /* Secondary DMA fetch address debug reg:
  404. */
  405. #define DMA_FADD_S 0x20d4
  406. /* Memory Interface Arbitration State
  407. */
  408. #define MI_ARB_STATE 0x20e4
  409. /* Cache mode 0 reg.
  410. * - Manipulating render cache behaviour is central
  411. * to the concept of zone rendering, tuning this reg can help avoid
  412. * unnecessary render cache reads and even writes (for z/stencil)
  413. * at beginning and end of scene.
  414. *
  415. * - To change a bit, write to this reg with a mask bit set and the
  416. * bit of interest either set or cleared. EG: (BIT<<16) | BIT to set.
  417. */
  418. #define Cache_Mode_0 0x2120
  419. #define CACHE_MODE_0 0x2120
  420. #define CM0_MASK_SHIFT 16
  421. #define CM0_IZ_OPT_DISABLE (1<<6)
  422. #define CM0_ZR_OPT_DISABLE (1<<5)
  423. #define CM0_DEPTH_EVICT_DISABLE (1<<4)
  424. #define CM0_COLOR_EVICT_DISABLE (1<<3)
  425. #define CM0_DEPTH_WRITE_DISABLE (1<<1)
  426. #define CM0_RC_OP_FLUSH_DISABLE (1<<0)
  427. /* Graphics flush control. A CPU write flushes the GWB of all writes.
  428. * The data is discarded.
  429. */
  430. #define GFX_FLSH_CNTL 0x2170
  431. /* Binner control. Defines the location of the bin pointer list:
  432. */
  433. #define BINCTL 0x2420
  434. #define BC_MASK (1 << 9)
  435. /* Binned scene info.
  436. */
  437. #define BINSCENE 0x2428
  438. #define BS_OP_LOAD (1 << 8)
  439. #define BS_MASK (1 << 22)
  440. /* Bin command parser debug reg:
  441. */
  442. #define BCPD 0x2480
  443. /* Bin memory control debug reg:
  444. */
  445. #define BMCD 0x2484
  446. /* Bin data cache debug reg:
  447. */
  448. #define BDCD 0x2488
  449. /* Binner pointer cache debug reg:
  450. */
  451. #define BPCD 0x248c
  452. /* Binner scratch pad debug reg:
  453. */
  454. #define BINSKPD 0x24f0
  455. /* HWB scratch pad debug reg:
  456. */
  457. #define HWBSKPD 0x24f4
  458. /* Binner memory pool reg:
  459. */
  460. #define BMP_BUFFER 0x2430
  461. #define BMP_PAGE_SIZE_4K (0 << 10)
  462. #define BMP_BUFFER_SIZE_SHIFT 1
  463. #define BMP_ENABLE (1 << 0)
  464. /* Get/put memory from the binner memory pool:
  465. */
  466. #define BMP_GET 0x2438
  467. #define BMP_PUT 0x2440
  468. #define BMP_OFFSET_SHIFT 5
  469. /* 3D state packets:
  470. */
  471. #define GFX_OP_RASTER_RULES ((0x3<<29)|(0x7<<24))
  472. #define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19))
  473. #define SC_UPDATE_SCISSOR (0x1<<1)
  474. #define SC_ENABLE_MASK (0x1<<0)
  475. #define SC_ENABLE (0x1<<0)
  476. #define GFX_OP_LOAD_INDIRECT ((0x3<<29)|(0x1d<<24)|(0x7<<16))
  477. #define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
  478. #define SCI_YMIN_MASK (0xffff<<16)
  479. #define SCI_XMIN_MASK (0xffff<<0)
  480. #define SCI_YMAX_MASK (0xffff<<16)
  481. #define SCI_XMAX_MASK (0xffff<<0)
  482. #define GFX_OP_SCISSOR_ENABLE ((0x3<<29)|(0x1c<<24)|(0x10<<19))
  483. #define GFX_OP_SCISSOR_RECT ((0x3<<29)|(0x1d<<24)|(0x81<<16)|1)
  484. #define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
  485. #define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
  486. #define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x4)
  487. #define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
  488. #define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
  489. #define GFX_OP_DRAWRECT_INFO_I965 ((0x7900<<16)|0x2)
  490. #define SRC_COPY_BLT_CMD ((2<<29)|(0x43<<22)|4)
  491. #define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6)
  492. #define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21)
  493. #define XY_SRC_COPY_BLT_WRITE_RGB (1<<20)
  494. #define XY_SRC_COPY_BLT_SRC_TILED (1<<15)
  495. #define XY_SRC_COPY_BLT_DST_TILED (1<<11)
  496. #define MI_BATCH_BUFFER ((0x30<<23)|1)
  497. #define MI_BATCH_BUFFER_START (0x31<<23)
  498. #define MI_BATCH_BUFFER_END (0xA<<23)
  499. #define MI_BATCH_NON_SECURE (1)
  500. #define MI_BATCH_NON_SECURE_I965 (1<<8)
  501. #define MI_WAIT_FOR_EVENT ((0x3<<23))
  502. #define MI_WAIT_FOR_PLANE_B_FLIP (1<<6)
  503. #define MI_WAIT_FOR_PLANE_A_FLIP (1<<2)
  504. #define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1)
  505. #define MI_LOAD_SCAN_LINES_INCL ((0x12<<23))
  506. #define CMD_OP_DISPLAYBUFFER_INFO ((0x0<<29)|(0x14<<23)|2)
  507. #define ASYNC_FLIP (1<<22)
  508. #define DISPLAY_PLANE_A (0<<20)
  509. #define DISPLAY_PLANE_B (1<<20)
  510. /* Display regs */
  511. #define DSPACNTR 0x70180
  512. #define DSPBCNTR 0x71180
  513. #define DISPPLANE_SEL_PIPE_MASK (1<<24)
  514. /* Define the region of interest for the binner:
  515. */
  516. #define CMD_OP_BIN_CONTROL ((0x3<<29)|(0x1d<<24)|(0x84<<16)|4)
  517. #define CMD_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1)
  518. #define CMD_MI_FLUSH (0x04 << 23)
  519. #define MI_NO_WRITE_FLUSH (1 << 2)
  520. #define MI_READ_FLUSH (1 << 0)
  521. #define MI_EXE_FLUSH (1 << 1)
  522. #define MI_END_SCENE (1 << 4) /* flush binner and incr scene count */
  523. #define MI_SCENE_COUNT (1 << 3) /* just increment scene count */
  524. #define BREADCRUMB_BITS 31
  525. #define BREADCRUMB_MASK ((1U << BREADCRUMB_BITS) - 1)
  526. #define READ_BREADCRUMB(dev_priv) (((volatile u32*)(dev_priv->hw_status_page))[5])
  527. #define READ_HWSP(dev_priv, reg) (((volatile u32*)(dev_priv->hw_status_page))[reg])
  528. #define BLC_PWM_CTL 0x61254
  529. #define BACKLIGHT_MODULATION_FREQ_SHIFT (17)
  530. #define BLC_PWM_CTL2 0x61250
  531. /**
  532. * This is the most significant 15 bits of the number of backlight cycles in a
  533. * complete cycle of the modulated backlight control.
  534. *
  535. * The actual value is this field multiplied by two.
  536. */
  537. #define BACKLIGHT_MODULATION_FREQ_MASK (0x7fff << 17)
  538. #define BLM_LEGACY_MODE (1 << 16)
  539. /**
  540. * This is the number of cycles out of the backlight modulation cycle for which
  541. * the backlight is on.
  542. *
  543. * This field must be no greater than the number of cycles in the complete
  544. * backlight modulation cycle.
  545. */
  546. #define BACKLIGHT_DUTY_CYCLE_SHIFT (0)
  547. #define BACKLIGHT_DUTY_CYCLE_MASK (0xffff)
  548. #define I915_GCFGC 0xf0
  549. #define I915_LOW_FREQUENCY_ENABLE (1 << 7)
  550. #define I915_DISPLAY_CLOCK_190_200_MHZ (0 << 4)
  551. #define I915_DISPLAY_CLOCK_333_MHZ (4 << 4)
  552. #define I915_DISPLAY_CLOCK_MASK (7 << 4)
  553. #define I855_HPLLCC 0xc0
  554. #define I855_CLOCK_CONTROL_MASK (3 << 0)
  555. #define I855_CLOCK_133_200 (0 << 0)
  556. #define I855_CLOCK_100_200 (1 << 0)
  557. #define I855_CLOCK_100_133 (2 << 0)
  558. #define I855_CLOCK_166_250 (3 << 0)
  559. /* p317, 319
  560. */
  561. #define VCLK2_VCO_M 0x6008 /* treat as 16 bit? (includes msbs) */
  562. #define VCLK2_VCO_N 0x600a
  563. #define VCLK2_VCO_DIV_SEL 0x6012
  564. #define VCLK_DIVISOR_VGA0 0x6000
  565. #define VCLK_DIVISOR_VGA1 0x6004
  566. #define VCLK_POST_DIV 0x6010
  567. /** Selects a post divisor of 4 instead of 2. */
  568. # define VGA1_PD_P2_DIV_4 (1 << 15)
  569. /** Overrides the p2 post divisor field */
  570. # define VGA1_PD_P1_DIV_2 (1 << 13)
  571. # define VGA1_PD_P1_SHIFT 8
  572. /** P1 value is 2 greater than this field */
  573. # define VGA1_PD_P1_MASK (0x1f << 8)
  574. /** Selects a post divisor of 4 instead of 2. */
  575. # define VGA0_PD_P2_DIV_4 (1 << 7)
  576. /** Overrides the p2 post divisor field */
  577. # define VGA0_PD_P1_DIV_2 (1 << 5)
  578. # define VGA0_PD_P1_SHIFT 0
  579. /** P1 value is 2 greater than this field */
  580. # define VGA0_PD_P1_MASK (0x1f << 0)
  581. /* PCI D state control register */
  582. #define D_STATE 0x6104
  583. #define DSPCLK_GATE_D 0x6200
  584. /* I830 CRTC registers */
  585. #define HTOTAL_A 0x60000
  586. #define HBLANK_A 0x60004
  587. #define HSYNC_A 0x60008
  588. #define VTOTAL_A 0x6000c
  589. #define VBLANK_A 0x60010
  590. #define VSYNC_A 0x60014
  591. #define PIPEASRC 0x6001c
  592. #define BCLRPAT_A 0x60020
  593. #define VSYNCSHIFT_A 0x60028
  594. #define HTOTAL_B 0x61000
  595. #define HBLANK_B 0x61004
  596. #define HSYNC_B 0x61008
  597. #define VTOTAL_B 0x6100c
  598. #define VBLANK_B 0x61010
  599. #define VSYNC_B 0x61014
  600. #define PIPEBSRC 0x6101c
  601. #define BCLRPAT_B 0x61020
  602. #define VSYNCSHIFT_B 0x61028
  603. #define PP_STATUS 0x61200
  604. # define PP_ON (1 << 31)
  605. /**
  606. * Indicates that all dependencies of the panel are on:
  607. *
  608. * - PLL enabled
  609. * - pipe enabled
  610. * - LVDS/DVOB/DVOC on
  611. */
  612. # define PP_READY (1 << 30)
  613. # define PP_SEQUENCE_NONE (0 << 28)
  614. # define PP_SEQUENCE_ON (1 << 28)
  615. # define PP_SEQUENCE_OFF (2 << 28)
  616. # define PP_SEQUENCE_MASK 0x30000000
  617. #define PP_CONTROL 0x61204
  618. # define POWER_TARGET_ON (1 << 0)
  619. #define LVDSPP_ON 0x61208
  620. #define LVDSPP_OFF 0x6120c
  621. #define PP_CYCLE 0x61210
  622. #define PFIT_CONTROL 0x61230
  623. # define PFIT_ENABLE (1 << 31)
  624. # define PFIT_PIPE_MASK (3 << 29)
  625. # define PFIT_PIPE_SHIFT 29
  626. # define VERT_INTERP_DISABLE (0 << 10)
  627. # define VERT_INTERP_BILINEAR (1 << 10)
  628. # define VERT_INTERP_MASK (3 << 10)
  629. # define VERT_AUTO_SCALE (1 << 9)
  630. # define HORIZ_INTERP_DISABLE (0 << 6)
  631. # define HORIZ_INTERP_BILINEAR (1 << 6)
  632. # define HORIZ_INTERP_MASK (3 << 6)
  633. # define HORIZ_AUTO_SCALE (1 << 5)
  634. # define PANEL_8TO6_DITHER_ENABLE (1 << 3)
  635. #define PFIT_PGM_RATIOS 0x61234
  636. # define PFIT_VERT_SCALE_MASK 0xfff00000
  637. # define PFIT_HORIZ_SCALE_MASK 0x0000fff0
  638. #define PFIT_AUTO_RATIOS 0x61238
  639. #define DPLL_A 0x06014
  640. #define DPLL_B 0x06018
  641. # define DPLL_VCO_ENABLE (1 << 31)
  642. # define DPLL_DVO_HIGH_SPEED (1 << 30)
  643. # define DPLL_SYNCLOCK_ENABLE (1 << 29)
  644. # define DPLL_VGA_MODE_DIS (1 << 28)
  645. # define DPLLB_MODE_DAC_SERIAL (1 << 26) /* i915 */
  646. # define DPLLB_MODE_LVDS (2 << 26) /* i915 */
  647. # define DPLL_MODE_MASK (3 << 26)
  648. # define DPLL_DAC_SERIAL_P2_CLOCK_DIV_10 (0 << 24) /* i915 */
  649. # define DPLL_DAC_SERIAL_P2_CLOCK_DIV_5 (1 << 24) /* i915 */
  650. # define DPLLB_LVDS_P2_CLOCK_DIV_14 (0 << 24) /* i915 */
  651. # define DPLLB_LVDS_P2_CLOCK_DIV_7 (1 << 24) /* i915 */
  652. # define DPLL_P2_CLOCK_DIV_MASK 0x03000000 /* i915 */
  653. # define DPLL_FPA01_P1_POST_DIV_MASK 0x00ff0000 /* i915 */
  654. /**
  655. * The i830 generation, in DAC/serial mode, defines p1 as two plus this
  656. * bitfield, or just 2 if PLL_P1_DIVIDE_BY_TWO is set.
  657. */
  658. # define DPLL_FPA01_P1_POST_DIV_MASK_I830 0x001f0000
  659. /**
  660. * The i830 generation, in LVDS mode, defines P1 as the bit number set within
  661. * this field (only one bit may be set).
  662. */
  663. # define DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS 0x003f0000
  664. # define DPLL_FPA01_P1_POST_DIV_SHIFT 16
  665. # define PLL_P2_DIVIDE_BY_4 (1 << 23) /* i830, required in DVO non-gang */
  666. # define PLL_P1_DIVIDE_BY_TWO (1 << 21) /* i830 */
  667. # define PLL_REF_INPUT_DREFCLK (0 << 13)
  668. # define PLL_REF_INPUT_TVCLKINA (1 << 13) /* i830 */
  669. # define PLL_REF_INPUT_TVCLKINBC (2 << 13) /* SDVO TVCLKIN */
  670. # define PLLB_REF_INPUT_SPREADSPECTRUMIN (3 << 13)
  671. # define PLL_REF_INPUT_MASK (3 << 13)
  672. # define PLL_LOAD_PULSE_PHASE_SHIFT 9
  673. /*
  674. * Parallel to Serial Load Pulse phase selection.
  675. * Selects the phase for the 10X DPLL clock for the PCIe
  676. * digital display port. The range is 4 to 13; 10 or more
  677. * is just a flip delay. The default is 6
  678. */
  679. # define PLL_LOAD_PULSE_PHASE_MASK (0xf << PLL_LOAD_PULSE_PHASE_SHIFT)
  680. # define DISPLAY_RATE_SELECT_FPA1 (1 << 8)
  681. /**
  682. * SDVO multiplier for 945G/GM. Not used on 965.
  683. *
  684. * \sa DPLL_MD_UDI_MULTIPLIER_MASK
  685. */
  686. # define SDVO_MULTIPLIER_MASK 0x000000ff
  687. # define SDVO_MULTIPLIER_SHIFT_HIRES 4
  688. # define SDVO_MULTIPLIER_SHIFT_VGA 0
  689. /** @defgroup DPLL_MD
  690. * @{
  691. */
  692. /** Pipe A SDVO/UDI clock multiplier/divider register for G965. */
  693. #define DPLL_A_MD 0x0601c
  694. /** Pipe B SDVO/UDI clock multiplier/divider register for G965. */
  695. #define DPLL_B_MD 0x06020
  696. /**
  697. * UDI pixel divider, controlling how many pixels are stuffed into a packet.
  698. *
  699. * Value is pixels minus 1. Must be set to 1 pixel for SDVO.
  700. */
  701. # define DPLL_MD_UDI_DIVIDER_MASK 0x3f000000
  702. # define DPLL_MD_UDI_DIVIDER_SHIFT 24
  703. /** UDI pixel divider for VGA, same as DPLL_MD_UDI_DIVIDER_MASK. */
  704. # define DPLL_MD_VGA_UDI_DIVIDER_MASK 0x003f0000
  705. # define DPLL_MD_VGA_UDI_DIVIDER_SHIFT 16
  706. /**
  707. * SDVO/UDI pixel multiplier.
  708. *
  709. * SDVO requires that the bus clock rate be between 1 and 2 Ghz, and the bus
  710. * clock rate is 10 times the DPLL clock. At low resolution/refresh rate
  711. * modes, the bus rate would be below the limits, so SDVO allows for stuffing
  712. * dummy bytes in the datastream at an increased clock rate, with both sides of
  713. * the link knowing how many bytes are fill.
  714. *
  715. * So, for a mode with a dotclock of 65Mhz, we would want to double the clock
  716. * rate to 130Mhz to get a bus rate of 1.30Ghz. The DPLL clock rate would be
  717. * set to 130Mhz, and the SDVO multiplier set to 2x in this register and
  718. * through an SDVO command.
  719. *
  720. * This register field has values of multiplication factor minus 1, with
  721. * a maximum multiplier of 5 for SDVO.
  722. */
  723. # define DPLL_MD_UDI_MULTIPLIER_MASK 0x00003f00
  724. # define DPLL_MD_UDI_MULTIPLIER_SHIFT 8
  725. /** SDVO/UDI pixel multiplier for VGA, same as DPLL_MD_UDI_MULTIPLIER_MASK.
  726. * This best be set to the default value (3) or the CRT won't work. No,
  727. * I don't entirely understand what this does...
  728. */
  729. # define DPLL_MD_VGA_UDI_MULTIPLIER_MASK 0x0000003f
  730. # define DPLL_MD_VGA_UDI_MULTIPLIER_SHIFT 0
  731. /** @} */
  732. #define DPLL_TEST 0x606c
  733. # define DPLLB_TEST_SDVO_DIV_1 (0 << 22)
  734. # define DPLLB_TEST_SDVO_DIV_2 (1 << 22)
  735. # define DPLLB_TEST_SDVO_DIV_4 (2 << 22)
  736. # define DPLLB_TEST_SDVO_DIV_MASK (3 << 22)
  737. # define DPLLB_TEST_N_BYPASS (1 << 19)
  738. # define DPLLB_TEST_M_BYPASS (1 << 18)
  739. # define DPLLB_INPUT_BUFFER_ENABLE (1 << 16)
  740. # define DPLLA_TEST_N_BYPASS (1 << 3)
  741. # define DPLLA_TEST_M_BYPASS (1 << 2)
  742. # define DPLLA_INPUT_BUFFER_ENABLE (1 << 0)
  743. #define ADPA 0x61100
  744. #define ADPA_DAC_ENABLE (1<<31)
  745. #define ADPA_DAC_DISABLE 0
  746. #define ADPA_PIPE_SELECT_MASK (1<<30)
  747. #define ADPA_PIPE_A_SELECT 0
  748. #define ADPA_PIPE_B_SELECT (1<<30)
  749. #define ADPA_USE_VGA_HVPOLARITY (1<<15)
  750. #define ADPA_SETS_HVPOLARITY 0
  751. #define ADPA_VSYNC_CNTL_DISABLE (1<<11)
  752. #define ADPA_VSYNC_CNTL_ENABLE 0
  753. #define ADPA_HSYNC_CNTL_DISABLE (1<<10)
  754. #define ADPA_HSYNC_CNTL_ENABLE 0
  755. #define ADPA_VSYNC_ACTIVE_HIGH (1<<4)
  756. #define ADPA_VSYNC_ACTIVE_LOW 0
  757. #define ADPA_HSYNC_ACTIVE_HIGH (1<<3)
  758. #define ADPA_HSYNC_ACTIVE_LOW 0
  759. #define FPA0 0x06040
  760. #define FPA1 0x06044
  761. #define FPB0 0x06048
  762. #define FPB1 0x0604c
  763. # define FP_N_DIV_MASK 0x003f0000
  764. # define FP_N_DIV_SHIFT 16
  765. # define FP_M1_DIV_MASK 0x00003f00
  766. # define FP_M1_DIV_SHIFT 8
  767. # define FP_M2_DIV_MASK 0x0000003f
  768. # define FP_M2_DIV_SHIFT 0
  769. #define PORT_HOTPLUG_EN 0x61110
  770. # define SDVOB_HOTPLUG_INT_EN (1 << 26)
  771. # define SDVOC_HOTPLUG_INT_EN (1 << 25)
  772. # define TV_HOTPLUG_INT_EN (1 << 18)
  773. # define CRT_HOTPLUG_INT_EN (1 << 9)
  774. # define CRT_HOTPLUG_FORCE_DETECT (1 << 3)
  775. #define PORT_HOTPLUG_STAT 0x61114
  776. # define CRT_HOTPLUG_INT_STATUS (1 << 11)
  777. # define TV_HOTPLUG_INT_STATUS (1 << 10)
  778. # define CRT_HOTPLUG_MONITOR_MASK (3 << 8)
  779. # define CRT_HOTPLUG_MONITOR_COLOR (3 << 8)
  780. # define CRT_HOTPLUG_MONITOR_MONO (2 << 8)
  781. # define CRT_HOTPLUG_MONITOR_NONE (0 << 8)
  782. # define SDVOC_HOTPLUG_INT_STATUS (1 << 7)
  783. # define SDVOB_HOTPLUG_INT_STATUS (1 << 6)
  784. #define SDVOB 0x61140
  785. #define SDVOC 0x61160
  786. #define SDVO_ENABLE (1 << 31)
  787. #define SDVO_PIPE_B_SELECT (1 << 30)
  788. #define SDVO_STALL_SELECT (1 << 29)
  789. #define SDVO_INTERRUPT_ENABLE (1 << 26)
  790. /**
  791. * 915G/GM SDVO pixel multiplier.
  792. *
  793. * Programmed value is multiplier - 1, up to 5x.
  794. *
  795. * \sa DPLL_MD_UDI_MULTIPLIER_MASK
  796. */
  797. #define SDVO_PORT_MULTIPLY_MASK (7 << 23)
  798. #define SDVO_PORT_MULTIPLY_SHIFT 23
  799. #define SDVO_PHASE_SELECT_MASK (15 << 19)
  800. #define SDVO_PHASE_SELECT_DEFAULT (6 << 19)
  801. #define SDVO_CLOCK_OUTPUT_INVERT (1 << 18)
  802. #define SDVOC_GANG_MODE (1 << 16)
  803. #define SDVO_BORDER_ENABLE (1 << 7)
  804. #define SDVOB_PCIE_CONCURRENCY (1 << 3)
  805. #define SDVO_DETECTED (1 << 2)
  806. /* Bits to be preserved when writing */
  807. #define SDVOB_PRESERVE_MASK ((1 << 17) | (1 << 16) | (1 << 14))
  808. #define SDVOC_PRESERVE_MASK (1 << 17)
  809. /** @defgroup LVDS
  810. * @{
  811. */
  812. /**
  813. * This register controls the LVDS output enable, pipe selection, and data
  814. * format selection.
  815. *
  816. * All of the clock/data pairs are force powered down by power sequencing.
  817. */
  818. #define LVDS 0x61180
  819. /**
  820. * Enables the LVDS port. This bit must be set before DPLLs are enabled, as
  821. * the DPLL semantics change when the LVDS is assigned to that pipe.
  822. */
  823. # define LVDS_PORT_EN (1 << 31)
  824. /** Selects pipe B for LVDS data. Must be set on pre-965. */
  825. # define LVDS_PIPEB_SELECT (1 << 30)
  826. /**
  827. * Enables the A0-A2 data pairs and CLKA, containing 18 bits of color data per
  828. * pixel.
  829. */
  830. # define LVDS_A0A2_CLKA_POWER_MASK (3 << 8)
  831. # define LVDS_A0A2_CLKA_POWER_DOWN (0 << 8)
  832. # define LVDS_A0A2_CLKA_POWER_UP (3 << 8)
  833. /**
  834. * Controls the A3 data pair, which contains the additional LSBs for 24 bit
  835. * mode. Only enabled if LVDS_A0A2_CLKA_POWER_UP also indicates it should be
  836. * on.
  837. */
  838. # define LVDS_A3_POWER_MASK (3 << 6)
  839. # define LVDS_A3_POWER_DOWN (0 << 6)
  840. # define LVDS_A3_POWER_UP (3 << 6)
  841. /**
  842. * Controls the CLKB pair. This should only be set when LVDS_B0B3_POWER_UP
  843. * is set.
  844. */
  845. # define LVDS_CLKB_POWER_MASK (3 << 4)
  846. # define LVDS_CLKB_POWER_DOWN (0 << 4)
  847. # define LVDS_CLKB_POWER_UP (3 << 4)
  848. /**
  849. * Controls the B0-B3 data pairs. This must be set to match the DPLL p2
  850. * setting for whether we are in dual-channel mode. The B3 pair will
  851. * additionally only be powered up when LVDS_A3_POWER_UP is set.
  852. */
  853. # define LVDS_B0B3_POWER_MASK (3 << 2)
  854. # define LVDS_B0B3_POWER_DOWN (0 << 2)
  855. # define LVDS_B0B3_POWER_UP (3 << 2)
  856. #define PIPEACONF 0x70008
  857. #define PIPEACONF_ENABLE (1<<31)
  858. #define PIPEACONF_DISABLE 0
  859. #define PIPEACONF_DOUBLE_WIDE (1<<30)
  860. #define I965_PIPECONF_ACTIVE (1<<30)
  861. #define PIPEACONF_SINGLE_WIDE 0
  862. #define PIPEACONF_PIPE_UNLOCKED 0
  863. #define PIPEACONF_PIPE_LOCKED (1<<25)
  864. #define PIPEACONF_PALETTE 0
  865. #define PIPEACONF_GAMMA (1<<24)
  866. #define PIPECONF_FORCE_BORDER (1<<25)
  867. #define PIPECONF_PROGRESSIVE (0 << 21)
  868. #define PIPECONF_INTERLACE_W_FIELD_INDICATION (6 << 21)
  869. #define PIPECONF_INTERLACE_FIELD_0_ONLY (7 << 21)
  870. #define DSPARB 0x70030
  871. #define DSPARB_CSTART_MASK (0x7f << 7)
  872. #define DSPARB_CSTART_SHIFT 7
  873. #define DSPARB_BSTART_MASK (0x7f)
  874. #define DSPARB_BSTART_SHIFT 0
  875. #define PIPEBCONF 0x71008
  876. #define PIPEBCONF_ENABLE (1<<31)
  877. #define PIPEBCONF_DISABLE 0
  878. #define PIPEBCONF_DOUBLE_WIDE (1<<30)
  879. #define PIPEBCONF_DISABLE 0
  880. #define PIPEBCONF_GAMMA (1<<24)
  881. #define PIPEBCONF_PALETTE 0
  882. #define PIPEBGCMAXRED 0x71010
  883. #define PIPEBGCMAXGREEN 0x71014
  884. #define PIPEBGCMAXBLUE 0x71018
  885. #define PIPEBSTAT 0x71024
  886. #define PIPEBFRAMEHIGH 0x71040
  887. #define PIPEBFRAMEPIXEL 0x71044
  888. #define DSPACNTR 0x70180
  889. #define DSPBCNTR 0x71180
  890. #define DISPLAY_PLANE_ENABLE (1<<31)
  891. #define DISPLAY_PLANE_DISABLE 0
  892. #define DISPPLANE_GAMMA_ENABLE (1<<30)
  893. #define DISPPLANE_GAMMA_DISABLE 0
  894. #define DISPPLANE_PIXFORMAT_MASK (0xf<<26)
  895. #define DISPPLANE_8BPP (0x2<<26)
  896. #define DISPPLANE_15_16BPP (0x4<<26)
  897. #define DISPPLANE_16BPP (0x5<<26)
  898. #define DISPPLANE_32BPP_NO_ALPHA (0x6<<26)
  899. #define DISPPLANE_32BPP (0x7<<26)
  900. #define DISPPLANE_STEREO_ENABLE (1<<25)
  901. #define DISPPLANE_STEREO_DISABLE 0
  902. #define DISPPLANE_SEL_PIPE_MASK (1<<24)
  903. #define DISPPLANE_SEL_PIPE_A 0
  904. #define DISPPLANE_SEL_PIPE_B (1<<24)
  905. #define DISPPLANE_SRC_KEY_ENABLE (1<<22)
  906. #define DISPPLANE_SRC_KEY_DISABLE 0
  907. #define DISPPLANE_LINE_DOUBLE (1<<20)
  908. #define DISPPLANE_NO_LINE_DOUBLE 0
  909. #define DISPPLANE_STEREO_POLARITY_FIRST 0
  910. #define DISPPLANE_STEREO_POLARITY_SECOND (1<<18)
  911. /* plane B only */
  912. #define DISPPLANE_ALPHA_TRANS_ENABLE (1<<15)
  913. #define DISPPLANE_ALPHA_TRANS_DISABLE 0
  914. #define DISPPLANE_SPRITE_ABOVE_DISPLAYA 0
  915. #define DISPPLANE_SPRITE_ABOVE_OVERLAY (1)
  916. #define DSPABASE 0x70184
  917. #define DSPASTRIDE 0x70188
  918. #define DSPBBASE 0x71184
  919. #define DSPBADDR DSPBBASE
  920. #define DSPBSTRIDE 0x71188
  921. #define DSPAKEYVAL 0x70194
  922. #define DSPAKEYMASK 0x70198
  923. #define DSPAPOS 0x7018C /* reserved */
  924. #define DSPASIZE 0x70190
  925. #define DSPBPOS 0x7118C
  926. #define DSPBSIZE 0x71190
  927. #define DSPASURF 0x7019C
  928. #define DSPATILEOFF 0x701A4
  929. #define DSPBSURF 0x7119C
  930. #define DSPBTILEOFF 0x711A4
  931. #define VGACNTRL 0x71400
  932. # define VGA_DISP_DISABLE (1 << 31)
  933. # define VGA_2X_MODE (1 << 30)
  934. # define VGA_PIPE_B_SELECT (1 << 29)
  935. /*
  936. * Some BIOS scratch area registers. The 845 (and 830?) store the amount
  937. * of video memory available to the BIOS in SWF1.
  938. */
  939. #define SWF0 0x71410
  940. /*
  941. * 855 scratch registers.
  942. */
  943. #define SWF10 0x70410
  944. #define SWF30 0x72414
  945. /*
  946. * Overlay registers. These are overlay registers accessed via MMIO.
  947. * Those loaded via the overlay register page are defined in i830_video.c.
  948. */
  949. #define OVADD 0x30000
  950. #define DOVSTA 0x30008
  951. #define OC_BUF (0x3<<20)
  952. #define OGAMC5 0x30010
  953. #define OGAMC4 0x30014
  954. #define OGAMC3 0x30018
  955. #define OGAMC2 0x3001c
  956. #define OGAMC1 0x30020
  957. #define OGAMC0 0x30024
  958. /*
  959. * Palette registers
  960. */
  961. #define PALETTE_A 0x0a000
  962. #define PALETTE_B 0x0a800
  963. #define IS_I830(dev) ((dev)->pci_device == 0x3577)
  964. #define IS_845G(dev) ((dev)->pci_device == 0x2562)
  965. #define IS_I85X(dev) ((dev)->pci_device == 0x3582)
  966. #define IS_I855(dev) ((dev)->pci_device == 0x3582)
  967. #define IS_I865G(dev) ((dev)->pci_device == 0x2572)
  968. #define IS_I915G(dev) ((dev)->pci_device == 0x2582 || (dev)->pci_device == 0x258a)
  969. #define IS_I915GM(dev) ((dev)->pci_device == 0x2592)
  970. #define IS_I945G(dev) ((dev)->pci_device == 0x2772)
  971. #define IS_I945GM(dev) ((dev)->pci_device == 0x27A2 ||\
  972. (dev)->pci_device == 0x27AE)
  973. #define IS_I965G(dev) ((dev)->pci_device == 0x2972 || \
  974. (dev)->pci_device == 0x2982 || \
  975. (dev)->pci_device == 0x2992 || \
  976. (dev)->pci_device == 0x29A2 || \
  977. (dev)->pci_device == 0x2A02 || \
  978. (dev)->pci_device == 0x2A12 || \
  979. (dev)->pci_device == 0x2A42 || \
  980. (dev)->pci_device == 0x2E02 || \
  981. (dev)->pci_device == 0x2E12 || \
  982. (dev)->pci_device == 0x2E22)
  983. #define IS_I965GM(dev) ((dev)->pci_device == 0x2A02)
  984. #define IS_IGD_GM(dev) ((dev)->pci_device == 0x2A42)
  985. #define IS_G4X(dev) ((dev)->pci_device == 0x2E02 || \
  986. (dev)->pci_device == 0x2E12 || \
  987. (dev)->pci_device == 0x2E22)
  988. #define IS_G33(dev) ((dev)->pci_device == 0x29C2 || \
  989. (dev)->pci_device == 0x29B2 || \
  990. (dev)->pci_device == 0x29D2)
  991. #define IS_I9XX(dev) (IS_I915G(dev) || IS_I915GM(dev) || IS_I945G(dev) || \
  992. IS_I945GM(dev) || IS_I965G(dev) || IS_G33(dev))
  993. #define IS_MOBILE(dev) (IS_I830(dev) || IS_I85X(dev) || IS_I915GM(dev) || \
  994. IS_I945GM(dev) || IS_I965GM(dev) || IS_IGD_GM(dev))
  995. #define I915_NEED_GFX_HWS(dev) (IS_G33(dev) || IS_IGD_GM(dev) || IS_G4X(dev))
  996. #define PRIMARY_RINGBUFFER_SIZE (128*1024)
  997. #endif