Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_object.h
Show All 34 Lines | |||||
35 | class DrmObject | 35 | class DrmObject | ||
36 | { | 36 | { | ||
37 | public: | 37 | public: | ||
38 | // creates drm object by its id delivered by the kernel | 38 | // creates drm object by its id delivered by the kernel | ||
39 | DrmObject(uint32_t object_id, int fd); | 39 | DrmObject(uint32_t object_id, int fd); | ||
40 | 40 | | |||
41 | virtual ~DrmObject() = 0; | 41 | virtual ~DrmObject() = 0; | ||
42 | 42 | | |||
43 | enum class AtomicReturn { | | |||
44 | NoChange, | | |||
45 | Success, | | |||
46 | Error | | |||
47 | }; | | |||
48 | | ||||
49 | virtual bool init() = 0; | 43 | virtual bool init() = 0; | ||
50 | 44 | | |||
51 | uint32_t id() const { | 45 | uint32_t id() const { | ||
52 | return m_id; | 46 | return m_id; | ||
53 | } | 47 | } | ||
54 | 48 | | |||
55 | DrmOutput* output() const { | 49 | DrmOutput *output() const { | ||
56 | return m_output; | 50 | return m_output; | ||
57 | } | 51 | } | ||
58 | void setOutput(DrmOutput* output) { | 52 | void setOutput(DrmOutput* output) { | ||
59 | m_output = output; | 53 | m_output = output; | ||
60 | } | 54 | } | ||
61 | 55 | | |||
62 | uint32_t propId(int index) { | 56 | uint32_t propId(int prop) { | ||
63 | return m_props[index]->propId(); | 57 | return m_props[prop]->propId(); | ||
64 | } | 58 | } | ||
65 | uint64_t propValue(int index) { | 59 | uint64_t value(int prop) { | ||
66 | return m_props[index]->value(); | 60 | return m_props[prop]->value(); | ||
67 | } | 61 | } | ||
68 | void setPropValue(int index, uint64_t new_value); | | |||
69 | 62 | | |||
70 | uint32_t propsPending() { | 63 | void setValue(int prop, uint64_t new_value) | ||
71 | return m_propsPending; | 64 | { | ||
72 | } | 65 | Q_ASSERT(prop < m_props.size()); | ||
73 | uint32_t propsValid() { | 66 | m_props[prop]->setValue(new_value); | ||
74 | return m_propsValid; | | |||
75 | } | | |||
76 | void setPropsPending(uint32_t value) { | | |||
77 | m_propsPending = value; | | |||
78 | } | | |||
79 | void setPropsValid(uint32_t value) { | | |||
80 | m_propsValid = value; | | |||
81 | } | 67 | } | ||
82 | 68 | | |||
83 | bool atomicAddProperty(drmModeAtomicReq *req, int prop, uint64_t value); | 69 | virtual bool atomicPopulate(drmModeAtomicReq *req); | ||
84 | 70 | | |||
85 | protected: | 71 | protected: | ||
72 | virtual bool initProps() = 0; // only derived classes know names and quantity of properties | ||||
73 | void initProp(int n, drmModeObjectProperties *properties, QVector<QByteArray> enumNames = QVector<QByteArray>(0)); | ||||
74 | bool atomicAddProperty(drmModeAtomicReq *req, int prop, uint64_t value); | ||||
75 | | ||||
86 | const int m_fd = 0; | 76 | const int m_fd = 0; | ||
87 | const uint32_t m_id = 0; | 77 | const uint32_t m_id = 0; | ||
88 | | ||||
89 | DrmOutput *m_output = nullptr; | 78 | DrmOutput *m_output = nullptr; | ||
90 | 79 | | |||
91 | QVector<QByteArray> m_propsNames; // for comparision with received name of DRM object | 80 | // for comparision with received name of DRM object | ||
81 | QVector<QByteArray> m_propsNames; | ||||
92 | class Property; | 82 | class Property; | ||
93 | QVector<Property*> m_props; | 83 | QVector<Property *> m_props; | ||
94 | 84 | | |||
95 | uint32_t m_propsPending = 0; | | |||
96 | uint32_t m_propsValid = 0; | | |||
97 | | ||||
98 | virtual bool initProps() = 0; // only derived classes know names and quantity of properties | | |||
99 | void initProp(int n, drmModeObjectProperties *properties, QVector<QByteArray> enumNames = QVector<QByteArray>(0)); | | |||
100 | | ||||
101 | class Property | 85 | class Property | ||
102 | { | 86 | { | ||
103 | public: | 87 | public: | ||
104 | Property(drmModePropertyRes *prop, uint64_t val, QVector<QByteArray> enumNames); | 88 | Property(drmModePropertyRes *prop, uint64_t val, QVector<QByteArray> enumNames); | ||
105 | virtual ~Property(); | 89 | virtual ~Property(); | ||
106 | 90 | | |||
107 | void initEnumMap(drmModePropertyRes *prop); | 91 | void initEnumMap(drmModePropertyRes *prop); | ||
108 | 92 | | |||
109 | uint64_t enumMap(int n) { | 93 | uint64_t enumMap(int n) { | ||
110 | return m_enumMap[n]; // TODO: test on index out of bounds? | 94 | return m_enumMap[n]; // TODO: test on index out of bounds? | ||
111 | } | 95 | } | ||
112 | 96 | | |||
113 | uint32_t propId() { | 97 | uint32_t propId() { | ||
114 | return m_propId; | 98 | return m_propId; | ||
115 | } | 99 | } | ||
116 | uint32_t value() { | 100 | uint64_t value() { | ||
117 | return m_value; | 101 | return m_value; | ||
118 | } | 102 | } | ||
119 | void setValue(uint64_t new_value) { | 103 | void setValue(uint64_t new_value) { | ||
120 | m_value = new_value; | 104 | m_value = new_value; | ||
121 | } | 105 | } | ||
122 | 106 | | |||
123 | private: | 107 | private: | ||
124 | uint32_t m_propId = 0; | 108 | uint32_t m_propId = 0; | ||
Show All 13 Lines |