Index: chromeos/display/output_configurator.cc |
diff --git a/chromeos/display/output_configurator.cc b/chromeos/display/output_configurator.cc |
index 67da273b64965469c0b9d252e2e64e3c8ab16158..97577ad14f2a4af862a89fdfd9353d291ae52d64 100644 |
--- a/chromeos/display/output_configurator.cc |
+++ b/chromeos/display/output_configurator.cc |
@@ -812,6 +812,7 @@ bool OutputConfigurator::EnterState( |
OutputState output_state, |
DisplayPowerState power_state) { |
std::vector<bool> output_power; |
+ bool status; |
Daniel Erat
2014/01/08 21:40:28
move this down to the point where you need it, and
dsodman
2014/01/09 00:26:28
Done.
|
int num_on_outputs = GetOutputPower( |
cached_outputs_, power_state, &output_power); |
VLOG(1) << "EnterState: output=" << OutputStateToString(output_state) |
@@ -941,28 +942,59 @@ bool OutputConfigurator::EnterState( |
// Finally, apply the desired changes. |
DCHECK_EQ(cached_outputs_.size(), updated_outputs.size()); |
+ status = true; |
if (!updated_outputs.empty()) { |
delegate_->CreateFrameBuffer(width, height, updated_outputs); |
for (size_t i = 0; i < updated_outputs.size(); ++i) { |
const OutputSnapshot& output = updated_outputs[i]; |
- if (delegate_->ConfigureCrtc(output.crtc, output.current_mode, |
- output.output, output.x, output.y)) { |
- if (output.touch_device_id) |
- delegate_->ConfigureCTM(output.touch_device_id, output.transform); |
- cached_outputs_[i] = updated_outputs[i]; |
- } else { |
+ while (!delegate_->ConfigureCrtc(output.crtc, output.current_mode, |
+ output.output, output.x, output.y)) { |
LOG(WARNING) << "Unable to configure CRTC " << output.crtc << ":" |
<< " mode=" << output.current_mode |
<< " output=" << output.output |
<< " x=" << output.x |
<< " y=" << output.y; |
+ |
+ // Find the mode with the next-best resolution and see if that can |
+ // be set. |
+ int best_mode_pixels = 0; |
+ const ModeInfo* mode_info = GetModeInfo(output, output.current_mode); |
+ if (!mode_info) |
+ break; |
+ |
+ int current_mode_pixels = mode_info->width * mode_info->height; |
+ for (ModeInfoMap::const_iterator it = output.mode_infos.begin(); |
+ it != output.mode_infos.end(); it++) { |
Daniel Erat
2014/01/08 21:40:28
nit: indent one more space
dsodman
2014/01/09 00:26:28
Done.
|
+ int pixel_count = it->second.width * it->second.height; |
+ if ((pixel_count < current_mode_pixels) && |
+ (pixel_count > best_mode_pixels)) { |
+ updated_outputs[i].current_mode = it->first; |
+ best_mode_pixels = pixel_count; |
+ } |
+ } |
+ |
+ if (best_mode_pixels == 0) |
+ break; |
+ } |
+ |
+ // If we are trying to set mirror mode and one of the modeset's fails, |
Daniel Erat
2014/01/08 21:40:28
nit: s/modeset's/modesets/
dsodman
2014/01/09 00:26:28
Done.
|
+ // then the two monitors will be mis-matched. In this case, return |
+ // false to let the observers be aware. |
+ if (output_state == STATE_DUAL_MIRROR && |
+ output_power[i] && |
+ output.current_mode != output.mirror_mode) { |
+ status = false; |
} |
+ |
+ if (output.touch_device_id) |
+ delegate_->ConfigureCTM(output.touch_device_id, output.transform); |
+ cached_outputs_[i] = updated_outputs[i]; |
Daniel Erat
2014/01/08 21:40:28
ConfigureCTM() should only be run and cached_outpu
dsodman
2014/01/09 00:26:28
To be honest, I am not entirely sure what is the i
Daniel Erat
2014/01/09 00:40:34
i'm not an expert on the touch code, but i believe
|
} |
} |
output_state_ = output_state; |
power_state_ = power_state; |
- return true; |
+ return status; |
Daniel Erat
2014/01/08 21:40:28
i'm also not sure whether output_state_ and power_
dsodman
2014/01/09 00:26:28
Done.
|
} |
OutputState OutputConfigurator::ChooseOutputState( |