aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2012-09-03 09:25:12 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2012-09-03 14:42:10 -0400
commit28dcc2d60cb570d9f549c329b2f51400553412a1 (patch)
treeec327dfe215656bd0aa84afe64967248a85ecd8c /drivers/gpu
parentfcbc50da7753b210b4442ca9abc4efbd4e481f6e (diff)
drm/i915: do not expose a dysfunctional backlight interface to userspace
Previously intel_panel_setup_backlight() would create a sysfs backlight interface with max brightness of 1 if it was unable to figure out the max backlight brightness. This rendered the backlight interface useless. Do not create a dysfunctional backlight interface to begin with. Signed-off-by: Jani Nikula <jani.nikula@intel.com> Tested-by: David Woodhouse <David.Woodhouse@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 3df4f5fa892a..e019b2369861 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -162,19 +162,12 @@ static u32 i915_read_blc_pwm_ctl(struct drm_i915_private *dev_priv)
162 return val; 162 return val;
163} 163}
164 164
165u32 intel_panel_get_max_backlight(struct drm_device *dev) 165static u32 _intel_panel_get_max_backlight(struct drm_device *dev)
166{ 166{
167 struct drm_i915_private *dev_priv = dev->dev_private; 167 struct drm_i915_private *dev_priv = dev->dev_private;
168 u32 max; 168 u32 max;
169 169
170 max = i915_read_blc_pwm_ctl(dev_priv); 170 max = i915_read_blc_pwm_ctl(dev_priv);
171 if (max == 0) {
172 /* XXX add code here to query mode clock or hardware clock
173 * and program max PWM appropriately.
174 */
175 pr_warn_once("fixme: max PWM is zero\n");
176 return 1;
177 }
178 171
179 if (HAS_PCH_SPLIT(dev)) { 172 if (HAS_PCH_SPLIT(dev)) {
180 max >>= 16; 173 max >>= 16;
@@ -188,6 +181,22 @@ u32 intel_panel_get_max_backlight(struct drm_device *dev)
188 max *= 0xff; 181 max *= 0xff;
189 } 182 }
190 183
184 return max;
185}
186
187u32 intel_panel_get_max_backlight(struct drm_device *dev)
188{
189 u32 max;
190
191 max = _intel_panel_get_max_backlight(dev);
192 if (max == 0) {
193 /* XXX add code here to query mode clock or hardware clock
194 * and program max PWM appropriately.
195 */
196 pr_warn_once("fixme: max PWM is zero\n");
197 return 1;
198 }
199
191 DRM_DEBUG_DRIVER("max backlight PWM = %d\n", max); 200 DRM_DEBUG_DRIVER("max backlight PWM = %d\n", max);
192 return max; 201 return max;
193} 202}
@@ -424,7 +433,11 @@ int intel_panel_setup_backlight(struct drm_device *dev)
424 433
425 memset(&props, 0, sizeof(props)); 434 memset(&props, 0, sizeof(props));
426 props.type = BACKLIGHT_RAW; 435 props.type = BACKLIGHT_RAW;
427 props.max_brightness = intel_panel_get_max_backlight(dev); 436 props.max_brightness = _intel_panel_get_max_backlight(dev);
437 if (props.max_brightness == 0) {
438 DRM_ERROR("Failed to get maximum backlight value\n");
439 return -ENODEV;
440 }
428 dev_priv->backlight = 441 dev_priv->backlight =
429 backlight_device_register("intel_backlight", 442 backlight_device_register("intel_backlight",
430 &connector->kdev, dev, 443 &connector->kdev, dev,