On Wed, 08 Jan 2020, Ville Syrjala <ville.syrj...@linux.intel.com> wrote: > From: Ville Syrjälä <ville.syrj...@linux.intel.com> > > Move the force_dvi check to a single function that can be called from > both mode validation and compute_config(). > > Signed-off-by: Ville Syrjälä <ville.syrj...@linux.intel.com>
Reviewed-by: Jani Nikula <jani.nik...@intel.com> > --- > drivers/gpu/drm/i915/display/intel_hdmi.c | 49 ++++++++++++----------- > 1 file changed, 26 insertions(+), 23 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c > b/drivers/gpu/drm/i915/display/intel_hdmi.c > index 685589064d10..1659cff91426 100644 > --- a/drivers/gpu/drm/i915/display/intel_hdmi.c > +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c > @@ -2108,9 +2108,16 @@ static int intel_hdmi_source_max_tmds_clock(struct > intel_encoder *encoder) > return max_tmds_clock; > } > > +static bool intel_has_hdmi_sink(struct intel_hdmi *hdmi, > + const struct drm_connector_state *conn_state) > +{ > + return hdmi->has_hdmi_sink && > + > READ_ONCE(to_intel_digital_connector_state(conn_state)->force_audio) != > HDMI_AUDIO_OFF_DVI; > +} > + > static int hdmi_port_clock_limit(struct intel_hdmi *hdmi, > bool respect_downstream_limits, > - bool force_dvi) > + bool has_hdmi_sink) > { > struct intel_encoder *encoder = &hdmi_to_dig_port(hdmi)->base; > int max_tmds_clock = intel_hdmi_source_max_tmds_clock(encoder); > @@ -2126,7 +2133,7 @@ static int hdmi_port_clock_limit(struct intel_hdmi > *hdmi, > if (info->max_tmds_clock) > max_tmds_clock = min(max_tmds_clock, > info->max_tmds_clock); > - else if (!hdmi->has_hdmi_sink || force_dvi) > + else if (!has_hdmi_sink) > max_tmds_clock = min(max_tmds_clock, 165000); > } > > @@ -2136,13 +2143,14 @@ static int hdmi_port_clock_limit(struct intel_hdmi > *hdmi, > static enum drm_mode_status > hdmi_port_clock_valid(struct intel_hdmi *hdmi, > int clock, bool respect_downstream_limits, > - bool force_dvi) > + bool has_hdmi_sink) > { > struct drm_i915_private *dev_priv = to_i915(intel_hdmi_to_dev(hdmi)); > > if (clock < 25000) > return MODE_CLOCK_LOW; > - if (clock > hdmi_port_clock_limit(hdmi, respect_downstream_limits, > force_dvi)) > + if (clock > hdmi_port_clock_limit(hdmi, respect_downstream_limits, > + has_hdmi_sink)) > return MODE_CLOCK_HIGH; > > /* BXT DPLL can't generate 223-240 MHz */ > @@ -2164,16 +2172,13 @@ intel_hdmi_mode_valid(struct drm_connector *connector, > struct drm_device *dev = intel_hdmi_to_dev(hdmi); > struct drm_i915_private *dev_priv = to_i915(dev); > enum drm_mode_status status; > - int clock; > + int clock = mode->clock; > int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; > - bool force_dvi = > - > READ_ONCE(to_intel_digital_connector_state(connector->state)->force_audio) == > HDMI_AUDIO_OFF_DVI; > + bool has_hdmi_sink = intel_has_hdmi_sink(hdmi, connector->state); > > if (mode->flags & DRM_MODE_FLAG_DBLSCAN) > return MODE_NO_DBLESCAN; > > - clock = mode->clock; > - > if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == > DRM_MODE_FLAG_3D_FRAME_PACKING) > clock *= 2; > > @@ -2187,18 +2192,18 @@ intel_hdmi_mode_valid(struct drm_connector *connector, > clock /= 2; > > /* check if we can do 8bpc */ > - status = hdmi_port_clock_valid(hdmi, clock, true, force_dvi); > + status = hdmi_port_clock_valid(hdmi, clock, true, has_hdmi_sink); > > - if (hdmi->has_hdmi_sink && !force_dvi) { > + if (has_hdmi_sink) { > /* if we can't do 8bpc we may still be able to do 12bpc */ > if (status != MODE_OK && !HAS_GMCH(dev_priv)) > status = hdmi_port_clock_valid(hdmi, clock * 3 / 2, > - true, force_dvi); > + true, has_hdmi_sink); > > /* if we can't do 8,12bpc we may still be able to do 10bpc */ > if (status != MODE_OK && INTEL_GEN(dev_priv) >= 11) > status = hdmi_port_clock_valid(hdmi, clock * 5 / 4, > - true, force_dvi); > + true, has_hdmi_sink); > } > if (status != MODE_OK) > return status; > @@ -2314,7 +2319,7 @@ static int intel_hdmi_port_clock(int clock, int bpc) > > static int intel_hdmi_compute_bpc(struct intel_encoder *encoder, > struct intel_crtc_state *crtc_state, > - int clock, bool force_dvi) > + int clock) > { > struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); > int bpc; > @@ -2323,7 +2328,7 @@ static int intel_hdmi_compute_bpc(struct intel_encoder > *encoder, > if (hdmi_deep_color_possible(crtc_state, bpc) && > hdmi_port_clock_valid(intel_hdmi, > intel_hdmi_port_clock(clock, bpc), > - true, force_dvi) == MODE_OK) > + true, crtc_state->has_hdmi_sink) == > MODE_OK) > return bpc; > } > > @@ -2331,8 +2336,7 @@ static int intel_hdmi_compute_bpc(struct intel_encoder > *encoder, > } > > static int intel_hdmi_compute_clock(struct intel_encoder *encoder, > - struct intel_crtc_state *crtc_state, > - bool force_dvi) > + struct intel_crtc_state *crtc_state) > { > struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base); > const struct drm_display_mode *adjusted_mode = > @@ -2346,8 +2350,7 @@ static int intel_hdmi_compute_clock(struct > intel_encoder *encoder, > if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420) > clock /= 2; > > - bpc = intel_hdmi_compute_bpc(encoder, crtc_state, > - clock, force_dvi); > + bpc = intel_hdmi_compute_bpc(encoder, crtc_state, clock); > > crtc_state->port_clock = intel_hdmi_port_clock(clock, bpc); > > @@ -2363,7 +2366,7 @@ static int intel_hdmi_compute_clock(struct > intel_encoder *encoder, > bpc, crtc_state->pipe_bpp); > > if (hdmi_port_clock_valid(intel_hdmi, crtc_state->port_clock, > - false, force_dvi) != MODE_OK) { > + false, crtc_state->has_hdmi_sink) != MODE_OK) > { > DRM_DEBUG_KMS("unsupported HDMI clock (%d kHz), rejecting > mode\n", > crtc_state->port_clock); > return -EINVAL; > @@ -2411,14 +2414,14 @@ int intel_hdmi_compute_config(struct intel_encoder > *encoder, > struct drm_scdc *scdc = &connector->display_info.hdmi.scdc; > struct intel_digital_connector_state *intel_conn_state = > to_intel_digital_connector_state(conn_state); > - bool force_dvi = intel_conn_state->force_audio == HDMI_AUDIO_OFF_DVI; > int ret; > > if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN) > return -EINVAL; > > pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB; > - pipe_config->has_hdmi_sink = !force_dvi && intel_hdmi->has_hdmi_sink; > + pipe_config->has_hdmi_sink = intel_has_hdmi_sink(intel_hdmi, > + conn_state); > > if (pipe_config->has_hdmi_sink) > pipe_config->has_infoframe = true; > @@ -2447,7 +2450,7 @@ int intel_hdmi_compute_config(struct intel_encoder > *encoder, > intel_conn_state->force_audio == HDMI_AUDIO_ON; > } > > - ret = intel_hdmi_compute_clock(encoder, pipe_config, force_dvi); > + ret = intel_hdmi_compute_clock(encoder, pipe_config); > if (ret) > return ret; -- Jani Nikula, Intel Open Source Graphics Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx