| Index: ui/display/chromeos/x11/display_util.cc
|
| diff --git a/chromeos/display/output_util.cc b/ui/display/chromeos/x11/display_util.cc
|
| similarity index 71%
|
| rename from chromeos/display/output_util.cc
|
| rename to ui/display/chromeos/x11/display_util.cc
|
| index a1485b4d28dc1024d3616be33c64b878e17503d3..72457b1a1d3d60e8c039429deb628770ab5539c8 100644
|
| --- a/chromeos/display/output_util.cc
|
| +++ b/ui/display/chromeos/x11/display_util.cc
|
| @@ -1,23 +1,36 @@
|
| -// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// 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 "chromeos/display/output_util.h"
|
| +#include "ui/display/chromeos/x11/display_util.h"
|
|
|
| #include <X11/extensions/Xrandr.h>
|
| #include <X11/Xatom.h>
|
| #include <X11/Xlib.h>
|
|
|
| +#include "base/macros.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/x11/edid_parser_x11.h"
|
|
|
| -namespace chromeos {
|
| +namespace ui {
|
| +
|
| namespace {
|
|
|
| -// Prefixes for the built-in displays.
|
| -const char kInternal_LVDS[] = "LVDS";
|
| -const char kInternal_eDP[] = "eDP";
|
| -const char kInternal_DSI[] = "DSI";
|
| +struct OutputTypeMapping {
|
| + // Prefix of output name.
|
| + std::string name;
|
| + OutputType type;
|
| +};
|
| +
|
| +const OutputTypeMapping kOutputTypeMapping[] = {
|
| + {"LVDS", OUTPUT_TYPE_INTERNAL},
|
| + {"eDP", OUTPUT_TYPE_INTERNAL},
|
| + {"DSI", OUTPUT_TYPE_INTERNAL},
|
| + {"VGA", OUTPUT_TYPE_VGA},
|
| + {"HDMI", OUTPUT_TYPE_HDMI},
|
| + {"DVI", OUTPUT_TYPE_DVI},
|
| + {"DP", OUTPUT_TYPE_DISPLAYPORT}
|
| +};
|
|
|
| // Gets some useful data from the specified output device, such like
|
| // manufacturer's ID, product code, and human readable name. Returns false if it
|
| @@ -27,7 +40,7 @@ bool GetOutputDeviceData(XID output,
|
| uint16* manufacturer_id,
|
| std::string* human_readable_name) {
|
| unsigned long nitems = 0;
|
| - unsigned char *prop = NULL;
|
| + unsigned char* prop = NULL;
|
| if (!base::GetEDIDProperty(output, &nitems, &prop))
|
| return false;
|
|
|
| @@ -39,16 +52,27 @@ bool GetOutputDeviceData(XID output,
|
|
|
| } // namespace
|
|
|
| -std::string GetDisplayName(XID output_id) {
|
| +OutputType GetOutputTypeFromName(const std::string& name) {
|
| + for (unsigned int i = 0; i < arraysize(kOutputTypeMapping); ++i) {
|
| + if (name.find(kOutputTypeMapping[i].name) == 0) {
|
| + return kOutputTypeMapping[i].type;
|
| + }
|
| + }
|
| +
|
| + return OUTPUT_TYPE_UNKNOWN;
|
| +}
|
| +
|
| +std::string GetDisplayName(const OutputConfigurator::OutputSnapshot& output) {
|
| std::string display_name;
|
| - GetOutputDeviceData(output_id, NULL, &display_name);
|
| + GetOutputDeviceData(output.output, NULL, &display_name);
|
| return display_name;
|
| }
|
|
|
| -bool GetOutputOverscanFlag(XID output, bool* flag) {
|
| +bool GetOutputOverscanFlag(const OutputConfigurator::OutputSnapshot& output,
|
| + bool* flag) {
|
| unsigned long nitems = 0;
|
| - unsigned char *prop = NULL;
|
| - if (!base::GetEDIDProperty(output, &nitems, &prop))
|
| + unsigned char* prop = NULL;
|
| + if (!base::GetEDIDProperty(output.output, &nitems, &prop))
|
| return false;
|
|
|
| bool found = ParseOutputOverscanFlag(prop, nitems, flag);
|
| @@ -58,7 +82,7 @@ bool GetOutputOverscanFlag(XID output, bool* flag) {
|
|
|
| bool ParseOutputOverscanFlag(const unsigned char* prop,
|
| unsigned long nitems,
|
| - bool *flag) {
|
| + bool* flag) {
|
| // See http://en.wikipedia.org/wiki/Extended_display_identification_data
|
| // for the extension format of EDID. Also see EIA/CEA-861 spec for
|
| // the format of the extensions and how video capability is encoded.
|
| @@ -135,42 +159,4 @@ bool ParseOutputOverscanFlag(const unsigned char* prop,
|
| return false;
|
| }
|
|
|
| -bool IsInternalOutputName(const std::string& name) {
|
| - return name.find(kInternal_LVDS) == 0 || name.find(kInternal_eDP) == 0 ||
|
| - name.find(kInternal_DSI) == 0;
|
| -}
|
| -
|
| -const XRRModeInfo* FindXRRModeInfo(const XRRScreenResources* screen_resources,
|
| - XID current_mode) {
|
| - for (int m = 0; m < screen_resources->nmode; m++) {
|
| - XRRModeInfo *mode = &screen_resources->modes[m];
|
| - if (mode->id == current_mode)
|
| - return mode;
|
| - }
|
| - return NULL;
|
| -}
|
| -
|
| -namespace test {
|
| -
|
| -XRRModeInfo CreateModeInfo(int id,
|
| - int width,
|
| - int height,
|
| - bool interlaced,
|
| - float refresh_rate) {
|
| - XRRModeInfo mode_info = {0};
|
| - mode_info.id = id;
|
| - mode_info.width = width;
|
| - mode_info.height = height;
|
| - if (interlaced)
|
| - mode_info.modeFlags = RR_Interlace;
|
| - if (refresh_rate != 0.0f) {
|
| - mode_info.hTotal = 1;
|
| - mode_info.vTotal = 1;
|
| - mode_info.dotClock = refresh_rate;
|
| - }
|
| - return mode_info;
|
| -}
|
| -
|
| -} // namespace test
|
| -
|
| -} // namespace chromeos
|
| +} // namespace ui
|
|
|