Subversion Repositories Kolibri OS

Rev

Rev 4398 | Rev 5060 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4398 Rev 4560
1
/* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*-
1
/* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*-
2
 */
2
 */
3
/*
3
/*
4
 *
4
 *
5
 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
5
 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6
 * All Rights Reserved.
6
 * All Rights Reserved.
7
 *
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a
8
 * Permission is hereby granted, free of charge, to any person obtaining a
9
 * copy of this software and associated documentation files (the
9
 * copy of this software and associated documentation files (the
10
 * "Software"), to deal in the Software without restriction, including
10
 * "Software"), to deal in the Software without restriction, including
11
 * without limitation the rights to use, copy, modify, merge, publish,
11
 * without limitation the rights to use, copy, modify, merge, publish,
12
 * distribute, sub license, and/or sell copies of the Software, and to
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
13
 * permit persons to whom the Software is furnished to do so, subject to
14
 * the following conditions:
14
 * the following conditions:
15
 *
15
 *
16
 * The above copyright notice and this permission notice (including the
16
 * The above copyright notice and this permission notice (including the
17
 * next paragraph) shall be included in all copies or substantial portions
17
 * next paragraph) shall be included in all copies or substantial portions
18
 * of the Software.
18
 * of the Software.
19
 *
19
 *
20
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
23
 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
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,
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
25
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
 *
27
 *
28
 */
28
 */
29
 
29
 
30
//#include 
30
//#include 
31
#include 
31
#include 
32
#include 
32
#include 
33
#include "i915_drv.h"
33
#include "i915_drv.h"
34
#include "i915_trace.h"
34
#include "i915_trace.h"
35
#include "intel_drv.h"
35
#include "intel_drv.h"
36
 
36
 
37
#include 
37
#include 
38
#include 
38
#include 
39
#include 
39
#include 
40
#include 
40
#include 
41
 
41
 
42
#include 
42
#include 
43
 
43
 
44
#include 
44
#include 
45
 
45
 
46
#define __read_mostly
46
#define __read_mostly
47
 
47
 
48
int init_display_kms(struct drm_device *dev);
48
int init_display_kms(struct drm_device *dev);
49
 
49
 
50
static int i915_modeset __read_mostly = 1;
50
static int i915_modeset __read_mostly = 1;
51
module_param_named(modeset, i915_modeset, int, 0400);
51
module_param_named(modeset, i915_modeset, int, 0400);
52
MODULE_PARM_DESC(modeset,
52
MODULE_PARM_DESC(modeset,
53
		"Use kernel modesetting [KMS] (0=DRM_I915_KMS from .config, "
53
		"Use kernel modesetting [KMS] (0=DRM_I915_KMS from .config, "
54
		"1=on, -1=force vga console preference [default])");
54
		"1=on, -1=force vga console preference [default])");
55
 
55
 
56
unsigned int i915_fbpercrtc __always_unused = 0;
56
unsigned int i915_fbpercrtc __always_unused = 0;
57
module_param_named(fbpercrtc, i915_fbpercrtc, int, 0400);
57
module_param_named(fbpercrtc, i915_fbpercrtc, int, 0400);
58
 
58
 
59
int i915_panel_ignore_lid __read_mostly         =  1;
59
int i915_panel_ignore_lid __read_mostly         =  1;
60
module_param_named(panel_ignore_lid, i915_panel_ignore_lid, int, 0600);
60
module_param_named(panel_ignore_lid, i915_panel_ignore_lid, int, 0600);
61
MODULE_PARM_DESC(panel_ignore_lid,
61
MODULE_PARM_DESC(panel_ignore_lid,
62
		"Override lid status (0=autodetect, 1=autodetect disabled [default], "
62
		"Override lid status (0=autodetect, 1=autodetect disabled [default], "
63
		"-1=force lid closed, -2=force lid open)");
63
		"-1=force lid closed, -2=force lid open)");
64
 
64
 
65
unsigned int i915_powersave __read_mostly = 0;
65
unsigned int i915_powersave __read_mostly = 1;
66
module_param_named(powersave, i915_powersave, int, 0600);
66
module_param_named(powersave, i915_powersave, int, 0600);
67
MODULE_PARM_DESC(powersave,
67
MODULE_PARM_DESC(powersave,
68
		"Enable powersavings, fbc, downclocking, etc. (default: true)");
68
		"Enable powersavings, fbc, downclocking, etc. (default: true)");
69
 
69
 
70
int i915_semaphores __read_mostly = -1;
70
int i915_semaphores __read_mostly = -1;
71
module_param_named(semaphores, i915_semaphores, int, 0600);
71
module_param_named(semaphores, i915_semaphores, int, 0400);
72
MODULE_PARM_DESC(semaphores,
72
MODULE_PARM_DESC(semaphores,
73
		"Use semaphores for inter-ring sync (default: -1 (use per-chip defaults))");
73
		"Use semaphores for inter-ring sync (default: -1 (use per-chip defaults))");
74
 
74
 
75
int i915_enable_rc6 __read_mostly = 0;
75
int i915_enable_rc6 __read_mostly = -1;
76
module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0400);
76
module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0400);
77
MODULE_PARM_DESC(i915_enable_rc6,
77
MODULE_PARM_DESC(i915_enable_rc6,
78
		"Enable power-saving render C-state 6. "
78
		"Enable power-saving render C-state 6. "
79
		"Different stages can be selected via bitmask values "
79
		"Different stages can be selected via bitmask values "
80
		"(0 = disable; 1 = enable rc6; 2 = enable deep rc6; 4 = enable deepest rc6). "
80
		"(0 = disable; 1 = enable rc6; 2 = enable deep rc6; 4 = enable deepest rc6). "
81
		"For example, 3 would enable rc6 and deep rc6, and 7 would enable everything. "
81
		"For example, 3 would enable rc6 and deep rc6, and 7 would enable everything. "
82
		"default: -1 (use per-chip default)");
82
		"default: -1 (use per-chip default)");
83
 
83
 
84
int i915_enable_fbc __read_mostly = 0;
84
int i915_enable_fbc __read_mostly = -1;
85
module_param_named(i915_enable_fbc, i915_enable_fbc, int, 0600);
85
module_param_named(i915_enable_fbc, i915_enable_fbc, int, 0600);
86
MODULE_PARM_DESC(i915_enable_fbc,
86
MODULE_PARM_DESC(i915_enable_fbc,
87
		"Enable frame buffer compression for power savings "
87
		"Enable frame buffer compression for power savings "
88
		"(default: -1 (use per-chip default))");
88
		"(default: -1 (use per-chip default))");
89
 
89
 
90
unsigned int i915_lvds_downclock  __read_mostly =  0;
90
unsigned int i915_lvds_downclock  __read_mostly =  0;
91
module_param_named(lvds_downclock, i915_lvds_downclock, int, 0400);
91
module_param_named(lvds_downclock, i915_lvds_downclock, int, 0400);
92
MODULE_PARM_DESC(lvds_downclock,
92
MODULE_PARM_DESC(lvds_downclock,
93
		"Use panel (LVDS/eDP) downclocking for power savings "
93
		"Use panel (LVDS/eDP) downclocking for power savings "
94
		"(default: false)");
94
		"(default: false)");
95
 
95
 
96
int i915_lvds_channel_mode __read_mostly;
96
int i915_lvds_channel_mode __read_mostly;
97
module_param_named(lvds_channel_mode, i915_lvds_channel_mode, int, 0600);
97
module_param_named(lvds_channel_mode, i915_lvds_channel_mode, int, 0600);
98
MODULE_PARM_DESC(lvds_channel_mode,
98
MODULE_PARM_DESC(lvds_channel_mode,
99
		 "Specify LVDS channel mode "
99
		 "Specify LVDS channel mode "
100
		 "(0=probe BIOS [default], 1=single-channel, 2=dual-channel)");
100
		 "(0=probe BIOS [default], 1=single-channel, 2=dual-channel)");
101
 
101
 
102
int i915_panel_use_ssc __read_mostly = -1;
102
int i915_panel_use_ssc __read_mostly = -1;
103
module_param_named(lvds_use_ssc, i915_panel_use_ssc, int, 0600);
103
module_param_named(lvds_use_ssc, i915_panel_use_ssc, int, 0600);
104
MODULE_PARM_DESC(lvds_use_ssc,
104
MODULE_PARM_DESC(lvds_use_ssc,
105
		"Use Spread Spectrum Clock with panels [LVDS/eDP] "
105
		"Use Spread Spectrum Clock with panels [LVDS/eDP] "
106
		"(default: auto from VBT)");
106
		"(default: auto from VBT)");
107
 
107
 
108
int i915_vbt_sdvo_panel_type __read_mostly      = -1;
108
int i915_vbt_sdvo_panel_type __read_mostly      = -1;
109
module_param_named(vbt_sdvo_panel_type, i915_vbt_sdvo_panel_type, int, 0600);
109
module_param_named(vbt_sdvo_panel_type, i915_vbt_sdvo_panel_type, int, 0600);
110
MODULE_PARM_DESC(vbt_sdvo_panel_type,
110
MODULE_PARM_DESC(vbt_sdvo_panel_type,
111
		"Override/Ignore selection of SDVO panel mode in the VBT "
111
		"Override/Ignore selection of SDVO panel mode in the VBT "
112
		"(-2=ignore, -1=auto [default], index in VBT BIOS table)");
112
		"(-2=ignore, -1=auto [default], index in VBT BIOS table)");
113
 
113
 
114
static bool i915_try_reset __read_mostly = true;
114
static bool i915_try_reset __read_mostly = true;
115
module_param_named(reset, i915_try_reset, bool, 0600);
115
module_param_named(reset, i915_try_reset, bool, 0600);
116
MODULE_PARM_DESC(reset, "Attempt GPU resets (default: true)");
116
MODULE_PARM_DESC(reset, "Attempt GPU resets (default: true)");
117
 
117
 
