Skip to content

Commit 4d8ed54

Browse files
committed
drm/i915: Split color mgmt based on single vs. double buffered registers
Split the color management hooks along the single vs. double buffered registers line. Of the currently programmed registers GAMMA_MODE and the ilk+ pipe CSC are double buffered, the LUTS and CHV CGM block are single buffered. The double buffered register will be programmed during the normal pipe update with evasion, and also during pipe enable so that the settings will already be correct when the pipe starts up before the planes are enabled. The single buffered registers are currently programmed before the vblank evade. Which is totally wrong, but we'll correct that later. v2: Add some docs to explain the two vfuncs (Matt,Uma) Rebase Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190205160848.24662-6-ville.syrjala@linux.intel.com Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
1 parent 87cefd5 commit 4d8ed54

File tree

4 files changed

+46
-35
lines changed

4 files changed

+46
-35
lines changed

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,19 @@ struct drm_i915_display_funcs {
323323
/* display clock increase/decrease */
324324
/* pll clock increase/decrease */
325325

326-
void (*load_csc_matrix)(const struct intel_crtc_state *crtc_state);
326+
/*
327+
* Program double buffered color management registers during
328+
* vblank evasion. The registers should then latch during the
329+
* next vblank start, alongside any other double buffered registers
330+
* involved with the same commit.
331+
*/
332+
void (*color_commit)(const struct intel_crtc_state *crtc_state);
333+
/*
334+
* Load LUTs (and other single buffered color management
335+
* registers). Will (hopefully) be called during the vblank
336+
* following the latching of any double buffered registers
337+
* involved with the same commit.
338+
*/
327339
void (*load_luts)(const struct intel_crtc_state *crtc_state);
328340
};
329341

drivers/gpu/drm/i915/intel_color.c

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,6 @@ static void cherryview_load_csc_matrix(const struct intel_crtc_state *crtc_state
304304
I915_WRITE(CGM_PIPE_MODE(pipe), mode);
305305
}
306306

307-
void intel_color_set_csc(const struct intel_crtc_state *crtc_state)
308-
{
309-
struct drm_i915_private *dev_priv = to_i915(crtc_state->base.crtc->dev);
310-
311-
if (dev_priv->display.load_csc_matrix)
312-
dev_priv->display.load_csc_matrix(crtc_state);
313-
}
314-
315307
/* Loads the legacy palette/gamma unit for the CRTC. */
316308
static void i9xx_load_luts_internal(const struct intel_crtc_state *crtc_state,
317309
const struct drm_property_blob *blob)
@@ -359,6 +351,16 @@ static void i9xx_load_luts(const struct intel_crtc_state *crtc_state)
359351
i9xx_load_luts_internal(crtc_state, crtc_state->base.gamma_lut);
360352
}
361353

354+
static void hsw_color_commit(const struct intel_crtc_state *crtc_state)
355+
{
356+
struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
357+
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
358+
359+
I915_WRITE(GAMMA_MODE(crtc->pipe), crtc_state->gamma_mode);
360+
361+
ilk_load_csc_matrix(crtc_state);
362+
}
363+
362364
/* Loads the legacy palette/gamma unit for the CRTC on Haswell. */
363365
static void haswell_load_luts(const struct intel_crtc_state *crtc_state)
364366
{
@@ -376,8 +378,6 @@ static void haswell_load_luts(const struct intel_crtc_state *crtc_state)
376378
reenable_ips = true;
377379
}
378380

379-
I915_WRITE(GAMMA_MODE(crtc->pipe), crtc_state->gamma_mode);
380-
381381
i9xx_load_luts(crtc_state);
382382

383383
if (reenable_ips)
@@ -485,8 +485,6 @@ static void broadwell_load_luts(const struct intel_crtc_state *crtc_state)
485485
*/
486486
I915_WRITE(PREC_PAL_INDEX(pipe), 0);
487487
}
488-
489-
I915_WRITE(GAMMA_MODE(pipe), crtc_state->gamma_mode);
490488
}
491489

