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

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

Issue 2459973002: Expedite discovery of primary DRM device. (Closed)
Patch Set: Created 4 years, 1 month 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 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" 5 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <xf86drm.h> 9 #include <xf86drm.h>
10 10
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 300
301 void DrmDisplayHostManager::OnRemoveGraphicsDevice( 301 void DrmDisplayHostManager::OnRemoveGraphicsDevice(
302 const base::FilePath& sys_path) { 302 const base::FilePath& sys_path) {
303 proxy_->GpuRemoveGraphicsDevice(sys_path); 303 proxy_->GpuRemoveGraphicsDevice(sys_path);
304 NotifyDisplayDelegate(); 304 NotifyDisplayDelegate();
305 task_pending_ = false; 305 task_pending_ = false;
306 ProcessEvent(); 306 ProcessEvent();
307 } 307 }
308 308
309 void DrmDisplayHostManager::OnGpuThreadReady() { 309 void DrmDisplayHostManager::OnGpuProcessLaunched() {
310 // If in the middle of a configuration, just respond with the old list of
311 // displays. This is fine, since after the DRM resources are initialized and
312 // IPC-ed to the GPU NotifyDisplayDelegate() is called to let the display
313 // delegate know that the display configuration changed and it needs to
314 // update it again.
315 if (!get_displays_callback_.is_null()) {
316 base::ThreadTaskRunnerHandle::Get()->PostTask(
317 FROM_HERE,
318 base::Bind(&DrmDisplayHostManager::RunUpdateDisplaysCallback,
319 weak_ptr_factory_.GetWeakPtr(), get_displays_callback_));
320 get_displays_callback_.Reset();
321 }
322
323 // Signal that we're taking DRM master since we're going through the
324 // initialization process again and we'll take all the available resources.
325 if (!take_display_control_callback_.is_null())
326 GpuTookDisplayControl(true);
327
328 if (!relinquish_display_control_callback_.is_null())
329 GpuRelinquishedDisplayControl(false);
330
331 std::unique_ptr<DrmDeviceHandle> handle = 310 std::unique_ptr<DrmDeviceHandle> handle =
332 std::move(primary_drm_device_handle_); 311 std::move(primary_drm_device_handle_);
333 { 312 {
334 base::ThreadRestrictions::ScopedAllowIO allow_io; 313 base::ThreadRestrictions::ScopedAllowIO allow_io;
335 314
336 drm_devices_.clear(); 315 drm_devices_.clear();
337 drm_devices_[primary_graphics_card_path_] = 316 drm_devices_[primary_graphics_card_path_] =
dnicoara 2016/10/28 21:42:54 |drm_devices_| can't be accessed on multiple threa
338 MapDevPathToSysPath(primary_graphics_card_path_); 317 MapDevPathToSysPath(primary_graphics_card_path_);
339 318
340 if (!handle) { 319 if (!handle) {
341 handle.reset(new DrmDeviceHandle()); 320 handle.reset(new DrmDeviceHandle());
342 if (!handle->Initialize(primary_graphics_card_path_, 321 if (!handle->Initialize(primary_graphics_card_path_,
343 drm_devices_[primary_graphics_card_path_])) 322 drm_devices_[primary_graphics_card_path_]))
344 LOG(FATAL) << "Failed to open primary graphics card"; 323 LOG(FATAL) << "Failed to open primary graphics card";
345 } 324 }
346 } 325 }
347 326
348 // Send the primary device first since this is used to initialize graphics 327 // Send the primary device first since this is used to initialize graphics
349 // state. 328 // state.
350 proxy_->GpuAddGraphicsDevice(drm_devices_[primary_graphics_card_path_], 329 proxy_->GpuAddGraphicsDevice(drm_devices_[primary_graphics_card_path_],
dnicoara 2016/10/28 21:42:54 You may need to check how the buffer allocation is
351 base::FileDescriptor(handle->PassFD())); 330 base::FileDescriptor(handle->PassFD()));
331 }
332
333 void DrmDisplayHostManager::OnGpuThreadReady() {
334 // If in the middle of a configuration, just respond with the old list of
335 // displays. This is fine, since after the DRM resources are initialized and
336 // IPC-ed to the GPU NotifyDisplayDelegate() is called to let the display
337 // delegate know that the display configuration changed and it needs to
338 // update it again.
339 if (!get_displays_callback_.is_null()) {
340 base::ThreadTaskRunnerHandle::Get()->PostTask(
341 FROM_HERE,
342 base::Bind(&DrmDisplayHostManager::RunUpdateDisplaysCallback,
343 weak_ptr_factory_.GetWeakPtr(), get_displays_callback_));
344 get_displays_callback_.Reset();
345 }
346
347 // Signal that we're taking DRM master since we're going through the
348 // initialization process again and we'll take all the available resources.
349 if (!take_display_control_callback_.is_null())
350 GpuTookDisplayControl(true);
351
352 if (!relinquish_display_control_callback_.is_null())
353 GpuRelinquishedDisplayControl(false);
352 354
353 device_manager_->ScanDevices(this); 355 device_manager_->ScanDevices(this);
354 NotifyDisplayDelegate(); 356 NotifyDisplayDelegate();
355 } 357 }
356 358
357 void DrmDisplayHostManager::OnGpuThreadRetired() {} 359 void DrmDisplayHostManager::OnGpuThreadRetired() {}
358 360
359 void DrmDisplayHostManager::GpuHasUpdatedNativeDisplays( 361 void DrmDisplayHostManager::GpuHasUpdatedNativeDisplays(
360 const std::vector<DisplaySnapshot_Params>& params) { 362 const std::vector<DisplaySnapshot_Params>& params) {
361 std::vector<std::unique_ptr<DrmDisplayHost>> old_displays; 363 std::vector<std::unique_ptr<DrmDisplayHost>> old_displays;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 460
459 callback.Run(snapshots); 461 callback.Run(snapshots);
460 } 462 }
461 463
462 void DrmDisplayHostManager::NotifyDisplayDelegate() const { 464 void DrmDisplayHostManager::NotifyDisplayDelegate() const {
463 if (delegate_) 465 if (delegate_)
464 delegate_->OnConfigurationChanged(); 466 delegate_->OnConfigurationChanged();
465 } 467 }
466 468
467 } // namespace ui 469 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698