118
bool i915_enable_hangcheck __read_mostly = false;
118
bool i915_enable_hangcheck __read_mostly = false;
119
module_param_named(enable_hangcheck, i915_enable_hangcheck, bool, 0644);
119
module_param_named(enable_hangcheck, i915_enable_hangcheck, bool, 0644);
120
MODULE_PARM_DESC(enable_hangcheck,
120
MODULE_PARM_DESC(enable_hangcheck,
121
		"Periodically check GPU activity for detecting hangs. "
121
		"Periodically check GPU activity for detecting hangs. "
122
		"WARNING: Disabling this can cause system wide hangs. "
122
		"WARNING: Disabling this can cause system wide hangs. "
123
		"(default: true)");
123
		"(default: true)");
124
 
124
 
125
int i915_enable_ppgtt __read_mostly = 0;
125
int i915_enable_ppgtt __read_mostly = -1;
126
module_param_named(i915_enable_ppgtt, i915_enable_ppgtt, int, 0600);
126
module_param_named(i915_enable_ppgtt, i915_enable_ppgtt, int, 0400);
127
MODULE_PARM_DESC(i915_enable_ppgtt,
127
MODULE_PARM_DESC(i915_enable_ppgtt,
128
		"Enable PPGTT (default: true)");
128
		"Enable PPGTT (default: true)");
129
 
129
 
130
int i915_enable_psr __read_mostly = 0;
130
int i915_enable_psr __read_mostly = 0;
131
module_param_named(enable_psr, i915_enable_psr, int, 0600);
131
module_param_named(enable_psr, i915_enable_psr, int, 0600);
132
MODULE_PARM_DESC(enable_psr, "Enable PSR (default: false)");
132
MODULE_PARM_DESC(enable_psr, "Enable PSR (default: false)");
133
 
133
 
134
unsigned int i915_preliminary_hw_support __read_mostly = IS_ENABLED(CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT);
134
unsigned int i915_preliminary_hw_support __read_mostly = IS_ENABLED(CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT);
135
module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 0600);
135
module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 0600);
136
MODULE_PARM_DESC(preliminary_hw_support,
136
MODULE_PARM_DESC(preliminary_hw_support,
137
		"Enable preliminary hardware support.");
137
		"Enable preliminary hardware support.");
138
 
138
 
139
int i915_disable_power_well __read_mostly = 1;
139
int i915_disable_power_well __read_mostly = 1;
140
module_param_named(disable_power_well, i915_disable_power_well, int, 0600);
140
module_param_named(disable_power_well, i915_disable_power_well, int, 0600);
141
MODULE_PARM_DESC(disable_power_well,
141
MODULE_PARM_DESC(disable_power_well,
142
		 "Disable the power well when possible (default: true)");
142
		 "Disable the power well when possible (default: true)");
143
 
143
 
144
int i915_enable_ips __read_mostly = 1;
144
int i915_enable_ips __read_mostly = 1;
145
module_param_named(enable_ips, i915_enable_ips, int, 0600);
145
module_param_named(enable_ips, i915_enable_ips, int, 0600);
146
MODULE_PARM_DESC(enable_ips, "Enable IPS (default: true)");
146
MODULE_PARM_DESC(enable_ips, "Enable IPS (default: true)");
147
 
147
 
148
bool i915_fastboot __read_mostly = 0;
148
bool i915_fastboot __read_mostly = 0;
149
module_param_named(fastboot, i915_fastboot, bool, 0600);
149
module_param_named(fastboot, i915_fastboot, bool, 0600);
150
MODULE_PARM_DESC(fastboot, "Try to skip unnecessary mode sets at boot time "
150
MODULE_PARM_DESC(fastboot, "Try to skip unnecessary mode sets at boot time "
151
		 "(default: false)");
151
		 "(default: false)");
152
 
152
 
153
int i915_enable_pc8 __read_mostly = 0;
153
int i915_enable_pc8 __read_mostly = 0;
154
module_param_named(enable_pc8, i915_enable_pc8, int, 0600);
154
module_param_named(enable_pc8, i915_enable_pc8, int, 0600);
155
MODULE_PARM_DESC(enable_pc8, "Enable support for low power package C states (PC8+) (default: true)");
155
MODULE_PARM_DESC(enable_pc8, "Enable support for low power package C states (PC8+) (default: true)");
156
 
156
 
157
int i915_pc8_timeout __read_mostly = 5000;
157
int i915_pc8_timeout __read_mostly = 5000;
158
module_param_named(pc8_timeout, i915_pc8_timeout, int, 0600);
158
module_param_named(pc8_timeout, i915_pc8_timeout, int, 0600);
159
MODULE_PARM_DESC(pc8_timeout, "Number of msecs of idleness required to enter PC8+ (default: 5000)");
159
MODULE_PARM_DESC(pc8_timeout, "Number of msecs of idleness required to enter PC8+ (default: 5000)");
160
 
160
 
161
bool i915_prefault_disable __read_mostly;
161
bool i915_prefault_disable __read_mostly;
162
module_param_named(prefault_disable, i915_prefault_disable, bool, 0600);
162
module_param_named(prefault_disable, i915_prefault_disable, bool, 0600);
163
MODULE_PARM_DESC(prefault_disable,
163
MODULE_PARM_DESC(prefault_disable,
164
		"Disable page prefaulting for pread/pwrite/reloc (default:false). For developers only.");
164
		"Disable page prefaulting for pread/pwrite/reloc (default:false). For developers only.");
165
 
165
 
166
static struct drm_driver driver;
166
static struct drm_driver driver;
167
extern int intel_agp_enabled;
167
extern int intel_agp_enabled;
168
 
168
 
169
#define PCI_VENDOR_ID_INTEL        0x8086
169
#define PCI_VENDOR_ID_INTEL        0x8086
170
 
170
 
171
 
171
 
172
static const struct intel_device_info intel_i915g_info = {
172
static const struct intel_device_info intel_i915g_info = {
173
	.gen = 3, .is_i915g = 1, .cursor_needs_physical = 1, .num_pipes = 2,
173
	.gen = 3, .is_i915g = 1, .cursor_needs_physical = 1, .num_pipes = 2,
174
	.has_overlay = 1, .overlay_needs_physical = 1,
174
	.has_overlay = 1, .overlay_needs_physical = 1,
-
 
175
	.ring_mask = RENDER_RING,
175
};
176
};
176
static const struct intel_device_info intel_i915gm_info = {
177
static const struct intel_device_info intel_i915gm_info = {
177
	.gen = 3, .is_mobile = 1, .num_pipes = 2,
178
	.gen = 3, .is_mobile = 1, .num_pipes = 2,
178
	.cursor_needs_physical = 1,
179
	.cursor_needs_physical = 1,
179
	.has_overlay = 1, .overlay_needs_physical = 1,
180
	.has_overlay = 1, .overlay_needs_physical = 1,
180
	.supports_tv = 1,
181
	.supports_tv = 1,
-
 
182
	.has_fbc = 1,
-
 
183
	.ring_mask = RENDER_RING,
181
};
184
};
182
static const struct intel_device_info intel_i945g_info = {
185
static const struct intel_device_info intel_i945g_info = {
183
	.gen = 3, .has_hotplug = 1, .cursor_needs_physical = 1, .num_pipes = 2,
186
	.gen = 3, .has_hotplug = 1, .cursor_needs_physical = 1, .num_pipes = 2,
184
	.has_overlay = 1, .overlay_needs_physical = 1,
187
	.has_overlay = 1, .overlay_needs_physical = 1,
-
 
188
	.ring_mask = RENDER_RING,
185
};
189
};
186
static const struct intel_device_info intel_i945gm_info = {
190
static const struct intel_device_info intel_i945gm_info = {
187
	.gen = 3, .is_i945gm = 1, .is_mobile = 1, .num_pipes = 2,
191
	.gen = 3, .is_i945gm = 1, .is_mobile = 1, .num_pipes = 2,
188
	.has_hotplug = 1, .cursor_needs_physical = 1,
192
	.has_hotplug = 1, .cursor_needs_physical = 1,
189
	.has_overlay = 1, .overlay_needs_physical = 1,
193
	.has_overlay = 1, .overlay_needs_physical = 1,
190
	.supports_tv = 1,
194
	.supports_tv = 1,
-
 
195
	.has_fbc = 1,
-
 
196
	.ring_mask = RENDER_RING,
191
};
197
};
192
 
198
 
193
static const struct intel_device_info intel_i965g_info = {
199
static const struct intel_device_info intel_i965g_info = {
194
	.gen = 4, .is_broadwater = 1, .num_pipes = 2,
200
	.gen = 4, .is_broadwater = 1, .num_pipes = 2,
195
	.has_hotplug = 1,
201
	.has_hotplug = 1,
196
	.has_overlay = 1,
202
	.has_overlay = 1,
-
 
203
	.ring_mask = RENDER_RING,
197
};
204
};
198
 
205
 
199
static const struct intel_device_info intel_i965gm_info = {
206
static const struct intel_device_info intel_i965gm_info = {
200
	.gen = 4, .is_crestline = 1, .num_pipes = 2,
207
	.gen = 4, .is_crestline = 1, .num_pipes = 2,
201
	.is_mobile = 1, .has_fbc = 1, .has_hotplug = 1,
208
	.is_mobile = 1, .has_fbc = 1, .has_hotplug = 1,
202
	.has_overlay = 1,
209
	.has_overlay = 1,
203
	.supports_tv = 1,
210
	.supports_tv = 1,
-
 
211
	.ring_mask = RENDER_RING,
204
};
212
};
205
 
213
 
206
static const struct intel_device_info intel_g33_info = {
214
static const struct intel_device_info intel_g33_info = {
207
	.gen = 3, .is_g33 = 1, .num_pipes = 2,
215
	.gen = 3, .is_g33 = 1, .num_pipes = 2,
208
	.need_gfx_hws = 1, .has_hotplug = 1,
216
	.need_gfx_hws = 1, .has_hotplug = 1,
209
	.has_overlay = 1,
217
	.has_overlay = 1,
-
 
218
	.ring_mask = RENDER_RING,
210
};
219
};
211
 
