summarylogtreecommitdiffstats
path: root/amd_color_management.patch
blob: 0a4729f63915839e8b9b34b66802d6537f610465 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
commit c1d144ec250a6076692b466965aa962db20f8d54
Author: Andrew O'Neil <andy@andyofniall.net>
Date:   Thu Apr 25 16:30:28 2024 +1000

    Reapply "drm: Update AMD color management for Linux 6.8"
    
    This reverts commit 6a73eddd699e9f831f0356d009da7e4bb1c13e7d.

diff --git a/src/drm.cpp b/src/drm.cpp
index 86ed0cc..b3570b7 100644
--- a/src/drm.cpp
+++ b/src/drm.cpp
@@ -202,15 +202,15 @@ namespace gamescope
 			std::optional<CDRMAtomicProperty> rotation;
 			std::optional<CDRMAtomicProperty> COLOR_ENCODING;
 			std::optional<CDRMAtomicProperty> COLOR_RANGE;
-			std::optional<CDRMAtomicProperty> VALVE1_PLANE_DEGAMMA_TF;
-			std::optional<CDRMAtomicProperty> VALVE1_PLANE_DEGAMMA_LUT;
-			std::optional<CDRMAtomicProperty> VALVE1_PLANE_CTM;
-			std::optional<CDRMAtomicProperty> VALVE1_PLANE_HDR_MULT;
-			std::optional<CDRMAtomicProperty> VALVE1_PLANE_SHAPER_LUT;
-			std::optional<CDRMAtomicProperty> VALVE1_PLANE_SHAPER_TF;
-			std::optional<CDRMAtomicProperty> VALVE1_PLANE_LUT3D;
-			std::optional<CDRMAtomicProperty> VALVE1_PLANE_BLEND_TF;
-			std::optional<CDRMAtomicProperty> VALVE1_PLANE_BLEND_LUT;
+			std::optional<CDRMAtomicProperty> AMD_PLANE_DEGAMMA_TF;
+			std::optional<CDRMAtomicProperty> AMD_PLANE_DEGAMMA_LUT;
+			std::optional<CDRMAtomicProperty> AMD_PLANE_CTM;
+			std::optional<CDRMAtomicProperty> AMD_PLANE_HDR_MULT;
+			std::optional<CDRMAtomicProperty> AMD_PLANE_SHAPER_LUT;
+			std::optional<CDRMAtomicProperty> AMD_PLANE_SHAPER_TF;
+			std::optional<CDRMAtomicProperty> AMD_PLANE_LUT3D;
+			std::optional<CDRMAtomicProperty> AMD_PLANE_BLEND_TF;
+			std::optional<CDRMAtomicProperty> AMD_PLANE_BLEND_LUT;
 			std::optional<CDRMAtomicProperty> DUMMY_END;
 		};
 		      PlaneProperties &GetProperties()       { return m_Props; }
@@ -241,7 +241,7 @@ namespace gamescope
 			std::optional<CDRMAtomicProperty> CTM;
 			std::optional<CDRMAtomicProperty> VRR_ENABLED;
 			std::optional<CDRMAtomicProperty> OUT_FENCE_PTR;
-			std::optional<CDRMAtomicProperty> VALVE1_CRTC_REGAMMA_TF;
+			std::optional<CDRMAtomicProperty> AMD_CRTC_REGAMMA_TF;
 			std::optional<CDRMAtomicProperty> DUMMY_END;
 		};
 		      CRTCProperties &GetProperties()       { return m_Props; }
@@ -451,7 +451,7 @@ struct drm_t {
 		uint32_t color_mgmt_serial;
 		std::shared_ptr<gamescope::BackendBlob> lut3d_id[ EOTF_Count ];
 		std::shared_ptr<gamescope::BackendBlob> shaperlut_id[ EOTF_Count ];
-		drm_valve1_transfer_function output_tf = DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT;
+		amdgpu_transfer_function output_tf = AMDGPU_TRANSFER_FUNCTION_DEFAULT;
 	} current, pending;
 
 	// FBs in the atomic request, but not yet submitted to KMS
@@ -1311,8 +1311,8 @@ void finish_drm(struct drm_t *drm)
 		if ( pCRTC->GetProperties().OUT_FENCE_PTR )
 			pCRTC->GetProperties().OUT_FENCE_PTR->SetPendingValue( req, 0, true );
 
-		if ( pCRTC->GetProperties().VALVE1_CRTC_REGAMMA_TF )
-			pCRTC->GetProperties().VALVE1_CRTC_REGAMMA_TF->SetPendingValue( req, 0, true );
+		if ( pCRTC->GetProperties().AMD_CRTC_REGAMMA_TF )
+			pCRTC->GetProperties().AMD_CRTC_REGAMMA_TF->SetPendingValue( req, 0, true );
 	}
 
 	for ( std::unique_ptr< gamescope::CDRMPlane > &pPlane : drm->planes )
