Subversion Repositories Kolibri OS

Rev

Rev 4560 | Rev 5097 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4560 Rev 5060
Line 22... Line 22...
22
 *
22
 *
23
 * Authors:
23
 * Authors:
24
 *    Eric Anholt 
24
 *    Eric Anholt 
25
 *
25
 *
26
 */
26
 */
27
#include 
-
 
28
#include 
27
#include 
-
 
28
#include 
29
#include 
29
#include 
30
#include "i915_drv.h"
30
#include "i915_drv.h"
31
#include "intel_bios.h"
31
#include "intel_bios.h"
Line 32... Line 32...
32
 
32
 
Line 46... Line 46...
46
	/* skip to first section */
46
	/* skip to first section */
47
	index += bdb->header_size;
47
	index += bdb->header_size;
48
	total = bdb->bdb_size;
48
	total = bdb->bdb_size;
Line 49... Line 49...
49
 
49
 
50
	/* walk the sections looking for section_id */
50
	/* walk the sections looking for section_id */
51
	while (index < total) {
51
	while (index + 3 < total) {
52
		current_id = *(base + index);
52
		current_id = *(base + index);
-
 
53
		index++;
53
		index++;
54
 
54
		current_size = *((u16 *)(base + index));
55
		current_size = *((u16 *)(base + index));
-
 
56
		index += 2;
-
 
57
 
-
 
58
		if (index + current_size > total)
-
 
59
			return NULL;
55
		index += 2;
60
 
56
		if (current_id == section_id)
61
		if (current_id == section_id)
-
 
62
			return base + index;
57
			return base + index;
63
 
58
		index += current_size;
64
		index += current_size;
Line 59... Line 65...
59
	}
65
	}
60
 
66
 
Line 203... Line 209...
203
	const struct bdb_lvds_lfp_data *lvds_lfp_data;
209
	const struct bdb_lvds_lfp_data *lvds_lfp_data;
204
	const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
210
	const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
205
	const struct lvds_dvo_timing *panel_dvo_timing;
211
	const struct lvds_dvo_timing *panel_dvo_timing;
206
	const struct lvds_fp_timing *fp_timing;
212
	const struct lvds_fp_timing *fp_timing;
207
	struct drm_display_mode *panel_fixed_mode;
213
	struct drm_display_mode *panel_fixed_mode;
208
	int i, downclock;
214
	int i, downclock, drrs_mode;
Line 209... Line 215...
209
 
215
 
210
	lvds_options = find_section(bdb, BDB_LVDS_OPTIONS);
216
	lvds_options = find_section(bdb, BDB_LVDS_OPTIONS);
211
	if (!lvds_options)
217
	if (!lvds_options)
Line 215... Line 221...
215
	if (lvds_options->panel_type == 0xff)
221
	if (lvds_options->panel_type == 0xff)
216
		return;
222
		return;
Line 217... Line 223...
217
 
223
 
Line -... Line 224...
-
 
224
	panel_type = lvds_options->panel_type;
-
 
225
 
-
 
226
	drrs_mode = (lvds_options->dps_panel_type_bits
-
 
227
				>> (panel_type * 2)) & MODE_MASK;
-
 
228
	/*
-
 
229
	 * VBT has static DRRS = 0 and seamless DRRS = 2.
-
 
230
	 * The below piece of code is required to adjust vbt.drrs_type
-
 
231
	 * to match the enum drrs_support_type.
-
 
232
	 */
-
 
233
	switch (drrs_mode) {
-
 
234
	case 0:
-
 
235
		dev_priv->vbt.drrs_type = STATIC_DRRS_SUPPORT;
-
 
236
		DRM_DEBUG_KMS("DRRS supported mode is static\n");
-
 
237
		break;
-
 
238
	case 2:
-
 
239
		dev_priv->vbt.drrs_type = SEAMLESS_DRRS_SUPPORT;
-
 
240
		DRM_DEBUG_KMS("DRRS supported mode is seamless\n");
-
 
241
		break;
-
 
242
	default:
-
 
243
		dev_priv->vbt.drrs_type = DRRS_NOT_SUPPORTED;
-
 
244
		DRM_DEBUG_KMS("DRRS not supported (VBT input)\n");
-
 
245
		break;
218
	panel_type = lvds_options->panel_type;
246
	}
