OLD | NEW |
| (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_DRI_WRAPPER_H_ | |
6 #define UI_GFX_OZONE_IMPL_DRI_WRAPPER_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 DriWrapper { | |
21 public: | |
22 DriWrapper(const char* device_path); | |
23 virtual ~DriWrapper(); | |
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 // Sets the value of property with ID |property_id| to |value|. The property | |
67 // is applied to the connector with ID |connector_id|. | |
68 virtual bool ConnectorSetProperty(uint32_t connector_id, | |
69 uint32_t property_id, | |
70 uint64_t value); | |
71 | |
72 int get_fd() const { return fd_; } | |
73 | |
74 protected: | |
75 // The file descriptor associated with this wrapper. All DRM operations will | |
76 // be performed using this FD. | |
77 int fd_; | |
78 | |
79 private: | |
80 DISALLOW_COPY_AND_ASSIGN(DriWrapper); | |
81 }; | |
82 | |
83 } // namespace gfx | |
84 | |
85 #endif // UI_GFX_OZONE_IMPL_DRI_WRAPPER_H_ | |
OLD | NEW |