@@ -1338,32 +1338,32 @@ void finish_drm(struct drm_t *drm)
 		//if ( pPlane->GetProperties().zpos )
 		//	pPlane->GetProperties().zpos->SetPendingValue( req, , true );
 
-		if ( pPlane->GetProperties().VALVE1_PLANE_DEGAMMA_TF )
-			pPlane->GetProperties().VALVE1_PLANE_DEGAMMA_TF->SetPendingValue( req, DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT, true );
+		if ( pPlane->GetProperties().AMD_PLANE_DEGAMMA_TF )
+			pPlane->GetProperties().AMD_PLANE_DEGAMMA_TF->SetPendingValue( req, AMDGPU_TRANSFER_FUNCTION_DEFAULT, true );
 
-		if ( pPlane->GetProperties().VALVE1_PLANE_DEGAMMA_LUT )
-			pPlane->GetProperties().VALVE1_PLANE_DEGAMMA_LUT->SetPendingValue( req, 0, true );
+		if ( pPlane->GetProperties().AMD_PLANE_DEGAMMA_LUT )
+			pPlane->GetProperties().AMD_PLANE_DEGAMMA_LUT->SetPendingValue( req, 0, true );
 
-		if ( pPlane->GetProperties().VALVE1_PLANE_CTM )
-			pPlane->GetProperties().VALVE1_PLANE_CTM->SetPendingValue( req, 0, true );
+		if ( pPlane->GetProperties().AMD_PLANE_CTM )
+			pPlane->GetProperties().AMD_PLANE_CTM->SetPendingValue( req, 0, true );
 
-		if ( pPlane->GetProperties().VALVE1_PLANE_HDR_MULT )
-			pPlane->GetProperties().VALVE1_PLANE_HDR_MULT->SetPendingValue( req, 0x100000000ULL, true );
+		if ( pPlane->GetProperties().AMD_PLANE_HDR_MULT )
+			pPlane->GetProperties().AMD_PLANE_HDR_MULT->SetPendingValue( req, 0x100000000ULL, true );
 
-		if ( pPlane->GetProperties().VALVE1_PLANE_SHAPER_TF )
-			pPlane->GetProperties().VALVE1_PLANE_SHAPER_TF->SetPendingValue( req, DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT, true );
+		if ( pPlane->GetProperties().AMD_PLANE_SHAPER_TF )
+			pPlane->GetProperties().AMD_PLANE_SHAPER_TF->SetPendingValue( req, AMDGPU_TRANSFER_FUNCTION_DEFAULT, true );
 
-		if ( pPlane->GetProperties().VALVE1_PLANE_SHAPER_LUT )
-			pPlane->GetProperties().VALVE1_PLANE_SHAPER_LUT->SetPendingValue( req, 0, true );
+		if ( pPlane->GetProperties().AMD_PLANE_SHAPER_LUT )
+			pPlane->GetProperties().AMD_PLANE_SHAPER_LUT->SetPendingValue( req, 0, true );
 
-		if ( pPlane->GetProperties().VALVE1_PLANE_LUT3D )
-			pPlane->GetProperties().VALVE1_PLANE_LUT3D->SetPendingValue( req, 0, true );
+		if ( pPlane->GetProperties().AMD_PLANE_LUT3D )
+			pPlane->GetProperties().AMD_PLANE_LUT3D->SetPendingValue( req, 0, true );
 
-		if ( pPlane->GetProperties().VALVE1_PLANE_BLEND_TF )
-			pPlane->GetProperties().VALVE1_PLANE_BLEND_TF->SetPendingValue( req, DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT, true );
+		if ( pPlane->GetProperties().AMD_PLANE_BLEND_TF )
+			pPlane->GetProperties().AMD_PLANE_BLEND_TF->SetPendingValue( req, AMDGPU_TRANSFER_FUNCTION_DEFAULT, true );
 
-		if ( pPlane->GetProperties().VALVE1_PLANE_BLEND_LUT )
-			pPlane->GetProperties().VALVE1_PLANE_BLEND_LUT->SetPendingValue( req, 0, true );
+		if ( pPlane->GetProperties().AMD_PLANE_BLEND_LUT )
+			pPlane->GetProperties().AMD_PLANE_BLEND_LUT->SetPendingValue( req, 0, true );
 	}
 
 	// We can't do a non-blocking commit here or else risk EBUSY in case the
@@ -1604,37 +1604,73 @@ struct LiftoffStateCacheEntryKasher
 
 std::unordered_set<LiftoffStateCacheEntry, LiftoffStateCacheEntryKasher> g_LiftoffStateCache;
 
