summaryrefslogtreecommitdiffstats
path: root/ui/ozone/platform/drm/gpu/crtc_controller.h
diff options
context:
space:
mode:
authordnicoara <dnicoara@chromium.org>2015-03-05 12:46:18 -0800
committerCommit bot <commit-bot@chromium.org>2015-03-05 20:47:08 +0000
commit171d8c892da1b2e38f90c17b62896ba82f0719e3 (patch)
tree9fe2810948b2d8dfd73cd7a5afa002dcf79c0547 /ui/ozone/platform/drm/gpu/crtc_controller.h
parentf36607f2398cb4aa9b50449b1221bbc72e3f3453 (diff)
downloadchromium_src-171d8c892da1b2e38f90c17b62896ba82f0719e3.zip
chromium_src-171d8c892da1b2e38f90c17b62896ba82f0719e3.tar.gz
chromium_src-171d8c892da1b2e38f90c17b62896ba82f0719e3.tar.bz2
[Ozone] Rename and split the DRI platform for clarity
This CL does the following: - Moves the files in ui/ozone/platform/dri to ui/ozone/platform/drm since the platform name should really be DRM rather than DRI. Note, that the platform is still refered to as "dri" in GYP/GN since CrOS builds are still using the 'dri' name. - Rename all files with a "_dri*" suffix to a "drm_" prefix. Also rename all files with a "dri_" prefix to a "drm_" prefix. - Rename NativeDisplayDelegateDri to DrmDisplayDelegateManager since it is no longer dependent on the NativeDisplayDelegate interface and the new name better describes its intent. - Split the files in the platform into 2 sub-folders ("host" and "gpu"). Depending on the intended use place of the objects (Browser (host) process or GPU process) the files in the platform are split accordingly in the 2 sub-folders. BUG=none TBR=jam@chromium.org Review URL: https://codereview.chromium.org/975063002 Cr-Commit-Position: refs/heads/master@{#319320}
Diffstat (limited to 'ui/ozone/platform/drm/gpu/crtc_controller.h')
-rw-r--r--ui/ozone/platform/drm/gpu/crtc_controller.h117
1 files changed, 117 insertions, 0 deletions
diff --git a/ui/ozone/platform/drm/gpu/crtc_controller.h b/ui/ozone/platform/drm/gpu/crtc_controller.h
new file mode 100644
index 0000000..29135dc
--- /dev/null
+++ b/ui/ozone/platform/drm/gpu/crtc_controller.h
@@ -0,0 +1,117 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_OZONE_PLATFORM_DRM_GPU_CRTC_CONTROLLER_H_
+#define UI_OZONE_PLATFORM_DRM_GPU_CRTC_CONTROLLER_H_
+
+#include <stddef.h>
+#include <stdint.h>
+#include <xf86drmMode.h>
+
+#include "base/memory/weak_ptr.h"
+#include "base/observer_list.h"
+#include "ui/ozone/ozone_export.h"
+#include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h"
+#include "ui/ozone/platform/drm/gpu/overlay_plane.h"
+#include "ui/ozone/platform/drm/gpu/scoped_drm_types.h"
+
+namespace ui {
+
+class DrmDevice;
+class PageFlipObserver;
+
+// Wrapper around a CRTC.
+//
+// One CRTC can be paired up with one or more connectors. The simplest
+// configuration represents one CRTC driving one monitor, while pairing up a
+// CRTC with multiple connectors results in hardware mirroring.
+class OZONE_EXPORT CrtcController
+ : public base::SupportsWeakPtr<CrtcController> {
+ public:
+ CrtcController(const scoped_refptr<DrmDevice>& drm,
+ uint32_t crtc,
+ uint32_t connector);
+ ~CrtcController();
+
+ uint32_t crtc() const { return crtc_; }
+ uint32_t connector() const { return connector_; }
+ const scoped_refptr<DrmDevice>& drm() const { return drm_; }
+ bool is_disabled() const { return is_disabled_; }
+ bool page_flip_pending() const { return page_flip_pending_; }
+ uint64_t time_of_last_flip() const { return time_of_last_flip_; }
+
+ drmModeCrtc* saved_crtc() const { return saved_crtc_.get(); }
+
+ // Perform the initial modesetting operation using |plane| as the buffer for
+ // the primary plane. The CRTC configuration is specified by |mode|.
+ bool Modeset(const OverlayPlane& plane, drmModeModeInfo mode);
+
+ // Disables the controller.
+ bool Disable();
+
+ // Schedule a page flip event and present the overlays in |planes|.
+ bool SchedulePageFlip(HardwareDisplayPlaneList* plane_list,
+ const OverlayPlaneList& planes);
+
+ // Called if the page flip for this CRTC fails after being scheduled.
+ void PageFlipFailed();
+
+ // Called when the page flip event occurred. The event is provided by the
+ // kernel when a VBlank event finished. This allows the controller to
+ // update internal state and propagate the update to the surface.
+ // The tuple (seconds, useconds) represents the event timestamp. |seconds|
+ // represents the number of seconds while |useconds| represents the
+ // microseconds (< 1 second) in the timestamp.
+ void OnPageFlipEvent(unsigned int frame,
+ unsigned int seconds,
+ unsigned int useconds);
+
+ bool SetCursor(const scoped_refptr<ScanoutBuffer>& buffer);
+ bool UnsetCursor();
+ bool MoveCursor(const gfx::Point& location);
+
+ void AddObserver(PageFlipObserver* observer);
+ void RemoveObserver(PageFlipObserver* observer);
+
+ private:
+ scoped_refptr<DrmDevice> drm_;
+
+ HardwareDisplayPlaneManager* overlay_plane_manager_; // Not owned.
+
+ // Buffers need to be declared first so that they are destroyed last. Needed
+ // since the controllers may reference the buffers.
+ OverlayPlaneList current_planes_;
+ OverlayPlaneList pending_planes_;
+ scoped_refptr<ScanoutBuffer> cursor_buffer_;
+
+ uint32_t crtc_;
+
+ // TODO(dnicoara) Add support for hardware mirroring (multiple connectors).
+ uint32_t connector_;
+
+ drmModeModeInfo mode_;
+
+ // Store the state of the CRTC before we took over. Used to restore the CRTC
+ // once we no longer need it.
+ ScopedDrmCrtcPtr saved_crtc_;
+
+ // Keeps track of the CRTC state. If a surface has been bound, then the value
+ // is set to false. Otherwise it is true.
+ bool is_disabled_;
+
+ // True if a successful SchedulePageFlip occurred. Reset to false by a modeset
+ // operation or when the OnPageFlipEvent callback is triggered.
+ bool page_flip_pending_;
+
+ // The time of the last page flip event as reported by the kernel callback.
+ uint64_t time_of_last_flip_;
+
+ ObserverList<PageFlipObserver> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(CrtcController);
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_PLATFORM_DRM_GPU_CRTC_CONTROLLER_H_