492490
static void glk_load_degamma_lut(const struct intel_crtc_state *crtc_state)
@@ -539,8 +537,6 @@ static void glk_load_luts(const struct intel_crtc_state *crtc_state)
539537
*/
540538
I915_WRITE(PREC_PAL_INDEX(pipe), 0);
541539
}
542-
543-
I915_WRITE(GAMMA_MODE(pipe), crtc_state->gamma_mode);
544540
}
545541

546542
static void cherryview_load_luts(const struct intel_crtc_state *crtc_state)
@@ -551,10 +547,9 @@ static void cherryview_load_luts(const struct intel_crtc_state *crtc_state)
551547
const struct drm_property_blob *degamma_lut = crtc_state->base.degamma_lut;
552548
enum pipe pipe = crtc->pipe;
553549

550+
cherryview_load_csc_matrix(crtc_state);
551+
554552
if (crtc_state_is_legacy_gamma(crtc_state)) {
555-
/* Turn off degamma/gamma on CGM block. */
556-
I915_WRITE(CGM_PIPE_MODE(pipe),
557-
(crtc_state->base.ctm ? CGM_PIPE_MODE_CSC : 0));
558553
i9xx_load_luts_internal(crtc_state, gamma_lut);
559554
return;
560555
}
@@ -595,11 +590,6 @@ static void cherryview_load_luts(const struct intel_crtc_state *crtc_state)
595590
}
596591
}
597592

598-
I915_WRITE(CGM_PIPE_MODE(pipe),
599-
(crtc_state->base.ctm ? CGM_PIPE_MODE_CSC : 0) |
600-
(degamma_lut ? CGM_PIPE_MODE_DEGAMMA : 0) |
601-
(gamma_lut ? CGM_PIPE_MODE_GAMMA : 0));
602-
603593
/*
604594
* Also program a linear LUT in the legacy block (behind the
605595
* CGM block).
@@ -614,6 +604,14 @@ void intel_color_load_luts(const struct intel_crtc_state *crtc_state)
614604
dev_priv->display.load_luts(crtc_state);
615605
}
616606

607+
void intel_color_commit(const struct intel_crtc_state *crtc_state)
608+
{
609+
struct drm_i915_private *dev_priv = to_i915(crtc_state->base.crtc->dev);
610+
611+
if (dev_priv->display.color_commit)
612+
dev_priv->display.color_commit(crtc_state);
613+
}
614+
617615
static int check_lut_size(const struct drm_property_blob *lut, int expected)
618616
{
619617
int len;
@@ -675,18 +673,17 @@ void intel_color_init(struct intel_crtc *crtc)
675673
drm_mode_crtc_set_gamma_size(&crtc->base, 256);
676674

677675
if (IS_CHERRYVIEW(dev_priv)) {
678-
dev_priv->display.load_csc_matrix = cherryview_load_csc_matrix;
679676
dev_priv->display.load_luts = cherryview_load_luts;
680677
} else if (IS_HASWELL(dev_priv)) {
681-
dev_priv->display.load_csc_matrix = ilk_load_csc_matrix;
682678
dev_priv->display.load_luts = haswell_load_luts;
679+
dev_priv->display.color_commit = hsw_color_commit;
683680
} else if (IS_BROADWELL(dev_priv) || IS_GEN9_BC(dev_priv) ||
684681
IS_BROXTON(dev_priv)) {
685-
dev_priv->display.load_csc_matrix = ilk_load_csc_matrix;
686682
dev_priv->display.load_luts = broadwell_load_luts;
683+
dev_priv->display.color_commit = hsw_color_commit;
687684
} else if (IS_GEMINILAKE(dev_priv) || IS_CANNONLAKE(dev_priv)) {
688-
dev_priv->display.load_csc_matrix = ilk_load_csc_matrix;
689685
dev_priv->display.load_luts = glk_load_luts;
686+
dev_priv->display.color_commit = hsw_color_commit;
690687
} else {
691688
dev_priv->display.load_luts = i9xx_load_luts;
692689
}

drivers/gpu/drm/i915/intel_display.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5779,6 +5779,7 @@ static void ironlake_crtc_enable(struct intel_crtc_state *pipe_config,
57795779
* clocks enabled
57805780
*/
57815781
intel_color_load_luts(pipe_config);
5782+
intel_color_commit(pipe_config);
57825783