-static inline drm_valve1_transfer_function colorspace_to_plane_degamma_tf(GamescopeAppTextureColorspace colorspace)
+static inline amdgpu_transfer_function colorspace_to_plane_degamma_tf(GamescopeAppTextureColorspace colorspace)
 {
 	switch ( colorspace )
 	{
 		default: // Linear in this sense is SRGB. Linear = sRGB image view doing automatic sRGB -> Linear which doesn't happen on DRM side.
 		case GAMESCOPE_APP_TEXTURE_COLORSPACE_SRGB:
-			return DRM_VALVE1_TRANSFER_FUNCTION_SRGB;
+			return AMDGPU_TRANSFER_FUNCTION_SRGB_EOTF;
 		case GAMESCOPE_APP_TEXTURE_COLORSPACE_PASSTHRU:
 		case GAMESCOPE_APP_TEXTURE_COLORSPACE_SCRGB:
 			// Use LINEAR TF for scRGB float format as 80 nit = 1.0 in scRGB, which matches
 			// what PQ TF decodes to/encodes from.
 			// AMD internal format is FP16, and generally expected for 1.0 -> 80 nit.
 			// which just so happens to match scRGB.
-			return DRM_VALVE1_TRANSFER_FUNCTION_LINEAR;
+			return AMDGPU_TRANSFER_FUNCTION_IDENTITY;
 		case GAMESCOPE_APP_TEXTURE_COLORSPACE_HDR10_PQ:
-			return DRM_VALVE1_TRANSFER_FUNCTION_PQ;
+			return AMDGPU_TRANSFER_FUNCTION_PQ_EOTF;
 	}
 }
 
-static inline drm_valve1_transfer_function colorspace_to_plane_shaper_tf(GamescopeAppTextureColorspace colorspace)
+static inline amdgpu_transfer_function colorspace_to_plane_shaper_tf(GamescopeAppTextureColorspace colorspace)
 {
 	switch ( colorspace )
 	{
 		default:
 		case GAMESCOPE_APP_TEXTURE_COLORSPACE_SRGB:
-			return DRM_VALVE1_TRANSFER_FUNCTION_SRGB;
+			return AMDGPU_TRANSFER_FUNCTION_SRGB_INV_EOTF;
 		case GAMESCOPE_APP_TEXTURE_COLORSPACE_SCRGB: // scRGB Linear -> PQ for shaper + 3D LUT
 		case GAMESCOPE_APP_TEXTURE_COLORSPACE_HDR10_PQ:
-			return DRM_VALVE1_TRANSFER_FUNCTION_PQ;
+			return AMDGPU_TRANSFER_FUNCTION_PQ_INV_EOTF;
 		case GAMESCOPE_APP_TEXTURE_COLORSPACE_PASSTHRU:
-			return DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT;
+			return AMDGPU_TRANSFER_FUNCTION_DEFAULT;
+	}
+}
+
+static inline amdgpu_transfer_function inverse_tf(amdgpu_transfer_function tf)
+{
+	switch ( tf )
+	{
+		default:
+		case AMDGPU_TRANSFER_FUNCTION_DEFAULT:
+			return AMDGPU_TRANSFER_FUNCTION_DEFAULT;
+		case AMDGPU_TRANSFER_FUNCTION_IDENTITY:
+			return AMDGPU_TRANSFER_FUNCTION_IDENTITY;
+		case AMDGPU_TRANSFER_FUNCTION_SRGB_EOTF:
+			return AMDGPU_TRANSFER_FUNCTION_SRGB_INV_EOTF;
+		case AMDGPU_TRANSFER_FUNCTION_BT709_OETF:
+			return AMDGPU_TRANSFER_FUNCTION_BT709_INV_OETF;
+		case AMDGPU_TRANSFER_FUNCTION_PQ_EOTF:
+			return AMDGPU_TRANSFER_FUNCTION_PQ_INV_EOTF;
+		case AMDGPU_TRANSFER_FUNCTION_GAMMA22_EOTF:
+			return AMDGPU_TRANSFER_FUNCTION_GAMMA22_INV_EOTF;
+		case AMDGPU_TRANSFER_FUNCTION_GAMMA24_EOTF:
+			return AMDGPU_TRANSFER_FUNCTION_GAMMA24_INV_EOTF;
+		case AMDGPU_TRANSFER_FUNCTION_GAMMA26_EOTF:
+			return AMDGPU_TRANSFER_FUNCTION_GAMMA26_INV_EOTF;
+		case AMDGPU_TRANSFER_FUNCTION_SRGB_INV_EOTF:
+			return AMDGPU_TRANSFER_FUNCTION_SRGB_EOTF;
+		case AMDGPU_TRANSFER_FUNCTION_BT709_INV_OETF:
+			return AMDGPU_TRANSFER_FUNCTION_BT709_OETF;
+		case AMDGPU_TRANSFER_FUNCTION_PQ_INV_EOTF:
+			return AMDGPU_TRANSFER_FUNCTION_PQ_EOTF;
+		case AMDGPU_TRANSFER_FUNCTION_GAMMA22_INV_EOTF:
+			return AMDGPU_TRANSFER_FUNCTION_GAMMA22_EOTF;
+		case AMDGPU_TRANSFER_FUNCTION_GAMMA24_INV_EOTF:
+			return AMDGPU_TRANSFER_FUNCTION_GAMMA24_EOTF;
+		case AMDGPU_TRANSFER_FUNCTION_GAMMA26_INV_EOTF:
+			return AMDGPU_TRANSFER_FUNCTION_GAMMA26_EOTF;
 	}
 }
 
