OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_atomic.h" | 5 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h" |
6 | 6 |
7 #include <drm.h> | 7 #include <drm.h> |
8 #include <drm/drm_fourcc.h> | 8 #include <drm/drm_fourcc.h> |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <gbm.h> | 10 #include <gbm.h> |
11 #include <xf86drm.h> | 11 #include <xf86drm.h> |
12 | 12 |
13 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 13 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 namespace { | 16 namespace { |
17 | 17 |
| 18 const char* kTypePropName = "type"; |
18 const char* kCrtcPropName = "CRTC_ID"; | 19 const char* kCrtcPropName = "CRTC_ID"; |
19 const char* kFbPropName = "FB_ID"; | 20 const char* kFbPropName = "FB_ID"; |
20 const char* kCrtcXPropName = "CRTC_X"; | 21 const char* kCrtcXPropName = "CRTC_X"; |
21 const char* kCrtcYPropName = "CRTC_Y"; | 22 const char* kCrtcYPropName = "CRTC_Y"; |
22 const char* kCrtcWPropName = "CRTC_W"; | 23 const char* kCrtcWPropName = "CRTC_W"; |
23 const char* kCrtcHPropName = "CRTC_H"; | 24 const char* kCrtcHPropName = "CRTC_H"; |
24 const char* kSrcXPropName = "SRC_X"; | 25 const char* kSrcXPropName = "SRC_X"; |
25 const char* kSrcYPropName = "SRC_Y"; | 26 const char* kSrcYPropName = "SRC_Y"; |
26 const char* kSrcWPropName = "SRC_W"; | 27 const char* kSrcWPropName = "SRC_W"; |
27 const char* kSrcHPropName = "SRC_H"; | 28 const char* kSrcHPropName = "SRC_H"; |
28 | 29 |
| 30 HardwareDisplayPlane::Type GetPlaneType(int value) { |
| 31 switch (value) { |
| 32 case DRM_PLANE_TYPE_CURSOR: |
| 33 return HardwareDisplayPlane::kCursor; |
| 34 case DRM_PLANE_TYPE_PRIMARY: |
| 35 return HardwareDisplayPlane::kPrimary; |
| 36 case DRM_PLANE_TYPE_OVERLAY: |
| 37 return HardwareDisplayPlane::kOverlay; |
| 38 default: |
| 39 NOTREACHED(); |
| 40 return HardwareDisplayPlane::kDummy; |
| 41 } |
| 42 } |
| 43 |
29 } // namespace | 44 } // namespace |
30 | 45 |
31 HardwareDisplayPlaneAtomic::Property::Property() { | 46 HardwareDisplayPlaneAtomic::Property::Property() { |
32 } | 47 } |
33 | 48 |
34 bool HardwareDisplayPlaneAtomic::Property::Initialize( | 49 bool HardwareDisplayPlaneAtomic::Property::Initialize( |
35 DrmDevice* drm, | 50 DrmDevice* drm, |
36 const char* name, | 51 const char* name, |
37 const ScopedDrmObjectPropertyPtr& plane_props) { | 52 const ScopedDrmObjectPropertyPtr& plane_props) { |
38 for (uint32_t i = 0; i < plane_props->count_props; i++) { | 53 for (uint32_t i = 0; i < plane_props->count_props; i++) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 src_rect.height()); | 99 src_rect.height()); |
85 if (plane_set_error) { | 100 if (plane_set_error) { |
86 PLOG(ERROR) << "Failed to set plane data"; | 101 PLOG(ERROR) << "Failed to set plane data"; |
87 return false; | 102 return false; |
88 } | 103 } |
89 return true; | 104 return true; |
90 } | 105 } |
91 | 106 |
92 bool HardwareDisplayPlaneAtomic::Initialize( | 107 bool HardwareDisplayPlaneAtomic::Initialize( |
93 DrmDevice* drm, | 108 DrmDevice* drm, |
94 const std::vector<uint32_t>& formats) { | 109 const std::vector<uint32_t>& formats, |
| 110 bool is_dummy) { |
| 111 if (is_dummy) { |
| 112 type_ = kDummy; |
| 113 supported_formats_.push_back(DRM_FORMAT_XRGB8888); |
| 114 return true; |
| 115 } |
| 116 |
95 ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties( | 117 ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties( |
96 drm->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE)); | 118 drm->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE)); |
97 | 119 |
98 if (!plane_props) { | 120 if (!plane_props) { |
99 PLOG(ERROR) << "Unable to get plane properties."; | 121 PLOG(ERROR) << "Unable to get plane properties."; |
100 return false; | 122 return false; |
101 } | 123 } |
102 | 124 |
103 bool props_init = crtc_prop_.Initialize(drm, kCrtcPropName, plane_props) && | 125 bool props_init = crtc_prop_.Initialize(drm, kCrtcPropName, plane_props) && |
104 fb_prop_.Initialize(drm, kFbPropName, plane_props) && | 126 fb_prop_.Initialize(drm, kFbPropName, plane_props) && |
105 crtc_x_prop_.Initialize(drm, kCrtcXPropName, plane_props) && | 127 crtc_x_prop_.Initialize(drm, kCrtcXPropName, plane_props) && |
106 crtc_y_prop_.Initialize(drm, kCrtcYPropName, plane_props) && | 128 crtc_y_prop_.Initialize(drm, kCrtcYPropName, plane_props) && |
107 crtc_w_prop_.Initialize(drm, kCrtcWPropName, plane_props) && | 129 crtc_w_prop_.Initialize(drm, kCrtcWPropName, plane_props) && |
108 crtc_h_prop_.Initialize(drm, kCrtcHPropName, plane_props) && | 130 crtc_h_prop_.Initialize(drm, kCrtcHPropName, plane_props) && |
109 src_x_prop_.Initialize(drm, kSrcXPropName, plane_props) && | 131 src_x_prop_.Initialize(drm, kSrcXPropName, plane_props) && |
110 src_y_prop_.Initialize(drm, kSrcYPropName, plane_props) && | 132 src_y_prop_.Initialize(drm, kSrcYPropName, plane_props) && |
111 src_w_prop_.Initialize(drm, kSrcWPropName, plane_props) && | 133 src_w_prop_.Initialize(drm, kSrcWPropName, plane_props) && |
112 src_h_prop_.Initialize(drm, kSrcHPropName, plane_props); | 134 src_h_prop_.Initialize(drm, kSrcHPropName, plane_props); |
113 | 135 |
114 if (!props_init) { | 136 if (!props_init) { |
115 LOG(ERROR) << "Unable to get plane properties."; | 137 LOG(ERROR) << "Unable to get plane properties."; |
116 return false; | 138 return false; |
117 } | 139 } |
118 | 140 |
119 supported_formats_ = formats; | 141 supported_formats_ = formats; |
120 if (is_dummy()) | 142 |
121 supported_formats_.push_back(DRM_FORMAT_XRGB8888); | 143 for (uint32_t i = 0; i < plane_props->count_props; i++) { |
| 144 ScopedDrmPropertyPtr property( |
| 145 drmModeGetProperty(drm->get_fd(), plane_props->props[i])); |
| 146 if (property && !strcmp(property->name, kTypePropName)) { |
| 147 type_ = GetPlaneType(plane_props->prop_values[i]); |
| 148 } |
| 149 } |
122 | 150 |
123 return true; | 151 return true; |
124 } | 152 } |
125 | 153 |
126 bool HardwareDisplayPlaneAtomic::IsSupportedFormat(uint32_t format) const { | 154 bool HardwareDisplayPlaneAtomic::IsSupportedFormat(uint32_t format) const { |
127 uint32_t format_type = 0; | 155 uint32_t format_type = 0; |
128 switch (format) { | 156 switch (format) { |
129 case GBM_BO_FORMAT_ARGB8888: { | 157 case GBM_BO_FORMAT_ARGB8888: { |
130 // We create a FB of 24 bit color depth. | 158 // We create a FB of 24 bit color depth. |
131 format_type = DRM_FORMAT_XRGB8888; | 159 format_type = DRM_FORMAT_XRGB8888; |
(...skipping 10 matching lines...) Expand all Loading... |
142 | 170 |
143 for (auto& element : supported_formats_) { | 171 for (auto& element : supported_formats_) { |
144 if (element == format_type) | 172 if (element == format_type) |
145 return true; | 173 return true; |
146 } | 174 } |
147 | 175 |
148 return false; | 176 return false; |
149 } | 177 } |
150 | 178 |
151 } // namespace ui | 179 } // namespace ui |
OLD | NEW |