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.
5 #ifndef UI_GFX_OZONE_DRI_DRI_WRAPPER_H_
6 #define UI_GFX_OZONE_DRI_DRI_WRAPPER_H_
10 #include "base/basictypes.h"
11 #include "ui/gfx/gfx_export.h"
13 typedef struct _drmModeCrtc drmModeCrtc;
14 typedef struct _drmModeModeInfo drmModeModeInfo;
18 // Wraps DRM calls into a nice interface. Used to provide different
19 // implementations of the DRM calls. For the actual implementation the DRM API
20 // would be called. In unit tests this interface would be stubbed.
21 class GFX_EXPORT DriWrapper {
23 DriWrapper(const char* device_path);
24 virtual ~DriWrapper();
26 // Get the CRTC state. This is generally used to save state before using the
27 // CRTC. When the user finishes using the CRTC, the user should restore the
28 // CRTC to it's initial state. Use |SetCrtc| to restore the state.
29 virtual drmModeCrtc* GetCrtc(uint32_t crtc_id);
31 // Frees the CRTC mode object.
32 virtual void FreeCrtc(drmModeCrtc* crtc);
34 // Used to configure CRTC with ID |crtc_id| to use the connector in
35 // |connectors|. The CRTC will be configured with mode |mode| and will display
36 // the framebuffer with ID |framebuffer|. Before being able to display the
37 // framebuffer, it should be registered with the CRTC using |AddFramebuffer|.
38 virtual bool SetCrtc(uint32_t crtc_id,
41 drmModeModeInfo* mode);
43 // Used to set a specific configuration to the CRTC. Normally this function
44 // would be called with a CRTC saved state (from |GetCrtc|) to restore it to
45 // its original configuration.
46 virtual bool SetCrtc(drmModeCrtc* crtc, uint32_t* connectors);
48 // Register a buffer with the CRTC. On successful registration, the CRTC will
49 // assign a framebuffer ID to |framebuffer|.
50 virtual bool AddFramebuffer(const drmModeModeInfo& mode,
55 uint32_t* framebuffer);
57 // Deregister the given |framebuffer|.
58 virtual bool RemoveFramebuffer(uint32_t framebuffer);
60 // Schedules a pageflip for CRTC |crtc_id|. This function will return
61 // immediately. Upon completion of the pageflip event, the CRTC will be
62 // displaying the buffer with ID |framebuffer| and will have a DRM event
63 // queued on |fd_|. |data| is a generic pointer to some information the user
64 // will receive when processing the pageflip event.
65 virtual bool PageFlip(uint32_t crtc_id, uint32_t framebuffer, void* data);
67 // Sets the value of property with ID |property_id| to |value|. The property
68 // is applied to the connector with ID |connector_id|.
69 virtual bool ConnectorSetProperty(uint32_t connector_id,
73 // Set the cursor to be displayed in CRTC |crtc_id|. (width, height) is the
74 // cursor size pointed by |handle|.
75 virtual bool SetCursor(uint32_t crtc_id,
81 // Move the cursor on CRTC |crtc_id| to (x, y);
82 virtual bool MoveCursor(uint32_t crtc_id, int x, int y);
84 int get_fd() const { return fd_; }
87 // The file descriptor associated with this wrapper. All DRM operations will
88 // be performed using this FD.
92 DISALLOW_COPY_AND_ASSIGN(DriWrapper);
97 #endif // UI_GFX_OZONE_DRI_DRI_WRAPPER_H_