summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/ozone/common/gpu/ozone_gpu_messages.h7
-rw-r--r--ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc27
-rw-r--r--ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h2
-rw-r--r--ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc4
-rw-r--r--ui/ozone/platform/drm/host/drm_display_host_manager.cc47
-rw-r--r--ui/ozone/platform/drm/host/drm_display_host_manager.h11
-rw-r--r--ui/ozone/platform/drm/host/drm_native_display_delegate.cc4
7 files changed, 75 insertions, 27 deletions
diff --git a/ui/ozone/common/gpu/ozone_gpu_messages.h b/ui/ozone/common/gpu/ozone_gpu_messages.h
index e83169b..b58af6a 100644
--- a/ui/ozone/common/gpu/ozone_gpu_messages.h
+++ b/ui/ozone/common/gpu/ozone_gpu_messages.h
@@ -150,3 +150,10 @@ IPC_MESSAGE_CONTROL3(OzoneHostMsg_HDCPStateReceived,
IPC_MESSAGE_CONTROL2(OzoneHostMsg_HDCPStateUpdated,
int64_t /* display_id */,
bool /* success */)
+
+// Response to OzoneGpuMsg_TakeDisplayControl.
+IPC_MESSAGE_CONTROL1(OzoneHostMsg_DisplayControlTaken, bool /* success */)
+
+// Response to OzoneGpuMsg_RelinquishDisplayControl.
+IPC_MESSAGE_CONTROL1(OzoneHostMsg_DisplayControlRelinquished,
+ bool /* success */)
diff --git a/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc b/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc
index 5cee091..7d7bba4 100644
--- a/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc
+++ b/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc
@@ -97,26 +97,23 @@ std::vector<DisplaySnapshot_Params> DrmGpuDisplayManager::GetDisplays() {
bool DrmGpuDisplayManager::TakeDisplayControl() {
const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices();
- for (const auto& drm : devices) {
- if (!drm->SetMaster()) {
- LOG(ERROR) << "Failed to take control of the display";
- return false;
- }
+ bool status = true;
+ for (const auto& drm : devices)
+ status &= drm->SetMaster();
+
+ // Roll-back any successful operation.
+ if (!status) {
+ LOG(ERROR) << "Failed to take control of the display";
+ RelinquishDisplayControl();
}
- return true;
+ return status;
}
-bool DrmGpuDisplayManager::RelinquishDisplayControl() {
+void DrmGpuDisplayManager::RelinquishDisplayControl() {
const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices();
- for (const auto& drm : devices) {
- if (!drm->DropMaster()) {
- LOG(ERROR) << "Failed to relinquish control of the display";
- return false;
- }
- }
-
- return true;
+ for (const auto& drm : devices)
+ drm->DropMaster();
}
bool DrmGpuDisplayManager::ConfigureDisplay(
diff --git a/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h b/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h
index 44d300c..c4a3e21 100644
--- a/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h
+++ b/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h
@@ -28,7 +28,7 @@ class DrmGpuDisplayManager {
// Takes/releases the control of the DRM devices.
bool TakeDisplayControl();
- bool RelinquishDisplayControl();
+ void RelinquishDisplayControl();
bool ConfigureDisplay(int64_t id,
const DisplayMode_Params& mode,
diff --git a/ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc b/ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc
index b8b1b79..92df322 100644
--- a/ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc
+++ b/ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc
@@ -279,11 +279,13 @@ void DrmGpuPlatformSupport::OnDisableNativeDisplay(int64_t id) {
}
void DrmGpuPlatformSupport::OnTakeDisplayControl() {
- display_manager_->TakeDisplayControl();
+ sender_->Send(new OzoneHostMsg_DisplayControlTaken(
+ display_manager_->TakeDisplayControl()));
}
void DrmGpuPlatformSupport::OnRelinquishDisplayControl() {
display_manager_->RelinquishDisplayControl();
+ sender_->Send(new OzoneHostMsg_DisplayControlRelinquished(true));
}
void DrmGpuPlatformSupport::OnAddGraphicsDevice(
diff --git a/ui/ozone/platform/drm/host/drm_display_host_manager.cc b/ui/ozone/platform/drm/host/drm_display_host_manager.cc
index bef88fb..41a2c03 100644
--- a/ui/ozone/platform/drm/host/drm_display_host_manager.cc
+++ b/ui/ozone/platform/drm/host/drm_display_host_manager.cc
@@ -152,14 +152,18 @@ void DrmDisplayHostManager::RemoveDelegate(DrmNativeDisplayDelegate* delegate) {
delegate_ = nullptr;
}
-bool DrmDisplayHostManager::TakeDisplayControl() {
- proxy_->Send(new OzoneGpuMsg_TakeDisplayControl());
- return true;
+void DrmDisplayHostManager::TakeDisplayControl(
+ const DisplayControlCallback& callback) {
+ take_display_control_callback_ = callback;
+ if (!proxy_->Send(new OzoneGpuMsg_TakeDisplayControl()))
+ OnTakeDisplayControl(false);
}
-bool DrmDisplayHostManager::RelinquishDisplayControl() {
- proxy_->Send(new OzoneGpuMsg_RelinquishDisplayControl());
- return true;
+void DrmDisplayHostManager::RelinquishDisplayControl(
+ const DisplayControlCallback& callback) {
+ relinquish_display_control_callback_ = callback;
+ if (!proxy_->Send(new OzoneGpuMsg_RelinquishDisplayControl()))
+ OnRelinquishDisplayControl(false);
}
void DrmDisplayHostManager::UpdateDisplays(
@@ -263,6 +267,14 @@ void DrmDisplayHostManager::OnChannelEstablished(
get_displays_callback_.Reset();
}
+ // Signal that we're taking DRM master since we're going through the
+ // initialization process again and we'll take all the available resources.
+ if (!take_display_control_callback_.is_null())
+ OnTakeDisplayControl(true);
+
+ if (!relinquish_display_control_callback_.is_null())
+ OnRelinquishDisplayControl(false);
+
drm_devices_.clear();
drm_devices_.insert(primary_graphics_card_path_);
scoped_ptr<DrmDeviceHandle> handle = primary_drm_device_handle_.Pass();
@@ -293,6 +305,9 @@ bool DrmDisplayHostManager::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(OzoneHostMsg_DisplayConfigured, OnDisplayConfigured)
IPC_MESSAGE_HANDLER(OzoneHostMsg_HDCPStateReceived, OnHDCPStateReceived)
IPC_MESSAGE_HANDLER(OzoneHostMsg_HDCPStateUpdated, OnHDCPStateUpdated)
+ IPC_MESSAGE_HANDLER(OzoneHostMsg_DisplayControlTaken, OnTakeDisplayControl)
+ IPC_MESSAGE_HANDLER(OzoneHostMsg_DisplayControlRelinquished,
+ OnRelinquishDisplayControl)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -352,6 +367,26 @@ void DrmDisplayHostManager::OnHDCPStateUpdated(int64_t display_id,
LOG(ERROR) << "Couldn't find display with id=" << display_id;
}
+void DrmDisplayHostManager::OnTakeDisplayControl(bool status) {
+ if (!take_display_control_callback_.is_null()) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(take_display_control_callback_, status));
+ take_display_control_callback_.Reset();
+ } else {
+ LOG(ERROR) << "No callback for take display control";
+ }
+}
+
+void DrmDisplayHostManager::OnRelinquishDisplayControl(bool status) {
+ if (!relinquish_display_control_callback_.is_null()) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(relinquish_display_control_callback_, status));
+ relinquish_display_control_callback_.Reset();
+ } else {
+ LOG(ERROR) << "No callback for relinquish display control";
+ }
+}
+
void DrmDisplayHostManager::RunUpdateDisplaysCallback(
const GetDisplaysCallback& callback) const {
std::vector<DisplaySnapshot*> snapshots;
diff --git a/ui/ozone/platform/drm/host/drm_display_host_manager.h b/ui/ozone/platform/drm/host/drm_display_host_manager.h
index 41156ea..c0da4dd 100644
--- a/ui/ozone/platform/drm/host/drm_display_host_manager.h
+++ b/ui/ozone/platform/drm/host/drm_display_host_manager.h
@@ -38,8 +38,8 @@ class DrmDisplayHostManager : public DeviceEventObserver,
void AddDelegate(DrmNativeDisplayDelegate* delegate);
void RemoveDelegate(DrmNativeDisplayDelegate* delegate);
- bool TakeDisplayControl();
- bool RelinquishDisplayControl();
+ void TakeDisplayControl(const DisplayControlCallback& callback);
+ void RelinquishDisplayControl(const DisplayControlCallback& callback);
void UpdateDisplays(const GetDisplaysCallback& callback);
// DeviceEventObserver overrides:
@@ -81,6 +81,9 @@ class DrmDisplayHostManager : public DeviceEventObserver,
void OnHDCPStateReceived(int64_t display_id, bool status, HDCPState state);
void OnHDCPStateUpdated(int64_t display_id, bool status);
+ void OnTakeDisplayControl(bool status);
+ void OnRelinquishDisplayControl(bool status);
+
void RunUpdateDisplaysCallback(const GetDisplaysCallback& callback) const;
void NotifyDisplayDelegate() const;
@@ -103,6 +106,10 @@ class DrmDisplayHostManager : public DeviceEventObserver,
GetDisplaysCallback get_displays_callback_;
+ DisplayControlCallback take_display_control_callback_;
+
+ DisplayControlCallback relinquish_display_control_callback_;
+
// Used to serialize display event processing. This is done since
// opening/closing DRM devices cannot be done on the UI thread and are handled
// on a worker thread. Thus, we need to queue events in order to process them
diff --git a/ui/ozone/platform/drm/host/drm_native_display_delegate.cc b/ui/ozone/platform/drm/host/drm_native_display_delegate.cc
index 9710824..0d6389b 100644
--- a/ui/ozone/platform/drm/host/drm_native_display_delegate.cc
+++ b/ui/ozone/platform/drm/host/drm_native_display_delegate.cc
@@ -37,12 +37,12 @@ void DrmNativeDisplayDelegate::UngrabServer() {
void DrmNativeDisplayDelegate::TakeDisplayControl(
const DisplayControlCallback& callback) {
- callback.Run(display_manager_->TakeDisplayControl());
+ display_manager_->TakeDisplayControl(callback);
}
void DrmNativeDisplayDelegate::RelinquishDisplayControl(
const DisplayControlCallback& callback) {
- callback.Run(display_manager_->RelinquishDisplayControl());
+ display_manager_->RelinquishDisplayControl(callback);
}
void DrmNativeDisplayDelegate::SyncWithServer() {