1 #pragma once
2 
3 #include <vector>
4 
5 #include "drmpropobject.h"
6 
7 namespace kms
8 {
9 struct CrtcPriv;
10 
11 class Crtc : public DrmPropObject
12 {
13 	friend class Card;
14 	friend class Connector;
15 
16 public:
17 	void refresh();
18 
get_possible_planes()19 	const std::vector<Plane*>& get_possible_planes() const { return m_possible_planes; }
20 
21 	int set_mode(Connector* conn, const Videomode& mode);
22 	int set_mode(Connector* conn, Framebuffer& fb, const Videomode& mode);
23 
24 	int set_plane(Plane* plane, Framebuffer& fb,
25 		      int32_t dst_x, int32_t dst_y, uint32_t dst_w, uint32_t dst_h,
26 		      float src_x, float src_y, float src_w, float src_h);
27 	int disable_mode();
28 
29 	int disable_plane(Plane* plane);
30 
31 	Plane* get_primary_plane();
32 
33 	int page_flip(Framebuffer& fb, void* data);
34 
35 	uint32_t buffer_id() const;
36 	uint32_t x() const;
37 	uint32_t y() const;
38 	uint32_t width() const;
39 	uint32_t height() const;
40 	int mode_valid() const;
41 	Videomode mode() const;
42 	int legacy_gamma_size() const;
43 	void legacy_gamma_set(std::vector<std::tuple<uint16_t, uint16_t, uint16_t>> v);
44 
45 private:
46 	Crtc(Card& card, uint32_t id, uint32_t idx);
47 	~Crtc() override;
48 
49 	void setup() override;
50 	void restore_mode(Connector* conn);
51 
52 	CrtcPriv* m_priv;
53 
54 	std::vector<Plane*> m_possible_planes;
55 };
56 } // namespace kms
57