| 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 #include "ui/gfx/rect.h" |
| 18 #include "ui/gfx/size.h" |
| 17 | 19 |
| 18 namespace gfx { | 20 namespace gfx { |
| 19 | 21 |
| 20 class DriSurface; | 22 class ScanoutSurface; |
| 21 | 23 |
| 22 // The HDCOz will handle modesettings and scannout operations for hardware | 24 // The HDCOz will handle modesettings and scannout operations for hardware |
| 23 // devices. | 25 // devices. |
| 24 // | 26 // |
| 25 // In the DRM world there are 3 components that need to be paired up to be able | 27 // 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), | 28 // to display an image to the monitor: CRTC (cathode ray tube controller), |
| 27 // encoder and connector. The CRTC determines which framebuffer to read, when | 29 // 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 | 30 // 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 | 31 // to the appropriate format for the connector. The connector is the physical |
| 30 // connection that monitors connect to. | 32 // 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 | 110 // 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 | 111 // responsible for keeping track of the connector and CRTC and cleaning up |
| 110 // when it is destroyed. | 112 // when it is destroyed. |
| 111 void SetControllerInfo(DriWrapper* drm, | 113 void SetControllerInfo(DriWrapper* drm, |
| 112 uint32_t connector_id, | 114 uint32_t connector_id, |
| 113 uint32_t crtc_id, | 115 uint32_t crtc_id, |
| 114 uint32_t dpms_property_id, | 116 uint32_t dpms_property_id, |
| 115 drmModeModeInfo mode); | 117 drmModeModeInfo mode); |
| 116 | 118 |
| 117 // Associate the HDCO with a surface implementation and initialize it. | 119 // Associate the HDCO with a surface implementation and initialize it. |
| 118 bool BindSurfaceToController(scoped_ptr<DriSurface> surface); | 120 bool BindSurfaceToController(scoped_ptr<ScanoutSurface> surface); |
| 121 |
| 122 // Register the framebuffer with handle |handle| with the CRTC. On successful |
| 123 // registration an ID will be associated with it. The ID will be stored in |
| 124 // |framebuffer_id|. The ID will be used when the HDCO will scan out the |
| 125 // framebuffer. |
| 126 bool AddFramebuffer(uint8_t depth, |
| 127 uint8_t bpp, |
| 128 uint32_t stride, |
| 129 uint32_t handle, |
| 130 uint32_t* framebuffer_id); |
| 131 |
| 132 // Remove the association for the framebuffer with ID |framebuffer_id|. |
| 133 bool RemoveFramebuffer(uint32_t framebuffer_id); |
| 119 | 134 |
| 120 // Schedules the |surface_|'s framebuffer to be displayed on the next vsync | 135 // 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_| | 136 // 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 | 137 // 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 | 138 // 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 | 139 // be presented to the callback. We use that argument to pass in the HDCO |
| 125 // object the event belongs to. | 140 // object the event belongs to. |
| 126 // | 141 // |
| 127 // Between this call and the callback, the framebuffer used in this call | 142 // 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 | 143 // should not be modified in any way as it would cause screen tearing if the |
| 129 // hardware performed the flip. Note that the frontbuffer should also not | 144 // hardware performed the flip. Note that the frontbuffer should also not |
| 130 // be modified as it could still be displayed. | 145 // be modified as it could still be displayed. |
| 131 // | 146 // |
| 132 // Note that this function does not block. Also, this function should not be | 147 // Note that this function does not block. Also, this function should not be |
| 133 // called again before the page flip occurrs. | 148 // called again before the page flip occurrs. |
| 134 // | 149 // |
| 135 // Returns true if the page flip was successfully registered, false otherwise. | 150 // Returns true if the page flip was successfully registered, false otherwise. |
| 136 bool SchedulePageFlip(); | 151 bool SchedulePageFlip(); |
| 137 | 152 |
| 138 // Called when the page flip event occurred. The event is provided by the | 153 // Called when the page flip event occurred. The event is provided by the |
| 139 // kernel when a VBlank event finished. This allows the controller to | 154 // kernel when a VBlank event finished. This allows the controller to |
| 140 // update internal state and propagate the update to the surface. | 155 // update internal state and propagate the update to the surface. |
| 141 // The tuple (seconds, useconds) represents the event timestamp. |seconds| | 156 // The tuple (seconds, useconds) represents the event timestamp. |seconds| |
| 142 // represents the number of seconds while |useconds| represents the | 157 // represents the number of seconds while |useconds| represents the |
| 143 // microseconds (< 1 second) in the timestamp. | 158 // microseconds (< 1 second) in the timestamp. |
| 144 void OnPageFlipEvent(unsigned int frame, | 159 void OnPageFlipEvent(unsigned int frame, |
| 145 unsigned int seconds, | 160 unsigned int seconds, |
| 146 unsigned int useconds); | 161 unsigned int useconds); |
| 147 | 162 |
| 163 void SetOverlayPlaneInfo(gfx::Rect overlay_plane_rect, |
| 164 gfx::Size overlay_plane_size, |
| 165 unsigned overlay_plane_fb_id); |
| 166 |
| 148 State get_state() const { return state_; }; | 167 State get_state() const { return state_; }; |
| 149 | 168 |
| 150 int get_fd() const { return drm_->get_fd(); }; | 169 int get_fd() const { return drm_->get_fd(); }; |
| 151 | 170 |
| 152 const drmModeModeInfo& get_mode() const { return mode_; }; | 171 const drmModeModeInfo& get_mode() const { return mode_; }; |
| 153 | 172 |
| 154 DriSurface* get_surface() const { return surface_.get(); }; | 173 ScanoutSurface* get_surface() const { return surface_.get(); }; |
| 155 | 174 |
| 156 uint64_t get_time_of_last_flip() const { | 175 uint64_t get_time_of_last_flip() const { |
| 157 return time_of_last_flip_; | 176 return time_of_last_flip_; |
| 158 }; | 177 }; |
| 159 | 178 |
| 160 private: | 179 private: |
| 161 // Object containing the connection to the graphics device and wraps the API | 180 // Object containing the connection to the graphics device and wraps the API |
| 162 // calls to control it. | 181 // calls to control it. |
| 163 DriWrapper* drm_; | 182 DriWrapper* drm_; |
| 164 | 183 |
| 165 // TODO(dnicoara) Need to allow a CRTC to have multiple connectors. | 184 // TODO(dnicoara) Need to allow a CRTC to have multiple connectors. |
| 166 uint32_t connector_id_; | 185 uint32_t connector_id_; |
| 167 | 186 |
| 168 uint32_t crtc_id_; | 187 uint32_t crtc_id_; |
| 169 | 188 |
| 170 uint32_t dpms_property_id_; | 189 uint32_t dpms_property_id_; |
| 171 | 190 |
| 172 // TODO(dnicoara) Need to store all the modes. | 191 // TODO(dnicoara) Need to store all the modes. |
| 173 drmModeModeInfo mode_; | 192 drmModeModeInfo mode_; |
| 174 | 193 |
| 175 // Saved CRTC state from before we used it. Need it to restore state once we | 194 // Saved CRTC state from before we used it. Need it to restore state once we |
| 176 // are finished using this device. | 195 // are finished using this device. |
| 177 drmModeCrtc* saved_crtc_; | 196 drmModeCrtc* saved_crtc_; |
| 178 | 197 |
| 179 State state_; | 198 State state_; |
| 180 | 199 |
| 181 scoped_ptr<DriSurface> surface_; | 200 scoped_ptr<ScanoutSurface> surface_; |
| 182 | 201 |
| 183 uint64_t time_of_last_flip_; | 202 uint64_t time_of_last_flip_; |
| 184 | 203 |
| 204 gfx::Rect overlay_plane_rect_; |
| 205 gfx::Size overlay_plane_size_; |
| 206 unsigned overlay_plane_fb_id_; |
| 207 int overlay_plane_; |
| 208 |
| 185 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController); | 209 DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController); |
| 186 }; | 210 }; |
| 187 | 211 |
| 188 } // namespace gfx | 212 } // namespace gfx |
| 189 | 213 |
| 190 #endif // UI_GFX_OZONE_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ | 214 #endif // UI_GFX_OZONE_DRI_HARDWARE_DISPLAY_CONTROLLER_H_ |
| OLD | NEW |