Chromium Code Reviews| 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_modifiers_size = drm_plane->count_format_modifiers; | |
| 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_modifier> supported_format_modifiers( |
| 112 format_modifiers_size); | |
| 113 for (uint32_t j = 0; j < format_modifiers_size; j++) | |
|
Daniele Castagna
2016/12/20 18:03:29
nit: s/uint32_t/size_t
hoegsberg1
2016/12/22 23:05:21
I picked uint32_t deliberately to match format_mod
| |
| 114 supported_format_modifiers[j] = drm_plane->format_modifiers[j]; | |
| 115 | |
| 116 if (plane->Initialize(drm, supported_formats, supported_format_modifiers, | |
| 117 false, false)) { | |
| 111 // CRTC controllers always assume they have a cursor plane and the cursor | 118 // 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 | 119 // 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. | 120 // track of Cursor plane here to avoid re-using it for any other purpose. |
| 114 if (plane->type() != HardwareDisplayPlane::kCursor) | 121 if (plane->type() != HardwareDisplayPlane::kCursor) |
| 115 planes_.push_back(std::move(plane)); | 122 planes_.push_back(std::move(plane)); |
| 116 } | 123 } |
| 117 } | 124 } |
| 118 | 125 |
| 119 // crbug.com/464085: if driver reports no primary planes for a crtc, create a | 126 // 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. | 127 // dummy plane for which we can assign exactly one overlay. |
| 121 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move | 128 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move |
| 122 // this workaround into HardwareDisplayPlaneLegacy. | 129 // this workaround into HardwareDisplayPlaneLegacy. |
| 123 if (!has_universal_planes) { | 130 if (!has_universal_planes) { |
| 124 for (int i = 0; i < resources->count_crtcs; ++i) { | 131 for (int i = 0; i < resources->count_crtcs; ++i) { |
| 125 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { | 132 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { |
| 126 std::unique_ptr<HardwareDisplayPlane> dummy_plane( | 133 std::unique_ptr<HardwareDisplayPlane> dummy_plane( |
| 127 CreatePlane(resources->crtcs[i] - 1, (1 << i))); | 134 CreatePlane(resources->crtcs[i] - 1, (1 << i))); |
| 128 if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), true, | 135 if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), |
| 129 false)) { | 136 std::vector<struct drm_format_modifier>(), |
| 137 true, false)) { | |
| 130 planes_.push_back(std::move(dummy_plane)); | 138 planes_.push_back(std::move(dummy_plane)); |
| 131 } | 139 } |
| 132 } | 140 } |
| 133 } | 141 } |
| 134 } | 142 } |
| 135 | 143 |
| 136 std::sort(planes_.begin(), planes_.end(), | 144 std::sort(planes_.begin(), planes_.end(), |
| 137 [](const std::unique_ptr<HardwareDisplayPlane>& l, | 145 [](const std::unique_ptr<HardwareDisplayPlane>& l, |
| 138 const std::unique_ptr<HardwareDisplayPlane>& r) { | 146 const std::unique_ptr<HardwareDisplayPlane>& r) { |
| 139 return l->plane_id() < r->plane_id(); | 147 return l->plane_id() < r->plane_id(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 | 309 |
| 302 break; | 310 break; |
| 303 } else { | 311 } else { |
| 304 plane_z_order++; | 312 plane_z_order++; |
| 305 } | 313 } |
| 306 } | 314 } |
| 307 | 315 |
| 308 return format_supported; | 316 return format_supported; |
| 309 } | 317 } |
| 310 | 318 |
| 319 std::vector<uint64_t> HardwareDisplayPlaneManager::GetFormatModifiers( | |
| 320 uint32_t crtc_id, | |
| 321 uint32_t format) { | |
| 322 int crtc_index = LookupCrtcIndex(crtc_id); | |
| 323 | |
| 324 for (const auto& plane : planes_) { | |
| 325 if (plane->CanUseForCrtc(crtc_index) && | |
| 326 plane->type() == HardwareDisplayPlane::kPrimary) { | |
| 327 return plane->ModifiersForFormat(format); | |
| 328 } | |
| 329 } | |
| 330 | |
| 331 return std::vector<uint64_t>(); | |
| 332 } | |
| 333 | |
| 311 } // namespace ui | 334 } // namespace ui |
| OLD | NEW |