Subversion Repositories Kolibri OS

Rev

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

Rev 5354 Rev 6084
Line 30... Line 30...
30
//#include 
30
//#include 
31
#include 
31
#include 
32
#include 
32
#include 
33
#include 
33
#include 
34
#include 
34
#include 
-
 
35
#include 
35
#include 
36
#include 
36
#include 
37
#include 
37
#include "intel_drv.h"
38
#include "intel_drv.h"
38
#include 
39
#include 
39
#include "i915_drv.h"
40
#include "i915_drv.h"
Line 91... Line 92...
91
 
92
 
92
	return true;
93
	return true;
Line 93... Line 94...
93
}
94
}
94
 
95
 
95
static void intel_lvds_get_config(struct intel_encoder *encoder,
96
static void intel_lvds_get_config(struct intel_encoder *encoder,
96
				  struct intel_crtc_config *pipe_config)
97
				  struct intel_crtc_state *pipe_config)
97
{
98
{
-
 
99
	struct drm_device *dev = encoder->base.dev;
98
	struct drm_device *dev = encoder->base.dev;
100
	struct drm_i915_private *dev_priv = dev->dev_private;
99
	struct drm_i915_private *dev_priv = dev->dev_private;
101
	struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
Line 100... Line -...
100
	u32 lvds_reg, tmp, flags = 0;
-
 
101
	int dotclock;
-
 
102
 
-
 
103
	if (HAS_PCH_SPLIT(dev))
-
 
104
		lvds_reg = PCH_LVDS;
-
 
105
	else
102
	u32 tmp, flags = 0;
106
		lvds_reg = LVDS;
103
	int dotclock;
107
 
104
 
108
	tmp = I915_READ(lvds_reg);
105
	tmp = I915_READ(lvds_encoder->reg);
109
	if (tmp & LVDS_HSYNC_POLARITY)
106
	if (tmp & LVDS_HSYNC_POLARITY)
110
		flags |= DRM_MODE_FLAG_NHSYNC;
107
		flags |= DRM_MODE_FLAG_NHSYNC;
111
	else
108
	else
112
		flags |= DRM_MODE_FLAG_PHSYNC;
109
		flags |= DRM_MODE_FLAG_PHSYNC;
113
	if (tmp & LVDS_VSYNC_POLARITY)
110
	if (tmp & LVDS_VSYNC_POLARITY)
Line 114... Line 111...
114
		flags |= DRM_MODE_FLAG_NVSYNC;
111
		flags |= DRM_MODE_FLAG_NVSYNC;
Line 115... Line 112...
115
	else
112
	else
116
		flags |= DRM_MODE_FLAG_PVSYNC;
113
		flags |= DRM_MODE_FLAG_PVSYNC;
117
 
114
 
Line 127... Line 124...
127
	dotclock = pipe_config->port_clock;
124
	dotclock = pipe_config->port_clock;
Line 128... Line 125...
128
 
125
 
129
	if (HAS_PCH_SPLIT(dev_priv->dev))
126
	if (HAS_PCH_SPLIT(dev_priv->dev))
Line 130... Line 127...
130
		ironlake_check_encoder_dotclock(pipe_config, dotclock);
127
		ironlake_check_encoder_dotclock(pipe_config, dotclock);
131
 
128
 
Line 132... Line 129...
132
	pipe_config->adjusted_mode.crtc_clock = dotclock;
129
	pipe_config->base.adjusted_mode.crtc_clock = dotclock;
133
}
130
}
134
 
131
 
135
static void intel_pre_enable_lvds(struct intel_encoder *encoder)
132
static void intel_pre_enable_lvds(struct intel_encoder *encoder)
136
{
133
{
137
	struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
134
	struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
138
	struct drm_device *dev = encoder->base.dev;
135
	struct drm_device *dev = encoder->base.dev;
139
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
140
	struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
136
	struct drm_i915_private *dev_priv = dev->dev_private;
141
	const struct drm_display_mode *adjusted_mode =
137
	struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
Line 142... Line 138...
142
		&crtc->config.adjusted_mode;
138
	const struct drm_display_mode *adjusted_mode = &crtc->config->base.adjusted_mode;
143
	int pipe = crtc->pipe;
139
	int pipe = crtc->pipe;
Line 165... Line 161...
165
		}
161
		}
166
	}
162
	}
Line 167... Line 163...
167
 
163
 
168
	/* set the corresponsding LVDS_BORDER bit */
164
	/* set the corresponsding LVDS_BORDER bit */
169
	temp &= ~LVDS_BORDER_ENABLE;
165
	temp &= ~LVDS_BORDER_ENABLE;
170
	temp |= crtc->config.gmch_pfit.lvds_border_bits;
166
	temp |= crtc->config->gmch_pfit.lvds_border_bits;
171
	/* Set the B0-B3 data pairs corresponding to whether we're going to
167
	/* Set the B0-B3 data pairs corresponding to whether we're going to
172
	 * set the DPLLs for dual-channel mode or not.
168
	 * set the DPLLs for dual-channel mode or not.
173
	 */
169
	 */
174
	if (lvds_encoder->is_dual_link)
170
	if (lvds_encoder->is_dual_link)
Line 188... Line 184...
188
	 * special lvds dither control bit on pch-split platforms, dithering is
184
	 * special lvds dither control bit on pch-split platforms, dithering is
189
	 * only controlled through the PIPECONF reg. */
185
	 * only controlled through the PIPECONF reg. */
190
	if (INTEL_INFO(dev)->gen == 4) {
186
	if (INTEL_INFO(dev)->gen == 4) {
191
		/* Bspec wording suggests that LVDS port dithering only exists
187
		/* Bspec wording suggests that LVDS port dithering only exists
192
		 * for 18bpp panels. */
188
		 * for 18bpp panels. */
193
		if (crtc->config.dither && crtc->config.pipe_bpp == 18)
189
		if (crtc->config->dither && crtc->config->pipe_bpp == 18)
194
			temp |= LVDS_ENABLE_DITHER;
190
			temp |= LVDS_ENABLE_DITHER;
195
		else
191
		else
196
			temp &= ~LVDS_ENABLE_DITHER;
192
			temp &= ~LVDS_ENABLE_DITHER;
197
	}
193
	}
198
	temp &= ~(LVDS_HSYNC_POLARITY | LVDS_VSYNC_POLARITY);
194
	temp &= ~(LVDS_HSYNC_POLARITY | LVDS_VSYNC_POLARITY);
Line 236... Line 232...
236
 
232
 
237
static void intel_disable_lvds(struct intel_encoder *encoder)
233
static void intel_disable_lvds(struct intel_encoder *encoder)
238
{
234
{
239
	struct drm_device *dev = encoder->base.dev;
235
	struct drm_device *dev = encoder->base.dev;
240
	struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
-
 
241
	struct intel_connector *intel_connector =
-
 
242
		&lvds_encoder->attached_connector->base;
236
	struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
243
	struct drm_i915_private *dev_priv = dev->dev_private;
237
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 244... Line 238...
244
	u32 ctl_reg, stat_reg;
238
	u32 ctl_reg, stat_reg;
245
 
239
 
Line 249... Line 243...
249
	} else {
243
	} else {
250
		ctl_reg = PP_CONTROL;
244
		ctl_reg = PP_CONTROL;
251
		stat_reg = PP_STATUS;
245
		stat_reg = PP_STATUS;
252
	}
246
	}
Line 253... Line -...
253
 
-
 
254
	intel_panel_disable_backlight(intel_connector);
-
 
255
 
247
 
256
	I915_WRITE(ctl_reg, I915_READ(ctl_reg) & ~POWER_TARGET_ON);
248
	I915_WRITE(ctl_reg, I915_READ(ctl_reg) & ~POWER_TARGET_ON);
257
	if (wait_for((I915_READ(stat_reg) & PP_ON) == 0, 1000))
249
	if (wait_for((I915_READ(stat_reg) & PP_ON) == 0, 1000))
Line 258... Line 250...
258
		DRM_ERROR("timed out waiting for panel to power off\n");
250
		DRM_ERROR("timed out waiting for panel to power off\n");
259
 
251
 
260
	I915_WRITE(lvds_encoder->reg, I915_READ(lvds_encoder->reg) & ~LVDS_PORT_EN);
252
	I915_WRITE(lvds_encoder->reg, I915_READ(lvds_encoder->reg) & ~LVDS_PORT_EN);
Line -... Line 253...
-
 
253
	POSTING_READ(lvds_encoder->reg);
-
 
254
}
-
 
255
 
-
 
256
static void gmch_disable_lvds(struct intel_encoder *encoder)
-
 
257
{
-
 
258
	struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
-
 
259
	struct intel_connector *intel_connector =
-
 
260
		&lvds_encoder->attached_connector->base;
-
 
261
 
-
 
262
	intel_panel_disable_backlight(intel_connector);
-
 
263
 
-
 
264
	intel_disable_lvds(encoder);
-
 
265
}
-
 
266
 
-
 
267
static void pch_disable_lvds(struct intel_encoder *encoder)
-
 
268
{
-
 
269
	struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
-
 
270
	struct intel_connector *intel_connector =
-
 
271
		&lvds_encoder->attached_connector->base;
-
 
272
 
-
 
273
	intel_panel_disable_backlight(intel_connector);
-
 
274
}
-
 
275
 
-
 
276
static void pch_post_disable_lvds(struct intel_encoder *encoder)
-
 
277
{
261
	POSTING_READ(lvds_encoder->reg);
278
	intel_disable_lvds(encoder);
262
}
279
}
263
 
280
 
264
static enum drm_mode_status
281
static enum drm_mode_status
265
intel_lvds_mode_valid(struct drm_connector *connector,
282
intel_lvds_mode_valid(struct drm_connector *connector,
266
				 struct drm_display_mode *mode)
283
		      struct drm_display_mode *mode)
-
 
284
{
Line 267... Line 285...
267
{
285
	struct intel_connector *intel_connector = to_intel_connector(connector);
268
	struct intel_connector *intel_connector = to_intel_connector(connector);
286
	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
269
	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
287
	int max_pixclk = to_i915(connector->dev)->max_dotclk_freq;
270
 
288
 
-
 
289
	if (mode->hdisplay > fixed_mode->hdisplay)
-
 
290
		return MODE_PANEL;
Line 271... Line 291...
271
	if (mode->hdisplay > fixed_mode->hdisplay)
291
	if (mode->vdisplay > fixed_mode->vdisplay)
272
		return MODE_PANEL;
292
		return MODE_PANEL;
Line 273... Line 293...
273
	if (mode->vdisplay > fixed_mode->vdisplay)
293
	if (fixed_mode->clock > max_pixclk)
274
		return MODE_PANEL;
294
		return MODE_CLOCK_HIGH;
275
 
295
 
276
	return MODE_OK;
296
	return MODE_OK;
277
}
297
}
278
 
298
 
279
static bool intel_lvds_compute_config(struct intel_encoder *intel_encoder,
299
static bool intel_lvds_compute_config(struct intel_encoder *intel_encoder,
280
				      struct intel_crtc_config *pipe_config)
300
				      struct intel_crtc_state *pipe_config)
