OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 "chromeos/display/output_configurator.h" | 5 #include "chromeos/display/output_configurator.h" |
6 | 6 |
7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 #include <X11/extensions/Xrandr.h> | 8 #include <X11/extensions/Xrandr.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/chromeos/chromeos_version.h" | 11 #include "base/chromeos/chromeos_version.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "chromeos/display/output_util.h" |
15 #include "chromeos/display/real_output_configurator_delegate.h" | 16 #include "chromeos/display/real_output_configurator_delegate.h" |
16 | 17 |
17 namespace chromeos { | 18 namespace chromeos { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 // Prefixes for the built-in displays. | |
22 const char kInternal_LVDS[] = "LVDS"; | |
23 const char kInternal_eDP[] = "eDP"; | |
24 | |
25 // The delay to perform configuration after RRNotify. See the comment | 22 // The delay to perform configuration after RRNotify. See the comment |
26 // in |Dispatch()|. | 23 // in |Dispatch()|. |
27 const int64 kConfigureDelayMs = 500; | 24 const int64 kConfigureDelayMs = 500; |
28 | 25 |
29 // Returns a string describing |state|. | 26 // Returns a string describing |state|. |
30 std::string DisplayPowerStateToString(DisplayPowerState state) { | 27 std::string DisplayPowerStateToString(DisplayPowerState state) { |
31 switch (state) { | 28 switch (state) { |
32 case DISPLAY_POWER_ALL_ON: | 29 case DISPLAY_POWER_ALL_ON: |
33 return "ALL_ON"; | 30 return "ALL_ON"; |
34 case DISPLAY_POWER_ALL_OFF: | 31 case DISPLAY_POWER_ALL_OFF: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 : output(None), | 83 : output(None), |
87 crtc(None), | 84 crtc(None), |
88 current_mode(None), | 85 current_mode(None), |
89 native_mode(None), | 86 native_mode(None), |
90 mirror_mode(None), | 87 mirror_mode(None), |
91 y(0), | 88 y(0), |
92 height(0), | 89 height(0), |
93 is_internal(false), | 90 is_internal(false), |
94 is_aspect_preserving_scaling(false), | 91 is_aspect_preserving_scaling(false), |
95 touch_device_id(0), | 92 touch_device_id(0), |
96 index(0) {} | 93 display_id(0), |
| 94 has_display_id(false) {} |
97 | 95 |
98 OutputConfigurator::CoordinateTransformation::CoordinateTransformation() | 96 OutputConfigurator::CoordinateTransformation::CoordinateTransformation() |
99 : x_scale(1.0), | 97 : x_scale(1.0), |
100 x_offset(0.0), | 98 x_offset(0.0), |
101 y_scale(1.0), | 99 y_scale(1.0), |
102 y_offset(0.0) {} | 100 y_offset(0.0) {} |
103 | 101 |
104 OutputConfigurator::CrtcConfig::CrtcConfig() | 102 OutputConfigurator::CrtcConfig::CrtcConfig() |
105 : crtc(None), | 103 : crtc(None), |
106 x(0), | 104 x(0), |
(...skipping 28 matching lines...) Expand all Loading... |
135 | 133 |
136 if (!configurator_->configure_timer_->IsRunning()) { | 134 if (!configurator_->configure_timer_->IsRunning()) { |
137 LOG(ERROR) << "ConfigureOutputs() timer not running"; | 135 LOG(ERROR) << "ConfigureOutputs() timer not running"; |
138 return false; | 136 return false; |
139 } | 137 } |
140 | 138 |
141 configurator_->ConfigureOutputs(); | 139 configurator_->ConfigureOutputs(); |
142 return true; | 140 return true; |
143 } | 141 } |
144 | 142 |
145 // static | |
146 bool OutputConfigurator::IsInternalOutputName(const std::string& name) { | |
147 return name.find(kInternal_LVDS) == 0 || name.find(kInternal_eDP) == 0; | |
148 } | |
149 | |
150 OutputConfigurator::OutputConfigurator() | 143 OutputConfigurator::OutputConfigurator() |
151 : state_controller_(NULL), | 144 : state_controller_(NULL), |
152 configure_display_(base::chromeos::IsRunningOnChromeOS()), | 145 configure_display_(base::chromeos::IsRunningOnChromeOS()), |
153 xrandr_event_base_(0), | 146 xrandr_event_base_(0), |
154 output_state_(STATE_INVALID), | 147 output_state_(STATE_INVALID), |
155 power_state_(DISPLAY_POWER_ALL_ON) { | 148 power_state_(DISPLAY_POWER_ALL_ON) { |
156 } | 149 } |
157 | 150 |
158 OutputConfigurator::~OutputConfigurator() {} | 151 OutputConfigurator::~OutputConfigurator() {} |
159 | 152 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 case 1: | 498 case 1: |
506 return STATE_SINGLE; | 499 return STATE_SINGLE; |
507 case 2: { | 500 case 2: { |
508 if (num_on_outputs == 1) { | 501 if (num_on_outputs == 1) { |
509 // If only one output is currently turned on, return the "single" | 502 // If only one output is currently turned on, return the "single" |
510 // state so that its native mode will be used. | 503 // state so that its native mode will be used. |
511 return STATE_SINGLE; | 504 return STATE_SINGLE; |
512 } else { | 505 } else { |
513 // With either both outputs on or both outputs off, use one of the | 506 // With either both outputs on or both outputs off, use one of the |
514 // dual modes. | 507 // dual modes. |
515 return state_controller_->GetStateForOutputs(outputs); | 508 std::vector<int64> display_ids; |
| 509 for (size_t i = 0; i < outputs.size(); ++i) { |
| 510 // If display id isn't available, switch to extended mode. |
| 511 if (!outputs[i].has_display_id) |
| 512 return STATE_DUAL_EXTENDED; |
| 513 display_ids.push_back(outputs[i].display_id); |
| 514 } |
| 515 return state_controller_->GetStateForDisplayIds(display_ids); |
516 } | 516 } |
517 } | 517 } |
518 default: | 518 default: |
519 NOTREACHED(); | 519 NOTREACHED(); |
520 } | 520 } |
521 return STATE_INVALID; | 521 return STATE_INVALID; |
522 } | 522 } |
523 | 523 |
524 OutputConfigurator::CoordinateTransformation | 524 OutputConfigurator::CoordinateTransformation |
525 OutputConfigurator::GetMirrorModeCTM( | 525 OutputConfigurator::GetMirrorModeCTM( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 float width_ratio = static_cast<float>(mirror_mode_width) / | 578 float width_ratio = static_cast<float>(mirror_mode_width) / |
579 static_cast<float>(native_mode_width); | 579 static_cast<float>(native_mode_width); |
580 float height_ratio = static_cast<float>(mirror_mode_height) / | 580 float height_ratio = static_cast<float>(mirror_mode_height) / |
581 static_cast<float>(native_mode_height); | 581 static_cast<float>(native_mode_height); |
582 | 582 |
583 area_ratio = width_ratio * height_ratio; | 583 area_ratio = width_ratio * height_ratio; |
584 return area_ratio; | 584 return area_ratio; |
585 } | 585 } |
586 | 586 |
587 } // namespace chromeos | 587 } // namespace chromeos |
OLD | NEW |