i915_drv.h 33 KB

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