@@ -1822,8 +1858,8 @@ namespace gamescope
 		auto rawProperties = GetRawProperties();
 		if ( rawProperties )
 		{
-			m_Props.type                     = CDRMAtomicProperty::Instantiate( "type",                     this, *rawProperties );
-			m_Props.IN_FORMATS               = CDRMAtomicProperty::Instantiate( "IN_FORMATS",               this, *rawProperties );
+			m_Props.type                  = CDRMAtomicProperty::Instantiate( "type",                  this, *rawProperties );
+			m_Props.IN_FORMATS            = CDRMAtomicProperty::Instantiate( "IN_FORMATS",            this, *rawProperties );
 
 			m_Props.FB_ID                    = CDRMAtomicProperty::Instantiate( "FB_ID",                    this, *rawProperties );
 			m_Props.IN_FENCE_FD              = CDRMAtomicProperty::Instantiate( "IN_FENCE_FD",              this, *rawProperties );
@@ -1841,15 +1877,15 @@ namespace gamescope
 			m_Props.rotation                 = CDRMAtomicProperty::Instantiate( "rotation",                 this, *rawProperties );
 			m_Props.COLOR_ENCODING           = CDRMAtomicProperty::Instantiate( "COLOR_ENCODING",           this, *rawProperties );
 			m_Props.COLOR_RANGE              = CDRMAtomicProperty::Instantiate( "COLOR_RANGE",              this, *rawProperties );
-			m_Props.VALVE1_PLANE_DEGAMMA_TF  = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_DEGAMMA_TF",  this, *rawProperties );
-			m_Props.VALVE1_PLANE_DEGAMMA_LUT = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_DEGAMMA_LUT", this, *rawProperties );
-			m_Props.VALVE1_PLANE_CTM         = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_CTM",         this, *rawProperties );
-			m_Props.VALVE1_PLANE_HDR_MULT    = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_HDR_MULT",    this, *rawProperties );
-			m_Props.VALVE1_PLANE_SHAPER_LUT  = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_SHAPER_LUT",  this, *rawProperties );
-			m_Props.VALVE1_PLANE_SHAPER_TF   = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_SHAPER_TF",   this, *rawProperties );
-			m_Props.VALVE1_PLANE_LUT3D       = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_LUT3D",       this, *rawProperties );
-			m_Props.VALVE1_PLANE_BLEND_TF    = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_BLEND_TF",    this, *rawProperties );
-			m_Props.VALVE1_PLANE_BLEND_LUT   = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_BLEND_LUT",   this, *rawProperties );
+			m_Props.AMD_PLANE_DEGAMMA_TF     = CDRMAtomicProperty::Instantiate( "AMD_PLANE_DEGAMMA_TF",     this, *rawProperties );
+			m_Props.AMD_PLANE_DEGAMMA_LUT    = CDRMAtomicProperty::Instantiate( "AMD_PLANE_DEGAMMA_LUT",    this, *rawProperties );
+			m_Props.AMD_PLANE_CTM            = CDRMAtomicProperty::Instantiate( "AMD_PLANE_CTM",            this, *rawProperties );
+			m_Props.AMD_PLANE_HDR_MULT       = CDRMAtomicProperty::Instantiate( "AMD_PLANE_HDR_MULT",       this, *rawProperties );
+			m_Props.AMD_PLANE_SHAPER_LUT     = CDRMAtomicProperty::Instantiate( "AMD_PLANE_SHAPER_LUT",     this, *rawProperties );
+			m_Props.AMD_PLANE_SHAPER_TF      = CDRMAtomicProperty::Instantiate( "AMD_PLANE_SHAPER_TF",      this, *rawProperties );
+			m_Props.AMD_PLANE_LUT3D          = CDRMAtomicProperty::Instantiate( "AMD_PLANE_LUT3D",          this, *rawProperties );
+			m_Props.AMD_PLANE_BLEND_TF       = CDRMAtomicProperty::Instantiate( "AMD_PLANE_BLEND_TF",       this, *rawProperties );
+			m_Props.AMD_PLANE_BLEND_LUT      = CDRMAtomicProperty::Instantiate( "AMD_PLANE_BLEND_LUT",      this, *rawProperties );
 		}
 	}
 
