OLD | NEW |
(Empty) | |
| 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/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" |
| 14 #include "ui/ozone/ozone_export.h" |
| 15 #include "ui/ozone/platform/drm/common/scoped_drm_types.h" |
| 16 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h" |
| 17 #include "ui/ozone/platform/drm/gpu/overlay_plane.h" |
| 18 |
| 19 namespace ui { |
| 20 |
| 21 class DrmDevice; |
| 22 class PageFlipRequest; |
| 23 |
| 24 // Wrapper around a CRTC. |
| 25 // |
| 26 // One CRTC can be paired up with one or more connectors. The simplest |
| 27 // configuration represents one CRTC driving one monitor, while pairing up a |
| 28 // CRTC with multiple connectors results in hardware mirroring. |
| 29 class OZONE_EXPORT CrtcController |
| 30 : public base::SupportsWeakPtr<CrtcController> { |
| 31 public: |
| 32 CrtcController(const scoped_refptr<DrmDevice>& drm, |
| 33 uint32_t crtc, |
| 34 uint32_t connector); |
| 35 ~CrtcController(); |
| 36 |
| 37 drmModeModeInfo mode() const { return mode_; } |
| 38 uint32_t crtc() const { return crtc_; } |
| 39 uint32_t connector() const { return connector_; } |
| 40 const scoped_refptr<DrmDevice>& drm() const { return drm_; } |
| 41 bool is_disabled() const { return is_disabled_; } |
| 42 uint64_t time_of_last_flip() const { return time_of_last_flip_; } |
| 43 |
| 44 // Perform the initial modesetting operation using |plane| as the buffer for |
| 45 // the primary plane. The CRTC configuration is specified by |mode|. |
| 46 bool Modeset(const OverlayPlane& plane, drmModeModeInfo mode); |
| 47 |
| 48 // Disables the controller. |
| 49 bool Disable(); |
| 50 |
| 51 // Schedule a page flip event and present the overlays in |planes|. |
| 52 bool SchedulePageFlip(HardwareDisplayPlaneList* plane_list, |
| 53 const OverlayPlaneList& planes, |
| 54 bool test_only, |
| 55 scoped_refptr<PageFlipRequest> page_flip_request); |
| 56 |
| 57 // Called if the page flip for this CRTC fails after being scheduled. |
| 58 void PageFlipFailed(); |
| 59 |
| 60 // Called when the page flip event occurred. The event is provided by the |
| 61 // kernel when a VBlank event finished. This allows the controller to |
| 62 // update internal state and propagate the update to the surface. |
| 63 // The tuple (seconds, useconds) represents the event timestamp. |seconds| |
| 64 // represents the number of seconds while |useconds| represents the |
| 65 // microseconds (< 1 second) in the timestamp. |
| 66 void OnPageFlipEvent(unsigned int frame, |
| 67 unsigned int seconds, |
| 68 unsigned int useconds); |
| 69 |
| 70 bool SetCursor(const scoped_refptr<ScanoutBuffer>& buffer); |
| 71 bool MoveCursor(const gfx::Point& location); |
| 72 |
| 73 private: |
| 74 bool ResetCursor(); |
| 75 |
| 76 void SignalPageFlipRequest(); |
| 77 |
| 78 scoped_refptr<DrmDevice> drm_; |
| 79 |
| 80 HardwareDisplayPlaneManager* overlay_plane_manager_; // Not owned. |
| 81 |
| 82 // Buffers need to be declared first so that they are destroyed last. Needed |
| 83 // since the controllers may reference the buffers. |
| 84 OverlayPlaneList current_planes_; |
| 85 OverlayPlaneList pending_planes_; |
| 86 scoped_refptr<ScanoutBuffer> cursor_buffer_; |
| 87 scoped_refptr<PageFlipRequest> page_flip_request_; |
| 88 |
| 89 uint32_t crtc_; |
| 90 |
| 91 // TODO(dnicoara) Add support for hardware mirroring (multiple connectors). |
| 92 uint32_t connector_; |
| 93 |
| 94 drmModeModeInfo mode_; |
| 95 |
| 96 // Keeps track of the CRTC state. If a surface has been bound, then the value |
| 97 // is set to false. Otherwise it is true. |
| 98 bool is_disabled_ = true; |
| 99 |
| 100 // The time of the last page flip event as reported by the kernel callback. |
| 101 uint64_t time_of_last_flip_ = 0; |
| 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(CrtcController); |
| 104 }; |
| 105 |
| 106 } // namespace ui |
| 107 |
| 108 #endif // UI_OZONE_PLATFORM_DRM_GPU_CRTC_CONTROLLER_H_ |
OLD | NEW |