| 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_fourcc.h> | 7 #include <drm_fourcc.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 crtcs_.clear(); | 86 crtcs_.clear(); |
| 87 for (int i = 0; i < resources->count_crtcs; ++i) { | 87 for (int i = 0; i < resources->count_crtcs; ++i) { |
| 88 crtcs_.push_back(resources->crtcs[i]); | 88 crtcs_.push_back(resources->crtcs[i]); |
| 89 } | 89 } |
| 90 | 90 |
| 91 uint32_t num_planes = plane_resources->count_planes; | 91 uint32_t num_planes = plane_resources->count_planes; |
| 92 std::set<uint32_t> plane_ids; | 92 std::set<uint32_t> plane_ids; |
| 93 for (uint32_t i = 0; i < num_planes; ++i) { | 93 for (uint32_t i = 0; i < num_planes; ++i) { |
| 94 ScopedDrmPlanePtr drm_plane( | 94 ScopedDrmPlanePtr drm_plane( |
| 95 drmModeGetPlane(drm->get_fd(), plane_resources->planes[i])); | 95 drmModeGetPlane2(drm->get_fd(), plane_resources->planes[i])); |
| 96 if (!drm_plane) { | 96 if (!drm_plane) { |
| 97 PLOG(ERROR) << "Failed to get plane " << i; | 97 PLOG(ERROR) << "Failed to get plane " << i; |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 | 100 |
| 101 uint32_t formats_size = drm_plane->count_formats; | 101 uint32_t formats_size = drm_plane->count_formats; |
| 102 uint32_t format_info_size = drm_plane->count_format_info; |
| 102 plane_ids.insert(drm_plane->plane_id); | 103 plane_ids.insert(drm_plane->plane_id); |
| 103 std::unique_ptr<HardwareDisplayPlane> plane( | 104 std::unique_ptr<HardwareDisplayPlane> plane( |
| 104 CreatePlane(drm_plane->plane_id, drm_plane->possible_crtcs)); | 105 CreatePlane(drm_plane->plane_id, drm_plane->possible_crtcs)); |
| 105 | 106 |
| 106 std::vector<uint32_t> supported_formats(formats_size); | 107 std::vector<uint32_t> supported_formats(formats_size); |
| 107 for (uint32_t j = 0; j < formats_size; j++) | 108 for (uint32_t j = 0; j < formats_size; j++) |
| 108 supported_formats[j] = drm_plane->formats[j]; | 109 supported_formats[j] = drm_plane->formats[j]; |
| 109 | 110 |
| 110 if (plane->Initialize(drm, supported_formats, false, false)) { | 111 std::vector<struct drm_format_info> supported_format_info(format_info_size); |
| 112 for (uint32_t j = 0; j < format_info_size; j++) |
| 113 supported_format_info[j] = drm_plane->format_info[j]; |
| 114 |
| 115 if (plane->Initialize(drm, supported_formats, |
| 116 » » » supported_format_info, false, false)) { |
| 111 // CRTC controllers always assume they have a cursor plane and the cursor | 117 // CRTC controllers always assume they have a cursor plane and the cursor |
| 112 // plane is updated via cursor specific DRM API. Hence, we dont keep | 118 // plane is updated via cursor specific DRM API. Hence, we dont keep |
| 113 // track of Cursor plane here to avoid re-using it for any other purpose. | 119 // track of Cursor plane here to avoid re-using it for any other purpose. |
| 114 if (plane->type() != HardwareDisplayPlane::kCursor) | 120 if (plane->type() != HardwareDisplayPlane::kCursor) |
| 115 planes_.push_back(std::move(plane)); | 121 planes_.push_back(std::move(plane)); |
| 116 } | 122 } |
| 117 } | 123 } |
| 118 | 124 |
| 119 // crbug.com/464085: if driver reports no primary planes for a crtc, create a | 125 // crbug.com/464085: if driver reports no primary planes for a crtc, create a |
| 120 // dummy plane for which we can assign exactly one overlay. | 126 // dummy plane for which we can assign exactly one overlay. |
| 121 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move | 127 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move |
| 122 // this workaround into HardwareDisplayPlaneLegacy. | 128 // this workaround into HardwareDisplayPlaneLegacy. |
| 123 if (!has_universal_planes) { | 129 if (!has_universal_planes) { |
| 124 for (int i = 0; i < resources->count_crtcs; ++i) { | 130 for (int i = 0; i < resources->count_crtcs; ++i) { |
| 125 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { | 131 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { |
| 126 std::unique_ptr<HardwareDisplayPlane> dummy_plane( | 132 std::unique_ptr<HardwareDisplayPlane> dummy_plane( |
| 127 CreatePlane(resources->crtcs[i] - 1, (1 << i))); | 133 CreatePlane(resources->crtcs[i] - 1, (1 << i))); |
| 128 if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), true, | 134 if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), |
| 129 false)) { | 135 » » » » std::vector<struct drm_format_info>(), |
| 136 » » » » true, false)) { |
| 130 planes_.push_back(std::move(dummy_plane)); | 137 planes_.push_back(std::move(dummy_plane)); |
| 131 } | 138 } |
| 132 } | 139 } |
| 133 } | 140 } |
| 134 } | 141 } |
| 135 | 142 |
| 136 std::sort(planes_.begin(), planes_.end(), | 143 std::sort(planes_.begin(), planes_.end(), |
| 137 [](const std::unique_ptr<HardwareDisplayPlane>& l, | 144 [](const std::unique_ptr<HardwareDisplayPlane>& l, |
| 138 const std::unique_ptr<HardwareDisplayPlane>& r) { | 145 const std::unique_ptr<HardwareDisplayPlane>& r) { |
| 139 return l->plane_id() < r->plane_id(); | 146 return l->plane_id() < r->plane_id(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 308 |
| 302 break; | 309 break; |
| 303 } else { | 310 } else { |
| 304 plane_z_order++; | 311 plane_z_order++; |
| 305 } | 312 } |
| 306 } | 313 } |
| 307 | 314 |
| 308 return format_supported; | 315 return format_supported; |
| 309 } | 316 } |
| 310 | 317 |
| 318 uint32_t HardwareDisplayPlaneManager::GetFormatModifiers(uint32_t crtc_id, uint3
2_t format, |
| 319 uint64_t *modifiers, ui
nt32_t count) { |
| 320 int crtc_index = LookupCrtcIndex(crtc_id); |
| 321 |
| 322 for (const auto& plane : planes_) { |
| 323 if (plane->CanUseForCrtc(crtc_index) && |
| 324 plane->type() == HardwareDisplayPlane::kPrimary) { |
| 325 return plane->ModifiersForFormat(format, modifiers, count); |
| 326 } |
| 327 } |
| 328 |
| 329 return 0; |
| 330 } |
| 331 |
| 311 } // namespace ui | 332 } // namespace ui |
| OLD | NEW |