From 909fe21ac369409e445fc4e82ab943f5c2725a2f Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Fri, 7 Dec 2012 15:32:45 +0200 Subject: [PATCH] drm/i915: set the BIOS current backlight level Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Cc: Jani Nikula With hopes that this might improve driver <-> BIOS co-operation. Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/intel_opregion.c | 19 +++++++++++++++++-- drivers/gpu/drm/i915/intel_panel.c | 4 ++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 2ab476d..8dd74c1 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1683,12 +1683,14 @@ extern void intel_opregion_fini(struct drm_device *dev); extern void intel_opregion_asle_intr(struct drm_device *dev); extern void intel_opregion_gse_intr(struct drm_device *dev); extern void intel_opregion_enable_asle(struct drm_device *dev); +extern void intel_opregion_asle_set_cblv(struct drm_device *dev, u32 level, u32 max); #else static inline void intel_opregion_init(struct drm_device *dev) { return; } static inline void intel_opregion_fini(struct drm_device *dev) { return; } static inline void intel_opregion_asle_intr(struct drm_device *dev) { return; } static inline void intel_opregion_gse_intr(struct drm_device *dev) { return; } static inline void intel_opregion_enable_asle(struct drm_device *dev) { return; } +static inline void intel_opregion_asle_set_cblv(struct drm_device *dev, u32 level, u32 max) { return; } #endif /* intel_acpi.c */ diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c index 7741c22..2b86bb3 100644 --- a/drivers/gpu/drm/i915/intel_opregion.c +++ b/drivers/gpu/drm/i915/intel_opregion.c @@ -148,10 +148,26 @@ struct opregion_asle { #define ACPI_LVDS_OUTPUT (4<<8) #ifdef CONFIG_ACPI -static u32 asle_set_backlight(struct drm_device *dev, u32 bclp) + +void intel_opregion_asle_set_cblv(struct drm_device *dev, u32 level, u32 max) { struct drm_i915_private *dev_priv = dev->dev_private; struct opregion_asle __iomem *asle = dev_priv->opregion.asle; + + if (!dev_priv->opregion.header || !asle) + return; + + if (level > max) + level = max; + + /* scale to 0...100 */ + level = level * 100 / max; + + iowrite32(level | ASLE_CBLV_VALID, &asle->cblv); +} + +static u32 asle_set_backlight(struct drm_device *dev, u32 bclp) +{ u32 max; DRM_DEBUG_DRIVER("bclp = 0x%08x\n", bclp); @@ -165,7 +181,6 @@ static u32 asle_set_backlight(struct drm_device *dev, u32 bclp) max = intel_panel_get_max_backlight(dev); intel_panel_set_backlight(dev, bclp * max / 255); - iowrite32((bclp*0x64)/0xff | ASLE_CBLV_VALID, &asle->cblv); return 0; } diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index c758ad2..1eff8e0 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c @@ -285,6 +285,10 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level) { struct drm_i915_private *dev_priv = dev->dev_private; + /* set brightness reference value for bios */ + intel_opregion_asle_set_cblv(dev, level, + intel_panel_get_max_backlight(dev)); + dev_priv->backlight_level = level; if (dev_priv->backlight_enabled) intel_panel_actually_set_backlight(dev, level); -- 1.7.9.5