Chromium Code Reviews| 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"; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 src_rect.height()); | 85 src_rect.height()); |
| 85 if (plane_set_error) { | 86 if (plane_set_error) { |
| 86 PLOG(ERROR) << "Failed to set plane data"; | 87 PLOG(ERROR) << "Failed to set plane data"; |
| 87 return false; | 88 return false; |
| 88 } | 89 } |
| 89 return true; | 90 return true; |
| 90 } | 91 } |
| 91 | 92 |
| 92 bool HardwareDisplayPlaneAtomic::Initialize( | 93 bool HardwareDisplayPlaneAtomic::Initialize( |
| 93 DrmDevice* drm, | 94 DrmDevice* drm, |
| 94 const std::vector<uint32_t>& formats) { | 95 const std::vector<uint32_t>& formats, |
| 96 bool is_dummy) { | |
| 97 if (is_dummy) { | |
| 98 type_ = Dummy; | |
| 99 supported_formats_.push_back(DRM_FORMAT_XRGB8888); | |
| 100 return true; | |
| 101 } | |
| 102 | |
| 95 ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties( | 103 ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties( |
| 96 drm->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE)); | 104 drm->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE)); |
| 97 | 105 |
| 98 if (!plane_props) { | 106 if (!plane_props) { |
| 99 PLOG(ERROR) << "Unable to get plane properties."; | 107 PLOG(ERROR) << "Unable to get plane properties."; |
| 100 return false; | 108 return false; |
| 101 } | 109 } |
| 102 | 110 |
| 103 bool props_init = crtc_prop_.Initialize(drm, kCrtcPropName, plane_props) && | 111 bool props_init = crtc_prop_.Initialize(drm, kCrtcPropName, plane_props) && |
| 104 fb_prop_.Initialize(drm, kFbPropName, plane_props) && | 112 fb_prop_.Initialize(drm, kFbPropName, plane_props) && |
| 105 crtc_x_prop_.Initialize(drm, kCrtcXPropName, plane_props) && | 113 crtc_x_prop_.Initialize(drm, kCrtcXPropName, plane_props) && |
| 106 crtc_y_prop_.Initialize(drm, kCrtcYPropName, plane_props) && | 114 crtc_y_prop_.Initialize(drm, kCrtcYPropName, plane_props) && |
| 107 crtc_w_prop_.Initialize(drm, kCrtcWPropName, plane_props) && | 115 crtc_w_prop_.Initialize(drm, kCrtcWPropName, plane_props) && |
| 108 crtc_h_prop_.Initialize(drm, kCrtcHPropName, plane_props) && | 116 crtc_h_prop_.Initialize(drm, kCrtcHPropName, plane_props) && |
| 109 src_x_prop_.Initialize(drm, kSrcXPropName, plane_props) && | 117 src_x_prop_.Initialize(drm, kSrcXPropName, plane_props) && |
| 110 src_y_prop_.Initialize(drm, kSrcYPropName, plane_props) && | 118 src_y_prop_.Initialize(drm, kSrcYPropName, plane_props) && |
| 111 src_w_prop_.Initialize(drm, kSrcWPropName, plane_props) && | 119 src_w_prop_.Initialize(drm, kSrcWPropName, plane_props) && |
| 112 src_h_prop_.Initialize(drm, kSrcHPropName, plane_props); | 120 src_h_prop_.Initialize(drm, kSrcHPropName, plane_props); |
| 113 | 121 |
| 114 if (!props_init) { | 122 if (!props_init) { |
| 115 LOG(ERROR) << "Unable to get plane properties."; | 123 LOG(ERROR) << "Unable to get plane properties."; |
| 116 return false; | 124 return false; |
| 117 } | 125 } |
| 118 | 126 |
| 119 supported_formats_ = formats; | 127 supported_formats_ = formats; |
| 120 if (is_dummy()) | 128 |
| 121 supported_formats_.push_back(DRM_FORMAT_XRGB8888); | 129 for (uint32_t i = 0; i < plane_props->count_props; i++) { |
| 130 ScopedDrmPropertyPtr property( | |
| 131 drmModeGetProperty(drm->get_fd(), plane_props->props[i])); | |
| 132 if (property && !strcmp(property->name, kTypePropName)) { | |
| 133 int value = plane_props->prop_values[i]; | |
| 134 switch (value) { | |
|
dnicoara
2015/08/20 14:22:46
Could you please split this in a helper function?
kalyank
2015/08/20 16:36:18
Done.
| |
| 135 case DRM_PLANE_TYPE_CURSOR: | |
| 136 type_ = Cursor; | |
| 137 break; | |
| 138 case DRM_PLANE_TYPE_PRIMARY: | |
| 139 type_ = Primary; | |
| 140 break; | |
| 141 case DRM_PLANE_TYPE_OVERLAY: | |
| 142 type_ = Overlay; | |
| 143 break; | |
| 144 default: | |
| 145 break; | |
| 146 } | |
| 147 break; | |
| 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 |