i915_pci.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. /*
  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. #include <linux/console.h>
  25. #include <linux/vgaarb.h>
  26. #include <linux/vga_switcheroo.h>
  27. #include "i915_drv.h"
  28. #include "i915_selftest.h"
  29. #define GEN_DEFAULT_PIPEOFFSETS \
  30. .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
  31. PIPE_C_OFFSET, PIPE_EDP_OFFSET }, \
  32. .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
  33. TRANSCODER_C_OFFSET, TRANSCODER_EDP_OFFSET }, \
  34. .palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET }
  35. #define GEN_CHV_PIPEOFFSETS \
  36. .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
  37. CHV_PIPE_C_OFFSET }, \
  38. .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
  39. CHV_TRANSCODER_C_OFFSET, }, \
  40. .palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET, \
  41. CHV_PALETTE_C_OFFSET }
  42. #define CURSOR_OFFSETS \
  43. .cursor_offsets = { CURSOR_A_OFFSET, CURSOR_B_OFFSET, CHV_CURSOR_C_OFFSET }
  44. #define IVB_CURSOR_OFFSETS \
  45. .cursor_offsets = { CURSOR_A_OFFSET, IVB_CURSOR_B_OFFSET, IVB_CURSOR_C_OFFSET }
  46. #define BDW_COLORS \
  47. .color = { .degamma_lut_size = 512, .gamma_lut_size = 512 }
  48. #define CHV_COLORS \
  49. .color = { .degamma_lut_size = 65, .gamma_lut_size = 257 }
  50. /* Keep in gen based order, and chronological order within a gen */
  51. #define GEN2_FEATURES \
  52. .gen = 2, .num_pipes = 1, \
  53. .has_overlay = 1, .overlay_needs_physical = 1, \
  54. .has_gmch_display = 1, \
  55. .hws_needs_physical = 1, \
  56. .unfenced_needs_alignment = 1, \
  57. .ring_mask = RENDER_RING, \
  58. GEN_DEFAULT_PIPEOFFSETS, \
  59. CURSOR_OFFSETS
  60. static const struct intel_device_info intel_i830_info = {
  61. GEN2_FEATURES,
  62. .platform = INTEL_I830,
  63. .is_mobile = 1, .cursor_needs_physical = 1,
  64. .num_pipes = 2, /* legal, last one wins */
  65. };
  66. static const struct intel_device_info intel_i845g_info = {
  67. GEN2_FEATURES,
  68. .platform = INTEL_I845G,
  69. };
  70. static const struct intel_device_info intel_i85x_info = {
  71. GEN2_FEATURES,
  72. .platform = INTEL_I85X, .is_mobile = 1,
  73. .num_pipes = 2, /* legal, last one wins */
  74. .cursor_needs_physical = 1,
  75. .has_fbc = 1,
  76. };
  77. static const struct intel_device_info intel_i865g_info = {
  78. GEN2_FEATURES,
  79. .platform = INTEL_I865G,
  80. };
  81. #define GEN3_FEATURES \
  82. .gen = 3, .num_pipes = 2, \
  83. .has_gmch_display = 1, \
  84. .ring_mask = RENDER_RING, \
  85. GEN_DEFAULT_PIPEOFFSETS, \
  86. CURSOR_OFFSETS
  87. static const struct intel_device_info intel_i915g_info = {
  88. GEN3_FEATURES,
  89. .platform = INTEL_I915G, .cursor_needs_physical = 1,
  90. .has_overlay = 1, .overlay_needs_physical = 1,
  91. .hws_needs_physical = 1,
  92. .unfenced_needs_alignment = 1,
  93. };
  94. static const struct intel_device_info intel_i915gm_info = {
  95. GEN3_FEATURES,
  96. .platform = INTEL_I915GM,
  97. .is_mobile = 1,
  98. .cursor_needs_physical = 1,
  99. .has_overlay = 1, .overlay_needs_physical = 1,
  100. .supports_tv = 1,
  101. .has_fbc = 1,
  102. .hws_needs_physical = 1,
  103. .unfenced_needs_alignment = 1,
  104. };
  105. static const struct intel_device_info intel_i945g_info = {
  106. GEN3_FEATURES,
  107. .platform = INTEL_I945G,
  108. .has_hotplug = 1, .cursor_needs_physical = 1,
  109. .has_overlay = 1, .overlay_needs_physical = 1,
  110. .hws_needs_physical = 1,
  111. .unfenced_needs_alignment = 1,
  112. };
  113. static const struct intel_device_info intel_i945gm_info = {
  114. GEN3_FEATURES,
  115. .platform = INTEL_I945GM, .is_mobile = 1,
  116. .has_hotplug = 1, .cursor_needs_physical = 1,
  117. .has_overlay = 1, .overlay_needs_physical = 1,
  118. .supports_tv = 1,
  119. .has_fbc = 1,
  120. .hws_needs_physical = 1,
  121. .unfenced_needs_alignment = 1,
  122. };
  123. static const struct intel_device_info intel_g33_info = {
  124. GEN3_FEATURES,
  125. .platform = INTEL_G33,
  126. .has_hotplug = 1,
  127. .has_overlay = 1,
  128. };
  129. static const struct intel_device_info intel_pineview_info = {
  130. GEN3_FEATURES,
  131. .platform = INTEL_PINEVIEW, .is_mobile = 1,
  132. .has_hotplug = 1,
  133. .has_overlay = 1,
  134. };
  135. #define GEN4_FEATURES \
  136. .gen = 4, .num_pipes = 2, \
  137. .has_hotplug = 1, \
  138. .has_gmch_display = 1, \
  139. .ring_mask = RENDER_RING, \
  140. GEN_DEFAULT_PIPEOFFSETS, \
  141. CURSOR_OFFSETS
  142. static const struct intel_device_info intel_i965g_info = {
  143. GEN4_FEATURES,
  144. .platform = INTEL_I965G,
  145. .has_overlay = 1,
  146. .hws_needs_physical = 1,
  147. };
  148. static const struct intel_device_info intel_i965gm_info = {
  149. GEN4_FEATURES,
  150. .platform = INTEL_I965GM,
  151. .is_mobile = 1, .has_fbc = 1,
  152. .has_overlay = 1,
  153. .supports_tv = 1,
  154. .hws_needs_physical = 1,
  155. };
  156. static const struct intel_device_info intel_g45_info = {
  157. GEN4_FEATURES,
  158. .platform = INTEL_G45,
  159. .has_pipe_cxsr = 1,
  160. .ring_mask = RENDER_RING | BSD_RING,
  161. };
  162. static const struct intel_device_info intel_gm45_info = {
  163. GEN4_FEATURES,
  164. .platform = INTEL_GM45,
  165. .is_mobile = 1, .has_fbc = 1,
  166. .has_pipe_cxsr = 1,
  167. .supports_tv = 1,
  168. .ring_mask = RENDER_RING | BSD_RING,
  169. };
  170. #define GEN5_FEATURES \
  171. .gen = 5, .num_pipes = 2, \
  172. .has_hotplug = 1, \
  173. .has_gmbus_irq = 1, \
  174. .ring_mask = RENDER_RING | BSD_RING, \
  175. GEN_DEFAULT_PIPEOFFSETS, \
  176. CURSOR_OFFSETS
  177. static const struct intel_device_info intel_ironlake_d_info = {
  178. GEN5_FEATURES,
  179. .platform = INTEL_IRONLAKE,
  180. };
  181. static const struct intel_device_info intel_ironlake_m_info = {
  182. GEN5_FEATURES,
  183. .platform = INTEL_IRONLAKE,
  184. .is_mobile = 1, .has_fbc = 1,
  185. };
  186. #define GEN6_FEATURES \
  187. .gen = 6, .num_pipes = 2, \
  188. .has_hotplug = 1, \
  189. .has_fbc = 1, \
  190. .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
  191. .has_llc = 1, \
  192. .has_rc6 = 1, \
  193. .has_rc6p = 1, \
  194. .has_gmbus_irq = 1, \
  195. .has_aliasing_ppgtt = 1, \
  196. GEN_DEFAULT_PIPEOFFSETS, \
  197. CURSOR_OFFSETS
  198. static const struct intel_device_info intel_sandybridge_d_info = {
  199. GEN6_FEATURES,
  200. .platform = INTEL_SANDYBRIDGE,
  201. };
  202. static const struct intel_device_info intel_sandybridge_m_info = {
  203. GEN6_FEATURES,
  204. .platform = INTEL_SANDYBRIDGE,
  205. .is_mobile = 1,
  206. };
  207. #define GEN7_FEATURES \
  208. .gen = 7, .num_pipes = 3, \
  209. .has_hotplug = 1, \
  210. .has_fbc = 1, \
  211. .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
  212. .has_llc = 1, \
  213. .has_rc6 = 1, \
  214. .has_rc6p = 1, \
  215. .has_gmbus_irq = 1, \
  216. .has_aliasing_ppgtt = 1, \
  217. .has_full_ppgtt = 1, \
  218. GEN_DEFAULT_PIPEOFFSETS, \
  219. IVB_CURSOR_OFFSETS
  220. static const struct intel_device_info intel_ivybridge_d_info = {
  221. GEN7_FEATURES,
  222. .platform = INTEL_IVYBRIDGE,
  223. .has_l3_dpf = 1,
  224. };
  225. static const struct intel_device_info intel_ivybridge_m_info = {
  226. GEN7_FEATURES,
  227. .platform = INTEL_IVYBRIDGE,
  228. .is_mobile = 1,
  229. .has_l3_dpf = 1,
  230. };
  231. static const struct intel_device_info intel_ivybridge_q_info = {
  232. GEN7_FEATURES,
  233. .platform = INTEL_IVYBRIDGE,
  234. .num_pipes = 0, /* legal, last one wins */
  235. .has_l3_dpf = 1,
  236. };
  237. static const struct intel_device_info intel_valleyview_info = {
  238. .platform = INTEL_VALLEYVIEW,
  239. .gen = 7,
  240. .is_lp = 1,
  241. .num_pipes = 2,
  242. .has_psr = 1,
  243. .has_runtime_pm = 1,
  244. .has_rc6 = 1,
  245. .has_gmbus_irq = 1,
  246. .has_gmch_display = 1,
  247. .has_hotplug = 1,
  248. .has_aliasing_ppgtt = 1,
  249. .has_full_ppgtt = 1,
  250. .ring_mask = RENDER_RING | BSD_RING | BLT_RING,
  251. .display_mmio_offset = VLV_DISPLAY_BASE,
  252. GEN_DEFAULT_PIPEOFFSETS,
  253. CURSOR_OFFSETS
  254. };
  255. #define HSW_FEATURES \
  256. GEN7_FEATURES, \
  257. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
  258. .has_ddi = 1, \
  259. .has_fpga_dbg = 1, \
  260. .has_psr = 1, \
  261. .has_resource_streamer = 1, \
  262. .has_dp_mst = 1, \
  263. .has_rc6p = 0 /* RC6p removed-by HSW */, \
  264. .has_runtime_pm = 1
  265. static const struct intel_device_info intel_haswell_info = {
  266. HSW_FEATURES,
  267. .platform = INTEL_HASWELL,
  268. .has_l3_dpf = 1,
  269. };
  270. #define BDW_FEATURES \
  271. HSW_FEATURES, \
  272. BDW_COLORS, \
  273. .has_logical_ring_contexts = 1, \
  274. .has_full_48bit_ppgtt = 1, \
  275. .has_64bit_reloc = 1, \
  276. .has_reset_engine = 1
  277. #define BDW_PLATFORM \
  278. BDW_FEATURES, \
  279. .gen = 8, \
  280. .platform = INTEL_BROADWELL
  281. static const struct intel_device_info intel_broadwell_info = {
  282. BDW_PLATFORM,
  283. };
  284. static const struct intel_device_info intel_broadwell_gt3_info = {
  285. BDW_PLATFORM,
  286. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
  287. };
  288. static const struct intel_device_info intel_cherryview_info = {
  289. .gen = 8, .num_pipes = 3,
  290. .has_hotplug = 1,
  291. .is_lp = 1,
  292. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
  293. .platform = INTEL_CHERRYVIEW,
  294. .has_64bit_reloc = 1,
  295. .has_psr = 1,
  296. .has_runtime_pm = 1,
  297. .has_resource_streamer = 1,
  298. .has_rc6 = 1,
  299. .has_gmbus_irq = 1,
  300. .has_logical_ring_contexts = 1,
  301. .has_gmch_display = 1,
  302. .has_aliasing_ppgtt = 1,
  303. .has_full_ppgtt = 1,
  304. .has_reset_engine = 1,
  305. .display_mmio_offset = VLV_DISPLAY_BASE,
  306. GEN_CHV_PIPEOFFSETS,
  307. CURSOR_OFFSETS,
  308. CHV_COLORS,
  309. };
  310. #define SKL_PLATFORM \
  311. BDW_FEATURES, \
  312. .gen = 9, \
  313. .platform = INTEL_SKYLAKE, \
  314. .has_csr = 1, \
  315. .has_guc = 1, \
  316. .ddb_size = 896
  317. static const struct intel_device_info intel_skylake_info = {
  318. SKL_PLATFORM,
  319. };
  320. static const struct intel_device_info intel_skylake_gt3_info = {
  321. SKL_PLATFORM,
  322. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
  323. };
  324. #define GEN9_LP_FEATURES \
  325. .gen = 9, \
  326. .is_lp = 1, \
  327. .has_hotplug = 1, \
  328. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
  329. .num_pipes = 3, \
  330. .has_64bit_reloc = 1, \
  331. .has_ddi = 1, \
  332. .has_fpga_dbg = 1, \
  333. .has_fbc = 1, \
  334. .has_runtime_pm = 1, \
  335. .has_pooled_eu = 0, \
  336. .has_csr = 1, \
  337. .has_resource_streamer = 1, \
  338. .has_rc6 = 1, \
  339. .has_dp_mst = 1, \
  340. .has_gmbus_irq = 1, \
  341. .has_logical_ring_contexts = 1, \
  342. .has_guc = 1, \
  343. .has_aliasing_ppgtt = 1, \
  344. .has_full_ppgtt = 1, \
  345. .has_full_48bit_ppgtt = 1, \
  346. .has_reset_engine = 1, \
  347. GEN_DEFAULT_PIPEOFFSETS, \
  348. IVB_CURSOR_OFFSETS, \
  349. BDW_COLORS
  350. static const struct intel_device_info intel_broxton_info = {
  351. GEN9_LP_FEATURES,
  352. .platform = INTEL_BROXTON,
  353. .ddb_size = 512,
  354. .has_reset_engine = false,
  355. };
  356. static const struct intel_device_info intel_geminilake_info = {
  357. GEN9_LP_FEATURES,
  358. .platform = INTEL_GEMINILAKE,
  359. .ddb_size = 1024,
  360. .color = { .degamma_lut_size = 0, .gamma_lut_size = 1024 }
  361. };
  362. #define KBL_PLATFORM \
  363. BDW_FEATURES, \
  364. .gen = 9, \
  365. .platform = INTEL_KABYLAKE, \
  366. .has_csr = 1, \
  367. .has_guc = 1, \
  368. .ddb_size = 896
  369. static const struct intel_device_info intel_kabylake_info = {
  370. KBL_PLATFORM,
  371. };
  372. static const struct intel_device_info intel_kabylake_gt3_info = {
  373. KBL_PLATFORM,
  374. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
  375. };
  376. #define CFL_PLATFORM \
  377. .is_alpha_support = 1, \
  378. BDW_FEATURES, \
  379. .gen = 9, \
  380. .platform = INTEL_COFFEELAKE, \
  381. .has_csr = 1, \
  382. .has_guc = 1, \
  383. .ddb_size = 896
  384. static const struct intel_device_info intel_coffeelake_info = {
  385. CFL_PLATFORM,
  386. };
  387. static const struct intel_device_info intel_coffeelake_gt3_info = {
  388. CFL_PLATFORM,
  389. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
  390. };
  391. static const struct intel_device_info intel_cannonlake_info = {
  392. BDW_FEATURES,
  393. .is_alpha_support = 1,
  394. .platform = INTEL_CANNONLAKE,
  395. .gen = 10,
  396. .ddb_size = 1024,
  397. .has_csr = 1,
  398. .color = { .degamma_lut_size = 0, .gamma_lut_size = 1024 }
  399. };
  400. /*
  401. * Make sure any device matches here are from most specific to most
  402. * general. For example, since the Quanta match is based on the subsystem
  403. * and subvendor IDs, we need it to come before the more general IVB
  404. * PCI ID matches, otherwise we'll use the wrong info struct above.
  405. */
  406. static const struct pci_device_id pciidlist[] = {
  407. INTEL_I830_IDS(&intel_i830_info),
  408. INTEL_I845G_IDS(&intel_i845g_info),
  409. INTEL_I85X_IDS(&intel_i85x_info),
  410. INTEL_I865G_IDS(&intel_i865g_info),
  411. INTEL_I915G_IDS(&intel_i915g_info),
  412. INTEL_I915GM_IDS(&intel_i915gm_info),
  413. INTEL_I945G_IDS(&intel_i945g_info),
  414. INTEL_I945GM_IDS(&intel_i945gm_info),
  415. INTEL_I965G_IDS(&intel_i965g_info),
  416. INTEL_G33_IDS(&intel_g33_info),
  417. INTEL_I965GM_IDS(&intel_i965gm_info),
  418. INTEL_GM45_IDS(&intel_gm45_info),
  419. INTEL_G45_IDS(&intel_g45_info),
  420. INTEL_PINEVIEW_IDS(&intel_pineview_info),
  421. INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info),
  422. INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info),
  423. INTEL_SNB_D_IDS(&intel_sandybridge_d_info),
  424. INTEL_SNB_M_IDS(&intel_sandybridge_m_info),
  425. INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */
  426. INTEL_IVB_M_IDS(&intel_ivybridge_m_info),
  427. INTEL_IVB_D_IDS(&intel_ivybridge_d_info),
  428. INTEL_HSW_IDS(&intel_haswell_info),
  429. INTEL_VLV_IDS(&intel_valleyview_info),
  430. INTEL_BDW_GT12_IDS(&intel_broadwell_info),
  431. INTEL_BDW_GT3_IDS(&intel_broadwell_gt3_info),
  432. INTEL_BDW_RSVD_IDS(&intel_broadwell_info),
  433. INTEL_CHV_IDS(&intel_cherryview_info),
  434. INTEL_SKL_GT1_IDS(&intel_skylake_info),
  435. INTEL_SKL_GT2_IDS(&intel_skylake_info),
  436. INTEL_SKL_GT3_IDS(&intel_skylake_gt3_info),
  437. INTEL_SKL_GT4_IDS(&intel_skylake_gt3_info),
  438. INTEL_BXT_IDS(&intel_broxton_info),
  439. INTEL_GLK_IDS(&intel_geminilake_info),
  440. INTEL_KBL_GT1_IDS(&intel_kabylake_info),
  441. INTEL_KBL_GT2_IDS(&intel_kabylake_info),
  442. INTEL_KBL_GT3_IDS(&intel_kabylake_gt3_info),
  443. INTEL_KBL_GT4_IDS(&intel_kabylake_gt3_info),
  444. INTEL_CFL_S_IDS(&intel_coffeelake_info),
  445. INTEL_CFL_H_IDS(&intel_coffeelake_info),
  446. INTEL_CFL_U_IDS(&intel_coffeelake_gt3_info),
  447. INTEL_CNL_IDS(&intel_cannonlake_info),
  448. {0, 0, 0}
  449. };
  450. MODULE_DEVICE_TABLE(pci, pciidlist);
  451. static void i915_pci_remove(struct pci_dev *pdev)
  452. {
  453. struct drm_device *dev = pci_get_drvdata(pdev);
  454. i915_driver_unload(dev);
  455. drm_dev_unref(dev);
  456. }
  457. static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  458. {
  459. struct intel_device_info *intel_info =
  460. (struct intel_device_info *) ent->driver_data;
  461. int err;
  462. if (IS_ALPHA_SUPPORT(intel_info) && !i915.alpha_support) {
  463. DRM_INFO("The driver support for your hardware in this kernel version is alpha quality\n"
  464. "See CONFIG_DRM_I915_ALPHA_SUPPORT or i915.alpha_support module parameter\n"
  465. "to enable support in this kernel version, or check for kernel updates.\n");
  466. return -ENODEV;
  467. }
  468. /* Only bind to function 0 of the device. Early generations
  469. * used function 1 as a placeholder for multi-head. This causes
  470. * us confusion instead, especially on the systems where both
  471. * functions have the same PCI-ID!
  472. */
  473. if (PCI_FUNC(pdev->devfn))
  474. return -ENODEV;
  475. /*
  476. * apple-gmux is needed on dual GPU MacBook Pro
  477. * to probe the panel if we're the inactive GPU.
  478. */
  479. if (vga_switcheroo_client_probe_defer(pdev))
  480. return -EPROBE_DEFER;
  481. err = i915_driver_load(pdev, ent);
  482. if (err)
  483. return err;
  484. err = i915_live_selftests(pdev);
  485. if (err) {
  486. i915_pci_remove(pdev);
  487. return err > 0 ? -ENOTTY : err;
  488. }
  489. return 0;
  490. }
  491. static struct pci_driver i915_pci_driver = {
  492. .name = DRIVER_NAME,
  493. .id_table = pciidlist,
  494. .probe = i915_pci_probe,
  495. .remove = i915_pci_remove,
  496. .driver.pm = &i915_pm_ops,
  497. };
  498. static int __init i915_init(void)
  499. {
  500. bool use_kms = true;
  501. int err;
  502. err = i915_mock_selftests();
  503. if (err)
  504. return err > 0 ? 0 : err;
  505. /*
  506. * Enable KMS by default, unless explicitly overriden by
  507. * either the i915.modeset prarameter or by the
  508. * vga_text_mode_force boot option.
  509. */
  510. if (i915.modeset == 0)
  511. use_kms = false;
  512. if (vgacon_text_force() && i915.modeset == -1)
  513. use_kms = false;
  514. if (!use_kms) {
  515. /* Silently fail loading to not upset userspace. */
  516. DRM_DEBUG_DRIVER("KMS disabled.\n");
  517. return 0;
  518. }
  519. return pci_register_driver(&i915_pci_driver);
  520. }
  521. static void __exit i915_exit(void)
  522. {
  523. if (!i915_pci_driver.driver.owner)
  524. return;
  525. pci_unregister_driver(&i915_pci_driver);
  526. }
  527. module_init(i915_init);
  528. module_exit(i915_exit);
  529. MODULE_AUTHOR("Tungsten Graphics, Inc.");
  530. MODULE_AUTHOR("Intel Corporation");
  531. MODULE_DESCRIPTION(DRIVER_DESC);
  532. MODULE_LICENSE("GPL and additional rights");