@@ -1869,14 +1905,14 @@ namespace gamescope
 		auto rawProperties = GetRawProperties();
 		if ( rawProperties )
 		{
-			m_Props.ACTIVE                   = CDRMAtomicProperty::Instantiate( "ACTIVE",                 this, *rawProperties );
-			m_Props.MODE_ID                  = CDRMAtomicProperty::Instantiate( "MODE_ID",                this, *rawProperties );
-			m_Props.GAMMA_LUT                = CDRMAtomicProperty::Instantiate( "GAMMA_LUT",              this, *rawProperties );
-			m_Props.DEGAMMA_LUT              = CDRMAtomicProperty::Instantiate( "DEGAMMA_LUT",            this, *rawProperties );
-			m_Props.CTM                      = CDRMAtomicProperty::Instantiate( "CTM",                    this, *rawProperties );
-			m_Props.VRR_ENABLED              = CDRMAtomicProperty::Instantiate( "VRR_ENABLED",            this, *rawProperties );
-			m_Props.OUT_FENCE_PTR            = CDRMAtomicProperty::Instantiate( "OUT_FENCE_PTR",          this, *rawProperties );
-			m_Props.VALVE1_CRTC_REGAMMA_TF   = CDRMAtomicProperty::Instantiate( "VALVE1_CRTC_REGAMMA_TF", this, *rawProperties );
+			m_Props.ACTIVE              = CDRMAtomicProperty::Instantiate( "ACTIVE",              this, *rawProperties );
+			m_Props.MODE_ID             = CDRMAtomicProperty::Instantiate( "MODE_ID",             this, *rawProperties );
+			m_Props.GAMMA_LUT           = CDRMAtomicProperty::Instantiate( "GAMMA_LUT",           this, *rawProperties );
+			m_Props.DEGAMMA_LUT         = CDRMAtomicProperty::Instantiate( "DEGAMMA_LUT",         this, *rawProperties );
+			m_Props.CTM                 = CDRMAtomicProperty::Instantiate( "CTM",                 this, *rawProperties );
+			m_Props.VRR_ENABLED         = CDRMAtomicProperty::Instantiate( "VRR_ENABLED",         this, *rawProperties );
+			m_Props.OUT_FENCE_PTR       = CDRMAtomicProperty::Instantiate( "OUT_FENCE_PTR",       this, *rawProperties );
+			m_Props.AMD_CRTC_REGAMMA_TF = CDRMAtomicProperty::Instantiate( "AMD_CRTC_REGAMMA_TF", this, *rawProperties );
 		}
 	}
 
@@ -2357,8 +2393,8 @@ drm_prepare_liftoff( struct drm_t *drm, const struct FrameInfo_t *frameInfo, boo
 
 				if ( drm_supports_color_mgmt( drm ) )
 				{
-					drm_valve1_transfer_function degamma_tf = colorspace_to_plane_degamma_tf( entry.layerState[i].colorspace );
-					drm_valve1_transfer_function shaper_tf = colorspace_to_plane_shaper_tf( entry.layerState[i].colorspace );
+					amdgpu_transfer_function degamma_tf = colorspace_to_plane_degamma_tf( entry.layerState[i].colorspace );
+					amdgpu_transfer_function shaper_tf = colorspace_to_plane_shaper_tf( entry.layerState[i].colorspace );
 
 					if ( entry.layerState[i].ycbcr )
 					{
@@ -2370,27 +2406,27 @@ drm_prepare_liftoff( struct drm_t *drm, const struct FrameInfo_t *frameInfo, boo
 						//
 						// Doing LINEAR/DEFAULT here introduces banding so... this is the best way.
 						// (sRGB DEGAMMA does NOT work on YUV planes!)
-						degamma_tf = DRM_VALVE1_TRANSFER_FUNCTION_BT709;
-						shaper_tf = DRM_VALVE1_TRANSFER_FUNCTION_BT709;
+						degamma_tf = AMDGPU_TRANSFER_FUNCTION_BT709_OETF;
+						shaper_tf = AMDGPU_TRANSFER_FUNCTION_BT709_INV_OETF;
 					}
 
 					if (!cv_drm_debug_disable_degamma_tf)
-						liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_DEGAMMA_TF", degamma_tf );
+						liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_DEGAMMA_TF", degamma_tf );
 					else
-						liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_DEGAMMA_TF", 0 );
+						liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_DEGAMMA_TF", 0 );
 
 					if ( !cv_drm_debug_disable_shaper_and_3dlut )
 					{
-						liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_SHAPER_LUT", drm->pending.shaperlut_id[ ColorSpaceToEOTFIndex( entry.layerState[i].colorspace ) ]->GetBlobValue() );
-						liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_SHAPER_TF", shaper_tf );
-						liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_LUT3D", drm->pending.lut3d_id[ ColorSpaceToEOTFIndex( entry.layerState[i].colorspace ) ]->GetBlobValue() );
+						liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_SHAPER_LUT", drm->pending.shaperlut_id[ ColorSpaceToEOTFIndex( entry.layerState[i].colorspace ) ]->GetBlobValue() );
+						liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_SHAPER_TF", shaper_tf );
+						liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_LUT3D", drm->pending.lut3d_id[ ColorSpaceToEOTFIndex( entry.layerState[i].colorspace ) ]->GetBlobValue() );
 						// Josh: See shaders/colorimetry.h colorspace_blend_tf if you have questions as to why we start doing sRGB for BLEND_TF despite potentially working in Gamma 2.2 space prior.
 					}
 					else
 					{
-						liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_SHAPER_LUT", 0 );
-						liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_SHAPER_TF", 0 );
-						liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_LUT3D", 0 );
+						liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_SHAPER_LUT", 0 );
+						liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_SHAPER_TF", 0 );
+						liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_LUT3D", 0 );
 					}
 				}
 			}
@@ -2398,25 +2434,25 @@ drm_prepare_liftoff( struct drm_t *drm, const struct FrameInfo_t *frameInfo, boo
 			{
 				if ( drm_supports_color_mgmt( drm ) )
 				{
-					liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_DEGAMMA_TF", DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT );
-					liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_SHAPER_LUT", 0 );
-					liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_SHAPER_TF", 0 );
-					liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_LUT3D", 0 );
-					liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_CTM", 0 );
+					liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_DEGAMMA_TF", AMDGPU_TRANSFER_FUNCTION_DEFAULT );
+					liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_SHAPER_LUT", 0 );
+					liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_SHAPER_TF", 0 );
+					liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_LUT3D", 0 );
+					liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_CTM", 0 );
 				}
 			}
 
 			if ( drm_supports_color_mgmt( drm ) )
 			{
 				if (!cv_drm_debug_disable_blend_tf && !bSinglePlane)
-					liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_BLEND_TF", drm->pending.output_tf );
+					liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_BLEND_TF", drm->pending.output_tf );
 				else
-					liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_BLEND_TF", DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT );
+					liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_BLEND_TF", AMDGPU_TRANSFER_FUNCTION_DEFAULT );
 
 				if (frameInfo->layers[i].ctm != nullptr)
-					liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_CTM", frameInfo->layers[i].ctm->GetBlobValue() );
+					liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_CTM", frameInfo->layers[i].ctm->GetBlobValue() );
 				else
-					liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_CTM", 0 );
+					liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_CTM", 0 );
 			}
 		}
 		else
@@ -2429,12 +2465,12 @@ drm_prepare_liftoff( struct drm_t *drm, const struct FrameInfo_t *frameInfo, boo
 
 			if ( drm_supports_color_mgmt( drm ) )
 			{
-				liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_DEGAMMA_TF", DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT );
-				liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_SHAPER_LUT", 0 );
-				liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_SHAPER_TF", 0 );
-				liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_LUT3D", 0 );
-				liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_BLEND_TF", DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT );
-				liftoff_layer_set_property( drm->lo_layers[ i ], "VALVE1_PLANE_CTM", 0 );
+				liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_DEGAMMA_TF", AMDGPU_TRANSFER_FUNCTION_DEFAULT );
+				liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_SHAPER_LUT", 0 );
+				liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_SHAPER_TF", 0 );
+				liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_LUT3D", 0 );
+				liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_BLEND_TF", AMDGPU_TRANSFER_FUNCTION_DEFAULT );
+				liftoff_layer_set_property( drm->lo_layers[ i ], "AMD_PLANE_CTM", 0 );
 			}
 		}
 	}
@@ -2515,7 +2551,7 @@ int drm_prepare( struct drm_t *drm, bool async, const struct FrameInfo_t *frameI
 			drm->needs_modeset = true;
 	}
 
-	uint32_t uColorimetry = DRM_MODE_COLORIMETRY_DEFAULT;
+	drm_colorspace uColorimetry = DRM_MODE_COLORIMETRY_DEFAULT;
 
 	const bool bWantsHDR10 = g_bOutputHDREnabled && frameInfo->outputEncodingEOTF == EOTF_PQ;
 	gamescope::BackendBlob *pHDRMetadata = nullptr;