220
 
212
static const struct intel_device_info intel_g45_info = {
221
static const struct intel_device_info intel_g45_info = {
213
	.gen = 4, .is_g4x = 1, .need_gfx_hws = 1, .num_pipes = 2,
222
	.gen = 4, .is_g4x = 1, .need_gfx_hws = 1, .num_pipes = 2,
214
	.has_pipe_cxsr = 1, .has_hotplug = 1,
223
	.has_pipe_cxsr = 1, .has_hotplug = 1,
215
	.has_bsd_ring = 1,
224
	.ring_mask = RENDER_RING | BSD_RING,
216
};
225
};
217
 
226
 
218
static const struct intel_device_info intel_gm45_info = {
227
static const struct intel_device_info intel_gm45_info = {
219
	.gen = 4, .is_g4x = 1, .num_pipes = 2,
228
	.gen = 4, .is_g4x = 1, .num_pipes = 2,
220
	.is_mobile = 1, .need_gfx_hws = 1, .has_fbc = 1,
229
	.is_mobile = 1, .need_gfx_hws = 1, .has_fbc = 1,
221
	.has_pipe_cxsr = 1, .has_hotplug = 1,
230
	.has_pipe_cxsr = 1, .has_hotplug = 1,
222
	.supports_tv = 1,
231
	.supports_tv = 1,
223
	.has_bsd_ring = 1,
232
	.ring_mask = RENDER_RING | BSD_RING,
224
};
233
};
225
 
234
 
226
static const struct intel_device_info intel_pineview_info = {
235
static const struct intel_device_info intel_pineview_info = {
227
	.gen = 3, .is_g33 = 1, .is_pineview = 1, .is_mobile = 1, .num_pipes = 2,
236
	.gen = 3, .is_g33 = 1, .is_pineview = 1, .is_mobile = 1, .num_pipes = 2,
228
	.need_gfx_hws = 1, .has_hotplug = 1,
237
	.need_gfx_hws = 1, .has_hotplug = 1,
229
	.has_overlay = 1,
238
	.has_overlay = 1,
230
};
239
};
231
 
240
 
232
static const struct intel_device_info intel_ironlake_d_info = {
241
static const struct intel_device_info intel_ironlake_d_info = {
233
	.gen = 5, .num_pipes = 2,
242
	.gen = 5, .num_pipes = 2,
234
	.need_gfx_hws = 1, .has_hotplug = 1,
243
	.need_gfx_hws = 1, .has_hotplug = 1,
235
	.has_bsd_ring = 1,
244
	.ring_mask = RENDER_RING | BSD_RING,
236
};
245
};
237
 
246
 
238
static const struct intel_device_info intel_ironlake_m_info = {
247
static const struct intel_device_info intel_ironlake_m_info = {
239
	.gen = 5, .is_mobile = 1, .num_pipes = 2,
248
	.gen = 5, .is_mobile = 1, .num_pipes = 2,
240
	.need_gfx_hws = 1, .has_hotplug = 1,
249
	.need_gfx_hws = 1, .has_hotplug = 1,
241
	.has_fbc = 1,
250
	.has_fbc = 1,
242
	.has_bsd_ring = 1,
251
	.ring_mask = RENDER_RING | BSD_RING,
243
};
252
};
244
 
253
 
245
static const struct intel_device_info intel_sandybridge_d_info = {
254
static const struct intel_device_info intel_sandybridge_d_info = {
246
	.gen = 6, .num_pipes = 2,
255
	.gen = 6, .num_pipes = 2,
247
	.need_gfx_hws = 1, .has_hotplug = 1,
256
	.need_gfx_hws = 1, .has_hotplug = 1,
248
    .has_bsd_ring = 1,
257
	.has_fbc = 1,
249
    .has_blt_ring = 1,
258
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING,
250
	.has_llc = 1,
259
	.has_llc = 1,
251
	.has_force_wake = 1,
-
 
252
};
260
};
253
 
261
 
254
static const struct intel_device_info intel_sandybridge_m_info = {
262
static const struct intel_device_info intel_sandybridge_m_info = {
255
	.gen = 6, .is_mobile = 1, .num_pipes = 2,
263
	.gen = 6, .is_mobile = 1, .num_pipes = 2,
256
	.need_gfx_hws = 1, .has_hotplug = 1,
264
	.need_gfx_hws = 1, .has_hotplug = 1,
257
    .has_fbc      = 1,
265
    .has_fbc      = 1,
258
    .has_bsd_ring = 1,
-
 
259
    .has_blt_ring = 1,
266
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING,
260
	.has_llc = 1,
267
	.has_llc = 1,
261
	.has_force_wake = 1,
-
 
262
};
268
};
263
 
269
 
264
#define GEN7_FEATURES  \
270
#define GEN7_FEATURES  \
265
	.gen = 7, .num_pipes = 3, \
271
	.gen = 7, .num_pipes = 3, \
266
	.need_gfx_hws = 1, .has_hotplug = 1, \
272
	.need_gfx_hws = 1, .has_hotplug = 1, \
267
	.has_bsd_ring = 1, \
273
	.has_fbc = 1, \
268
	.has_blt_ring = 1, \
274
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
269
	.has_llc = 1, \
275
	.has_llc = 1
270
	.has_force_wake = 1
-
 
271
 
276
 
272
static const struct intel_device_info intel_ivybridge_d_info = {
277
static const struct intel_device_info intel_ivybridge_d_info = {
273
	GEN7_FEATURES,
278
	GEN7_FEATURES,
274
	.is_ivybridge = 1,
279
	.is_ivybridge = 1,
275
};
280
};
276
 
281
 
277
static const struct intel_device_info intel_ivybridge_m_info = {
282
static const struct intel_device_info intel_ivybridge_m_info = {
278
	GEN7_FEATURES,
283
	GEN7_FEATURES,
279
	.is_ivybridge = 1,
284
	.is_ivybridge = 1,
280
	.is_mobile = 1,
285
	.is_mobile = 1,
281
	.has_fbc = 1,
-
 
282
};
286
};
283
 
287
 
284
static const struct intel_device_info intel_ivybridge_q_info = {
288
static const struct intel_device_info intel_ivybridge_q_info = {
285
	GEN7_FEATURES,
289
	GEN7_FEATURES,
286
	.is_ivybridge = 1,
290
	.is_ivybridge = 1,
287
	.num_pipes = 0, /* legal, last one wins */
291
	.num_pipes = 0, /* legal, last one wins */
288
};
292
};
289
 
293
 
290
static const struct intel_device_info intel_valleyview_m_info = {
294
static const struct intel_device_info intel_valleyview_m_info = {
291
	GEN7_FEATURES,
295
	GEN7_FEATURES,
292
	.is_mobile = 1,
296
	.is_mobile = 1,
293
	.num_pipes = 2,
297
	.num_pipes = 2,
294
	.is_valleyview = 1,
298
	.is_valleyview = 1,
295
	.display_mmio_offset = VLV_DISPLAY_BASE,
299
	.display_mmio_offset = VLV_DISPLAY_BASE,
-
 
300
	.has_fbc = 0, /* legal, last one wins */
296
	.has_llc = 0, /* legal, last one wins */
301
	.has_llc = 0, /* legal, last one wins */
297
};
302
};
298
 
303
 
299
static const struct intel_device_info intel_valleyview_d_info = {
304
static const struct intel_device_info intel_valleyview_d_info = {
300
	GEN7_FEATURES,
305
	GEN7_FEATURES,
301
	.num_pipes = 2,
306
	.num_pipes = 2,
302
	.is_valleyview = 1,
307
	.is_valleyview = 1,
303
	.display_mmio_offset = VLV_DISPLAY_BASE,
308
	.display_mmio_offset = VLV_DISPLAY_BASE,
-
 
309
	.has_fbc = 0, /* legal, last one wins */
304
	.has_llc = 0, /* legal, last one wins */
310
	.has_llc = 0, /* legal, last one wins */
305
};
311
};
306
 
312
 
307
static const struct intel_device_info intel_haswell_d_info = {
313
static const struct intel_device_info intel_haswell_d_info = {
308
	GEN7_FEATURES,
314
	GEN7_FEATURES,
309
	.is_haswell = 1,
315
	.is_haswell = 1,
310
	.has_ddi = 1,
316
	.has_ddi = 1,
311
	.has_fpga_dbg = 1,
317
	.has_fpga_dbg = 1,
312
	.has_vebox_ring = 1,
318
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
313
};
319
};
314
 
320
 
315
static const struct intel_device_info intel_haswell_m_info = {
321
static const struct intel_device_info intel_haswell_m_info = {
316
	GEN7_FEATURES,
322
	GEN7_FEATURES,
317
	.is_haswell = 1,
323
	.is_haswell = 1,
318
	.is_mobile = 1,
324
	.is_mobile = 1,
319
	.has_ddi = 1,
325
	.has_ddi = 1,
320
	.has_fpga_dbg = 1,
326
	.has_fpga_dbg = 1,
-
 
327
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
-
 
328
};
-
 
329
 
-
 
330
static const struct intel_device_info intel_broadwell_d_info = {
-
 
331
	.gen = 8, .num_pipes = 3,
-
 
332
	.need_gfx_hws = 1, .has_hotplug = 1,
-
 
333
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
321
	.has_fbc = 1,
334
	.has_llc = 1,
-
 
335
	.has_ddi = 1,
-
 
336
};
-
 
337
 
-
 
338
static const struct intel_device_info intel_broadwell_m_info = {
-
 
339
	.gen = 8, .is_mobile = 1, .num_pipes = 3,
-
 
340
	.need_gfx_hws = 1, .has_hotplug = 1,
-
 
341
	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
-
 
342
	.has_llc = 1,
322
	.has_vebox_ring = 1,
343
	.has_ddi = 1,
323
};
344
};
324
 
