[drm] Add initial support for DPMS
We read the drm property for the connector and set dpms initialy to On.
This commit is contained in:
parent
07414e88a5
commit
902bdb6cf0
2 changed files with 48 additions and 10 deletions
|
@ -237,16 +237,6 @@ void DrmBackend::openDrm()
|
|||
initCursor();
|
||||
}
|
||||
|
||||
template <typename Pointer, void (*cleanupFunc)(Pointer*)>
|
||||
struct DrmCleanup
|
||||
{
|
||||
static inline void cleanup(Pointer *ptr)
|
||||
{
|
||||
cleanupFunc(ptr);
|
||||
}
|
||||
};
|
||||
template <typename T, void (*cleanupFunc)(T*)> using ScopedDrmPointer = QScopedPointer<T, DrmCleanup<T, cleanupFunc>>;
|
||||
|
||||
void DrmBackend::queryResources()
|
||||
{
|
||||
if (m_fd < 0) {
|
||||
|
@ -607,8 +597,10 @@ void DrmOutput::cleanupBlackBuffer()
|
|||
void DrmOutput::init(drmModeConnector *connector)
|
||||
{
|
||||
initEdid(connector);
|
||||
initDpms(connector);
|
||||
m_savedCrtc.reset(drmModeGetCrtc(m_backend->fd(), m_crtcId));
|
||||
blank();
|
||||
setDpms(DpmsMode::On);
|
||||
if (!m_waylandOutput.isNull()) {
|
||||
delete m_waylandOutput.data();
|
||||
m_waylandOutput.clear();
|
||||
|
@ -875,6 +867,32 @@ void DrmOutput::initEdid(drmModeConnector *connector)
|
|||
m_edid.physicalSize = extractPhysicalSize(edid.data());
|
||||
}
|
||||
|
||||
void DrmOutput::initDpms(drmModeConnector *connector)
|
||||
{
|
||||
for (int i = 0; i < connector->count_props; ++i) {
|
||||
ScopedDrmPointer<_drmModeProperty, &drmModeFreeProperty> property(drmModeGetProperty(m_backend->fd(), connector->props[i]));
|
||||
if (!property) {
|
||||
continue;
|
||||
}
|
||||
if (qstrcmp(property->name, "DPMS") == 0) {
|
||||
m_dpms.swap(property);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrmOutput::setDpms(DrmOutput::DpmsMode mode)
|
||||
{
|
||||
if (m_dpms.isNull()) {
|
||||
return;
|
||||
}
|
||||
if (drmModeConnectorSetProperty(m_backend->fd(), m_connector, m_dpms->prop_id, uint64_t(mode)) != 0) {
|
||||
qCWarning(KWIN_DRM) << "Setting DPMS failed";
|
||||
return;
|
||||
}
|
||||
m_dpmsMode = mode;
|
||||
}
|
||||
|
||||
QString DrmOutput::name() const
|
||||
{
|
||||
if (!m_waylandOutput) {
|
||||
|
|
|
@ -46,6 +46,16 @@ class UdevMonitor;
|
|||
class DrmBuffer;
|
||||
class DrmOutput;
|
||||
|
||||
template <typename Pointer, void (*cleanupFunc)(Pointer*)>
|
||||
struct DrmCleanup
|
||||
{
|
||||
static inline void cleanup(Pointer *ptr)
|
||||
{
|
||||
cleanupFunc(ptr);
|
||||
}
|
||||
};
|
||||
template <typename T, void (*cleanupFunc)(T*)> using ScopedDrmPointer = QScopedPointer<T, DrmCleanup<T, cleanupFunc>>;
|
||||
|
||||
class KWIN_EXPORT DrmBackend : public AbstractBackend
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -132,6 +142,13 @@ public:
|
|||
QRect geometry() const;
|
||||
QString name() const;
|
||||
int currentRefreshRate() const;
|
||||
enum class DpmsMode {
|
||||
On = DRM_MODE_DPMS_ON,
|
||||
Standby = DRM_MODE_DPMS_STANDBY,
|
||||
Suspend = DRM_MODE_DPMS_SUSPEND,
|
||||
Off = DRM_MODE_DPMS_OFF
|
||||
};
|
||||
void setDpms(DpmsMode mode);
|
||||
|
||||
private:
|
||||
friend class DrmBackend;
|
||||
|
@ -139,6 +156,7 @@ private:
|
|||
void cleanupBlackBuffer();
|
||||
bool setMode(DrmBuffer *buffer);
|
||||
void initEdid(drmModeConnector *connector);
|
||||
void initDpms(drmModeConnector *connector);
|
||||
bool isCurrentMode(const drmModeModeInfo *mode) const;
|
||||
|
||||
DrmBackend *m_backend;
|
||||
|
@ -157,6 +175,8 @@ private:
|
|||
Edid m_edid;
|
||||
QScopedPointer<_drmModeCrtc, CrtcCleanup> m_savedCrtc;
|
||||
QPointer<KWayland::Server::OutputInterface> m_waylandOutput;
|
||||
ScopedDrmPointer<_drmModeProperty, &drmModeFreeProperty> m_dpms;
|
||||
DpmsMode m_dpmsMode = DpmsMode::On;
|
||||
};
|
||||
|
||||
class DrmBuffer
|
||||
|
|
Loading…
Reference in a new issue