Skip to content

Commit f19d90e

Browse files
committed
drm/i915: Split ilk vs. icl csc matrix handling
Split the csc matrix handling to ilk+ and icl+ functions. This keeps the logic clear on what is loaded into which CSC unit on the hardware. We also fix the icl+ code to load the full->limited range conversion matrix into the output CSC rather than the pipe CSC which was used on earlier platforms. And we also turn on the pipe CSC only when the ctm is present. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190218193137.22914-8-ville.syrjala@linux.intel.com Reviewed-by: Uma Shankar <uma.shankar@intel.com>
1 parent b281264 commit f19d90e

File tree

1 file changed

+42
-29
lines changed

1 file changed

+42
-29
lines changed

drivers/gpu/drm/i915/intel_color.c

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -255,36 +255,19 @@ static void ilk_load_csc_matrix(const struct intel_crtc_state *crtc_state)
255255
struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
256256
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
257257
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-
}
280258

281259
if (crtc_state->base.ctm) {
282-
ilk_csc_convert_ctm(crtc_state, coeffs);
260+
u16 coeff[9];
283261

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,
285264
limited_color_range ?
286265
ilk_csc_postoff_limited_range :
287266
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);
288271
} else if (limited_color_range) {
289272
ilk_update_pipe_csc(crtc, ilk_csc_off_zero,
290273
ilk_csc_coeff_limited_range,
@@ -295,7 +278,33 @@ static void ilk_load_csc_matrix(const struct intel_crtc_state *crtc_state)
295278
ilk_csc_off_zero);
296279
}
297280

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);
299308
}
300309

301310
/*
@@ -445,7 +454,10 @@ static void skl_color_commit(const struct intel_crtc_state *crtc_state)
445454

446455
I915_WRITE(GAMMA_MODE(crtc->pipe), crtc_state->gamma_mode);
447456

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);
449461
}
450462

451463
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)
843855
crtc_state->gamma_mode = GAMMA_MODE_MODE_8BIT;
844856

845857
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)
848860
crtc_state->csc_mode |= ICL_OUTPUT_CSC_ENABLE;
849861

850-
crtc_state->csc_mode |= ICL_CSC_ENABLE;
862+
if (crtc_state->base.ctm)
863+
crtc_state->csc_mode |= ICL_CSC_ENABLE;
851864
}
852865

853866
return 0;

0 commit comments

Comments
 (0)