@@ -2554,17 +2590,17 @@ int drm_prepare( struct drm_t *drm, bool async, const struct FrameInfo_t *frameI
 		if ( !cv_drm_debug_disable_output_tf && !bSinglePlane )
 		{
 			drm->pending.output_tf = g_bOutputHDREnabled
-				? DRM_VALVE1_TRANSFER_FUNCTION_PQ
-				: DRM_VALVE1_TRANSFER_FUNCTION_SRGB;
+				? AMDGPU_TRANSFER_FUNCTION_PQ_EOTF
+				: AMDGPU_TRANSFER_FUNCTION_SRGB_EOTF;
 		}
 		else
 		{
-			drm->pending.output_tf = DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT;
+			drm->pending.output_tf = AMDGPU_TRANSFER_FUNCTION_DEFAULT;
 		}
 	}
 	else
 	{
-		drm->pending.output_tf = DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT;
+		drm->pending.output_tf = AMDGPU_TRANSFER_FUNCTION_DEFAULT;
 	}
 
 	uint32_t flags = DRM_MODE_ATOMIC_NONBLOCK;
@@ -2627,8 +2663,8 @@ int drm_prepare( struct drm_t *drm, bool async, const struct FrameInfo_t *frameI
 			if ( pCRTC->GetProperties().OUT_FENCE_PTR )
 				pCRTC->GetProperties().OUT_FENCE_PTR->SetPendingValue( drm->req, 0, bForceInRequest );
 
-			if ( pCRTC->GetProperties().VALVE1_CRTC_REGAMMA_TF )
-				pCRTC->GetProperties().VALVE1_CRTC_REGAMMA_TF->SetPendingValue( drm->req, 0, bForceInRequest );
+			if ( pCRTC->GetProperties().AMD_CRTC_REGAMMA_TF )
+				pCRTC->GetProperties().AMD_CRTC_REGAMMA_TF->SetPendingValue( drm->req, 0, bForceInRequest );
 		}
 
 		if ( drm->pConnector )
@@ -2662,12 +2698,12 @@ int drm_prepare( struct drm_t *drm, bool async, const struct FrameInfo_t *frameI
 
 	if ( drm->pCRTC )
 	{
-		if ( drm->pCRTC->GetProperties().VALVE1_CRTC_REGAMMA_TF )
+		if ( drm->pCRTC->GetProperties().AMD_CRTC_REGAMMA_TF )
 		{
 			if ( !cv_drm_debug_disable_regamma_tf )
-				drm->pCRTC->GetProperties().VALVE1_CRTC_REGAMMA_TF->SetPendingValue( drm->req, drm->pending.output_tf, bForceInRequest );
+				drm->pCRTC->GetProperties().AMD_CRTC_REGAMMA_TF->SetPendingValue( drm->req, inverse_tf( drm->pending.output_tf ), bForceInRequest );
 			else
-				drm->pCRTC->GetProperties().VALVE1_CRTC_REGAMMA_TF->SetPendingValue( drm->req, DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT, bForceInRequest );
+				drm->pCRTC->GetProperties().AMD_CRTC_REGAMMA_TF->SetPendingValue( drm->req, AMDGPU_TRANSFER_FUNCTION_DEFAULT, bForceInRequest );
 		}
 	}
 
@@ -2983,7 +3019,7 @@ bool drm_supports_color_mgmt(struct drm_t *drm)
 	if ( !drm->pPrimaryPlane )
 		return false;
 
-	return drm->pPrimaryPlane->GetProperties().VALVE1_PLANE_CTM.has_value();
+	return drm->pPrimaryPlane->GetProperties().AMD_PLANE_CTM.has_value() && drm->pPrimaryPlane->GetProperties().AMD_PLANE_BLEND_TF.has_value();
 }
 
 std::span<const uint32_t> drm_get_valid_refresh_rates( struct drm_t *drm )
diff --git a/src/drm_include.h b/src/drm_include.h
index 500c304..d0ed3ce 100644
--- a/src/drm_include.h
+++ b/src/drm_include.h
@@ -28,19 +28,22 @@ enum drm_color_range {
 	DRM_COLOR_RANGE_MAX,
 };
 
