agp/intel: Remove duplicate const
[deliverable/linux.git] / drivers / gpu / drm / i915 / i915_drv.h
CommitLineData
1da177e4
LT
1/* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
2 */
0d6aa60b 3/*
bc54fd1a 4 *
1da177e4
LT
5 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * All Rights Reserved.
bc54fd1a
DA
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 *
0d6aa60b 28 */
1da177e4
LT
29
30#ifndef _I915_DRV_H_
31#define _I915_DRV_H_
32
585fb111 33#include "i915_reg.h"
79e53945 34#include "intel_bios.h"
8187a2b7 35#include "intel_ringbuffer.h"
0839ccb8 36#include <linux/io-mapping.h>
f899fc64 37#include <linux/i2c.h>
0ade6386 38#include <drm/intel-gtt.h>
585fb111 39
1da177e4
LT
40/* General customization:
41 */
42
43#define DRIVER_AUTHOR "Tungsten Graphics, Inc."
44
45#define DRIVER_NAME "i915"
46#define DRIVER_DESC "Intel Graphics"
673a394b 47#define DRIVER_DATE "20080730"
1da177e4 48
317c35d1
JB
49enum pipe {
50 PIPE_A = 0,
51 PIPE_B,
52};
53
80824003
JB
54enum plane {
55 PLANE_A = 0,
56 PLANE_B,
57};
58
52440211
KP
59#define I915_NUM_PIPE 2
60
62fdfeaf
EA
61#define I915_GEM_GPU_DOMAINS (~(I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT))
62
1da177e4
LT
63/* Interface history:
64 *
65 * 1.1: Original.
0d6aa60b
DA
66 * 1.2: Add Power Management
67 * 1.3: Add vblank support
de227f5f 68 * 1.4: Fix cmdbuffer path, add heap destroy
702880f2 69 * 1.5: Add vblank pipe configuration
2228ed67
MCA
70 * 1.6: - New ioctl for scheduling buffer swaps on vertical blank
71 * - Support vertical blank on secondary display pipe
1da177e4
LT
72 */
73#define DRIVER_MAJOR 1
2228ed67 74#define DRIVER_MINOR 6
1da177e4
LT
75#define DRIVER_PATCHLEVEL 0
76
673a394b 77#define WATCH_COHERENCY 0
673a394b 78#define WATCH_EXEC 0
673a394b 79#define WATCH_RELOC 0
23bc5982 80#define WATCH_LISTS 0
673a394b
EA
81#define WATCH_PWRITE 0
82
71acb5eb
DA
83#define I915_GEM_PHYS_CURSOR_0 1
84#define I915_GEM_PHYS_CURSOR_1 2
85#define I915_GEM_PHYS_OVERLAY_REGS 3
86#define I915_MAX_PHYS_OBJECT (I915_GEM_PHYS_OVERLAY_REGS)
87
88struct drm_i915_gem_phys_object {
89 int id;
90 struct page **page_list;
91 drm_dma_handle_t *handle;
05394f39 92 struct drm_i915_gem_object *cur_obj;
71acb5eb
DA
93};
94
1da177e4
LT
95struct mem_block {
96 struct mem_block *next;
97 struct mem_block *prev;
98 int start;
99 int size;
6c340eac 100 struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
1da177e4
LT
101};
102
0a3e67a4
JB
103struct opregion_header;
104struct opregion_acpi;
105struct opregion_swsci;
106struct opregion_asle;
107
8ee1c3db
MG
108struct intel_opregion {
109 struct opregion_header *header;
110 struct opregion_acpi *acpi;
111 struct opregion_swsci *swsci;
112 struct opregion_asle *asle;
44834a67 113 void *vbt;
8ee1c3db 114};
44834a67 115#define OPREGION_SIZE (8*1024)
8ee1c3db 116
6ef3d427
CW
117struct intel_overlay;
118struct intel_overlay_error_state;
119
7c1c2871
DA
120struct drm_i915_master_private {
121 drm_local_map_t *sarea;
122 struct _drm_i915_sarea *sarea_priv;
123};
de151cf6
JB
124#define I915_FENCE_REG_NONE -1
125
126struct drm_i915_fence_reg {
05394f39 127 struct drm_i915_gem_object *obj;
007cc8ac 128 struct list_head lru_list;
53640e1d 129 bool gpu;
de151cf6 130};
7c1c2871 131
9b9d172d 132struct sdvo_device_mapping {
e957d772 133 u8 initialized;
9b9d172d 134 u8 dvo_port;
135 u8 slave_addr;
136 u8 dvo_wiring;
e957d772
CW
137 u8 i2c_pin;
138 u8 i2c_speed;
b1083333 139 u8 ddc_pin;
9b9d172d 140};
141
c4a1d9e4
CW
142struct intel_display_error_state;
143
63eeaf38
JB
144struct drm_i915_error_state {
145 u32 eir;
146 u32 pgtbl_er;
147 u32 pipeastat;
148 u32 pipebstat;
149 u32 ipeir;
150 u32 ipehr;
151 u32 instdone;
152 u32 acthd;
1d8f38f4
CW
153 u32 error; /* gen6+ */
154 u32 bcs_acthd; /* gen6+ blt engine */
155 u32 bcs_ipehr;
156 u32 bcs_ipeir;
157 u32 bcs_instdone;
158 u32 bcs_seqno;
add354dd
CW
159 u32 vcs_acthd; /* gen6+ bsd engine */
160 u32 vcs_ipehr;
161 u32 vcs_ipeir;
162 u32 vcs_instdone;
163 u32 vcs_seqno;
63eeaf38
JB
164 u32 instpm;
165 u32 instps;
166 u32 instdone1;
167 u32 seqno;
9df30794 168 u64 bbaddr;
63eeaf38 169 struct timeval time;
9df30794
CW
170 struct drm_i915_error_object {
171 int page_count;
172 u32 gtt_offset;
173 u32 *pages[0];
174 } *ringbuffer, *batchbuffer[2];
175 struct drm_i915_error_buffer {
176 size_t size;
177 u32 name;
178 u32 seqno;
179 u32 gtt_offset;
180 u32 read_domains;
181 u32 write_domain;
182 u32 fence_reg;
183 s32 pinned:2;
184 u32 tiling:2;
185 u32 dirty:1;
186 u32 purgeable:1;
e5c65260 187 u32 ring:4;
c724e8a9
CW
188 } *active_bo, *pinned_bo;
189 u32 active_bo_count, pinned_bo_count;
6ef3d427 190 struct intel_overlay_error_state *overlay;
c4a1d9e4 191 struct intel_display_error_state *display;
63eeaf38
JB
192};
193
e70236a8
JB
194struct drm_i915_display_funcs {
195 void (*dpms)(struct drm_crtc *crtc, int mode);
ee5382ae 196 bool (*fbc_enabled)(struct drm_device *dev);
e70236a8
JB
197 void (*enable_fbc)(struct drm_crtc *crtc, unsigned long interval);
198 void (*disable_fbc)(struct drm_device *dev);
199 int (*get_display_clock_speed)(struct drm_device *dev);
200 int (*get_fifo_size)(struct drm_device *dev, int plane);
201 void (*update_wm)(struct drm_device *dev, int planea_clock,
fa143215
ZY
202 int planeb_clock, int sr_hdisplay, int sr_htotal,
203 int pixel_size);
e70236a8
JB
204 /* clock updates for mode set */
205 /* cursor updates */
206 /* render clock increase/decrease */
207 /* display clock increase/decrease */
208 /* pll clock increase/decrease */
209 /* clock gating init */
210};
211
cfdf1fa2 212struct intel_device_info {
c96c3a8c 213 u8 gen;
cfdf1fa2 214 u8 is_mobile : 1;
5ce8ba7c 215 u8 is_i85x : 1;
cfdf1fa2 216 u8 is_i915g : 1;
cfdf1fa2 217 u8 is_i945gm : 1;
cfdf1fa2
KH
218 u8 is_g33 : 1;
219 u8 need_gfx_hws : 1;
220 u8 is_g4x : 1;
221 u8 is_pineview : 1;
534843da
CW
222 u8 is_broadwater : 1;
223 u8 is_crestline : 1;
cfdf1fa2
KH
224 u8 has_fbc : 1;
225 u8 has_rc6 : 1;
226 u8 has_pipe_cxsr : 1;
227 u8 has_hotplug : 1;
b295d1b6 228 u8 cursor_needs_physical : 1;
31578148
CW
229 u8 has_overlay : 1;
230 u8 overlay_needs_physical : 1;
a6c45cf0 231 u8 supports_tv : 1;
92f49d9c 232 u8 has_bsd_ring : 1;
549f7365 233 u8 has_blt_ring : 1;
cfdf1fa2
KH
234};
235
b5e50c3f 236enum no_fbc_reason {
bed4a673 237 FBC_NO_OUTPUT, /* no outputs enabled to compress */
b5e50c3f
JB
238 FBC_STOLEN_TOO_SMALL, /* not enough space to hold compressed buffers */
239 FBC_UNSUPPORTED_MODE, /* interlace or doublescanned mode */
240 FBC_MODE_TOO_LARGE, /* mode too large for compression */
241 FBC_BAD_PLANE, /* fbc not supported on plane */
242 FBC_NOT_TILED, /* buffer not tiled */
9c928d16 243 FBC_MULTIPLE_PIPES, /* more than one pipe active */
b5e50c3f
JB
244};
245
3bad0781
ZW
246enum intel_pch {
247 PCH_IBX, /* Ibexpeak PCH */
248 PCH_CPT, /* Cougarpoint PCH */
249};
250
b690e96c
JB
251#define QUIRK_PIPEA_FORCE (1<<0)
252
8be48d92 253struct intel_fbdev;
38651674 254
1da177e4 255typedef struct drm_i915_private {
673a394b
EA
256 struct drm_device *dev;
257
cfdf1fa2
KH
258 const struct intel_device_info *info;
259
ac5c4e76
DA
260 int has_gem;
261
3043c60c 262 void __iomem *regs;
1da177e4 263
f899fc64
CW
264 struct intel_gmbus {
265 struct i2c_adapter adapter;
e957d772
CW
266 struct i2c_adapter *force_bit;
267 u32 reg0;
f899fc64
CW
268 } *gmbus;
269
ec2a4c3f 270 struct pci_dev *bridge_dev;
8187a2b7 271 struct intel_ring_buffer render_ring;
d1b851fc 272 struct intel_ring_buffer bsd_ring;
549f7365 273 struct intel_ring_buffer blt_ring;
6f392d54 274 uint32_t next_seqno;
1da177e4 275
9c8da5eb 276 drm_dma_handle_t *status_page_dmah;
e552eb70 277 void *seqno_page;
1da177e4 278 dma_addr_t dma_status_page;
0a3e67a4 279 uint32_t counter;
e552eb70 280 unsigned int seqno_gfx_addr;
dc7a9319 281 drm_local_map_t hws_map;
05394f39
CW
282 struct drm_i915_gem_object *seqno_obj;
283 struct drm_i915_gem_object *pwrctx;
284 struct drm_i915_gem_object *renderctx;
1da177e4 285
d7658989
JB
286 struct resource mch_res;
287
a6b54f3f 288 unsigned int cpp;
1da177e4
LT
289 int back_offset;
290 int front_offset;
291 int current_page;
292 int page_flipping;
1da177e4 293
1da177e4 294 atomic_t irq_received;
ed4cb414
EA
295 /** Protects user_irq_refcount and irq_mask_reg */
296 spinlock_t user_irq_lock;
9d34e5db 297 u32 trace_irq_seqno;
ed4cb414
EA
298 /** Cached value of IMR to avoid reads in updating the bitfield */
299 u32 irq_mask_reg;
7c463586 300 u32 pipestat[2];
f2b115e6 301 /** splitted irq regs for graphics and display engine on Ironlake,
036a4a7d
ZW
302 irq_mask_reg is still used for display irq. */
303 u32 gt_irq_mask_reg;
304 u32 gt_irq_enable_reg;
305 u32 de_irq_enable_reg;
c650156a
ZW
306 u32 pch_irq_mask_reg;
307 u32 pch_irq_enable_reg;
1da177e4 308
5ca58282
JB
309 u32 hotplug_supported_mask;
310 struct work_struct hotplug_work;
311
1da177e4
LT
312 int tex_lru_log_granularity;
313 int allow_batchbuffer;
314 struct mem_block *agp_heap;
0d6aa60b 315 unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
702880f2 316 int vblank_pipe;
a3524f1b 317 int num_pipe;
a6b54f3f 318
f65d9421 319 /* For hangcheck timer */
b3b079db 320#define DRM_I915_HANGCHECK_PERIOD 250 /* in ms */
f65d9421
BG
321 struct timer_list hangcheck_timer;
322 int hangcheck_count;
323 uint32_t last_acthd;
cbb465e7
CW
324 uint32_t last_instdone;
325 uint32_t last_instdone1;
f65d9421 326
80824003
JB
327 unsigned long cfb_size;
328 unsigned long cfb_pitch;
bed4a673 329 unsigned long cfb_offset;
80824003
JB
330 int cfb_fence;
331 int cfb_plane;
bed4a673 332 int cfb_y;
80824003 333
79e53945
JB
334 int irq_enabled;
335
8ee1c3db
MG
336 struct intel_opregion opregion;
337
02e792fb
DV
338 /* overlay */
339 struct intel_overlay *overlay;
340
79e53945 341 /* LVDS info */
a9573556 342 int backlight_level; /* restore backlight to this value */
79e53945 343 struct drm_display_mode *panel_fixed_mode;
88631706
ML
344 struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */
345 struct drm_display_mode *sdvo_lvds_vbt_mode; /* if any */
79e53945
JB
346
347 /* Feature bits from the VBIOS */
95281e35
HE
348 unsigned int int_tv_support:1;
349 unsigned int lvds_dither:1;
350 unsigned int lvds_vbt:1;
351 unsigned int int_crt_support:1;
43565a06
KH
352 unsigned int lvds_use_ssc:1;
353 int lvds_ssc_freq;
5ceb0f9b 354 struct {
9f0e7ff4
JB
355 int rate;
356 int lanes;
357 int preemphasis;
358 int vswing;
359
360 bool initialized;
361 bool support;
362 int bpp;
363 struct edp_power_seq pps;
5ceb0f9b 364 } edp;
89667383 365 bool no_aux_handshake;
79e53945 366
c1c7af60
JB
367 struct notifier_block lid_notifier;
368
f899fc64 369 int crt_ddc_pin;
de151cf6
JB
370 struct drm_i915_fence_reg fence_regs[16]; /* assume 965 */
371 int fence_reg_start; /* 4 if userland hasn't ioctl'd us yet */
372 int num_fence_regs; /* 8 on pre-965, 16 otherwise */
373
95534263 374 unsigned int fsb_freq, mem_freq, is_ddr3;
7662c8bd 375
63eeaf38
JB
376 spinlock_t error_lock;
377 struct drm_i915_error_state *first_error;
8a905236 378 struct work_struct error_work;
30dbf0c0 379 struct completion error_completion;
9c9fe1f8 380 struct workqueue_struct *wq;
63eeaf38 381
e70236a8
JB
382 /* Display functions */
383 struct drm_i915_display_funcs display;
384
3bad0781
ZW
385 /* PCH chipset type */
386 enum intel_pch pch_type;
387
b690e96c
JB
388 unsigned long quirks;
389
ba8bbcf6 390 /* Register state */
c9354c85 391 bool modeset_on_lid;
ba8bbcf6
JB
392 u8 saveLBB;
393 u32 saveDSPACNTR;
394 u32 saveDSPBCNTR;
e948e994 395 u32 saveDSPARB;
461cba2d 396 u32 saveHWS;
ba8bbcf6
JB
397 u32 savePIPEACONF;
398 u32 savePIPEBCONF;
399 u32 savePIPEASRC;
400 u32 savePIPEBSRC;
401 u32 saveFPA0;
402 u32 saveFPA1;
403 u32 saveDPLL_A;
404 u32 saveDPLL_A_MD;
405 u32 saveHTOTAL_A;
406 u32 saveHBLANK_A;
407 u32 saveHSYNC_A;
408 u32 saveVTOTAL_A;
409 u32 saveVBLANK_A;
410 u32 saveVSYNC_A;
411 u32 saveBCLRPAT_A;
5586c8bc 412 u32 saveTRANSACONF;
42048781
ZW
413 u32 saveTRANS_HTOTAL_A;
414 u32 saveTRANS_HBLANK_A;
415 u32 saveTRANS_HSYNC_A;
416 u32 saveTRANS_VTOTAL_A;
417 u32 saveTRANS_VBLANK_A;
418 u32 saveTRANS_VSYNC_A;
0da3ea12 419 u32 savePIPEASTAT;
ba8bbcf6
JB
420 u32 saveDSPASTRIDE;
421 u32 saveDSPASIZE;
422 u32 saveDSPAPOS;
585fb111 423 u32 saveDSPAADDR;
ba8bbcf6
JB
424 u32 saveDSPASURF;
425 u32 saveDSPATILEOFF;
426 u32 savePFIT_PGM_RATIOS;
0eb96d6e 427 u32 saveBLC_HIST_CTL;
ba8bbcf6
JB
428 u32 saveBLC_PWM_CTL;
429 u32 saveBLC_PWM_CTL2;
42048781
ZW
430 u32 saveBLC_CPU_PWM_CTL;
431 u32 saveBLC_CPU_PWM_CTL2;
ba8bbcf6
JB
432 u32 saveFPB0;
433 u32 saveFPB1;
434 u32 saveDPLL_B;
435 u32 saveDPLL_B_MD;
436 u32 saveHTOTAL_B;
437 u32 saveHBLANK_B;
438 u32 saveHSYNC_B;
439 u32 saveVTOTAL_B;
440 u32 saveVBLANK_B;
441 u32 saveVSYNC_B;
442 u32 saveBCLRPAT_B;
5586c8bc 443 u32 saveTRANSBCONF;
42048781
ZW
444 u32 saveTRANS_HTOTAL_B;
445 u32 saveTRANS_HBLANK_B;
446 u32 saveTRANS_HSYNC_B;
447 u32 saveTRANS_VTOTAL_B;
448 u32 saveTRANS_VBLANK_B;
449 u32 saveTRANS_VSYNC_B;
0da3ea12 450 u32 savePIPEBSTAT;
ba8bbcf6
JB
451 u32 saveDSPBSTRIDE;
452 u32 saveDSPBSIZE;
453 u32 saveDSPBPOS;
585fb111 454 u32 saveDSPBADDR;
ba8bbcf6
JB
455 u32 saveDSPBSURF;
456 u32 saveDSPBTILEOFF;
585fb111
JB
457 u32 saveVGA0;
458 u32 saveVGA1;
459 u32 saveVGA_PD;
ba8bbcf6
JB
460 u32 saveVGACNTRL;
461 u32 saveADPA;
462 u32 saveLVDS;
585fb111
JB
463 u32 savePP_ON_DELAYS;
464 u32 savePP_OFF_DELAYS;
ba8bbcf6
JB
465 u32 saveDVOA;
466 u32 saveDVOB;
467 u32 saveDVOC;
468 u32 savePP_ON;
469 u32 savePP_OFF;
470 u32 savePP_CONTROL;
585fb111 471 u32 savePP_DIVISOR;
ba8bbcf6
JB
472 u32 savePFIT_CONTROL;
473 u32 save_palette_a[256];
474 u32 save_palette_b[256];
06027f91 475 u32 saveDPFC_CB_BASE;
ba8bbcf6
JB
476 u32 saveFBC_CFB_BASE;
477 u32 saveFBC_LL_BASE;
478 u32 saveFBC_CONTROL;
479 u32 saveFBC_CONTROL2;
0da3ea12
JB
480 u32 saveIER;
481 u32 saveIIR;
482 u32 saveIMR;
42048781
ZW
483 u32 saveDEIER;
484 u32 saveDEIMR;
485 u32 saveGTIER;
486 u32 saveGTIMR;
487 u32 saveFDI_RXA_IMR;
488 u32 saveFDI_RXB_IMR;
1f84e550 489 u32 saveCACHE_MODE_0;
1f84e550 490 u32 saveMI_ARB_STATE;
ba8bbcf6
JB
491 u32 saveSWF0[16];
492 u32 saveSWF1[16];
493 u32 saveSWF2[3];
494 u8 saveMSR;
495 u8 saveSR[8];
123f794f 496 u8 saveGR[25];
ba8bbcf6 497 u8 saveAR_INDEX;
a59e122a 498 u8 saveAR[21];
ba8bbcf6 499 u8 saveDACMASK;
a59e122a 500 u8 saveCR[37];
79f11c19 501 uint64_t saveFENCE[16];
1fd1c624
EA
502 u32 saveCURACNTR;
503 u32 saveCURAPOS;
504 u32 saveCURABASE;
505 u32 saveCURBCNTR;
506 u32 saveCURBPOS;
507 u32 saveCURBBASE;
508 u32 saveCURSIZE;
a4fc5ed6
KP
509 u32 saveDP_B;
510 u32 saveDP_C;
511 u32 saveDP_D;
512 u32 savePIPEA_GMCH_DATA_M;
513 u32 savePIPEB_GMCH_DATA_M;
514 u32 savePIPEA_GMCH_DATA_N;
515 u32 savePIPEB_GMCH_DATA_N;
516 u32 savePIPEA_DP_LINK_M;
517 u32 savePIPEB_DP_LINK_M;
518 u32 savePIPEA_DP_LINK_N;
519 u32 savePIPEB_DP_LINK_N;
42048781
ZW
520 u32 saveFDI_RXA_CTL;
521 u32 saveFDI_TXA_CTL;
522 u32 saveFDI_RXB_CTL;
523 u32 saveFDI_TXB_CTL;
524 u32 savePFA_CTL_1;
525 u32 savePFB_CTL_1;
526 u32 savePFA_WIN_SZ;
527 u32 savePFB_WIN_SZ;
528 u32 savePFA_WIN_POS;
529 u32 savePFB_WIN_POS;
5586c8bc
ZW
530 u32 savePCH_DREF_CONTROL;
531 u32 saveDISP_ARB_CTL;
532 u32 savePIPEA_DATA_M1;
533 u32 savePIPEA_DATA_N1;
534 u32 savePIPEA_LINK_M1;
535 u32 savePIPEA_LINK_N1;
536 u32 savePIPEB_DATA_M1;
537 u32 savePIPEB_DATA_N1;
538 u32 savePIPEB_LINK_M1;
539 u32 savePIPEB_LINK_N1;
b5b72e89 540 u32 saveMCHBAR_RENDER_STANDBY;
673a394b
EA
541
542 struct {
19966754 543 /** Bridge to intel-gtt-ko */
c64f7ba5 544 const struct intel_gtt *gtt;
19966754 545 /** Memory allocator for GTT stolen memory */
fe669bf8 546 struct drm_mm stolen;
19966754 547 /** Memory allocator for GTT */
673a394b 548 struct drm_mm gtt_space;
93a37f20
DV
549 /** List of all objects in gtt_space. Used to restore gtt
550 * mappings on resume */
551 struct list_head gtt_list;
a6e0aa42
DV
552 /** End of mappable part of GTT */
553 unsigned long gtt_mappable_end;
673a394b 554
0839ccb8 555 struct io_mapping *gtt_mapping;
ab657db1 556 int gtt_mtrr;
0839ccb8 557
17250b71 558 struct shrinker inactive_shrinker;
31169714 559
69dc4987
CW
560 /**
561 * List of objects currently involved in rendering.
562 *
563 * Includes buffers having the contents of their GPU caches
564 * flushed, not necessarily primitives. last_rendering_seqno
565 * represents when the rendering involved will be completed.
566 *
567 * A reference is held on the buffer while on this list.
568 */
569 struct list_head active_list;
570
673a394b
EA
571 /**
572 * List of objects which are not in the ringbuffer but which
573 * still have a write_domain which needs to be flushed before
574 * unbinding.
575 *
ce44b0ea
EA
576 * last_rendering_seqno is 0 while an object is in this list.
577 *
673a394b
EA
578 * A reference is held on the buffer while on this list.
579 */
580 struct list_head flushing_list;
581
582 /**
583 * LRU list of objects which are not in the ringbuffer and
584 * are ready to unbind, but are still in the GTT.
585 *
ce44b0ea
EA
586 * last_rendering_seqno is 0 while an object is in this list.
587 *
673a394b
EA
588 * A reference is not held on the buffer while on this list,
589 * as merely being GTT-bound shouldn't prevent its being
590 * freed, and we'll pull it off the list in the free path.
591 */
592 struct list_head inactive_list;
593
f13d3f73
CW
594 /**
595 * LRU list of objects which are not in the ringbuffer but
596 * are still pinned in the GTT.
597 */
598 struct list_head pinned_list;
599
a09ba7fa
EA
600 /** LRU list of objects with fence regs on them. */
601 struct list_head fence_list;
602
be72615b
CW
603 /**
604 * List of objects currently pending being freed.
605 *
606 * These objects are no longer in use, but due to a signal
607 * we were prevented from freeing them at the appointed time.
608 */
609 struct list_head deferred_free_list;
610
673a394b
EA
611 /**
612 * We leave the user IRQ off as much as possible,
613 * but this means that requests will finish and never
614 * be retired once the system goes idle. Set a timer to
615 * fire periodically while the ring is running. When it
616 * fires, go retire requests.
617 */
618 struct delayed_work retire_work;
619
673a394b
EA
620 /**
621 * Flag if the X Server, and thus DRM, is not currently in
622 * control of the device.
623 *
624 * This is set between LeaveVT and EnterVT. It needs to be
625 * replaced with a semaphore. It also needs to be
626 * transitioned away from for kernel modesetting.
627 */
628 int suspended;
629
630 /**
631 * Flag if the hardware appears to be wedged.
632 *
633 * This is set when attempts to idle the device timeout.
634 * It prevents command submission from occuring and makes
635 * every pending request fail
636 */
ba1234d1 637 atomic_t wedged;
673a394b
EA
638
639 /** Bit 6 swizzling required for X tiling */
640 uint32_t bit_6_swizzle_x;
641 /** Bit 6 swizzling required for Y tiling */
642 uint32_t bit_6_swizzle_y;
71acb5eb
DA
643
644 /* storage for physical objects */
645 struct drm_i915_gem_phys_object *phys_objs[I915_MAX_PHYS_OBJECT];
9220434a 646
73aa808f
CW
647 /* accounting, useful for userland debugging */
648 size_t object_memory;
649 size_t pin_memory;
650 size_t gtt_memory;
fb7d516a
DV
651 size_t gtt_mappable_memory;
652 size_t mappable_gtt_used;
653 size_t mappable_gtt_total;
73aa808f
CW
654 size_t gtt_total;
655 u32 object_count;
656 u32 pin_count;
fb7d516a 657 u32 gtt_mappable_count;
73aa808f 658 u32 gtt_count;
673a394b 659 } mm;
9b9d172d 660 struct sdvo_device_mapping sdvo_mappings[2];
a3e17eb8
ZY
661 /* indicate whether the LVDS_BORDER should be enabled or not */
662 unsigned int lvds_border_bits;
1d8e1c75
CW
663 /* Panel fitter placement and size for Ironlake+ */
664 u32 pch_pf_pos, pch_pf_size;
652c393a 665
6b95a207
KH
666 struct drm_crtc *plane_to_crtc_mapping[2];
667 struct drm_crtc *pipe_to_crtc_mapping[2];
668 wait_queue_head_t pending_flip_queue;
1afe3e9d 669 bool flip_pending_is_done;
6b95a207 670
652c393a
JB
671 /* Reclocking support */
672 bool render_reclock_avail;
673 bool lvds_downclock_avail;
18f9ed12
ZY
674 /* indicates the reduced downclock for LVDS*/
675 int lvds_downclock;
652c393a
JB
676 struct work_struct idle_work;
677 struct timer_list idle_timer;
678 bool busy;
679 u16 orig_clock;
6363ee6f
ZY
680 int child_dev_num;
681 struct child_device_config *child_dev;
a2565377 682 struct drm_connector *int_lvds_connector;
f97108d1 683
c4804411 684 bool mchbar_need_disable;
f97108d1
JB
685
686 u8 cur_delay;
687 u8 min_delay;
688 u8 max_delay;
7648fa99
JB
689 u8 fmax;
690 u8 fstart;
691
05394f39
CW
692 u64 last_count1;
693 unsigned long last_time1;
694 u64 last_count2;
695 struct timespec last_time2;
696 unsigned long gfx_power;
697 int c_m;
698 int r_t;
699 u8 corr;
7648fa99 700 spinlock_t *mchdev_lock;
b5e50c3f
JB
701
702 enum no_fbc_reason no_fbc_reason;
38651674 703
20bf377e
JB
704 struct drm_mm_node *compressed_fb;
705 struct drm_mm_node *compressed_llb;
34dc4d44 706
ae681d96
CW
707 unsigned long last_gpu_reset;
708
8be48d92
DA
709 /* list of fbdev register on this device */
710 struct intel_fbdev *fbdev;
1da177e4
LT
711} drm_i915_private_t;
712
673a394b 713struct drm_i915_gem_object {
c397b908 714 struct drm_gem_object base;
673a394b
EA
715
716 /** Current space allocated to this object in the GTT, if any. */
717 struct drm_mm_node *gtt_space;
93a37f20 718 struct list_head gtt_list;
673a394b
EA
719
720 /** This object's place on the active/flushing/inactive lists */
69dc4987
CW
721 struct list_head ring_list;
722 struct list_head mm_list;
99fcb766
DV
723 /** This object's place on GPU write list */
724 struct list_head gpu_write_list;
cd377ea9
CW
725 /** This object's place on eviction list */
726 struct list_head evict_list;
673a394b
EA
727
728 /**
729 * This is set if the object is on the active or flushing lists
730 * (has pending rendering), and is not set if it's on inactive (ready
731 * to be unbound).
732 */
778c3544 733 unsigned int active : 1;
673a394b
EA
734
735 /**
736 * This is set if the object has been written to since last bound
737 * to the GTT
738 */
778c3544
DV
739 unsigned int dirty : 1;
740
741 /**
742 * Fence register bits (if any) for this object. Will be set
743 * as needed when mapped into the GTT.
744 * Protected by dev->struct_mutex.
745 *
746 * Size: 4 bits for 16 fences + sign (for FENCE_REG_NONE)
747 */
11824e8c 748 signed int fence_reg : 5;
778c3544
DV
749
750 /**
751 * Used for checking the object doesn't appear more than once
752 * in an execbuffer object list.
753 */
754 unsigned int in_execbuffer : 1;
755
756 /**
757 * Advice: are the backing pages purgeable?
758 */
759 unsigned int madv : 2;
760
778c3544
DV
761 /**
762 * Current tiling mode for the object.
763 */
764 unsigned int tiling_mode : 2;
765
766 /** How many users have pinned this object in GTT space. The following
767 * users can each hold at most one reference: pwrite/pread, pin_ioctl
768 * (via user_pin_count), execbuffer (objects are not allowed multiple
769 * times for the same batchbuffer), and the framebuffer code. When
770 * switching/pageflipping, the framebuffer code has at most two buffers
771 * pinned per crtc.
772 *
773 * In the worst case this is 1 + 1 + 1 + 2*2 = 7. That would fit into 3
774 * bits with absolutely no headroom. So use 4 bits. */
11824e8c 775 unsigned int pin_count : 4;
778c3544 776#define DRM_I915_GEM_OBJECT_MAX_PIN_COUNT 0xf
673a394b 777
75e9e915
DV
778 /**
779 * Is the object at the current location in the gtt mappable and
780 * fenceable? Used to avoid costly recalculations.
781 */
782 unsigned int map_and_fenceable : 1;
783
fb7d516a
DV
784 /**
785 * Whether the current gtt mapping needs to be mappable (and isn't just
786 * mappable by accident). Track pin and fault separate for a more
787 * accurate mappable working set.
788 */
789 unsigned int fault_mappable : 1;
790 unsigned int pin_mappable : 1;
791
856fa198 792 struct page **pages;
673a394b 793
185cbcb3
DV
794 /**
795 * DMAR support
796 */
797 struct scatterlist *sg_list;
798 int num_sg;
799
673a394b
EA
800 /**
801 * Current offset of the object in GTT space.
802 *
803 * This is the same as gtt_space->start
804 */
805 uint32_t gtt_offset;
e67b8ce1 806
852835f3
ZN
807 /* Which ring is refering to is this object */
808 struct intel_ring_buffer *ring;
809
673a394b
EA
810 /** Breadcrumb of last rendering to the buffer. */
811 uint32_t last_rendering_seqno;
812
778c3544 813 /** Current tiling stride for the object, if it's tiled. */
de151cf6 814 uint32_t stride;
673a394b 815
280b713b 816 /** Record of address bit 17 of each page at last unbind. */
d312ec25 817 unsigned long *bit_17;
280b713b 818
ba1eb1d8
KP
819 /** AGP mapping type (AGP_USER_MEMORY or AGP_USER_CACHED_MEMORY */
820 uint32_t agp_type;
821
673a394b 822 /**
e47c68e9
EA
823 * If present, while GEM_DOMAIN_CPU is in the read domain this array
824 * flags which individual pages are valid.
673a394b
EA
825 */
826 uint8_t *page_cpu_valid;
79e53945
JB
827
828 /** User space pin count and filp owning the pin */
829 uint32_t user_pin_count;
830 struct drm_file *pin_filp;
71acb5eb
DA
831
832 /** for phy allocated objects */
833 struct drm_i915_gem_phys_object *phys_obj;
b70d11da 834
6b95a207
KH
835 /**
836 * Number of crtcs where this object is currently the fb, but
837 * will be page flipped away on the next vblank. When it
838 * reaches 0, dev_priv->pending_flip_queue will be woken up.
839 */
840 atomic_t pending_flip;
673a394b
EA
841};
842
62b8b215 843#define to_intel_bo(x) container_of(x, struct drm_i915_gem_object, base)
23010e43 844
673a394b
EA
845/**
846 * Request queue structure.
847 *
848 * The request queue allows us to note sequence numbers that have been emitted
849 * and may be associated with active buffers to be retired.
850 *
851 * By keeping this list, we can avoid having to do questionable
852 * sequence-number comparisons on buffer last_rendering_seqnos, and associate
853 * an emission time with seqnos for tracking how far ahead of the GPU we are.
854 */
855struct drm_i915_gem_request {
852835f3
ZN
856 /** On Which ring this request was generated */
857 struct intel_ring_buffer *ring;
858
673a394b
EA
859 /** GEM sequence number associated with this request. */
860 uint32_t seqno;
861
862 /** Time at which this request was emitted, in jiffies. */
863 unsigned long emitted_jiffies;
864
b962442e 865 /** global list entry for this request */
673a394b 866 struct list_head list;
b962442e 867
f787a5f5 868 struct drm_i915_file_private *file_priv;
b962442e
EA
869 /** file_priv list entry for this request */
870 struct list_head client_list;
673a394b
EA
871};
872
873struct drm_i915_file_private {
874 struct {
1c25595f 875 struct spinlock lock;
b962442e 876 struct list_head request_list;
673a394b
EA
877 } mm;
878};
879
79e53945
JB
880enum intel_chip_family {
881 CHIP_I8XX = 0x01,
882 CHIP_I9XX = 0x02,
883 CHIP_I915 = 0x04,
884 CHIP_I965 = 0x08,
885};
886
cae5852d
ZN
887#define INTEL_INFO(dev) (((struct drm_i915_private *) (dev)->dev_private)->info)
888
889#define IS_I830(dev) ((dev)->pci_device == 0x3577)
890#define IS_845G(dev) ((dev)->pci_device == 0x2562)
891#define IS_I85X(dev) (INTEL_INFO(dev)->is_i85x)
892#define IS_I865G(dev) ((dev)->pci_device == 0x2572)
893#define IS_I915G(dev) (INTEL_INFO(dev)->is_i915g)
894#define IS_I915GM(dev) ((dev)->pci_device == 0x2592)
895#define IS_I945G(dev) ((dev)->pci_device == 0x2772)
896#define IS_I945GM(dev) (INTEL_INFO(dev)->is_i945gm)
897#define IS_BROADWATER(dev) (INTEL_INFO(dev)->is_broadwater)
898#define IS_CRESTLINE(dev) (INTEL_INFO(dev)->is_crestline)
899#define IS_GM45(dev) ((dev)->pci_device == 0x2A42)
900#define IS_G4X(dev) (INTEL_INFO(dev)->is_g4x)
901#define IS_PINEVIEW_G(dev) ((dev)->pci_device == 0xa001)
902#define IS_PINEVIEW_M(dev) ((dev)->pci_device == 0xa011)
903#define IS_PINEVIEW(dev) (INTEL_INFO(dev)->is_pineview)
904#define IS_G33(dev) (INTEL_INFO(dev)->is_g33)
905#define IS_IRONLAKE_D(dev) ((dev)->pci_device == 0x0042)
906#define IS_IRONLAKE_M(dev) ((dev)->pci_device == 0x0046)
907#define IS_MOBILE(dev) (INTEL_INFO(dev)->is_mobile)
908
909#define IS_GEN2(dev) (INTEL_INFO(dev)->gen == 2)
910#define IS_GEN3(dev) (INTEL_INFO(dev)->gen == 3)
911#define IS_GEN4(dev) (INTEL_INFO(dev)->gen == 4)
912#define IS_GEN5(dev) (INTEL_INFO(dev)->gen == 5)
913#define IS_GEN6(dev) (INTEL_INFO(dev)->gen == 6)
914
915#define HAS_BSD(dev) (INTEL_INFO(dev)->has_bsd_ring)
916#define HAS_BLT(dev) (INTEL_INFO(dev)->has_blt_ring)
917#define I915_NEED_GFX_HWS(dev) (INTEL_INFO(dev)->need_gfx_hws)
918
05394f39 919#define HAS_OVERLAY(dev) (INTEL_INFO(dev)->has_overlay)
cae5852d
ZN
920#define OVERLAY_NEEDS_PHYSICAL(dev) (INTEL_INFO(dev)->overlay_needs_physical)
921
922/* With the 945 and later, Y tiling got adjusted so that it was 32 128-byte
923 * rows, which changed the alignment requirements and fence programming.
924 */
925#define HAS_128_BYTE_Y_TILING(dev) (!IS_GEN2(dev) && !(IS_I915G(dev) || \
926 IS_I915GM(dev)))
927#define SUPPORTS_DIGITAL_OUTPUTS(dev) (!IS_GEN2(dev) && !IS_PINEVIEW(dev))
928#define SUPPORTS_INTEGRATED_HDMI(dev) (IS_G4X(dev) || IS_GEN5(dev))
929#define SUPPORTS_INTEGRATED_DP(dev) (IS_G4X(dev) || IS_GEN5(dev))
930#define SUPPORTS_EDP(dev) (IS_IRONLAKE_M(dev))
931#define SUPPORTS_TV(dev) (INTEL_INFO(dev)->supports_tv)
932#define I915_HAS_HOTPLUG(dev) (INTEL_INFO(dev)->has_hotplug)
933/* dsparb controlled by hw only */
934#define DSPARB_HWCONTROL(dev) (IS_G4X(dev) || IS_IRONLAKE(dev))
935
936#define HAS_FW_BLC(dev) (INTEL_INFO(dev)->gen > 2)
937#define HAS_PIPE_CXSR(dev) (INTEL_INFO(dev)->has_pipe_cxsr)
938#define I915_HAS_FBC(dev) (INTEL_INFO(dev)->has_fbc)
939#define I915_HAS_RC6(dev) (INTEL_INFO(dev)->has_rc6)
940
941#define HAS_PCH_SPLIT(dev) (IS_GEN5(dev) || IS_GEN6(dev))
942#define HAS_PIPE_CONTROL(dev) (IS_GEN5(dev) || IS_GEN6(dev))
943
944#define INTEL_PCH_TYPE(dev) (((struct drm_i915_private *)(dev)->dev_private)->pch_type)
945#define HAS_PCH_CPT(dev) (INTEL_PCH_TYPE(dev) == PCH_CPT)
946#define HAS_PCH_IBX(dev) (INTEL_PCH_TYPE(dev) == PCH_IBX)
947
05394f39
CW
948#include "i915_trace.h"
949
c153f45f 950extern struct drm_ioctl_desc i915_ioctls[];
b3a83639 951extern int i915_max_ioctl;
79e53945 952extern unsigned int i915_fbpercrtc;
652c393a 953extern unsigned int i915_powersave;
33814341 954extern unsigned int i915_lvds_downclock;
b3a83639 955
6a9ee8af
DA
956extern int i915_suspend(struct drm_device *dev, pm_message_t state);
957extern int i915_resume(struct drm_device *dev);
1341d655
BG
958extern void i915_save_display(struct drm_device *dev);
959extern void i915_restore_display(struct drm_device *dev);
7c1c2871
DA
960extern int i915_master_create(struct drm_device *dev, struct drm_master *master);
961extern void i915_master_destroy(struct drm_device *dev, struct drm_master *master);
962
1da177e4 963 /* i915_dma.c */
84b1fd10 964extern void i915_kernel_lost_context(struct drm_device * dev);
22eae947 965extern int i915_driver_load(struct drm_device *, unsigned long flags);
ba8bbcf6 966extern int i915_driver_unload(struct drm_device *);
673a394b 967extern int i915_driver_open(struct drm_device *dev, struct drm_file *file_priv);
84b1fd10 968extern void i915_driver_lastclose(struct drm_device * dev);
6c340eac
EA
969extern void i915_driver_preclose(struct drm_device *dev,
970 struct drm_file *file_priv);
673a394b
EA
971extern void i915_driver_postclose(struct drm_device *dev,
972 struct drm_file *file_priv);
84b1fd10 973extern int i915_driver_device_is_agp(struct drm_device * dev);
0d6aa60b
DA
974extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
975 unsigned long arg);
673a394b 976extern int i915_emit_box(struct drm_device *dev,
201361a5 977 struct drm_clip_rect *boxes,
673a394b 978 int i, int DR1, int DR4);
f803aa55 979extern int i915_reset(struct drm_device *dev, u8 flags);
7648fa99
JB
980extern unsigned long i915_chipset_val(struct drm_i915_private *dev_priv);
981extern unsigned long i915_mch_val(struct drm_i915_private *dev_priv);
982extern unsigned long i915_gfx_val(struct drm_i915_private *dev_priv);
983extern void i915_update_gfx_val(struct drm_i915_private *dev_priv);
984
af6061af 985
1da177e4 986/* i915_irq.c */
f65d9421 987void i915_hangcheck_elapsed(unsigned long data);
527f9e90 988void i915_handle_error(struct drm_device *dev, bool wedged);
c153f45f
EA
989extern int i915_irq_emit(struct drm_device *dev, void *data,
990 struct drm_file *file_priv);
991extern int i915_irq_wait(struct drm_device *dev, void *data,
992 struct drm_file *file_priv);
9d34e5db 993void i915_trace_irq_get(struct drm_device *dev, u32 seqno);
79e53945 994extern void i915_enable_interrupt (struct drm_device *dev);
1da177e4
LT
995
996extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
84b1fd10 997extern void i915_driver_irq_preinstall(struct drm_device * dev);
0a3e67a4 998extern int i915_driver_irq_postinstall(struct drm_device *dev);
84b1fd10 999extern void i915_driver_irq_uninstall(struct drm_device * dev);
c153f45f
EA
1000extern int i915_vblank_pipe_set(struct drm_device *dev, void *data,
1001 struct drm_file *file_priv);
1002extern int i915_vblank_pipe_get(struct drm_device *dev, void *data,
1003 struct drm_file *file_priv);
0a3e67a4
JB
1004extern int i915_enable_vblank(struct drm_device *dev, int crtc);
1005extern void i915_disable_vblank(struct drm_device *dev, int crtc);
1006extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc);
9880b7a5 1007extern u32 gm45_get_vblank_counter(struct drm_device *dev, int crtc);
c153f45f
EA
1008extern int i915_vblank_swap(struct drm_device *dev, void *data,
1009 struct drm_file *file_priv);
8ee1c3db 1010extern void i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask);
62fdfeaf 1011extern void i915_disable_irq(drm_i915_private_t *dev_priv, u32 mask);
8187a2b7
ZN
1012extern void ironlake_enable_graphics_irq(drm_i915_private_t *dev_priv,
1013 u32 mask);
1014extern void ironlake_disable_graphics_irq(drm_i915_private_t *dev_priv,
1015 u32 mask);
1da177e4 1016
7c463586
KP
1017void
1018i915_enable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask);
1019
1020void
1021i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask);
1022
01c66889
ZY
1023void intel_enable_asle (struct drm_device *dev);
1024
3bd3c932
CW
1025#ifdef CONFIG_DEBUG_FS
1026extern void i915_destroy_error_state(struct drm_device *dev);
1027#else
1028#define i915_destroy_error_state(x)
1029#endif
1030
7c463586 1031
1da177e4 1032/* i915_mem.c */
c153f45f
EA
1033extern int i915_mem_alloc(struct drm_device *dev, void *data,
1034 struct drm_file *file_priv);
1035extern int i915_mem_free(struct drm_device *dev, void *data,
1036 struct drm_file *file_priv);
1037extern int i915_mem_init_heap(struct drm_device *dev, void *data,
1038 struct drm_file *file_priv);
1039extern int i915_mem_destroy_heap(struct drm_device *dev, void *data,
1040 struct drm_file *file_priv);
1da177e4 1041extern void i915_mem_takedown(struct mem_block **heap);
84b1fd10 1042extern void i915_mem_release(struct drm_device * dev,
6c340eac 1043 struct drm_file *file_priv, struct mem_block *heap);
673a394b 1044/* i915_gem.c */
30dbf0c0 1045int i915_gem_check_is_wedged(struct drm_device *dev);
673a394b
EA
1046int i915_gem_init_ioctl(struct drm_device *dev, void *data,
1047 struct drm_file *file_priv);
1048int i915_gem_create_ioctl(struct drm_device *dev, void *data,
1049 struct drm_file *file_priv);
1050int i915_gem_pread_ioctl(struct drm_device *dev, void *data,
1051 struct drm_file *file_priv);
1052int i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
1053 struct drm_file *file_priv);
1054int i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
1055 struct drm_file *file_priv);
de151cf6
JB
1056int i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
1057 struct drm_file *file_priv);
673a394b
EA
1058int i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
1059 struct drm_file *file_priv);
1060int i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
1061 struct drm_file *file_priv);
1062int i915_gem_execbuffer(struct drm_device *dev, void *data,
1063 struct drm_file *file_priv);
76446cac
JB
1064int i915_gem_execbuffer2(struct drm_device *dev, void *data,
1065 struct drm_file *file_priv);
673a394b
EA
1066int i915_gem_pin_ioctl(struct drm_device *dev, void *data,
1067 struct drm_file *file_priv);
1068int i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
1069 struct drm_file *file_priv);
1070int i915_gem_busy_ioctl(struct drm_device *dev, void *data,
1071 struct drm_file *file_priv);
1072int i915_gem_throttle_ioctl(struct drm_device *dev, void *data,
1073 struct drm_file *file_priv);
3ef94daa
CW
1074int i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
1075 struct drm_file *file_priv);
673a394b
EA
1076int i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
1077 struct drm_file *file_priv);
1078int i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
1079 struct drm_file *file_priv);
1080int i915_gem_set_tiling(struct drm_device *dev, void *data,
1081 struct drm_file *file_priv);
1082int i915_gem_get_tiling(struct drm_device *dev, void *data,
1083 struct drm_file *file_priv);
5a125c3c
EA
1084int i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
1085 struct drm_file *file_priv);
673a394b 1086void i915_gem_load(struct drm_device *dev);
673a394b 1087int i915_gem_init_object(struct drm_gem_object *obj);
05394f39
CW
1088struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
1089 size_t size);
673a394b 1090void i915_gem_free_object(struct drm_gem_object *obj);
05394f39
CW
1091int i915_gem_object_pin(struct drm_i915_gem_object *obj,
1092 uint32_t alignment,
75e9e915 1093 bool map_and_fenceable);
05394f39
CW
1094void i915_gem_object_unpin(struct drm_i915_gem_object *obj);
1095int i915_gem_object_unbind(struct drm_i915_gem_object *obj);
1096void i915_gem_release_mmap(struct drm_i915_gem_object *obj);
673a394b 1097void i915_gem_lastclose(struct drm_device *dev);
f787a5f5
CW
1098
1099/**
1100 * Returns true if seq1 is later than seq2.
1101 */
1102static inline bool
1103i915_seqno_passed(uint32_t seq1, uint32_t seq2)
1104{
1105 return (int32_t)(seq1 - seq2) >= 0;
1106}
1107
05394f39 1108int i915_gem_object_get_fence_reg(struct drm_i915_gem_object *obj,
2cf34d7b 1109 bool interruptible);
05394f39 1110int i915_gem_object_put_fence_reg(struct drm_i915_gem_object *obj,
2cf34d7b 1111 bool interruptible);
b09a1fec 1112void i915_gem_retire_requests(struct drm_device *dev);
069efc1d 1113void i915_gem_reset(struct drm_device *dev);
05394f39
CW
1114void i915_gem_clflush_object(struct drm_i915_gem_object *obj);
1115int i915_gem_object_set_domain(struct drm_i915_gem_object *obj,
79e53945
JB
1116 uint32_t read_domains,
1117 uint32_t write_domain);
85345517
CW
1118int i915_gem_object_flush_gpu(struct drm_i915_gem_object *obj,
1119 bool interruptible);
79e53945
JB
1120int i915_gem_init_ringbuffer(struct drm_device *dev);
1121void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
1122int i915_gem_do_init(struct drm_device *dev, unsigned long start,
53984635 1123 unsigned long mappable_end, unsigned long end);
b47eb4a2 1124int i915_gpu_idle(struct drm_device *dev);
5669fcac 1125int i915_gem_idle(struct drm_device *dev);
3cce469c
CW
1126int i915_add_request(struct drm_device *dev,
1127 struct drm_file *file_priv,
1128 struct drm_i915_gem_request *request,
1129 struct intel_ring_buffer *ring);
852835f3 1130int i915_do_wait_request(struct drm_device *dev,
8a1a49f9
DV
1131 uint32_t seqno,
1132 bool interruptible,
1133 struct intel_ring_buffer *ring);
de151cf6 1134int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
05394f39 1135int i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj,
79e53945 1136 int write);
05394f39 1137int i915_gem_object_set_to_display_plane(struct drm_i915_gem_object *obj,
48b956c5 1138 bool pipelined);
71acb5eb 1139int i915_gem_attach_phys_object(struct drm_device *dev,
05394f39 1140 struct drm_i915_gem_object *obj,
6eeefaf3
CW
1141 int id,
1142 int align);
71acb5eb 1143void i915_gem_detach_phys_object(struct drm_device *dev,
05394f39 1144 struct drm_i915_gem_object *obj);
71acb5eb 1145void i915_gem_free_all_phys_object(struct drm_device *dev);
05394f39 1146void i915_gem_release(struct drm_device *dev, struct drm_file *file);
673a394b 1147
76aaf220
DV
1148/* i915_gem_gtt.c */
1149void i915_gem_restore_gtt_mappings(struct drm_device *dev);
05394f39
CW
1150int i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj);
1151void i915_gem_gtt_unbind_object(struct drm_i915_gem_object *obj);
76aaf220 1152
b47eb4a2 1153/* i915_gem_evict.c */
a6e0aa42
DV
1154int i915_gem_evict_something(struct drm_device *dev, int min_size,
1155 unsigned alignment, bool mappable);
5eac3ab4
CW
1156int i915_gem_evict_everything(struct drm_device *dev, bool purgeable_only);
1157int i915_gem_evict_inactive(struct drm_device *dev, bool purgeable_only);
b47eb4a2 1158
673a394b
EA
1159/* i915_gem_tiling.c */
1160void i915_gem_detect_bit_6_swizzle(struct drm_device *dev);
05394f39
CW
1161void i915_gem_object_do_bit_17_swizzle(struct drm_i915_gem_object *obj);
1162void i915_gem_object_save_bit_17_swizzle(struct drm_i915_gem_object *obj);
673a394b
EA
1163
1164/* i915_gem_debug.c */
05394f39 1165void i915_gem_dump_object(struct drm_i915_gem_object *obj, int len,
673a394b 1166 const char *where, uint32_t mark);
23bc5982
CW
1167#if WATCH_LISTS
1168int i915_verify_lists(struct drm_device *dev);
673a394b 1169#else
23bc5982 1170#define i915_verify_lists(dev) 0
673a394b 1171#endif
05394f39
CW
1172void i915_gem_object_check_coherency(struct drm_i915_gem_object *obj,
1173 int handle);
1174void i915_gem_dump_object(struct drm_i915_gem_object *obj, int len,
673a394b 1175 const char *where, uint32_t mark);
1da177e4 1176
2017263e 1177/* i915_debugfs.c */
27c202ad
BG
1178int i915_debugfs_init(struct drm_minor *minor);
1179void i915_debugfs_cleanup(struct drm_minor *minor);
2017263e 1180
317c35d1
JB
1181/* i915_suspend.c */
1182extern int i915_save_state(struct drm_device *dev);
1183extern int i915_restore_state(struct drm_device *dev);
0a3e67a4
JB
1184
1185/* i915_suspend.c */
1186extern int i915_save_state(struct drm_device *dev);
1187extern int i915_restore_state(struct drm_device *dev);
317c35d1 1188
f899fc64
CW
1189/* intel_i2c.c */
1190extern int intel_setup_gmbus(struct drm_device *dev);
1191extern void intel_teardown_gmbus(struct drm_device *dev);
e957d772
CW
1192extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
1193extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
b8232e90
CW
1194extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
1195{
1196 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
1197}
f899fc64
CW
1198extern void intel_i2c_reset(struct drm_device *dev);
1199
3b617967 1200/* intel_opregion.c */
44834a67
CW
1201extern int intel_opregion_setup(struct drm_device *dev);
1202#ifdef CONFIG_ACPI
1203extern void intel_opregion_init(struct drm_device *dev);
1204extern void intel_opregion_fini(struct drm_device *dev);
3b617967
CW
1205extern void intel_opregion_asle_intr(struct drm_device *dev);
1206extern void intel_opregion_gse_intr(struct drm_device *dev);
1207extern void intel_opregion_enable_asle(struct drm_device *dev);
65e082c9 1208#else
44834a67
CW
1209static inline void intel_opregion_init(struct drm_device *dev) { return; }
1210static inline void intel_opregion_fini(struct drm_device *dev) { return; }
3b617967
CW
1211static inline void intel_opregion_asle_intr(struct drm_device *dev) { return; }
1212static inline void intel_opregion_gse_intr(struct drm_device *dev) { return; }
1213static inline void intel_opregion_enable_asle(struct drm_device *dev) { return; }
65e082c9 1214#endif
8ee1c3db 1215
723bfd70
JB
1216/* intel_acpi.c */
1217#ifdef CONFIG_ACPI
1218extern void intel_register_dsm_handler(void);
1219extern void intel_unregister_dsm_handler(void);
1220#else
1221static inline void intel_register_dsm_handler(void) { return; }
1222static inline void intel_unregister_dsm_handler(void) { return; }
1223#endif /* CONFIG_ACPI */
1224
79e53945
JB
1225/* modesetting */
1226extern void intel_modeset_init(struct drm_device *dev);
1227extern void intel_modeset_cleanup(struct drm_device *dev);
28d52043 1228extern int intel_modeset_vga_set_state(struct drm_device *dev, bool state);
80824003 1229extern void i8xx_disable_fbc(struct drm_device *dev);
74dff282 1230extern void g4x_disable_fbc(struct drm_device *dev);
b52eb4dc 1231extern void ironlake_disable_fbc(struct drm_device *dev);
ee5382ae
AJ
1232extern void intel_disable_fbc(struct drm_device *dev);
1233extern void intel_enable_fbc(struct drm_crtc *crtc, unsigned long interval);
1234extern bool intel_fbc_enabled(struct drm_device *dev);
7648fa99 1235extern bool ironlake_set_drps(struct drm_device *dev, u8 val);
3bad0781 1236extern void intel_detect_pch (struct drm_device *dev);
e3421a18 1237extern int intel_trans_dp_port_sel (struct drm_crtc *crtc);
3bad0781 1238
6ef3d427 1239/* overlay */
3bd3c932 1240#ifdef CONFIG_DEBUG_FS
6ef3d427
CW
1241extern struct intel_overlay_error_state *intel_overlay_capture_error_state(struct drm_device *dev);
1242extern void intel_overlay_print_error_state(struct seq_file *m, struct intel_overlay_error_state *error);
c4a1d9e4
CW
1243
1244extern struct intel_display_error_state *intel_display_capture_error_state(struct drm_device *dev);
1245extern void intel_display_print_error_state(struct seq_file *m,
1246 struct drm_device *dev,
1247 struct intel_display_error_state *error);
3bd3c932 1248#endif
6ef3d427 1249
546b0974
EA
1250/**
1251 * Lock test for when it's just for synchronization of ring access.
1252 *
1253 * In that case, we don't need to do it when GEM is initialized as nobody else
1254 * has access to the ring.
1255 */
05394f39
CW
1256#define RING_LOCK_TEST_WITH_RETURN(dev, file) do { \
1257 if (((drm_i915_private_t *)dev->dev_private)->render_ring.obj \
8187a2b7 1258 == NULL) \
05394f39 1259 LOCK_TEST_WITH_RETURN(dev, file); \
546b0974
EA
1260} while (0)
1261
cae5852d 1262
5f75377d
KP
1263#define __i915_read(x, y) \
1264static inline u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \
1265 u##x val = read##y(dev_priv->regs + reg); \
1266 trace_i915_reg_rw('R', reg, val, sizeof(val)); \
1267 return val; \
1268}
1269__i915_read(8, b)
1270__i915_read(16, w)
1271__i915_read(32, l)
1272__i915_read(64, q)
1273#undef __i915_read
1274
1275#define __i915_write(x, y) \
1276static inline void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \
1277 trace_i915_reg_rw('W', reg, val, sizeof(val)); \
1278 write##y(val, dev_priv->regs + reg); \
1279}
1280__i915_write(8, b)
1281__i915_write(16, w)
1282__i915_write(32, l)
1283__i915_write(64, q)
1284#undef __i915_write
1285
1286#define I915_READ8(reg) i915_read8(dev_priv, (reg))
1287#define I915_WRITE8(reg, val) i915_write8(dev_priv, (reg), (val))
1288
1289#define I915_READ16(reg) i915_read16(dev_priv, (reg))
1290#define I915_WRITE16(reg, val) i915_write16(dev_priv, (reg), (val))
1291#define I915_READ16_NOTRACE(reg) readw(dev_priv->regs + (reg))
1292#define I915_WRITE16_NOTRACE(reg, val) writew(val, dev_priv->regs + (reg))
1293
1294#define I915_READ(reg) i915_read32(dev_priv, (reg))
1295#define I915_WRITE(reg, val) i915_write32(dev_priv, (reg), (val))
cae5852d
ZN
1296#define I915_READ_NOTRACE(reg) readl(dev_priv->regs + (reg))
1297#define I915_WRITE_NOTRACE(reg, val) writel(val, dev_priv->regs + (reg))
5f75377d
KP
1298
1299#define I915_WRITE64(reg, val) i915_write64(dev_priv, (reg), (val))
1300#define I915_READ64(reg) i915_read64(dev_priv, (reg))
cae5852d
ZN
1301
1302#define POSTING_READ(reg) (void)I915_READ_NOTRACE(reg)
1303#define POSTING_READ16(reg) (void)I915_READ16_NOTRACE(reg)
1304
ba4f01a3 1305
cae5852d
ZN
1306/* On SNB platform, before reading ring registers forcewake bit
1307 * must be set to prevent GT core from power down and stale values being
1308 * returned.
1309 */
1310static inline u32 i915_safe_read(struct drm_i915_private *dev_priv, u32 reg)
1311{
1312 if (IS_GEN6(dev_priv->dev)) {
1313 I915_WRITE_NOTRACE(FORCEWAKE, 1);
1314 POSTING_READ(FORCEWAKE);
1315 /* XXX How long do we really need to wait here?
1316 * Will different registers/engines require different periods?
1317 */
1318 udelay(100);
1319 }
1320 return I915_READ(reg);
1321}
1322
ba4f01a3
YL
1323static inline void
1324i915_write(struct drm_i915_private *dev_priv, u32 reg, u64 val, int len)
1325{
1326 /* Trace down the write operation before the real write */
1327 trace_i915_reg_rw('W', reg, val, len);
1328 switch (len) {
1329 case 8:
1330 writeq(val, dev_priv->regs + reg);
1331 break;
1332 case 4:
1333 writel(val, dev_priv->regs + reg);
1334 break;
1335 case 2:
1336 writew(val, dev_priv->regs + reg);
1337 break;
1338 case 1:
1339 writeb(val, dev_priv->regs + reg);
1340 break;
1341 }
1342}
1343
e1f99ce6
CW
1344#define BEGIN_LP_RING(n) \
1345 intel_ring_begin(&dev_priv->render_ring, (n))
1da177e4 1346
e1f99ce6
CW
1347#define OUT_RING(x) \
1348 intel_ring_emit(&dev_priv->render_ring, x)
1da177e4 1349
e1f99ce6
CW
1350#define ADVANCE_LP_RING() \
1351 intel_ring_advance(&dev_priv->render_ring)
1da177e4 1352
ba8bbcf6 1353/**
585fb111
JB
1354 * Reads a dword out of the status page, which is written to from the command
1355 * queue by automatic updates, MI_REPORT_HEAD, MI_STORE_DATA_INDEX, or
1356 * MI_STORE_DATA_IMM.
ba8bbcf6 1357 *
585fb111 1358 * The following dwords have a reserved meaning:
0cdad7e8
KP
1359 * 0x00: ISR copy, updated when an ISR bit not set in the HWSTAM changes.
1360 * 0x04: ring 0 head pointer
1361 * 0x05: ring 1 head pointer (915-class)
1362 * 0x06: ring 2 head pointer (915-class)
1363 * 0x10-0x1b: Context status DWords (GM45)
1364 * 0x1f: Last written status offset. (GM45)
ba8bbcf6 1365 *
0cdad7e8 1366 * The area from dword 0x20 to 0x3ff is available for driver usage.
ba8bbcf6 1367 */
8187a2b7
ZN
1368#define READ_HWSP(dev_priv, reg) (((volatile u32 *)\
1369 (dev_priv->render_ring.status_page.page_addr))[reg])
0baf823a 1370#define READ_BREADCRUMB(dev_priv) READ_HWSP(dev_priv, I915_BREADCRUMB_INDEX)
0cdad7e8 1371#define I915_GEM_HWS_INDEX 0x20
0baf823a 1372#define I915_BREADCRUMB_INDEX 0x21
ba8bbcf6 1373
1da177e4 1374#endif
This page took 0.53715 seconds and 5 git commands to generate.