Skip to content

Commit 1df3825

Browse files
6by9popcornmix
authored andcommitted
drm/vc4: Enable gamma block only when required.
With HVS5 the gamma block is now only reprogrammed with a disable/enable. Loading the table from vc4_hvs_init_channel (called from vc4_hvs_atomic_enable) appears to be at an invalid point in time and so isn't applied. Switch to enabling and disabling the gamma table instead. This isn't safe if the pipeline is running, but it isn't now. For HVS4 it is safe to enable and disable dynamically, so adopt that approach there too. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent fb27937 commit 1df3825

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

‎drivers/gpu/drm/vc4/vc4_hvs.c‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,12 @@ static int vc4_hvs_init_channel(struct vc4_dev *vc4, struct drm_crtc *crtc,
480480
dispbkgndx &= ~SCALER_DISPBKGND_GAMMA;
481481
dispbkgndx &= ~SCALER_DISPBKGND_INTERLACE;
482482

483+
if (crtc->state->gamma_lut)
484+
/* Enable gamma on if required */
485+
dispbkgndx |= SCALER_DISPBKGND_GAMMA;
486+
483487
HVS_WRITE(SCALER_DISPBKGNDX(chan), dispbkgndx |
484-
SCALER_DISPBKGND_AUTOHS | SCALER_DISPBKGND_GAMMA |
488+
SCALER_DISPBKGND_AUTOHS |
485489
(interlace ? SCALER_DISPBKGND_INTERLACE : 0));
486490

487491
/* Reload the LUT, since the SRAMs would have been disabled if
@@ -718,17 +722,25 @@ void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
718722
u32 dispbkgndx = HVS_READ(SCALER_DISPBKGNDX(vc4_state->assigned_channel));
719723

720724
if (crtc->state->gamma_lut) {
721-
if (!vc4->hvs->hvs5)
725+
if (!vc4->hvs->hvs5) {
722726
vc4_hvs_update_gamma_lut(crtc);
723-
else
727+
dispbkgndx |= SCALER_DISPBKGND_GAMMA;
728+
} else {
724729
vc5_hvs_update_gamma_lut(crtc);
725-
dispbkgndx |= SCALER_DISPBKGND_GAMMA;
730+
}
726731
} else {
727732
/* Unsetting DISPBKGND_GAMMA skips the gamma lut step
728733
* in hardware, which is the same as a linear lut that
729734
* DRM expects us to use in absence of a user lut.
735+
*
736+
* Do NOT change state dynamically for hvs5 as it
737+
* inserts a delay in the pipeline that will cause
738+
* stalls if enabled/disabled whilst running. The other
739+
* should already be disabling/enabling the pipeline
740+
* when gamma changes.
730741
*/
731-
dispbkgndx &= ~SCALER_DISPBKGND_GAMMA;
742+
if (!vc4->hvs->hvs5)
743+
dispbkgndx &= ~SCALER_DISPBKGND_GAMMA;
732744
}
733745
HVS_WRITE(SCALER_DISPBKGNDX(vc4_state->assigned_channel), dispbkgndx);
734746
}

0 commit comments

Comments
 (0)