vdr-plugin-softhddevice-drm-gles 1.6.2
drmplane.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-or-later
2
16#include <cerrno>
17#include <cinttypes>
18#include <cstdlib>
19#include <cstring>
20
21#include <xf86drm.h>
22#include <xf86drmMode.h>
23
24#include "drmplane.h"
25#include "logger.h"
26
40{
42 if (!props) {
43 LOGERROR("drmplane: %s: could not get %u properties: %s", __FUNCTION__, GetId(), strerror(errno));
44 return;
45 }
46
48
49 m_propsInfo = (drmModePropertyRes **)calloc(m_props->count_props, sizeof(*m_propsInfo));
50 for (uint32_t i = 0; i < m_props->count_props; i++) {
52 }
53}
54
59{
60 if (!GetProps())
61 return;
62
63 if (!GetPropsInfo())
64 return;
65
66 for (uint32_t i = 0; i < m_props->count_props; i++) {
67 if (m_propsInfo[i])
69
70 }
73}
74
106
115{
116 int id = -1;
117
118 for (int i = 0; i < GetCountProps(); i++) {
119 if (strcmp(GetPropsInfoName(i), propName) == 0) {
120 id = GetPropsInfoPropId(i);
121 break;
122 }
123 }
124
125 if (id < 0) {
126 LOGDEBUG("drmplane: %s: Unable to find value for property \'%s\'.",
128 return -EINVAL;
129 }
130
132}
133
143
150{
151 SetPropertyRequest(ModeReq, "CRTC_ID", GetCrtcId());
153
154 SetPropertyRequest(ModeReq, "CRTC_X", GetCrtcX());
155 SetPropertyRequest(ModeReq, "CRTC_Y", GetCrtcY());
156 SetPropertyRequest(ModeReq, "CRTC_W", GetCrtcW());
157 SetPropertyRequest(ModeReq, "CRTC_H", GetCrtcH());
158
161 SetPropertyRequest(ModeReq, "SRC_W", GetSrcW() << 16);
162 SetPropertyRequest(ModeReq, "SRC_H", GetSrcH() << 16);
163}
164
175
185{
188
189 if (!(ModeReq = drmModeAtomicAlloc())) {
190 LOGERROR("drmplane: %s: cannot allocate atomic request (%d): %m", __FUNCTION__, errno);
191 return 0;
192 }
193
195
197 LOGDEBUG2(L_DRM, "drmplane: %s: cannot set atomic mode (%d), don't use zpos change: %m",
200 return 0;
201 }
202
204
205 return 1;
206}
207
211void cDrmPlane::DumpParameters(const char *id)
212{
213 LOGERROR("DumpParameters (plane_id = %d | %s):", GetId(), id);
214 LOGERROR(" CRTC ID: %" PRIu64 "", GetCrtcId());
215 LOGERROR(" FB ID : %" PRIu64 "", GetFbId());
216 LOGERROR(" CRTC X : %" PRIu64 "", GetCrtcX());
217 LOGERROR(" CRTC Y : %" PRIu64 "", GetCrtcY());
218 LOGERROR(" CRTC W : %" PRIu64 "", GetCrtcW());
219 LOGERROR(" CRTC H : %" PRIu64 "", GetCrtcH());
220 LOGERROR(" SRC X : %" PRIu64 "", GetSrcX());
221 LOGERROR(" SRC Y : %" PRIu64 "", GetSrcY());
222 LOGERROR(" SRC W : %" PRIu64 "", GetSrcW());
223 LOGERROR(" SRC H : %" PRIu64 "", GetSrcH());
224 LOGERROR(" ZPOS : %" PRIu64 "", GetZpos());
225}
226
uint64_t m_crtcX
CRTC_X.
Definition drmplane.h:77
uint64_t GetCrtcX(void)
Definition drmplane.h:48
uint64_t m_fbId
FB_ID.
Definition drmplane.h:76
uint64_t GetCrtcId(void)
Definition drmplane.h:46
uint64_t GetCrtcH(void)
Definition drmplane.h:51
uint64_t m_crtcId
CRTC_ID.
Definition drmplane.h:75
void SetProps(drmModeObjectProperties *props)
Definition drmplane.h:63
uint64_t GetSrcH(void)
Definition drmplane.h:55
uint32_t GetPropsInfoPropId(int prop)
Definition drmplane.h:61
uint64_t GetZpos(void)
Definition drmplane.h:56
char * GetPropsInfoName(int prop)
Definition drmplane.h:60
uint64_t GetSrcY(void)
Definition drmplane.h:53
uint64_t m_crtcW
CRTC_W.
Definition drmplane.h:79
uint64_t m_srcW
SRC_W.
Definition drmplane.h:83
uint64_t GetFbId(void)
Definition drmplane.h:47
drmModeObjectProperties * m_props
Definition drmplane.h:71
drmModePropertyRes ** GetPropsInfo(void)
Definition drmplane.h:64
uint64_t m_crtcH
CRTC_H.
Definition drmplane.h:80
int GetCountProps(void)
Definition drmplane.h:59
drmModePropertyRes ** m_propsInfo
Definition drmplane.h:72
uint64_t m_crtcY
CRTC_Y.
Definition drmplane.h:78
uint64_t GetSrcW(void)
Definition drmplane.h:54
uint64_t m_srcY
SRC_Y.
Definition drmplane.h:82
uint64_t m_srcH
SRC_H.
Definition drmplane.h:84
drmModeObjectProperties * GetProps(void)
Definition drmplane.h:62
uint64_t GetSrcX(void)
Definition drmplane.h:52
uint64_t GetCrtcW(void)
Definition drmplane.h:50
uint64_t m_srcX
SRC_X.
Definition drmplane.h:81
uint32_t GetId(void)
Definition drmplane.h:42
uint64_t GetCrtcY(void)
Definition drmplane.h:49
DRM Plane Header File.
void SetParams(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t)
Caches the modesetting parameters of a plane.
Definition drmplane.cpp:91
void ClearPlane(drmModeAtomicReqPtr)
Clear plane from drm.
Definition drmplane.cpp:170
int SetPropertyRequest(drmModeAtomicReqPtr, const char *, uint64_t)
Add the properties to the mode setting request.
Definition drmplane.cpp:114
int HasZpos(int)
Check, if the plane is able to set the zpos property.
Definition drmplane.cpp:184
void FillProperties(int)
Fill the plane properties.
Definition drmplane.cpp:39
void FreeProperties(void)
Free the previously filled plane properties.
Definition drmplane.cpp:58
void SetPlane(drmModeAtomicReqPtr)
Set all plane properties (except zpos)
Definition drmplane.cpp:149
void SetPlaneZpos(drmModeAtomicReqPtr)
Set the plane zpos property.
Definition drmplane.cpp:139
void DumpParameters(const char *)
Dump the cached plane parameter modesetting values.
Definition drmplane.cpp:211
#define LOGDEBUG2
log to LOG_DEBUG and add a prefix
Definition logger.h:42
#define LOGDEBUG
log to LOG_DEBUG
Definition logger.h:40
#define LOGERROR
log to LOG_ERR
Definition logger.h:34
@ L_DRM
drm logs
Definition logger.h:55
Logger Header File.