@@ -99,7 +99,9 @@ void Aquamarine::CDRMAtomicRequest::addConnector(Hyprutils::Memory::CSharedPoint
99
99
add (connector->crtc ->id , connector->crtc ->props .active , enable);
100
100
101
101
if (enable) {
102
- // TODO: gamma
102
+ if (connector->crtc ->props .gamma_lut && data.atomic .gammad )
103
+ add (connector->crtc ->id , connector->crtc ->props .gamma_lut , data.atomic .gammaLut );
104
+
103
105
if (connector->crtc ->props .vrr_enabled )
104
106
add (connector->crtc ->id , connector->crtc ->props .vrr_enabled , (uint64_t )STATE.adaptiveSync );
105
107
@@ -184,8 +186,7 @@ void Aquamarine::CDRMAtomicRequest::rollback(SDRMConnectorCommitData& data) {
184
186
conn->crtc ->atomic .ownModeID = true ;
185
187
if (data.atomic .blobbed )
186
188
rollbackBlob (&conn->crtc ->atomic .modeID , data.atomic .modeBlob );
187
- // TODO: gamma
188
- // rollbackBlob(&conn->crtc->atomic.gammaLut, conn->atomic.gammaLut);
189
+ rollbackBlob (&conn->crtc ->atomic .gammaLut , data.atomic .gammaLut );
189
190
destroyBlob (data.atomic .fbDamage );
190
191
}
191
192
@@ -199,8 +200,7 @@ void Aquamarine::CDRMAtomicRequest::apply(SDRMConnectorCommitData& data) {
199
200
conn->crtc ->atomic .ownModeID = true ;
200
201
if (data.atomic .blobbed )
201
202
commitBlob (&conn->crtc ->atomic .modeID , data.atomic .modeBlob );
202
- // TODO: gamma
203
- // commitBlob(&conn->crtc->atomic.gammaLut, conn->atomic.gammaLut);
203
+ commitBlob (&conn->crtc ->atomic .gammaLut , data.atomic .gammaLut );
204
204
destroyBlob (data.atomic .fbDamage );
205
205
}
206
206
@@ -227,7 +227,27 @@ bool Aquamarine::CDRMAtomicImpl::prepareConnector(Hyprutils::Memory::CSharedPoin
227
227
}
228
228
}
229
229
230
- // TODO: gamma
230
+ if (STATE.committed & COutputState::AQ_OUTPUT_STATE_GAMMA_LUT) {
231
+ if (!connector->crtc ->props .gamma_lut ) // TODO: allow this with legacy gamma, perhaps.
232
+ connector->backend ->backend ->log (AQ_LOG_ERROR, " atomic drm: failed to commit gamma: no gamma_lut prop" );
233
+ else {
234
+ std::vector<drm_color_lut> lut;
235
+ lut.resize (STATE.gammaLut .size () / 3 ); // [r,g,b]+
236
+
237
+ for (size_t i = 0 ; i < lut.size (); ++i) {
238
+ lut.at (i).red = STATE.gammaLut .at (i * 3 + 0 );
239
+ lut.at (i).green = STATE.gammaLut .at (i * 3 + 1 );
240
+ lut.at (i).blue = STATE.gammaLut .at (i * 3 + 2 );
241
+ lut.at (i).reserved = 0 ;
242
+ }
243
+
244
+ if (drmModeCreatePropertyBlob (connector->backend ->gpu ->fd , lut.data (), lut.size () * sizeof (drm_color_lut), &data.atomic .gammaLut )) {
245
+ connector->backend ->backend ->log (AQ_LOG_ERROR, " atomic drm: failed to create a gamma blob" );
246
+ data.atomic .gammaLut = 0 ;
247
+ } else
248
+ data.atomic .gammad = true ;
249
+ }
250
+ }
231
251
232
252
if (STATE.committed & COutputState::AQ_OUTPUT_STATE_DAMAGE && connector->crtc ->primary ->props .fb_damage_clips ) {
233
253
if (STATE.damage .empty ())
0 commit comments