Skip to content

Commit

Permalink
better fns
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Oct 7, 2024
1 parent 9ebce0b commit c46c55e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/backend/drm/impl/Atomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,16 @@ bool Aquamarine::CDRMAtomicImpl::prepareConnector(Hyprutils::Memory::CSharedPoin
if (!connector->crtc->props.ctm)
connector->backend->backend->log(AQ_LOG_ERROR, "atomic drm: failed to commit ctm: no ctm prop support");
else {
static auto doubleToS3132Fixed = [](const double val) -> uint64_t {
const uint64_t result = std::abs(val) * (1ULL << 32);
if (val < 0)
return result | 1ULL << 63;
return result;
};

drm_color_ctm ctm = {0};
for (size_t i = 0; i < 9; ++i) {
const double val = data.ctm->getMatrix()[i];
ctm.matrix[i] = static_cast<uint64_t>(val * std::pow(2, 32));
ctm.matrix[i] = doubleToS3132Fixed(data.ctm->getMatrix()[i]);
}

if (drmModeCreatePropertyBlob(connector->backend->gpu->fd, &ctm, sizeof(drm_color_ctm), &data.atomic.ctmBlob)) {
Expand Down

0 comments on commit c46c55e

Please sign in to comment.