@@ -255,36 +255,19 @@ static void ilk_load_csc_matrix(const struct intel_crtc_state *crtc_state)
255
255
struct intel_crtc * crtc = to_intel_crtc (crtc_state -> base .crtc );
256
256
struct drm_i915_private * dev_priv = to_i915 (crtc -> base .dev );
257
257
bool limited_color_range = ilk_csc_limited_range (crtc_state );
258
- enum pipe pipe = crtc -> pipe ;
259
- u16 coeffs [9 ] = {};
260
-
261
- if (crtc_state -> output_format == INTEL_OUTPUT_FORMAT_YCBCR420 ||
262
- crtc_state -> output_format == INTEL_OUTPUT_FORMAT_YCBCR444 ) {
263
- if (INTEL_GEN (dev_priv ) >= 11 )
264
- icl_update_output_csc (crtc , ilk_csc_off_zero ,
265
- ilk_csc_coeff_rgb_to_ycbcr ,
266
- ilk_csc_postoff_rgb_to_ycbcr );
267
- else
268
- ilk_update_pipe_csc (crtc , ilk_csc_off_zero ,
269
- ilk_csc_coeff_rgb_to_ycbcr ,
270
- ilk_csc_postoff_rgb_to_ycbcr );
271
-
272
- I915_WRITE (PIPE_CSC_MODE (pipe ), crtc_state -> csc_mode );
273
- /*
274
- * On pre GEN11 output CSC is not there, so with 1 pipe CSC
275
- * RGB to YUV conversion can be done. No need to go further
276
- */
277
- if (INTEL_GEN (dev_priv ) < 11 )
278
- return ;
279
- }
280
258
281
259
if (crtc_state -> base .ctm ) {
282
- ilk_csc_convert_ctm ( crtc_state , coeffs ) ;
260
+ u16 coeff [ 9 ] ;
283
261
284
- ilk_update_pipe_csc (crtc , ilk_csc_off_zero , coeffs ,
262
+ ilk_csc_convert_ctm (crtc_state , coeff );
263
+ ilk_update_pipe_csc (crtc , ilk_csc_off_zero , coeff ,
285
264
limited_color_range ?
286
265
ilk_csc_postoff_limited_range :
287
266
ilk_csc_off_zero );
267
+ } else if (crtc_state -> output_format != INTEL_OUTPUT_FORMAT_RGB ) {
268
+ ilk_update_pipe_csc (crtc , ilk_csc_off_zero ,
269
+ ilk_csc_coeff_rgb_to_ycbcr ,
270
+ ilk_csc_postoff_rgb_to_ycbcr );
288
271
} else if (limited_color_range ) {
289
272
ilk_update_pipe_csc (crtc , ilk_csc_off_zero ,
290
273
ilk_csc_coeff_limited_range ,
@@ -295,7 +278,33 @@ static void ilk_load_csc_matrix(const struct intel_crtc_state *crtc_state)
295
278
ilk_csc_off_zero );
296
279
}
297
280
298
- I915_WRITE (PIPE_CSC_MODE (pipe ), crtc_state -> csc_mode );
281
+ I915_WRITE (PIPE_CSC_MODE (crtc -> pipe ), crtc_state -> csc_mode );
282
+ }
283
+
284
+ static void icl_load_csc_matrix (const struct intel_crtc_state * crtc_state )
285
+ {
286
+ struct intel_crtc * crtc = to_intel_crtc (crtc_state -> base .crtc );
287
+ struct drm_i915_private * dev_priv = to_i915 (crtc -> base .dev );
288
+
289
+ if (crtc_state -> base .ctm ) {
290
+ u16 coeff [9 ];
291
+
292
+ ilk_csc_convert_ctm (crtc_state , coeff );
293
+ ilk_update_pipe_csc (crtc , ilk_csc_off_zero ,
294
+ coeff , ilk_csc_off_zero );
295
+ }
296
+
297
+ if (crtc_state -> output_format != INTEL_OUTPUT_FORMAT_RGB ) {
298
+ icl_update_output_csc (crtc , ilk_csc_off_zero ,
299
+ ilk_csc_coeff_rgb_to_ycbcr ,
300
+ ilk_csc_postoff_rgb_to_ycbcr );
301
+ } else if (crtc_state -> limited_color_range ) {
302
+ icl_update_output_csc (crtc , ilk_csc_off_zero ,
303
+ ilk_csc_coeff_limited_range ,
304
+ ilk_csc_postoff_limited_range );
305
+ }
306
+
307
+ I915_WRITE (PIPE_CSC_MODE (crtc -> pipe ), crtc_state -> csc_mode );
299
308
}
300
309
301
310
/*
@@ -445,7 +454,10 @@ static void skl_color_commit(const struct intel_crtc_state *crtc_state)
445
454
446
455
I915_WRITE (GAMMA_MODE (crtc -> pipe ), crtc_state -> gamma_mode );
447
456
448
- ilk_load_csc_matrix (crtc_state );
457
+ if (INTEL_GEN (dev_priv ) >= 11 )
458
+ icl_load_csc_matrix (crtc_state );
459
+ else
460
+ ilk_load_csc_matrix (crtc_state );
449
461
}
450
462
451
463
static void bdw_load_degamma_lut (const struct intel_crtc_state * crtc_state )
@@ -843,11 +855,12 @@ int intel_color_check(struct intel_crtc_state *crtc_state)
843
855
crtc_state -> gamma_mode = GAMMA_MODE_MODE_8BIT ;
844
856
845
857
if (INTEL_GEN (dev_priv ) >= 11 ) {
846
- if (crtc_state -> output_format == INTEL_OUTPUT_FORMAT_YCBCR420 ||
847
- crtc_state -> output_format == INTEL_OUTPUT_FORMAT_YCBCR444 )
858
+ if (crtc_state -> output_format != INTEL_OUTPUT_FORMAT_RGB ||
859
+ crtc_state -> limited_color_range )
848
860
crtc_state -> csc_mode |= ICL_OUTPUT_CSC_ENABLE ;
849
861
850
- crtc_state -> csc_mode |= ICL_CSC_ENABLE ;
862
+ if (crtc_state -> base .ctm )
863
+ crtc_state -> csc_mode |= ICL_CSC_ENABLE ;
851
864
}
852
865
853
866
return 0 ;
0 commit comments