Mir
real_kms_output.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17  */
18 
19 #ifndef MIR_GRAPHICS_MESA_REAL_KMS_OUTPUT_H_
20 #define MIR_GRAPHICS_MESA_REAL_KMS_OUTPUT_H_
21 
22 #include "kms_output.h"
23 #include "drm_mode_resources.h"
24 
25 #include <memory>
26 #include <mutex>
27 
28 namespace mir
29 {
30 namespace graphics
31 {
32 namespace mesa
33 {
34 
35 class PageFlipper;
36 
37 class RealKMSOutput : public KMSOutput
38 {
39 public:
40  RealKMSOutput(int drm_fd, uint32_t connector_id,
41  std::shared_ptr<PageFlipper> const& page_flipper);
43 
44  void reset();
45  void configure(geometry::Displacement fb_offset, size_t kms_mode_index);
46  geometry::Size size() const;
47  int max_refresh_rate() const;
48 
49  bool set_crtc(uint32_t fb_id);
50  void clear_crtc();
51  bool schedule_page_flip(uint32_t fb_id);
52  void wait_for_page_flip();
53 
54  void set_cursor(gbm_bo* buffer);
55  void move_cursor(geometry::Point destination);
56  void clear_cursor();
57  bool has_cursor() const;
58 
59  void set_power_mode(MirPowerMode mode);
60 
61 private:
62  bool ensure_crtc();
63  void restore_saved_crtc();
64 
65  int const drm_fd;
66  uint32_t const connector_id;
67  std::shared_ptr<PageFlipper> const page_flipper;
68 
69  DRMModeConnectorUPtr connector;
70  size_t mode_index;
71  geometry::Displacement fb_offset;
72  DRMModeCrtcUPtr current_crtc;
73  drmModeCrtc saved_crtc;
74  bool using_saved_crtc;
75  bool has_cursor_;
76 
77  MirPowerMode power_mode;
78  int dpms_enum_id;
79 
80  std::mutex power_mutex;
81 };
82 
83 }
84 }
85 }
86 
87 #endif /* MIR_GRAPHICS_MESA_REAL_KMS_OUTPUT_H_ */
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
std::unique_ptr< drmModeConnector, std::function< void(drmModeConnector *)> > DRMModeConnectorUPtr
Definition: drm_mode_resources.h:37
bool schedule_page_flip(uint32_t fb_id)
Definition: point.h:30
Definition: kms_output.h:37
RealKMSOutput(int drm_fd, uint32_t connector_id, std::shared_ptr< PageFlipper > const &page_flipper)
int max_refresh_rate() const
Approximate maximum refresh rate of this output to within 1Hz.
void configure(geometry::Displacement fb_offset, size_t kms_mode_index)
void move_cursor(geometry::Point destination)
MirPowerMode
Definition: common.h:101
void set_cursor(gbm_bo *buffer)
Definition: displacement.h:32
std::unique_ptr< drmModeCrtc, std::function< void(drmModeCrtc *)> > DRMModeCrtcUPtr
Definition: drm_mode_resources.h:35
Definition: real_kms_output.h:37
geometry::Size size() const
void set_power_mode(MirPowerMode mode)

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016