intel_bios.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. /*
  2. * Copyright © 2006 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 FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. *
  23. * Authors:
  24. * Eric Anholt <eric@anholt.net>
  25. *
  26. */
  27. #include "drmP.h"
  28. #include "drm.h"
  29. #include "i915_drm.h"
  30. #include "i915_drv.h"
  31. #include "intel_bios.h"
  32. #define SLAVE_ADDR1 0x70
  33. #define SLAVE_ADDR2 0x72
  34. static int panel_type;
  35. static void *
  36. find_section(struct bdb_header *bdb, int section_id)
  37. {
  38. u8 *base = (u8 *)bdb;
  39. int index = 0;
  40. u16 total, current_size;
  41. u8 current_id;
  42. /* skip to first section */
  43. index += bdb->header_size;
  44. total = bdb->bdb_size;
  45. /* walk the sections looking for section_id */
  46. while (index < total) {
  47. current_id = *(base + index);
  48. index++;
  49. current_size = *((u16 *)(base + index));
  50. index += 2;
  51. if (current_id == section_id)
  52. return base + index;
  53. index += current_size;
  54. }
  55. return NULL;
  56. }
  57. static u16
  58. get_blocksize(void *p)
  59. {
  60. u16 *block_ptr, block_size;
  61. block_ptr = (u16 *)((char *)p - 2);
  62. block_size = *block_ptr;
  63. return block_size;
  64. }
  65. static void
  66. fill_detail_timing_data(struct drm_display_mode *panel_fixed_mode,
  67. struct lvds_dvo_timing *dvo_timing)
  68. {
  69. panel_fixed_mode->hdisplay = (dvo_timing->hactive_hi << 8) |
  70. dvo_timing->hactive_lo;
  71. panel_fixed_mode->hsync_start = panel_fixed_mode->hdisplay +
  72. ((dvo_timing->hsync_off_hi << 8) | dvo_timing->hsync_off_lo);
  73. panel_fixed_mode->hsync_end = panel_fixed_mode->hsync_start +
  74. dvo_timing->hsync_pulse_width;
  75. panel_fixed_mode->htotal = panel_fixed_mode->hdisplay +
  76. ((dvo_timing->hblank_hi << 8) | dvo_timing->hblank_lo);
  77. panel_fixed_mode->vdisplay = (dvo_timing->vactive_hi << 8) |
  78. dvo_timing->vactive_lo;
  79. panel_fixed_mode->vsync_start = panel_fixed_mode->vdisplay +
  80. dvo_timing->vsync_off;
  81. panel_fixed_mode->vsync_end = panel_fixed_mode->vsync_start +
  82. dvo_timing->vsync_pulse_width;
  83. panel_fixed_mode->vtotal = panel_fixed_mode->vdisplay +
  84. ((dvo_timing->vblank_hi << 8) | dvo_timing->vblank_lo);
  85. panel_fixed_mode->clock = dvo_timing->clock * 10;
  86. panel_fixed_mode->type = DRM_MODE_TYPE_PREFERRED;
  87. if (dvo_timing->hsync_positive)
  88. panel_fixed_mode->flags |= DRM_MODE_FLAG_PHSYNC;
  89. else
  90. panel_fixed_mode->flags |= DRM_MODE_FLAG_NHSYNC;
  91. if (dvo_timing->vsync_positive)
  92. panel_fixed_mode->flags |= DRM_MODE_FLAG_PVSYNC;
  93. else
  94. panel_fixed_mode->flags |= DRM_MODE_FLAG_NVSYNC;
  95. /* Some VBTs have bogus h/vtotal values */
  96. if (panel_fixed_mode->hsync_end > panel_fixed_mode->htotal)
  97. panel_fixed_mode->htotal = panel_fixed_mode->hsync_end + 1;
  98. if (panel_fixed_mode->vsync_end > panel_fixed_mode->vtotal)
  99. panel_fixed_mode->vtotal = panel_fixed_mode->vsync_end + 1;
  100. drm_mode_set_name(panel_fixed_mode);
  101. }
  102. /* Try to find integrated panel data */
  103. static void
  104. parse_lfp_panel_data(struct drm_i915_private *dev_priv,
  105. struct bdb_header *bdb)
  106. {
  107. struct bdb_lvds_options *lvds_options;
  108. struct bdb_lvds_lfp_data *lvds_lfp_data;
  109. struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
  110. struct bdb_lvds_lfp_data_entry *entry;
  111. struct lvds_dvo_timing *dvo_timing;
  112. struct drm_display_mode *panel_fixed_mode;
  113. int lfp_data_size, dvo_timing_offset;
  114. int i, temp_downclock;
  115. struct drm_display_mode *temp_mode;
  116. lvds_options = find_section(bdb, BDB_LVDS_OPTIONS);
  117. if (!lvds_options)
  118. return;
  119. dev_priv->lvds_dither = lvds_options->pixel_dither;
  120. if (lvds_options->panel_type == 0xff)
  121. return;
  122. panel_type = lvds_options->panel_type;
  123. lvds_lfp_data = find_section(bdb, BDB_LVDS_LFP_DATA);
  124. if (!lvds_lfp_data)
  125. return;
  126. lvds_lfp_data_ptrs = find_section(bdb, BDB_LVDS_LFP_DATA_PTRS);
  127. if (!lvds_lfp_data_ptrs)
  128. return;
  129. dev_priv->lvds_vbt = 1;
  130. lfp_data_size = lvds_lfp_data_ptrs->ptr[1].dvo_timing_offset -
  131. lvds_lfp_data_ptrs->ptr[0].dvo_timing_offset;
  132. entry = (struct bdb_lvds_lfp_data_entry *)
  133. ((uint8_t *)lvds_lfp_data->data + (lfp_data_size *
  134. lvds_options->panel_type));
  135. dvo_timing_offset = lvds_lfp_data_ptrs->ptr[0].dvo_timing_offset -
  136. lvds_lfp_data_ptrs->ptr[0].fp_timing_offset;
  137. /*
  138. * the size of fp_timing varies on the different platform.
  139. * So calculate the DVO timing relative offset in LVDS data
  140. * entry to get the DVO timing entry
  141. */
  142. dvo_timing = (struct lvds_dvo_timing *)
  143. ((unsigned char *)entry + dvo_timing_offset);
  144. panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL);
  145. if (!panel_fixed_mode)
  146. return;
  147. fill_detail_timing_data(panel_fixed_mode, dvo_timing);
  148. dev_priv->lfp_lvds_vbt_mode = panel_fixed_mode;
  149. DRM_DEBUG_KMS("Found panel mode in BIOS VBT tables:\n");
  150. drm_mode_debug_printmodeline(panel_fixed_mode);
  151. temp_mode = kzalloc(sizeof(*temp_mode), GFP_KERNEL);
  152. temp_downclock = panel_fixed_mode->clock;
  153. /*
  154. * enumerate the LVDS panel timing info entry in VBT to check whether
  155. * the LVDS downclock is found.
  156. */
  157. for (i = 0; i < 16; i++) {
  158. entry = (struct bdb_lvds_lfp_data_entry *)
  159. ((uint8_t *)lvds_lfp_data->data + (lfp_data_size * i));
  160. dvo_timing = (struct lvds_dvo_timing *)
  161. ((unsigned char *)entry + dvo_timing_offset);
  162. fill_detail_timing_data(temp_mode, dvo_timing);
  163. if (temp_mode->hdisplay == panel_fixed_mode->hdisplay &&
  164. temp_mode->hsync_start == panel_fixed_mode->hsync_start &&
  165. temp_mode->hsync_end == panel_fixed_mode->hsync_end &&
  166. temp_mode->htotal == panel_fixed_mode->htotal &&
  167. temp_mode->vdisplay == panel_fixed_mode->vdisplay &&
  168. temp_mode->vsync_start == panel_fixed_mode->vsync_start &&
  169. temp_mode->vsync_end == panel_fixed_mode->vsync_end &&
  170. temp_mode->vtotal == panel_fixed_mode->vtotal &&
  171. temp_mode->clock < temp_downclock) {
  172. /*
  173. * downclock is already found. But we expect
  174. * to find the lower downclock.
  175. */
  176. temp_downclock = temp_mode->clock;
  177. }
  178. /* clear it to zero */
  179. memset(temp_mode, 0, sizeof(*temp_mode));
  180. }
  181. kfree(temp_mode);
  182. if (temp_downclock < panel_fixed_mode->clock &&
  183. i915_lvds_downclock) {
  184. dev_priv->lvds_downclock_avail = 1;
  185. dev_priv->lvds_downclock = temp_downclock;
  186. DRM_DEBUG_KMS("LVDS downclock is found in VBT. ",
  187. "Normal Clock %dKHz, downclock %dKHz\n",
  188. temp_downclock, panel_fixed_mode->clock);
  189. }
  190. return;
  191. }
  192. /* Try to find sdvo panel data */
  193. static void
  194. parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
  195. struct bdb_header *bdb)
  196. {
  197. struct bdb_sdvo_lvds_options *sdvo_lvds_options;
  198. struct lvds_dvo_timing *dvo_timing;
  199. struct drm_display_mode *panel_fixed_mode;
  200. sdvo_lvds_options = find_section(bdb, BDB_SDVO_LVDS_OPTIONS);
  201. if (!sdvo_lvds_options)
  202. return;
  203. dvo_timing = find_section(bdb, BDB_SDVO_PANEL_DTDS);
  204. if (!dvo_timing)
  205. return;
  206. panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL);
  207. if (!panel_fixed_mode)
  208. return;
  209. fill_detail_timing_data(panel_fixed_mode,
  210. dvo_timing + sdvo_lvds_options->panel_type);
  211. dev_priv->sdvo_lvds_vbt_mode = panel_fixed_mode;
  212. return;
  213. }
  214. static void
  215. parse_general_features(struct drm_i915_private *dev_priv,
  216. struct bdb_header *bdb)
  217. {
  218. struct drm_device *dev = dev_priv->dev;
  219. struct bdb_general_features *general;
  220. general = find_section(bdb, BDB_GENERAL_FEATURES);
  221. if (general) {
  222. dev_priv->int_tv_support = general->int_tv_support;
  223. dev_priv->int_crt_support = general->int_crt_support;
  224. dev_priv->lvds_use_ssc = general->enable_ssc;
  225. if (dev_priv->lvds_use_ssc) {
  226. if (IS_I85X(dev_priv->dev))
  227. dev_priv->lvds_ssc_freq =
  228. general->ssc_freq ? 66 : 48;
  229. else if (IS_IRONLAKE(dev_priv->dev) || IS_GEN6(dev))
  230. dev_priv->lvds_ssc_freq =
  231. general->ssc_freq ? 100 : 120;
  232. else
  233. dev_priv->lvds_ssc_freq =
  234. general->ssc_freq ? 100 : 96;
  235. }
  236. }
  237. }
  238. static void
  239. parse_general_definitions(struct drm_i915_private *dev_priv,
  240. struct bdb_header *bdb)
  241. {
  242. struct bdb_general_definitions *general;
  243. general = find_section(bdb, BDB_GENERAL_DEFINITIONS);
  244. if (general) {
  245. u16 block_size = get_blocksize(general);
  246. if (block_size >= sizeof(*general)) {
  247. int bus_pin = general->crt_ddc_gmbus_pin;
  248. DRM_DEBUG_KMS("crt_ddc_bus_pin: %d\n", bus_pin);
  249. if (bus_pin >= 1 && bus_pin <= 6)
  250. dev_priv->crt_ddc_pin = bus_pin;
  251. } else {
  252. DRM_DEBUG_KMS("BDB_GD too small (%d). Invalid.\n",
  253. block_size);
  254. }
  255. }
  256. }
  257. static void
  258. parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
  259. struct bdb_header *bdb)
  260. {
  261. struct sdvo_device_mapping *p_mapping;
  262. struct bdb_general_definitions *p_defs;
  263. struct child_device_config *p_child;
  264. int i, child_device_num, count;
  265. u16 block_size;
  266. p_defs = find_section(bdb, BDB_GENERAL_DEFINITIONS);
  267. if (!p_defs) {
  268. DRM_DEBUG_KMS("No general definition block is found, unable to construct sdvo mapping.\n");
  269. return;
  270. }
  271. /* judge whether the size of child device meets the requirements.
  272. * If the child device size obtained from general definition block
  273. * is different with sizeof(struct child_device_config), skip the
  274. * parsing of sdvo device info
  275. */
  276. if (p_defs->child_dev_size != sizeof(*p_child)) {
  277. /* different child dev size . Ignore it */
  278. DRM_DEBUG_KMS("different child size is found. Invalid.\n");
  279. return;
  280. }
  281. /* get the block size of general definitions */
  282. block_size = get_blocksize(p_defs);
  283. /* get the number of child device */
  284. child_device_num = (block_size - sizeof(*p_defs)) /
  285. sizeof(*p_child);
  286. count = 0;
  287. for (i = 0; i < child_device_num; i++) {
  288. p_child = &(p_defs->devices[i]);
  289. if (!p_child->device_type) {
  290. /* skip the device block if device type is invalid */
  291. continue;
  292. }
  293. if (p_child->slave_addr != SLAVE_ADDR1 &&
  294. p_child->slave_addr != SLAVE_ADDR2) {
  295. /*
  296. * If the slave address is neither 0x70 nor 0x72,
  297. * it is not a SDVO device. Skip it.
  298. */
  299. continue;
  300. }
  301. if (p_child->dvo_port != DEVICE_PORT_DVOB &&
  302. p_child->dvo_port != DEVICE_PORT_DVOC) {
  303. /* skip the incorrect SDVO port */
  304. DRM_DEBUG_KMS("Incorrect SDVO port. Skip it \n");
  305. continue;
  306. }
  307. DRM_DEBUG_KMS("the SDVO device with slave addr %2x is found on"
  308. " %s port\n",
  309. p_child->slave_addr,
  310. (p_child->dvo_port == DEVICE_PORT_DVOB) ?
  311. "SDVOB" : "SDVOC");
  312. p_mapping = &(dev_priv->sdvo_mappings[p_child->dvo_port - 1]);
  313. if (!p_mapping->initialized) {
  314. p_mapping->dvo_port = p_child->dvo_port;
  315. p_mapping->slave_addr = p_child->slave_addr;
  316. p_mapping->dvo_wiring = p_child->dvo_wiring;
  317. p_mapping->ddc_pin = p_child->ddc_pin;
  318. p_mapping->i2c_pin = p_child->i2c_pin;
  319. p_mapping->i2c_speed = p_child->i2c_speed;
  320. p_mapping->initialized = 1;
  321. DRM_DEBUG_KMS("SDVO device: dvo=%x, addr=%x, wiring=%d, ddc_pin=%d, i2c_pin=%d, i2c_speed=%d\n",
  322. p_mapping->dvo_port,
  323. p_mapping->slave_addr,
  324. p_mapping->dvo_wiring,
  325. p_mapping->ddc_pin,
  326. p_mapping->i2c_pin,
  327. p_mapping->i2c_speed);
  328. } else {
  329. DRM_DEBUG_KMS("Maybe one SDVO port is shared by "
  330. "two SDVO device.\n");
  331. }
  332. if (p_child->slave2_addr) {
  333. /* Maybe this is a SDVO device with multiple inputs */
  334. /* And the mapping info is not added */
  335. DRM_DEBUG_KMS("there exists the slave2_addr. Maybe this"
  336. " is a SDVO device with multiple inputs.\n");
  337. }
  338. count++;
  339. }
  340. if (!count) {
  341. /* No SDVO device info is found */
  342. DRM_DEBUG_KMS("No SDVO device info is found in VBT\n");
  343. }
  344. return;
  345. }
  346. static void
  347. parse_driver_features(struct drm_i915_private *dev_priv,
  348. struct bdb_header *bdb)
  349. {
  350. struct drm_device *dev = dev_priv->dev;
  351. struct bdb_driver_features *driver;
  352. driver = find_section(bdb, BDB_DRIVER_FEATURES);
  353. if (!driver)
  354. return;
  355. if (SUPPORTS_EDP(dev) &&
  356. driver->lvds_config == BDB_DRIVER_FEATURE_EDP)
  357. dev_priv->edp.support = 1;
  358. if (driver->dual_frequency)
  359. dev_priv->render_reclock_avail = true;
  360. }
  361. static void
  362. parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
  363. {
  364. struct bdb_edp *edp;
  365. edp = find_section(bdb, BDB_EDP);
  366. if (!edp) {
  367. if (SUPPORTS_EDP(dev_priv->dev) && dev_priv->edp.support) {
  368. DRM_DEBUG_KMS("No eDP BDB found but eDP panel "
  369. "supported, assume %dbpp panel color "
  370. "depth.\n",
  371. dev_priv->edp.bpp);
  372. }
  373. return;
  374. }
  375. switch ((edp->color_depth >> (panel_type * 2)) & 3) {
  376. case EDP_18BPP:
  377. dev_priv->edp.bpp = 18;
  378. break;
  379. case EDP_24BPP:
  380. dev_priv->edp.bpp = 24;
  381. break;
  382. case EDP_30BPP:
  383. dev_priv->edp.bpp = 30;
  384. break;
  385. }
  386. dev_priv->edp.rate = edp->link_params[panel_type].rate;
  387. dev_priv->edp.lanes = edp->link_params[panel_type].lanes;
  388. dev_priv->edp.preemphasis = edp->link_params[panel_type].preemphasis;
  389. dev_priv->edp.vswing = edp->link_params[panel_type].vswing;
  390. DRM_DEBUG_KMS("eDP vBIOS settings: bpp=%d, rate=%d, lanes=%d, preemphasis=%d, vswing=%d\n",
  391. dev_priv->edp.bpp,
  392. dev_priv->edp.rate,
  393. dev_priv->edp.lanes,
  394. dev_priv->edp.preemphasis,
  395. dev_priv->edp.vswing);
  396. dev_priv->edp.initialized = true;
  397. }
  398. static void
  399. parse_device_mapping(struct drm_i915_private *dev_priv,
  400. struct bdb_header *bdb)
  401. {
  402. struct bdb_general_definitions *p_defs;
  403. struct child_device_config *p_child, *child_dev_ptr;
  404. int i, child_device_num, count;
  405. u16 block_size;
  406. p_defs = find_section(bdb, BDB_GENERAL_DEFINITIONS);
  407. if (!p_defs) {
  408. DRM_DEBUG_KMS("No general definition block is found, no devices defined.\n");
  409. return;
  410. }
  411. /* judge whether the size of child device meets the requirements.
  412. * If the child device size obtained from general definition block
  413. * is different with sizeof(struct child_device_config), skip the
  414. * parsing of sdvo device info
  415. */
  416. if (p_defs->child_dev_size != sizeof(*p_child)) {
  417. /* different child dev size . Ignore it */
  418. DRM_DEBUG_KMS("different child size is found. Invalid.\n");
  419. return;
  420. }
  421. /* get the block size of general definitions */
  422. block_size = get_blocksize(p_defs);
  423. /* get the number of child device */
  424. child_device_num = (block_size - sizeof(*p_defs)) /
  425. sizeof(*p_child);
  426. count = 0;
  427. /* get the number of child device that is present */
  428. for (i = 0; i < child_device_num; i++) {
  429. p_child = &(p_defs->devices[i]);
  430. if (!p_child->device_type) {
  431. /* skip the device block if device type is invalid */
  432. continue;
  433. }
  434. count++;
  435. }
  436. if (!count) {
  437. DRM_DEBUG_KMS("no child dev is parsed from VBT \n");
  438. return;
  439. }
  440. dev_priv->child_dev = kzalloc(sizeof(*p_child) * count, GFP_KERNEL);
  441. if (!dev_priv->child_dev) {
  442. DRM_DEBUG_KMS("No memory space for child device\n");
  443. return;
  444. }
  445. dev_priv->child_dev_num = count;
  446. count = 0;
  447. for (i = 0; i < child_device_num; i++) {
  448. p_child = &(p_defs->devices[i]);
  449. if (!p_child->device_type) {
  450. /* skip the device block if device type is invalid */
  451. continue;
  452. }
  453. child_dev_ptr = dev_priv->child_dev + count;
  454. count++;
  455. memcpy((void *)child_dev_ptr, (void *)p_child,
  456. sizeof(*p_child));
  457. }
  458. return;
  459. }
  460. static void
  461. init_vbt_defaults(struct drm_i915_private *dev_priv)
  462. {
  463. dev_priv->crt_ddc_pin = GMBUS_PORT_VGADDC;
  464. /* LFP panel data */
  465. dev_priv->lvds_dither = 1;
  466. dev_priv->lvds_vbt = 0;
  467. /* SDVO panel data */
  468. dev_priv->sdvo_lvds_vbt_mode = NULL;
  469. /* general features */
  470. dev_priv->int_tv_support = 1;
  471. dev_priv->int_crt_support = 1;
  472. dev_priv->lvds_use_ssc = 0;
  473. /* eDP data */
  474. dev_priv->edp.bpp = 18;
  475. }
  476. /**
  477. * intel_init_bios - initialize VBIOS settings & find VBT
  478. * @dev: DRM device
  479. *
  480. * Loads the Video BIOS and checks that the VBT exists. Sets scratch registers
  481. * to appropriate values.
  482. *
  483. * Returns 0 on success, nonzero on failure.
  484. */
  485. bool
  486. intel_init_bios(struct drm_device *dev)
  487. {
  488. struct drm_i915_private *dev_priv = dev->dev_private;
  489. struct pci_dev *pdev = dev->pdev;
  490. struct bdb_header *bdb = NULL;
  491. u8 __iomem *bios = NULL;
  492. init_vbt_defaults(dev_priv);
  493. /* XXX Should this validation be moved to intel_opregion.c? */
  494. if (dev_priv->opregion.vbt) {
  495. struct vbt_header *vbt = dev_priv->opregion.vbt;
  496. if (memcmp(vbt->signature, "$VBT", 4) == 0) {
  497. DRM_DEBUG_DRIVER("Using VBT from OpRegion: %20s\n",
  498. vbt->signature);
  499. bdb = (struct bdb_header *)((char *)vbt + vbt->bdb_offset);
  500. } else
  501. dev_priv->opregion.vbt = NULL;
  502. }
  503. if (bdb == NULL) {
  504. struct vbt_header *vbt = NULL;
  505. size_t size;
  506. int i;
  507. bios = pci_map_rom(pdev, &size);
  508. if (!bios)
  509. return -1;
  510. /* Scour memory looking for the VBT signature */
  511. for (i = 0; i + 4 < size; i++) {
  512. if (!memcmp(bios + i, "$VBT", 4)) {
  513. vbt = (struct vbt_header *)(bios + i);
  514. break;
  515. }
  516. }
  517. if (!vbt) {
  518. DRM_ERROR("VBT signature missing\n");
  519. pci_unmap_rom(pdev, bios);
  520. return -1;
  521. }
  522. bdb = (struct bdb_header *)(bios + i + vbt->bdb_offset);
  523. }
  524. /* Grab useful general definitions */
  525. parse_general_features(dev_priv, bdb);
  526. parse_general_definitions(dev_priv, bdb);
  527. parse_lfp_panel_data(dev_priv, bdb);
  528. parse_sdvo_panel_data(dev_priv, bdb);
  529. parse_sdvo_device_mapping(dev_priv, bdb);
  530. parse_device_mapping(dev_priv, bdb);
  531. parse_driver_features(dev_priv, bdb);
  532. parse_edp(dev_priv, bdb);
  533. if (bios)
  534. pci_unmap_rom(pdev, bios);
  535. return 0;
  536. }