OLD | NEW |
1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "power_manager/backlight_controller.h" | 5 #include "power_manager/backlight_controller.h" |
6 | 6 |
7 #include <gdk/gdkx.h> | 7 #include <gdk/gdkx.h> |
8 #include <math.h> | 8 #include <math.h> |
9 #include <X11/extensions/dpms.h> | 9 #include <X11/extensions/dpms.h> |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 SetPowerState(BACKLIGHT_ACTIVE_OFF); | 121 SetPowerState(BACKLIGHT_ACTIVE_OFF); |
122 // Allow large swing in brightness_offset for absolute brightness | 122 // Allow large swing in brightness_offset for absolute brightness |
123 // outside of clamped brightness region. | 123 // outside of clamped brightness region. |
124 int64 absolute_brightness = als_brightness_level_ + *brightness_offset_; | 124 int64 absolute_brightness = als_brightness_level_ + *brightness_offset_; |
125 *brightness_offset_ += new_brightness - absolute_brightness; | 125 *brightness_offset_ += new_brightness - absolute_brightness; |
126 WriteBrightness(); | 126 WriteBrightness(); |
127 } | 127 } |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 | |
132 bool BacklightController::SetPowerState(PowerState state) { | 131 bool BacklightController::SetPowerState(PowerState state) { |
133 if (state == state_ || !is_initialized_) | 132 if (state == state_ || !is_initialized_) |
134 return false; | 133 return false; |
135 CHECK(state != BACKLIGHT_UNINITIALIZED); | 134 CHECK(state != BACKLIGHT_UNINITIALIZED); |
136 | 135 |
| 136 // If backlight is turned off, do not transition to dim or off states. |
| 137 // From ACTIVE_OFF state only transition to ACTIVE_ON and SUSPEND states. |
| 138 if (state_ == BACKLIGHT_ACTIVE_OFF && (state == BACKLIGHT_IDLE_OFF || |
| 139 state == BACKLIGHT_DIM)) |
| 140 return false; |
| 141 |
137 LOG(INFO) << PowerStateToString(state_) << " -> " | 142 LOG(INFO) << PowerStateToString(state_) << " -> " |
138 << PowerStateToString(state); | 143 << PowerStateToString(state); |
139 ReadBrightness(); | 144 ReadBrightness(); |
140 state_ = state; | 145 state_ = state; |
141 bool changed_brightness = WriteBrightness(); | 146 bool changed_brightness = WriteBrightness(); |
142 | 147 |
143 if (light_sensor_) | 148 if (light_sensor_) |
144 light_sensor_->EnableOrDisableSensor(state_); | 149 light_sensor_->EnableOrDisableSensor(state_); |
145 | 150 |
146 if (GDK_DISPLAY() == NULL) | 151 if (GDK_DISPLAY() == NULL) |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 WritePrefs(); | 304 WritePrefs(); |
300 } | 305 } |
301 | 306 |
302 void BacklightController::TurnScreenOff() { | 307 void BacklightController::TurnScreenOff() { |
303 if (state_ == BACKLIGHT_IDLE_OFF && GDK_DISPLAY() != NULL) | 308 if (state_ == BACKLIGHT_IDLE_OFF && GDK_DISPLAY() != NULL) |
304 CHECK(DPMSForceLevel(GDK_DISPLAY(), DPMSModeOff)); | 309 CHECK(DPMSForceLevel(GDK_DISPLAY(), DPMSModeOff)); |
305 } | 310 } |
306 | 311 |
307 | 312 |
308 } // namespace power_manager | 313 } // namespace power_manager |
OLD | NEW |