Commit b1040461 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Consolidate HDMI force_dvi handling

Move the force_dvi check to a single function that can be called from
both mode validation and compute_config().
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200108181242.13650-2-ville.syrjala@linux.intel.comReviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
parent cb70b713
...@@ -2109,9 +2109,16 @@ static int intel_hdmi_source_max_tmds_clock(struct intel_encoder *encoder) ...@@ -2109,9 +2109,16 @@ static int intel_hdmi_source_max_tmds_clock(struct intel_encoder *encoder)
return max_tmds_clock; 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, static int hdmi_port_clock_limit(struct intel_hdmi *hdmi,
bool respect_downstream_limits, bool respect_downstream_limits,
bool force_dvi) bool has_hdmi_sink)
{ {
struct intel_encoder *encoder = &hdmi_to_dig_port(hdmi)->base; struct intel_encoder *encoder = &hdmi_to_dig_port(hdmi)->base;
int max_tmds_clock = intel_hdmi_source_max_tmds_clock(encoder); int max_tmds_clock = intel_hdmi_source_max_tmds_clock(encoder);
...@@ -2127,7 +2134,7 @@ static int hdmi_port_clock_limit(struct intel_hdmi *hdmi, ...@@ -2127,7 +2134,7 @@ static int hdmi_port_clock_limit(struct intel_hdmi *hdmi,
if (info->max_tmds_clock) if (info->max_tmds_clock)
max_tmds_clock = min(max_tmds_clock, max_tmds_clock = min(max_tmds_clock,
info->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); max_tmds_clock = min(max_tmds_clock, 165000);
} }
...@@ -2137,13 +2144,14 @@ static int hdmi_port_clock_limit(struct intel_hdmi *hdmi, ...@@ -2137,13 +2144,14 @@ static int hdmi_port_clock_limit(struct intel_hdmi *hdmi,
static enum drm_mode_status static enum drm_mode_status
hdmi_port_clock_valid(struct intel_hdmi *hdmi, hdmi_port_clock_valid(struct intel_hdmi *hdmi,
int clock, bool respect_downstream_limits, 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)); struct drm_i915_private *dev_priv = to_i915(intel_hdmi_to_dev(hdmi));
if (clock < 25000) if (clock < 25000)
return MODE_CLOCK_LOW; 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; return MODE_CLOCK_HIGH;
/* BXT DPLL can't generate 223-240 MHz */ /* BXT DPLL can't generate 223-240 MHz */
...@@ -2165,16 +2173,13 @@ intel_hdmi_mode_valid(struct drm_connector *connector, ...@@ -2165,16 +2173,13 @@ intel_hdmi_mode_valid(struct drm_connector *connector,
struct drm_device *dev = intel_hdmi_to_dev(hdmi); struct drm_device *dev = intel_hdmi_to_dev(hdmi);
struct drm_i915_private *dev_priv = to_i915(dev); struct drm_i915_private *dev_priv = to_i915(dev);
enum drm_mode_status status; enum drm_mode_status status;
int clock; int clock = mode->clock;
int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
bool force_dvi = bool has_hdmi_sink = intel_has_hdmi_sink(hdmi, connector->state);
READ_ONCE(to_intel_digital_connector_state(connector->state)->force_audio) == HDMI_AUDIO_OFF_DVI;
if (mode->flags & DRM_MODE_FLAG_DBLSCAN) if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
return MODE_NO_DBLESCAN; return MODE_NO_DBLESCAN;
clock = mode->clock;
if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == DRM_MODE_FLAG_3D_FRAME_PACKING) if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == DRM_MODE_FLAG_3D_FRAME_PACKING)
clock *= 2; clock *= 2;
...@@ -2188,18 +2193,18 @@ intel_hdmi_mode_valid(struct drm_connector *connector, ...@@ -2188,18 +2193,18 @@ intel_hdmi_mode_valid(struct drm_connector *connector,
clock /= 2; clock /= 2;
/* check if we can do 8bpc */ /* 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 we can't do 8bpc we may still be able to do 12bpc */
if (status != MODE_OK && !HAS_GMCH(dev_priv)) if (status != MODE_OK && !HAS_GMCH(dev_priv))
status = hdmi_port_clock_valid(hdmi, clock * 3 / 2, 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 we can't do 8,12bpc we may still be able to do 10bpc */
if (status != MODE_OK && INTEL_GEN(dev_priv) >= 11) if (status != MODE_OK && INTEL_GEN(dev_priv) >= 11)
status = hdmi_port_clock_valid(hdmi, clock * 5 / 4, status = hdmi_port_clock_valid(hdmi, clock * 5 / 4,
true, force_dvi); true, has_hdmi_sink);
} }
if (status != MODE_OK) if (status != MODE_OK)
return status; return status;
...@@ -2315,7 +2320,7 @@ static int intel_hdmi_port_clock(int clock, int bpc) ...@@ -2315,7 +2320,7 @@ static int intel_hdmi_port_clock(int clock, int bpc)
static int intel_hdmi_compute_bpc(struct intel_encoder *encoder, static int intel_hdmi_compute_bpc(struct intel_encoder *encoder,
struct intel_crtc_state *crtc_state, struct intel_crtc_state *crtc_state,
int clock, bool force_dvi) int clock)
{ {
struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
int bpc; int bpc;
...@@ -2324,7 +2329,7 @@ static int intel_hdmi_compute_bpc(struct intel_encoder *encoder, ...@@ -2324,7 +2329,7 @@ static int intel_hdmi_compute_bpc(struct intel_encoder *encoder,
if (hdmi_deep_color_possible(crtc_state, bpc) && if (hdmi_deep_color_possible(crtc_state, bpc) &&
hdmi_port_clock_valid(intel_hdmi, hdmi_port_clock_valid(intel_hdmi,
intel_hdmi_port_clock(clock, bpc), intel_hdmi_port_clock(clock, bpc),
true, force_dvi) == MODE_OK) true, crtc_state->has_hdmi_sink) == MODE_OK)
return bpc; return bpc;
} }
...@@ -2332,8 +2337,7 @@ static int intel_hdmi_compute_bpc(struct intel_encoder *encoder, ...@@ -2332,8 +2337,7 @@ static int intel_hdmi_compute_bpc(struct intel_encoder *encoder,
} }
static int intel_hdmi_compute_clock(struct intel_encoder *encoder, static int intel_hdmi_compute_clock(struct intel_encoder *encoder,
struct intel_crtc_state *crtc_state, struct intel_crtc_state *crtc_state)
bool force_dvi)
{ {
struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
const struct drm_display_mode *adjusted_mode = const struct drm_display_mode *adjusted_mode =
...@@ -2347,8 +2351,7 @@ static int intel_hdmi_compute_clock(struct intel_encoder *encoder, ...@@ -2347,8 +2351,7 @@ static int intel_hdmi_compute_clock(struct intel_encoder *encoder,
if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420) if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420)
clock /= 2; clock /= 2;
bpc = intel_hdmi_compute_bpc(encoder, crtc_state, bpc = intel_hdmi_compute_bpc(encoder, crtc_state, clock);
clock, force_dvi);
crtc_state->port_clock = intel_hdmi_port_clock(clock, bpc); crtc_state->port_clock = intel_hdmi_port_clock(clock, bpc);
...@@ -2364,7 +2367,7 @@ static int intel_hdmi_compute_clock(struct intel_encoder *encoder, ...@@ -2364,7 +2367,7 @@ static int intel_hdmi_compute_clock(struct intel_encoder *encoder,
bpc, crtc_state->pipe_bpp); bpc, crtc_state->pipe_bpp);
if (hdmi_port_clock_valid(intel_hdmi, crtc_state->port_clock, 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", DRM_DEBUG_KMS("unsupported HDMI clock (%d kHz), rejecting mode\n",
crtc_state->port_clock); crtc_state->port_clock);
return -EINVAL; return -EINVAL;
...@@ -2412,14 +2415,14 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder, ...@@ -2412,14 +2415,14 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder,
struct drm_scdc *scdc = &connector->display_info.hdmi.scdc; struct drm_scdc *scdc = &connector->display_info.hdmi.scdc;
struct intel_digital_connector_state *intel_conn_state = struct intel_digital_connector_state *intel_conn_state =
to_intel_digital_connector_state(conn_state); to_intel_digital_connector_state(conn_state);
bool force_dvi = intel_conn_state->force_audio == HDMI_AUDIO_OFF_DVI;
int ret; int ret;
if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN) if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
return -EINVAL; return -EINVAL;
pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB; 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) if (pipe_config->has_hdmi_sink)
pipe_config->has_infoframe = true; pipe_config->has_infoframe = true;
...@@ -2448,7 +2451,7 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder, ...@@ -2448,7 +2451,7 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder,
intel_conn_state->force_audio == HDMI_AUDIO_ON; 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) if (ret)
return ret; return ret;
......
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