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

Side by Side Diff: ui/ozone/platform/drm/host/drm_display_host_manager.h

Issue 1661783002: Centralize all gbm ozone host IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_OZONE_PLATFORM_DRM_HOST_DRM_DISPLAY_HOST_MANAGER_H_ 5 #ifndef UI_OZONE_PLATFORM_DRM_HOST_DRM_DISPLAY_HOST_MANAGER_H_
6 #define UI_OZONE_PLATFORM_DRM_HOST_DRM_DISPLAY_HOST_MANAGER_H_ 6 #define UI_OZONE_PLATFORM_DRM_HOST_DRM_DISPLAY_HOST_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map>
11 #include <queue>
12
13 #include "base/file_descriptor_posix.h"
14 #include "base/files/scoped_file.h"
15 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/scoped_vector.h"
18 #include "base/memory/weak_ptr.h"
11 #include "ui/display/types/native_display_delegate.h" 19 #include "ui/display/types/native_display_delegate.h"
12 #include "ui/ozone/platform/drm/host/drm_display_host_manager_core.h" 20 #include "ui/events/ozone/device/device_event.h"
13 #include "ui/ozone/public/gpu_platform_support_host.h" 21 #include "ui/events/ozone/device/device_event_observer.h"
22 #include "ui/events/ozone/evdev/event_factory_evdev.h"
23 #include "ui/ozone/platform/drm/host/gpu_thread_observer.h"
14 24
15 namespace ui { 25 namespace ui {
16 26
17 class DeviceManager; 27 class DeviceManager;
28 class DrmDeviceHandle;
18 class DrmDisplayHost; 29 class DrmDisplayHost;
30 class DrmDisplayHostManager;
19 class DrmGpuPlatformSupportHost; 31 class DrmGpuPlatformSupportHost;
20 class DrmNativeDisplayDelegate; 32 class DrmNativeDisplayDelegate;
33 class GpuThreadAdapter;
21 34
22 struct DisplaySnapshot_Params; 35 struct DisplaySnapshot_Params;
23 36
24 class DrmDisplayHostManager : public GpuPlatformSupportHost { 37 // The portion of the DrmDisplayHostManager implementation that is agnostic
38 // in how its communication with GPU-specific functionality is implemented.
39 // This is used from both the IPC and the in-process versions in MUS.
40 class DrmDisplayHostManager : public DeviceEventObserver, GpuThreadObserver {
25 public: 41 public:
26 DrmDisplayHostManager(DrmGpuPlatformSupportHost* proxy, 42 DrmDisplayHostManager(GpuThreadAdapter* proxy,
27 DeviceManager* device_manager, 43 DeviceManager* device_manager,
28 InputControllerEvdev* input_controller); 44 InputControllerEvdev* input_controller);
29 ~DrmDisplayHostManager() override; 45 ~DrmDisplayHostManager() override;
30 46
31 DrmDisplayHost* GetDisplay(int64_t display_id); 47 DrmDisplayHost* GetDisplay(int64_t display_id);
48
49 // External API.
32 void AddDelegate(DrmNativeDisplayDelegate* delegate); 50 void AddDelegate(DrmNativeDisplayDelegate* delegate);
33 void RemoveDelegate(DrmNativeDisplayDelegate* delegate); 51 void RemoveDelegate(DrmNativeDisplayDelegate* delegate);
34
35 void TakeDisplayControl(const DisplayControlCallback& callback); 52 void TakeDisplayControl(const DisplayControlCallback& callback);
36 void RelinquishDisplayControl(const DisplayControlCallback& callback); 53 void RelinquishDisplayControl(const DisplayControlCallback& callback);
37 void UpdateDisplays(const GetDisplaysCallback& callback); 54 void UpdateDisplays(const GetDisplaysCallback& callback);
38 55
39 // IPC::Listener (by way of GpuPlatformSupportHost) overrides: 56 // DeviceEventObserver overrides:
40 void OnChannelEstablished( 57 void OnDeviceEvent(const DeviceEvent& event) override;
41 int host_id, 58
42 scoped_refptr<base::SingleThreadTaskRunner> send_runner, 59 // GpuThreadObserver overrides:
43 const base::Callback<void(IPC::Message*)>& send_callback) override; 60 void OnGpuThreadReady() override;
44 void OnChannelDestroyed(int host_id) override; 61 void OnGpuThreadRetired() override;
45 bool OnMessageReceived(const IPC::Message& message) override; 62
63 // Communication-free implementations of actions performed in response to
64 // messages from the GPU thread.
65 void GpuHasUpdatedNativeDisplays(
66 const std::vector<DisplaySnapshot_Params>& displays);
67 void GpuConfiguredDisplay(int64_t display_id, bool status);
68 void GpuReceivedHDCPState(int64_t display_id, bool status, HDCPState state);
69 void GpuUpdatedHDCPState(int64_t display_id, bool status);
70 void GpuTookDisplayControl(bool status);
71 void GpuRelinquishedDisplayControl(bool status);
46 72
47 private: 73 private:
48 // Concrete implementation of sending messages to the GPU thread hosted 74 struct DisplayEvent {
49 // functionality. 75 DisplayEvent(DeviceEvent::ActionType action_type,
50 class HostManagerIPC : public DrmDisplayHostManagerProxy { 76 const base::FilePath& path)
51 public: 77 : action_type(action_type), path(path) {}
52 HostManagerIPC(DrmGpuPlatformSupportHost* proxy,
53 DrmDisplayHostManager* parent);
54 ~HostManagerIPC() override;
55 78
56 void RegisterHandler() override; 79 DeviceEvent::ActionType action_type;
57 DrmGpuPlatformSupportHost* GetGpuPlatformSupportHost() override; 80 base::FilePath path;
58 bool TakeDisplayControl() override;
59 bool RefreshNativeDisplays() override;
60 bool RelinquishDisplayControl() override;
61 bool AddGraphicsDevice(const base::FilePath& path,
62 base::FileDescriptor fd) override;
63 bool RemoveGraphicsDevice(const base::FilePath& path) override;
64
65 private:
66 DrmGpuPlatformSupportHost* proxy_;
67 DrmDisplayHostManager* parent_;
68
69 DISALLOW_COPY_AND_ASSIGN(HostManagerIPC);
70 }; 81 };
71 82
72 // IPC Entry points. 83 // Handle hotplug events sequentially.
73 void OnUpdateNativeDisplays( 84 void ProcessEvent();
74 const std::vector<DisplaySnapshot_Params>& displays);
75 void OnDisplayConfigured(int64_t display_id, bool status);
76 void OnHDCPStateReceived(int64_t display_id, bool status, HDCPState state);
77 void OnHDCPStateUpdated(int64_t display_id, bool status);
78 void OnTakeDisplayControl(bool status);
79 void OnRelinquishDisplayControl(bool status);
80 85
81 // Sends messages to the GPU thread. 86 // Called as a result of finishing to process the display hotplug event. These
82 scoped_ptr<HostManagerIPC> sender_; 87 // are responsible for dequing the event and scheduling the next event.
88 void OnAddGraphicsDevice(const base::FilePath& path,
89 const base::FilePath& sysfs_path,
90 scoped_ptr<DrmDeviceHandle> handle);
91 void OnUpdateGraphicsDevice();
92 void OnRemoveGraphicsDevice(const base::FilePath& path);
83 93
84 // Implementation without messaging functionality. 94 void RunUpdateDisplaysCallback(const GetDisplaysCallback& callback) const;
85 scoped_ptr<DrmDisplayHostManagerCore> core_; 95
96 void NotifyDisplayDelegate() const;
97
98 GpuThreadAdapter* proxy_; // Not owned.
99 DeviceManager* device_manager_; // Not owned.
100 InputControllerEvdev* input_controller_; // Not owned.
101
102 DrmNativeDisplayDelegate* delegate_ = nullptr; // Not owned.
103
104 // File path for the primary graphics card which is opened by default in the
105 // GPU process. We'll avoid opening this in hotplug events since it will race
106 // with the GPU process trying to open it and aquire DRM master.
107 base::FilePath primary_graphics_card_path_;
108
109 // File path for virtual gem (VGEM) device.
110 base::FilePath vgem_card_path_;
111
112 // Keeps track if there is a dummy display. This happens on initialization
113 // when there is no connection to the GPU to update the displays.
114 bool has_dummy_display_ = false;
115
116 std::vector<scoped_ptr<DrmDisplayHost>> displays_;
117
118 GetDisplaysCallback get_displays_callback_;
119
120 bool display_externally_controlled_ = false;
121 bool display_control_change_pending_ = false;
122 DisplayControlCallback take_display_control_callback_;
123 DisplayControlCallback relinquish_display_control_callback_;
124
125 // Used to serialize display event processing. This is done since
126 // opening/closing DRM devices cannot be done on the UI thread and are handled
127 // on a worker thread. Thus, we need to queue events in order to process them
128 // in the correct order.
129 std::queue<DisplayEvent> event_queue_;
130
131 // True if a display event is currently being processed on a worker thread.
132 bool task_pending_ = false;
133
134 // Keeps track of all the active DRM devices. The key is the device path, the
135 // value is the sysfs path which has been resolved from the device path.
136 std::map<base::FilePath, base::FilePath> drm_devices_;
137
138 // This is used to cache the primary DRM device until the channel is
139 // established.
140 scoped_ptr<DrmDeviceHandle> primary_drm_device_handle_;
141
142 base::WeakPtrFactory<DrmDisplayHostManager> weak_ptr_factory_;
86 143
87 DISALLOW_COPY_AND_ASSIGN(DrmDisplayHostManager); 144 DISALLOW_COPY_AND_ASSIGN(DrmDisplayHostManager);
88 }; 145 };
89 146
90 } // namespace ui 147 } // namespace ui
91 148
92 #endif // UI_OZONE_PLATFORM_DRM_HOST_DRM_DISPLAY_HOST_MANAGER_H_ 149 #endif // UI_OZONE_PLATFORM_DRM_HOST_DRM_DISPLAY_HOST_MANAGER_H_
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/host/drm_display_host.cc ('k') | ui/ozone/platform/drm/host/drm_display_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698