219
 
247
 
220
	lvds_lfp_data = find_section(bdb, BDB_LVDS_LFP_DATA);
248
	lvds_lfp_data = find_section(bdb, BDB_LVDS_LFP_DATA);
Line 221... Line 249...
221
	if (!lvds_lfp_data)
249
	if (!lvds_lfp_data)
Line 256... Line 284...
256
		if (lvds_dvo_timing_equal_size(dvo_timing, panel_dvo_timing) &&
284
		if (lvds_dvo_timing_equal_size(dvo_timing, panel_dvo_timing) &&
257
		    dvo_timing->clock < downclock)
285
		    dvo_timing->clock < downclock)
258
			downclock = dvo_timing->clock;
286
			downclock = dvo_timing->clock;
259
	}
287
	}
Line 260... Line 288...
260
 
288
 
261
	if (downclock < panel_dvo_timing->clock && i915_lvds_downclock) {
289
	if (downclock < panel_dvo_timing->clock && i915.lvds_downclock) {
262
		dev_priv->lvds_downclock_avail = 1;
290
		dev_priv->lvds_downclock_avail = 1;
263
		dev_priv->lvds_downclock = downclock * 10;
291
		dev_priv->lvds_downclock = downclock * 10;
264
		DRM_DEBUG_KMS("LVDS downclock is found in VBT. "
292
		DRM_DEBUG_KMS("LVDS downclock is found in VBT. "
265
			      "Normal Clock %dKHz, downclock %dKHz\n",
293
			      "Normal Clock %dKHz, downclock %dKHz\n",
Line 296... Line 324...
296
		return;
324
		return;
297
	}
325
	}
Line 298... Line 326...
298
 
326
 
Line -... Line 327...
-
 
327
	entry = &backlight_data->data[panel_type];
-
 
328
 
-
 
329
	dev_priv->vbt.backlight.present = entry->type == BDB_BACKLIGHT_TYPE_PWM;
-
 
330
	if (!dev_priv->vbt.backlight.present) {
-
 
331
		DRM_DEBUG_KMS("PWM backlight not present in VBT (type %u)\n",
-
 
332
			      entry->type);
-
 
333
		return;
299
	entry = &backlight_data->data[panel_type];
334
	}
300
 
335
 
-
 
336
	dev_priv->vbt.backlight.pwm_freq_hz = entry->pwm_freq_hz;
301
	dev_priv->vbt.backlight.pwm_freq_hz = entry->pwm_freq_hz;
337
	dev_priv->vbt.backlight.active_low_pwm = entry->active_low_pwm;
302
	dev_priv->vbt.backlight.active_low_pwm = entry->active_low_pwm;
338
	dev_priv->vbt.backlight.min_brightness = entry->min_brightness;
303
	DRM_DEBUG_KMS("VBT backlight PWM modulation frequency %u Hz, "
339
	DRM_DEBUG_KMS("VBT backlight PWM modulation frequency %u Hz, "
304
		      "active %s, min brightness %u, level %u\n",
340
		      "active %s, min brightness %u, level %u\n",
305
		      dev_priv->vbt.backlight.pwm_freq_hz,
341
		      dev_priv->vbt.backlight.pwm_freq_hz,
306
		      dev_priv->vbt.backlight.active_low_pwm ? "low" : "high",
342
		      dev_priv->vbt.backlight.active_low_pwm ? "low" : "high",
307
		      entry->min_brightness,
343
		      dev_priv->vbt.backlight.min_brightness,
Line 308... Line 344...
308
		      backlight_data->level[panel_type]);
344
		      backlight_data->level[panel_type]);
309
}
345
}
Line 315... Line 351...
315
{
351
{
316
	struct lvds_dvo_timing *dvo_timing;
352
	struct lvds_dvo_timing *dvo_timing;
317
	struct drm_display_mode *panel_fixed_mode;
353
	struct drm_display_mode *panel_fixed_mode;
318
	int index;
354
	int index;
Line 319... Line 355...
319
 
355
 
320
	index = i915_vbt_sdvo_panel_type;
356
	index = i915.vbt_sdvo_panel_type;
321
	if (index == -2) {
357
	if (index == -2) {
322
		DRM_DEBUG_KMS("Ignore SDVO panel mode from BIOS VBT tables.\n");
358
		DRM_DEBUG_KMS("Ignore SDVO panel mode from BIOS VBT tables.\n");
323
		return;
359
		return;
Line 513... Line 549...
513
	if (driver->lvds_config == BDB_DRIVER_FEATURE_EDP)
549
	if (driver->lvds_config == BDB_DRIVER_FEATURE_EDP)
514
		dev_priv->vbt.edp_support = 1;
550
		dev_priv->vbt.edp_support = 1;
Line 515... Line 551...
515
 
551
 
516
	if (driver->dual_frequency)
552
	if (driver->dual_frequency)
-
 
553
		dev_priv->render_reclock_avail = true;
-
 
554
 
-
 
555
	DRM_DEBUG_KMS("DRRS State Enabled:%d\n", driver->drrs_enabled);
-
 
556
	/*
-
 
557
	 * If DRRS is not supported, drrs_type has to be set to 0.
-
 
558
	 * This is because, VBT is configured in such a way that
-
 
559
	 * static DRRS is 0 and DRRS not supported is represented by
-
 
560
	 * driver->drrs_enabled=false
-
 
561
	 */
-
 
562
	if (!driver->drrs_enabled)
517
		dev_priv->render_reclock_avail = true;
563
		dev_priv->vbt.drrs_type = DRRS_NOT_SUPPORTED;
Line 518... Line 564...
518
}
564
}
519
 
565
 
520
static void
566
static void
Line 547... Line 593...
547
	edp_pps = &edp->power_seqs[panel_type];
593
	edp_pps = &edp->power_seqs[panel_type];
548
	edp_link_params = &edp->link_params[panel_type];
594
	edp_link_params = &edp->link_params[panel_type];
Line 549... Line 595...
549
 
595
 
Line -... Line 596...
-
 
596
	dev_priv->vbt.edp_pps = *edp_pps;
-
 
597
 
550
	dev_priv->vbt.edp_pps = *edp_pps;
598
	switch (edp_link_params->rate) {
-
 
599
	case EDP_RATE_1_62:
551
 
600
		dev_priv->vbt.edp_rate = DP_LINK_BW_1_62;
-
 
601
		break;
-
 
602
	case EDP_RATE_2_7:
-
 
603
		dev_priv->vbt.edp_rate = DP_LINK_BW_2_7;
-
 
604
		break;
-
 
605
	default:
-
 
606
		DRM_DEBUG_KMS("VBT has unknown eDP link rate value %u\n",
-
 
607
			      edp_link_params->rate);
-
 
608
		break;
552
	dev_priv->vbt.edp_rate = edp_link_params->rate ? DP_LINK_BW_2_7 :
609
	}
553
		DP_LINK_BW_1_62;
610
 
554
	switch (edp_link_params->lanes) {
611
	switch (edp_link_params->lanes) {
555
	case 0:
612
	case EDP_LANE_1:
556
		dev_priv->vbt.edp_lanes = 1;
613
		dev_priv->vbt.edp_lanes = 1;
557
		break;
614
		break;
558
	case 1:
615
	case EDP_LANE_2:
559
		dev_priv->vbt.edp_lanes = 2;
616
		dev_priv->vbt.edp_lanes = 2;
560
		break;
-
 
561
	case 3:
617
		break;
562
	default:
618
	case EDP_LANE_4:
-
 
619
		dev_priv->vbt.edp_lanes = 4;
-
 
620
		break;
-
 
621
	default:
-
 
622
		DRM_DEBUG_KMS("VBT has unknown eDP lane count value %u\n",
563
		dev_priv->vbt.edp_lanes = 4;
623
			      edp_link_params->lanes);
-
 
624
		break;
564
		break;
625
	}
565
	}
626
 
566
	switch (edp_link_params->preemphasis) {
627
	switch (edp_link_params->preemphasis) {
567
	case 0:
628
	case EDP_PREEMPHASIS_NONE:
568
		dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_0;
629
		dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_0;
569
		break;
630
		break;
570
	case 1:
631
	case EDP_PREEMPHASIS_3_5dB:
571
		dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_3_5;
632
		dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_3_5;
572
		break;
633
		break;
573
	case 2:
634
	case EDP_PREEMPHASIS_6dB:
574
		dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_6;
635
		dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_6;
575
		break;
636
		break;
576
	case 3:
637
	case EDP_PREEMPHASIS_9_5dB:
-
 
638
		dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_9_5;
-
 
639
		break;
-
 
640
	default:
-
 
641
		DRM_DEBUG_KMS("VBT has unknown eDP pre-emphasis value %u\n",
577
		dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_9_5;
642
			      edp_link_params->preemphasis);
-
 
643
		break;
578
		break;
644
	}
579
	}
645
 
580
	switch (edp_link_params->vswing) {
646
	switch (edp_link_params->vswing) {
581
	case 0:
647
	case EDP_VSWING_0_4V:
582
		dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_400;
648
		dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_400;
583
		break;
649
		break;
584
	case 1:
650
	case EDP_VSWING_0_6V:
585
		dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_600;
651
		dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_600;
586
		break;
652
		break;
587
	case 2:
653
	case EDP_VSWING_0_8V:
588
		dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_800;
654
		dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_800;
589
		break;
655
		break;
590
	case 3:
656
	case EDP_VSWING_1_2V:
-
 
657
		dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_1200;
-
 
658
		break;
-
 
659
	default:
-
 
660
		DRM_DEBUG_KMS("VBT has unknown eDP voltage swing value %u\n",
591
		dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_1200;
661
			      edp_link_params->vswing);
592
		break;
662
		break;
Line -... Line 663...
-
 
663
	}
-
 
664
}
-
 
665
 
-
 
666
static u8 *goto_next_sequence(u8 *data, int *size)
-
 
667
{
-
 
668
	u16 len;
-
 
669
	int tmp = *size;
-
 
670
 
-
 
671
	if (--tmp < 0)
-
 
672
		return NULL;
-
 
673
 
-
 
674
	/* goto first element */
-
 
675
	data++;
-
 
676
	while (1) {
-
 
677
		switch (*data) {
-
 
678
		case MIPI_SEQ_ELEM_SEND_PKT:
-
 
679
			/*
-
 
680
			 * skip by this element payload size
-
 
681
			 * skip elem id, command flag and data type
-
 
682
			 */
-
 
683
			tmp -= 5;
-
 
684
			if (tmp < 0)
-
 
685
				return NULL;
-
 
686
 
-
 
687
			data += 3;
-
 
688
			len = *((u16 *)data);
-
 
689
 
-
 
690
			tmp -= len;
-
 
691
			if (tmp < 0)
-
 
692
				return NULL;
-
 
693
 
-
 
694
			/* skip by len */
-
 
695
			data = data + 2 + len;
-
 
696
			break;
-
 
697
		case MIPI_SEQ_ELEM_DELAY:
-
 
698
			/* skip by elem id, and delay is 4 bytes */
-
 
699
			tmp -= 5;
-
 
700
			if (tmp < 0)
-
 
701
				return NULL;
-
 
702
 
-
 
703
			data += 5;
-
 
704
			break;
-
 
705
		case MIPI_SEQ_ELEM_GPIO:
-
 
706
			tmp -= 3;
-
 
707
			if (tmp < 0)
-
 
708
				return NULL;
-
 
709
 
-
 
710
			data += 3;
-
 
711
			break;
-
 
712
		default:
-
 
713
			DRM_ERROR("Unknown element\n");
-
 
714
			return NULL;
-
 
715
		}
-
 
716
 
-
 
717
		/* end of sequence ? */
-
 
718
		if (*data == 0)
-
 
719
			break;
-
 
720
	}
-
 
721
 
-
 
722
	/* goto next sequence or end of block byte */
-
 
723
	if (--tmp < 0)
-
 
724
		return NULL;
-
 
725
 
-
 
726
	data++;
-
 
727
 
-
 
728
	/* update amount of data left for the sequence block to be parsed */
-
 
729
	*size = tmp;
593
	}
730
	return data;
594
}
731
}
595
 
732
 
596
static void
733
static void
-
 
734
parse_mipi(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
-
 
735
{
-
 
736
	struct bdb_mipi_config *start;
-
 
737
	struct bdb_mipi_sequence *sequence;
-
 
738
	struct mipi_config *config;
-
 
739
	struct mipi_pps_data *pps;
Line 597... Line 740...
597
parse_mipi(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
740
	u8 *data, *seq_data;
598
{
741
	int i, panel_id, seq_size;
599
	struct bdb_mipi *mipi;
-
 
600
 
742
	u16 block_size;
-
 
743
 
-
 
744
	/* parse MIPI blocks only if LFP type is MIPI */
-
 
745
	if (!dev_priv->vbt.has_mipi)
-
 
746
		return;
-
 
747
 
-
 
748
	/* Initialize this to undefined indicating no generic MIPI support */
-
 
749
	dev_priv->vbt.dsi.panel_id = MIPI_DSI_UNDEFINED_PANEL_ID;
-
 
750
 
-
 
751
	/* Block #40 is already parsed and panel_fixed_mode is
-
 
752
	 * stored in dev_priv->lfp_lvds_vbt_mode
-
 
753
	 * resuse this when needed
-
 
754
	 */
-
 
755
 
-
 
756
	/* Parse #52 for panel index used from panel_type already
-
 
757
	 * parsed
-
 
758
	 */
-
 
759
	start = find_section(bdb, BDB_MIPI_CONFIG);
-
 
760
	if (!start) {
-
 
761
		DRM_DEBUG_KMS("No MIPI config BDB found");
-
 
762
		return;
-
 
763
	}
-
 
764
 
-
 
765
	DRM_DEBUG_DRIVER("Found MIPI Config block, panel index = %d\n",
-
 
766
								panel_type);
-
 
767
 
-
 
768
	/*
-
 
769
	 * get hold of the correct configuration block and pps data as per
-
 
770
	 * the panel_type as index
-
 
771
	 */
-
 
772
	config = &start->config[panel_type];
-
 
773
	pps = &start->pps[panel_type];
-
 
774
 
-
 
775
	/* store as of now full data. Trim when we realise all is not needed */
-
 
776
	dev_priv->vbt.dsi.config = kmemdup(config, sizeof(struct mipi_config), GFP_KERNEL);
-
 
777
	if (!dev_priv->vbt.dsi.config)
-
 
778
		return;
-
 
779
 
-
 
780
	dev_priv->vbt.dsi.pps = kmemdup(pps, sizeof(struct mipi_pps_data), GFP_KERNEL);
-
 
781
	if (!dev_priv->vbt.dsi.pps) {
-
 
782
		kfree(dev_priv->vbt.dsi.config);
-
 
783
		return;
-
 
784
	}
-
 
785
 
-
 
786
	/* We have mandatory mipi config blocks. Initialize as generic panel */
-
 
787
	dev_priv->vbt.dsi.panel_id = MIPI_DSI_GENERIC_PANEL_ID;
-
 
788
 
-
 
789
	/* Check if we have sequence block as well */
-
 
790
	sequence = find_section(bdb, BDB_MIPI_SEQUENCE);
-
 
791
	if (!sequence) {
-
 
792
		DRM_DEBUG_KMS("No MIPI Sequence found, parsing complete\n");
-
 
793
		return;
-
 
794
	}
-
 
795
 
-
 
796
	DRM_DEBUG_DRIVER("Found MIPI sequence block\n");
-
 
797
 
-
 
798
	block_size = get_blocksize(sequence);
-
 
799
 
-
 
800
	/*
-
 
801
	 * parse the sequence block for individual sequences
-
 
802
	 */
-
 
803
	dev_priv->vbt.dsi.seq_version = sequence->version;
-
 
804
 
-
 
805
	seq_data = &sequence->data[0];
-
 
806
 
-
 
807
	/*
-
 
808
	 * sequence block is variable length and hence we need to parse and
-
 
809
	 * get the sequence data for specific panel id
-
 
810
	 */
-
 
811
	for (i = 0; i < MAX_MIPI_CONFIGURATIONS; i++) {
-
 
812
		panel_id = *seq_data;
-
 
813
		seq_size = *((u16 *) (seq_data + 1));
-
 
814
		if (panel_id == panel_type)
-
 
815
			break;
-
 
816
 
-
 
817
		/* skip the sequence including seq header of 3 bytes */
-
 
818
		seq_data = seq_data + 3 + seq_size;
-
 
819
		if ((seq_data - &sequence->data[0]) > block_size) {
-
 
820
			DRM_ERROR("Sequence start is beyond sequence block size, corrupted sequence block\n");
-
 
821
			return;
-
 
822
		}
-
 
823
	}
-
 
824
 
-
 
825
	if (i == MAX_MIPI_CONFIGURATIONS) {
-
 
826
		DRM_ERROR("Sequence block detected but no valid configuration\n");
-
 
827
		return;
-
 
828
	}
-
 
829
 
-
 
830
	/* check if found sequence is completely within the sequence block
-
 
831
	 * just being paranoid */
-
 
832
	if (seq_size > block_size) {
-
 
833
		DRM_ERROR("Corrupted sequence/size, bailing out\n");
-
 
834
		return;
-
 
835
	}
-
 
836
 
-
 
837
	/* skip the panel id(1 byte) and seq size(2 bytes) */
-
 
838
	dev_priv->vbt.dsi.data = kmemdup(seq_data + 3, seq_size, GFP_KERNEL);
-
 
839
	if (!dev_priv->vbt.dsi.data)
-
 
840
		return;
-
 
841
 
-
 
842
	/*
-
 
843
	 * loop into the sequence data and split into multiple sequneces
-
 
844
	 * There are only 5 types of sequences as of now
-
 
845
	 */
-
 
846
	data = dev_priv->vbt.dsi.data;
-
 
847
	dev_priv->vbt.dsi.size = seq_size;
-
 
848
 
-
 
849
	/* two consecutive 0x00 indicate end of all sequences */
-
 
850
	while (1) {
-
 
851
		int seq_id = *data;
-
 
852
		if (MIPI_SEQ_MAX > seq_id && seq_id > MIPI_SEQ_UNDEFINED) {
-
 
853
			dev_priv->vbt.dsi.sequence[seq_id] = data;
-
 
854
			DRM_DEBUG_DRIVER("Found mipi sequence - %d\n", seq_id);
-
 
855
		} else {
-
 
856
			DRM_ERROR("undefined sequence\n");
-
 
857
			goto err;
-
 
858
		}
-
 
859
 
-
 
860
		/* partial parsing to skip elements */
-
 
861
		data = goto_next_sequence(data, &seq_size);
-
 
862
 
-
 
863
		if (data == NULL) {
-
 
864
			DRM_ERROR("Sequence elements going beyond block itself. Sequence block parsing failed\n");
-
 
865
			goto err;
601
	mipi = find_section(bdb, BDB_MIPI);
866
		}
Line -... Line 867...
-
 
867
 
-
 
868
		if (*data == 0)
-
 
869
			break; /* end of sequence reached */
-
 
870
	}
-
 
871
 
-
 
872
	DRM_DEBUG_DRIVER("MIPI related vbt parsing complete\n");
-
 
873
	return;
602
	if (!mipi) {
874
err:
603
		DRM_DEBUG_KMS("No MIPI BDB found");
875
	kfree(dev_priv->vbt.dsi.data);
604
		return;
876
	dev_priv->vbt.dsi.data = NULL;
Line 605... Line 877...
605
	}
877
 
606
 
878
	/* error during parsing so set all pointers to null
607
	/* XXX: add more info */
879
	 * because of partial parsing */
Line 786... Line 1058...
786
		p_child = &(p_defs->devices[i]);
1058
		p_child = &(p_defs->devices[i]);
787
		if (!p_child->common.device_type) {
1059
		if (!p_child->common.device_type) {
788
			/* skip the device block if device type is invalid */
1060
			/* skip the device block if device type is invalid */
789
			continue;
1061
			continue;
790
		}
1062
		}
-
 
1063
 
-
 
1064
		if (p_child->common.dvo_port >= DVO_PORT_MIPIA
-
 
1065
		    && p_child->common.dvo_port <= DVO_PORT_MIPID
-
 
1066
		    &&p_child->common.device_type & DEVICE_TYPE_MIPI_OUTPUT) {
-
 
1067
			DRM_DEBUG_KMS("Found MIPI as LFP\n");
-
 
1068
			dev_priv->vbt.has_mipi = 1;
-
 
1069
			dev_priv->vbt.dsi.port = p_child->common.dvo_port;
-
 
1070
		}
-
 
1071
 
791
		child_dev_ptr = dev_priv->vbt.child_dev + count;
1072
		child_dev_ptr = dev_priv->vbt.child_dev + count;
792
		count++;
1073
		count++;
793
		memcpy((void *)child_dev_ptr, (void *)p_child,
1074
		memcpy((void *)child_dev_ptr, (void *)p_child,
794
					sizeof(*p_child));
1075
					sizeof(*p_child));
795
	}
1076
	}
Line 802... Line 1083...
802
	struct drm_device *dev = dev_priv->dev;
1083
	struct drm_device *dev = dev_priv->dev;
803
	enum port port;
1084
	enum port port;
Line 804... Line 1085...
804
 
1085
 
Line -... Line 1086...
-
 
1086
	dev_priv->vbt.crt_ddc_pin = GMBUS_PORT_VGADDC;
-
 
1087
 
-
 
1088
	/* Default to having backlight */
805
	dev_priv->vbt.crt_ddc_pin = GMBUS_PORT_VGADDC;
1089
	dev_priv->vbt.backlight.present = true;
806
 
1090
 
807
	/* LFP panel data */
1091
	/* LFP panel data */
Line 808... Line 1092...
808
	dev_priv->vbt.lvds_dither = 1;
1092
	dev_priv->vbt.lvds_dither = 1;
Line 836... Line 1120...
836
		info->supports_hdmi = info->supports_dvi;
1120
		info->supports_hdmi = info->supports_dvi;
837
		info->supports_dp = (port != PORT_E);
1121
		info->supports_dp = (port != PORT_E);
838
	}
1122
	}
