diff mbox series

[3/9] drm/i915/sdvo: Consolidate SDVO HDMI force_dvi handling

Message ID 20200108181242.13650-3-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [1/9] drm/i915/sdvo: Reduce the size of the on stack buffers | expand

Commit Message

Ville Syrjala Jan. 8, 2020, 6:12 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Move the force_dvi check to a single function that can be called from
both mode validation and compute_config(). Note that currently we
don't call it from mode validation, but that will change soon.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_sdvo.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

Comments

Jani Nikula Jan. 14, 2020, 2:52 p.m. UTC | #1
On Wed, 08 Jan 2020, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Move the force_dvi check to a single function that can be called from
> both mode validation and compute_config(). Note that currently we
> don't call it from mode validation, but that will change soon.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/display/intel_sdvo.c | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_sdvo.c b/drivers/gpu/drm/i915/display/intel_sdvo.c
> index 02119c827c80..2d2c5e1c7e7c 100644
> --- a/drivers/gpu/drm/i915/display/intel_sdvo.c
> +++ b/drivers/gpu/drm/i915/display/intel_sdvo.c
> @@ -1264,6 +1264,13 @@ static void i9xx_adjust_sdvo_tv_clock(struct intel_crtc_state *pipe_config)
>  	pipe_config->clock_set = true;
>  }
>  
> +static bool intel_has_hdmi_sink(struct intel_sdvo *sdvo,
> +				const struct drm_connector_state *conn_state)
> +{
> +	return sdvo->has_hdmi_monitor &&
> +		READ_ONCE(to_intel_digital_connector_state(conn_state)->force_audio) != HDMI_AUDIO_OFF_DVI;
> +}
> +
>  static int intel_sdvo_compute_config(struct intel_encoder *encoder,
>  				     struct intel_crtc_state *pipe_config,
>  				     struct drm_connector_state *conn_state)
> @@ -1319,12 +1326,15 @@ static int intel_sdvo_compute_config(struct intel_encoder *encoder,
>  	pipe_config->pixel_multiplier =
>  		intel_sdvo_get_pixel_multiplier(adjusted_mode);
>  
> -	if (intel_sdvo_state->base.force_audio != HDMI_AUDIO_OFF_DVI)
> -		pipe_config->has_hdmi_sink = intel_sdvo->has_hdmi_monitor;
> +	pipe_config->has_hdmi_sink = intel_has_hdmi_sink(intel_sdvo, conn_state);
>  
> -	if (intel_sdvo_state->base.force_audio == HDMI_AUDIO_ON ||
> -	    (intel_sdvo_state->base.force_audio == HDMI_AUDIO_AUTO && intel_sdvo->has_hdmi_audio))
> -		pipe_config->has_audio = true;
> +	if (pipe_config->has_hdmi_sink) {
> +		if (intel_sdvo_state->base.force_audio == HDMI_AUDIO_AUTO)
> +			pipe_config->has_audio = intel_sdvo->has_hdmi_audio;
> +		else
> +			pipe_config->has_audio =
> +				intel_sdvo_state->base.force_audio == HDMI_AUDIO_ON;
> +	}
>  
>  	if (intel_sdvo_state->base.broadcast_rgb == INTEL_BROADCAST_RGB_AUTO) {
>  		/*
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_sdvo.c b/drivers/gpu/drm/i915/display/intel_sdvo.c
index 02119c827c80..2d2c5e1c7e7c 100644
--- a/drivers/gpu/drm/i915/display/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/display/intel_sdvo.c
@@ -1264,6 +1264,13 @@  static void i9xx_adjust_sdvo_tv_clock(struct intel_crtc_state *pipe_config)
 	pipe_config->clock_set = true;
 }
 
+static bool intel_has_hdmi_sink(struct intel_sdvo *sdvo,
+				const struct drm_connector_state *conn_state)
+{
+	return sdvo->has_hdmi_monitor &&
+		READ_ONCE(to_intel_digital_connector_state(conn_state)->force_audio) != HDMI_AUDIO_OFF_DVI;
+}
+
 static int intel_sdvo_compute_config(struct intel_encoder *encoder,
 				     struct intel_crtc_state *pipe_config,
 				     struct drm_connector_state *conn_state)
@@ -1319,12 +1326,15 @@  static int intel_sdvo_compute_config(struct intel_encoder *encoder,
 	pipe_config->pixel_multiplier =
 		intel_sdvo_get_pixel_multiplier(adjusted_mode);
 
-	if (intel_sdvo_state->base.force_audio != HDMI_AUDIO_OFF_DVI)
-		pipe_config->has_hdmi_sink = intel_sdvo->has_hdmi_monitor;
+	pipe_config->has_hdmi_sink = intel_has_hdmi_sink(intel_sdvo, conn_state);
 
-	if (intel_sdvo_state->base.force_audio == HDMI_AUDIO_ON ||
-	    (intel_sdvo_state->base.force_audio == HDMI_AUDIO_AUTO && intel_sdvo->has_hdmi_audio))
-		pipe_config->has_audio = true;
+	if (pipe_config->has_hdmi_sink) {
+		if (intel_sdvo_state->base.force_audio == HDMI_AUDIO_AUTO)
+			pipe_config->has_audio = intel_sdvo->has_hdmi_audio;
+		else
+			pipe_config->has_audio =
+				intel_sdvo_state->base.force_audio == HDMI_AUDIO_ON;
+	}
 
 	if (intel_sdvo_state->base.broadcast_rgb == INTEL_BROADCAST_RGB_AUTO) {
 		/*