345
 
325
/*
346
/*
326
 * Make sure any device matches here are from most specific to most
347
 * Make sure any device matches here are from most specific to most
327
 * general.  For example, since the Quanta match is based on the subsystem
348
 * general.  For example, since the Quanta match is based on the subsystem
328
 * and subvendor IDs, we need it to come before the more general IVB
349
 * and subvendor IDs, we need it to come before the more general IVB
329
 * PCI ID matches, otherwise we'll use the wrong info struct above.
350
 * PCI ID matches, otherwise we'll use the wrong info struct above.
330
 */
351
 */
331
#define INTEL_PCI_IDS \
352
#define INTEL_PCI_IDS \
332
	INTEL_I915G_IDS(&intel_i915g_info),	\
353
	INTEL_I915G_IDS(&intel_i915g_info),	\
333
	INTEL_I915GM_IDS(&intel_i915gm_info),	\
354
	INTEL_I915GM_IDS(&intel_i915gm_info),	\
334
	INTEL_I945G_IDS(&intel_i945g_info),	\
355
	INTEL_I945G_IDS(&intel_i945g_info),	\
335
	INTEL_I945GM_IDS(&intel_i945gm_info),	\
356
	INTEL_I945GM_IDS(&intel_i945gm_info),	\
336
	INTEL_I965G_IDS(&intel_i965g_info),	\
357
	INTEL_I965G_IDS(&intel_i965g_info),	\
337
	INTEL_G33_IDS(&intel_g33_info),		\
358
	INTEL_G33_IDS(&intel_g33_info),		\
338
	INTEL_I965GM_IDS(&intel_i965gm_info),	\
359
	INTEL_I965GM_IDS(&intel_i965gm_info),	\
339
	INTEL_GM45_IDS(&intel_gm45_info), 	\
360
	INTEL_GM45_IDS(&intel_gm45_info), 	\
340
	INTEL_G45_IDS(&intel_g45_info), 	\
361
	INTEL_G45_IDS(&intel_g45_info), 	\
341
	INTEL_PINEVIEW_IDS(&intel_pineview_info),	\
362
	INTEL_PINEVIEW_IDS(&intel_pineview_info),	\
342
	INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info),	\
363
	INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info),	\
343
	INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info),	\
364
	INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info),	\
344
	INTEL_SNB_D_IDS(&intel_sandybridge_d_info),	\
365
	INTEL_SNB_D_IDS(&intel_sandybridge_d_info),	\
345
	INTEL_SNB_M_IDS(&intel_sandybridge_m_info),	\
366
	INTEL_SNB_M_IDS(&intel_sandybridge_m_info),	\
346
	INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */ \
367
	INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */ \
347
	INTEL_IVB_M_IDS(&intel_ivybridge_m_info),	\
368
	INTEL_IVB_M_IDS(&intel_ivybridge_m_info),	\
348
	INTEL_IVB_D_IDS(&intel_ivybridge_d_info),	\
369
	INTEL_IVB_D_IDS(&intel_ivybridge_d_info),	\
349
	INTEL_HSW_D_IDS(&intel_haswell_d_info), \
370
	INTEL_HSW_D_IDS(&intel_haswell_d_info), \
350
	INTEL_HSW_M_IDS(&intel_haswell_m_info), \
371
	INTEL_HSW_M_IDS(&intel_haswell_m_info), \
351
	INTEL_VLV_M_IDS(&intel_valleyview_m_info),	\
372
	INTEL_VLV_M_IDS(&intel_valleyview_m_info),	\
352
	INTEL_VLV_D_IDS(&intel_valleyview_d_info)
373
	INTEL_VLV_D_IDS(&intel_valleyview_d_info),	\
-
 
374
	INTEL_BDW_M_IDS(&intel_broadwell_m_info),	\
-
 
375
	INTEL_BDW_D_IDS(&intel_broadwell_d_info)
353
 
376
 
354
static const struct pci_device_id pciidlist[] = {       /* aka */
377
static const struct pci_device_id pciidlist[] = {       /* aka */
355
	INTEL_PCI_IDS,
378
	INTEL_PCI_IDS,
356
    {0, 0, 0}
379
    {0, 0, 0}
357
};
380
};
358
 
381
 
359
#define INTEL_PCH_DEVICE_ID_MASK        0xff00
382
#define INTEL_PCH_DEVICE_ID_MASK        0xff00
360
#define INTEL_PCH_IBX_DEVICE_ID_TYPE    0x3b00
383
#define INTEL_PCH_IBX_DEVICE_ID_TYPE    0x3b00
361
#define INTEL_PCH_CPT_DEVICE_ID_TYPE    0x1c00
384
#define INTEL_PCH_CPT_DEVICE_ID_TYPE    0x1c00
362
#define INTEL_PCH_PPT_DEVICE_ID_TYPE    0x1e00
385
#define INTEL_PCH_PPT_DEVICE_ID_TYPE    0x1e00
363
#define INTEL_PCH_LPT_DEVICE_ID_TYPE	0x8c00
386
#define INTEL_PCH_LPT_DEVICE_ID_TYPE	0x8c00
364
 
387
 
365
void intel_detect_pch(struct drm_device *dev)
388
void intel_detect_pch(struct drm_device *dev)
366
{
389
{
367
    struct drm_i915_private *dev_priv = dev->dev_private;
390
    struct drm_i915_private *dev_priv = dev->dev_private;
368
    struct pci_dev *pch;
391
    struct pci_dev *pch;
369
 
392
 
370
	/* In all current cases, num_pipes is equivalent to the PCH_NOP setting
393
	/* In all current cases, num_pipes is equivalent to the PCH_NOP setting
371
	 * (which really amounts to a PCH but no South Display).
394
	 * (which really amounts to a PCH but no South Display).
372
	 */
395
	 */
373
	if (INTEL_INFO(dev)->num_pipes == 0) {
396
	if (INTEL_INFO(dev)->num_pipes == 0) {
374
		dev_priv->pch_type = PCH_NOP;
397
		dev_priv->pch_type = PCH_NOP;
375
		return;
398
		return;
376
	}
399
	}
377
 
400
 
378
    /*
401
    /*
379
     * The reason to probe ISA bridge instead of Dev31:Fun0 is to
402
     * The reason to probe ISA bridge instead of Dev31:Fun0 is to
380
     * make graphics device passthrough work easy for VMM, that only
403
     * make graphics device passthrough work easy for VMM, that only
381
     * need to expose ISA bridge to let driver know the real hardware
404
     * need to expose ISA bridge to let driver know the real hardware
382
     * underneath. This is a requirement from virtualization team.
405
     * underneath. This is a requirement from virtualization team.
383
	 *
406
	 *
384
	 * In some virtualized environments (e.g. XEN), there is irrelevant
407
	 * In some virtualized environments (e.g. XEN), there is irrelevant
385
	 * ISA bridge in the system. To work reliably, we should scan trhough
408
	 * ISA bridge in the system. To work reliably, we should scan trhough
386
	 * all the ISA bridge devices and check for the first match, instead
409
	 * all the ISA bridge devices and check for the first match, instead
387
	 * of only checking the first one.
410
	 * of only checking the first one.
388
     */
411
     */
389
    pch = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
412
    pch = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
390
	while (pch) {
413
	while (pch) {
391
		struct pci_dev *curr = pch;
414
		struct pci_dev *curr = pch;
392
        if (pch->vendor == PCI_VENDOR_ID_INTEL) {
415
        if (pch->vendor == PCI_VENDOR_ID_INTEL) {
393
			unsigned short id;
416
			unsigned short id;
394
            id = pch->device & INTEL_PCH_DEVICE_ID_MASK;
417
            id = pch->device & INTEL_PCH_DEVICE_ID_MASK;
395
			dev_priv->pch_id = id;
418
			dev_priv->pch_id = id;
396
 
419
 
397
            if (id == INTEL_PCH_IBX_DEVICE_ID_TYPE) {
420
            if (id == INTEL_PCH_IBX_DEVICE_ID_TYPE) {
398
                dev_priv->pch_type = PCH_IBX;
421
                dev_priv->pch_type = PCH_IBX;
399
                DRM_DEBUG_KMS("Found Ibex Peak PCH\n");
422
                DRM_DEBUG_KMS("Found Ibex Peak PCH\n");
400
				WARN_ON(!IS_GEN5(dev));
423
				WARN_ON(!IS_GEN5(dev));
401
            } else if (id == INTEL_PCH_CPT_DEVICE_ID_TYPE) {
424
            } else if (id == INTEL_PCH_CPT_DEVICE_ID_TYPE) {
402
                dev_priv->pch_type = PCH_CPT;
425
                dev_priv->pch_type = PCH_CPT;
403
                DRM_DEBUG_KMS("Found CougarPoint PCH\n");
426
                DRM_DEBUG_KMS("Found CougarPoint PCH\n");
404
				WARN_ON(!(IS_GEN6(dev) || IS_IVYBRIDGE(dev)));
427
				WARN_ON(!(IS_GEN6(dev) || IS_IVYBRIDGE(dev)));
405
            } else if (id == INTEL_PCH_PPT_DEVICE_ID_TYPE) {
428
            } else if (id == INTEL_PCH_PPT_DEVICE_ID_TYPE) {
406
                /* PantherPoint is CPT compatible */
429
                /* PantherPoint is CPT compatible */
407
                dev_priv->pch_type = PCH_CPT;
430
                dev_priv->pch_type = PCH_CPT;
408
                DRM_DEBUG_KMS("Found PatherPoint PCH\n");
431
				DRM_DEBUG_KMS("Found PantherPoint PCH\n");
409
				WARN_ON(!(IS_GEN6(dev) || IS_IVYBRIDGE(dev)));
432
				WARN_ON(!(IS_GEN6(dev) || IS_IVYBRIDGE(dev)));
410
			} else if (id == INTEL_PCH_LPT_DEVICE_ID_TYPE) {
433
			} else if (id == INTEL_PCH_LPT_DEVICE_ID_TYPE) {
411
				dev_priv->pch_type = PCH_LPT;
434
				dev_priv->pch_type = PCH_LPT;
412
				DRM_DEBUG_KMS("Found LynxPoint PCH\n");
435
				DRM_DEBUG_KMS("Found LynxPoint PCH\n");
413
				WARN_ON(!IS_HASWELL(dev));
436
				WARN_ON(!IS_HASWELL(dev));
414
				WARN_ON(IS_ULT(dev));
437
				WARN_ON(IS_ULT(dev));
-
 
438
			} else if (IS_BROADWELL(dev)) {
-
 
439
				dev_priv->pch_type = PCH_LPT;
-
 
440
				dev_priv->pch_id =
-
 
441
					INTEL_PCH_LPT_LP_DEVICE_ID_TYPE;
-
 
442
				DRM_DEBUG_KMS("This is Broadwell, assuming "
-
 
443
					      "LynxPoint LP PCH\n");
415
			} else if (id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
444
			} else if (id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
416
				dev_priv->pch_type = PCH_LPT;
445
				dev_priv->pch_type = PCH_LPT;
417
				DRM_DEBUG_KMS("Found LynxPoint LP PCH\n");
446
				DRM_DEBUG_KMS("Found LynxPoint LP PCH\n");
418
				WARN_ON(!IS_HASWELL(dev));
447
				WARN_ON(!IS_HASWELL(dev));
419
				WARN_ON(!IS_ULT(dev));
448
				WARN_ON(!IS_ULT(dev));
420
			} else {
449
			} else {
421
				goto check_next;
450
				goto check_next;
422
            }
451
            }
423
			break;
452
			break;
424
        }
453
        }
425
check_next:
454
check_next:
426
		pch = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, curr);
455
		pch = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, curr);
427
//       pci_dev_put(curr);
456
//       pci_dev_put(curr);
428
    }
457
    }
429
	if (!pch)
458
	if (!pch)
430
		DRM_DEBUG_KMS("No PCH found?\n");
459
		DRM_DEBUG_KMS("No PCH found?\n");
431
}
460
}
432
 
461
 
433
bool i915_semaphore_is_enabled(struct drm_device *dev)
462
bool i915_semaphore_is_enabled(struct drm_device *dev)
434
{
463
{
435
	if (INTEL_INFO(dev)->gen < 6)
464
	if (INTEL_INFO(dev)->gen < 6)
436
		return 0;
465
		return false;
-
 
466
 
-
 
467
	/* Until we get further testing... */
-
 
468
	if (IS_GEN8(dev)) {
-
 
469
		WARN_ON(!i915_preliminary_hw_support);
-
 
470
		return false;
-
 
471
	}
437
 
472
 
438
	if (i915_semaphores >= 0)
473
	if (i915_semaphores >= 0)
439
		return i915_semaphores;
474
		return i915_semaphores;
440
 
475
 
441
#ifdef CONFIG_INTEL_IOMMU
476
#ifdef CONFIG_INTEL_IOMMU
442
	/* Enable semaphores on SNB when IO remapping is off */
477
	/* Enable semaphores on SNB when IO remapping is off */
443
	if (INTEL_INFO(dev)->gen == 6 && intel_iommu_gfx_mapped)
478
	if (INTEL_INFO(dev)->gen == 6 && intel_iommu_gfx_mapped)
444
		return false;
479
		return false;
445
#endif
480
#endif
446
 
481
 
447
	return 1;
482
	return true;
448
}
483
}
449
 
484
 
450
#if 0
485
#if 0
451
static int i915_drm_freeze(struct drm_device *dev)
486
static int i915_drm_freeze(struct drm_device *dev)
452
{
487
{
453
	struct drm_i915_private *dev_priv = dev->dev_private;
488
	struct drm_i915_private *dev_priv = dev->dev_private;
454
	struct drm_crtc *crtc;
489
	struct drm_crtc *crtc;
-
 
490
 
-
 
491
	intel_runtime_pm_get(dev_priv);
455
 
492
 
456
	/* ignore lid events during suspend */
493
	/* ignore lid events during suspend */
457
	mutex_lock(&dev_priv->modeset_restore_lock);
494
	mutex_lock(&dev_priv->modeset_restore_lock);
458
	dev_priv->modeset_restore = MODESET_SUSPENDED;
495
	dev_priv->modeset_restore = MODESET_SUSPENDED;
459
	mutex_unlock(&dev_priv->modeset_restore_lock);
496
	mutex_unlock(&dev_priv->modeset_restore_lock);
460
 
497
 
461
	/* We do a lot of poking in a lot of registers, make sure they work
498
	/* We do a lot of poking in a lot of registers, make sure they work
462
	 * properly. */
499
	 * properly. */
463
	hsw_disable_package_c8(dev_priv);
500
	hsw_disable_package_c8(dev_priv);
464
	intel_set_power_well(dev, true);
501
	intel_display_set_init_power(dev, true);
465
 
502
 
466
	drm_kms_helper_poll_disable(dev);
503
	drm_kms_helper_poll_disable(dev);
467
 
504
 
468
	pci_save_state(dev->pdev);
505
	pci_save_state(dev->pdev);
469
 
506
 
470
	/* If KMS is active, we do the leavevt stuff here */
507
	/* If KMS is active, we do the leavevt stuff here */
471
	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
508
	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
472
		int error;
509
		int error;
473
 
-
 
474
		mutex_lock(&dev->struct_mutex);
510
 
475
		error = i915_gem_idle(dev);
-
 
476
		mutex_unlock(&dev->struct_mutex);
511
		error = i915_gem_suspend(dev);
477
		if (error) {
512
		if (error) {
478
			dev_err(&dev->pdev->dev,
513
			dev_err(&dev->pdev->dev,
479
				"GEM idle failed, resume might fail\n");
514
				"GEM idle failed, resume might fail\n");
480
			return error;
515
			return error;
481
		}
516
		}
482
 
517
 
483
		cancel_delayed_work_sync(&dev_priv->rps.delayed_resume_work);
518
		cancel_delayed_work_sync(&dev_priv->rps.delayed_resume_work);
484
 
519
 
485
		drm_irq_uninstall(dev);
520
		drm_irq_uninstall(dev);
486
		dev_priv->enable_hotplug_processing = false;
521
		dev_priv->enable_hotplug_processing = false;
487
		/*
522
		/*
488
		 * Disable CRTCs directly since we want to preserve sw state
523
		 * Disable CRTCs directly since we want to preserve sw state
489
		 * for _thaw.
524
		 * for _thaw.
490
		 */
525
		 */
-
 
526
		mutex_lock(&dev->mode_config.mutex);
491
		list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
527
		list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
492
			dev_priv->display.crtc_disable(crtc);
528
			dev_priv->display.crtc_disable(crtc);
-
 
529
		mutex_unlock(&dev->mode_config.mutex);
493
 
530
 
494
		intel_modeset_suspend_hw(dev);
531
		intel_modeset_suspend_hw(dev);
495
	}
532
	}
-
 
533
 
-
 
534
	i915_gem_suspend_gtt_mappings(dev);
496
 
535
 
497
	i915_save_state(dev);
536
	i915_save_state(dev);
498
 
537
 
499
	intel_opregion_fini(dev);
538
	intel_opregion_fini(dev);
500
 
539
 
501
	console_lock();
540
	console_lock();
502
	intel_fbdev_set_suspend(dev, FBINFO_STATE_SUSPENDED);
541
	intel_fbdev_set_suspend(dev, FBINFO_STATE_SUSPENDED);
503
	console_unlock();
542
	console_unlock();
504
 
543
 
505
	return 0;
544
	return 0;
506
}
545
}
507
 
546
 
508
int i915_suspend(struct drm_device *dev, pm_message_t state)
547
int i915_suspend(struct drm_device *dev, pm_message_t state)
509
{
548
{
510
	int error;
549
	int error;
511
 
550
 
512
	if (!dev || !dev->dev_private) {
551
	if (!dev || !dev->dev_private) {
513
		DRM_ERROR("dev: %p\n", dev);
552
		DRM_ERROR("dev: %p\n", dev);
514
		DRM_ERROR("DRM not initialized, aborting suspend.\n");
553
		DRM_ERROR("DRM not initialized, aborting suspend.\n");
515
		return -ENODEV;
554
		return -ENODEV;
516
	}
555
	}
517
 
556
 
518
	if (state.event == PM_EVENT_PRETHAW)
557
	if (state.event == PM_EVENT_PRETHAW)
519
		return 0;
558
		return 0;
520
 
559
 
521
 
560
 
522
	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
561
	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
523
		return 0;
562
		return 0;
524
 
563
 
525
	error = i915_drm_freeze(dev);
564
	error = i915_drm_freeze(dev);
526
	if (error)
565
	if (error)
527
		return error;
566
		return error;
528
 
567
 
529
	if (state.event == PM_EVENT_SUSPEND) {
568
	if (state.event == PM_EVENT_SUSPEND) {
530
		/* Shut down the device */
569
		/* Shut down the device */
531
		pci_disable_device(dev->pdev);
570
		pci_disable_device(dev->pdev);
532
		pci_set_power_state(dev->pdev, PCI_D3hot);
571
		pci_set_power_state(dev->pdev, PCI_D3hot);
533
	}
572
	}
534
 
573
 
535
	return 0;
574
	return 0;
536
}
575
}
537
 
576
 
538
void intel_console_resume(struct work_struct *work)
577
void intel_console_resume(struct work_struct *work)
539
{
578
{
540
	struct drm_i915_private *dev_priv =
579
	struct drm_i915_private *dev_priv =
541
		container_of(work, struct drm_i915_private,
580
		container_of(work, struct drm_i915_private,
542
			     console_resume_work);
581
			     console_resume_work);
543
	struct drm_device *dev = dev_priv->dev;
582
	struct drm_device *dev = dev_priv->dev;
544
 
583
 
545
	console_lock();
584
	console_lock();
546
	intel_fbdev_set_suspend(dev, FBINFO_STATE_RUNNING);
585
	intel_fbdev_set_suspend(dev, FBINFO_STATE_RUNNING);
547
	console_unlock();
586
	console_unlock();
548
}
587
}
549
 
