diff options
author | Jani Nikula <jani.nikula@intel.com> | 2014-08-13 05:10:12 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-09-03 04:54:18 -0400 |
commit | ab656bb9012b9eabc21234caa47af478ea6ceec5 (patch) | |
tree | 764f3234093276529ebf52bf700da08860103f2a /drivers/gpu | |
parent | 1250d107cf9b82217a63520b0b76a947665537c2 (diff) |
drm/i915: add some framework for backlight bl_power support
Make backlight class sysfs bl_power a sub-state of backlight enabled, if
a backlight power connector callback is defined. It's up to the
connector callback to handle the sub-state, typically in a way that
respects panel power sequencing.
v2: Post the version that does not oops. *facepalm*.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed_by: Clinton Taylor <Clinton.A.Taylor@intel.com>
Tested_by: Clinton Taylor <Clinton.A.Taylor@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/i915/intel_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_panel.c | 26 |
2 files changed, 28 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 2466b2bc9099..a35d8a22bf87 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
@@ -179,6 +179,8 @@ struct intel_panel { | |||
179 | bool active_low_pwm; | 179 | bool active_low_pwm; |
180 | struct backlight_device *device; | 180 | struct backlight_device *device; |
181 | } backlight; | 181 | } backlight; |
182 | |||
183 | void (*backlight_power)(struct intel_connector *, bool enable); | ||
182 | }; | 184 | }; |
183 | 185 | ||
184 | struct intel_connector { | 186 | struct intel_connector { |
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index 59b028f0b1e8..af5435634929 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c | |||
@@ -751,6 +751,8 @@ void intel_panel_disable_backlight(struct intel_connector *connector) | |||
751 | 751 | ||
752 | spin_lock_irqsave(&dev_priv->backlight_lock, flags); | 752 | spin_lock_irqsave(&dev_priv->backlight_lock, flags); |
753 | 753 | ||
754 | if (panel->backlight.device) | ||
755 | panel->backlight.device->props.power = FB_BLANK_POWERDOWN; | ||
754 | panel->backlight.enabled = false; | 756 | panel->backlight.enabled = false; |
755 | dev_priv->display.disable_backlight(connector); | 757 | dev_priv->display.disable_backlight(connector); |
756 | 758 | ||
@@ -957,6 +959,8 @@ void intel_panel_enable_backlight(struct intel_connector *connector) | |||
957 | 959 | ||
958 | dev_priv->display.enable_backlight(connector); | 960 | dev_priv->display.enable_backlight(connector); |
959 | panel->backlight.enabled = true; | 961 | panel->backlight.enabled = true; |
962 | if (panel->backlight.device) | ||
963 | panel->backlight.device->props.power = FB_BLANK_UNBLANK; | ||
960 | 964 | ||
961 | spin_unlock_irqrestore(&dev_priv->backlight_lock, flags); | 965 | spin_unlock_irqrestore(&dev_priv->backlight_lock, flags); |
962 | } | 966 | } |
@@ -965,6 +969,7 @@ void intel_panel_enable_backlight(struct intel_connector *connector) | |||
965 | static int intel_backlight_device_update_status(struct backlight_device *bd) | 969 | static int intel_backlight_device_update_status(struct backlight_device *bd) |
966 | { | 970 | { |
967 | struct intel_connector *connector = bl_get_data(bd); | 971 | struct intel_connector *connector = bl_get_data(bd); |
972 | struct intel_panel *panel = &connector->panel; | ||
968 | struct drm_device *dev = connector->base.dev; | 973 | struct drm_device *dev = connector->base.dev; |
969 | 974 | ||
970 | drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); | 975 | drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); |
@@ -972,6 +977,22 @@ static int intel_backlight_device_update_status(struct backlight_device *bd) | |||
972 | bd->props.brightness, bd->props.max_brightness); | 977 | bd->props.brightness, bd->props.max_brightness); |
973 | intel_panel_set_backlight(connector, bd->props.brightness, | 978 | intel_panel_set_backlight(connector, bd->props.brightness, |
974 | bd->props.max_brightness); | 979 | bd->props.max_brightness); |
980 | |||
981 | /* | ||
982 | * Allow flipping bl_power as a sub-state of enabled. Sadly the | ||
983 | * backlight class device does not make it easy to to differentiate | ||
984 | * between callbacks for brightness and bl_power, so our backlight_power | ||
985 | * callback needs to take this into account. | ||
986 | */ | ||
987 | if (panel->backlight.enabled) { | ||
988 | if (panel->backlight_power) { | ||
989 | bool enable = bd->props.power == FB_BLANK_UNBLANK; | ||
990 | panel->backlight_power(connector, enable); | ||
991 | } | ||
992 | } else { | ||
993 | bd->props.power = FB_BLANK_POWERDOWN; | ||
994 | } | ||
995 | |||
975 | drm_modeset_unlock(&dev->mode_config.connection_mutex); | 996 | drm_modeset_unlock(&dev->mode_config.connection_mutex); |
976 | return 0; | 997 | return 0; |
977 | } | 998 | } |
@@ -1023,6 +1044,11 @@ static int intel_backlight_device_register(struct intel_connector *connector) | |||
1023 | panel->backlight.level, | 1044 | panel->backlight.level, |
1024 | props.max_brightness); | 1045 | props.max_brightness); |
1025 | 1046 | ||
1047 | if (panel->backlight.enabled) | ||
1048 | props.power = FB_BLANK_UNBLANK; | ||
1049 | else | ||
1050 | props.power = FB_BLANK_POWERDOWN; | ||
1051 | |||
1026 | /* | 1052 | /* |
1027 | * Note: using the same name independent of the connector prevents | 1053 | * Note: using the same name independent of the connector prevents |
1028 | * registration of multiple backlight devices in the driver. | 1054 | * registration of multiple backlight devices in the driver. |