Commit b79ebe74 authored by Imre Deak's avatar Imre Deak

drm/i915/ddi: Simplify get_encoder_power_domains()

We can simplify the encoder's get_power_domains() hook by calling it
only if the encoder is active. That way the hook can return its power
domains unconditionally without checking the active state by calling
encoder::get_hw_state(). This get_hw_state() query is in fact
redundant since it's already done by intel_modeset_readout_hw_state()
setting the encoder's crtc or leaving it NULL accordingly. Let's use
this fact to decide if the encoder is active.

While at it clarify the comment in intel_ddi_get_power_domains() about
primary vs. fake MST encoders and make sure we never do an incorrect
encoder->dig_port cast for fake MST encoders.
Suggested-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180705122654.17072-1-imre.deak@intel.com
parent 6cc42152
...@@ -2006,24 +2006,19 @@ intel_ddi_main_link_aux_domain(struct intel_dp *intel_dp) ...@@ -2006,24 +2006,19 @@ intel_ddi_main_link_aux_domain(struct intel_dp *intel_dp)
static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder, static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder,
struct intel_crtc_state *crtc_state) struct intel_crtc_state *crtc_state)
{ {
struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base); struct intel_digital_port *dig_port;
enum pipe pipe;
u64 domains; u64 domains;
if (!intel_ddi_get_hw_state(encoder, &pipe))
return 0;
domains = BIT_ULL(dig_port->ddi_io_power_domain);
if (!crtc_state)
return domains;
/* /*
* TODO: Add support for MST encoders. Atm, the following should never * TODO: Add support for MST encoders. Atm, the following should never
* happen since this function will be called only for the primary * happen since fake-MST encoders don't set their get_power_domains()
* encoder which doesn't have its own pipe/crtc_state. * hook.
*/ */
if (WARN_ON(intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST))) if (WARN_ON(intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST)))
return domains; return 0;
dig_port = enc_to_dig_port(&encoder->base);
domains = BIT_ULL(dig_port->ddi_io_power_domain);
/* AUX power is only needed for (e)DP mode, not for HDMI. */ /* AUX power is only needed for (e)DP mode, not for HDMI. */
if (intel_crtc_has_dp_encoder(crtc_state)) { if (intel_crtc_has_dp_encoder(crtc_state)) {
......
...@@ -15664,14 +15664,13 @@ get_encoder_power_domains(struct drm_i915_private *dev_priv) ...@@ -15664,14 +15664,13 @@ get_encoder_power_domains(struct drm_i915_private *dev_priv)
continue; continue;
/* /*
* For MST and inactive encoders we don't have a crtc state. * MST-primary and inactive encoders don't have a crtc state
* FIXME: no need to call get_power_domains in such cases, it * and neither of these require any power domain references.
* will always return 0.
*/ */
crtc_state = encoder->base.crtc ? if (!encoder->base.crtc)
to_intel_crtc_state(encoder->base.crtc->state) : continue;
NULL;
crtc_state = to_intel_crtc_state(encoder->base.crtc->state);
get_domains = encoder->get_power_domains(encoder, crtc_state); get_domains = encoder->get_power_domains(encoder, crtc_state);
for_each_power_domain(domain, get_domains) for_each_power_domain(domain, get_domains)
intel_display_power_get(dev_priv, domain); intel_display_power_get(dev_priv, domain);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment