drm/vc4: Rework the encoder retrieval code
authorMaxime Ripard <maxime@cerno.tech>
Tue, 16 Mar 2021 12:51:52 +0000 (13:51 +0100)
committerPhil Elwell <8911409+pelwell@users.noreply.github.com>
Wed, 21 Apr 2021 13:13:56 +0000 (14:13 +0100)
commit3cf3d39b754a78c67134da7b8109eb968129ef8d
tree9ccbc62f4542a9ccc867e034eff6f0a1f2eb9435
parent4fb83a7fce24148e541bce94622f2efcb620d18b
drm/vc4: Rework the encoder retrieval code

Due to a FIFO that cannot be flushed between the pixelvalve and the HDMI
controllers on BCM2711, we need to carefully disable both at boot time
if they were left enabled by the firmware.

However, at the time we're running that code, the struct drm_connector
encoder pointer isn't set yet, and thus we cannot retrieve the encoder
associated to our CRTC.

We can however make use of the fact that we have a less flexible setup
than what DRM allows where we have a 1:1 relationship between our CRTCs
and encoders (and connectors), and thus store the crtc associated to our
encoder at boot time.

We cannot do that at the time the encoders are probed though, since the
CRTCs won't be probed yet and thus we don't know at that time which CRTC
index we're going to get, so let's do this in two passes: we can first
bind all the components and then once they all are bound, we can iterate
over all the encoders to find their associated CRTC and set the pointer.

This is similar to what we're doing to set the possible_crtcs field.

Fixes: 875a4d536842 ("drm/vc4: drv: Disable the CRTC at boot time")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
drivers/gpu/drm/vc4/vc4_crtc.c
drivers/gpu/drm/vc4/vc4_drv.c
drivers/gpu/drm/vc4/vc4_drv.h