839
}
1123
}
Line -... Line 1124...
-
 
1124
 
-
 
1125
static struct bdb_header *validate_vbt(char *base, size_t size,
-
 
1126
				       struct vbt_header *vbt,
-
 
1127
				       const char *source)
-
 
1128
{
-
 
1129
	size_t offset;
-
 
1130
	struct bdb_header *bdb;
-
 
1131
 
-
 
1132
	if (vbt == NULL) {
-
 
1133
		DRM_DEBUG_DRIVER("VBT signature missing\n");
-
 
1134
		return NULL;
-
 
1135
	}
-
 
1136
 
-
 
1137
	offset = (char *)vbt - base;
-
 
1138
	if (offset + sizeof(struct vbt_header) > size) {
-
 
1139
		DRM_DEBUG_DRIVER("VBT header incomplete\n");
-
 
1140
		return NULL;
-
 
1141
	}
-
 
1142
 
-
 
1143
	if (memcmp(vbt->signature, "$VBT", 4)) {
-
 
1144
		DRM_DEBUG_DRIVER("VBT invalid signature\n");
-
 
1145
		return NULL;
-
 
1146
	}
-
 
1147
 
-
 
1148
	offset += vbt->bdb_offset;
-
 
1149
	if (offset + sizeof(struct bdb_header) > size) {
-
 
1150
		DRM_DEBUG_DRIVER("BDB header incomplete\n");
-
 
1151
		return NULL;
-
 
1152
	}
-
 
1153
 
-
 
1154
	bdb = (struct bdb_header *)(base + offset);
-
 
1155
	if (offset + bdb->bdb_size > size) {
-
 
1156
		DRM_DEBUG_DRIVER("BDB incomplete\n");
-
 
1157
		return NULL;
-
 
1158
	}
-
 
1159
 
-
 
1160
	DRM_DEBUG_KMS("Using VBT from %s: %20s\n",
-
 
1161
		      source, vbt->signature);
-
 
1162
	return bdb;
Line 840... Line 1163...
840
 
1163
}
841
 
1164
 
842
/**
1165
/**
843
 * intel_parse_bios - find VBT and initialize settings from the BIOS
1166
 * intel_parse_bios - find VBT and initialize settings from the BIOS
Line 860... Line 1183...
860
		return -ENODEV;
1183
		return -ENODEV;
Line 861... Line 1184...
861
 
1184
 
Line 862... Line 1185...
862
	init_vbt_defaults(dev_priv);
1185
	init_vbt_defaults(dev_priv);
863
 
1186
 
864
	/* XXX Should this validation be moved to intel_opregion.c? */
1187
	/* XXX Should this validation be moved to intel_opregion.c? */
865
	if (dev_priv->opregion.vbt) {
-
 
866
		struct vbt_header *vbt = dev_priv->opregion.vbt;
-
 
867
		if (memcmp(vbt->signature, "$VBT", 4) == 0) {
-
 
868
			DRM_DEBUG_KMS("Using VBT from OpRegion: %20s\n",
1188
	if (dev_priv->opregion.vbt)
869
					 vbt->signature);
-
 
870
			bdb = (struct bdb_header *)((char *)vbt + vbt->bdb_offset);
1189
		bdb = validate_vbt((char *)dev_priv->opregion.header, OPREGION_SIZE,
871
		} else
-
 
Line 872... Line 1190...
872
			dev_priv->opregion.vbt = NULL;
1190
				   (struct vbt_header *)dev_priv->opregion.vbt,
873
	}
-
 
874
 
1191
				   "OpRegion");
