Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: ui/ozone/platform/dri/display_snapshot_dri.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/dri/display_snapshot_dri.h ('k') | ui/ozone/platform/dri/dri.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/ozone/platform/dri/display_snapshot_dri.h"
6
7 #include <stdint.h>
8 #include <stdlib.h>
9 #include <xf86drmMode.h>
10
11 #include "base/format_macros.h"
12 #include "base/logging.h"
13 #include "base/strings/stringprintf.h"
14 #include "ui/display/util/edid_parser.h"
15 #include "ui/ozone/platform/dri/display_mode_dri.h"
16 #include "ui/ozone/platform/dri/dri_util.h"
17 #include "ui/ozone/platform/dri/dri_wrapper.h"
18
19 namespace ui {
20
21 namespace {
22
23 DisplayConnectionType GetDisplayType(drmModeConnector* connector) {
24 switch (connector->connector_type) {
25 case DRM_MODE_CONNECTOR_VGA:
26 return DISPLAY_CONNECTION_TYPE_VGA;
27 case DRM_MODE_CONNECTOR_DVII:
28 case DRM_MODE_CONNECTOR_DVID:
29 case DRM_MODE_CONNECTOR_DVIA:
30 return DISPLAY_CONNECTION_TYPE_DVI;
31 case DRM_MODE_CONNECTOR_LVDS:
32 case DRM_MODE_CONNECTOR_eDP:
33 return DISPLAY_CONNECTION_TYPE_INTERNAL;
34 case DRM_MODE_CONNECTOR_DisplayPort:
35 return DISPLAY_CONNECTION_TYPE_DISPLAYPORT;
36 case DRM_MODE_CONNECTOR_HDMIA:
37 case DRM_MODE_CONNECTOR_HDMIB:
38 return DISPLAY_CONNECTION_TYPE_HDMI;
39 default:
40 return DISPLAY_CONNECTION_TYPE_UNKNOWN;
41 }
42 }
43
44 bool IsAspectPreserving(DriWrapper* drm, drmModeConnector* connector) {
45 ScopedDrmPropertyPtr property(drm->GetProperty(connector, "scaling mode"));
46 if (!property)
47 return false;
48
49 for (int props_i = 0; props_i < connector->count_props; ++props_i) {
50 if (connector->props[props_i] != property->prop_id)
51 continue;
52
53 for (int enums_i = 0; enums_i < property->count_enums; ++enums_i) {
54 if (property->enums[enums_i].value == connector->prop_values[props_i] &&
55 strcmp(property->enums[enums_i].name, "Full aspect") == 0)
56 return true;
57 }
58 }
59
60 return false;
61 }
62
63 } // namespace
64
65 DisplaySnapshotDri::DisplaySnapshotDri(DriWrapper* drm,
66 drmModeConnector* connector,
67 drmModeCrtc* crtc,
68 uint32_t index)
69 : DisplaySnapshot(index,
70 false,
71 gfx::Point(crtc->x, crtc->y),
72 gfx::Size(connector->mmWidth, connector->mmHeight),
73 GetDisplayType(connector),
74 IsAspectPreserving(drm, connector),
75 false,
76 std::string(),
77 std::vector<const DisplayMode*>(),
78 NULL,
79 NULL),
80 connector_(connector->connector_id),
81 crtc_(crtc->crtc_id),
82 dpms_property_(drm->GetProperty(connector, "DPMS")) {
83 if (!dpms_property_)
84 VLOG(1) << "Failed to find the DPMS property for connector "
85 << connector->connector_id;
86
87 ScopedDrmPropertyBlobPtr edid_blob(drm->GetPropertyBlob(connector, "EDID"));
88
89 if (edid_blob) {
90 std::vector<uint8_t> edid(
91 static_cast<uint8_t*>(edid_blob->data),
92 static_cast<uint8_t*>(edid_blob->data) + edid_blob->length);
93
94 has_proper_display_id_ = GetDisplayIdFromEDID(edid, index, &display_id_);
95 ParseOutputDeviceData(edid, NULL, &display_name_);
96 ParseOutputOverscanFlag(edid, &overscan_flag_);
97 } else {
98 VLOG(1) << "Failed to get EDID blob for connector "
99 << connector->connector_id;
100 }
101
102 for (int i = 0; i < connector->count_modes; ++i) {
103 drmModeModeInfo& mode = connector->modes[i];
104 modes_.push_back(new DisplayModeDri(mode));
105
106 if (crtc->mode_valid && SameMode(crtc->mode, mode))
107 current_mode_ = modes_.back();
108
109 if (mode.type & DRM_MODE_TYPE_PREFERRED)
110 native_mode_ = modes_.back();
111 }
112
113 // If no preferred mode is found then use the first one. Using the first one
114 // since it should be the best mode.
115 if (!native_mode_ && !modes_.empty())
116 native_mode_ = modes_.front();
117 }
118
119 DisplaySnapshotDri::~DisplaySnapshotDri() {
120 }
121
122 std::string DisplaySnapshotDri::ToString() const {
123 return base::StringPrintf(
124 "[type=%d, connector=%" PRIu32 ", crtc=%" PRIu32 ", mode=%s, dim=%s]",
125 type_,
126 connector_,
127 crtc_,
128 current_mode_ ? current_mode_->ToString().c_str() : "NULL",
129 physical_size_.ToString().c_str());
130 }
131
132 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/display_snapshot_dri.h ('k') | ui/ozone/platform/dri/dri.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698