| OLD | NEW |
| 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> | 10 #include <map> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 DrmDisplayHostManager(GpuThreadAdapter* proxy, | 41 DrmDisplayHostManager(GpuThreadAdapter* proxy, |
| 42 DeviceManager* device_manager, | 42 DeviceManager* device_manager, |
| 43 InputControllerEvdev* input_controller); | 43 InputControllerEvdev* input_controller); |
| 44 ~DrmDisplayHostManager() override; | 44 ~DrmDisplayHostManager() override; |
| 45 | 45 |
| 46 DrmDisplayHost* GetDisplay(int64_t display_id); | 46 DrmDisplayHost* GetDisplay(int64_t display_id); |
| 47 | 47 |
| 48 // External API. | 48 // External API. |
| 49 void AddDelegate(DrmNativeDisplayDelegate* delegate); | 49 void AddDelegate(DrmNativeDisplayDelegate* delegate); |
| 50 void RemoveDelegate(DrmNativeDisplayDelegate* delegate); | 50 void RemoveDelegate(DrmNativeDisplayDelegate* delegate); |
| 51 void TakeDisplayControl(const DisplayControlCallback& callback); | 51 void TakeDisplayControl(const display::DisplayControlCallback& callback); |
| 52 void RelinquishDisplayControl(const DisplayControlCallback& callback); | 52 void RelinquishDisplayControl( |
| 53 void UpdateDisplays(const GetDisplaysCallback& callback); | 53 const display::DisplayControlCallback& callback); |
| 54 void UpdateDisplays(const display::GetDisplaysCallback& callback); |
| 54 | 55 |
| 55 // DeviceEventObserver overrides: | 56 // DeviceEventObserver overrides: |
| 56 void OnDeviceEvent(const DeviceEvent& event) override; | 57 void OnDeviceEvent(const DeviceEvent& event) override; |
| 57 | 58 |
| 58 // GpuThreadObserver overrides: | 59 // GpuThreadObserver overrides: |
| 59 void OnGpuProcessLaunched() override; | 60 void OnGpuProcessLaunched() override; |
| 60 void OnGpuThreadReady() override; | 61 void OnGpuThreadReady() override; |
| 61 void OnGpuThreadRetired() override; | 62 void OnGpuThreadRetired() override; |
| 62 | 63 |
| 63 // Communication-free implementations of actions performed in response to | 64 // Communication-free implementations of actions performed in response to |
| 64 // messages from the GPU thread. | 65 // messages from the GPU thread. |
| 65 void GpuHasUpdatedNativeDisplays( | 66 void GpuHasUpdatedNativeDisplays( |
| 66 const std::vector<DisplaySnapshot_Params>& displays); | 67 const std::vector<DisplaySnapshot_Params>& displays); |
| 67 void GpuConfiguredDisplay(int64_t display_id, bool status); | 68 void GpuConfiguredDisplay(int64_t display_id, bool status); |
| 68 void GpuReceivedHDCPState(int64_t display_id, bool status, HDCPState state); | 69 void GpuReceivedHDCPState(int64_t display_id, |
| 70 bool status, |
| 71 display::HDCPState state); |
| 69 void GpuUpdatedHDCPState(int64_t display_id, bool status); | 72 void GpuUpdatedHDCPState(int64_t display_id, bool status); |
| 70 void GpuTookDisplayControl(bool status); | 73 void GpuTookDisplayControl(bool status); |
| 71 void GpuRelinquishedDisplayControl(bool status); | 74 void GpuRelinquishedDisplayControl(bool status); |
| 72 | 75 |
| 73 private: | 76 private: |
| 74 struct DisplayEvent { | 77 struct DisplayEvent { |
| 75 DisplayEvent(DeviceEvent::ActionType action_type, | 78 DisplayEvent(DeviceEvent::ActionType action_type, |
| 76 const base::FilePath& path) | 79 const base::FilePath& path) |
| 77 : action_type(action_type), path(path) {} | 80 : action_type(action_type), path(path) {} |
| 78 | 81 |
| 79 DeviceEvent::ActionType action_type; | 82 DeviceEvent::ActionType action_type; |
| 80 base::FilePath path; | 83 base::FilePath path; |
| 81 }; | 84 }; |
| 82 | 85 |
| 83 // Handle hotplug events sequentially. | 86 // Handle hotplug events sequentially. |
| 84 void ProcessEvent(); | 87 void ProcessEvent(); |
| 85 | 88 |
| 86 // Called as a result of finishing to process the display hotplug event. These | 89 // Called as a result of finishing to process the display hotplug event. These |
| 87 // are responsible for dequing the event and scheduling the next event. | 90 // are responsible for dequing the event and scheduling the next event. |
| 88 void OnAddGraphicsDevice(const base::FilePath& path, | 91 void OnAddGraphicsDevice(const base::FilePath& path, |
| 89 const base::FilePath& sysfs_path, | 92 const base::FilePath& sysfs_path, |
| 90 std::unique_ptr<DrmDeviceHandle> handle); | 93 std::unique_ptr<DrmDeviceHandle> handle); |
| 91 void OnUpdateGraphicsDevice(); | 94 void OnUpdateGraphicsDevice(); |
| 92 void OnRemoveGraphicsDevice(const base::FilePath& path); | 95 void OnRemoveGraphicsDevice(const base::FilePath& path); |
| 93 | 96 |
| 94 void RunUpdateDisplaysCallback(const GetDisplaysCallback& callback) const; | 97 void RunUpdateDisplaysCallback( |
| 98 const display::GetDisplaysCallback& callback) const; |
| 95 | 99 |
| 96 void NotifyDisplayDelegate() const; | 100 void NotifyDisplayDelegate() const; |
| 97 | 101 |
| 98 GpuThreadAdapter* proxy_; // Not owned. | 102 GpuThreadAdapter* proxy_; // Not owned. |
| 99 DeviceManager* device_manager_; // Not owned. | 103 DeviceManager* device_manager_; // Not owned. |
| 100 InputControllerEvdev* input_controller_; // Not owned. | 104 InputControllerEvdev* input_controller_; // Not owned. |
| 101 | 105 |
| 102 DrmNativeDisplayDelegate* delegate_ = nullptr; // Not owned. | 106 DrmNativeDisplayDelegate* delegate_ = nullptr; // Not owned. |
| 103 | 107 |
| 104 // File path for the primary graphics card which is opened by default in the | 108 // 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 | 109 // 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. | 110 // with the GPU process trying to open it and aquire DRM master. |
| 107 base::FilePath primary_graphics_card_path_; | 111 base::FilePath primary_graphics_card_path_; |
| 108 | 112 |
| 109 // Keeps track if there is a dummy display. This happens on initialization | 113 // Keeps track if there is a dummy display. This happens on initialization |
| 110 // when there is no connection to the GPU to update the displays. | 114 // when there is no connection to the GPU to update the displays. |
| 111 bool has_dummy_display_ = false; | 115 bool has_dummy_display_ = false; |
| 112 | 116 |
| 113 std::vector<std::unique_ptr<DrmDisplayHost>> displays_; | 117 std::vector<std::unique_ptr<DrmDisplayHost>> displays_; |
| 114 | 118 |
| 115 GetDisplaysCallback get_displays_callback_; | 119 display::GetDisplaysCallback get_displays_callback_; |
| 116 | 120 |
| 117 bool display_externally_controlled_ = false; | 121 bool display_externally_controlled_ = false; |
| 118 bool display_control_change_pending_ = false; | 122 bool display_control_change_pending_ = false; |
| 119 DisplayControlCallback take_display_control_callback_; | 123 display::DisplayControlCallback take_display_control_callback_; |
| 120 DisplayControlCallback relinquish_display_control_callback_; | 124 display::DisplayControlCallback relinquish_display_control_callback_; |
| 121 | 125 |
| 122 // Used to serialize display event processing. This is done since | 126 // Used to serialize display event processing. This is done since |
| 123 // opening/closing DRM devices cannot be done on the UI thread and are handled | 127 // opening/closing DRM devices cannot be done on the UI thread and are handled |
| 124 // on a worker thread. Thus, we need to queue events in order to process them | 128 // on a worker thread. Thus, we need to queue events in order to process them |
| 125 // in the correct order. | 129 // in the correct order. |
| 126 std::queue<DisplayEvent> event_queue_; | 130 std::queue<DisplayEvent> event_queue_; |
| 127 | 131 |
| 128 // True if a display event is currently being processed on a worker thread. | 132 // True if a display event is currently being processed on a worker thread. |
| 129 bool task_pending_ = false; | 133 bool task_pending_ = false; |
| 130 | 134 |
| 131 // Keeps track of all the active DRM devices. The key is the device path, the | 135 // Keeps track of all the active DRM devices. The key is the device path, the |
| 132 // value is the sysfs path which has been resolved from the device path. | 136 // value is the sysfs path which has been resolved from the device path. |
| 133 std::map<base::FilePath, base::FilePath> drm_devices_; | 137 std::map<base::FilePath, base::FilePath> drm_devices_; |
| 134 | 138 |
| 135 // This is used to cache the primary DRM device until the channel is | 139 // This is used to cache the primary DRM device until the channel is |
| 136 // established. | 140 // established. |
| 137 std::unique_ptr<DrmDeviceHandle> primary_drm_device_handle_; | 141 std::unique_ptr<DrmDeviceHandle> primary_drm_device_handle_; |
| 138 | 142 |
| 139 base::WeakPtrFactory<DrmDisplayHostManager> weak_ptr_factory_; | 143 base::WeakPtrFactory<DrmDisplayHostManager> weak_ptr_factory_; |
| 140 | 144 |
| 141 DISALLOW_COPY_AND_ASSIGN(DrmDisplayHostManager); | 145 DISALLOW_COPY_AND_ASSIGN(DrmDisplayHostManager); |
| 142 }; | 146 }; |
| 143 | 147 |
| 144 } // namespace ui | 148 } // namespace ui |
| 145 | 149 |
| 146 #endif // UI_OZONE_PLATFORM_DRM_HOST_DRM_DISPLAY_HOST_MANAGER_H_ | 150 #endif // UI_OZONE_PLATFORM_DRM_HOST_DRM_DISPLAY_HOST_MANAGER_H_ |
| OLD | NEW |