Skip to content

Commit b281264

Browse files
committed
drm/i915: Clean the csc limited range/identity programming
Just provide precomputed CSC matrices for the identity and limited range cases. This removes the remaining nuts and bolts stuff from ilk_load_csc_matrix(), allowing one to actually see the high level logic. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190218193137.22914-7-ville.syrjala@linux.intel.com Reviewed-by: Uma Shankar <uma.shankar@intel.com>
1 parent c9e235a commit b281264

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

drivers/gpu/drm/i915/intel_color.c

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,31 @@
5252
#define ILK_CSC_COEFF_FP(coeff, fbits) \
5353
(clamp_val(((coeff) >> (32 - (fbits) - 3)) + 4, 0, 0xfff) & 0xff8)
5454

55-
#define ILK_CSC_COEFF_LIMITED_RANGE \
56-
ILK_CSC_COEFF_FP(CTM_COEFF_LIMITED_RANGE, 9)
57-
#define ILK_CSC_COEFF_1_0 \
58-
((7 << 12) | ILK_CSC_COEFF_FP(CTM_COEFF_1_0, 8))
55+
#define ILK_CSC_COEFF_LIMITED_RANGE 0x0dc0
56+
#define ILK_CSC_COEFF_1_0 0x7800
5957

6058
#define ILK_CSC_POSTOFF_LIMITED_RANGE (16 * (1 << 12) / 255)
6159

6260
static const u16 ilk_csc_off_zero[3] = {};
6361

62+
static const u16 ilk_csc_coeff_identity[9] = {
63+
ILK_CSC_COEFF_1_0, 0, 0,
64+
0, ILK_CSC_COEFF_1_0, 0,
65+
0, 0, ILK_CSC_COEFF_1_0,
66+
};
67+
6468
static const u16 ilk_csc_postoff_limited_range[3] = {
6569
ILK_CSC_POSTOFF_LIMITED_RANGE,
6670
ILK_CSC_POSTOFF_LIMITED_RANGE,
6771
ILK_CSC_POSTOFF_LIMITED_RANGE,
6872
};
6973

74+
static const u16 ilk_csc_coeff_limited_range[9] = {
75+
ILK_CSC_COEFF_LIMITED_RANGE, 0, 0,
76+
0, ILK_CSC_COEFF_LIMITED_RANGE, 0,
77+
0, 0, ILK_CSC_COEFF_LIMITED_RANGE,
78+
};
79+
7080
/*
7181
* These values are direct register values specified in the Bspec,
7282
* for RGB->YUV conversion matrix (colorspace BT709)
@@ -247,7 +257,6 @@ static void ilk_load_csc_matrix(const struct intel_crtc_state *crtc_state)
247257
bool limited_color_range = ilk_csc_limited_range(crtc_state);
248258
enum pipe pipe = crtc->pipe;
249259
u16 coeffs[9] = {};
250-
int i;
251260

252261
if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420 ||
253262
crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444) {
@@ -271,28 +280,20 @@ static void ilk_load_csc_matrix(const struct intel_crtc_state *crtc_state)
271280

272281
if (crtc_state->base.ctm) {
273282
ilk_csc_convert_ctm(crtc_state, coeffs);
274-
} else {
275-
/*
276-
* Load an identity matrix if no coefficients are provided.
277-
*
278-
* TODO: Check what kind of values actually come out of the
279-
* pipe with these coeff/postoff values and adjust to get the
280-
* best accuracy. Perhaps we even need to take the bpc value
281-
* into consideration.
282-
*/
283-
for (i = 0; i < 3; i++) {
284-
if (limited_color_range)
285-
coeffs[i * 3 + i] =
286-
ILK_CSC_COEFF_LIMITED_RANGE;
287-
else
288-
coeffs[i * 3 + i] = ILK_CSC_COEFF_1_0;
289-
}
290-
}
291283

292-
ilk_update_pipe_csc(crtc, ilk_csc_off_zero, coeffs,
293-
limited_color_range ?
294-
ilk_csc_postoff_limited_range :
295-
ilk_csc_off_zero);
284+
ilk_update_pipe_csc(crtc, ilk_csc_off_zero, coeffs,
285+
limited_color_range ?
286+
ilk_csc_postoff_limited_range :
287+
ilk_csc_off_zero);
288+
} else if (limited_color_range) {
289+
ilk_update_pipe_csc(crtc, ilk_csc_off_zero,
290+
ilk_csc_coeff_limited_range,
291+
ilk_csc_postoff_limited_range);
292+
} else if (crtc_state->csc_enable) {
293+
ilk_update_pipe_csc(crtc, ilk_csc_off_zero,
294+
ilk_csc_coeff_identity,
295+
ilk_csc_off_zero);
296+
}
296297

297298
I915_WRITE(PIPE_CSC_MODE(pipe), crtc_state->csc_mode);
298299
}

0 commit comments

Comments
 (0)