summaryrefslogtreecommitdiffstats
path: root/ui/ozone/platform/drm/host
diff options
context:
space:
mode:
authordnicoara <dnicoara@chromium.org>2015-06-03 14:08:41 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-03 21:09:17 +0000
commite00e594f7556feb2bb533df02a84c9f2b247e13a (patch)
tree8b2fecb038997027b7493725b26b8b4343761134 /ui/ozone/platform/drm/host
parent33f8aca3cf3f44bc900e9a9ce7e4598cd2cf5bb9 (diff)
downloadchromium_src-e00e594f7556feb2bb533df02a84c9f2b247e13a.zip
chromium_src-e00e594f7556feb2bb533df02a84c9f2b247e13a.tar.gz
chromium_src-e00e594f7556feb2bb533df02a84c9f2b247e13a.tar.bz2
[Ozone-Drm] Implement async display ownership transfer
Allows us to properly signal Frecon when we're done taking/releasing the displays. Oterwise Frecon may try and take DRM master and fail. At that point Chrome will think it doesn't have master (so it stops painting) and Frecon won't be painting since it failed to get master. BUG=none Review URL: https://codereview.chromium.org/1167533003 Cr-Commit-Position: refs/heads/master@{#332678}
Diffstat (limited to 'ui/ozone/platform/drm/host')
-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
3 files changed, 52 insertions, 10 deletions
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() {