588
 
550
static void intel_resume_hotplug(struct drm_device *dev)
589
static void intel_resume_hotplug(struct drm_device *dev)
551
{
590
{
552
	struct drm_mode_config *mode_config = &dev->mode_config;
591
	struct drm_mode_config *mode_config = &dev->mode_config;
553
	struct intel_encoder *encoder;
592
	struct intel_encoder *encoder;
554
 
593
 
555
	mutex_lock(&mode_config->mutex);
594
	mutex_lock(&mode_config->mutex);
556
	DRM_DEBUG_KMS("running encoder hotplug functions\n");
595
	DRM_DEBUG_KMS("running encoder hotplug functions\n");
557
 
596
 
558
	list_for_each_entry(encoder, &mode_config->encoder_list, base.head)
597
	list_for_each_entry(encoder, &mode_config->encoder_list, base.head)
559
		if (encoder->hot_plug)
598
		if (encoder->hot_plug)
560
			encoder->hot_plug(encoder);
599
			encoder->hot_plug(encoder);
561
 
600
 
562
	mutex_unlock(&mode_config->mutex);
601
	mutex_unlock(&mode_config->mutex);
563
 
602
 
564
	/* Just fire off a uevent and let userspace tell us what to do */
603
	/* Just fire off a uevent and let userspace tell us what to do */
565
	drm_helper_hpd_irq_event(dev);
604
	drm_helper_hpd_irq_event(dev);
566
}
605
}
567
 
606
 
568
static int __i915_drm_thaw(struct drm_device *dev)
607
static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings)
569
{
608
{
570
	struct drm_i915_private *dev_priv = dev->dev_private;
609
	struct drm_i915_private *dev_priv = dev->dev_private;
571
	int error = 0;
610
	int error = 0;
-
 
611
 
-
 
612
	intel_uncore_early_sanitize(dev);
-
 
613
 
-
 
614
	intel_uncore_sanitize(dev);
-
 
615
 
-
 
616
	if (drm_core_check_feature(dev, DRIVER_MODESET) &&
-
 
617
	    restore_gtt_mappings) {
-
 
618
		mutex_lock(&dev->struct_mutex);
-
 
619
		i915_gem_restore_gtt_mappings(dev);
-
 
620
		mutex_unlock(&dev->struct_mutex);
-
 
621
	}
-
 
622
 
-
 
623
	intel_power_domains_init_hw(dev);
572
 
624
 
573
	i915_restore_state(dev);
625
	i915_restore_state(dev);
574
	intel_opregion_setup(dev);
626
	intel_opregion_setup(dev);
575
 
627
 
576
	/* KMS EnterVT equivalent */
628
	/* KMS EnterVT equivalent */
577
	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
629
	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
578
		intel_init_pch_refclk(dev);
630
		intel_init_pch_refclk(dev);
579
 
631
 
580
		mutex_lock(&dev->struct_mutex);
632
		mutex_lock(&dev->struct_mutex);
581
 
633
 
582
		error = i915_gem_init_hw(dev);
634
		error = i915_gem_init_hw(dev);
583
		mutex_unlock(&dev->struct_mutex);
635
		mutex_unlock(&dev->struct_mutex);
584
 
636
 
585
		/* We need working interrupts for modeset enabling ... */
637
		/* We need working interrupts for modeset enabling ... */
586
		drm_irq_install(dev);
638
		drm_irq_install(dev);
587
 
639
 
588
		intel_modeset_init_hw(dev);
640
		intel_modeset_init_hw(dev);
589
 
641
 
590
		drm_modeset_lock_all(dev);
642
		drm_modeset_lock_all(dev);
-
 
643
		drm_mode_config_reset(dev);
591
		intel_modeset_setup_hw_state(dev, true);
644
		intel_modeset_setup_hw_state(dev, true);
592
		drm_modeset_unlock_all(dev);
645
		drm_modeset_unlock_all(dev);
593
 
646
 
594
		/*
647
		/*
595
		 * ... but also need to make sure that hotplug processing
648
		 * ... but also need to make sure that hotplug processing
596
		 * doesn't cause havoc. Like in the driver load code we don't
649
		 * doesn't cause havoc. Like in the driver load code we don't
597
		 * bother with the tiny race here where we might loose hotplug
650
		 * bother with the tiny race here where we might loose hotplug
598
		 * notifications.
651
		 * notifications.
599
		 * */
652
		 * */
600
		intel_hpd_init(dev);
653
		intel_hpd_init(dev);
601
		dev_priv->enable_hotplug_processing = true;
654
		dev_priv->enable_hotplug_processing = true;
602
		/* Config may have changed between suspend and resume */
655
		/* Config may have changed between suspend and resume */
603
		intel_resume_hotplug(dev);
656
		intel_resume_hotplug(dev);
604
	}
657
	}
605
 
658
 
606
	intel_opregion_init(dev);
659
	intel_opregion_init(dev);
607
 
660
 
608
	/*
661
	/*
609
	 * The console lock can be pretty contented on resume due
662
	 * The console lock can be pretty contented on resume due
610
	 * to all the printk activity.  Try to keep it out of the hot
663
	 * to all the printk activity.  Try to keep it out of the hot
611
	 * path of resume if possible.
664
	 * path of resume if possible.
612
	 */
665
	 */
613
	if (console_trylock()) {
666
	if (console_trylock()) {
614
		intel_fbdev_set_suspend(dev, FBINFO_STATE_RUNNING);
667
		intel_fbdev_set_suspend(dev, FBINFO_STATE_RUNNING);
615
		console_unlock();
668
		console_unlock();
616
	} else {
669
	} else {
617
		schedule_work(&dev_priv->console_resume_work);
670
		schedule_work(&dev_priv->console_resume_work);
618
	}
671
	}
619
 
672
 
620
	/* Undo what we did at i915_drm_freeze so the refcount goes back to the
673
	/* Undo what we did at i915_drm_freeze so the refcount goes back to the
621
	 * expected level. */
674
	 * expected level. */
622
	hsw_enable_package_c8(dev_priv);
675
	hsw_enable_package_c8(dev_priv);
623
 
676
 
624
	mutex_lock(&dev_priv->modeset_restore_lock);
677
	mutex_lock(&dev_priv->modeset_restore_lock);
625
	dev_priv->modeset_restore = MODESET_DONE;
678
	dev_priv->modeset_restore = MODESET_DONE;
626
	mutex_unlock(&dev_priv->modeset_restore_lock);
679
	mutex_unlock(&dev_priv->modeset_restore_lock);
-
 
680
 
-
 
681
	intel_runtime_pm_put(dev_priv);
627
	return error;
682
	return error;
628
}
683
}
629
 
684
 
630
static int i915_drm_thaw(struct drm_device *dev)
685
static int i915_drm_thaw(struct drm_device *dev)
631
{
686
{
632
	int error = 0;
-
 
633
 
-
 
634
	intel_uncore_sanitize(dev);
-
 
635
 
-
 
636
	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
687
	if (drm_core_check_feature(dev, DRIVER_MODESET))
637
		mutex_lock(&dev->struct_mutex);
-
 
638
		i915_gem_restore_gtt_mappings(dev);
-
 
639
		mutex_unlock(&dev->struct_mutex);
-
 
640
	} else if (drm_core_check_feature(dev, DRIVER_MODESET))
-
 
641
		i915_check_and_clear_faults(dev);
688
		i915_check_and_clear_faults(dev);
642
 
689
 
643
	__i915_drm_thaw(dev);
-
 
644
 
-
 
645
	return error;
690
	return __i915_drm_thaw(dev, true);
646
}
691
}
647
 
692
 
648
int i915_resume(struct drm_device *dev)
693
int i915_resume(struct drm_device *dev)
649
{
694
{
650
	struct drm_i915_private *dev_priv = dev->dev_private;
695
	struct drm_i915_private *dev_priv = dev->dev_private;
651
	int ret;
696
	int ret;
652
 
697
 
653
	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
698
	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
654
		return 0;
699
		return 0;
655
 
700
 
656
	if (pci_enable_device(dev->pdev))
701
	if (pci_enable_device(dev->pdev))
657
		return -EIO;
702
		return -EIO;
658
 
703
 
659
	pci_set_master(dev->pdev);
704
	pci_set_master(dev->pdev);
660
 
-
 
661
	intel_uncore_sanitize(dev);
-
 
662
 
705
 
663
	/*
706
	/*
664
	 * Platforms with opregion should have sane BIOS, older ones (gen3 and
707
	 * Platforms with opregion should have sane BIOS, older ones (gen3 and
-
 
708
	 * earlier) need to restore the GTT mappings since the BIOS might clear
665
	 * earlier) need this since the BIOS might clear all our scratch PTEs.
709
	 * all our scratch PTEs.
666
	 */
-
 
667
	if (drm_core_check_feature(dev, DRIVER_MODESET) &&
710
	 */
668
	    !dev_priv->opregion.header) {
-
 
669
		mutex_lock(&dev->struct_mutex);
-
 
670
		i915_gem_restore_gtt_mappings(dev);
-
 
671
		mutex_unlock(&dev->struct_mutex);
-
 
672
	}
-
 
673
 
-
 
674
	ret = __i915_drm_thaw(dev);
711
	ret = __i915_drm_thaw(dev, !dev_priv->opregion.header);
675
	if (ret)
712
	if (ret)
676
		return ret;
713
		return ret;
677
 
714
 
678
	drm_kms_helper_poll_enable(dev);
715
	drm_kms_helper_poll_enable(dev);
679
	return 0;
716
	return 0;
680
}
717
}
681
 
718
 
