blob: 66e126683fddeedc662489ea5134702844f19e11 [file] [log] [blame]
Chris Wilson42f55512016-06-24 14:00:26 +01001/*
2 * Copyright © 2016 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 */
24
Chris Wilsona09d0ba2016-06-24 14:00:27 +010025#include <linux/console.h>
Chris Wilson42f55512016-06-24 14:00:26 +010026#include <linux/vgaarb.h>
27#include <linux/vga_switcheroo.h>
28
29#include "i915_drv.h"
30
31#define GEN_DEFAULT_PIPEOFFSETS \
32 .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
33 PIPE_C_OFFSET, PIPE_EDP_OFFSET }, \
34 .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
35 TRANSCODER_C_OFFSET, TRANSCODER_EDP_OFFSET }, \
36 .palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET }
37
38#define GEN_CHV_PIPEOFFSETS \
39 .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
40 CHV_PIPE_C_OFFSET }, \
41 .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
42 CHV_TRANSCODER_C_OFFSET, }, \
43 .palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET, \
44 CHV_PALETTE_C_OFFSET }
45
46#define CURSOR_OFFSETS \
47 .cursor_offsets = { CURSOR_A_OFFSET, CURSOR_B_OFFSET, CHV_CURSOR_C_OFFSET }
48
49#define IVB_CURSOR_OFFSETS \
50 .cursor_offsets = { CURSOR_A_OFFSET, IVB_CURSOR_B_OFFSET, IVB_CURSOR_C_OFFSET }
51
52#define BDW_COLORS \
53 .color = { .degamma_lut_size = 512, .gamma_lut_size = 512 }
54#define CHV_COLORS \
55 .color = { .degamma_lut_size = 65, .gamma_lut_size = 257 }
56
57static const struct intel_device_info intel_i830_info = {
58 .gen = 2, .is_mobile = 1, .cursor_needs_physical = 1, .num_pipes = 2,
59 .has_overlay = 1, .overlay_needs_physical = 1,
60 .ring_mask = RENDER_RING,
61 GEN_DEFAULT_PIPEOFFSETS,
62 CURSOR_OFFSETS,
63};
64
65static const struct intel_device_info intel_845g_info = {
66 .gen = 2, .num_pipes = 1,
67 .has_overlay = 1, .overlay_needs_physical = 1,
68 .ring_mask = RENDER_RING,
69 GEN_DEFAULT_PIPEOFFSETS,
70 CURSOR_OFFSETS,
71};
72
73static const struct intel_device_info intel_i85x_info = {
74 .gen = 2, .is_i85x = 1, .is_mobile = 1, .num_pipes = 2,
75 .cursor_needs_physical = 1,
76 .has_overlay = 1, .overlay_needs_physical = 1,
77 .has_fbc = 1,
78 .ring_mask = RENDER_RING,
79 GEN_DEFAULT_PIPEOFFSETS,
80 CURSOR_OFFSETS,
81};
82
83static const struct intel_device_info intel_i865g_info = {
84 .gen = 2, .num_pipes = 1,
85 .has_overlay = 1, .overlay_needs_physical = 1,
86 .ring_mask = RENDER_RING,
87 GEN_DEFAULT_PIPEOFFSETS,
88 CURSOR_OFFSETS,
89};
90
91static const struct intel_device_info intel_i915g_info = {
92 .gen = 3, .is_i915g = 1, .cursor_needs_physical = 1, .num_pipes = 2,
93 .has_overlay = 1, .overlay_needs_physical = 1,
94 .ring_mask = RENDER_RING,
95 GEN_DEFAULT_PIPEOFFSETS,
96 CURSOR_OFFSETS,
97};
98static const struct intel_device_info intel_i915gm_info = {
99 .gen = 3, .is_mobile = 1, .num_pipes = 2,
100 .cursor_needs_physical = 1,
101 .has_overlay = 1, .overlay_needs_physical = 1,
102 .supports_tv = 1,
103 .has_fbc = 1,
104 .ring_mask = RENDER_RING,
105 GEN_DEFAULT_PIPEOFFSETS,
106 CURSOR_OFFSETS,
107};
108static const struct intel_device_info intel_i945g_info = {
109 .gen = 3, .has_hotplug = 1, .cursor_needs_physical = 1, .num_pipes = 2,
110 .has_overlay = 1, .overlay_needs_physical = 1,
111 .ring_mask = RENDER_RING,
112 GEN_DEFAULT_PIPEOFFSETS,
113 CURSOR_OFFSETS,
114};
115static const struct intel_device_info intel_i945gm_info = {
116 .gen = 3, .is_i945gm = 1, .is_mobile = 1, .num_pipes = 2,
117 .has_hotplug = 1, .cursor_needs_physical = 1,
118 .has_overlay = 1, .overlay_needs_physical = 1,
119 .supports_tv = 1,
120 .has_fbc = 1,
121 .ring_mask = RENDER_RING,
122 GEN_DEFAULT_PIPEOFFSETS,
123 CURSOR_OFFSETS,
124};
125
Carlos Santa4d495be2016-08-17 12:30:49 -0700126#define GEN4_FEATURES \
127 .gen = 4, .num_pipes = 2, \
128 .has_hotplug = 1, \
129 .ring_mask = RENDER_RING, \
130 GEN_DEFAULT_PIPEOFFSETS, \
131 CURSOR_OFFSETS
132
Chris Wilson42f55512016-06-24 14:00:26 +0100133static const struct intel_device_info intel_i965g_info = {
Carlos Santa4d495be2016-08-17 12:30:49 -0700134 GEN4_FEATURES,
135 .is_broadwater = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100136 .has_overlay = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100137};
138
139static const struct intel_device_info intel_i965gm_info = {
Carlos Santa4d495be2016-08-17 12:30:49 -0700140 GEN4_FEATURES,
141 .is_crestline = 1,
142 .is_mobile = 1, .has_fbc = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100143 .has_overlay = 1,
144 .supports_tv = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100145};
146
147static const struct intel_device_info intel_g33_info = {
148 .gen = 3, .is_g33 = 1, .num_pipes = 2,
149 .need_gfx_hws = 1, .has_hotplug = 1,
150 .has_overlay = 1,
151 .ring_mask = RENDER_RING,
152 GEN_DEFAULT_PIPEOFFSETS,
153 CURSOR_OFFSETS,
154};
155
156static const struct intel_device_info intel_g45_info = {
Carlos Santa4d495be2016-08-17 12:30:49 -0700157 GEN4_FEATURES,
158 .is_g4x = 1, .need_gfx_hws = 1,
159 .has_pipe_cxsr = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100160 .ring_mask = RENDER_RING | BSD_RING,
Chris Wilson42f55512016-06-24 14:00:26 +0100161};
162
163static const struct intel_device_info intel_gm45_info = {
Carlos Santa4d495be2016-08-17 12:30:49 -0700164 GEN4_FEATURES,
165 .is_g4x = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100166 .is_mobile = 1, .need_gfx_hws = 1, .has_fbc = 1,
Carlos Santa4d495be2016-08-17 12:30:49 -0700167 .has_pipe_cxsr = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100168 .supports_tv = 1,
169 .ring_mask = RENDER_RING | BSD_RING,
Chris Wilson42f55512016-06-24 14:00:26 +0100170};
171
172static const struct intel_device_info intel_pineview_info = {
173 .gen = 3, .is_g33 = 1, .is_pineview = 1, .is_mobile = 1, .num_pipes = 2,
174 .need_gfx_hws = 1, .has_hotplug = 1,
175 .has_overlay = 1,
Chris Wilson6ce21352016-07-29 00:45:35 +0100176 .ring_mask = RENDER_RING,
Chris Wilson42f55512016-06-24 14:00:26 +0100177 GEN_DEFAULT_PIPEOFFSETS,
178 CURSOR_OFFSETS,
179};
180
Carlos Santaa1323382016-08-17 12:30:47 -0700181#define GEN5_FEATURES \
182 .gen = 5, .num_pipes = 2, \
183 .need_gfx_hws = 1, .has_hotplug = 1, \
Carlos Santab355f102016-08-17 12:30:48 -0700184 .has_gmbus_irq = 1, \
Carlos Santaa1323382016-08-17 12:30:47 -0700185 .ring_mask = RENDER_RING | BSD_RING, \
186 GEN_DEFAULT_PIPEOFFSETS, \
187 CURSOR_OFFSETS
188
Chris Wilson42f55512016-06-24 14:00:26 +0100189static const struct intel_device_info intel_ironlake_d_info = {
Carlos Santaa1323382016-08-17 12:30:47 -0700190 GEN5_FEATURES,
Chris Wilson42f55512016-06-24 14:00:26 +0100191};
192
193static const struct intel_device_info intel_ironlake_m_info = {
Carlos Santaa1323382016-08-17 12:30:47 -0700194 GEN5_FEATURES,
195 .is_mobile = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100196};
197
Carlos Santa07db6be2016-08-17 12:30:38 -0700198#define GEN6_FEATURES \
199 .gen = 6, .num_pipes = 2, \
200 .need_gfx_hws = 1, .has_hotplug = 1, \
201 .has_fbc = 1, \
202 .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
203 .has_llc = 1, \
Carlos Santa86f36242016-08-17 12:30:44 -0700204 .has_rc6 = 1, \
Carlos Santa33b5bf82016-08-17 12:30:45 -0700205 .has_rc6p = 1, \
Carlos Santab355f102016-08-17 12:30:48 -0700206 .has_gmbus_irq = 1, \
Carlos Santa07db6be2016-08-17 12:30:38 -0700207 GEN_DEFAULT_PIPEOFFSETS, \
208 CURSOR_OFFSETS
209
Chris Wilson42f55512016-06-24 14:00:26 +0100210static const struct intel_device_info intel_sandybridge_d_info = {
Carlos Santa07db6be2016-08-17 12:30:38 -0700211 GEN6_FEATURES,
Chris Wilson42f55512016-06-24 14:00:26 +0100212};
213
214static const struct intel_device_info intel_sandybridge_m_info = {
Carlos Santa07db6be2016-08-17 12:30:38 -0700215 GEN6_FEATURES,
216 .is_mobile = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100217};
218
219#define GEN7_FEATURES \
220 .gen = 7, .num_pipes = 3, \
221 .need_gfx_hws = 1, .has_hotplug = 1, \
222 .has_fbc = 1, \
223 .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
224 .has_llc = 1, \
Carlos Santa86f36242016-08-17 12:30:44 -0700225 .has_rc6 = 1, \
Carlos Santa33b5bf82016-08-17 12:30:45 -0700226 .has_rc6p = 1, \
Carlos Santab355f102016-08-17 12:30:48 -0700227 .has_gmbus_irq = 1, \
Chris Wilson42f55512016-06-24 14:00:26 +0100228 GEN_DEFAULT_PIPEOFFSETS, \
229 IVB_CURSOR_OFFSETS
230
231static const struct intel_device_info intel_ivybridge_d_info = {
232 GEN7_FEATURES,
233 .is_ivybridge = 1,
234};
235
236static const struct intel_device_info intel_ivybridge_m_info = {
237 GEN7_FEATURES,
238 .is_ivybridge = 1,
239 .is_mobile = 1,
240};
241
242static const struct intel_device_info intel_ivybridge_q_info = {
243 GEN7_FEATURES,
244 .is_ivybridge = 1,
245 .num_pipes = 0, /* legal, last one wins */
246};
247
248#define VLV_FEATURES \
249 .gen = 7, .num_pipes = 2, \
Carlos Santa6e3b84d2016-08-17 12:30:36 -0700250 .has_psr = 1, \
Carlos Santa4aa4c232016-08-17 12:30:39 -0700251 .has_runtime_pm = 1, \
Carlos Santa86f36242016-08-17 12:30:44 -0700252 .has_rc6 = 1, \
Carlos Santab355f102016-08-17 12:30:48 -0700253 .has_gmbus_irq = 1, \
Chris Wilson42f55512016-06-24 14:00:26 +0100254 .need_gfx_hws = 1, .has_hotplug = 1, \
255 .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
256 .display_mmio_offset = VLV_DISPLAY_BASE, \
257 GEN_DEFAULT_PIPEOFFSETS, \
258 CURSOR_OFFSETS
259
Carlos Santa8d9c20e2016-08-17 12:30:37 -0700260static const struct intel_device_info intel_valleyview_info = {
Chris Wilson42f55512016-06-24 14:00:26 +0100261 VLV_FEATURES,
262 .is_valleyview = 1,
263};
264
265#define HSW_FEATURES \
266 GEN7_FEATURES, \
267 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
268 .has_ddi = 1, \
Carlos Santa6e3b84d2016-08-17 12:30:36 -0700269 .has_fpga_dbg = 1, \
Carlos Santa4aa4c232016-08-17 12:30:39 -0700270 .has_psr = 1, \
Carlos Santa53233f02016-08-17 12:30:43 -0700271 .has_resource_streamer = 1, \
Carlos Santa1d3fe532016-08-17 12:30:46 -0700272 .has_dp_mst = 1, \
Carlos Santa33b5bf82016-08-17 12:30:45 -0700273 .has_rc6p = 0 /* RC6p removed-by HSW */, \
Carlos Santa4aa4c232016-08-17 12:30:39 -0700274 .has_runtime_pm = 1
Chris Wilson42f55512016-06-24 14:00:26 +0100275
Carlos Santa8d9c20e2016-08-17 12:30:37 -0700276static const struct intel_device_info intel_haswell_info = {
Chris Wilson42f55512016-06-24 14:00:26 +0100277 HSW_FEATURES,
278 .is_haswell = 1,
279};
280
Chris Wilson42f55512016-06-24 14:00:26 +0100281#define BDW_FEATURES \
282 HSW_FEATURES, \
283 BDW_COLORS
284
Carlos Santa8d9c20e2016-08-17 12:30:37 -0700285static const struct intel_device_info intel_broadwell_info = {
Chris Wilson42f55512016-06-24 14:00:26 +0100286 BDW_FEATURES,
287 .gen = 8,
288 .is_broadwell = 1,
289};
290
Carlos Santa8d9c20e2016-08-17 12:30:37 -0700291static const struct intel_device_info intel_broadwell_gt3_info = {
Chris Wilson42f55512016-06-24 14:00:26 +0100292 BDW_FEATURES,
293 .gen = 8,
294 .is_broadwell = 1,
295 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
296};
297
Chris Wilson42f55512016-06-24 14:00:26 +0100298static const struct intel_device_info intel_cherryview_info = {
299 .gen = 8, .num_pipes = 3,
300 .need_gfx_hws = 1, .has_hotplug = 1,
301 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
302 .is_cherryview = 1,
Carlos Santa6e3b84d2016-08-17 12:30:36 -0700303 .has_psr = 1,
Carlos Santa4aa4c232016-08-17 12:30:39 -0700304 .has_runtime_pm = 1,
Carlos Santa53233f02016-08-17 12:30:43 -0700305 .has_resource_streamer = 1,
Carlos Santa86f36242016-08-17 12:30:44 -0700306 .has_rc6 = 1,
Carlos Santab355f102016-08-17 12:30:48 -0700307 .has_gmbus_irq = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100308 .display_mmio_offset = VLV_DISPLAY_BASE,
309 GEN_CHV_PIPEOFFSETS,
310 CURSOR_OFFSETS,
311 CHV_COLORS,
312};
313
314static const struct intel_device_info intel_skylake_info = {
315 BDW_FEATURES,
316 .is_skylake = 1,
317 .gen = 9,
Carlos Santa3bacde12016-08-17 12:30:42 -0700318 .has_csr = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100319};
320
321static const struct intel_device_info intel_skylake_gt3_info = {
322 BDW_FEATURES,
323 .is_skylake = 1,
324 .gen = 9,
Carlos Santa3bacde12016-08-17 12:30:42 -0700325 .has_csr = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100326 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
327};
328
329static const struct intel_device_info intel_broxton_info = {
Chris Wilson42f55512016-06-24 14:00:26 +0100330 .is_broxton = 1,
331 .gen = 9,
332 .need_gfx_hws = 1, .has_hotplug = 1,
333 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
334 .num_pipes = 3,
335 .has_ddi = 1,
336 .has_fpga_dbg = 1,
337 .has_fbc = 1,
Carlos Santa4aa4c232016-08-17 12:30:39 -0700338 .has_runtime_pm = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100339 .has_pooled_eu = 0,
Carlos Santa3bacde12016-08-17 12:30:42 -0700340 .has_csr = 1,
Carlos Santa53233f02016-08-17 12:30:43 -0700341 .has_resource_streamer = 1,
Carlos Santa86f36242016-08-17 12:30:44 -0700342 .has_rc6 = 1,
Carlos Santa1d3fe532016-08-17 12:30:46 -0700343 .has_dp_mst = 1,
Carlos Santab355f102016-08-17 12:30:48 -0700344 .has_gmbus_irq = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100345 GEN_DEFAULT_PIPEOFFSETS,
346 IVB_CURSOR_OFFSETS,
347 BDW_COLORS,
348};
349
350static const struct intel_device_info intel_kabylake_info = {
351 BDW_FEATURES,
352 .is_kabylake = 1,
353 .gen = 9,
Carlos Santa3bacde12016-08-17 12:30:42 -0700354 .has_csr = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100355};
356
357static const struct intel_device_info intel_kabylake_gt3_info = {
358 BDW_FEATURES,
359 .is_kabylake = 1,
360 .gen = 9,
Carlos Santa3bacde12016-08-17 12:30:42 -0700361 .has_csr = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100362 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
363};
364
365/*
366 * Make sure any device matches here are from most specific to most
367 * general. For example, since the Quanta match is based on the subsystem
368 * and subvendor IDs, we need it to come before the more general IVB
369 * PCI ID matches, otherwise we'll use the wrong info struct above.
370 */
371static const struct pci_device_id pciidlist[] = {
372 INTEL_I830_IDS(&intel_i830_info),
373 INTEL_I845G_IDS(&intel_845g_info),
374 INTEL_I85X_IDS(&intel_i85x_info),
375 INTEL_I865G_IDS(&intel_i865g_info),
376 INTEL_I915G_IDS(&intel_i915g_info),
377 INTEL_I915GM_IDS(&intel_i915gm_info),
378 INTEL_I945G_IDS(&intel_i945g_info),
379 INTEL_I945GM_IDS(&intel_i945gm_info),
380 INTEL_I965G_IDS(&intel_i965g_info),
381 INTEL_G33_IDS(&intel_g33_info),
382 INTEL_I965GM_IDS(&intel_i965gm_info),
383 INTEL_GM45_IDS(&intel_gm45_info),
384 INTEL_G45_IDS(&intel_g45_info),
385 INTEL_PINEVIEW_IDS(&intel_pineview_info),
386 INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info),
387 INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info),
388 INTEL_SNB_D_IDS(&intel_sandybridge_d_info),
389 INTEL_SNB_M_IDS(&intel_sandybridge_m_info),
390 INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */
391 INTEL_IVB_M_IDS(&intel_ivybridge_m_info),
392 INTEL_IVB_D_IDS(&intel_ivybridge_d_info),
Carlos Santa8d9c20e2016-08-17 12:30:37 -0700393 INTEL_HSW_IDS(&intel_haswell_info),
394 INTEL_VLV_IDS(&intel_valleyview_info),
395 INTEL_BDW_GT12_IDS(&intel_broadwell_info),
396 INTEL_BDW_GT3_IDS(&intel_broadwell_gt3_info),
Chris Wilson42f55512016-06-24 14:00:26 +0100397 INTEL_CHV_IDS(&intel_cherryview_info),
398 INTEL_SKL_GT1_IDS(&intel_skylake_info),
399 INTEL_SKL_GT2_IDS(&intel_skylake_info),
400 INTEL_SKL_GT3_IDS(&intel_skylake_gt3_info),
401 INTEL_SKL_GT4_IDS(&intel_skylake_gt3_info),
402 INTEL_BXT_IDS(&intel_broxton_info),
403 INTEL_KBL_GT1_IDS(&intel_kabylake_info),
404 INTEL_KBL_GT2_IDS(&intel_kabylake_info),
405 INTEL_KBL_GT3_IDS(&intel_kabylake_gt3_info),
406 INTEL_KBL_GT4_IDS(&intel_kabylake_gt3_info),
407 {0, 0, 0}
408};
409MODULE_DEVICE_TABLE(pci, pciidlist);
410
411extern int i915_driver_load(struct pci_dev *pdev,
412 const struct pci_device_id *ent);
413
414static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
415{
416 struct intel_device_info *intel_info =
417 (struct intel_device_info *) ent->driver_data;
418
419 if (IS_PRELIMINARY_HW(intel_info) && !i915.preliminary_hw_support) {
420 DRM_INFO("This hardware requires preliminary hardware support.\n"
421 "See CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT, and/or modparam preliminary_hw_support\n");
422 return -ENODEV;
423 }
424
425 /* Only bind to function 0 of the device. Early generations
426 * used function 1 as a placeholder for multi-head. This causes
427 * us confusion instead, especially on the systems where both
428 * functions have the same PCI-ID!
429 */
430 if (PCI_FUNC(pdev->devfn))
431 return -ENODEV;
432
433 /*
434 * apple-gmux is needed on dual GPU MacBook Pro
435 * to probe the panel if we're the inactive GPU.
436 */
437 if (vga_switcheroo_client_probe_defer(pdev))
438 return -EPROBE_DEFER;
439
440 return i915_driver_load(pdev, ent);
441}
442
443extern void i915_driver_unload(struct drm_device *dev);
444
445static void i915_pci_remove(struct pci_dev *pdev)
446{
447 struct drm_device *dev = pci_get_drvdata(pdev);
448
449 i915_driver_unload(dev);
450 drm_dev_unref(dev);
451}
452
453extern const struct dev_pm_ops i915_pm_ops;
454
Chris Wilsona09d0ba2016-06-24 14:00:27 +0100455static struct pci_driver i915_pci_driver = {
Chris Wilson42f55512016-06-24 14:00:26 +0100456 .name = DRIVER_NAME,
457 .id_table = pciidlist,
458 .probe = i915_pci_probe,
459 .remove = i915_pci_remove,
460 .driver.pm = &i915_pm_ops,
461};
Chris Wilsona09d0ba2016-06-24 14:00:27 +0100462
463static int __init i915_init(void)
464{
465 bool use_kms = true;
466
467 /*
468 * Enable KMS by default, unless explicitly overriden by
469 * either the i915.modeset prarameter or by the
470 * vga_text_mode_force boot option.
471 */
472
473 if (i915.modeset == 0)
474 use_kms = false;
475
476 if (vgacon_text_force() && i915.modeset == -1)
477 use_kms = false;
478
479 if (!use_kms) {
480 /* Silently fail loading to not upset userspace. */
481 DRM_DEBUG_DRIVER("KMS disabled.\n");
482 return 0;
483 }
484
485 return pci_register_driver(&i915_pci_driver);
486}
487
488static void __exit i915_exit(void)
489{
490 if (!i915_pci_driver.driver.owner)
491 return;
492
493 pci_unregister_driver(&i915_pci_driver);
494}
495
496module_init(i915_init);
497module_exit(i915_exit);
498
499MODULE_AUTHOR("Tungsten Graphics, Inc.");
500MODULE_AUTHOR("Intel Corporation");
501
502MODULE_DESCRIPTION(DRIVER_DESC);
503MODULE_LICENSE("GPL and additional rights");