summaryrefslogtreecommitdiffstats
path: root/ui/ozone/platform/drm/gpu/drm_display_snapshot.cc
diff options
context:
space:
mode:
authordnicoara <dnicoara@chromium.org>2015-03-05 12:46:18 -0800
committerCommit bot <commit-bot@chromium.org>2015-03-05 20:47:08 +0000
commit171d8c892da1b2e38f90c17b62896ba82f0719e3 (patch)
tree9fe2810948b2d8dfd73cd7a5afa002dcf79c0547 /ui/ozone/platform/drm/gpu/drm_display_snapshot.cc
parentf36607f2398cb4aa9b50449b1221bbc72e3f3453 (diff)
downloadchromium_src-171d8c892da1b2e38f90c17b62896ba82f0719e3.zip
chromium_src-171d8c892da1b2e38f90c17b62896ba82f0719e3.tar.gz
chromium_src-171d8c892da1b2e38f90c17b62896ba82f0719e3.tar.bz2
[Ozone] Rename and split the DRI platform for clarity
This CL does the following: - Moves the files in ui/ozone/platform/dri to ui/ozone/platform/drm since the platform name should really be DRM rather than DRI. Note, that the platform is still refered to as "dri" in GYP/GN since CrOS builds are still using the 'dri' name. - Rename all files with a "_dri*" suffix to a "drm_" prefix. Also rename all files with a "dri_" prefix to a "drm_" prefix. - Rename NativeDisplayDelegateDri to DrmDisplayDelegateManager since it is no longer dependent on the NativeDisplayDelegate interface and the new name better describes its intent. - Split the files in the platform into 2 sub-folders ("host" and "gpu"). Depending on the intended use place of the objects (Browser (host) process or GPU process) the files in the platform are split accordingly in the 2 sub-folders. BUG=none TBR=jam@chromium.org Review URL: https://codereview.chromium.org/975063002 Cr-Commit-Position: refs/heads/master@{#319320}
Diffstat (limited to 'ui/ozone/platform/drm/gpu/drm_display_snapshot.cc')
-rw-r--r--ui/ozone/platform/drm/gpu/drm_display_snapshot.cc138
1 files changed, 138 insertions, 0 deletions
diff --git a/ui/ozone/platform/drm/gpu/drm_display_snapshot.cc b/ui/ozone/platform/drm/gpu/drm_display_snapshot.cc
new file mode 100644
index 0000000..96e0a2f
--- /dev/null
+++ b/ui/ozone/platform/drm/gpu/drm_display_snapshot.cc
@@ -0,0 +1,138 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/platform/drm/gpu/drm_display_snapshot.h"
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <xf86drmMode.h>
+
+#include "base/format_macros.h"
+#include "base/logging.h"
+#include "base/strings/stringprintf.h"
+#include "ui/display/util/edid_parser.h"
+#include "ui/ozone/platform/drm/gpu/drm_device.h"
+#include "ui/ozone/platform/drm/gpu/drm_display_mode.h"
+#include "ui/ozone/platform/drm/gpu/drm_util.h"
+
+#if !defined(DRM_MODE_CONNECTOR_DSI)
+#define DRM_MODE_CONNECTOR_DSI 16
+#endif
+
+namespace ui {
+
+namespace {
+
+DisplayConnectionType GetDisplayType(drmModeConnector* connector) {
+ switch (connector->connector_type) {
+ case DRM_MODE_CONNECTOR_VGA:
+ return DISPLAY_CONNECTION_TYPE_VGA;
+ case DRM_MODE_CONNECTOR_DVII:
+ case DRM_MODE_CONNECTOR_DVID:
+ case DRM_MODE_CONNECTOR_DVIA:
+ return DISPLAY_CONNECTION_TYPE_DVI;
+ case DRM_MODE_CONNECTOR_LVDS:
+ case DRM_MODE_CONNECTOR_eDP:
+ case DRM_MODE_CONNECTOR_DSI:
+ return DISPLAY_CONNECTION_TYPE_INTERNAL;
+ case DRM_MODE_CONNECTOR_DisplayPort:
+ return DISPLAY_CONNECTION_TYPE_DISPLAYPORT;
+ case DRM_MODE_CONNECTOR_HDMIA:
+ case DRM_MODE_CONNECTOR_HDMIB:
+ return DISPLAY_CONNECTION_TYPE_HDMI;
+ default:
+ return DISPLAY_CONNECTION_TYPE_UNKNOWN;
+ }
+}
+
+bool IsAspectPreserving(DrmDevice* drm, drmModeConnector* connector) {
+ ScopedDrmPropertyPtr property(drm->GetProperty(connector, "scaling mode"));
+ if (!property)
+ return false;
+
+ for (int props_i = 0; props_i < connector->count_props; ++props_i) {
+ if (connector->props[props_i] != property->prop_id)
+ continue;
+
+ for (int enums_i = 0; enums_i < property->count_enums; ++enums_i) {
+ if (property->enums[enums_i].value == connector->prop_values[props_i] &&
+ strcmp(property->enums[enums_i].name, "Full aspect") == 0)
+ return true;
+ }
+ }
+
+ return false;
+}
+
+} // namespace
+
+DrmDisplaySnapshot::DrmDisplaySnapshot(const scoped_refptr<DrmDevice>& drm,
+ drmModeConnector* connector,
+ drmModeCrtc* crtc,
+ uint32_t index)
+ : DisplaySnapshot(index,
+ gfx::Point(crtc->x, crtc->y),
+ gfx::Size(connector->mmWidth, connector->mmHeight),
+ GetDisplayType(connector),
+ IsAspectPreserving(drm.get(), connector),
+ false,
+ std::string(),
+ std::vector<const DisplayMode*>(),
+ nullptr,
+ nullptr),
+ drm_(drm),
+ connector_(connector->connector_id),
+ crtc_(crtc->crtc_id),
+ dpms_property_(drm->GetProperty(connector, "DPMS")) {
+ if (!dpms_property_)
+ VLOG(1) << "Failed to find the DPMS property for connector "
+ << connector->connector_id;
+
+ ScopedDrmPropertyBlobPtr edid_blob(drm->GetPropertyBlob(connector, "EDID"));
+
+ if (edid_blob) {
+ std::vector<uint8_t> edid(
+ static_cast<uint8_t*>(edid_blob->data),
+ static_cast<uint8_t*>(edid_blob->data) + edid_blob->length);
+
+ if (!GetDisplayIdFromEDID(edid, index, &display_id_))
+ display_id_ = index;
+
+ ParseOutputDeviceData(edid, nullptr, &display_name_, nullptr, nullptr);
+ ParseOutputOverscanFlag(edid, &overscan_flag_);
+ } else {
+ VLOG(1) << "Failed to get EDID blob for connector "
+ << connector->connector_id;
+ }
+
+ for (int i = 0; i < connector->count_modes; ++i) {
+ drmModeModeInfo& mode = connector->modes[i];
+ modes_.push_back(new DrmDisplayMode(mode));
+
+ if (crtc->mode_valid && SameMode(crtc->mode, mode))
+ current_mode_ = modes_.back();
+
+ if (mode.type & DRM_MODE_TYPE_PREFERRED)
+ native_mode_ = modes_.back();
+ }
+
+ // If no preferred mode is found then use the first one. Using the first one
+ // since it should be the best mode.
+ if (!native_mode_ && !modes_.empty())
+ native_mode_ = modes_.front();
+}
+
+DrmDisplaySnapshot::~DrmDisplaySnapshot() {
+}
+
+std::string DrmDisplaySnapshot::ToString() const {
+ return base::StringPrintf(
+ "[type=%d, connector=%" PRIu32 ", crtc=%" PRIu32
+ ", origin=%s, mode=%s, dim=%s]",
+ type_, connector_, crtc_, origin_.ToString().c_str(),
+ current_mode_ ? current_mode_->ToString().c_str() : "NULL",
+ physical_size_.ToString().c_str());
+}
+
+} // namespace ui