OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef UI_GFX_OZONE_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ | 5 #ifndef UI_GFX_OZONE_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ |
6 #define UI_GFX_OZONE_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ | 6 #define UI_GFX_OZONE_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <xf86drmMode.h> | 10 #include <xf86drmMode.h> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "ui/gfx/gfx_export.h" | 15 #include "ui/gfx/gfx_export.h" |
16 #include "ui/gfx/ozone/dri/dri_wrapper.h" | 16 #include "ui/gfx/ozone/dri/dri_wrapper.h" |
17 | 17 |
18 namespace gfx { | 18 namespace gfx { |
19 | 19 |
20 class DriSurface; | 20 class ScanoutSurface; |
21 | 21 |
22 // The HDCOz will handle modesettings and scannout operations for hardware | 22 // The HDCOz will handle modesettings and scannout operations for hardware |
23 // devices. | 23 // devices. |
24 // | 24 // |
25 // In the DRM world there are 3 components that need to be paired up to be able | 25 // In the DRM world there are 3 components that need to be paired up to be able |
26 // to display an image to the monitor: CRTC (cathode ray tube controller), | 26 // to display an image to the monitor: CRTC (cathode ray tube controller), |
27 // encoder and connector. The CRTC determines which framebuffer to read, when | 27 // encoder and connector. The CRTC determines which framebuffer to read, when |
28 // to scanout and where to scanout. Encoders converts the stream from the CRTC | 28 // to scanout and where to scanout. Encoders converts the stream from the CRTC |
29 // to the appropriate format for the connector. The connector is the physical | 29 // to the appropriate format for the connector. The connector is the physical |
30 // connection that monitors connect to. | 30 // connection that monitors connect to. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // Set the hardware configuration for this HDCO. Once this is set, the HDCO is | 108 // Set the hardware configuration for this HDCO. Once this is set, the HDCO is |
109 // responsible for keeping track of the connector and CRTC and cleaning up | 109 // responsible for keeping track of the connector and CRTC and cleaning up |
110 // when it is destroyed. | 110 // when it is destroyed. |
111 void SetControllerInfo(DriWrapper* drm, | 111 void SetControllerInfo(DriWrapper* drm, |
112 uint32_t connector_id, | 112 uint32_t connector_id, |
113 uint32_t crtc_id, | 113 uint32_t crtc_id, |
114 uint32_t dpms_property_id, | 114 uint32_t dpms_property_id, |
115 drmModeModeInfo mode); | 115 drmModeModeInfo mode); |
116 | 116 |
117 // Associate the HDCO with a surface implementation and initialize it. | 117 // Associate the HDCO with a surface implementation and initialize it. |
118 bool BindSurfaceToController(scoped_ptr<DriSurface> surface); | 118 bool BindSurfaceToController(scoped_ptr<ScanoutSurface> surface); |
| 119 |
| 120 // Register the framebuffer with handle |handle| with the CRTC. On successful |
| 121 // registration an ID will be associated with it. The ID will be stored in |
| 122 // |framebuffer_id|. The ID will be used when the HDCO will scan out the |
| 123 // framebuffer. |
| 124 bool AddFramebuffer(uint8_t depth, |
| 125 uint8_t bpp, |
| 126 uint32_t stride, |
| 127 uint32_t handle, |
| 128 uint32_t* framebuffer_id); |
| 129 |
| 130 // Remove the association for the framebuffer with ID |framebuffer_id|. |
| 131 bool RemoveFramebuffer(uint32_t framebuffer_id); |
119 | 132 |
120 // Schedules the |surface_|'s framebuffer to be displayed on the next vsync | 133 // Schedules the |surface_|'s framebuffer to be displayed on the next vsync |
121 // event. The event will be posted on the graphics card file descriptor |fd_| | 134 // event. The event will be posted on the graphics card file descriptor |fd_| |
122 // and it can be read and processed by |drmHandleEvent|. That function can | 135 // and it can be read and processed by |drmHandleEvent|. That function can |
123 // define the callback for the page flip event. A generic data argument will | 136 // define the callback for the page flip event. A generic data argument will |
124 // be presented to the callback. We use that argument to pass in the HDCO | 137 // be presented to the callback. We use that argument to pass in the HDCO |
125 // object the event belongs to. | 138 // object the event belongs to. |
126 // | 139 // |
127 // Between this call and the callback, the framebuffer used in this call | 140 // Between this call and the callback, the framebuffer used in this call |
128 // should not be modified in any way as it would cause screen tearing if the | 141 // should not be modified in any way as it would cause screen tearing if the |
(...skipping 15 matching lines...) Expand all Loading... |
144 void OnPageFlipEvent(unsigned int frame, | 157 void OnPageFlipEvent(unsigned int frame, |
145 unsigned int seconds, | 158 unsigned int seconds, |
146 unsigned int useconds); | 159 unsigned int useconds); |
147 | 160 |
148 State get_state() const { return state_; }; | 161 State get_state() const { return state_; }; |
149 | 162 |
150 int get_fd() const { return drm_->get_fd(); }; | 163 int get_fd() const { return drm_->get_fd(); }; |
151 | 164 |
152 const drmModeModeInfo& get_mode() const { return mode_; }; | 165 const drmModeModeInfo& get_mode() const { return mode_; }; |
153 | 166 |
154 DriSurface* get_surface() const { return surface_.get(); }; | 167 ScanoutSurface* get_surface() const { return surface_.get(); }; |
155 | 168 |
156 uint64_t get_time_of_last_flip() const { | 169 uint64_t get_time_of_last_flip() const { |
157 return time_of_last_flip_; | 170 return time_of_last_flip_; |
158 }; | 171 }; |
159 | 172 |
160 private: | 173 private: |
161 // Object containing the connection to the graphics device and wraps the API | 174 // Object containing the connection to the graphics device and wraps the API |
162 // calls to control it. | 175 // calls to control it. |
163 DriWrapper* drm_; | 176 DriWrapper* drm_; |
164 | 177 |
165 // TODO(dnicoara) Need to allow a CRTC to have multiple connectors. | 178 // TODO(dnicoara) Need to allow a CRTC to have multiple connectors. |
166 uint32_t connector_id_; | 179 uint32_t connector_id_; |
167 | 180 |
168 uint32_t crtc_id_; | 181 uint32_t crtc_id_; |
169 | 182 |
170 uint32_t dpms_property_id_; | 183 uint32_t dpms_property_id_; |
171 | 184 |
172 // TODO(dnicoara) Need to store all the modes. | 185 // TODO(dnicoara) Need to store all the modes. |
173 drmModeModeInfo mode_; | 186 drmModeModeInfo mode_; |
174 | 187 |
175 // Saved CRTC state from before we used it. Need it to restore state once we | 188 // Saved CRTC state from before we used it. Need it to restore state once we |
176 // are finished using this device. | 189 // are finished using this device. |
177 drmModeCrtc* saved_crtc_; | 190 drmModeCrtc* saved_crtc_; |
178 | 191 |
179 State state_; | 192 State state_; |
180 | 193 |
181 scoped_ptr<DriSurface> surface_; | 194 scoped_ptr<ScanoutSurface> surface_; |
182 | 195 |
183 uint64_t time_of_last_flip_; | 196 uint64_t time_of_last_flip_; |
184 | 197 |
185 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController); | 198 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController); |
186 }; | 199 }; |
187 | 200 |
188 } // namespace gfx | 201 } // namespace gfx |
189 | 202 |
190 #endif // UI_GFX_OZONE_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ | 203 #endif // UI_GFX_OZONE_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ |
OLD | NEW |