682
/**
719
/**
683
 * i915_reset - reset chip after a hang
720
 * i915_reset - reset chip after a hang
684
 * @dev: drm device to reset
721
 * @dev: drm device to reset
685
 *
722
 *
686
 * Reset the chip.  Useful if a hang is detected. Returns zero on successful
723
 * Reset the chip.  Useful if a hang is detected. Returns zero on successful
687
 * reset or otherwise an error code.
724
 * reset or otherwise an error code.
688
 *
725
 *
689
 * Procedure is fairly simple:
726
 * Procedure is fairly simple:
690
 *   - reset the chip using the reset reg
727
 *   - reset the chip using the reset reg
691
 *   - re-init context state
728
 *   - re-init context state
692
 *   - re-init hardware status page
729
 *   - re-init hardware status page
693
 *   - re-init ring buffer
730
 *   - re-init ring buffer
694
 *   - re-init interrupt state
731
 *   - re-init interrupt state
695
 *   - re-init display
732
 *   - re-init display
696
 */
733
 */
697
int i915_reset(struct drm_device *dev)
734
int i915_reset(struct drm_device *dev)
698
{
735
{
699
	drm_i915_private_t *dev_priv = dev->dev_private;
736
	drm_i915_private_t *dev_priv = dev->dev_private;
700
	bool simulated;
737
	bool simulated;
701
	int ret;
738
	int ret;
702
 
739
 
703
	if (!i915_try_reset)
740
	if (!i915_try_reset)
704
		return 0;
741
		return 0;
705
 
742
 
706
	mutex_lock(&dev->struct_mutex);
743
	mutex_lock(&dev->struct_mutex);
707
 
744
 
708
	i915_gem_reset(dev);
745
	i915_gem_reset(dev);
709
 
746
 
710
	simulated = dev_priv->gpu_error.stop_rings != 0;
747
	simulated = dev_priv->gpu_error.stop_rings != 0;
711
 
-
 
712
	if (!simulated && get_seconds() - dev_priv->gpu_error.last_reset < 5) {
-
 
713
		DRM_ERROR("GPU hanging too fast, declaring wedged!\n");
-
 
714
		ret = -ENODEV;
-
 
715
	} else {
748
 
716
		ret = intel_gpu_reset(dev);
749
		ret = intel_gpu_reset(dev);
717
 
750
 
718
		/* Also reset the gpu hangman. */
751
		/* Also reset the gpu hangman. */
719
		if (simulated) {
752
		if (simulated) {
720
			DRM_INFO("Simulated gpu hang, resetting stop_rings\n");
753
			DRM_INFO("Simulated gpu hang, resetting stop_rings\n");
721
			dev_priv->gpu_error.stop_rings = 0;
754
			dev_priv->gpu_error.stop_rings = 0;
722
			if (ret == -ENODEV) {
755
			if (ret == -ENODEV) {
723
				DRM_ERROR("Reset not implemented, but ignoring "
756
			DRM_INFO("Reset not implemented, but ignoring "
724
					  "error for simulated gpu hangs\n");
757
					  "error for simulated gpu hangs\n");
725
				ret = 0;
758
				ret = 0;
726
			}
759
			}
727
		} else
-
 
728
			dev_priv->gpu_error.last_reset = get_seconds();
-
 
729
	}
760
	}
-
 
761
 
730
	if (ret) {
762
	if (ret) {
731
		DRM_ERROR("Failed to reset chip.\n");
763
		DRM_ERROR("Failed to reset chip: %i\n", ret);
732
		mutex_unlock(&dev->struct_mutex);
764
		mutex_unlock(&dev->struct_mutex);
733
		return ret;
765
		return ret;
734
	}
766
	}
735
 
767
 
736
	/* Ok, now get things going again... */
768
	/* Ok, now get things going again... */
737
 
769
 
738
	/*
770
	/*
739
	 * Everything depends on having the GTT running, so we need to start
771
	 * Everything depends on having the GTT running, so we need to start
740
	 * there.  Fortunately we don't need to do this unless we reset the
772
	 * there.  Fortunately we don't need to do this unless we reset the
741
	 * chip at a PCI level.
773
	 * chip at a PCI level.
742
	 *
774
	 *
743
	 * Next we need to restore the context, but we don't use those
775
	 * Next we need to restore the context, but we don't use those
744
	 * yet either...
776
	 * yet either...
745
	 *
777
	 *
746
	 * Ring buffer needs to be re-initialized in the KMS case, or if X
778
	 * Ring buffer needs to be re-initialized in the KMS case, or if X
747
	 * was running at the time of the reset (i.e. we weren't VT
779
	 * was running at the time of the reset (i.e. we weren't VT
748
	 * switched away).
780
	 * switched away).
749
	 */
781
	 */
750
	if (drm_core_check_feature(dev, DRIVER_MODESET) ||
782
	if (drm_core_check_feature(dev, DRIVER_MODESET) ||
751
			!dev_priv->ums.mm_suspended) {
783
			!dev_priv->ums.mm_suspended) {
752
		struct intel_ring_buffer *ring;
-
 
753
		int i;
-
 
754
 
-
 
755
		dev_priv->ums.mm_suspended = 0;
784
		dev_priv->ums.mm_suspended = 0;
756
 
785
 
757
		i915_gem_init_swizzling(dev);
-
 
758
 
-
 
759
		for_each_ring(ring, dev_priv, i)
-
 
760
			ring->init(ring);
-
 
761
 
-
 
762
		i915_gem_context_init(dev);
-
 
763
		if (dev_priv->mm.aliasing_ppgtt) {
-
 
764
			ret = dev_priv->mm.aliasing_ppgtt->enable(dev);
-
 
765
			if (ret)
-
 
766
				i915_gem_cleanup_aliasing_ppgtt(dev);
-
 
767
		}
-
 
768
 
-
 
769
		/*
-
 
770
		 * It would make sense to re-init all the other hw state, at
-
 
771
		 * least the rps/rc6/emon init done within modeset_init_hw. For
-
 
772
		 * some unknown reason, this blows up my ilk, so don't.
-
 
773
		 */
-
 
774
 
786
		ret = i915_gem_init_hw(dev);
-
 
787
		mutex_unlock(&dev->struct_mutex);
-
 
788
		if (ret) {
-
 
789
			DRM_ERROR("Failed hw init on reset %d\n", ret);
-
 
790
			return ret;
775
		mutex_unlock(&dev->struct_mutex);
791
		}
776
 
792
 
777
		drm_irq_uninstall(dev);
793
		drm_irq_uninstall(dev);
778
		drm_irq_install(dev);
794
		drm_irq_install(dev);
779
		intel_hpd_init(dev);
795
		intel_hpd_init(dev);
780
	} else {
796
	} else {
781
		mutex_unlock(&dev->struct_mutex);
797
		mutex_unlock(&dev->struct_mutex);
782
	}
798
	}
783
 
799
 
784
	return 0;
800
	return 0;
785
}
801
}
786
 
802
 
787
static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
803
static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
788
{
804
{
789
	struct intel_device_info *intel_info =
805
	struct intel_device_info *intel_info =
790
		(struct intel_device_info *) ent->driver_data;
806
		(struct intel_device_info *) ent->driver_data;
-
 
807
 
-
 
808
	if (IS_PRELIMINARY_HW(intel_info) && !i915_preliminary_hw_support) {
-
 
809
		DRM_INFO("This hardware requires preliminary hardware support.\n"
-
 
810
			 "See CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT, and/or modparam preliminary_hw_support\n");
-
 
811
		return -ENODEV;
-
 
812
	}
791
 
813
 
792
	/* Only bind to function 0 of the device. Early generations
814
	/* Only bind to function 0 of the device. Early generations
793
	 * used function 1 as a placeholder for multi-head. This causes
815
	 * used function 1 as a placeholder for multi-head. This causes
794
	 * us confusion instead, especially on the systems where both
816
	 * us confusion instead, especially on the systems where both
795
	 * functions have the same PCI-ID!
817
	 * functions have the same PCI-ID!
796
	 */
818
	 */
797
	if (PCI_FUNC(pdev->devfn))
819
	if (PCI_FUNC(pdev->devfn))
798
		return -ENODEV;
820
		return -ENODEV;
799
 
821
 
800
	/* We've managed to ship a kms-enabled ddx that shipped with an XvMC
822
	/* We've managed to ship a kms-enabled ddx that shipped with an XvMC
801
	 * implementation for gen3 (and only gen3) that used legacy drm maps
823
	 * implementation for gen3 (and only gen3) that used legacy drm maps
802
	 * (gasp!) to share buffers between X and the client. Hence we need to
824
	 * (gasp!) to share buffers between X and the client. Hence we need to
803
	 * keep around the fake agp stuff for gen3, even when kms is enabled. */
825
	 * keep around the fake agp stuff for gen3, even when kms is enabled. */
804
	if (intel_info->gen != 3) {
826
	if (intel_info->gen != 3) {
805
		driver.driver_features &=
827
		driver.driver_features &=
806
			~(DRIVER_USE_AGP | DRIVER_REQUIRE_AGP);
828
			~(DRIVER_USE_AGP | DRIVER_REQUIRE_AGP);
807
	} else if (!intel_agp_enabled) {
829
	} else if (!intel_agp_enabled) {
808
		DRM_ERROR("drm/i915 can't work without intel_agp module!\n");
830
		DRM_ERROR("drm/i915 can't work without intel_agp module!\n");
809
		return -ENODEV;
831
		return -ENODEV;
810
	}
832
	}
811
 
833
 
812
	return drm_get_pci_dev(pdev, ent, &driver);
834
	return drm_get_pci_dev(pdev, ent, &driver);
813
}
835
}
814
 
836
 
815
static void
837
static void
816
i915_pci_remove(struct pci_dev *pdev)
838
i915_pci_remove(struct pci_dev *pdev)
817
{
839
{
818
	struct drm_device *dev = pci_get_drvdata(pdev);
840
	struct drm_device *dev = pci_get_drvdata(pdev);
819
 
841
 
820
	drm_put_dev(dev);
842
	drm_put_dev(dev);
821
}
843
}
822
 
