Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(785)

Side by Side Diff: ui/ozone/platform/dri/screen_manager.cc

Issue 522463005: [Ozone-GBM] Handle GPU crashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reland of: [Ozone-GBM] Handle GPU crashes Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/ozone/platform/dri/screen_manager.h" 5 #include "ui/ozone/platform/dri/screen_manager.h"
6 6
7 #include <xf86drmMode.h> 7 #include <xf86drmMode.h>
8 8
9 #include "ui/gfx/geometry/point.h" 9 #include "ui/gfx/geometry/point.h"
10 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/geometry/size.h" 11 #include "ui/gfx/geometry/size.h"
12 #include "ui/ozone/platform/dri/crtc_state.h" 12 #include "ui/ozone/platform/dri/crtc_state.h"
13 #include "ui/ozone/platform/dri/dri_util.h" 13 #include "ui/ozone/platform/dri/dri_util.h"
14 #include "ui/ozone/platform/dri/hardware_display_controller.h" 14 #include "ui/ozone/platform/dri/hardware_display_controller.h"
15 #include "ui/ozone/platform/dri/scanout_buffer.h" 15 #include "ui/ozone/platform/dri/scanout_buffer.h"
16 16
17 namespace ui { 17 namespace ui {
18 18
19 ScreenManager::ScreenManager(DriWrapper* dri, 19 ScreenManager::ScreenManager(DriWrapper* dri,
20 ScanoutBufferGenerator* buffer_generator) 20 ScanoutBufferGenerator* buffer_generator)
21 : dri_(dri), buffer_generator_(buffer_generator) { 21 : dri_(dri), buffer_generator_(buffer_generator) {
22 } 22 }
23 23
24 ScreenManager::~ScreenManager() { 24 ScreenManager::~ScreenManager() {
25 } 25 }
26 26
27 void ScreenManager::AddDisplayController(uint32_t crtc, uint32_t connector) {
28 HardwareDisplayControllers::iterator it = FindDisplayController(crtc);
29 // TODO(dnicoara): Turn this into a DCHECK when async display configuration is
30 // properly supported. (When there can't be a race between forcing initial
31 // display configuration in ScreenManager and NativeDisplayDelegate creating
32 // the display controllers.)
33 if (it != controllers_.end()) {
34 LOG(WARNING) << "Display controller (crtc=" << crtc << ") already present.";
35 return;
36 }
37
38 controllers_.push_back(new HardwareDisplayController(
39 dri_, scoped_ptr<CrtcState>(new CrtcState(dri_, crtc, connector))));
40 }
41
27 void ScreenManager::RemoveDisplayController(uint32_t crtc) { 42 void ScreenManager::RemoveDisplayController(uint32_t crtc) {
28 HardwareDisplayControllers::iterator it = FindDisplayController(crtc); 43 HardwareDisplayControllers::iterator it = FindDisplayController(crtc);
29 if (it != controllers_.end()) { 44 if (it != controllers_.end()) {
30 bool is_mirrored = (*it)->IsMirrored(); 45 bool is_mirrored = (*it)->IsMirrored();
31 (*it)->RemoveCrtc(crtc); 46 (*it)->RemoveCrtc(crtc);
32 if (!is_mirrored) 47 if (!is_mirrored)
33 controllers_.erase(it); 48 controllers_.erase(it);
34 } 49 }
35 } 50 }
36 51
37 bool ScreenManager::ConfigureDisplayController(uint32_t crtc, 52 bool ScreenManager::ConfigureDisplayController(uint32_t crtc,
38 uint32_t connector, 53 uint32_t connector,
39 const gfx::Point& origin, 54 const gfx::Point& origin,
40 const drmModeModeInfo& mode) { 55 const drmModeModeInfo& mode) {
41 gfx::Rect modeset_bounds( 56 gfx::Rect modeset_bounds(
42 origin.x(), origin.y(), mode.hdisplay, mode.vdisplay); 57 origin.x(), origin.y(), mode.hdisplay, mode.vdisplay);
43 HardwareDisplayControllers::iterator it = FindDisplayController(crtc); 58 HardwareDisplayControllers::iterator it = FindDisplayController(crtc);
44 HardwareDisplayController* controller = NULL; 59 DCHECK(controllers_.end() != it) << "Display controller (crtc=" << crtc
45 if (it != controllers_.end()) { 60 << ") doesn't exist.";
46 controller = *it;
47 // If nothing changed just enable the controller. Note, we perform an exact
48 // comparison on the mode since the refresh rate may have changed.
49 if (SameMode(mode, controller->get_mode()) &&
50 origin == controller->origin() && !controller->IsDisabled())
51 return controller->Enable();
52 61
53 // Either the mode or the location of the display changed, so exit mirror 62 HardwareDisplayController* controller = *it;
54 // mode and configure the display independently. If the caller still wants 63 controller = *it;
55 // mirror mode, subsequent calls configuring the other controllers will 64 // If nothing changed just enable the controller. Note, we perform an exact
56 // restore mirror mode. 65 // comparison on the mode since the refresh rate may have changed.
57 if (controller->IsMirrored()) { 66 if (SameMode(mode, controller->get_mode()) &&
58 controller = 67 origin == controller->origin() && !controller->IsDisabled())
59 new HardwareDisplayController(dri_, controller->RemoveCrtc(crtc)); 68 return controller->Enable();
60 controllers_.push_back(controller);
61 it = --controllers_.end();
62 }
63 69
64 HardwareDisplayControllers::iterator mirror = 70 // Either the mode or the location of the display changed, so exit mirror
65 FindActiveDisplayControllerByLocation(modeset_bounds); 71 // mode and configure the display independently. If the caller still wants
66 // Handle mirror mode. 72 // mirror mode, subsequent calls configuring the other controllers will
67 if (mirror != controllers_.end() && it != mirror) 73 // restore mirror mode.
68 return HandleMirrorMode(it, mirror, crtc, connector); 74 if (controller->IsMirrored()) {
69 } else { 75 controller =
70 HardwareDisplayControllers::iterator mirror = 76 new HardwareDisplayController(dri_, controller->RemoveCrtc(crtc));
71 FindActiveDisplayControllerByLocation(modeset_bounds); 77 controllers_.push_back(controller);
72 if (mirror != controllers_.end()) { 78 it = --controllers_.end();
73 (*mirror)->AddCrtc(
74 scoped_ptr<CrtcState>(new CrtcState(dri_, crtc, connector)));
75 return (*mirror)->Enable();
76 }
77 } 79 }
78 80
79 if (!controller) { 81 HardwareDisplayControllers::iterator mirror =
80 controller = new HardwareDisplayController( 82 FindActiveDisplayControllerByLocation(modeset_bounds);
81 dri_, 83 // Handle mirror mode.
82 scoped_ptr<CrtcState>(new CrtcState(dri_, crtc, connector))); 84 if (mirror != controllers_.end() && it != mirror)
83 controllers_.push_back(controller); 85 return HandleMirrorMode(it, mirror, crtc, connector);
84 }
85 86
86 return ModesetDisplayController(controller, origin, mode); 87 return ModesetDisplayController(controller, origin, mode);
87 } 88 }
88 89
89 bool ScreenManager::DisableDisplayController(uint32_t crtc) { 90 bool ScreenManager::DisableDisplayController(uint32_t crtc) {
90 HardwareDisplayControllers::iterator it = FindDisplayController(crtc); 91 HardwareDisplayControllers::iterator it = FindDisplayController(crtc);
91 if (it != controllers_.end()) { 92 if (it != controllers_.end()) {
92 if ((*it)->IsMirrored()) { 93 if ((*it)->IsMirrored()) {
93 HardwareDisplayController* controller = 94 HardwareDisplayController* controller =
94 new HardwareDisplayController(dri_, (*it)->RemoveCrtc(crtc)); 95 new HardwareDisplayController(dri_, (*it)->RemoveCrtc(crtc));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 154
154 DCHECK_NE(0u, displays.size()); 155 DCHECK_NE(0u, displays.size());
155 156
156 ScopedDrmPropertyPtr dpms( 157 ScopedDrmPropertyPtr dpms(
157 dri_->GetProperty(displays[0]->connector(), "DPMS")); 158 dri_->GetProperty(displays[0]->connector(), "DPMS"));
158 if (dpms) 159 if (dpms)
159 dri_->SetProperty(displays[0]->connector()->connector_id, 160 dri_->SetProperty(displays[0]->connector()->connector_id,
160 dpms->prop_id, 161 dpms->prop_id,
161 DRM_MODE_DPMS_ON); 162 DRM_MODE_DPMS_ON);
162 163
164 AddDisplayController(displays[0]->crtc()->crtc_id,
165 displays[0]->connector()->connector_id);
163 ConfigureDisplayController(displays[0]->crtc()->crtc_id, 166 ConfigureDisplayController(displays[0]->crtc()->crtc_id,
164 displays[0]->connector()->connector_id, 167 displays[0]->connector()->connector_id,
165 gfx::Point(), 168 gfx::Point(),
166 displays[0]->connector()->modes[0]); 169 displays[0]->connector()->modes[0]);
167 } 170 }
168 171
169 bool ScreenManager::ModesetDisplayController( 172 bool ScreenManager::ModesetDisplayController(
170 HardwareDisplayController* controller, 173 HardwareDisplayController* controller,
171 const gfx::Point& origin, 174 const gfx::Point& origin,
172 const drmModeModeInfo& mode) { 175 const drmModeModeInfo& mode) {
(...skipping 30 matching lines...) Expand all
203 206
204 // When things go wrong revert back to the previous configuration since 207 // When things go wrong revert back to the previous configuration since
205 // it is expected that the configuration would not have changed if 208 // it is expected that the configuration would not have changed if
206 // things fail. 209 // things fail.
207 (*original)->AddCrtc((*mirror)->RemoveCrtc(crtc)); 210 (*original)->AddCrtc((*mirror)->RemoveCrtc(crtc));
208 (*original)->Enable(); 211 (*original)->Enable();
209 return false; 212 return false;
210 } 213 }
211 214
212 } // namespace ui 215 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/screen_manager.h ('k') | ui/ozone/platform/dri/screen_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698