57835784
if (dev_priv->display.initial_watermarks != NULL)
57845785
dev_priv->display.initial_watermarks(old_intel_state, pipe_config);
@@ -5888,8 +5889,6 @@ static void haswell_crtc_enable(struct intel_crtc_state *pipe_config,
58885889

58895890
haswell_set_pipemisc(pipe_config);
58905891

5891-
intel_color_set_csc(pipe_config);
5892-
58935892
intel_crtc->active = true;
58945893

58955894
/* Display WA #1180: WaDisableScalarClockGating: glk, cnl */
@@ -5908,6 +5907,7 @@ static void haswell_crtc_enable(struct intel_crtc_state *pipe_config,
59085907
* clocks enabled
59095908
*/
59105909
intel_color_load_luts(pipe_config);
5910+
intel_color_commit(pipe_config);
59115911

59125912
if (INTEL_GEN(dev_priv) >= 11)
59135913
icl_set_pipe_chicken(intel_crtc);
@@ -6245,8 +6245,6 @@ static void valleyview_crtc_enable(struct intel_crtc_state *pipe_config,
62456245

62466246
i9xx_set_pipeconf(pipe_config);
62476247

6248-
intel_color_set_csc(pipe_config);
6249-
62506248
intel_crtc->active = true;
62516249

62526250
intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
@@ -6266,6 +6264,7 @@ static void valleyview_crtc_enable(struct intel_crtc_state *pipe_config,
62666264
i9xx_pfit_enable(pipe_config);
62676265

62686266
intel_color_load_luts(pipe_config);
6267+
intel_color_commit(pipe_config);
62696268

62706269
dev_priv->display.initial_watermarks(old_intel_state,
62716270
pipe_config);
@@ -6322,6 +6321,7 @@ static void i9xx_crtc_enable(struct intel_crtc_state *pipe_config,
63226321
i9xx_pfit_enable(pipe_config);
63236322

63246323
intel_color_load_luts(pipe_config);
6324+
intel_color_commit(pipe_config);
63256325

63266326
if (dev_priv->display.initial_watermarks != NULL)
63276327
dev_priv->display.initial_watermarks(old_intel_state,
@@ -13742,17 +13742,19 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
1374213742

1374313743
if (!modeset &&
1374413744
(intel_cstate->base.color_mgmt_changed ||
13745-
intel_cstate->update_pipe)) {
13746-
intel_color_set_csc(intel_cstate);
13745+
intel_cstate->update_pipe))
1374713746
intel_color_load_luts(intel_cstate);
13748-
}
1374913747

1375013748
/* Perform vblank evasion around commit operation */
1375113749
intel_pipe_update_start(intel_cstate);
1375213750

1375313751
if (modeset)
1375413752
goto out;
1375513753

13754+
if (intel_cstate->base.color_mgmt_changed ||
13755+
intel_cstate->update_pipe)
13756+
intel_color_commit(intel_cstate);
13757+
1375613758
if (intel_cstate->update_pipe)
1375713759
intel_update_pipe_config(old_intel_cstate, intel_cstate);
1375813760
else if (INTEL_GEN(dev_priv) >= 9)

drivers/gpu/drm/i915/intel_drv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,7 @@ int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_
23892389
/* intel_color.c */
23902390
void intel_color_init(struct intel_crtc *crtc);
23912391
int intel_color_check(struct intel_crtc_state *crtc_state);
2392-
void intel_color_set_csc(const struct intel_crtc_state *crtc_state);
2392+
void intel_color_commit(const struct intel_crtc_state *crtc_state);
23932393
void intel_color_load_luts(const struct intel_crtc_state *crtc_state);
23942394

23952395
/* intel_lspcon.c */

0 commit comments

Comments
 (0)