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

Side by Side Diff: ui/gfx/ozone/impl/hardware_display_controller_ozone.h

Issue 49303002: [Ozone] Rename software implementation files to use Dri prefix (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ifdef Created 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 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_GFX_OZONE_IMPL_HARDWARE_DISPLAY_CONTROLLER_OZONE_H_
6 #define UI_GFX_OZONE_IMPL_HARDWARE_DISPLAY_CONTROLLER_OZONE_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10 #include <xf86drmMode.h>
11 #include <vector>
12
13 #include "base/basictypes.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "ui/gfx/ozone/impl/drm_wrapper_ozone.h"
16
17 namespace gfx {
18
19 class SoftwareSurfaceOzone;
20
21 // The HDCOz will handle modesettings and scannout operations for hardware
22 // devices.
23 //
24 // In the DRM world there are 3 components that need to be paired up to be able
25 // to display an image to the monitor: CRTC (cathode ray tube controller),
26 // encoder and connector. The CRTC determines which framebuffer to read, when
27 // to scanout and where to scanout. Encoders converts the stream from the CRTC
28 // to the appropriate format for the connector. The connector is the physical
29 // connection that monitors connect to.
30 //
31 // There is no 1:1:1 pairing for these components. It is possible for an encoder
32 // to be compatible to multiple CRTCs and each connector can be used with
33 // multiple encoders. In addition, it is possible to use one CRTC with multiple
34 // connectors such that we can display the same image on multiple monitors.
35 //
36 // For example, the following configuration shows 2 different screens being
37 // initialized separately.
38 // ------------- -------------
39 // | Connector | | Connector |
40 // | HDMI | | VGA |
41 // ------------- -------------
42 // ^ ^
43 // | |
44 // ------------- -------------
45 // | Encoder1 | | Encoder2 |
46 // ------------- -------------
47 // ^ ^
48 // | |
49 // ------------- -------------
50 // | CRTC1 | | CRTC2 |
51 // ------------- -------------
52 //
53 // In the following configuration 2 different screens are associated with the
54 // same CRTC, so on scanout the same framebuffer will be displayed on both
55 // monitors.
56 // ------------- -------------
57 // | Connector | | Connector |
58 // | HDMI | | VGA |
59 // ------------- -------------
60 // ^ ^
61 // | |
62 // ------------- -------------
63 // | Encoder1 | | Encoder2 |
64 // ------------- -------------
65 // ^ ^
66 // | |
67 // ----------------------
68 // | CRTC1 |
69 // ----------------------
70 //
71 // Note that it is possible to have more connectors than CRTCs which means that
72 // only a subset of connectors can be active independently, showing different
73 // framebuffers. Though, in this case, it would be possible to have all
74 // connectors active if some use the same CRTC to mirror the display.
75 //
76 // TODO(dnicoara) Need to have a way to detect events (such as monitor
77 // connected or disconnected).
78 class HardwareDisplayControllerOzone {
79 public:
80 // Controller states. The state transitions will happen from top to bottom.
81 enum State {
82 // When we allocate a HDCO as a stub. At this point there is no connector
83 // and CRTC associated with this device.
84 UNASSOCIATED,
85
86 // When |SetControllerInfo| is called and the HDCO has the information of
87 // the hardware it will control. At this point it knows everything it needs
88 // to control the hardware but doesn't have a surface.
89 UNINITIALIZED,
90
91 // A surface is associated with the HDCO. This means that the controller can
92 // potentially display the backing surface to the display. Though the
93 // surface framebuffer still needs to be registered with the CRTC.
94 SURFACE_INITIALIZED,
95
96 // The CRTC now knows about the surface attributes.
97 INITIALIZED,
98
99 // Error state if any of the initialization steps fail.
100 FAILED,
101 };
102
103 HardwareDisplayControllerOzone();
104
105 ~HardwareDisplayControllerOzone();
106
107 // Set the hardware configuration for this HDCO. Once this is set, the HDCO is
108 // responsible for keeping track of the connector and CRTC and cleaning up
109 // when it is destroyed.
110 void SetControllerInfo(DrmWrapperOzone* drm,
111 uint32_t connector_id,
112 uint32_t crtc_id,
113 uint32_t dpms_property_id,
114 drmModeModeInfo mode);
115
116 // Associate the HDCO with a surface implementation and initialize it.
117 bool BindSurfaceToController(scoped_ptr<SoftwareSurfaceOzone> surface);
118
119 // Schedules the |surface_|'s framebuffer to be displayed on the next vsync
120 // event. The event will be posted on the graphics card file descriptor |fd_|
121 // and it can be read and processed by |drmHandleEvent|. That function can
122 // define the callback for the page flip event. A generic data argument will
123 // be presented to the callback. We use that argument to pass in the HDCO
124 // object the event belongs to.
125 //
126 // Between this call and the callback, the framebuffer used in this call
127 // should not be modified in any way as it would cause screen tearing if the
128 // hardware performed the flip. Note that the frontbuffer should also not
129 // be modified as it could still be displayed.
130 //
131 // Note that this function does not block. Also, this function should not be
132 // called again before the page flip occurrs.
133 //
134 // Returns true if the page flip was successfully registered, false otherwise.
135 bool SchedulePageFlip();
136
137 State get_state() const { return state_; };
138
139 int get_fd() const { return drm_->get_fd(); };
140
141 const drmModeModeInfo& get_mode() const { return mode_; };
142
143 SoftwareSurfaceOzone* get_surface() const { return surface_.get(); };
144
145 private:
146 // Object containing the connection to the graphics device and wraps the API
147 // calls to control it.
148 DrmWrapperOzone* drm_;
149
150 // TODO(dnicoara) Need to allow a CRTC to have multiple connectors.
151 uint32_t connector_id_;
152
153 uint32_t crtc_id_;
154
155 uint32_t dpms_property_id_;
156
157 // TODO(dnicoara) Need to store all the modes.
158 drmModeModeInfo mode_;
159
160 // Saved CRTC state from before we used it. Need it to restore state once we
161 // are finished using this device.
162 drmModeCrtc* saved_crtc_;
163
164 State state_;
165
166 scoped_ptr<SoftwareSurfaceOzone> surface_;
167
168 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayControllerOzone);
169 };
170
171 } // namespace gfx
172
173 #endif // UI_GFX_OZONE_IMPL_HARDWARE_DISPLAY_CONTROLLER_OZONE_H_
OLDNEW
« no previous file with comments | « ui/gfx/ozone/impl/hardware_display_controller.cc ('k') | ui/gfx/ozone/impl/hardware_display_controller_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698