Skip to content

Commit e870563

Browse files
vsyrjalajlahtine-intel
authored andcommitted
drm/i915: Fix readout degamma_lut mismatch on ilk/snb
On ilk/snb the pipe may be configured to place the LUT before or after the CSC depending on various factors, but as there is only one LUT (no split mode like on IVB+) we only advertise a gamma_lut and no degamma_lut in the uapi to avoid confusing userspace. This can cause a problem during readout if the VBIOS/GOP enabled the LUT in the pre CSC configuration. The current code blindly assigns the results of the readout to the degamma_lut, which will cause a failure during the next atomic_check() as we aren't expecting anything to be in degamma_lut since it's not visible to userspace. Fix the problem by assigning whatever LUT we read out from the hardware into gamma_lut. Cc: [email protected] Fixes: d255929 ("drm/i915: Make ilk_read_luts() capable of degamma readout") Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11608 Signed-off-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Uma Shankar <[email protected]> (cherry picked from commit 33eca84) Signed-off-by: Joonas Lahtinen <[email protected]>
1 parent 59d3cfd commit e870563

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

drivers/gpu/drm/i915/display/intel_modeset_setup.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ static void intel_modeset_update_connector_atomic_state(struct drm_i915_private
326326

327327
static void intel_crtc_copy_hw_to_uapi_state(struct intel_crtc_state *crtc_state)
328328
{
329+
struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev);
330+
329331
if (intel_crtc_is_joiner_secondary(crtc_state))
330332
return;
331333

@@ -337,11 +339,30 @@ static void intel_crtc_copy_hw_to_uapi_state(struct intel_crtc_state *crtc_state
337339
crtc_state->uapi.adjusted_mode = crtc_state->hw.adjusted_mode;
338340
crtc_state->uapi.scaling_filter = crtc_state->hw.scaling_filter;
339341

340-
/* assume 1:1 mapping */
341-
drm_property_replace_blob(&crtc_state->hw.degamma_lut,
342-
crtc_state->pre_csc_lut);
343-
drm_property_replace_blob(&crtc_state->hw.gamma_lut,
344-
crtc_state->post_csc_lut);
342+
if (DISPLAY_INFO(i915)->color.degamma_lut_size) {
343+
/* assume 1:1 mapping */
344+
drm_property_replace_blob(&crtc_state->hw.degamma_lut,
345+
crtc_state->pre_csc_lut);
346+
drm_property_replace_blob(&crtc_state->hw.gamma_lut,
347+
crtc_state->post_csc_lut);
348+
} else {
349+
/*
350+
* ilk/snb hw may be configured for either pre_csc_lut
351+
* or post_csc_lut, but we don't advertise degamma_lut as
352+
* being available in the uapi since there is only one
353+
* hardware LUT. Always assign the result of the readout
354+
* to gamma_lut as that is the only valid source of LUTs
355+
* in the uapi.
356+
*/
357+
drm_WARN_ON(&i915->drm, crtc_state->post_csc_lut &&
358+
crtc_state->pre_csc_lut);
359+
360+
drm_property_replace_blob(&crtc_state->hw.degamma_lut,
361+
NULL);
362+
drm_property_replace_blob(&crtc_state->hw.gamma_lut,
363+
crtc_state->post_csc_lut ?:
364+
crtc_state->pre_csc_lut);
365+
}
345366

346367
drm_property_replace_blob(&crtc_state->uapi.degamma_lut,
347368
crtc_state->hw.degamma_lut);

0 commit comments

Comments
 (0)