844
 
823
static int i915_pm_suspend(struct device *dev)
845
static int i915_pm_suspend(struct device *dev)
824
{
846
{
825
	struct pci_dev *pdev = to_pci_dev(dev);
847
	struct pci_dev *pdev = to_pci_dev(dev);
826
	struct drm_device *drm_dev = pci_get_drvdata(pdev);
848
	struct drm_device *drm_dev = pci_get_drvdata(pdev);
827
	int error;
849
	int error;
828
 
850
 
829
	if (!drm_dev || !drm_dev->dev_private) {
851
	if (!drm_dev || !drm_dev->dev_private) {
830
		dev_err(dev, "DRM not initialized, aborting suspend.\n");
852
		dev_err(dev, "DRM not initialized, aborting suspend.\n");
831
		return -ENODEV;
853
		return -ENODEV;
832
	}
854
	}
833
 
855
 
834
	if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF)
856
	if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF)
835
		return 0;
857
		return 0;
836
 
858
 
837
	error = i915_drm_freeze(drm_dev);
859
	error = i915_drm_freeze(drm_dev);
838
	if (error)
860
	if (error)
839
		return error;
861
		return error;
840
 
862
 
841
	pci_disable_device(pdev);
863
	pci_disable_device(pdev);
842
	pci_set_power_state(pdev, PCI_D3hot);
864
	pci_set_power_state(pdev, PCI_D3hot);
843
 
865
 
844
	return 0;
866
	return 0;
845
}
867
}
846
 
868
 
847
static int i915_pm_resume(struct device *dev)
869
static int i915_pm_resume(struct device *dev)
848
{
870
{
849
	struct pci_dev *pdev = to_pci_dev(dev);
871
	struct pci_dev *pdev = to_pci_dev(dev);
850
	struct drm_device *drm_dev = pci_get_drvdata(pdev);
872
	struct drm_device *drm_dev = pci_get_drvdata(pdev);
851
 
873
 
852
	return i915_resume(drm_dev);
874
	return i915_resume(drm_dev);
853
}
875
}
854
 
876
 
855
static int i915_pm_freeze(struct device *dev)
877
static int i915_pm_freeze(struct device *dev)
856
{
878
{
857
	struct pci_dev *pdev = to_pci_dev(dev);
879
	struct pci_dev *pdev = to_pci_dev(dev);
858
	struct drm_device *drm_dev = pci_get_drvdata(pdev);
880
	struct drm_device *drm_dev = pci_get_drvdata(pdev);
859
 
881
 
860
	if (!drm_dev || !drm_dev->dev_private) {
882
	if (!drm_dev || !drm_dev->dev_private) {
861
		dev_err(dev, "DRM not initialized, aborting suspend.\n");
883
		dev_err(dev, "DRM not initialized, aborting suspend.\n");
862
		return -ENODEV;
884
		return -ENODEV;
863
	}
885
	}
864
 
886
 
865
	return i915_drm_freeze(drm_dev);
887
	return i915_drm_freeze(drm_dev);
866
}
888
}
867
 
889
 
868
static int i915_pm_thaw(struct device *dev)
890
static int i915_pm_thaw(struct device *dev)
869
{
891
{
870
	struct pci_dev *pdev = to_pci_dev(dev);
892
	struct pci_dev *pdev = to_pci_dev(dev);
871
	struct drm_device *drm_dev = pci_get_drvdata(pdev);
893
	struct drm_device *drm_dev = pci_get_drvdata(pdev);
872
 
894
 
873
	return i915_drm_thaw(drm_dev);
895
	return i915_drm_thaw(drm_dev);
874
}
896
}
875
 
897
 
876
static int i915_pm_poweroff(struct device *dev)
898
static int i915_pm_poweroff(struct device *dev)
877
{
899
{
878
	struct pci_dev *pdev = to_pci_dev(dev);
900
	struct pci_dev *pdev = to_pci_dev(dev);
879
	struct drm_device *drm_dev = pci_get_drvdata(pdev);
901
	struct drm_device *drm_dev = pci_get_drvdata(pdev);
880
 
902
 
881
	return i915_drm_freeze(drm_dev);
903
	return i915_drm_freeze(drm_dev);
882
}
904
}
-
 
905
 
883
 
906
 
884
#endif
907
#endif
885
 
908
 
886
static struct drm_driver driver = {
909
static struct drm_driver driver = {
887
    /* Don't use MTRRs here; the Xserver or userspace app should
910
    /* Don't use MTRRs here; the Xserver or userspace app should
888
     * deal with them for Intel hardware.
911
     * deal with them for Intel hardware.
889
     */
912
     */
890
    .driver_features =
913
    .driver_features =
891
	    DRIVER_USE_AGP | DRIVER_REQUIRE_AGP |
914
	    DRIVER_USE_AGP |
892
	    DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | DRIVER_PRIME |
915
	    DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | DRIVER_PRIME |
893
	    DRIVER_RENDER,
916
	    DRIVER_RENDER,
894
    .load = i915_driver_load,
917
    .load = i915_driver_load,
895
//    .unload = i915_driver_unload,
918
//    .unload = i915_driver_unload,
896
      .open = i915_driver_open,
919
      .open = i915_driver_open,
897
//    .lastclose = i915_driver_lastclose,
920
//    .lastclose = i915_driver_lastclose,
898
//    .preclose = i915_driver_preclose,
921
//    .preclose = i915_driver_preclose,
899
//    .postclose = i915_driver_postclose,
922
//    .postclose = i915_driver_postclose,
900
 
923
 
901
    /* Used in place of i915_pm_ops for non-DRIVER_MODESET */
924
    /* Used in place of i915_pm_ops for non-DRIVER_MODESET */
902
//    .suspend = i915_suspend,
925
//    .suspend = i915_suspend,
903
//    .resume = i915_resume,
926
//    .resume = i915_resume,
904
 
927
 
905
//    .device_is_agp = i915_driver_device_is_agp,
928
//    .device_is_agp = i915_driver_device_is_agp,
906
//    .master_create = i915_master_create,
929
//    .master_create = i915_master_create,
907
//    .master_destroy = i915_master_destroy,
930
//    .master_destroy = i915_master_destroy,
908
#if defined(CONFIG_DEBUG_FS)
931
#if defined(CONFIG_DEBUG_FS)
909
	.debugfs_init = i915_debugfs_init,
932
	.debugfs_init = i915_debugfs_init,
910
	.debugfs_cleanup = i915_debugfs_cleanup,
933
	.debugfs_cleanup = i915_debugfs_cleanup,
911
#endif
934
#endif
912
    .gem_init_object = i915_gem_init_object,
-
 
913
    .gem_free_object = i915_gem_free_object,
935
    .gem_free_object = i915_gem_free_object,
914
 
936
 
915
//    .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
937
//    .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
916
//    .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
938
//    .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
917
//    .gem_prime_export = i915_gem_prime_export,
939
//    .gem_prime_export = i915_gem_prime_export,
918
//    .gem_prime_import = i915_gem_prime_import,
940
//    .gem_prime_import = i915_gem_prime_import,
919
 
941
 
920
//    .dumb_create = i915_gem_dumb_create,
942
//    .dumb_create = i915_gem_dumb_create,
921
//    .dumb_map_offset = i915_gem_mmap_gtt,
943
//    .dumb_map_offset = i915_gem_mmap_gtt,
922
//    .dumb_destroy = i915_gem_dumb_destroy,
944
//    .dumb_destroy = i915_gem_dumb_destroy,
923
//    .ioctls = i915_ioctls,
945
//    .ioctls = i915_ioctls,
924
//    .fops = &i915_driver_fops,
946
//    .fops = &i915_driver_fops,
925
//    .name = DRIVER_NAME,
947
//    .name = DRIVER_NAME,
926
//    .desc = DRIVER_DESC,
948
//    .desc = DRIVER_DESC,
927
//    .date = DRIVER_DATE,
949
//    .date = DRIVER_DATE,
928
//    .major = DRIVER_MAJOR,
950
//    .major = DRIVER_MAJOR,
929
//    .minor = DRIVER_MINOR,
951
//    .minor = DRIVER_MINOR,
930
//    .patchlevel = DRIVER_PATCHLEVEL,
952
//    .patchlevel = DRIVER_PATCHLEVEL,
931
};
953
};
932
 
954
 
933
 
955
 
934
 
956
 
935
 
957
 
936
int i915_init(void)
958
int i915_init(void)
937
{
959
{
938
    static pci_dev_t device;
960
    static pci_dev_t device;
939
    const struct pci_device_id  *ent;
961
    const struct pci_device_id  *ent;
940
    int  err;
962
    int  err;
941
 
963
 
942
    ent = find_pci_device(&device, pciidlist);
964
    ent = find_pci_device(&device, pciidlist);
943
    if( unlikely(ent == NULL) )
965
    if( unlikely(ent == NULL) )
944
    {
966
    {
945
        dbgprintf("device not found\n");
967
        dbgprintf("device not found\n");
946
        return -ENODEV;
968
        return -ENODEV;
947
    };
969
    };
948
 
970
 
949
    drm_core_init();
971
    drm_core_init();
950
 
972
 
951
    DRM_INFO("device %x:%x\n", device.pci_dev.vendor,
973
    DRM_INFO("device %x:%x\n", device.pci_dev.vendor,
952
                                device.pci_dev.device);
974
                                device.pci_dev.device);
953
 
975
 
954
    driver.driver_features |= DRIVER_MODESET;
976
    driver.driver_features |= DRIVER_MODESET;
955
 
977
 
956
    err = drm_get_pci_dev(&device.pci_dev, ent, &driver);
978
    err = drm_get_pci_dev(&device.pci_dev, ent, &driver);
957
 
979
 
958
    return err;
980
    return err;
959
}
981
}