i915_drv.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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. /* General customization:
  33. */
  34. #define DRIVER_AUTHOR "Tungsten Graphics, Inc."
  35. #define DRIVER_NAME "i915"
  36. #define DRIVER_DESC "Intel Graphics"
  37. #define DRIVER_DATE "20080730"
  38. enum pipe {
  39. PIPE_A = 0,
  40. PIPE_B,
  41. };
  42. /* Interface history:
  43. *
  44. * 1.1: Original.
  45. * 1.2: Add Power Management
  46. * 1.3: Add vblank support
  47. * 1.4: Fix cmdbuffer path, add heap destroy
  48. * 1.5: Add vblank pipe configuration
  49. * 1.6: - New ioctl for scheduling buffer swaps on vertical blank
  50. * - Support vertical blank on secondary display pipe
  51. */
  52. #define DRIVER_MAJOR 1
  53. #define DRIVER_MINOR 6
  54. #define DRIVER_PATCHLEVEL 0
  55. #define WATCH_COHERENCY 0
  56. #define WATCH_BUF 0
  57. #define WATCH_EXEC 0
  58. #define WATCH_LRU 0
  59. #define WATCH_RELOC 0
  60. #define WATCH_INACTIVE 0
  61. #define WATCH_PWRITE 0
  62. typedef struct _drm_i915_ring_buffer {
  63. int tail_mask;
  64. unsigned long Size;
  65. u8 *virtual_start;
  66. int head;
  67. int tail;
  68. int space;
  69. drm_local_map_t map;
  70. struct drm_gem_object *ring_obj;
  71. } drm_i915_ring_buffer_t;
  72. struct mem_block {
  73. struct mem_block *next;
  74. struct mem_block *prev;
  75. int start;
  76. int size;
  77. struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
  78. };
  79. typedef struct _drm_i915_vbl_swap {
  80. struct list_head head;
  81. drm_drawable_t drw_id;
  82. unsigned int plane;
  83. unsigned int sequence;
  84. } drm_i915_vbl_swap_t;
  85. struct opregion_header;
  86. struct opregion_acpi;
  87. struct opregion_swsci;
  88. struct opregion_asle;
  89. struct intel_opregion {
  90. struct opregion_header *header;
  91. struct opregion_acpi *acpi;
  92. struct opregion_swsci *swsci;
  93. struct opregion_asle *asle;
  94. int enabled;
  95. };
  96. typedef struct drm_i915_private {
  97. struct drm_device *dev;
  98. drm_local_map_t *sarea;
  99. drm_local_map_t *mmio_map;
  100. drm_i915_sarea_t *sarea_priv;
  101. drm_i915_ring_buffer_t ring;
  102. drm_dma_handle_t *status_page_dmah;
  103. void *hw_status_page;
  104. dma_addr_t dma_status_page;
  105. uint32_t counter;
  106. unsigned int status_gfx_addr;
  107. drm_local_map_t hws_map;
  108. struct drm_gem_object *hws_obj;
  109. unsigned int cpp;
  110. int back_offset;
  111. int front_offset;
  112. int current_page;
  113. int page_flipping;
  114. wait_queue_head_t irq_queue;
  115. atomic_t irq_received;
  116. /** Protects user_irq_refcount and irq_mask_reg */
  117. spinlock_t user_irq_lock;
  118. /** Refcount for i915_user_irq_get() versus i915_user_irq_put(). */
  119. int user_irq_refcount;
  120. /** Cached value of IMR to avoid reads in updating the bitfield */
  121. u32 irq_mask_reg;
  122. int tex_lru_log_granularity;
  123. int allow_batchbuffer;
  124. struct mem_block *agp_heap;
  125. unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
  126. int vblank_pipe;
  127. spinlock_t swaps_lock;
  128. drm_i915_vbl_swap_t vbl_swaps;
  129. unsigned int swaps_pending;
  130. struct intel_opregion opregion;
  131. /* Register state */
  132. u8 saveLBB;
  133. u32 saveDSPACNTR;
  134. u32 saveDSPBCNTR;
  135. u32 saveDSPARB;
  136. u32 savePIPEACONF;
  137. u32 savePIPEBCONF;
  138. u32 savePIPEASRC;
  139. u32 savePIPEBSRC;
  140. u32 saveFPA0;
  141. u32 saveFPA1;
  142. u32 saveDPLL_A;
  143. u32 saveDPLL_A_MD;
  144. u32 saveHTOTAL_A;
  145. u32 saveHBLANK_A;
  146. u32 saveHSYNC_A;
  147. u32 saveVTOTAL_A;
  148. u32 saveVBLANK_A;
  149. u32 saveVSYNC_A;
  150. u32 saveBCLRPAT_A;
  151. u32 savePIPEASTAT;
  152. u32 saveDSPASTRIDE;
  153. u32 saveDSPASIZE;
  154. u32 saveDSPAPOS;
  155. u32 saveDSPAADDR;
  156. u32 saveDSPASURF;
  157. u32 saveDSPATILEOFF;
  158. u32 savePFIT_PGM_RATIOS;
  159. u32 saveBLC_PWM_CTL;
  160. u32 saveBLC_PWM_CTL2;
  161. u32 saveFPB0;
  162. u32 saveFPB1;
  163. u32 saveDPLL_B;
  164. u32 saveDPLL_B_MD;
  165. u32 saveHTOTAL_B;
  166. u32 saveHBLANK_B;
  167. u32 saveHSYNC_B;
  168. u32 saveVTOTAL_B;
  169. u32 saveVBLANK_B;
  170. u32 saveVSYNC_B;
  171. u32 saveBCLRPAT_B;
  172. u32 savePIPEBSTAT;
  173. u32 saveDSPBSTRIDE;
  174. u32 saveDSPBSIZE;
  175. u32 saveDSPBPOS;
  176. u32 saveDSPBADDR;
  177. u32 saveDSPBSURF;
  178. u32 saveDSPBTILEOFF;
  179. u32 saveVGA0;
  180. u32 saveVGA1;
  181. u32 saveVGA_PD;
  182. u32 saveVGACNTRL;
  183. u32 saveADPA;
  184. u32 saveLVDS;
  185. u32 savePP_ON_DELAYS;
  186. u32 savePP_OFF_DELAYS;
  187. u32 saveDVOA;
  188. u32 saveDVOB;
  189. u32 saveDVOC;
  190. u32 savePP_ON;
  191. u32 savePP_OFF;
  192. u32 savePP_CONTROL;
  193. u32 savePP_DIVISOR;
  194. u32 savePFIT_CONTROL;
  195. u32 save_palette_a[256];
  196. u32 save_palette_b[256];
  197. u32 saveFBC_CFB_BASE;
  198. u32 saveFBC_LL_BASE;
  199. u32 saveFBC_CONTROL;
  200. u32 saveFBC_CONTROL2;
  201. u32 saveIER;
  202. u32 saveIIR;
  203. u32 saveIMR;
  204. u32 saveCACHE_MODE_0;
  205. u32 saveD_STATE;
  206. u32 saveCG_2D_DIS;
  207. u32 saveMI_ARB_STATE;
  208. u32 saveSWF0[16];
  209. u32 saveSWF1[16];
  210. u32 saveSWF2[3];
  211. u8 saveMSR;
  212. u8 saveSR[8];
  213. u8 saveGR[25];
  214. u8 saveAR_INDEX;
  215. u8 saveAR[21];
  216. u8 saveDACMASK;
  217. u8 saveDACDATA[256*3]; /* 256 3-byte colors */
  218. u8 saveCR[37];
  219. struct {
  220. struct drm_mm gtt_space;
  221. /**
  222. * List of objects currently involved in rendering from the
  223. * ringbuffer.
  224. *
  225. * A reference is held on the buffer while on this list.
  226. */
  227. struct list_head active_list;
  228. /**
  229. * List of objects which are not in the ringbuffer but which
  230. * still have a write_domain which needs to be flushed before
  231. * unbinding.
  232. *
  233. * A reference is held on the buffer while on this list.
  234. */
  235. struct list_head flushing_list;
  236. /**
  237. * LRU list of objects which are not in the ringbuffer and
  238. * are ready to unbind, but are still in the GTT.
  239. *
  240. * A reference is not held on the buffer while on this list,
  241. * as merely being GTT-bound shouldn't prevent its being
  242. * freed, and we'll pull it off the list in the free path.
  243. */
  244. struct list_head inactive_list;
  245. /**
  246. * List of breadcrumbs associated with GPU requests currently
  247. * outstanding.
  248. */
  249. struct list_head request_list;
  250. /**
  251. * We leave the user IRQ off as much as possible,
  252. * but this means that requests will finish and never
  253. * be retired once the system goes idle. Set a timer to
  254. * fire periodically while the ring is running. When it
  255. * fires, go retire requests.
  256. */
  257. struct delayed_work retire_work;
  258. uint32_t next_gem_seqno;
  259. /**
  260. * Waiting sequence number, if any
  261. */
  262. uint32_t waiting_gem_seqno;
  263. /**
  264. * Last seq seen at irq time
  265. */
  266. uint32_t irq_gem_seqno;
  267. /**
  268. * Flag if the X Server, and thus DRM, is not currently in
  269. * control of the device.
  270. *
  271. * This is set between LeaveVT and EnterVT. It needs to be
  272. * replaced with a semaphore. It also needs to be
  273. * transitioned away from for kernel modesetting.
  274. */
  275. int suspended;
  276. /**
  277. * Flag if the hardware appears to be wedged.
  278. *
  279. * This is set when attempts to idle the device timeout.
  280. * It prevents command submission from occuring and makes
  281. * every pending request fail
  282. */
  283. int wedged;
  284. /** Bit 6 swizzling required for X tiling */
  285. uint32_t bit_6_swizzle_x;
  286. /** Bit 6 swizzling required for Y tiling */
  287. uint32_t bit_6_swizzle_y;
  288. } mm;
  289. } drm_i915_private_t;
  290. /** driver private structure attached to each drm_gem_object */
  291. struct drm_i915_gem_object {
  292. struct drm_gem_object *obj;
  293. /** Current space allocated to this object in the GTT, if any. */
  294. struct drm_mm_node *gtt_space;
  295. /** This object's place on the active/flushing/inactive lists */
  296. struct list_head list;
  297. /**
  298. * This is set if the object is on the active or flushing lists
  299. * (has pending rendering), and is not set if it's on inactive (ready
  300. * to be unbound).
  301. */
  302. int active;
  303. /**
  304. * This is set if the object has been written to since last bound
  305. * to the GTT
  306. */
  307. int dirty;
  308. /** AGP memory structure for our GTT binding. */
  309. DRM_AGP_MEM *agp_mem;
  310. struct page **page_list;
  311. /**
  312. * Current offset of the object in GTT space.
  313. *
  314. * This is the same as gtt_space->start
  315. */
  316. uint32_t gtt_offset;
  317. /** Boolean whether this object has a valid gtt offset. */
  318. int gtt_bound;
  319. /** How many users have pinned this object in GTT space */
  320. int pin_count;
  321. /** Breadcrumb of last rendering to the buffer. */
  322. uint32_t last_rendering_seqno;
  323. /** Current tiling mode for the object. */
  324. uint32_t tiling_mode;
  325. /**
  326. * Flagging of which individual pages are valid in GEM_DOMAIN_CPU when
  327. * GEM_DOMAIN_CPU is not in the object's read domain.
  328. */
  329. uint8_t *page_cpu_valid;
  330. };
  331. /**
  332. * Request queue structure.
  333. *
  334. * The request queue allows us to note sequence numbers that have been emitted
  335. * and may be associated with active buffers to be retired.
  336. *
  337. * By keeping this list, we can avoid having to do questionable
  338. * sequence-number comparisons on buffer last_rendering_seqnos, and associate
  339. * an emission time with seqnos for tracking how far ahead of the GPU we are.
  340. */
  341. struct drm_i915_gem_request {
  342. /** GEM sequence number associated with this request. */
  343. uint32_t seqno;
  344. /** Time at which this request was emitted, in jiffies. */
  345. unsigned long emitted_jiffies;
  346. /** Cache domains that were flushed at the start of the request. */
  347. uint32_t flush_domains;
  348. struct list_head list;
  349. };
  350. struct drm_i915_file_private {
  351. struct {
  352. uint32_t last_gem_seqno;
  353. uint32_t last_gem_throttle_seqno;
  354. } mm;
  355. };
  356. extern struct drm_ioctl_desc i915_ioctls[];
  357. extern int i915_max_ioctl;
  358. /* i915_dma.c */
  359. extern void i915_kernel_lost_context(struct drm_device * dev);
  360. extern int i915_driver_load(struct drm_device *, unsigned long flags);
  361. extern int i915_driver_unload(struct drm_device *);
  362. extern int i915_driver_open(struct drm_device *dev, struct drm_file *file_priv);
  363. extern void i915_driver_lastclose(struct drm_device * dev);
  364. extern void i915_driver_preclose(struct drm_device *dev,
  365. struct drm_file *file_priv);
  366. extern void i915_driver_postclose(struct drm_device *dev,
  367. struct drm_file *file_priv);
  368. extern int i915_driver_device_is_agp(struct drm_device * dev);
  369. extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
  370. unsigned long arg);
  371. extern int i915_emit_box(struct drm_device *dev,
  372. struct drm_clip_rect __user *boxes,
  373. int i, int DR1, int DR4);
  374. /* i915_irq.c */
  375. extern int i915_irq_emit(struct drm_device *dev, void *data,
  376. struct drm_file *file_priv);
  377. extern int i915_irq_wait(struct drm_device *dev, void *data,
  378. struct drm_file *file_priv);
  379. void i915_user_irq_get(struct drm_device *dev);
  380. void i915_user_irq_put(struct drm_device *dev);
  381. extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
  382. extern void i915_driver_irq_preinstall(struct drm_device * dev);
  383. extern int i915_driver_irq_postinstall(struct drm_device *dev);
  384. extern void i915_driver_irq_uninstall(struct drm_device * dev);
  385. extern int i915_vblank_pipe_set(struct drm_device *dev, void *data,
  386. struct drm_file *file_priv);
  387. extern int i915_vblank_pipe_get(struct drm_device *dev, void *data,
  388. struct drm_file *file_priv);
  389. extern int i915_enable_vblank(struct drm_device *dev, int crtc);
  390. extern void i915_disable_vblank(struct drm_device *dev, int crtc);
  391. extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc);
  392. extern int i915_vblank_swap(struct drm_device *dev, void *data,
  393. struct drm_file *file_priv);
  394. extern void i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask);
  395. /* i915_mem.c */
  396. extern int i915_mem_alloc(struct drm_device *dev, void *data,
  397. struct drm_file *file_priv);
  398. extern int i915_mem_free(struct drm_device *dev, void *data,
  399. struct drm_file *file_priv);
  400. extern int i915_mem_init_heap(struct drm_device *dev, void *data,
  401. struct drm_file *file_priv);
  402. extern int i915_mem_destroy_heap(struct drm_device *dev, void *data,
  403. struct drm_file *file_priv);
  404. extern void i915_mem_takedown(struct mem_block **heap);
  405. extern void i915_mem_release(struct drm_device * dev,
  406. struct drm_file *file_priv, struct mem_block *heap);
  407. /* i915_gem.c */
  408. int i915_gem_init_ioctl(struct drm_device *dev, void *data,
  409. struct drm_file *file_priv);
  410. int i915_gem_create_ioctl(struct drm_device *dev, void *data,
  411. struct drm_file *file_priv);
  412. int i915_gem_pread_ioctl(struct drm_device *dev, void *data,
  413. struct drm_file *file_priv);
  414. int i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
  415. struct drm_file *file_priv);
  416. int i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
  417. struct drm_file *file_priv);
  418. int i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
  419. struct drm_file *file_priv);
  420. int i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
  421. struct drm_file *file_priv);
  422. int i915_gem_execbuffer(struct drm_device *dev, void *data,
  423. struct drm_file *file_priv);
  424. int i915_gem_pin_ioctl(struct drm_device *dev, void *data,
  425. struct drm_file *file_priv);
  426. int i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
  427. struct drm_file *file_priv);
  428. int i915_gem_busy_ioctl(struct drm_device *dev, void *data,
  429. struct drm_file *file_priv);
  430. int i915_gem_throttle_ioctl(struct drm_device *dev, void *data,
  431. struct drm_file *file_priv);
  432. int i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
  433. struct drm_file *file_priv);
  434. int i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
  435. struct drm_file *file_priv);
  436. int i915_gem_set_tiling(struct drm_device *dev, void *data,
  437. struct drm_file *file_priv);
  438. int i915_gem_get_tiling(struct drm_device *dev, void *data,
  439. struct drm_file *file_priv);
  440. void i915_gem_load(struct drm_device *dev);
  441. int i915_gem_proc_init(struct drm_minor *minor);
  442. void i915_gem_proc_cleanup(struct drm_minor *minor);
  443. int i915_gem_init_object(struct drm_gem_object *obj);
  444. void i915_gem_free_object(struct drm_gem_object *obj);
  445. int i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment);
  446. void i915_gem_object_unpin(struct drm_gem_object *obj);
  447. void i915_gem_lastclose(struct drm_device *dev);
  448. uint32_t i915_get_gem_seqno(struct drm_device *dev);
  449. void i915_gem_retire_requests(struct drm_device *dev);
  450. void i915_gem_retire_work_handler(struct work_struct *work);
  451. void i915_gem_clflush_object(struct drm_gem_object *obj);
  452. /* i915_gem_tiling.c */
  453. void i915_gem_detect_bit_6_swizzle(struct drm_device *dev);
  454. /* i915_gem_debug.c */
  455. void i915_gem_dump_object(struct drm_gem_object *obj, int len,
  456. const char *where, uint32_t mark);
  457. #if WATCH_INACTIVE
  458. void i915_verify_inactive(struct drm_device *dev, char *file, int line);
  459. #else
  460. #define i915_verify_inactive(dev, file, line)
  461. #endif
  462. void i915_gem_object_check_coherency(struct drm_gem_object *obj, int handle);
  463. void i915_gem_dump_object(struct drm_gem_object *obj, int len,
  464. const char *where, uint32_t mark);
  465. void i915_dump_lru(struct drm_device *dev, const char *where);
  466. /* i915_suspend.c */
  467. extern int i915_save_state(struct drm_device *dev);
  468. extern int i915_restore_state(struct drm_device *dev);
  469. /* i915_suspend.c */
  470. extern int i915_save_state(struct drm_device *dev);
  471. extern int i915_restore_state(struct drm_device *dev);
  472. /* i915_opregion.c */
  473. extern int intel_opregion_init(struct drm_device *dev);
  474. extern void intel_opregion_free(struct drm_device *dev);
  475. extern void opregion_asle_intr(struct drm_device *dev);
  476. extern void opregion_enable_asle(struct drm_device *dev);
  477. #define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg))
  478. #define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
  479. #define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, (reg))
  480. #define I915_WRITE16(reg,val) DRM_WRITE16(dev_priv->mmio_map, (reg), (val))
  481. #define I915_READ8(reg) DRM_READ8(dev_priv->mmio_map, (reg))
  482. #define I915_WRITE8(reg,val) DRM_WRITE8(dev_priv->mmio_map, (reg), (val))
  483. #define I915_VERBOSE 0
  484. #define RING_LOCALS unsigned int outring, ringmask, outcount; \
  485. volatile char *virt;
  486. #define BEGIN_LP_RING(n) do { \
  487. if (I915_VERBOSE) \
  488. DRM_DEBUG("BEGIN_LP_RING(%d)\n", (n)); \
  489. if (dev_priv->ring.space < (n)*4) \
  490. i915_wait_ring(dev, (n)*4, __func__); \
  491. outcount = 0; \
  492. outring = dev_priv->ring.tail; \
  493. ringmask = dev_priv->ring.tail_mask; \
  494. virt = dev_priv->ring.virtual_start; \
  495. } while (0)
  496. #define OUT_RING(n) do { \
  497. if (I915_VERBOSE) DRM_DEBUG(" OUT_RING %x\n", (int)(n)); \
  498. *(volatile unsigned int *)(virt + outring) = (n); \
  499. outcount++; \
  500. outring += 4; \
  501. outring &= ringmask; \
  502. } while (0)
  503. #define ADVANCE_LP_RING() do { \
  504. if (I915_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING %x\n", outring); \
  505. dev_priv->ring.tail = outring; \
  506. dev_priv->ring.space -= outcount * 4; \
  507. I915_WRITE(PRB0_TAIL, outring); \
  508. } while(0)
  509. /**
  510. * Reads a dword out of the status page, which is written to from the command
  511. * queue by automatic updates, MI_REPORT_HEAD, MI_STORE_DATA_INDEX, or
  512. * MI_STORE_DATA_IMM.
  513. *
  514. * The following dwords have a reserved meaning:
  515. * 0: ISR copy, updated when an ISR bit not set in the HWSTAM changes.
  516. * 4: ring 0 head pointer
  517. * 5: ring 1 head pointer (915-class)
  518. * 6: ring 2 head pointer (915-class)
  519. *
  520. * The area from dword 0x10 to 0x3ff is available for driver usage.
  521. */
  522. #define READ_HWSP(dev_priv, reg) (((volatile u32*)(dev_priv->hw_status_page))[reg])
  523. #define READ_BREADCRUMB(dev_priv) READ_HWSP(dev_priv, 5)
  524. #define I915_GEM_HWS_INDEX 0x10
  525. extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
  526. #define IS_I830(dev) ((dev)->pci_device == 0x3577)
  527. #define IS_845G(dev) ((dev)->pci_device == 0x2562)
  528. #define IS_I85X(dev) ((dev)->pci_device == 0x3582)
  529. #define IS_I855(dev) ((dev)->pci_device == 0x3582)
  530. #define IS_I865G(dev) ((dev)->pci_device == 0x2572)
  531. #define IS_I915G(dev) ((dev)->pci_device == 0x2582 || (dev)->pci_device == 0x258a)
  532. #define IS_I915GM(dev) ((dev)->pci_device == 0x2592)
  533. #define IS_I945G(dev) ((dev)->pci_device == 0x2772)
  534. #define IS_I945GM(dev) ((dev)->pci_device == 0x27A2 ||\
  535. (dev)->pci_device == 0x27AE)
  536. #define IS_I965G(dev) ((dev)->pci_device == 0x2972 || \
  537. (dev)->pci_device == 0x2982 || \
  538. (dev)->pci_device == 0x2992 || \
  539. (dev)->pci_device == 0x29A2 || \
  540. (dev)->pci_device == 0x2A02 || \
  541. (dev)->pci_device == 0x2A12 || \
  542. (dev)->pci_device == 0x2A42 || \
  543. (dev)->pci_device == 0x2E02 || \
  544. (dev)->pci_device == 0x2E12 || \
  545. (dev)->pci_device == 0x2E22)
  546. #define IS_I965GM(dev) ((dev)->pci_device == 0x2A02)
  547. #define IS_GM45(dev) ((dev)->pci_device == 0x2A42)
  548. #define IS_G4X(dev) ((dev)->pci_device == 0x2E02 || \
  549. (dev)->pci_device == 0x2E12 || \
  550. (dev)->pci_device == 0x2E22)
  551. #define IS_G33(dev) ((dev)->pci_device == 0x29C2 || \
  552. (dev)->pci_device == 0x29B2 || \
  553. (dev)->pci_device == 0x29D2)
  554. #define IS_I9XX(dev) (IS_I915G(dev) || IS_I915GM(dev) || IS_I945G(dev) || \
  555. IS_I945GM(dev) || IS_I965G(dev) || IS_G33(dev))
  556. #define IS_MOBILE(dev) (IS_I830(dev) || IS_I85X(dev) || IS_I915GM(dev) || \
  557. IS_I945GM(dev) || IS_I965GM(dev) || IS_GM45(dev))
  558. #define I915_NEED_GFX_HWS(dev) (IS_G33(dev) || IS_GM45(dev) || IS_G4X(dev))
  559. #define PRIMARY_RINGBUFFER_SIZE (128*1024)
  560. #endif