Skip to content

Commit ef073f6

Browse files
mripardpelwell
authored andcommitted
drm/vc4: hdmi: Introduce a scdc_enabled flag
We currently rely on two functions, vc4_hdmi_supports_scrambling() and vc4_hdmi_mode_needs_scrambling() to determine if we should enable and disable the scrambler for any given mode. Since we might need to disable the controller at boot, we also always run vc4_hdmi_disable_scrambling() and thus call those functions without a mode yet, which in turns need to make some special casing in order for it to work. Instead of duplicating the check for whether or not we need to take care of the scrambler in both vc4_hdmi_enable_scrambling() and vc4_hdmi_disable_scrambling(), we can do that check only when we enable it and store whether or not it's been enabled in our private structure. We also need to initialize that flag at true to make sure we disable the scrambler at boot since we can't really know its state yet. This allows to simplify a bit that part of the driver, and removes one user of our copy of the CRTC adjusted mode outside of KMS (since vc4_hdmi_disable_scrambling() might be called from the hotplug interrupt handler). It also removes our last user of the legacy encoder->crtc pointer. Signed-off-by: Maxime Ripard <maxime@cerno.tech>
1 parent 0dbc7ae commit ef073f6

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -643,29 +643,23 @@ static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder)
643643
VC5_HDMI_SCRAMBLER_CTL_ENABLE);
644644
spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
645645

646+
vc4_hdmi->scdc_enabled = true;
647+
646648
queue_delayed_work(system_wq, &vc4_hdmi->scrambling_work,
647649
msecs_to_jiffies(SCRAMBLING_POLLING_DELAY_MS));
648650
}
649651

650652
static void vc4_hdmi_disable_scrambling(struct drm_encoder *encoder)
651653
{
652654
struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
653-
struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode;
654-
struct drm_crtc *crtc = encoder->crtc;
655655
unsigned long flags;
656656

657657
lockdep_assert_held(&vc4_hdmi->mutex);
658658

659-
/*
660-
* At boot, encoder->crtc will be NULL. Since we don't know the
661-
* state of the scrambler and in order to avoid any
662-
* inconsistency, let's disable it all the time.
663-
*/
664-
if (crtc && !vc4_hdmi_supports_scrambling(encoder, mode))
659+
if (!vc4_hdmi->scdc_enabled)
665660
return;
666661

667-
if (crtc && !vc4_hdmi_mode_needs_scrambling(mode))
668-
return;
662+
vc4_hdmi->scdc_enabled = false;
669663

670664
if (delayed_work_pending(&vc4_hdmi->scrambling_work))
671665
cancel_delayed_work_sync(&vc4_hdmi->scrambling_work);
@@ -2608,6 +2602,14 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
26082602
vc4_hdmi->pdev = pdev;
26092603
vc4_hdmi->variant = variant;
26102604

2605+
/*
2606+
* Since we don't know the state of the controller and its
2607+
* display (if any), let's assume it's always enabled.
2608+
* vc4_hdmi_disable_scrambling() will thus run at boot, make
2609+
* sure it's disabled, and avoid any inconsistency.
2610+
*/
2611+
vc4_hdmi->scdc_enabled = true;
2612+
26112613
ret = variant->init_resources(vc4_hdmi);
26122614
if (ret)
26132615
return ret;

‎drivers/gpu/drm/vc4/vc4_hdmi.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ struct vc4_hdmi {
225225
* Protected by @mutex.
226226
*/
227227
bool output_enabled;
228+
229+
/**
230+
* @scdc_enabled: Is the HDMI controller currently running with
231+
* the scrambler on? Protected by @mutex.
232+
*/
233+
bool scdc_enabled;
228234
};
229235

230236
static inline struct vc4_hdmi *

0 commit comments

Comments
 (0)