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: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200108181242.13650-2-ville.syrjala@linux.intel.com Reviewed-by: Jani Nikula <jani.nikula@intel.com>
This commit is contained in:
parent
cb70b713a8
commit
b1040461e6
|
@ -2109,9 +2109,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);
|
||||
|
@ -2127,7 +2134,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);
|
||||
}
|
||||
|
||||
|
@ -2137,13 +2144,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 */
|
||||
|
@ -2165,16 +2173,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;
|
||||
|
||||
|
@ -2188,18 +2193,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;
|
||||
|
@ -2315,7 +2320,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);
|
||||
int bpc;
|
||||
|
@ -2324,7 +2329,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;
|
||||
}
|
||||
|
||||
|
@ -2332,8 +2337,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);
|
||||
const struct drm_display_mode *adjusted_mode =
|
||||
|
@ -2347,8 +2351,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);
|
||||
|
||||
|
@ -2364,7 +2367,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;
|
||||
|
@ -2412,14 +2415,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;
|
||||
|
@ -2448,7 +2451,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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue