diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-09-11 08:12:25 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-11-29 06:42:58 -0500 |
commit | 7dec060675125f17a547950d715018a63131a437 (patch) | |
tree | b2d3a77048281cc060f0fb33310693a8d2c5f992 /drivers/gpu/drm/i915/intel_lvds.c | |
parent | 13c7d8703127334890c894ddab13b3a92a26580a (diff) |
drm/i915: add intel_lvds->reg
To ditch at least some of the PCH_SPLIT ? PCH_LVDS : LVDS code ...
v2: Rebase on top of Jani Nikula's panel rework.
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
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.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c index 31fdbfd48e44..6b6ed642b29f 100644 --- a/drivers/gpu/drm/i915/intel_lvds.c +++ b/drivers/gpu/drm/i915/intel_lvds.c | |||
@@ -53,6 +53,7 @@ struct intel_lvds_encoder { | |||
53 | u32 pfit_pgm_ratios; | 53 | u32 pfit_pgm_ratios; |
54 | bool pfit_dirty; | 54 | bool pfit_dirty; |
55 | bool is_dual_link; | 55 | bool is_dual_link; |
56 | u32 reg; | ||
56 | 57 | ||
57 | struct intel_lvds_connector *attached_connector; | 58 | struct intel_lvds_connector *attached_connector; |
58 | }; | 59 | }; |
@@ -72,15 +73,10 @@ static bool intel_lvds_get_hw_state(struct intel_encoder *encoder, | |||
72 | { | 73 | { |
73 | struct drm_device *dev = encoder->base.dev; | 74 | struct drm_device *dev = encoder->base.dev; |
74 | struct drm_i915_private *dev_priv = dev->dev_private; | 75 | struct drm_i915_private *dev_priv = dev->dev_private; |
75 | u32 lvds_reg, tmp; | 76 | struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base); |
76 | 77 | u32 tmp; | |
77 | if (HAS_PCH_SPLIT(dev)) { | ||
78 | lvds_reg = PCH_LVDS; | ||
79 | } else { | ||
80 | lvds_reg = LVDS; | ||
81 | } | ||
82 | 78 | ||
83 | tmp = I915_READ(lvds_reg); | 79 | tmp = I915_READ(lvds_encoder->reg); |
84 | 80 | ||
85 | if (!(tmp & LVDS_PORT_EN)) | 81 | if (!(tmp & LVDS_PORT_EN)) |
86 | return false; | 82 | return false; |
@@ -102,19 +98,17 @@ static void intel_enable_lvds(struct intel_encoder *encoder) | |||
102 | struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base); | 98 | struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base); |
103 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); | 99 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); |
104 | struct drm_i915_private *dev_priv = dev->dev_private; | 100 | struct drm_i915_private *dev_priv = dev->dev_private; |
105 | u32 ctl_reg, lvds_reg, stat_reg; | 101 | u32 ctl_reg, stat_reg; |
106 | 102 | ||
107 | if (HAS_PCH_SPLIT(dev)) { | 103 | if (HAS_PCH_SPLIT(dev)) { |
108 | ctl_reg = PCH_PP_CONTROL; | 104 | ctl_reg = PCH_PP_CONTROL; |
109 | lvds_reg = PCH_LVDS; | ||
110 | stat_reg = PCH_PP_STATUS; | 105 | stat_reg = PCH_PP_STATUS; |
111 | } else { | 106 | } else { |
112 | ctl_reg = PP_CONTROL; | 107 | ctl_reg = PP_CONTROL; |
113 | lvds_reg = LVDS; | ||
114 | stat_reg = PP_STATUS; | 108 | stat_reg = PP_STATUS; |
115 | } | 109 | } |
116 | 110 | ||
117 | I915_WRITE(lvds_reg, I915_READ(lvds_reg) | LVDS_PORT_EN); | 111 | I915_WRITE(lvds_encoder->reg, I915_READ(lvds_encoder->reg) | LVDS_PORT_EN); |
118 | 112 | ||
119 | if (lvds_encoder->pfit_dirty) { | 113 | if (lvds_encoder->pfit_dirty) { |
120 | /* | 114 | /* |
@@ -133,7 +127,7 @@ static void intel_enable_lvds(struct intel_encoder *encoder) | |||
133 | } | 127 | } |
134 | 128 | ||
135 | I915_WRITE(ctl_reg, I915_READ(ctl_reg) | POWER_TARGET_ON); | 129 | I915_WRITE(ctl_reg, I915_READ(ctl_reg) | POWER_TARGET_ON); |
136 | POSTING_READ(lvds_reg); | 130 | POSTING_READ(lvds_encoder->reg); |
137 | if (wait_for((I915_READ(stat_reg) & PP_ON) != 0, 1000)) | 131 | if (wait_for((I915_READ(stat_reg) & PP_ON) != 0, 1000)) |
138 | DRM_ERROR("timed out waiting for panel to power on\n"); | 132 | DRM_ERROR("timed out waiting for panel to power on\n"); |
139 | 133 | ||
@@ -145,15 +139,13 @@ static void intel_disable_lvds(struct intel_encoder *encoder) | |||
145 | struct drm_device *dev = encoder->base.dev; | 139 | struct drm_device *dev = encoder->base.dev; |
146 | struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base); | 140 | struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base); |
147 | struct drm_i915_private *dev_priv = dev->dev_private; | 141 | struct drm_i915_private *dev_priv = dev->dev_private; |
148 | u32 ctl_reg, lvds_reg, stat_reg; | 142 | u32 ctl_reg, stat_reg; |
149 | 143 | ||
150 | if (HAS_PCH_SPLIT(dev)) { | 144 | if (HAS_PCH_SPLIT(dev)) { |
151 | ctl_reg = PCH_PP_CONTROL; | 145 | ctl_reg = PCH_PP_CONTROL; |
152 | lvds_reg = PCH_LVDS; | ||
153 | stat_reg = PCH_PP_STATUS; | 146 | stat_reg = PCH_PP_STATUS; |
154 | } else { | 147 | } else { |
155 | ctl_reg = PP_CONTROL; | 148 | ctl_reg = PP_CONTROL; |
156 | lvds_reg = LVDS; | ||
157 | stat_reg = PP_STATUS; | 149 | stat_reg = PP_STATUS; |
158 | } | 150 | } |
159 | 151 | ||
@@ -168,8 +160,8 @@ static void intel_disable_lvds(struct intel_encoder *encoder) | |||
168 | lvds_encoder->pfit_dirty = true; | 160 | lvds_encoder->pfit_dirty = true; |
169 | } | 161 | } |
170 | 162 | ||
171 | I915_WRITE(lvds_reg, I915_READ(lvds_reg) & ~LVDS_PORT_EN); | 163 | I915_WRITE(lvds_encoder->reg, I915_READ(lvds_encoder->reg) & ~LVDS_PORT_EN); |
172 | POSTING_READ(lvds_reg); | 164 | POSTING_READ(lvds_encoder->reg); |
173 | } | 165 | } |
174 | 166 | ||
175 | static int intel_lvds_mode_valid(struct drm_connector *connector, | 167 | static int intel_lvds_mode_valid(struct drm_connector *connector, |
@@ -939,17 +931,11 @@ bool intel_is_dual_link_lvds(struct drm_device *dev) | |||
939 | return false; | 931 | return false; |
940 | } | 932 | } |
941 | 933 | ||
942 | static bool compute_is_dual_link_lvds(struct drm_device *dev) | 934 | static bool compute_is_dual_link_lvds(struct intel_lvds_encoder *lvds_encoder) |
943 | { | 935 | { |
936 | struct drm_device *dev = lvds_encoder->base.base.dev; | ||
944 | unsigned int val; | 937 | unsigned int val; |
945 | struct drm_i915_private *dev_priv = dev->dev_private; | 938 | struct drm_i915_private *dev_priv = dev->dev_private; |
946 | u32 lvds_reg; | ||
947 | |||
948 | if (HAS_PCH_SPLIT(dev)) { | ||
949 | lvds_reg = PCH_LVDS; | ||
950 | } else { | ||
951 | lvds_reg = LVDS; | ||
952 | } | ||
953 | 939 | ||
954 | /* use the module option value if specified */ | 940 | /* use the module option value if specified */ |
955 | if (i915_lvds_channel_mode > 0) | 941 | if (i915_lvds_channel_mode > 0) |
@@ -963,7 +949,7 @@ static bool compute_is_dual_link_lvds(struct drm_device *dev) | |||
963 | * we need to check "the value to be set" in VBT when LVDS | 949 | * we need to check "the value to be set" in VBT when LVDS |
964 | * register is uninitialized. | 950 | * register is uninitialized. |
965 | */ | 951 | */ |
966 | val = I915_READ(lvds_reg); | 952 | val = I915_READ(lvds_encoder->reg); |
967 | if (!(val & ~(LVDS_PIPE_MASK | LVDS_DETECTED))) | 953 | if (!(val & ~(LVDS_PIPE_MASK | LVDS_DETECTED))) |
968 | val = dev_priv->bios_lvds_val; | 954 | val = dev_priv->bios_lvds_val; |
969 | 955 | ||
@@ -1076,6 +1062,12 @@ bool intel_lvds_init(struct drm_device *dev) | |||
1076 | connector->interlace_allowed = false; | 1062 | connector->interlace_allowed = false; |
1077 | connector->doublescan_allowed = false; | 1063 | connector->doublescan_allowed = false; |
1078 | 1064 | ||
1065 | if (HAS_PCH_SPLIT(dev)) { | ||
1066 | lvds_encoder->reg = PCH_LVDS; | ||
1067 | } else { | ||
1068 | lvds_encoder->reg = LVDS; | ||
1069 | } | ||
1070 | |||
1079 | /* create the scaling mode property */ | 1071 | /* create the scaling mode property */ |
1080 | drm_mode_create_scaling_mode_property(dev); | 1072 | drm_mode_create_scaling_mode_property(dev); |
1081 | drm_object_attach_property(&connector->base, | 1073 | drm_object_attach_property(&connector->base, |
@@ -1176,7 +1168,7 @@ bool intel_lvds_init(struct drm_device *dev) | |||
1176 | goto failed; | 1168 | goto failed; |
1177 | 1169 | ||
1178 | out: | 1170 | out: |
1179 | lvds_encoder->is_dual_link = compute_is_dual_link_lvds(dev); | 1171 | lvds_encoder->is_dual_link = compute_is_dual_link_lvds(lvds_encoder); |
1180 | DRM_DEBUG_KMS("detected %s-link lvds configuration\n", | 1172 | DRM_DEBUG_KMS("detected %s-link lvds configuration\n", |
1181 | lvds_encoder->is_dual_link ? "dual" : "single"); | 1173 | lvds_encoder->is_dual_link ? "dual" : "single"); |
1182 | 1174 | ||