OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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_DRM_WRAPPER_OZONE_H_ |
| 6 #define UI_GFX_OZONE_IMPL_DRM_WRAPPER_OZONE_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 |
| 12 typedef struct _drmModeCrtc drmModeCrtc; |
| 13 typedef struct _drmModeModeInfo drmModeModeInfo; |
| 14 |
| 15 namespace gfx { |
| 16 |
| 17 // Wraps DRM calls into a nice interface. Used to provide different |
| 18 // implementations of the DRM calls. For the actual implementation the DRM API |
| 19 // would be called. In unit tests this interface would be stubbed. |
| 20 class DrmWrapperOzone { |
| 21 public: |
| 22 DrmWrapperOzone(const char* device_path); |
| 23 virtual ~DrmWrapperOzone(); |
| 24 |
| 25 // Get the CRTC state. This is generally used to save state before using the |
| 26 // CRTC. When the user finishes using the CRTC, the user should restore the |
| 27 // CRTC to it's initial state. Use |SetCrtc| to restore the state. |
| 28 virtual drmModeCrtc* GetCrtc(uint32_t crtc_id); |
| 29 |
| 30 // Frees the CRTC mode object. |
| 31 virtual void FreeCrtc(drmModeCrtc* crtc); |
| 32 |
| 33 // Used to configure CRTC with ID |crtc_id| to use the connector in |
| 34 // |connectors|. The CRTC will be configured with mode |mode| and will display |
| 35 // the framebuffer with ID |framebuffer|. Before being able to display the |
| 36 // framebuffer, it should be registered with the CRTC using |AddFramebuffer|. |
| 37 virtual bool SetCrtc(uint32_t crtc_id, |
| 38 uint32_t framebuffer, |
| 39 uint32_t* connectors, |
| 40 drmModeModeInfo* mode); |
| 41 |
| 42 // Used to set a specific configuration to the CRTC. Normally this function |
| 43 // would be called with a CRTC saved state (from |GetCrtc|) to restore it to |
| 44 // its original configuration. |
| 45 virtual bool SetCrtc(drmModeCrtc* crtc, uint32_t* connectors); |
| 46 |
| 47 // Register a buffer with the CRTC. On successful registration, the CRTC will |
| 48 // assign a framebuffer ID to |framebuffer|. |
| 49 virtual bool AddFramebuffer(const drmModeModeInfo& mode, |
| 50 uint8_t depth, |
| 51 uint8_t bpp, |
| 52 uint32_t stride, |
| 53 uint32_t handle, |
| 54 uint32_t* framebuffer); |
| 55 |
| 56 // Deregister the given |framebuffer|. |
| 57 virtual bool RemoveFramebuffer(uint32_t framebuffer); |
| 58 |
| 59 // Schedules a pageflip for CRTC |crtc_id|. This function will return |
| 60 // immediately. Upon completion of the pageflip event, the CRTC will be |
| 61 // displaying the buffer with ID |framebuffer| and will have a DRM event |
| 62 // queued on |fd_|. |data| is a generic pointer to some information the user |
| 63 // will receive when processing the pageflip event. |
| 64 virtual bool PageFlip(uint32_t crtc_id, uint32_t framebuffer, void* data); |
| 65 |
| 66 int get_fd() const { return fd_; } |
| 67 |
| 68 protected: |
| 69 // The file descriptor associated with this wrapper. All DRM operations will |
| 70 // be performed using this FD. |
| 71 int fd_; |
| 72 |
| 73 private: |
| 74 DISALLOW_COPY_AND_ASSIGN(DrmWrapperOzone); |
| 75 }; |
| 76 |
| 77 } // namespace gfx |
| 78 |
| 79 #endif // UI_GFX_OZONE_IMPL_DRM_WRAPPER_OZONE_H_ |
OLD | NEW |