1 #pragma once 2 3 #include <cstdint> 4 #include <vector> 5 #include <map> 6 #include <memory> 7 8 #include "decls.h" 9 #include "pipeline.h" 10 11 namespace kms 12 { 13 class Card 14 { 15 friend class Framebuffer; 16 public: 17 Card(const std::string& dev_path = ""); 18 Card(const std::string& driver, uint32_t idx); 19 virtual ~Card(); 20 21 Card(const Card& other) = delete; 22 Card& operator=(const Card& other) = delete; 23 fd()24 int fd() const { return m_fd; } 25 26 void drop_master(); 27 28 Connector* get_first_connected_connector() const; 29 30 DrmObject* get_object(uint32_t id) const; 31 Connector* get_connector(uint32_t id) const; 32 Crtc* get_crtc(uint32_t id) const; 33 Encoder* get_encoder(uint32_t id) const; 34 Plane* get_plane(uint32_t id) const; 35 Property* get_prop(uint32_t id) const; 36 is_master()37 bool is_master() const { return m_is_master; } has_atomic()38 bool has_atomic() const { return m_has_atomic; } has_has_universal_planes()39 bool has_has_universal_planes() const { return m_has_universal_planes; } has_dumb_buffers()40 bool has_dumb_buffers() const { return m_has_dumb; } 41 bool has_kms() const; 42 get_connectors()43 const std::vector<Connector*> get_connectors() const { return m_connectors; } get_encoders()44 const std::vector<Encoder*> get_encoders() const { return m_encoders; } get_crtcs()45 const std::vector<Crtc*> get_crtcs() const { return m_crtcs; } get_planes()46 const std::vector<Plane*> get_planes() const { return m_planes; } get_properties()47 const std::vector<Property*> get_properties() const { return m_properties; } 48 49 const std::vector<DrmObject*> get_objects() const; 50 51 std::vector<Pipeline> get_connected_pipelines(); 52 53 void call_page_flip_handlers(); 54 55 int disable_all(); 56 version_name()57 const std::string& version_name() const { return m_version_name; } 58 59 private: 60 void setup(); 61 void restore_modes(); 62 63 std::map<uint32_t, DrmObject*> m_obmap; 64 65 std::vector<Connector*> m_connectors; 66 std::vector<Encoder*> m_encoders; 67 std::vector<Crtc*> m_crtcs; 68 std::vector<Plane*> m_planes; 69 std::vector<Property*> m_properties; 70 std::vector<Framebuffer*> m_framebuffers; 71 72 int m_fd; 73 bool m_is_master; 74 75 bool m_has_atomic; 76 bool m_has_universal_planes; 77 bool m_has_dumb; 78 79 int m_version_major; 80 int m_version_minor; 81 int m_version_patchlevel; 82 std::string m_version_name; 83 std::string m_version_date; 84 std::string m_version_desc; 85 }; 86 } 87