vdr-plugin-softhddevice-drm-gles 1.6.4-d0291bb
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
35{
37 if (!props) {
38 LOGERROR("drmplane: %s: could not get %u properties: %s", __FUNCTION__, GetId(), strerror(errno));
39 return;
40 }
41
43
44 m_propsInfo = (drmModePropertyRes **)calloc(m_props->count_props, sizeof(*m_propsInfo));
45 for (uint32_t i = 0; i < m_props->count_props; i++) {
47 }
48}
49
54{
55 if (!GetProps())
56 return;
57
58 if (!GetPropsInfo())
59 return;
60
61 for (uint32_t i = 0; i < m_props->count_props; i++) {
62 if (m_propsInfo[i])
64
65 }
68}
69
101
110{
111 int id = -1;
112
113 for (int i = 0; i < GetCountProps(); i++) {
114 if (strcmp(GetPropsInfoName(i), propName) == 0) {
115 id = GetPropsInfoPropId(i);
116 break;
117 }
118 }
119
120 if (id < 0) {
121 LOGDEBUG("drmplane: %s: Unable to find value for property \'%s\'.",
123 return -EINVAL;
124 }
125
127}
128
138
145{
146 SetPropertyRequest(ModeReq, "CRTC_ID", GetCrtcId());
148
149 SetPropertyRequest(ModeReq, "CRTC_X", GetCrtcX());
150 SetPropertyRequest(ModeReq, "CRTC_Y", GetCrtcY());
151 SetPropertyRequest(ModeReq, "CRTC_W", GetCrtcW());
152 SetPropertyRequest(ModeReq, "CRTC_H", GetCrtcH());
153
156 SetPropertyRequest(ModeReq, "SRC_W", GetSrcW() << 16);
157 SetPropertyRequest(ModeReq, "SRC_H", GetSrcH() << 16);
158}
159
170
180{
183
184 if (!(ModeReq = drmModeAtomicAlloc())) {
185 LOGERROR("drmplane: %s: cannot allocate atomic request (%d): %m", __FUNCTION__, errno);
186 return 0;
187 }
188
190
192 LOGDEBUG2(L_DRM, "drmplane: %s: cannot set atomic mode (%d), don't use zpos change: %m",
195 return 0;
196 }
197
199
200 return 1;
201}
202
206void cDrmPlane::DumpParameters(const char *id)
207{
208 LOGERROR("DumpParameters (plane_id = %d | %s):", GetId(), id);
209 LOGERROR(" CRTC ID: %" PRIu64 "", GetCrtcId());
210 LOGERROR(" FB ID : %" PRIu64 "", GetFbId());
211 LOGERROR(" CRTC X : %" PRIu64 "", GetCrtcX());
212 LOGERROR(" CRTC Y : %" PRIu64 "", GetCrtcY());
213 LOGERROR(" CRTC W : %" PRIu64 "", GetCrtcW());
214 LOGERROR(" CRTC H : %" PRIu64 "", GetCrtcH());
215 LOGERROR(" SRC X : %" PRIu64 "", GetSrcX());
216 LOGERROR(" SRC Y : %" PRIu64 "", GetSrcY());
217 LOGERROR(" SRC W : %" PRIu64 "", GetSrcW());
218 LOGERROR(" SRC H : %" PRIu64 "", GetSrcH());
219 LOGERROR(" ZPOS : %" PRIu64 "", GetZpos());
220}
uint64_t m_crtcX
CRTC_X.
Definition drmplane.h:74
uint64_t GetCrtcX(void)
Definition drmplane.h:45
uint64_t m_fbId
FB_ID.
Definition drmplane.h:73
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:86
uint64_t GetCrtcId(void)
Definition drmplane.h:43
void ClearPlane(drmModeAtomicReqPtr)
Clear plane from drm.
Definition drmplane.cpp:165
uint64_t GetCrtcH(void)
Definition drmplane.h:48
uint64_t m_crtcId
CRTC_ID.
Definition drmplane.h:72
void SetProps(drmModeObjectProperties *props)
Definition drmplane.h:60
uint64_t GetSrcH(void)
Definition drmplane.h:52
uint32_t GetPropsInfoPropId(int prop)
Definition drmplane.h:58
int SetPropertyRequest(drmModeAtomicReqPtr, const char *, uint64_t)
Add the properties to the mode setting request.
Definition drmplane.cpp:109
uint64_t GetZpos(void)
Definition drmplane.h:53
int HasZpos(int)
Check, if the plane is able to set the zpos property.
Definition drmplane.cpp:179
void FillProperties(int)
Fill the plane properties.
Definition drmplane.cpp:34
char * GetPropsInfoName(int prop)
Definition drmplane.h:57
uint64_t GetSrcY(void)
Definition drmplane.h:50
uint64_t m_crtcW
CRTC_W.
Definition drmplane.h:76
uint64_t m_srcW
SRC_W.
Definition drmplane.h:80
uint64_t GetFbId(void)
Definition drmplane.h:44
drmModeObjectProperties * m_props
Definition drmplane.h:68
drmModePropertyRes ** GetPropsInfo(void)
Definition drmplane.h:61
uint64_t m_crtcH
CRTC_H.
Definition drmplane.h:77
void FreeProperties(void)
Free the previously filled plane properties.
Definition drmplane.cpp:53
void SetPlane(drmModeAtomicReqPtr)
Set all plane properties (except zpos)
Definition drmplane.cpp:144
int GetCountProps(void)
Definition drmplane.h:56
drmModePropertyRes ** m_propsInfo
Definition drmplane.h:69
uint64_t m_crtcY
CRTC_Y.
Definition drmplane.h:75
void SetPlaneZpos(drmModeAtomicReqPtr)
Set the plane zpos property.
Definition drmplane.cpp:134
uint64_t GetSrcW(void)
Definition drmplane.h:51
uint64_t m_srcY
SRC_Y.
Definition drmplane.h:79
uint64_t m_srcH
SRC_H.
Definition drmplane.h:81
drmModeObjectProperties * GetProps(void)
Definition drmplane.h:59
uint64_t GetSrcX(void)
Definition drmplane.h:49
uint64_t GetCrtcW(void)
Definition drmplane.h:47
uint64_t m_srcX
SRC_X.
Definition drmplane.h:78
uint32_t GetId(void)
Definition drmplane.h:39
uint64_t GetCrtcY(void)
Definition drmplane.h:46
void DumpParameters(const char *)
Dump the cached plane parameter modesetting values.
Definition drmplane.cpp:206
DRM Plane Header File.
#define LOGDEBUG2
log to LOG_DEBUG and add a prefix
Definition logger.h:47
#define LOGDEBUG
log to LOG_DEBUG
Definition logger.h:45
#define LOGERROR
log to LOG_ERR
Definition logger.h:39
@ L_DRM
drm logs
Definition logger.h:60
Logger Header File.