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

drm/i915: Have pfit calculations return an error code

Change intel_{gmch,pch}_panel_fitting() to return a normal
error vs. success int. We'll need this later to validate that
the margin properties aren't misconfigured.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200422161917.17389-6-ville.syrjala@linux.intel.comReviewed-by: default avatarManasi Navare <manasi.d.navare@intel.com>
parent 4cecc7c0
...@@ -1526,13 +1526,17 @@ static int gen11_dsi_compute_config(struct intel_encoder *encoder, ...@@ -1526,13 +1526,17 @@ static int gen11_dsi_compute_config(struct intel_encoder *encoder,
base); base);
struct intel_connector *intel_connector = intel_dsi->attached_connector; struct intel_connector *intel_connector = intel_dsi->attached_connector;
const struct drm_display_mode *fixed_mode = const struct drm_display_mode *fixed_mode =
intel_connector->panel.fixed_mode; intel_connector->panel.fixed_mode;
struct drm_display_mode *adjusted_mode = struct drm_display_mode *adjusted_mode =
&pipe_config->hw.adjusted_mode; &pipe_config->hw.adjusted_mode;
int ret;
pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB; pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB;
intel_fixed_panel_mode(fixed_mode, adjusted_mode); intel_fixed_panel_mode(fixed_mode, adjusted_mode);
intel_pch_panel_fitting(pipe_config, conn_state);
ret = intel_pch_panel_fitting(pipe_config, conn_state);
if (ret)
return ret;
adjusted_mode->flags = 0; adjusted_mode->flags = 0;
......
...@@ -2354,9 +2354,7 @@ intel_dp_ycbcr420_config(struct intel_dp *intel_dp, ...@@ -2354,9 +2354,7 @@ intel_dp_ycbcr420_config(struct intel_dp *intel_dp,
crtc_state->output_format = INTEL_OUTPUT_FORMAT_YCBCR420; crtc_state->output_format = INTEL_OUTPUT_FORMAT_YCBCR420;
intel_pch_panel_fitting(crtc_state, conn_state); return intel_pch_panel_fitting(crtc_state, conn_state);
return 0;
} }
bool intel_dp_limited_color_range(const struct intel_crtc_state *crtc_state, bool intel_dp_limited_color_range(const struct intel_crtc_state *crtc_state,
...@@ -2568,9 +2566,11 @@ intel_dp_compute_config(struct intel_encoder *encoder, ...@@ -2568,9 +2566,11 @@ intel_dp_compute_config(struct intel_encoder *encoder,
adjusted_mode); adjusted_mode);
if (HAS_GMCH(dev_priv)) if (HAS_GMCH(dev_priv))
intel_gmch_panel_fitting(pipe_config, conn_state); ret = intel_gmch_panel_fitting(pipe_config, conn_state);
else else
intel_pch_panel_fitting(pipe_config, conn_state); ret = intel_pch_panel_fitting(pipe_config, conn_state);
if (ret)
return ret;
} }
if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN) if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
......
...@@ -2321,24 +2321,27 @@ static bool hdmi_deep_color_possible(const struct intel_crtc_state *crtc_state, ...@@ -2321,24 +2321,27 @@ static bool hdmi_deep_color_possible(const struct intel_crtc_state *crtc_state,
return true; return true;
} }
static bool static int
intel_hdmi_ycbcr420_config(struct intel_crtc_state *crtc_state, intel_hdmi_ycbcr420_config(struct intel_crtc_state *crtc_state,
const struct drm_connector_state *conn_state) const struct drm_connector_state *conn_state)
{ {
struct drm_connector *connector = conn_state->connector; struct drm_connector *connector = conn_state->connector;
struct drm_i915_private *i915 = to_i915(connector->dev); struct drm_i915_private *i915 = to_i915(connector->dev);
const struct drm_display_mode *adjusted_mode =
&crtc_state->hw.adjusted_mode;
if (!drm_mode_is_420_only(&connector->display_info, adjusted_mode))
return 0;
if (!connector->ycbcr_420_allowed) { if (!connector->ycbcr_420_allowed) {
drm_err(&i915->drm, drm_err(&i915->drm,
"Platform doesn't support YCBCR420 output\n"); "Platform doesn't support YCBCR420 output\n");
return false; return -EINVAL;
} }
crtc_state->output_format = INTEL_OUTPUT_FORMAT_YCBCR420; crtc_state->output_format = INTEL_OUTPUT_FORMAT_YCBCR420;
intel_pch_panel_fitting(crtc_state, conn_state); return intel_pch_panel_fitting(crtc_state, conn_state);
return true;
} }
static int intel_hdmi_port_clock(int clock, int bpc) static int intel_hdmi_port_clock(int clock, int bpc)
...@@ -2466,13 +2469,9 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder, ...@@ -2466,13 +2469,9 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder,
if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK)
pipe_config->pixel_multiplier = 2; pipe_config->pixel_multiplier = 2;
if (drm_mode_is_420_only(&connector->display_info, adjusted_mode)) { ret = intel_hdmi_ycbcr420_config(pipe_config, conn_state);
if (!intel_hdmi_ycbcr420_config(pipe_config, conn_state)) { if (ret)
drm_err(&dev_priv->drm, return ret;
"Can't support YCBCR420 output\n");
return -EINVAL;
}
}
pipe_config->limited_color_range = pipe_config->limited_color_range =
intel_hdmi_limited_color_range(pipe_config, conn_state); intel_hdmi_limited_color_range(pipe_config, conn_state);
......
...@@ -403,6 +403,7 @@ static int intel_lvds_compute_config(struct intel_encoder *intel_encoder, ...@@ -403,6 +403,7 @@ static int intel_lvds_compute_config(struct intel_encoder *intel_encoder,
struct drm_display_mode *adjusted_mode = &pipe_config->hw.adjusted_mode; struct drm_display_mode *adjusted_mode = &pipe_config->hw.adjusted_mode;
struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->uapi.crtc); struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->uapi.crtc);
unsigned int lvds_bpp; unsigned int lvds_bpp;
int ret;
/* Should never happen!! */ /* Should never happen!! */
if (INTEL_GEN(dev_priv) < 4 && intel_crtc->pipe == 0) { if (INTEL_GEN(dev_priv) < 4 && intel_crtc->pipe == 0) {
...@@ -436,13 +437,15 @@ static int intel_lvds_compute_config(struct intel_encoder *intel_encoder, ...@@ -436,13 +437,15 @@ static int intel_lvds_compute_config(struct intel_encoder *intel_encoder,
if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN) if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
return -EINVAL; return -EINVAL;
if (HAS_PCH_SPLIT(dev_priv)) { if (HAS_PCH_SPLIT(dev_priv))
pipe_config->has_pch_encoder = true; pipe_config->has_pch_encoder = true;
intel_pch_panel_fitting(pipe_config, conn_state); if (HAS_GMCH(dev_priv))
} else { ret = intel_gmch_panel_fitting(pipe_config, conn_state);
intel_gmch_panel_fitting(pipe_config, conn_state); else
} ret = intel_pch_panel_fitting(pipe_config, conn_state);
if (ret)
return ret;
/* /*
* XXX: It would be nice to support lower refresh rates on the * XXX: It would be nice to support lower refresh rates on the
......
...@@ -176,9 +176,8 @@ intel_panel_vbt_fixed_mode(struct intel_connector *connector) ...@@ -176,9 +176,8 @@ intel_panel_vbt_fixed_mode(struct intel_connector *connector)
} }
/* adjusted_mode has been preset to be the panel's fixed mode */ /* adjusted_mode has been preset to be the panel's fixed mode */
void int intel_pch_panel_fitting(struct intel_crtc_state *crtc_state,
intel_pch_panel_fitting(struct intel_crtc_state *crtc_state, const struct drm_connector_state *conn_state)
const struct drm_connector_state *conn_state)
{ {
const struct drm_display_mode *adjusted_mode = const struct drm_display_mode *adjusted_mode =
&crtc_state->hw.adjusted_mode; &crtc_state->hw.adjusted_mode;
...@@ -188,7 +187,7 @@ intel_pch_panel_fitting(struct intel_crtc_state *crtc_state, ...@@ -188,7 +187,7 @@ intel_pch_panel_fitting(struct intel_crtc_state *crtc_state,
if (adjusted_mode->crtc_hdisplay == crtc_state->pipe_src_w && if (adjusted_mode->crtc_hdisplay == crtc_state->pipe_src_w &&
adjusted_mode->crtc_vdisplay == crtc_state->pipe_src_h && adjusted_mode->crtc_vdisplay == crtc_state->pipe_src_h &&
crtc_state->output_format != INTEL_OUTPUT_FORMAT_YCBCR420) crtc_state->output_format != INTEL_OUTPUT_FORMAT_YCBCR420)
return; return 0;
switch (conn_state->scaling_mode) { switch (conn_state->scaling_mode) {
case DRM_MODE_SCALE_CENTER: case DRM_MODE_SCALE_CENTER:
...@@ -239,12 +238,14 @@ intel_pch_panel_fitting(struct intel_crtc_state *crtc_state, ...@@ -239,12 +238,14 @@ intel_pch_panel_fitting(struct intel_crtc_state *crtc_state,
default: default:
MISSING_CASE(conn_state->scaling_mode); MISSING_CASE(conn_state->scaling_mode);
return; return -EINVAL;
} }
drm_rect_init(&crtc_state->pch_pfit.dst, drm_rect_init(&crtc_state->pch_pfit.dst,
x, y, width, height); x, y, width, height);
crtc_state->pch_pfit.enabled = true; crtc_state->pch_pfit.enabled = true;
return 0;
} }
static void static void
...@@ -381,8 +382,8 @@ static void i9xx_scale_aspect(struct intel_crtc_state *crtc_state, ...@@ -381,8 +382,8 @@ static void i9xx_scale_aspect(struct intel_crtc_state *crtc_state,
} }
} }
void intel_gmch_panel_fitting(struct intel_crtc_state *crtc_state, int intel_gmch_panel_fitting(struct intel_crtc_state *crtc_state,
const struct drm_connector_state *conn_state) const struct drm_connector_state *conn_state)
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
...@@ -431,7 +432,7 @@ void intel_gmch_panel_fitting(struct intel_crtc_state *crtc_state, ...@@ -431,7 +432,7 @@ void intel_gmch_panel_fitting(struct intel_crtc_state *crtc_state,
break; break;
default: default:
MISSING_CASE(conn_state->scaling_mode); MISSING_CASE(conn_state->scaling_mode);
return; return -EINVAL;
} }
/* 965+ wants fuzzy fitting */ /* 965+ wants fuzzy fitting */
...@@ -452,6 +453,8 @@ void intel_gmch_panel_fitting(struct intel_crtc_state *crtc_state, ...@@ -452,6 +453,8 @@ void intel_gmch_panel_fitting(struct intel_crtc_state *crtc_state,
crtc_state->gmch_pfit.control = pfit_control; crtc_state->gmch_pfit.control = pfit_control;
crtc_state->gmch_pfit.pgm_ratios = pfit_pgm_ratios; crtc_state->gmch_pfit.pgm_ratios = pfit_pgm_ratios;
crtc_state->gmch_pfit.lvds_border_bits = border; crtc_state->gmch_pfit.lvds_border_bits = border;
return 0;
} }
/** /**
......
...@@ -25,10 +25,10 @@ int intel_panel_init(struct intel_panel *panel, ...@@ -25,10 +25,10 @@ int intel_panel_init(struct intel_panel *panel,
void intel_panel_fini(struct intel_panel *panel); void intel_panel_fini(struct intel_panel *panel);
void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode, void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
struct drm_display_mode *adjusted_mode); struct drm_display_mode *adjusted_mode);
void intel_pch_panel_fitting(struct intel_crtc_state *crtc_state, int intel_pch_panel_fitting(struct intel_crtc_state *crtc_state,
const struct drm_connector_state *conn_state);
int intel_gmch_panel_fitting(struct intel_crtc_state *crtc_state,
const struct drm_connector_state *conn_state); const struct drm_connector_state *conn_state);
void intel_gmch_panel_fitting(struct intel_crtc_state *crtc_state,
const struct drm_connector_state *conn_state);
void intel_panel_set_backlight_acpi(const struct drm_connector_state *conn_state, void intel_panel_set_backlight_acpi(const struct drm_connector_state *conn_state,
u32 level, u32 max); u32 level, u32 max);
int intel_panel_setup_backlight(struct drm_connector *connector, int intel_panel_setup_backlight(struct drm_connector *connector,
......
...@@ -278,9 +278,11 @@ static int intel_dsi_compute_config(struct intel_encoder *encoder, ...@@ -278,9 +278,11 @@ static int intel_dsi_compute_config(struct intel_encoder *encoder,
intel_fixed_panel_mode(fixed_mode, adjusted_mode); intel_fixed_panel_mode(fixed_mode, adjusted_mode);
if (HAS_GMCH(dev_priv)) if (HAS_GMCH(dev_priv))
intel_gmch_panel_fitting(pipe_config, conn_state); ret = intel_gmch_panel_fitting(pipe_config, conn_state);
else else
intel_pch_panel_fitting(pipe_config, conn_state); ret = intel_pch_panel_fitting(pipe_config, conn_state);
if (ret)
return ret;
} }
if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN) if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
......
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