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 3 // found in the LICENSE file. 4 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_CRTC_CONTROLLER_H_ 6 #define UI_OZONE_PLATFORM_DRM_GPU_CRTC_CONTROLLER_H_ 7 8 #include <stddef.h> 9 #include <stdint.h> 10 #include <xf86drmMode.h> 11 12 #include "base/macros.h" 13 #include "base/memory/weak_ptr.h" 14 #include "base/observer_list.h" 15 #include "base/time/time.h" 16 #include "ui/gfx/swap_result.h" 17 #include "ui/ozone/platform/drm/common/scoped_drm_types.h" 18 #include "ui/ozone/platform/drm/gpu/drm_overlay_plane.h" 19 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h" 20 21 namespace ui { 22 23 class DrmDevice; 24 25 // Wrapper around a CRTC. 26 // 27 // One CRTC can be paired up with one or more connectors. The simplest 28 // configuration represents one CRTC driving one monitor, while pairing up a 29 // CRTC with multiple connectors results in hardware mirroring. 30 class CrtcController { 31 public: 32 CrtcController(const scoped_refptr<DrmDevice>& drm, 33 uint32_t crtc, 34 uint32_t connector); 35 ~CrtcController(); 36 mode()37 drmModeModeInfo mode() const { return state_.mode; } crtc()38 uint32_t crtc() const { return crtc_; } connector()39 uint32_t connector() const { return connector_; } drm()40 const scoped_refptr<DrmDevice>& drm() const { return drm_; } is_enabled()41 bool is_enabled() const { return state_.properties.active.value; } 42 43 bool AssignOverlayPlanes(HardwareDisplayPlaneList* plane_list, 44 const DrmOverlayPlaneList& planes, 45 bool is_modesetting); 46 47 // Returns a vector of format modifiers for the given fourcc format 48 // on this CRTCs primary plane. A format modifier describes the 49 // actual layout of the buffer, such as whether it's linear, tiled 50 // one way or another or maybe compressed. Except for generic 51 // modifiers such as DRM_FORMAT_MOD_NONE (linear), the modifier 52 // values are 64 bit values that we don't understand at this 53 // level. We pass the modifers to gbm_bo_create_with_modifiers() and 54 // gbm will pick a modifier as it allocates the bo. 55 std::vector<uint64_t> GetFormatModifiers(uint32_t fourcc_format); 56 57 void SetCursor(uint32_t handle, const gfx::Size& size); 58 void MoveCursor(const gfx::Point& location); 59 60 private: 61 const scoped_refptr<DrmDevice> drm_; 62 63 const uint32_t crtc_; 64 65 // TODO(dnicoara) Add support for hardware mirroring (multiple connectors). 66 const uint32_t connector_; 67 68 const HardwareDisplayPlaneManager::CrtcState& state_; 69 70 DISALLOW_COPY_AND_ASSIGN(CrtcController); 71 }; 72 73 } // namespace ui 74 75 #endif // UI_OZONE_PLATFORM_DRM_GPU_CRTC_CONTROLLER_H_ 76