-enum drm_valve1_transfer_function {
-	DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT,
-
-	DRM_VALVE1_TRANSFER_FUNCTION_SRGB,
-	DRM_VALVE1_TRANSFER_FUNCTION_BT709,
-	DRM_VALVE1_TRANSFER_FUNCTION_PQ,
-	DRM_VALVE1_TRANSFER_FUNCTION_LINEAR,
-	DRM_VALVE1_TRANSFER_FUNCTION_UNITY,
-	DRM_VALVE1_TRANSFER_FUNCTION_HLG,
-	DRM_VALVE1_TRANSFER_FUNCTION_GAMMA22,
-	DRM_VALVE1_TRANSFER_FUNCTION_GAMMA24,
-	DRM_VALVE1_TRANSFER_FUNCTION_GAMMA26,
-	DRM_VALVE1_TRANSFER_FUNCTION_MAX,
+enum amdgpu_transfer_function {
+	AMDGPU_TRANSFER_FUNCTION_DEFAULT,
+	AMDGPU_TRANSFER_FUNCTION_SRGB_EOTF,
+	AMDGPU_TRANSFER_FUNCTION_BT709_INV_OETF,
+	AMDGPU_TRANSFER_FUNCTION_PQ_EOTF,
+	AMDGPU_TRANSFER_FUNCTION_IDENTITY,
+	AMDGPU_TRANSFER_FUNCTION_GAMMA22_EOTF,
+	AMDGPU_TRANSFER_FUNCTION_GAMMA24_EOTF,
+	AMDGPU_TRANSFER_FUNCTION_GAMMA26_EOTF,
+	AMDGPU_TRANSFER_FUNCTION_SRGB_INV_EOTF,
+	AMDGPU_TRANSFER_FUNCTION_BT709_OETF,
+	AMDGPU_TRANSFER_FUNCTION_PQ_INV_EOTF,
+	AMDGPU_TRANSFER_FUNCTION_GAMMA22_INV_EOTF,
+	AMDGPU_TRANSFER_FUNCTION_GAMMA24_INV_EOTF,
+	AMDGPU_TRANSFER_FUNCTION_GAMMA26_INV_EOTF,
+	AMDGPU_TRANSFER_FUNCTION_COUNT
 };
 
 enum drm_panel_orientation {
@@ -51,28 +54,31 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
-/* For Default case, driver will set the colorspace */
-#define DRM_MODE_COLORIMETRY_DEFAULT			0
-/* CEA 861 Normal Colorimetry options */
-#define DRM_MODE_COLORIMETRY_NO_DATA			0
-#define DRM_MODE_COLORIMETRY_SMPTE_170M_YCC		1
-#define DRM_MODE_COLORIMETRY_BT709_YCC			2
-/* CEA 861 Extended Colorimetry Options */
-#define DRM_MODE_COLORIMETRY_XVYCC_601			3
-#define DRM_MODE_COLORIMETRY_XVYCC_709			4
-#define DRM_MODE_COLORIMETRY_SYCC_601			5
-#define DRM_MODE_COLORIMETRY_OPYCC_601			6
-#define DRM_MODE_COLORIMETRY_OPRGB			7
-#define DRM_MODE_COLORIMETRY_BT2020_CYCC		8
-#define DRM_MODE_COLORIMETRY_BT2020_RGB			9
-#define DRM_MODE_COLORIMETRY_BT2020_YCC			10
-/* Additional Colorimetry extension added as part of CTA 861.G */
-#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		11
-#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER		12
-/* Additional Colorimetry Options added for DP 1.4a VSC Colorimetry Format */
-#define DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED		13
-#define DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT		14
-#define DRM_MODE_COLORIMETRY_BT601_YCC			15
+enum drm_colorspace {
+	/* For Default case, driver will set the colorspace */
+	DRM_MODE_COLORIMETRY_DEFAULT 		= 0,
+	/* CEA 861 Normal Colorimetry options */
+	DRM_MODE_COLORIMETRY_NO_DATA		= 0,
+	DRM_MODE_COLORIMETRY_SMPTE_170M_YCC	= 1,
+	DRM_MODE_COLORIMETRY_BT709_YCC		= 2,
+	/* CEA 861 Extended Colorimetry Options */
+	DRM_MODE_COLORIMETRY_XVYCC_601		= 3,
+	DRM_MODE_COLORIMETRY_XVYCC_709		= 4,
+	DRM_MODE_COLORIMETRY_SYCC_601		= 5,
+	DRM_MODE_COLORIMETRY_OPYCC_601		= 6,
+	DRM_MODE_COLORIMETRY_OPRGB		= 7,
+	DRM_MODE_COLORIMETRY_BT2020_CYCC	= 8,
+	DRM_MODE_COLORIMETRY_BT2020_RGB		= 9,
+	DRM_MODE_COLORIMETRY_BT2020_YCC		= 10,
+	/* Additional Colorimetry extension added as part of CTA 861.G */
+	DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65	= 11,
+	DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER	= 12,
+	/* Additional Colorimetry Options added for DP 1.4a VSC Colorimetry Format */
+	DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED	= 13,
+	DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT	= 14,
+	DRM_MODE_COLORIMETRY_BT601_YCC		= 15,
+	DRM_MODE_COLORIMETRY_COUNT
+};
 
 /* Content type options */
 #define DRM_MODE_CONTENT_TYPE_NO_DATA		0