875
	if (bdb == NULL) {
-
 
Line 876... Line 1192...
876
		struct vbt_header *vbt = NULL;
1192
 
877
		size_t size;
1193
	if (bdb == NULL) {
878
		int i;
1194
		size_t i, size;
Line 879... Line 1195...
879
 
1195
 
880
		bios = pci_map_rom(pdev, &size);
1196
		bios = pci_map_rom(pdev, &size);
881
		if (!bios)
1197
		if (!bios)
-
 
1198
			return -1;
882
			return -1;
1199
 
-
 
1200
		/* Scour memory looking for the VBT signature */
883
 
1201
		for (i = 0; i + 4 < size; i++) {
884
		/* Scour memory looking for the VBT signature */
1202
			if (memcmp(bios + i, "$VBT", 4) == 0) {
885
		for (i = 0; i + 4 < size; i++) {
1203
				bdb = validate_vbt(bios, size,
Line 886... Line 1204...
886
			if (!memcmp(bios + i, "$VBT", 4)) {
1204
						   (struct vbt_header *)(bios + i),
887
				vbt = (struct vbt_header *)(bios + i);
-
 
888
				break;
1205
						   "PCI ROM");
889
			}
1206
				break;
890
		}
1207
			}
891
 
-
 
892
		if (!vbt) {
-
 
893
			DRM_DEBUG_DRIVER("VBT signature missing\n");
1208
		}
Line 894... Line 1209...
894
			pci_unmap_rom(pdev, bios);
1209
 
895
			return -1;
1210
		if (!bdb) {
896
		}
1211
			pci_unmap_rom(pdev, bios);