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.h" | 5 #include "ui/ozone/platform/drm/gpu/hardware_display_plane.h" |
6 | 6 |
7 #include <drm.h> | 7 #include <drm.h> |
8 #include <drm/drm_fourcc.h> | |
8 #include <xf86drm.h> | 9 #include <xf86drm.h> |
9 | 10 |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
12 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 13 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
13 | 14 |
14 namespace ui { | 15 namespace ui { |
15 | 16 |
17 namespace { | |
18 | |
19 const char* kTypePropName = "type"; | |
20 HardwareDisplayPlane::Type GetPlaneType(int value) { | |
21 switch (value) { | |
22 case DRM_PLANE_TYPE_CURSOR: | |
23 return HardwareDisplayPlane::kCursor; | |
24 case DRM_PLANE_TYPE_PRIMARY: | |
25 return HardwareDisplayPlane::kPrimary; | |
26 case DRM_PLANE_TYPE_OVERLAY: | |
27 return HardwareDisplayPlane::kOverlay; | |
28 default: | |
29 NOTREACHED(); | |
30 return HardwareDisplayPlane::kDummy; | |
31 } | |
32 } | |
33 | |
34 } // namespace | |
35 | |
16 HardwareDisplayPlane::HardwareDisplayPlane(uint32_t plane_id, | 36 HardwareDisplayPlane::HardwareDisplayPlane(uint32_t plane_id, |
17 uint32_t possible_crtcs) | 37 uint32_t possible_crtcs) |
18 : plane_id_(plane_id), possible_crtcs_(possible_crtcs) { | 38 : plane_id_(plane_id), possible_crtcs_(possible_crtcs) { |
19 } | 39 } |
20 | 40 |
21 HardwareDisplayPlane::~HardwareDisplayPlane() { | 41 HardwareDisplayPlane::~HardwareDisplayPlane() { |
22 } | 42 } |
23 | 43 |
24 bool HardwareDisplayPlane::CanUseForCrtc(uint32_t crtc_index) { | 44 bool HardwareDisplayPlane::CanUseForCrtc(uint32_t crtc_index) { |
25 return possible_crtcs_ & (1 << crtc_index); | 45 return possible_crtcs_ & (1 << crtc_index); |
26 } | 46 } |
27 | 47 |
28 bool HardwareDisplayPlane::Initialize(DrmDevice* drm, | 48 bool HardwareDisplayPlane::Initialize(DrmDevice* drm, |
29 const std::vector<uint32_t>& formats) { | 49 const std::vector<uint32_t>& formats, |
30 return true; | 50 bool is_dummy) { |
51 if (is_dummy) { | |
52 type_ = kDummy; | |
53 supported_formats_.push_back(DRM_FORMAT_XRGB8888); | |
54 return true; | |
55 } | |
56 | |
57 supported_formats_ = formats; | |
58 | |
59 ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties( | |
kalyank
2015/08/22 01:54:37
Sorry, the previous reply got badly formatted.
I r
| |
60 drm->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE)); | |
61 if (!plane_props) { | |
62 PLOG(ERROR) << "Unable to get plane properties."; | |
63 return false; | |
64 } | |
65 | |
66 uint32_t count_props = plane_props->count_props; | |
67 for (uint32_t i = 0; i < count_props; i++) { | |
68 ScopedDrmPropertyPtr property( | |
69 drmModeGetProperty(drm->get_fd(), plane_props->props[i])); | |
70 if (property && !strcmp(property->name, kTypePropName)) { | |
71 type_ = GetPlaneType(plane_props->prop_values[i]); | |
72 } | |
73 } | |
74 | |
75 return InitializeProperties(drm, plane_props); | |
31 } | 76 } |
32 | 77 |
33 bool HardwareDisplayPlane::IsSupportedFormat(uint32_t format) const { | 78 bool HardwareDisplayPlane::IsSupportedFormat(uint32_t format) const { |
34 return true; | 79 return true; |
35 } | 80 } |
36 | 81 |
82 bool HardwareDisplayPlane::InitializeProperties( | |
83 DrmDevice* drm, | |
84 const ScopedDrmObjectPropertyPtr& plane_props) { | |
85 return true; | |
86 } | |
87 | |
37 } // namespace ui | 88 } // namespace ui |
OLD | NEW |