OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef POWER_MANAGER_BACKLIGHT_CONTROLLER_H_ | 5 #ifndef POWER_MANAGER_BACKLIGHT_CONTROLLER_H_ |
6 #define POWER_MANAGER_BACKLIGHT_CONTROLLER_H_ | 6 #define POWER_MANAGER_BACKLIGHT_CONTROLLER_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "power_manager/backlight_interface.h" | 10 #include "power_manager/backlight_interface.h" |
11 #include "power_manager/power_prefs_interface.h" | 11 #include "power_manager/power_prefs_interface.h" |
12 #include "power_manager/xidle_monitor.h" | 12 #include "power_manager/xidle_monitor.h" |
13 | 13 |
14 namespace power_manager { | 14 namespace power_manager { |
15 | 15 |
16 enum DimState { | 16 enum DimState { |
17 BACKLIGHT_ACTIVE, BACKLIGHT_DIM | 17 BACKLIGHT_ACTIVE, BACKLIGHT_DIM |
18 }; | 18 }; |
19 | 19 |
20 enum PowerState { | 20 enum PowerState { |
21 BACKLIGHT_OFF, BACKLIGHT_ON | 21 BACKLIGHT_OFF, BACKLIGHT_ON |
22 }; | 22 }; |
23 | 23 |
24 // Control the backlight. | 24 // Control the backlight. |
25 class BacklightController { | 25 class BacklightController { |
26 public: | 26 public: |
27 explicit BacklightController(BacklightInterface* backlight, | 27 explicit BacklightController(BacklightInterface* backlight, |
28 PowerPrefsInterface *prefs); | 28 PowerPrefsInterface* prefs); |
29 virtual ~BacklightController() {} | 29 virtual ~BacklightController() {} |
30 | 30 |
31 // Initialize the object. | 31 // Initialize the object. |
32 bool Init(); | 32 bool Init(); |
33 | 33 |
34 // Set |level| to the current brightness level of the backlight as a | 34 // Set |level| to the current brightness level of the backlight as a |
35 // percentage. | 35 // percentage. |
36 void GetBrightness(int64* level); | 36 void GetBrightness(int64* level); |
37 | 37 |
38 // Increase / decrease brightness by specified offset. | 38 // Increase / decrease brightness by specified offset. |
(...skipping 11 matching lines...) Expand all Loading... | |
50 | 50 |
51 // Read brightness settings from the system and apply any changes made | 51 // Read brightness settings from the system and apply any changes made |
52 // by other programs to our local view. | 52 // by other programs to our local view. |
53 int64 ReadBrightness(); | 53 int64 ReadBrightness(); |
54 | 54 |
55 // Write brightness based on current settings. Returns new brightness level. | 55 // Write brightness based on current settings. Returns new brightness level. |
56 int64 WriteBrightness(); | 56 int64 WriteBrightness(); |
57 | 57 |
58 void set_als_brightness_level(int64 level) { als_brightness_level_ = level; } | 58 void set_als_brightness_level(int64 level) { als_brightness_level_ = level; } |
59 | 59 |
60 int64 plugged_brightness_offset() { return plugged_brightness_offset_; } | 60 int64 plugged_brightness_offset() { return plugged_brightness_offset_; } |
tfarina
2010/06/05 01:10:26
I really would like to make this and the below get
| |
61 void set_plugged_brightness_offset(int64 offset) { | 61 void set_plugged_brightness_offset(int64 offset) { |
62 plugged_brightness_offset_ = offset; | 62 plugged_brightness_offset_ = offset; |
63 } | 63 } |
64 | 64 |
65 int64 unplugged_brightness_offset() { return unplugged_brightness_offset_; } | 65 int64 unplugged_brightness_offset() { return unplugged_brightness_offset_; } |
66 void set_unplugged_brightness_offset(int64 offset) { | 66 void set_unplugged_brightness_offset(int64 offset) { |
67 unplugged_brightness_offset_ = offset; | 67 unplugged_brightness_offset_ = offset; |
68 } | 68 } |
69 | 69 |
70 private: | 70 private: |
71 // Clamp |x| to fit between 0 and 100. | 71 // Clamp |x| to fit between 0 and 100. |
72 int64 clamp(int64 x) { return std::min(100LL, std::max(0LL, x)); } | 72 int64 clamp(int64 x) { return std::min(100LL, std::max(0LL, x)); } |
tfarina
2010/06/05 01:08:56
In a follow up patch, maybe could we rename this t
| |
73 | 73 |
74 void ReadPrefs(); | 74 void ReadPrefs(); |
75 void WritePrefs(); | 75 void WritePrefs(); |
76 | 76 |
77 // Backlight used for dimming. Non-owned. | 77 // Backlight used for dimming. Non-owned. |
78 BacklightInterface* backlight_; | 78 BacklightInterface* backlight_; |
79 | 79 |
80 // Interface for saving preferences. Non-owned. | 80 // Interface for saving preferences. Non-owned. |
81 PowerPrefsInterface* prefs_; | 81 PowerPrefsInterface* prefs_; |
82 | 82 |
(...skipping 19 matching lines...) Expand all Loading... | |
102 // Min and max brightness for backlight object. | 102 // Min and max brightness for backlight object. |
103 int64 min_; | 103 int64 min_; |
104 int64 max_; | 104 int64 max_; |
105 | 105 |
106 DISALLOW_COPY_AND_ASSIGN(BacklightController); | 106 DISALLOW_COPY_AND_ASSIGN(BacklightController); |
107 }; | 107 }; |
108 | 108 |
109 } // namespace power_manager | 109 } // namespace power_manager |
110 | 110 |
111 #endif // POWER_MANAGER_BACKLIGHT_CONTROLLER_H_ | 111 #endif // POWER_MANAGER_BACKLIGHT_CONTROLLER_H_ |
OLD | NEW |