diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2010-02-11 16:50:06 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-02-17 23:26:26 -0500 |
commit | bc4624cad9b53b3fd3248fe3086b432471fc0fe0 (patch) | |
tree | f92f287482fe1e5de377e91d7c3498a4f98dda43 | |
parent | 2745932495ca3634b11a8662b464d2bf0325ae78 (diff) |
drm/radeon/kms: simplify picking power state
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_pm.c | 57 |
1 files changed, 18 insertions, 39 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c index a8e151ec1351..f0234351fd57 100644 --- a/drivers/gpu/drm/radeon/radeon_pm.c +++ b/drivers/gpu/drm/radeon/radeon_pm.c | |||
@@ -81,60 +81,39 @@ static void radeon_print_power_mode_info(struct radeon_device *rdev) | |||
81 | static struct radeon_power_state * radeon_pick_power_state(struct radeon_device *rdev, | 81 | static struct radeon_power_state * radeon_pick_power_state(struct radeon_device *rdev, |
82 | enum radeon_pm_state_type type) | 82 | enum radeon_pm_state_type type) |
83 | { | 83 | { |
84 | int i; | 84 | int i, j; |
85 | struct radeon_power_state *power_state = NULL; | 85 | enum radeon_pm_state_type wanted_types[2]; |
86 | int wanted_count; | ||
86 | 87 | ||
87 | switch (type) { | 88 | switch (type) { |
88 | case POWER_STATE_TYPE_DEFAULT: | 89 | case POWER_STATE_TYPE_DEFAULT: |
89 | default: | 90 | default: |
90 | return rdev->pm.default_power_state; | 91 | return rdev->pm.default_power_state; |
91 | case POWER_STATE_TYPE_POWERSAVE: | 92 | case POWER_STATE_TYPE_POWERSAVE: |
92 | for (i = 0; i < rdev->pm.num_power_states; i++) { | 93 | wanted_types[0] = POWER_STATE_TYPE_POWERSAVE; |
93 | if (rdev->pm.power_state[i].type == POWER_STATE_TYPE_POWERSAVE) { | 94 | wanted_types[1] = POWER_STATE_TYPE_BATTERY; |
94 | power_state = &rdev->pm.power_state[i]; | 95 | wanted_count = 2; |
95 | break; | ||
96 | } | ||
97 | } | ||
98 | if (power_state == NULL) { | ||
99 | for (i = 0; i < rdev->pm.num_power_states; i++) { | ||
100 | if (rdev->pm.power_state[i].type == POWER_STATE_TYPE_BATTERY) { | ||
101 | power_state = &rdev->pm.power_state[i]; | ||
102 | break; | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | break; | 96 | break; |
107 | case POWER_STATE_TYPE_BATTERY: | 97 | case POWER_STATE_TYPE_BATTERY: |
108 | for (i = 0; i < rdev->pm.num_power_states; i++) { | 98 | wanted_types[0] = POWER_STATE_TYPE_BATTERY; |
109 | if (rdev->pm.power_state[i].type == POWER_STATE_TYPE_BATTERY) { | 99 | wanted_types[1] = POWER_STATE_TYPE_POWERSAVE; |
110 | power_state = &rdev->pm.power_state[i]; | 100 | wanted_count = 2; |
111 | break; | ||
112 | } | ||
113 | } | ||
114 | if (power_state == NULL) { | ||
115 | for (i = 0; i < rdev->pm.num_power_states; i++) { | ||
116 | if (rdev->pm.power_state[i].type == POWER_STATE_TYPE_POWERSAVE) { | ||
117 | power_state = &rdev->pm.power_state[i]; | ||
118 | break; | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | break; | 101 | break; |
123 | case POWER_STATE_TYPE_BALANCED: | 102 | case POWER_STATE_TYPE_BALANCED: |
124 | case POWER_STATE_TYPE_PERFORMANCE: | 103 | case POWER_STATE_TYPE_PERFORMANCE: |
125 | for (i = 0; i < rdev->pm.num_power_states; i++) { | 104 | wanted_types[0] = type; |
126 | if (rdev->pm.power_state[i].type == type) { | 105 | wanted_count = 1; |
127 | power_state = &rdev->pm.power_state[i]; | ||
128 | break; | ||
129 | } | ||
130 | } | ||
131 | break; | 106 | break; |
132 | } | 107 | } |
133 | 108 | ||
134 | if (power_state == NULL) | 109 | for (i = 0; i < wanted_count; i++) { |
135 | return rdev->pm.default_power_state; | 110 | for (j = 0; j < rdev->pm.num_power_states; j++) { |
111 | if (rdev->pm.power_state[j].type == wanted_types[i]) | ||
112 | return &rdev->pm.power_state[j]; | ||
113 | } | ||
114 | } | ||
136 | 115 | ||
137 | return power_state; | 116 | return rdev->pm.default_power_state; |
138 | } | 117 | } |
139 | 118 | ||
140 | static struct radeon_pm_clock_info * radeon_pick_clock_mode(struct radeon_device *rdev, | 119 | static struct radeon_pm_clock_info * radeon_pick_clock_mode(struct radeon_device *rdev, |