diff options
author | Jesse Barnes <jesse.barnes@intel.com> | 2007-11-21 23:14:14 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2008-02-07 00:09:38 -0500 |
commit | ba8bbcf6ff4650712f64c0ef61139c73898e2165 (patch) | |
tree | bd82043d355bdb060ec8291992bca912880f780a /drivers/char/drm/i915_drv.c | |
parent | e8b962b6df50b74afed14af7f7a7d569b3ba70ac (diff) |
i915: add suspend/resume support
Add suspend/resume support to the i915 driver. Moves some of the
initialization into the driver load routine, and fixes up places where we
assumed no dev_private existed in some of the cleanup paths. This allows
us to suspend/resume properly even if X isn't running.
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/i915_drv.c')
-rw-r--r-- | drivers/char/drm/i915_drv.c | 462 |
1 files changed, 462 insertions, 0 deletions
diff --git a/drivers/char/drm/i915_drv.c b/drivers/char/drm/i915_drv.c index 63b667538e08..d745f3fd6fbf 100644 --- a/drivers/char/drm/i915_drv.c +++ b/drivers/char/drm/i915_drv.c | |||
@@ -38,6 +38,465 @@ static struct pci_device_id pciidlist[] = { | |||
38 | i915_PCI_IDS | 38 | i915_PCI_IDS |
39 | }; | 39 | }; |
40 | 40 | ||
41 | enum pipe { | ||
42 | PIPE_A = 0, | ||
43 | PIPE_B, | ||
44 | }; | ||
45 | |||
46 | static bool i915_pipe_enabled(struct drm_device *dev, enum pipe pipe) | ||
47 | { | ||
48 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
49 | |||
50 | if (pipe == PIPE_A) | ||
51 | return (I915_READ(DPLL_A) & DPLL_VCO_ENABLE); | ||
52 | else | ||
53 | return (I915_READ(DPLL_B) & DPLL_VCO_ENABLE); | ||
54 | } | ||
55 | |||
56 | static void i915_save_palette(struct drm_device *dev, enum pipe pipe) | ||
57 | { | ||
58 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
59 | unsigned long reg = (pipe == PIPE_A ? PALETTE_A : PALETTE_B); | ||
60 | u32 *array; | ||
61 | int i; | ||
62 | |||
63 | if (!i915_pipe_enabled(dev, pipe)) | ||
64 | return; | ||
65 | |||
66 | if (pipe == PIPE_A) | ||
67 | array = dev_priv->save_palette_a; | ||
68 | else | ||
69 | array = dev_priv->save_palette_b; | ||
70 | |||
71 | for(i = 0; i < 256; i++) | ||
72 | array[i] = I915_READ(reg + (i << 2)); | ||
73 | } | ||
74 | |||
75 | static void i915_restore_palette(struct drm_device *dev, enum pipe pipe) | ||
76 | { | ||
77 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
78 | unsigned long reg = (pipe == PIPE_A ? PALETTE_A : PALETTE_B); | ||
79 | u32 *array; | ||
80 | int i; | ||
81 | |||
82 | if (!i915_pipe_enabled(dev, pipe)) | ||
83 | return; | ||
84 | |||
85 | if (pipe == PIPE_A) | ||
86 | array = dev_priv->save_palette_a; | ||
87 | else | ||
88 | array = dev_priv->save_palette_b; | ||
89 | |||
90 | for(i = 0; i < 256; i++) | ||
91 | I915_WRITE(reg + (i << 2), array[i]); | ||
92 | } | ||
93 | |||
94 | static u8 i915_read_indexed(u16 index_port, u16 data_port, u8 reg) | ||
95 | { | ||
96 | outb(reg, index_port); | ||
97 | return inb(data_port); | ||
98 | } | ||
99 | |||
100 | static u8 i915_read_ar(u16 st01, u8 reg, u16 palette_enable) | ||
101 | { | ||
102 | inb(st01); | ||
103 | outb(palette_enable | reg, VGA_AR_INDEX); | ||
104 | return inb(VGA_AR_DATA_READ); | ||
105 | } | ||
106 | |||
107 | static void i915_write_ar(u8 st01, u8 reg, u8 val, u16 palette_enable) | ||
108 | { | ||
109 | inb(st01); | ||
110 | outb(palette_enable | reg, VGA_AR_INDEX); | ||
111 | outb(val, VGA_AR_DATA_WRITE); | ||
112 | } | ||
113 | |||
114 | static void i915_write_indexed(u16 index_port, u16 data_port, u8 reg, u8 val) | ||
115 | { | ||
116 | outb(reg, index_port); | ||
117 | outb(val, data_port); | ||
118 | } | ||
119 | |||
120 | static void i915_save_vga(struct drm_device *dev) | ||
121 | { | ||
122 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
123 | int i; | ||
124 | u16 cr_index, cr_data, st01; | ||
125 | |||
126 | /* VGA color palette registers */ | ||
127 | dev_priv->saveDACMASK = inb(VGA_DACMASK); | ||
128 | /* DACCRX automatically increments during read */ | ||
129 | outb(0, VGA_DACRX); | ||
130 | /* Read 3 bytes of color data from each index */ | ||
131 | for (i = 0; i < 256 * 3; i++) | ||
132 | dev_priv->saveDACDATA[i] = inb(VGA_DACDATA); | ||
133 | |||
134 | /* MSR bits */ | ||
135 | dev_priv->saveMSR = inb(VGA_MSR_READ); | ||
136 | if (dev_priv->saveMSR & VGA_MSR_CGA_MODE) { | ||
137 | cr_index = VGA_CR_INDEX_CGA; | ||
138 | cr_data = VGA_CR_DATA_CGA; | ||
139 | st01 = VGA_ST01_CGA; | ||
140 | } else { | ||
141 | cr_index = VGA_CR_INDEX_MDA; | ||
142 | cr_data = VGA_CR_DATA_MDA; | ||
143 | st01 = VGA_ST01_MDA; | ||
144 | } | ||
145 | |||
146 | /* CRT controller regs */ | ||
147 | i915_write_indexed(cr_index, cr_data, 0x11, | ||
148 | i915_read_indexed(cr_index, cr_data, 0x11) & | ||
149 | (~0x80)); | ||
150 | for (i = 0; i < 0x24; i++) | ||
151 | dev_priv->saveCR[i] = | ||
152 | i915_read_indexed(cr_index, cr_data, i); | ||
153 | /* Make sure we don't turn off CR group 0 writes */ | ||
154 | dev_priv->saveCR[0x11] &= ~0x80; | ||
155 | |||
156 | /* Attribute controller registers */ | ||
157 | inb(st01); | ||
158 | dev_priv->saveAR_INDEX = inb(VGA_AR_INDEX); | ||
159 | for (i = 0; i < 20; i++) | ||
160 | dev_priv->saveAR[i] = i915_read_ar(st01, i, 0); | ||
161 | inb(st01); | ||
162 | outb(dev_priv->saveAR_INDEX, VGA_AR_INDEX); | ||
163 | |||
164 | /* Graphics controller registers */ | ||
165 | for (i = 0; i < 9; i++) | ||
166 | dev_priv->saveGR[i] = | ||
167 | i915_read_indexed(VGA_GR_INDEX, VGA_GR_DATA, i); | ||
168 | |||
169 | dev_priv->saveGR[0x10] = | ||
170 | i915_read_indexed(VGA_GR_INDEX, VGA_GR_DATA, 0x10); | ||
171 | dev_priv->saveGR[0x11] = | ||
172 | i915_read_indexed(VGA_GR_INDEX, VGA_GR_DATA, 0x11); | ||
173 | dev_priv->saveGR[0x18] = | ||
174 | i915_read_indexed(VGA_GR_INDEX, VGA_GR_DATA, 0x18); | ||
175 | |||
176 | /* Sequencer registers */ | ||
177 | for (i = 0; i < 8; i++) | ||
178 | dev_priv->saveSR[i] = | ||
179 | i915_read_indexed(VGA_SR_INDEX, VGA_SR_DATA, i); | ||
180 | } | ||
181 | |||
182 | static void i915_restore_vga(struct drm_device *dev) | ||
183 | { | ||
184 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
185 | int i; | ||
186 | u16 cr_index, cr_data, st01; | ||
187 | |||
188 | /* MSR bits */ | ||
189 | outb(dev_priv->saveMSR, VGA_MSR_WRITE); | ||
190 | if (dev_priv->saveMSR & VGA_MSR_CGA_MODE) { | ||
191 | cr_index = VGA_CR_INDEX_CGA; | ||
192 | cr_data = VGA_CR_DATA_CGA; | ||
193 | st01 = VGA_ST01_CGA; | ||
194 | } else { | ||
195 | cr_index = VGA_CR_INDEX_MDA; | ||
196 | cr_data = VGA_CR_DATA_MDA; | ||
197 | st01 = VGA_ST01_MDA; | ||
198 | } | ||
199 | |||
200 | /* Sequencer registers, don't write SR07 */ | ||
201 | for (i = 0; i < 7; i++) | ||
202 | i915_write_indexed(VGA_SR_INDEX, VGA_SR_DATA, i, | ||
203 | dev_priv->saveSR[i]); | ||
204 | |||
205 | /* CRT controller regs */ | ||
206 | /* Enable CR group 0 writes */ | ||
207 | i915_write_indexed(cr_index, cr_data, 0x11, dev_priv->saveCR[0x11]); | ||
208 | for (i = 0; i < 0x24; i++) | ||
209 | i915_write_indexed(cr_index, cr_data, i, dev_priv->saveCR[i]); | ||
210 | |||
211 | /* Graphics controller regs */ | ||
212 | for (i = 0; i < 9; i++) | ||
213 | i915_write_indexed(VGA_GR_INDEX, VGA_GR_DATA, i, | ||
214 | dev_priv->saveGR[i]); | ||
215 | |||
216 | i915_write_indexed(VGA_GR_INDEX, VGA_GR_DATA, 0x10, | ||
217 | dev_priv->saveGR[0x10]); | ||
218 | i915_write_indexed(VGA_GR_INDEX, VGA_GR_DATA, 0x11, | ||
219 | dev_priv->saveGR[0x11]); | ||
220 | i915_write_indexed(VGA_GR_INDEX, VGA_GR_DATA, 0x18, | ||
221 | dev_priv->saveGR[0x18]); | ||
222 | |||
223 | /* Attribute controller registers */ | ||
224 | for (i = 0; i < 20; i++) | ||
225 | i915_write_ar(st01, i, dev_priv->saveAR[i], 0); | ||
226 | inb(st01); /* switch back to index mode */ | ||
227 | outb(dev_priv->saveAR_INDEX | 0x20, VGA_AR_INDEX); | ||
228 | |||
229 | /* VGA color palette registers */ | ||
230 | outb(dev_priv->saveDACMASK, VGA_DACMASK); | ||
231 | /* DACCRX automatically increments during read */ | ||
232 | outb(0, VGA_DACWX); | ||
233 | /* Read 3 bytes of color data from each index */ | ||
234 | for (i = 0; i < 256 * 3; i++) | ||
235 | outb(dev_priv->saveDACDATA[i], VGA_DACDATA); | ||
236 | |||
237 | } | ||
238 | |||
239 | static int i915_suspend(struct drm_device *dev) | ||
240 | { | ||
241 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
242 | int i; | ||
243 | |||
244 | if (!dev || !dev_priv) { | ||
245 | printk(KERN_ERR "dev: %p, dev_priv: %p\n", dev, dev_priv); | ||
246 | printk(KERN_ERR "DRM not initialized, aborting suspend.\n"); | ||
247 | return -ENODEV; | ||
248 | } | ||
249 | |||
250 | pci_save_state(dev->pdev); | ||
251 | pci_read_config_byte(dev->pdev, LBB, &dev_priv->saveLBB); | ||
252 | |||
253 | /* Pipe & plane A info */ | ||
254 | dev_priv->savePIPEACONF = I915_READ(PIPEACONF); | ||
255 | dev_priv->savePIPEASRC = I915_READ(PIPEASRC); | ||
256 | dev_priv->saveFPA0 = I915_READ(FPA0); | ||
257 | dev_priv->saveFPA1 = I915_READ(FPA1); | ||
258 | dev_priv->saveDPLL_A = I915_READ(DPLL_A); | ||
259 | if (IS_I965G(dev)) | ||
260 | dev_priv->saveDPLL_A_MD = I915_READ(DPLL_A_MD); | ||
261 | dev_priv->saveHTOTAL_A = I915_READ(HTOTAL_A); | ||
262 | dev_priv->saveHBLANK_A = I915_READ(HBLANK_A); | ||
263 | dev_priv->saveHSYNC_A = I915_READ(HSYNC_A); | ||
264 | dev_priv->saveVTOTAL_A = I915_READ(VTOTAL_A); | ||
265 | dev_priv->saveVBLANK_A = I915_READ(VBLANK_A); | ||
266 | dev_priv->saveVSYNC_A = I915_READ(VSYNC_A); | ||
267 | dev_priv->saveBCLRPAT_A = I915_READ(BCLRPAT_A); | ||
268 | |||
269 | dev_priv->saveDSPACNTR = I915_READ(DSPACNTR); | ||
270 | dev_priv->saveDSPASTRIDE = I915_READ(DSPASTRIDE); | ||
271 | dev_priv->saveDSPASIZE = I915_READ(DSPASIZE); | ||
272 | dev_priv->saveDSPAPOS = I915_READ(DSPAPOS); | ||
273 | dev_priv->saveDSPABASE = I915_READ(DSPABASE); | ||
274 | if (IS_I965G(dev)) { | ||
275 | dev_priv->saveDSPASURF = I915_READ(DSPASURF); | ||
276 | dev_priv->saveDSPATILEOFF = I915_READ(DSPATILEOFF); | ||
277 | } | ||
278 | i915_save_palette(dev, PIPE_A); | ||
279 | |||
280 | /* Pipe & plane B info */ | ||
281 | dev_priv->savePIPEBCONF = I915_READ(PIPEBCONF); | ||
282 | dev_priv->savePIPEBSRC = I915_READ(PIPEBSRC); | ||
283 | dev_priv->saveFPB0 = I915_READ(FPB0); | ||
284 | dev_priv->saveFPB1 = I915_READ(FPB1); | ||
285 | dev_priv->saveDPLL_B = I915_READ(DPLL_B); | ||
286 | if (IS_I965G(dev)) | ||
287 | dev_priv->saveDPLL_B_MD = I915_READ(DPLL_B_MD); | ||
288 | dev_priv->saveHTOTAL_B = I915_READ(HTOTAL_B); | ||
289 | dev_priv->saveHBLANK_B = I915_READ(HBLANK_B); | ||
290 | dev_priv->saveHSYNC_B = I915_READ(HSYNC_B); | ||
291 | dev_priv->saveVTOTAL_B = I915_READ(VTOTAL_B); | ||
292 | dev_priv->saveVBLANK_B = I915_READ(VBLANK_B); | ||
293 | dev_priv->saveVSYNC_B = I915_READ(VSYNC_B); | ||
294 | dev_priv->saveBCLRPAT_A = I915_READ(BCLRPAT_A); | ||
295 | |||
296 | dev_priv->saveDSPBCNTR = I915_READ(DSPBCNTR); | ||
297 | dev_priv->saveDSPBSTRIDE = I915_READ(DSPBSTRIDE); | ||
298 | dev_priv->saveDSPBSIZE = I915_READ(DSPBSIZE); | ||
299 | dev_priv->saveDSPBPOS = I915_READ(DSPBPOS); | ||
300 | dev_priv->saveDSPBBASE = I915_READ(DSPBBASE); | ||
301 | if (IS_I965GM(dev)) { | ||
302 | dev_priv->saveDSPBSURF = I915_READ(DSPBSURF); | ||
303 | dev_priv->saveDSPBTILEOFF = I915_READ(DSPBTILEOFF); | ||
304 | } | ||
305 | i915_save_palette(dev, PIPE_B); | ||
306 | |||
307 | /* CRT state */ | ||
308 | dev_priv->saveADPA = I915_READ(ADPA); | ||
309 | |||
310 | /* LVDS state */ | ||
311 | dev_priv->savePP_CONTROL = I915_READ(PP_CONTROL); | ||
312 | dev_priv->savePFIT_PGM_RATIOS = I915_READ(PFIT_PGM_RATIOS); | ||
313 | dev_priv->saveBLC_PWM_CTL = I915_READ(BLC_PWM_CTL); | ||
314 | if (IS_I965G(dev)) | ||
315 | dev_priv->saveBLC_PWM_CTL2 = I915_READ(BLC_PWM_CTL2); | ||
316 | if (IS_MOBILE(dev) && !IS_I830(dev)) | ||
317 | dev_priv->saveLVDS = I915_READ(LVDS); | ||
318 | if (!IS_I830(dev) && !IS_845G(dev)) | ||
319 | dev_priv->savePFIT_CONTROL = I915_READ(PFIT_CONTROL); | ||
320 | dev_priv->saveLVDSPP_ON = I915_READ(LVDSPP_ON); | ||
321 | dev_priv->saveLVDSPP_OFF = I915_READ(LVDSPP_OFF); | ||
322 | dev_priv->savePP_CYCLE = I915_READ(PP_CYCLE); | ||
323 | |||
324 | /* FIXME: save TV & SDVO state */ | ||
325 | |||
326 | /* FBC state */ | ||
327 | dev_priv->saveFBC_CFB_BASE = I915_READ(FBC_CFB_BASE); | ||
328 | dev_priv->saveFBC_LL_BASE = I915_READ(FBC_LL_BASE); | ||
329 | dev_priv->saveFBC_CONTROL2 = I915_READ(FBC_CONTROL2); | ||
330 | dev_priv->saveFBC_CONTROL = I915_READ(FBC_CONTROL); | ||
331 | |||
332 | /* VGA state */ | ||
333 | dev_priv->saveVCLK_DIVISOR_VGA0 = I915_READ(VCLK_DIVISOR_VGA0); | ||
334 | dev_priv->saveVCLK_DIVISOR_VGA1 = I915_READ(VCLK_DIVISOR_VGA1); | ||
335 | dev_priv->saveVCLK_POST_DIV = I915_READ(VCLK_POST_DIV); | ||
336 | dev_priv->saveVGACNTRL = I915_READ(VGACNTRL); | ||
337 | |||
338 | /* Scratch space */ | ||
339 | for (i = 0; i < 16; i++) { | ||
340 | dev_priv->saveSWF0[i] = I915_READ(SWF0 + (i << 2)); | ||
341 | dev_priv->saveSWF1[i] = I915_READ(SWF10 + (i << 2)); | ||
342 | } | ||
343 | for (i = 0; i < 3; i++) | ||
344 | dev_priv->saveSWF2[i] = I915_READ(SWF30 + (i << 2)); | ||
345 | |||
346 | i915_save_vga(dev); | ||
347 | |||
348 | /* Shut down the device */ | ||
349 | pci_disable_device(dev->pdev); | ||
350 | pci_set_power_state(dev->pdev, PCI_D3hot); | ||
351 | |||
352 | return 0; | ||
353 | } | ||
354 | |||
355 | static int i915_resume(struct drm_device *dev) | ||
356 | { | ||
357 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
358 | int i; | ||
359 | |||
360 | pci_set_power_state(dev->pdev, PCI_D0); | ||
361 | pci_restore_state(dev->pdev); | ||
362 | if (pci_enable_device(dev->pdev)) | ||
363 | return -1; | ||
364 | |||
365 | pci_write_config_byte(dev->pdev, LBB, dev_priv->saveLBB); | ||
366 | |||
367 | /* Pipe & plane A info */ | ||
368 | /* Prime the clock */ | ||
369 | if (dev_priv->saveDPLL_A & DPLL_VCO_ENABLE) { | ||
370 | I915_WRITE(DPLL_A, dev_priv->saveDPLL_A & | ||
371 | ~DPLL_VCO_ENABLE); | ||
372 | udelay(150); | ||
373 | } | ||
374 | I915_WRITE(FPA0, dev_priv->saveFPA0); | ||
375 | I915_WRITE(FPA1, dev_priv->saveFPA1); | ||
376 | /* Actually enable it */ | ||
377 | I915_WRITE(DPLL_A, dev_priv->saveDPLL_A); | ||
378 | udelay(150); | ||
379 | if (IS_I965G(dev)) | ||
380 | I915_WRITE(DPLL_A_MD, dev_priv->saveDPLL_A_MD); | ||
381 | udelay(150); | ||
382 | |||
383 | /* Restore mode */ | ||
384 | I915_WRITE(HTOTAL_A, dev_priv->saveHTOTAL_A); | ||
385 | I915_WRITE(HBLANK_A, dev_priv->saveHBLANK_A); | ||
386 | I915_WRITE(HSYNC_A, dev_priv->saveHSYNC_A); | ||
387 | I915_WRITE(VTOTAL_A, dev_priv->saveVTOTAL_A); | ||
388 | I915_WRITE(VBLANK_A, dev_priv->saveVBLANK_A); | ||
389 | I915_WRITE(VSYNC_A, dev_priv->saveVSYNC_A); | ||
390 | I915_WRITE(BCLRPAT_A, dev_priv->saveBCLRPAT_A); | ||
391 | |||
392 | /* Restore plane info */ | ||
393 | I915_WRITE(DSPASIZE, dev_priv->saveDSPASIZE); | ||
394 | I915_WRITE(DSPAPOS, dev_priv->saveDSPAPOS); | ||
395 | I915_WRITE(PIPEASRC, dev_priv->savePIPEASRC); | ||
396 | I915_WRITE(DSPABASE, dev_priv->saveDSPABASE); | ||
397 | I915_WRITE(DSPASTRIDE, dev_priv->saveDSPASTRIDE); | ||
398 | if (IS_I965G(dev)) { | ||
399 | I915_WRITE(DSPASURF, dev_priv->saveDSPASURF); | ||
400 | I915_WRITE(DSPATILEOFF, dev_priv->saveDSPATILEOFF); | ||
401 | } | ||
402 | |||
403 | if ((dev_priv->saveDPLL_A & DPLL_VCO_ENABLE) && | ||
404 | (dev_priv->saveDPLL_A & DPLL_VGA_MODE_DIS)) | ||
405 | I915_WRITE(PIPEACONF, dev_priv->savePIPEACONF); | ||
406 | |||
407 | i915_restore_palette(dev, PIPE_A); | ||
408 | /* Enable the plane */ | ||
409 | I915_WRITE(DSPACNTR, dev_priv->saveDSPACNTR); | ||
410 | I915_WRITE(DSPABASE, I915_READ(DSPABASE)); | ||
411 | |||
412 | /* Pipe & plane B info */ | ||
413 | if (dev_priv->saveDPLL_B & DPLL_VCO_ENABLE) { | ||
414 | I915_WRITE(DPLL_B, dev_priv->saveDPLL_B & | ||
415 | ~DPLL_VCO_ENABLE); | ||
416 | udelay(150); | ||
417 | } | ||
418 | I915_WRITE(FPB0, dev_priv->saveFPB0); | ||
419 | I915_WRITE(FPB1, dev_priv->saveFPB1); | ||
420 | /* Actually enable it */ | ||
421 | I915_WRITE(DPLL_B, dev_priv->saveDPLL_B); | ||
422 | udelay(150); | ||
423 | if (IS_I965G(dev)) | ||
424 | I915_WRITE(DPLL_B_MD, dev_priv->saveDPLL_B_MD); | ||
425 | udelay(150); | ||
426 | |||
427 | /* Restore mode */ | ||
428 | I915_WRITE(HTOTAL_B, dev_priv->saveHTOTAL_B); | ||
429 | I915_WRITE(HBLANK_B, dev_priv->saveHBLANK_B); | ||
430 | I915_WRITE(HSYNC_B, dev_priv->saveHSYNC_B); | ||
431 | I915_WRITE(VTOTAL_B, dev_priv->saveVTOTAL_B); | ||
432 | I915_WRITE(VBLANK_B, dev_priv->saveVBLANK_B); | ||
433 | I915_WRITE(VSYNC_B, dev_priv->saveVSYNC_B); | ||
434 | I915_WRITE(BCLRPAT_B, dev_priv->saveBCLRPAT_B); | ||
435 | |||
436 | /* Restore plane info */ | ||
437 | I915_WRITE(DSPBSIZE, dev_priv->saveDSPBSIZE); | ||
438 | I915_WRITE(DSPBPOS, dev_priv->saveDSPBPOS); | ||
439 | I915_WRITE(PIPEBSRC, dev_priv->savePIPEBSRC); | ||
440 | I915_WRITE(DSPBBASE, dev_priv->saveDSPBBASE); | ||
441 | I915_WRITE(DSPBSTRIDE, dev_priv->saveDSPBSTRIDE); | ||
442 | if (IS_I965G(dev)) { | ||
443 | I915_WRITE(DSPBSURF, dev_priv->saveDSPBSURF); | ||
444 | I915_WRITE(DSPBTILEOFF, dev_priv->saveDSPBTILEOFF); | ||
445 | } | ||
446 | |||
447 | if ((dev_priv->saveDPLL_B & DPLL_VCO_ENABLE) && | ||
448 | (dev_priv->saveDPLL_B & DPLL_VGA_MODE_DIS)) | ||
449 | I915_WRITE(PIPEBCONF, dev_priv->savePIPEBCONF); | ||
450 | i915_restore_palette(dev, PIPE_A); | ||
451 | /* Enable the plane */ | ||
452 | I915_WRITE(DSPBCNTR, dev_priv->saveDSPBCNTR); | ||
453 | I915_WRITE(DSPBBASE, I915_READ(DSPBBASE)); | ||
454 | |||
455 | /* CRT state */ | ||
456 | I915_WRITE(ADPA, dev_priv->saveADPA); | ||
457 | |||
458 | /* LVDS state */ | ||
459 | if (IS_I965G(dev)) | ||
460 | I915_WRITE(BLC_PWM_CTL2, dev_priv->saveBLC_PWM_CTL2); | ||
461 | if (IS_MOBILE(dev) && !IS_I830(dev)) | ||
462 | I915_WRITE(LVDS, dev_priv->saveLVDS); | ||
463 | if (!IS_I830(dev) && !IS_845G(dev)) | ||
464 | I915_WRITE(PFIT_CONTROL, dev_priv->savePFIT_CONTROL); | ||
465 | |||
466 | I915_WRITE(PFIT_PGM_RATIOS, dev_priv->savePFIT_PGM_RATIOS); | ||
467 | I915_WRITE(BLC_PWM_CTL, dev_priv->saveBLC_PWM_CTL); | ||
468 | I915_WRITE(LVDSPP_ON, dev_priv->saveLVDSPP_ON); | ||
469 | I915_WRITE(LVDSPP_OFF, dev_priv->saveLVDSPP_OFF); | ||
470 | I915_WRITE(PP_CYCLE, dev_priv->savePP_CYCLE); | ||
471 | I915_WRITE(PP_CONTROL, dev_priv->savePP_CONTROL); | ||
472 | |||
473 | /* FIXME: restore TV & SDVO state */ | ||
474 | |||
475 | /* FBC info */ | ||
476 | I915_WRITE(FBC_CFB_BASE, dev_priv->saveFBC_CFB_BASE); | ||
477 | I915_WRITE(FBC_LL_BASE, dev_priv->saveFBC_LL_BASE); | ||
478 | I915_WRITE(FBC_CONTROL2, dev_priv->saveFBC_CONTROL2); | ||
479 | I915_WRITE(FBC_CONTROL, dev_priv->saveFBC_CONTROL); | ||
480 | |||
481 | /* VGA state */ | ||
482 | I915_WRITE(VGACNTRL, dev_priv->saveVGACNTRL); | ||
483 | I915_WRITE(VCLK_DIVISOR_VGA0, dev_priv->saveVCLK_DIVISOR_VGA0); | ||
484 | I915_WRITE(VCLK_DIVISOR_VGA1, dev_priv->saveVCLK_DIVISOR_VGA1); | ||
485 | I915_WRITE(VCLK_POST_DIV, dev_priv->saveVCLK_POST_DIV); | ||
486 | udelay(150); | ||
487 | |||
488 | for (i = 0; i < 16; i++) { | ||
489 | I915_WRITE(SWF0 + (i << 2), dev_priv->saveSWF0[i]); | ||
490 | I915_WRITE(SWF10 + (i << 2), dev_priv->saveSWF1[i+7]); | ||
491 | } | ||
492 | for (i = 0; i < 3; i++) | ||
493 | I915_WRITE(SWF30 + (i << 2), dev_priv->saveSWF2[i]); | ||
494 | |||
495 | i915_restore_vga(dev); | ||
496 | |||
497 | return 0; | ||
498 | } | ||
499 | |||
41 | static struct drm_driver driver = { | 500 | static struct drm_driver driver = { |
42 | /* don't use mtrr's here, the Xserver or user space app should | 501 | /* don't use mtrr's here, the Xserver or user space app should |
43 | * deal with them for intel hardware. | 502 | * deal with them for intel hardware. |
@@ -47,8 +506,11 @@ static struct drm_driver driver = { | |||
47 | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL | | 506 | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL | |
48 | DRIVER_IRQ_VBL2, | 507 | DRIVER_IRQ_VBL2, |
49 | .load = i915_driver_load, | 508 | .load = i915_driver_load, |
509 | .unload = i915_driver_unload, | ||
50 | .lastclose = i915_driver_lastclose, | 510 | .lastclose = i915_driver_lastclose, |
51 | .preclose = i915_driver_preclose, | 511 | .preclose = i915_driver_preclose, |
512 | .suspend = i915_suspend, | ||
513 | .resume = i915_resume, | ||
52 | .device_is_agp = i915_driver_device_is_agp, | 514 | .device_is_agp = i915_driver_device_is_agp, |
53 | .vblank_wait = i915_driver_vblank_wait, | 515 | .vblank_wait = i915_driver_vblank_wait, |
54 | .vblank_wait2 = i915_driver_vblank_wait2, | 516 | .vblank_wait2 = i915_driver_vblank_wait2, |