Skip to content

Commit

Permalink
drm/vc4: hdmi: Introduce an output_enabled flag
Browse files Browse the repository at this point in the history
We currently poke at encoder->crtc in the ALSA code path to determine
whether the HDMI output is enabled or not, and thus whether we should
allow the audio output.

However, that pointer is deprecated and shouldn't really be used by
atomic drivers anymore. Since we have the infrastructure in place now,
let's just create a flag that we toggle to report whether the controller
is currently enabled and use that instead of encoder->crtc in ALSA.

Link: https://lore.kernel.org/r/20211025141113.702757-9-maxime@cerno.tech
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
  • Loading branch information
Maxime Ripard committed Nov 5, 2021
1 parent a64ff88 commit ebae26d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 12 additions & 4 deletions drivers/gpu/drm/vc4/vc4_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,11 @@ static void vc4_hdmi_encoder_post_crtc_powerdown(struct drm_encoder *encoder,

static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder)
{
struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);

mutex_lock(&vc4_hdmi->mutex);
vc4_hdmi->output_enabled = false;
mutex_unlock(&vc4_hdmi->mutex);
}

static void vc4_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, bool enable)
Expand Down Expand Up @@ -1218,6 +1223,11 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder,

static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)
{
struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);

mutex_lock(&vc4_hdmi->mutex);
vc4_hdmi->output_enabled = true;
mutex_unlock(&vc4_hdmi->mutex);
}

static void vc4_hdmi_encoder_atomic_mode_set(struct drm_encoder *encoder,
Expand Down Expand Up @@ -1397,14 +1407,12 @@ static inline struct vc4_hdmi *dai_to_hdmi(struct snd_soc_dai *dai)

static bool vc4_hdmi_audio_can_stream(struct vc4_hdmi *vc4_hdmi)
{
struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;

lockdep_assert_held(&vc4_hdmi->mutex);

/*
* The encoder doesn't have a CRTC until the first modeset.
* If the controller is disabled, prevent any ALSA output.
*/
if (!encoder->crtc)
if (!vc4_hdmi->output_enabled)
return false;

/*
Expand Down
6 changes: 6 additions & 0 deletions drivers/gpu/drm/vc4/vc4_hdmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ struct vc4_hdmi {
* for use by ALSA hooks and interrupt handlers. Protected by @mutex.
*/
struct drm_display_mode saved_adjusted_mode;

/**
* @output_enabled: Is the HDMI controller currently active?
* Protected by @mutex.
*/
bool output_enabled;
};

static inline struct vc4_hdmi *
Expand Down

0 comments on commit ebae26d

Please sign in to comment.