281
{
301
{
282
	struct drm_device *dev = intel_encoder->base.dev;
302
	struct drm_device *dev = intel_encoder->base.dev;
283
	struct intel_lvds_encoder *lvds_encoder =
303
	struct intel_lvds_encoder *lvds_encoder =
Line 284... Line 304...
284
		to_lvds_encoder(&intel_encoder->base);
304
		to_lvds_encoder(&intel_encoder->base);
285
	struct intel_connector *intel_connector =
305
	struct intel_connector *intel_connector =
286
		&lvds_encoder->attached_connector->base;
306
		&lvds_encoder->attached_connector->base;
Line 450... Line 470...
450
	 * and as part of the cleanup in the hw state restore we also redisable
470
	 * and as part of the cleanup in the hw state restore we also redisable
451
	 * the vga plane.
471
	 * the vga plane.
452
	 */
472
	 */
453
	if (!HAS_PCH_SPLIT(dev)) {
473
	if (!HAS_PCH_SPLIT(dev)) {
454
	drm_modeset_lock_all(dev);
474
		drm_modeset_lock_all(dev);
455
	intel_modeset_setup_hw_state(dev, true);
475
		intel_display_resume(dev);
456
	drm_modeset_unlock_all(dev);
476
		drm_modeset_unlock_all(dev);
457
	}
477
	}
Line 458... Line 478...
458
 
478
 
Line 506... Line 526...
506
			return 0;
526
			return 0;
507
		}
527
		}
508
		intel_connector->panel.fitting_mode = value;
528
		intel_connector->panel.fitting_mode = value;
Line 509... Line 529...
509
 
529
 
510
		crtc = intel_attached_encoder(connector)->base.crtc;
530
		crtc = intel_attached_encoder(connector)->base.crtc;
511
		if (crtc && crtc->enabled) {
531
		if (crtc && crtc->state->enable) {
512
			/*
532
			/*
513
			 * If the CRTC is enabled, the display will be changed
533
			 * If the CRTC is enabled, the display will be changed
514
			 * according to the new panel fitting mode.
534
			 * according to the new panel fitting mode.
515
			 */
535
			 */
Line 525... Line 545...
525
	.mode_valid = intel_lvds_mode_valid,
545
	.mode_valid = intel_lvds_mode_valid,
526
	.best_encoder = intel_best_encoder,
546
	.best_encoder = intel_best_encoder,
527
};
547
};
Line 528... Line 548...
528
 
548
 
529
static const struct drm_connector_funcs intel_lvds_connector_funcs = {
549
static const struct drm_connector_funcs intel_lvds_connector_funcs = {
530
	.dpms = intel_connector_dpms,
550
	.dpms = drm_atomic_helper_connector_dpms,
531
	.detect = intel_lvds_detect,
551
	.detect = intel_lvds_detect,
532
	.fill_modes = drm_helper_probe_single_connector_modes,
552
	.fill_modes = drm_helper_probe_single_connector_modes,
-
 
553
	.set_property = intel_lvds_set_property,
533
	.set_property = intel_lvds_set_property,
554
	.atomic_get_property = intel_connector_atomic_get_property,
-
 
555
	.destroy = intel_lvds_destroy,
-
 
556
	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
534
	.destroy = intel_lvds_destroy,
557
	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
Line 535... Line 558...
535
};
558
};
536
 
559
 
537
static const struct drm_encoder_funcs intel_lvds_enc_funcs = {
560
static const struct drm_encoder_funcs intel_lvds_enc_funcs = {
Line 775... Line 798...
775
		 */
798
		 */
776
		if (child->device_type != DEVICE_TYPE_INT_LFP &&
799
		if (child->device_type != DEVICE_TYPE_INT_LFP &&
777
		    child->device_type != DEVICE_TYPE_LFP)
800
		    child->device_type != DEVICE_TYPE_LFP)
778
			continue;
801
			continue;
Line 779... Line 802...
779
 
802
 
780
		if (intel_gmbus_is_port_valid(child->i2c_pin))
803
		if (intel_gmbus_is_valid_pin(dev_priv, child->i2c_pin))
Line 781... Line 804...
781
		    *i2c_pin = child->i2c_pin;
804
			*i2c_pin = child->i2c_pin;
782
 
805
 
783
		/* However, we cannot trust the BIOS writers to populate
806
		/* However, we cannot trust the BIOS writers to populate
Line 807... Line 830...
807
}
830
}
Line 808... Line 831...
808
 
831
 
809
static const struct dmi_system_id intel_dual_link_lvds[] = {
832
static const struct dmi_system_id intel_dual_link_lvds[] = {
810
	{
833
	{
811
		.callback = intel_dual_link_lvds_callback,
834
		.callback = intel_dual_link_lvds_callback,
-
 
835
		.ident = "Apple MacBook Pro 15\" (2010)",
-
 
836
		.matches = {
-
 
837
			DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
-
 
838
			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro6,2"),
-
 
839
		},
-
 
840
	},
-
 
841
	{
-
 
842
		.callback = intel_dual_link_lvds_callback,
812
		.ident = "Apple MacBook Pro (Core i5/i7 Series)",
843
		.ident = "Apple MacBook Pro 15\" (2011)",
813
		.matches = {
844
		.matches = {
814
			DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
845
			DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
815
			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro8,2"),
846
			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro8,2"),
816
		},
847
		},
-
 
848
	},
-
 
849
	{
-
 
850
		.callback = intel_dual_link_lvds_callback,
-
 
851
		.ident = "Apple MacBook Pro 15\" (2012)",
-
 
852
		.matches = {
-
 
853
			DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
-
 
854
			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro9,1"),
-
 
855
		},
817
	},
856
	},
818
	{ }	/* terminating entry */
857
	{ }	/* terminating entry */
Line 819... Line 858...
819
};
858
};
820
 
859
 
Line 842... Line 881...
842
 
881
 
843
	/* use the module option value if specified */
882
	/* use the module option value if specified */
844
	if (i915.lvds_channel_mode > 0)
883
	if (i915.lvds_channel_mode > 0)
Line -... Line 884...
-
 
884
		return i915.lvds_channel_mode == 2;
-
 
885
 
-
 
886
	/* single channel LVDS is limited to 112 MHz */
-
 
887
	if (lvds_encoder->attached_connector->base.panel.fixed_mode->clock
-
 
888
	    > 112999)
845
		return i915.lvds_channel_mode == 2;
889
		return true;
846
 
890
 
Line 847... Line 891...
847
	if (dmi_check_system(intel_dual_link_lvds))
891
	if (dmi_check_system(intel_dual_link_lvds))
848
		return true;
892
		return true;
Line 893... Line 937...
893
	struct drm_display_mode *scan; /* *modes, *bios_mode; */
937
	struct drm_display_mode *scan; /* *modes, *bios_mode; */
894
	struct drm_display_mode *fixed_mode = NULL;
938
	struct drm_display_mode *fixed_mode = NULL;
895
	struct drm_display_mode *downclock_mode = NULL;
939
	struct drm_display_mode *downclock_mode = NULL;
896
	struct edid *edid;
940
	struct edid *edid;
897
	struct drm_crtc *crtc;
941
	struct drm_crtc *crtc;
-
 
942
	u32 lvds_reg;
898
	u32 lvds;
943
	u32 lvds;
899
	int pipe;
944
	int pipe;
900
	u8 pin;
945
	u8 pin;
Line 901... Line 946...
901
 
946
 
Line 904... Line 949...
904
	 * checking quirk lists to avoid bogus WARNINGs.
949
	 * checking quirk lists to avoid bogus WARNINGs.
905
	 */
950
	 */
906
	if (HAS_PCH_SPLIT(dev)) {
951
	if (HAS_PCH_SPLIT(dev)) {
907
		I915_WRITE(PCH_PP_CONTROL,
952
		I915_WRITE(PCH_PP_CONTROL,
908
			   I915_READ(PCH_PP_CONTROL) | PANEL_UNLOCK_REGS);
953
			   I915_READ(PCH_PP_CONTROL) | PANEL_UNLOCK_REGS);
909
	} else {
954
	} else if (INTEL_INFO(dev_priv)->gen < 5) {
910
		I915_WRITE(PP_CONTROL,
955
		I915_WRITE(PP_CONTROL,
911
			   I915_READ(PP_CONTROL) | PANEL_UNLOCK_REGS);
956
			   I915_READ(PP_CONTROL) | PANEL_UNLOCK_REGS);
912
	}
957
	}
913
	if (!intel_lvds_supported(dev))
958
	if (!intel_lvds_supported(dev))
914
		return;
959
		return;
Line 915... Line 960...
915
 
960
 
916
	/* Skip init on machines we know falsely report LVDS */
961
	/* Skip init on machines we know falsely report LVDS */
917
	if (dmi_check_system(intel_no_lvds))
962
	if (dmi_check_system(intel_no_lvds))
Line 918... Line 963...
918
		return;
963
		return;
919
 
964
 
920
	pin = GMBUS_PORT_PANEL;
-
 
921
	if (!lvds_is_present_in_vbt(dev, &pin)) {
965
	if (HAS_PCH_SPLIT(dev))
-
 
966
		lvds_reg = PCH_LVDS;
922
		DRM_DEBUG_KMS("LVDS is not present in VBT\n");
967
	else
-
 
968
		lvds_reg = LVDS;
Line 923... Line 969...
923
		return;
969
 
924
	}
970
	lvds = I915_READ(lvds_reg);
925
 
971
 
926
	if (HAS_PCH_SPLIT(dev)) {
972
	if (HAS_PCH_SPLIT(dev)) {
927
		if ((I915_READ(PCH_LVDS) & LVDS_DETECTED) == 0)
973
		if ((lvds & LVDS_DETECTED) == 0)
928
			return;
974
			return;
929
		if (dev_priv->vbt.edp_support) {
975
		if (dev_priv->vbt.edp_support) {
930
			DRM_DEBUG_KMS("disable LVDS for eDP support\n");
976
			DRM_DEBUG_KMS("disable LVDS for eDP support\n");
Line -... Line 977...
-
 
977
			return;
-
 
978
		}
-
 
979
	}
-
 
980
 
-
 
981
	pin = GMBUS_PIN_PANEL;
-
 
982
	if (!lvds_is_present_in_vbt(dev, &pin)) {
-
 
983
		if ((lvds & LVDS_PORT_EN) == 0) {
-
 
984
			DRM_DEBUG_KMS("LVDS is not present in VBT\n");
-
 
985
			return;
-
 
986
		}
-
 
987
		DRM_DEBUG_KMS("LVDS is not present in VBT, but enabled anyway\n");
-
 
988
	}
-
 
989
 
-
 
990
	 /* Set the Panel Power On/Off timings if uninitialized. */
-
 
991
	if (INTEL_INFO(dev_priv)->gen < 5 &&
-
 
992
	    I915_READ(PP_ON_DELAYS) == 0 && I915_READ(PP_OFF_DELAYS) == 0) {
-
 
993
		/* Set T2 to 40ms and T5 to 200ms */
-
 
994
		I915_WRITE(PP_ON_DELAYS, 0x019007d0);
-
 
995
 
-
 
996
		/* Set T3 to 35ms and Tx to 200ms */
-
 
997
		I915_WRITE(PP_OFF_DELAYS, 0x015e07d0);
931
			return;
998
 
932
		}
999
		DRM_DEBUG_KMS("Panel power timings uninitialized, setting defaults\n");
933
	}
1000
	}
Line 934... Line 1001...
934
 
1001
 
935
	lvds_encoder = kzalloc(sizeof(*lvds_encoder), GFP_KERNEL);
1002
	lvds_encoder = kzalloc(sizeof(*lvds_encoder), GFP_KERNEL);
936
	if (!lvds_encoder)
1003
	if (!lvds_encoder)
937
		return;
1004
		return;
938
 
1005
 
Line -... Line 1006...
-
 
1006
	lvds_connector = kzalloc(sizeof(*lvds_connector), GFP_KERNEL);
-
 
1007
	if (!lvds_connector) {
-
 
1008
		kfree(lvds_encoder);
-
 
1009
		return;
-
 
1010
	}
-
 
1011
 
939
	lvds_connector = kzalloc(sizeof(*lvds_connector), GFP_KERNEL);
1012
	if (intel_connector_init(&lvds_connector->base) < 0) {
Line 940... Line 1013...
940
	if (!lvds_connector) {
1013
		kfree(lvds_connector);
941
		kfree(lvds_encoder);
1014
		kfree(lvds_encoder);
942
		return;
1015
		return;
Line 955... Line 1028...
955
			 DRM_MODE_ENCODER_LVDS);
1028
			 DRM_MODE_ENCODER_LVDS);
Line 956... Line 1029...
956
 
1029
 
957
	intel_encoder->enable = intel_enable_lvds;
1030
	intel_encoder->enable = intel_enable_lvds;
958
	intel_encoder->pre_enable = intel_pre_enable_lvds;
1031
	intel_encoder->pre_enable = intel_pre_enable_lvds;
-
 
1032
	intel_encoder->compute_config = intel_lvds_compute_config;
-
 
1033
	if (HAS_PCH_SPLIT(dev_priv)) {
-
 
1034
		intel_encoder->disable = pch_disable_lvds;
-
 
1035
		intel_encoder->post_disable = pch_post_disable_lvds;
959
	intel_encoder->compute_config = intel_lvds_compute_config;
1036
	} else {
-
 
1037
		intel_encoder->disable = gmch_disable_lvds;
960
	intel_encoder->disable = intel_disable_lvds;
1038
	}
961
	intel_encoder->get_hw_state = intel_lvds_get_hw_state;
1039
	intel_encoder->get_hw_state = intel_lvds_get_hw_state;
962
	intel_encoder->get_config = intel_lvds_get_config;
1040
	intel_encoder->get_config = intel_lvds_get_config;
963
	intel_connector->get_hw_state = intel_connector_get_hw_state;
1041
	intel_connector->get_hw_state = intel_connector_get_hw_state;
Line 977... Line 1055...
977
	drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs);
1055
	drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs);
978
	connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1056
	connector->display_info.subpixel_order = SubPixelHorizontalRGB;
979
	connector->interlace_allowed = false;
1057
	connector->interlace_allowed = false;
980
	connector->doublescan_allowed = false;
1058
	connector->doublescan_allowed = false;
Line 981... Line -...
981
 
-
 
982
	if (HAS_PCH_SPLIT(dev)) {
1059
 
983
		lvds_encoder->reg = PCH_LVDS;
-
 
984
	} else {
-
 
985
		lvds_encoder->reg = LVDS;
-
 
Line 986... Line 1060...
986
	}
1060
	lvds_encoder->reg = lvds_reg;
987
 
1061
 
988
	/* create the scaling mode property */
1062
	/* create the scaling mode property */
989
	drm_mode_create_scaling_mode_property(dev);
1063
	drm_mode_create_scaling_mode_property(dev);
Line 1035... Line 1109...
1035
		if (scan->type & DRM_MODE_TYPE_PREFERRED) {
1109
		if (scan->type & DRM_MODE_TYPE_PREFERRED) {
1036
			DRM_DEBUG_KMS("using preferred mode from EDID: ");
1110
			DRM_DEBUG_KMS("using preferred mode from EDID: ");
1037
			drm_mode_debug_printmodeline(scan);
1111
			drm_mode_debug_printmodeline(scan);
Line 1038... Line 1112...
1038
 
1112
 
1039
			fixed_mode = drm_mode_duplicate(dev, scan);
1113
			fixed_mode = drm_mode_duplicate(dev, scan);
1040
			if (fixed_mode) {
-
 
1041
				downclock_mode =
-
 
1042
					intel_find_panel_downclock(dev,
-
 
1043
					fixed_mode, connector);
-
 
1044
				if (downclock_mode != NULL &&
-
 
1045
					i915.lvds_downclock) {
-
 
1046
					/* We found the downclock for LVDS. */
-
 
1047
					dev_priv->lvds_downclock_avail = true;
-
 
1048
					dev_priv->lvds_downclock =
-
 
1049
						downclock_mode->clock;
-
 
1050
					DRM_DEBUG_KMS("LVDS downclock is found"
-
 
1051
					" in EDID. Normal clock %dKhz, "
-
 
1052
					"downclock %dKhz\n",
-
 
1053
					fixed_mode->clock,
-
 
1054
					dev_priv->lvds_downclock);
-
 
1055
				}
1114
			if (fixed_mode)
1056
			goto out;
1115
				goto out;
1057
		}
1116
		}
1058
	}
-
 
Line 1059... Line 1117...
1059
	}
1117
	}
1060
 
1118
 
1061
	/* Failed to get EDID, what about VBT? */
1119
	/* Failed to get EDID, what about VBT? */
1062
	if (dev_priv->vbt.lfp_lvds_vbt_mode) {
1120
	if (dev_priv->vbt.lfp_lvds_vbt_mode) {
Line 1078... Line 1136...
1078
 
1136
 
1079
	/* Ironlake: FIXME if still fail, not try pipe mode now */
1137
	/* Ironlake: FIXME if still fail, not try pipe mode now */
1080
	if (HAS_PCH_SPLIT(dev))
1138
	if (HAS_PCH_SPLIT(dev))
Line 1081... Line -...
1081
		goto failed;
-
 
1082
 
1139
		goto failed;
1083
	lvds = I915_READ(LVDS);
1140
 
Line 1084... Line 1141...
1084
	pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0;
1141
	pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0;
1085
	crtc = intel_get_crtc_for_pipe(dev, pipe);
1142
	crtc = intel_get_crtc_for_pipe(dev, pipe);
Line 1099... Line 1156...
1099
		goto failed;
1156
		goto failed;
Line 1100... Line 1157...
1100
 
1157
 
1101
out:
1158
out:
Line -... Line 1159...
-
 
1159
	mutex_unlock(&dev->mode_config.mutex);
-
 
1160
 
1102
	mutex_unlock(&dev->mode_config.mutex);
1161
	intel_panel_init(&intel_connector->panel, fixed_mode, downclock_mode);
1103
 
1162
 
1104
	lvds_encoder->is_dual_link = compute_is_dual_link_lvds(lvds_encoder);
1163
	lvds_encoder->is_dual_link = compute_is_dual_link_lvds(lvds_encoder);
Line 1105... Line 1164...
1105
	DRM_DEBUG_KMS("detected %s-link lvds configuration\n",
1164
	DRM_DEBUG_KMS("detected %s-link lvds configuration\n",
1106
		      lvds_encoder->is_dual_link ? "dual" : "single");
1165
		      lvds_encoder->is_dual_link ? "dual" : "single");
Line 1107... Line 1166...
1107
 
1166
 
Line 1108... Line -...
1108
	lvds_encoder->a3_power = I915_READ(lvds_encoder->reg) &
-
 
1109
				 LVDS_A3_POWER_MASK;
1167
	lvds_encoder->a3_power = I915_READ(lvds_encoder->reg) &
Line 1110... Line 1168...
1110
 
1168
				 LVDS_A3_POWER_MASK;
Line 1111... Line 1169...
1111
	drm_connector_register(connector);
1169