| OLD | NEW |
| 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/drm/gpu/hardware_display_plane_manager.h" | 5 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h" |
| 6 | 6 |
| 7 #include <drm.h> | 7 #include <drm.h> |
| 8 #include <xf86drm.h> | 8 #include <xf86drm.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 HardwareDisplayPlaneManager::HardwareDisplayPlaneManager() : drm_(nullptr) { | 62 HardwareDisplayPlaneManager::HardwareDisplayPlaneManager() : drm_(nullptr) { |
| 63 } | 63 } |
| 64 | 64 |
| 65 HardwareDisplayPlaneManager::~HardwareDisplayPlaneManager() { | 65 HardwareDisplayPlaneManager::~HardwareDisplayPlaneManager() { |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool HardwareDisplayPlaneManager::Initialize(DrmDevice* drm) { | 68 bool HardwareDisplayPlaneManager::Initialize(DrmDevice* drm) { |
| 69 drm_ = drm; | 69 drm_ = drm; |
| 70 | |
| 71 // Try to get all of the planes if possible, so we don't have to try to | |
| 72 // discover hidden primary planes. | |
| 73 bool has_universal_planes = false; | |
| 74 #if defined(DRM_CLIENT_CAP_UNIVERSAL_PLANES) | |
| 75 has_universal_planes = drm->SetCapability(DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); | |
| 76 #endif // defined(DRM_CLIENT_CAP_UNIVERSAL_PLANES) | |
| 77 | |
| 78 ScopedDrmResourcesPtr resources(drmModeGetResources(drm->get_fd())); | 70 ScopedDrmResourcesPtr resources(drmModeGetResources(drm->get_fd())); |
| 79 if (!resources) { | 71 if (!resources) { |
| 80 PLOG(ERROR) << "Failed to get resources"; | 72 PLOG(ERROR) << "Failed to get resources"; |
| 81 return false; | 73 return false; |
| 82 } | 74 } |
| 83 | 75 |
| 84 ScopedDrmPlaneResPtr plane_resources(drmModeGetPlaneResources(drm->get_fd())); | 76 ScopedDrmPlaneResPtr plane_resources(drmModeGetPlaneResources(drm->get_fd())); |
| 85 if (!plane_resources) { | 77 if (!plane_resources) { |
| 86 PLOG(ERROR) << "Failed to get plane resources"; | 78 PLOG(ERROR) << "Failed to get plane resources"; |
| 87 return false; | 79 return false; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 105 scoped_ptr<HardwareDisplayPlane> plane( | 97 scoped_ptr<HardwareDisplayPlane> plane( |
| 106 CreatePlane(drm_plane->plane_id, drm_plane->possible_crtcs)); | 98 CreatePlane(drm_plane->plane_id, drm_plane->possible_crtcs)); |
| 107 if (plane->Initialize(drm)) | 99 if (plane->Initialize(drm)) |
| 108 planes_.push_back(plane.release()); | 100 planes_.push_back(plane.release()); |
| 109 } | 101 } |
| 110 | 102 |
| 111 // crbug.com/464085: if driver reports no primary planes for a crtc, create a | 103 // crbug.com/464085: if driver reports no primary planes for a crtc, create a |
| 112 // dummy plane for which we can assign exactly one overlay. | 104 // dummy plane for which we can assign exactly one overlay. |
| 113 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move | 105 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move |
| 114 // this workaround into HardwareDisplayPlaneLegacy. | 106 // this workaround into HardwareDisplayPlaneLegacy. |
| 115 if (!has_universal_planes) { | 107 for (int i = 0; i < resources->count_crtcs; ++i) { |
| 116 for (int i = 0; i < resources->count_crtcs; ++i) { | 108 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { |
| 117 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { | 109 scoped_ptr<HardwareDisplayPlane> dummy_plane( |
| 118 scoped_ptr<HardwareDisplayPlane> dummy_plane( | 110 CreatePlane(resources->crtcs[i] - 1, (1 << i))); |
| 119 CreatePlane(resources->crtcs[i] - 1, (1 << i))); | 111 dummy_plane->set_is_dummy(true); |
| 120 dummy_plane->set_is_dummy(true); | 112 if (dummy_plane->Initialize(drm)) |
| 121 if (dummy_plane->Initialize(drm)) | 113 planes_.push_back(dummy_plane.release()); |
| 122 planes_.push_back(dummy_plane.release()); | |
| 123 } | |
| 124 } | 114 } |
| 125 } | 115 } |
| 126 | 116 |
| 127 std::sort(planes_.begin(), planes_.end(), | 117 std::sort(planes_.begin(), planes_.end(), |
| 128 [](HardwareDisplayPlane* l, HardwareDisplayPlane* r) { | 118 [](HardwareDisplayPlane* l, HardwareDisplayPlane* r) { |
| 129 return l->plane_id() < r->plane_id(); | 119 return l->plane_id() < r->plane_id(); |
| 130 }); | 120 }); |
| 131 return true; | 121 return true; |
| 132 } | 122 } |
| 133 | 123 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 if (plane->owning_crtc() == crtc_id) { | 213 if (plane->owning_crtc() == crtc_id) { |
| 224 plane->set_owning_crtc(0); | 214 plane->set_owning_crtc(0); |
| 225 plane->set_in_use(false); | 215 plane->set_in_use(false); |
| 226 } else { | 216 } else { |
| 227 plane_list->old_plane_list.push_back(plane); | 217 plane_list->old_plane_list.push_back(plane); |
| 228 } | 218 } |
| 229 } | 219 } |
| 230 } | 220 } |
| 231 | 221 |
| 232 } // namespace ui | 222 } // namespace ui |
| OLD | NEW |