aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_lvds.c
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2012-10-19 07:51:43 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2012-10-22 12:03:02 -0400
commit29b99b4841cc15854475a299aceaa018e7a468f1 (patch)
tree66e0a4923b642a2b30949bfa361e11754ee61104 /drivers/gpu/drm/i915/intel_lvds.c
parentc2fb7916927e989ea424e61ce5fe617e54878827 (diff)
drm/i915/lvds: Rename intel_lvds to intel_lvds_encoder
In preparation for introducing intel_lvds_connector to move some of the LVDS specific storage away from drm_i915_private, first rename the encoder to avoid potential confusion. Based on earlier work by Chris Wilson <chris@chris-wilson.co.uk> CC: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_lvds.c')
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c129
1 files changed, 61 insertions, 68 deletions
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index e3166df55daa..4006cd7fdcd5 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -40,7 +40,7 @@
40#include <linux/acpi.h> 40#include <linux/acpi.h>
41 41
42/* Private structure for the integrated LVDS support */ 42/* Private structure for the integrated LVDS support */
43struct intel_lvds { 43struct intel_lvds_encoder {
44 struct intel_encoder base; 44 struct intel_encoder base;
45 45
46 struct edid *edid; 46 struct edid *edid;
@@ -53,15 +53,15 @@ struct intel_lvds {
53 struct drm_display_mode *fixed_mode; 53 struct drm_display_mode *fixed_mode;
54}; 54};
55 55
56static struct intel_lvds *to_intel_lvds(struct drm_encoder *encoder) 56static struct intel_lvds_encoder *to_lvds_encoder(struct drm_encoder *encoder)
57{ 57{
58 return container_of(encoder, struct intel_lvds, base.base); 58 return container_of(encoder, struct intel_lvds_encoder, base.base);
59} 59}
60 60
61static struct intel_lvds *intel_attached_lvds(struct drm_connector *connector) 61static struct intel_lvds_encoder *intel_attached_lvds(struct drm_connector *connector)
62{ 62{
63 return container_of(intel_attached_encoder(connector), 63 return container_of(intel_attached_encoder(connector),
64 struct intel_lvds, base); 64 struct intel_lvds_encoder, base);
65} 65}
66 66
67static bool intel_lvds_get_hw_state(struct intel_encoder *encoder, 67static bool intel_lvds_get_hw_state(struct intel_encoder *encoder,
@@ -96,7 +96,7 @@ static bool intel_lvds_get_hw_state(struct intel_encoder *encoder,
96static void intel_enable_lvds(struct intel_encoder *encoder) 96static void intel_enable_lvds(struct intel_encoder *encoder)
97{ 97{
98 struct drm_device *dev = encoder->base.dev; 98 struct drm_device *dev = encoder->base.dev;
99 struct intel_lvds *intel_lvds = to_intel_lvds(&encoder->base); 99 struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
100 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); 100 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
101 struct drm_i915_private *dev_priv = dev->dev_private; 101 struct drm_i915_private *dev_priv = dev->dev_private;
102 u32 ctl_reg, lvds_reg, stat_reg; 102 u32 ctl_reg, lvds_reg, stat_reg;
@@ -113,7 +113,7 @@ static void intel_enable_lvds(struct intel_encoder *encoder)
113 113
114 I915_WRITE(lvds_reg, I915_READ(lvds_reg) | LVDS_PORT_EN); 114 I915_WRITE(lvds_reg, I915_READ(lvds_reg) | LVDS_PORT_EN);
115 115
116 if (intel_lvds->pfit_dirty) { 116 if (lvds_encoder->pfit_dirty) {
117 /* 117 /*
118 * Enable automatic panel scaling so that non-native modes 118 * Enable automatic panel scaling so that non-native modes
119 * fill the screen. The panel fitter should only be 119 * fill the screen. The panel fitter should only be
@@ -121,12 +121,12 @@ static void intel_enable_lvds(struct intel_encoder *encoder)
121 * register description and PRM. 121 * register description and PRM.
122 */ 122 */
123 DRM_DEBUG_KMS("applying panel-fitter: %x, %x\n", 123 DRM_DEBUG_KMS("applying panel-fitter: %x, %x\n",
124 intel_lvds->pfit_control, 124 lvds_encoder->pfit_control,
125 intel_lvds->pfit_pgm_ratios); 125 lvds_encoder->pfit_pgm_ratios);
126 126
127 I915_WRITE(PFIT_PGM_RATIOS, intel_lvds->pfit_pgm_ratios); 127 I915_WRITE(PFIT_PGM_RATIOS, lvds_encoder->pfit_pgm_ratios);
128 I915_WRITE(PFIT_CONTROL, intel_lvds->pfit_control); 128 I915_WRITE(PFIT_CONTROL, lvds_encoder->pfit_control);
129 intel_lvds->pfit_dirty = false; 129 lvds_encoder->pfit_dirty = false;
130 } 130 }
131 131
132 I915_WRITE(ctl_reg, I915_READ(ctl_reg) | POWER_TARGET_ON); 132 I915_WRITE(ctl_reg, I915_READ(ctl_reg) | POWER_TARGET_ON);
@@ -140,7 +140,7 @@ static void intel_enable_lvds(struct intel_encoder *encoder)
140static void intel_disable_lvds(struct intel_encoder *encoder) 140static void intel_disable_lvds(struct intel_encoder *encoder)
141{ 141{
142 struct drm_device *dev = encoder->base.dev; 142 struct drm_device *dev = encoder->base.dev;
143 struct intel_lvds *intel_lvds = to_intel_lvds(&encoder->base); 143 struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
144 struct drm_i915_private *dev_priv = dev->dev_private; 144 struct drm_i915_private *dev_priv = dev->dev_private;
145 u32 ctl_reg, lvds_reg, stat_reg; 145 u32 ctl_reg, lvds_reg, stat_reg;
146 146
@@ -160,9 +160,9 @@ static void intel_disable_lvds(struct intel_encoder *encoder)
160 if (wait_for((I915_READ(stat_reg) & PP_ON) == 0, 1000)) 160 if (wait_for((I915_READ(stat_reg) & PP_ON) == 0, 1000))
161 DRM_ERROR("timed out waiting for panel to power off\n"); 161 DRM_ERROR("timed out waiting for panel to power off\n");
162 162
163 if (intel_lvds->pfit_control) { 163 if (lvds_encoder->pfit_control) {
164 I915_WRITE(PFIT_CONTROL, 0); 164 I915_WRITE(PFIT_CONTROL, 0);
165 intel_lvds->pfit_dirty = true; 165 lvds_encoder->pfit_dirty = true;
166 } 166 }
167 167
168 I915_WRITE(lvds_reg, I915_READ(lvds_reg) & ~LVDS_PORT_EN); 168 I915_WRITE(lvds_reg, I915_READ(lvds_reg) & ~LVDS_PORT_EN);
@@ -172,8 +172,8 @@ static void intel_disable_lvds(struct intel_encoder *encoder)
172static int intel_lvds_mode_valid(struct drm_connector *connector, 172static int intel_lvds_mode_valid(struct drm_connector *connector,
173 struct drm_display_mode *mode) 173 struct drm_display_mode *mode)
174{ 174{
175 struct intel_lvds *intel_lvds = intel_attached_lvds(connector); 175 struct intel_lvds_encoder *lvds_encoder = intel_attached_lvds(connector);
176 struct drm_display_mode *fixed_mode = intel_lvds->fixed_mode; 176 struct drm_display_mode *fixed_mode = lvds_encoder->fixed_mode;
177 177
178 if (mode->hdisplay > fixed_mode->hdisplay) 178 if (mode->hdisplay > fixed_mode->hdisplay)
179 return MODE_PANEL; 179 return MODE_PANEL;
@@ -249,8 +249,8 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
249{ 249{
250 struct drm_device *dev = encoder->dev; 250 struct drm_device *dev = encoder->dev;
251 struct drm_i915_private *dev_priv = dev->dev_private; 251 struct drm_i915_private *dev_priv = dev->dev_private;
252 struct intel_lvds *intel_lvds = to_intel_lvds(encoder); 252 struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(encoder);
253 struct intel_crtc *intel_crtc = intel_lvds->base.new_crtc; 253 struct intel_crtc *intel_crtc = lvds_encoder->base.new_crtc;
254 u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0; 254 u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0;
255 int pipe; 255 int pipe;
256 256
@@ -260,7 +260,7 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
260 return false; 260 return false;
261 } 261 }
262 262
263 if (intel_encoder_check_is_cloned(&intel_lvds->base)) 263 if (intel_encoder_check_is_cloned(&lvds_encoder->base))
264 return false; 264 return false;
265 265
266 /* 266 /*
@@ -269,10 +269,10 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
269 * with the panel scaling set up to source from the H/VDisplay 269 * with the panel scaling set up to source from the H/VDisplay
270 * of the original mode. 270 * of the original mode.
271 */ 271 */
272 intel_fixed_panel_mode(intel_lvds->fixed_mode, adjusted_mode); 272 intel_fixed_panel_mode(lvds_encoder->fixed_mode, adjusted_mode);
273 273
274 if (HAS_PCH_SPLIT(dev)) { 274 if (HAS_PCH_SPLIT(dev)) {
275 intel_pch_panel_fitting(dev, intel_lvds->fitting_mode, 275 intel_pch_panel_fitting(dev, lvds_encoder->fitting_mode,
276 mode, adjusted_mode); 276 mode, adjusted_mode);
277 return true; 277 return true;
278 } 278 }
@@ -298,7 +298,7 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
298 298
299 drm_mode_set_crtcinfo(adjusted_mode, 0); 299 drm_mode_set_crtcinfo(adjusted_mode, 0);
300 300
301 switch (intel_lvds->fitting_mode) { 301 switch (lvds_encoder->fitting_mode) {
302 case DRM_MODE_SCALE_CENTER: 302 case DRM_MODE_SCALE_CENTER:
303 /* 303 /*
304 * For centered modes, we have to calculate border widths & 304 * For centered modes, we have to calculate border widths &
@@ -396,11 +396,11 @@ out:
396 if (INTEL_INFO(dev)->gen < 4 && dev_priv->lvds_dither) 396 if (INTEL_INFO(dev)->gen < 4 && dev_priv->lvds_dither)
397 pfit_control |= PANEL_8TO6_DITHER_ENABLE; 397 pfit_control |= PANEL_8TO6_DITHER_ENABLE;
398 398
399 if (pfit_control != intel_lvds->pfit_control || 399 if (pfit_control != lvds_encoder->pfit_control ||
400 pfit_pgm_ratios != intel_lvds->pfit_pgm_ratios) { 400 pfit_pgm_ratios != lvds_encoder->pfit_pgm_ratios) {
401 intel_lvds->pfit_control = pfit_control; 401 lvds_encoder->pfit_control = pfit_control;
402 intel_lvds->pfit_pgm_ratios = pfit_pgm_ratios; 402 lvds_encoder->pfit_pgm_ratios = pfit_pgm_ratios;
403 intel_lvds->pfit_dirty = true; 403 lvds_encoder->pfit_dirty = true;
404 } 404 }
405 dev_priv->lvds_border_bits = border; 405 dev_priv->lvds_border_bits = border;
406 406
@@ -449,14 +449,14 @@ intel_lvds_detect(struct drm_connector *connector, bool force)
449 */ 449 */
450static int intel_lvds_get_modes(struct drm_connector *connector) 450static int intel_lvds_get_modes(struct drm_connector *connector)
451{ 451{
452 struct intel_lvds *intel_lvds = intel_attached_lvds(connector); 452 struct intel_lvds_encoder *lvds_encoder = intel_attached_lvds(connector);
453 struct drm_device *dev = connector->dev; 453 struct drm_device *dev = connector->dev;
454 struct drm_display_mode *mode; 454 struct drm_display_mode *mode;
455 455
456 if (intel_lvds->edid) 456 if (lvds_encoder->edid)
457 return drm_add_edid_modes(connector, intel_lvds->edid); 457 return drm_add_edid_modes(connector, lvds_encoder->edid);
458 458
459 mode = drm_mode_duplicate(dev, intel_lvds->fixed_mode); 459 mode = drm_mode_duplicate(dev, lvds_encoder->fixed_mode);
460 if (mode == NULL) 460 if (mode == NULL)
461 return 0; 461 return 0;
462 462
@@ -557,22 +557,22 @@ static int intel_lvds_set_property(struct drm_connector *connector,
557 struct drm_property *property, 557 struct drm_property *property,
558 uint64_t value) 558 uint64_t value)
559{ 559{
560 struct intel_lvds *intel_lvds = intel_attached_lvds(connector); 560 struct intel_lvds_encoder *lvds_encoder = intel_attached_lvds(connector);
561 struct drm_device *dev = connector->dev; 561 struct drm_device *dev = connector->dev;
562 562
563 if (property == dev->mode_config.scaling_mode_property) { 563 if (property == dev->mode_config.scaling_mode_property) {
564 struct drm_crtc *crtc = intel_lvds->base.base.crtc; 564 struct drm_crtc *crtc = lvds_encoder->base.base.crtc;
565 565
566 if (value == DRM_MODE_SCALE_NONE) { 566 if (value == DRM_MODE_SCALE_NONE) {
567 DRM_DEBUG_KMS("no scaling not supported\n"); 567 DRM_DEBUG_KMS("no scaling not supported\n");
568 return -EINVAL; 568 return -EINVAL;
569 } 569 }
570 570
571 if (intel_lvds->fitting_mode == value) { 571 if (lvds_encoder->fitting_mode == value) {
572 /* the LVDS scaling property is not changed */ 572 /* the LVDS scaling property is not changed */
573 return 0; 573 return 0;
574 } 574 }
575 intel_lvds->fitting_mode = value; 575 lvds_encoder->fitting_mode = value;
576 if (crtc && crtc->enabled) { 576 if (crtc && crtc->enabled) {
577 /* 577 /*
578 * If the CRTC is enabled, the display will be changed 578 * If the CRTC is enabled, the display will be changed
@@ -904,7 +904,7 @@ static bool intel_lvds_supported(struct drm_device *dev)
904bool intel_lvds_init(struct drm_device *dev) 904bool intel_lvds_init(struct drm_device *dev)
905{ 905{
906 struct drm_i915_private *dev_priv = dev->dev_private; 906 struct drm_i915_private *dev_priv = dev->dev_private;
907 struct intel_lvds *intel_lvds; 907 struct intel_lvds_encoder *lvds_encoder;
908 struct intel_encoder *intel_encoder; 908 struct intel_encoder *intel_encoder;
909 struct intel_connector *intel_connector; 909 struct intel_connector *intel_connector;
910 struct drm_connector *connector; 910 struct drm_connector *connector;
@@ -937,22 +937,21 @@ bool intel_lvds_init(struct drm_device *dev)
937 } 937 }
938 } 938 }
939 939
940 intel_lvds = kzalloc(sizeof(struct intel_lvds), GFP_KERNEL); 940 lvds_encoder = kzalloc(sizeof(struct intel_lvds_encoder), GFP_KERNEL);
941 if (!intel_lvds) { 941 if (!lvds_encoder)
942 return false; 942 return false;
943 }
944 943
945 intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); 944 intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
946 if (!intel_connector) { 945 if (!intel_connector) {
947 kfree(intel_lvds); 946 kfree(lvds_encoder);
948 return false; 947 return false;
949 } 948 }
950 949
951 if (!HAS_PCH_SPLIT(dev)) { 950 if (!HAS_PCH_SPLIT(dev)) {
952 intel_lvds->pfit_control = I915_READ(PFIT_CONTROL); 951 lvds_encoder->pfit_control = I915_READ(PFIT_CONTROL);
953 } 952 }
954 953
955 intel_encoder = &intel_lvds->base; 954 intel_encoder = &lvds_encoder->base;
956 encoder = &intel_encoder->base; 955 encoder = &intel_encoder->base;
957 connector = &intel_connector->base; 956 connector = &intel_connector->base;
958 drm_connector_init(dev, &intel_connector->base, &intel_lvds_connector_funcs, 957 drm_connector_init(dev, &intel_connector->base, &intel_lvds_connector_funcs,
@@ -992,7 +991,7 @@ bool intel_lvds_init(struct drm_device *dev)
992 drm_connector_attach_property(&intel_connector->base, 991 drm_connector_attach_property(&intel_connector->base,
993 dev->mode_config.scaling_mode_property, 992 dev->mode_config.scaling_mode_property,
994 DRM_MODE_SCALE_ASPECT); 993 DRM_MODE_SCALE_ASPECT);
995 intel_lvds->fitting_mode = DRM_MODE_SCALE_ASPECT; 994 lvds_encoder->fitting_mode = DRM_MODE_SCALE_ASPECT;
996 /* 995 /*
997 * LVDS discovery: 996 * LVDS discovery:
998 * 1) check for EDID on DDC 997 * 1) check for EDID on DDC
@@ -1007,20 +1006,18 @@ bool intel_lvds_init(struct drm_device *dev)
1007 * Attempt to get the fixed panel mode from DDC. Assume that the 1006 * Attempt to get the fixed panel mode from DDC. Assume that the
1008 * preferred mode is the right one. 1007 * preferred mode is the right one.
1009 */ 1008 */
1010 intel_lvds->edid = drm_get_edid(connector, 1009 lvds_encoder->edid = drm_get_edid(connector,
1011 intel_gmbus_get_adapter(dev_priv, 1010 intel_gmbus_get_adapter(dev_priv, pin));
1012 pin)); 1011 if (lvds_encoder->edid) {
1013 if (intel_lvds->edid) { 1012 if (drm_add_edid_modes(connector, lvds_encoder->edid)) {
1014 if (drm_add_edid_modes(connector,
1015 intel_lvds->edid)) {
1016 drm_mode_connector_update_edid_property(connector, 1013 drm_mode_connector_update_edid_property(connector,
1017 intel_lvds->edid); 1014 lvds_encoder->edid);
1018 } else { 1015 } else {
1019 kfree(intel_lvds->edid); 1016 kfree(lvds_encoder->edid);
1020 intel_lvds->edid = NULL; 1017 lvds_encoder->edid = NULL;
1021 } 1018 }
1022 } 1019 }
1023 if (!intel_lvds->edid) { 1020 if (!lvds_encoder->edid) {
1024 /* Didn't get an EDID, so 1021 /* Didn't get an EDID, so
1025 * Set wide sync ranges so we get all modes 1022 * Set wide sync ranges so we get all modes
1026 * handed to valid_mode for checking 1023 * handed to valid_mode for checking
@@ -1033,10 +1030,8 @@ bool intel_lvds_init(struct drm_device *dev)
1033 1030
1034 list_for_each_entry(scan, &connector->probed_modes, head) { 1031 list_for_each_entry(scan, &connector->probed_modes, head) {
1035 if (scan->type & DRM_MODE_TYPE_PREFERRED) { 1032 if (scan->type & DRM_MODE_TYPE_PREFERRED) {
1036 intel_lvds->fixed_mode = 1033 lvds_encoder->fixed_mode = drm_mode_duplicate(dev, scan);
1037 drm_mode_duplicate(dev, scan); 1034 intel_find_lvds_downclock(dev, lvds_encoder->fixed_mode,
1038 intel_find_lvds_downclock(dev,
1039 intel_lvds->fixed_mode,
1040 connector); 1035 connector);
1041 goto out; 1036 goto out;
1042 } 1037 }
@@ -1044,11 +1039,10 @@ bool intel_lvds_init(struct drm_device *dev)
1044 1039
1045 /* Failed to get EDID, what about VBT? */ 1040 /* Failed to get EDID, what about VBT? */
1046 if (dev_priv->lfp_lvds_vbt_mode) { 1041 if (dev_priv->lfp_lvds_vbt_mode) {
1047 intel_lvds->fixed_mode = 1042 lvds_encoder->fixed_mode =
1048 drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode); 1043 drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode);
1049 if (intel_lvds->fixed_mode) { 1044 if (lvds_encoder->fixed_mode) {
1050 intel_lvds->fixed_mode->type |= 1045 lvds_encoder->fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
1051 DRM_MODE_TYPE_PREFERRED;
1052 goto out; 1046 goto out;
1053 } 1047 }
1054 } 1048 }
@@ -1068,16 +1062,15 @@ bool intel_lvds_init(struct drm_device *dev)
1068 crtc = intel_get_crtc_for_pipe(dev, pipe); 1062 crtc = intel_get_crtc_for_pipe(dev, pipe);
1069 1063
1070 if (crtc && (lvds & LVDS_PORT_EN)) { 1064 if (crtc && (lvds & LVDS_PORT_EN)) {
1071 intel_lvds->fixed_mode = intel_crtc_mode_get(dev, crtc); 1065 lvds_encoder->fixed_mode = intel_crtc_mode_get(dev, crtc);
1072 if (intel_lvds->fixed_mode) { 1066 if (lvds_encoder->fixed_mode) {
1073 intel_lvds->fixed_mode->type |= 1067 lvds_encoder->fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
1074 DRM_MODE_TYPE_PREFERRED;
1075 goto out; 1068 goto out;
1076 } 1069 }
1077 } 1070 }
1078 1071
1079 /* If we still don't have a mode after all that, give up. */ 1072 /* If we still don't have a mode after all that, give up. */
1080 if (!intel_lvds->fixed_mode) 1073 if (!lvds_encoder->fixed_mode)
1081 goto failed; 1074 goto failed;
1082 1075
1083out: 1076out:
@@ -1109,7 +1102,7 @@ failed:
1109 DRM_DEBUG_KMS("No LVDS modes found, disabling.\n"); 1102 DRM_DEBUG_KMS("No LVDS modes found, disabling.\n");
1110 drm_connector_cleanup(connector); 1103 drm_connector_cleanup(connector);
1111 drm_encoder_cleanup(encoder); 1104 drm_encoder_cleanup(encoder);
1112 kfree(intel_lvds); 1105 kfree(lvds_encoder);
1113 kfree(intel_connector); 1106 kfree(intel_connector);
1114 return false; 1107 return false;
1115} 1108}