32 const auto buffer = m_primaryLayer->currentBuffer();
33 auto commit = std::make_unique<DrmLegacyCommit>(
this, buffer);
34 if (!commit->doPageflip(m_pending.presentationMode)) {
35 qCWarning(KWIN_DRM) <<
"Page flip failed:" << strerror(errno);
36 return errnoToError();
38 m_commitThread->setPendingCommit(std::move(commit));
49 if (!m_primaryLayer->checkTestBuffer()) {
52 auto commit = std::make_unique<DrmLegacyCommit>(
this, m_primaryLayer->currentBuffer());
53 if (!commit->doModeset(m_connector, m_pending.mode.get())) {
54 qCWarning(KWIN_DRM) <<
"Modeset failed!" << strerror(errno);
55 return errnoToError();
60DrmPipeline::Error DrmPipeline::commitPipelinesLegacy(
const QList<DrmPipeline *> &pipelines, CommitMode mode,
const QList<DrmObject *> &unusedObjects)
63 for (
const auto &pipeline : pipelines) {
64 err = pipeline->applyPendingChangesLegacy();
71 for (
const auto &pipeline : pipelines) {
72 pipeline->revertPendingChanges();
73 pipeline->applyPendingChangesLegacy();
76 for (
const auto &pipeline : pipelines) {
77 pipeline->applyPendingChanges();
82 for (
const auto &obj : unusedObjects) {
83 if (
auto crtc =
dynamic_cast<DrmCrtc *
>(obj)) {
93 if (!m_pending.active && m_pending.crtc) {
99 qCWarning(KWIN_DRM) <<
"Setting vrr failed!" << strerror(errno);
100 return errnoToError();
108 const uint32_t hborder = calculateUnderscan();
117 const auto blob = createHdrMetadata(m_pending.colorDescription.
transferFunction());
128 if (m_pending.crtc != m_next.crtc || *m_pending.mode != currentModeContent) {
129 qCDebug(KWIN_DRM) <<
"Using legacy path to set mode" << m_pending.mode->nativeMode()->name;
130 Error err = legacyModeset();
135 if (m_pending.gamma &&
drmModeCrtcSetGamma(
gpu()->fd(), m_pending.crtc->
id(), m_pending.gamma->lut().size(), m_pending.gamma->lut().red(), m_pending.gamma->lut().green(), m_pending.gamma->lut().blue()) != 0) {
136 qCWarning(KWIN_DRM) <<
"Setting gamma failed!" << strerror(errno);
137 return errnoToError();
145 qCWarning(KWIN_DRM) <<
"Setting legacy dpms failed!" << strerror(errno);
146 return errnoToError();
151bool DrmPipeline::setCursorLegacy()
155 if (bo && bo->buffer() &&
cursorLayer()->isEnabled()) {
156 const DmaBufAttributes *attributes = bo->buffer()->dmabufAttributes();
157 if (drmPrimeFDToHandle(
gpu()->fd(), attributes->
fd[0].get(), &handle) != 0) {
158 qCWarning(KWIN_DRM) <<
"drmPrimeFDToHandle() failed";
163 struct drm_mode_cursor2 arg = {
164 .flags = DRM_MODE_CURSOR_BO | DRM_MODE_CURSOR_MOVE,
165 .crtc_id = m_pending.crtc->
id(),
166 .x = int32_t(m_cursorLayer->position().x()),
167 .y = int32_t(m_cursorLayer->position().y()),
171 .hot_x = int32_t(m_cursorLayer->hotspot().x()),
172 .hot_y = int32_t(m_cursorLayer->hotspot().y()),
174 const int ret =
drmIoctl(
gpu()->fd(), DRM_IOCTL_MODE_CURSOR2, &arg);
177 drmCloseBufferHandle(
gpu()->fd(), handle);
NamedTransferFunction transferFunction() const
const Colorimetry & colorimetry() const
DrmEnumProperty< BroadcastRgbOptions > broadcastRGB
DrmProperty underscanHBorder
static BroadcastRgbOptions rgbRangeToBroadcastRgb(Output::RgbRange rgbRange)
DrmEnumProperty< DrmContentType > contentType
DrmEnumProperty< ScalingMode > scalingMode
DrmEnumProperty< Colorspace > colorspace
DrmProperty underscanVBorder
DrmEnumProperty< UnderscanOptions > underscan
drmModeModeInfo queryCurrentMode()
bool setEnumLegacy(Enum value)
bool hasEnum(Enum value) const
DrmPipelineLayer * cursorLayer() const
void forceLegacyModeset()
std::shared_ptr< DrmConnectorMode > mode() const
bool activePending() const
virtual std::shared_ptr< DrmFramebuffer > currentBuffer() const =0
bool setPropertyLegacy(uint64_t value)
int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size, uint16_t *red, uint16_t *green, uint16_t *blue)
int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, uint32_t x, uint32_t y, uint32_t *connectors, int count, drmModeModeInfoPtr mode)
int drmIoctl(int fd, unsigned long request, void *arg)
int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height)