Commit f8d98030 authored by dnicoara's avatar dnicoara Committed by Commit bot

[Ozone-Drm] Refactor GPU display management

This change decouples the DisplaySnapshot from the DrmDisplay since the
snapshot is only needed to IPC the display information to the browser
process. Also, move all the display configuration calls into the
DrmDisplay object to simplify state and clarify the intent of the
operations.

This change also moves the logic to parse the DRM display state into
DisplaySnapshot objects into a common location intended to be used by
both GPU and Browser processes. The parsing logic will be used in a
subsequent change to allow proper parsing of display configuration on
the browser side during startup.

BUG=484294

Review URL: https://codereview.chromium.org/1129923004

Cr-Commit-Position: refs/heads/master@{#329462}
parent eece86a3
...@@ -35,10 +35,8 @@ source_set("drm_common") { ...@@ -35,10 +35,8 @@ source_set("drm_common") {
"gpu/drm_device_generator.h", "gpu/drm_device_generator.h",
"gpu/drm_device_manager.cc", "gpu/drm_device_manager.cc",
"gpu/drm_device_manager.h", "gpu/drm_device_manager.h",
"gpu/drm_display_mode.cc", "gpu/drm_display.cc",
"gpu/drm_display_mode.h", "gpu/drm_display.h",
"gpu/drm_display_snapshot.cc",
"gpu/drm_display_snapshot.h",
"gpu/drm_gpu_display_manager.cc", "gpu/drm_gpu_display_manager.cc",
"gpu/drm_gpu_display_manager.h", "gpu/drm_gpu_display_manager.h",
"gpu/drm_gpu_platform_support.cc", "gpu/drm_gpu_platform_support.cc",
......
...@@ -9,6 +9,12 @@ ...@@ -9,6 +9,12 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <xf86drmMode.h> #include <xf86drmMode.h>
#include "ui/display/util/edid_parser.h"
#if !defined(DRM_MODE_CONNECTOR_DSI)
#define DRM_MODE_CONNECTOR_DSI 16
#endif
namespace ui { namespace ui {
namespace { namespace {
...@@ -53,6 +59,96 @@ uint32_t GetCrtc(int fd, ...@@ -53,6 +59,96 @@ uint32_t GetCrtc(int fd,
return 0; return 0;
} }
// Computes the refresh rate for the specific mode. If we have enough
// information use the mode timings to compute a more exact value otherwise
// fallback to using the mode's vertical refresh rate (the kernel computes this
// the same way, however there is a loss in precision since |vrefresh| is sent
// as an integer).
float GetRefreshRate(const drmModeModeInfo& mode) {
if (!mode.htotal || !mode.vtotal)
return mode.vrefresh;
float clock = mode.clock;
float htotal = mode.htotal;
float vtotal = mode.vtotal;
return (clock * 1000.0f) / (htotal * vtotal);
}
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;
}
}
int GetDrmProperty(int fd,
drmModeConnector* connector,
const std::string& name,
ScopedDrmPropertyPtr* property) {
for (int i = 0; i < connector->count_props; ++i) {
ScopedDrmPropertyPtr tmp(drmModeGetProperty(fd, connector->props[i]));
if (!tmp)
continue;
if (name == tmp->name) {
*property = tmp.Pass();
return i;
}
}
return -1;
}
std::string GetNameForEnumValue(drmModePropertyRes* property, uint32_t value) {
for (int i = 0; i < property->count_enums; ++i)
if (property->enums[i].value == value)
return property->enums[i].name;
return std::string();
}
ScopedDrmPropertyBlobPtr GetDrmPropertyBlob(int fd,
drmModeConnector* connector,
const std::string& name) {
ScopedDrmPropertyPtr property;
int index = GetDrmProperty(fd, connector, name, &property);
if (index < 0)
return nullptr;
if (property->flags & DRM_MODE_PROP_BLOB) {
return ScopedDrmPropertyBlobPtr(
drmModeGetPropertyBlob(fd, connector->prop_values[index]));
}
return nullptr;
}
bool IsAspectPreserving(int fd, drmModeConnector* connector) {
ScopedDrmPropertyPtr property;
int index = GetDrmProperty(fd, connector, "scaling mode", &property);
if (index < 0)
return false;
return (GetNameForEnumValue(property.get(), connector->prop_values[index]) ==
"Full aspect");
}
} // namespace } // namespace
HardwareDisplayControllerInfo::HardwareDisplayControllerInfo( HardwareDisplayControllerInfo::HardwareDisplayControllerInfo(
...@@ -100,4 +196,69 @@ bool SameMode(const drmModeModeInfo& lhs, const drmModeModeInfo& rhs) { ...@@ -100,4 +196,69 @@ bool SameMode(const drmModeModeInfo& lhs, const drmModeModeInfo& rhs) {
lhs.flags == rhs.flags && strcmp(lhs.name, rhs.name) == 0; lhs.flags == rhs.flags && strcmp(lhs.name, rhs.name) == 0;
} }
DisplayMode_Params CreateDisplayModeParams(const drmModeModeInfo& mode) {
DisplayMode_Params params;
params.size = gfx::Size(mode.hdisplay, mode.vdisplay);
params.is_interlaced = mode.flags & DRM_MODE_FLAG_INTERLACE;
params.refresh_rate = GetRefreshRate(mode);
return params;
}
DisplaySnapshot_Params CreateDisplaySnapshotParams(
HardwareDisplayControllerInfo* info,
int fd,
size_t display_index) {
DisplaySnapshot_Params params;
params.display_id = display_index;
params.physical_size =
gfx::Size(info->connector()->mmWidth, info->connector()->mmHeight);
params.type = GetDisplayType(info->connector());
params.is_aspect_preserving_scaling =
IsAspectPreserving(fd, info->connector());
ScopedDrmPropertyBlobPtr edid_blob(
GetDrmPropertyBlob(fd, info->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, display_index, &params.display_id))
params.display_id = display_index;
ParseOutputDeviceData(edid, nullptr, &params.display_name, nullptr,
nullptr);
ParseOutputOverscanFlag(edid, &params.has_overscan);
} else {
VLOG(1) << "Failed to get EDID blob for connector "
<< info->connector()->connector_id;
}
for (int i = 0; i < info->connector()->count_modes; ++i) {
const drmModeModeInfo& mode = info->connector()->modes[i];
params.modes.push_back(CreateDisplayModeParams(mode));
if (info->crtc()->mode_valid && SameMode(info->crtc()->mode, mode)) {
params.has_current_mode = true;
params.current_mode = params.modes.back();
}
if (mode.type & DRM_MODE_TYPE_PREFERRED) {
params.has_native_mode = true;
params.native_mode = params.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 (!params.has_native_mode && !params.modes.empty()) {
params.has_native_mode = true;
params.native_mode = params.modes.front();
}
return params;
}
} // namespace ui } // namespace ui
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_vector.h" #include "base/memory/scoped_vector.h"
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/platform/drm/common/scoped_drm_types.h" #include "ui/ozone/platform/drm/common/scoped_drm_types.h"
typedef struct _drmModeModeInfo drmModeModeInfo; typedef struct _drmModeModeInfo drmModeModeInfo;
...@@ -39,6 +40,17 @@ ScopedVector<HardwareDisplayControllerInfo> GetAvailableDisplayControllerInfos( ...@@ -39,6 +40,17 @@ ScopedVector<HardwareDisplayControllerInfo> GetAvailableDisplayControllerInfos(
bool SameMode(const drmModeModeInfo& lhs, const drmModeModeInfo& rhs); bool SameMode(const drmModeModeInfo& lhs, const drmModeModeInfo& rhs);
DisplayMode_Params CreateDisplayModeParams(const drmModeModeInfo& mode);
// |info| provides the DRM information related to the display, |fd| is the
// connection to the DRM device and |index| provides a unique identifier for the
// display. |index| will be used to generate the display id (it may be the id if
// the monitor's EDID lacks the necessary identifiers).
DisplaySnapshot_Params CreateDisplaySnapshotParams(
HardwareDisplayControllerInfo* info,
int fd,
size_t display_index);
} // namespace ui } // namespace ui
#endif // UI_OZONE_PLATFORM_DRM_COMMON_DRM_UTIL_H_ #endif // UI_OZONE_PLATFORM_DRM_COMMON_DRM_UTIL_H_
...@@ -57,10 +57,8 @@ ...@@ -57,10 +57,8 @@
'gpu/drm_device_generator.h', 'gpu/drm_device_generator.h',
'gpu/drm_device_manager.cc', 'gpu/drm_device_manager.cc',
'gpu/drm_device_manager.h', 'gpu/drm_device_manager.h',
'gpu/drm_display_mode.cc', 'gpu/drm_display.cc',
'gpu/drm_display_mode.h', 'gpu/drm_display.h',
'gpu/drm_display_snapshot.cc',
'gpu/drm_display_snapshot.h',
'gpu/drm_gpu_display_manager.cc', 'gpu/drm_gpu_display_manager.cc',
'gpu/drm_gpu_display_manager.h', 'gpu/drm_gpu_display_manager.h',
'gpu/drm_gpu_platform_support.cc', 'gpu/drm_gpu_platform_support.cc',
......
// Copyright 2015 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.h"
#include <xf86drmMode.h>
#include "ui/display/types/gamma_ramp_rgb_entry.h"
#include "ui/ozone/platform/drm/common/drm_util.h"
#include "ui/ozone/platform/drm/gpu/drm_device.h"
#include "ui/ozone/platform/drm/gpu/screen_manager.h"
namespace ui {
namespace {
const char kContentProtection[] = "Content Protection";
struct ContentProtectionMapping {
const char* name;
HDCPState state;
};
const ContentProtectionMapping kContentProtectionStates[] = {
{"Undesired", HDCP_STATE_UNDESIRED},
{"Desired", HDCP_STATE_DESIRED},
{"Enabled", HDCP_STATE_ENABLED}};
// Converts |state| to the DRM value associated with the it.
uint32_t GetContentProtectionValue(drmModePropertyRes* property,
HDCPState state) {
std::string name;
for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) {
if (kContentProtectionStates[i].state == state) {
name = kContentProtectionStates[i].name;
break;
}
}
for (int i = 0; i < property->count_enums; ++i)
if (name == property->enums[i].name)
return i;
NOTREACHED();
return 0;
}
std::string GetEnumNameForProperty(drmModeConnector* connector,
drmModePropertyRes* property) {
for (int prop_idx = 0; prop_idx < connector->count_props; ++prop_idx) {
if (connector->props[prop_idx] != property->prop_id)
continue;
for (int enum_idx = 0; enum_idx < property->count_enums; ++enum_idx) {
const drm_mode_property_enum& property_enum = property->enums[enum_idx];
if (property_enum.value == connector->prop_values[prop_idx])
return property_enum.name;
}
}
NOTREACHED();
return std::string();
}
gfx::Size GetDrmModeSize(const drmModeModeInfo& mode) {
return gfx::Size(mode.hdisplay, mode.vdisplay);
}
} // namespace
DrmDisplay::DrmDisplay(ScreenManager* screen_manager,
int64_t display_id,
const scoped_refptr<DrmDevice>& drm,
uint32_t crtc,
uint32_t connector,
const std::vector<drmModeModeInfo>& modes)
: screen_manager_(screen_manager),
display_id_(display_id),
drm_(drm),
crtc_(crtc),
connector_(connector),
modes_(modes) {
}
DrmDisplay::~DrmDisplay() {
}
bool DrmDisplay::Configure(const drmModeModeInfo* mode,
const gfx::Point& origin) {
VLOG(1) << "DRM configuring: device=" << drm_->device_path().value()
<< " crtc=" << crtc_ << " connector=" << connector_
<< " origin=" << origin.ToString()
<< " size=" << (mode ? GetDrmModeSize(*mode).ToString() : "0x0");
if (mode) {
if (!screen_manager_->ConfigureDisplayController(drm_, crtc_, connector_,
origin, *mode)) {
VLOG(1) << "Failed to configure: device=" << drm_->device_path().value()
<< " crtc=" << crtc_ << " connector=" << connector_;
return false;
}
} else {
if (!screen_manager_->DisableDisplayController(drm_, crtc_)) {
VLOG(1) << "Failed to disable device=" << drm_->device_path().value()
<< " crtc=" << crtc_;
return false;
}
}
return true;
}
bool DrmDisplay::GetHDCPState(HDCPState* state) {
ScopedDrmConnectorPtr connector(drm_->GetConnector(connector_));
if (!connector) {
PLOG(ERROR) << "Failed to get connector " << connector_;
return false;
}
ScopedDrmPropertyPtr hdcp_property(
drm_->GetProperty(connector.get(), kContentProtection));
if (!hdcp_property) {
PLOG(ERROR) << "'" << kContentProtection << "' property doesn't exist.";
return false;
}
std::string name =
GetEnumNameForProperty(connector.get(), hdcp_property.get());
for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) {
if (name == kContentProtectionStates[i].name) {
*state = kContentProtectionStates[i].state;
VLOG(3) << "HDCP state: " << *state << " (" << name << ")";
return true;
}
}
LOG(ERROR) << "Unknown content protection value '" << name << "'";
return false;
}
bool DrmDisplay::SetHDCPState(HDCPState state) {
ScopedDrmConnectorPtr connector(drm_->GetConnector(connector_));
if (!connector) {
PLOG(ERROR) << "Failed to get connector " << connector_;
return false;
}
ScopedDrmPropertyPtr hdcp_property(
drm_->GetProperty(connector.get(), kContentProtection));
if (!hdcp_property) {
LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist.";
return false;
}
return drm_->SetProperty(
connector_, hdcp_property->prop_id,
GetContentProtectionValue(hdcp_property.get(), state));
}
void DrmDisplay::SetGammaRamp(const std::vector<GammaRampRGBEntry>& lut) {
if (!drm_->SetGammaRamp(crtc_, lut)) {
LOG(ERROR) << "Failed to set gamma ramp for display: crtc_id = " << crtc_
<< " size = " << lut.size();
}
}
} // namespace ui
// Copyright 2015 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.
#ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_DISPLAY_H_
#define UI_OZONE_PLATFORM_DRM_GPU_DRM_DISPLAY_H_
#include <vector>
#include "base/memory/ref_counted.h"
#include "ui/display/types/display_constants.h"
typedef struct _drmModeModeInfo drmModeModeInfo;
namespace gfx {
class Point;
}
namespace ui {
class DrmDevice;
class ScreenManager;
struct GammaRampRGBEntry;
class DrmDisplay {
public:
DrmDisplay(ScreenManager* screen_manager,
int64_t display_id,
const scoped_refptr<DrmDevice>& drm,
uint32_t crtc,
uint32_t connector,
const std::vector<drmModeModeInfo>& modes);
~DrmDisplay();
int64_t display_id() const { return display_id_; }
scoped_refptr<DrmDevice> drm() const { return drm_; }
uint32_t crtc() const { return crtc_; }
uint32_t connector() const { return connector_; }
const std::vector<drmModeModeInfo>& modes() const { return modes_; }
bool Configure(const drmModeModeInfo* mode, const gfx::Point& origin);
bool GetHDCPState(HDCPState* state);
bool SetHDCPState(HDCPState state);
void SetGammaRamp(const std::vector<GammaRampRGBEntry>& lut);
private:
ScreenManager* screen_manager_; // Not owned.
int64_t display_id_;
scoped_refptr<DrmDevice> drm_;
uint32_t crtc_;
uint32_t connector_;
std::vector<drmModeModeInfo> modes_;
DISALLOW_COPY_AND_ASSIGN(DrmDisplay);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DISPLAY_H_
// 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_mode.h"
namespace ui {
namespace {
float GetRefreshRate(const drmModeModeInfo& mode) {
if (!mode.htotal || !mode.vtotal)
return mode.vrefresh;
float clock = mode.clock;
float htotal = mode.htotal;
float vtotal = mode.vtotal;
return (clock * 1000.0f) / (htotal * vtotal);
}
} // namespace
DrmDisplayMode::DrmDisplayMode(const drmModeModeInfo& mode)
: DisplayMode(gfx::Size(mode.hdisplay, mode.vdisplay),
mode.flags & DRM_MODE_FLAG_INTERLACE,
GetRefreshRate(mode)),
mode_info_(mode) {
}
DrmDisplayMode::~DrmDisplayMode() {
}
} // namespace ui
// 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.
#ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_DISPLAY_MODE_H_
#define UI_OZONE_PLATFORM_DRM_GPU_DRM_DISPLAY_MODE_H_
#include <stdint.h>
#include <stdlib.h>
#include <xf86drmMode.h>
#include "ui/display/types/display_mode.h"
namespace ui {
class DrmDisplayMode : public DisplayMode {
public:
DrmDisplayMode(const drmModeModeInfo& mode);
~DrmDisplayMode() override;
// Native details about this mode. Only used internally in the DRM
// implementation.
drmModeModeInfo mode_info() const { return mode_info_; }
private:
drmModeModeInfo mode_info_;
DISALLOW_COPY_AND_ASSIGN(DrmDisplayMode);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DISPLAY_MODE_H_
// 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/common/drm_util.h"
#include "ui/ozone/platform/drm/gpu/drm_device.h"
#include "ui/ozone/platform/drm/gpu/drm_display_mode.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) {
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
// 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.
#ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_DISPLAY_SNAPSHOT_H_
#define UI_OZONE_PLATFORM_DRM_GPU_DRM_DISPLAY_SNAPSHOT_H_
#include "base/memory/ref_counted.h"
#include "ui/display/types/display_snapshot.h"
#include "ui/ozone/platform/drm/common/scoped_drm_types.h"
namespace ui {
class DrmDevice;
class DrmDisplaySnapshot : public DisplaySnapshot {
public:
DrmDisplaySnapshot(const scoped_refptr<DrmDevice>& drm,
drmModeConnector* connector,
drmModeCrtc* crtc,
uint32_t index);
~DrmDisplaySnapshot() override;
scoped_refptr<DrmDevice> drm() const { return drm_; }
// Native properties of a display used by the DRM implementation in
// configuring this display.
uint32_t connector() const { return connector_; }
uint32_t crtc() const { return crtc_; }
// DisplaySnapshot overrides:
std::string ToString() const override;
private:
scoped_refptr<DrmDevice> drm_;
uint32_t connector_;
uint32_t crtc_;
std::string name_;
bool overscan_flag_;
DISALLOW_COPY_AND_ASSIGN(DrmDisplaySnapshot);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DISPLAY_SNAPSHOT_H_
...@@ -5,25 +5,13 @@ ...@@ -5,25 +5,13 @@
#ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_GPU_DISPLAY_MANAGER_H_ #ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_GPU_DISPLAY_MANAGER_H_
#define UI_OZONE_PLATFORM_DRM_GPU_DRM_GPU_DISPLAY_MANAGER_H_ #define UI_OZONE_PLATFORM_DRM_GPU_DRM_GPU_DISPLAY_MANAGER_H_
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h" #include "base/memory/scoped_vector.h"
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h" #include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
namespace base {
class FilePath;
class SingleThreadTaskRunner;
struct FileDescriptor;
}
namespace ui { namespace ui {
class DeviceManager;
class DisplayMode;
class DrmDevice;
class DrmDeviceManager; class DrmDeviceManager;
class DrmDisplaySnapshot; class DrmDisplay;
class DrmDisplayMode;
class ScreenManager; class ScreenManager;
struct GammaRampRGBEntry; struct GammaRampRGBEntry;
...@@ -34,58 +22,34 @@ class DrmGpuDisplayManager { ...@@ -34,58 +22,34 @@ class DrmGpuDisplayManager {
DrmDeviceManager* drm_device_manager); DrmDeviceManager* drm_device_manager);
~DrmGpuDisplayManager(); ~DrmGpuDisplayManager();
void InitializeIOTaskRunner(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
// Returns a list of the connected displays. When this is called the list of // Returns a list of the connected displays. When this is called the list of
// displays is refreshed. // displays is refreshed.
std::vector<DisplaySnapshot_Params> GetDisplays(); std::vector<DisplaySnapshot_Params> GetDisplays();
bool ConfigureDisplay(int64_t id,
const DisplayMode_Params& mode,
const gfx::Point& origin);
bool DisableDisplay(int64_t id);
// Takes/releases the control of the DRM devices. // Takes/releases the control of the DRM devices.
bool TakeDisplayControl(); bool TakeDisplayControl();
bool RelinquishDisplayControl(); bool RelinquishDisplayControl();
// Called on DRM hotplug events to add/remove a DRM device. bool ConfigureDisplay(int64_t id,
void AddGraphicsDevice(const base::FilePath& path, const DisplayMode_Params& mode,
const base::FileDescriptor& fd); const gfx::Point& origin);
void RemoveGraphicsDevice(const base::FilePath& path); bool DisableDisplay(int64_t id);
bool GetHDCPState(int64_t display_id, HDCPState* state); bool GetHDCPState(int64_t display_id, HDCPState* state);
bool SetHDCPState(int64_t display_id, HDCPState state); bool SetHDCPState(int64_t display_id, HDCPState state);
// Set the gamma ramp for a particular display id.
void SetGammaRamp(int64_t id, const std::vector<GammaRampRGBEntry>& lut); void SetGammaRamp(int64_t id, const std::vector<GammaRampRGBEntry>& lut);
private: private:
DrmDisplaySnapshot* FindDisplaySnapshot(int64_t id); DrmDisplay* FindDisplay(int64_t display_id);
const DrmDisplayMode* FindDisplayMode(const gfx::Size& size,
bool is_interlaced,
float refresh_rate);
void RefreshDisplayList();
bool Configure(const DrmDisplaySnapshot& output,
const DrmDisplayMode* mode,
const gfx::Point& origin);
// Notify ScreenManager of all the displays that were present before the // Notify ScreenManager of all the displays that were present before the
// update but are gone after the update. // update but are gone after the update.
void NotifyScreenManager( void NotifyScreenManager(const std::vector<DrmDisplay*>& new_displays,
const std::vector<DrmDisplaySnapshot*>& new_displays, const std::vector<DrmDisplay*>& old_displays) const;
const std::vector<DrmDisplaySnapshot*>& old_displays) const;
ScreenManager* screen_manager_; // Not owned. ScreenManager* screen_manager_; // Not owned.
DrmDeviceManager* drm_device_manager_; // Not owned. DrmDeviceManager* drm_device_manager_; // Not owned.
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
std::vector<scoped_refptr<DrmDevice>> devices_; ScopedVector<DrmDisplay> displays_;
// Modes can be shared between different displays, so we need to keep track
// of them independently for cleanup.
ScopedVector<const DisplayMode> cached_modes_;
ScopedVector<DrmDisplaySnapshot> cached_displays_;
DISALLOW_COPY_AND_ASSIGN(DrmGpuDisplayManager); DISALLOW_COPY_AND_ASSIGN(DrmGpuDisplayManager);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment