[Intel-gfx] [PATCH 4/4] drm/i915: Changed the return type from 'void', so as to return an error
Ville Syrjälä
ville.syrjala at linux.intel.com
Tue Apr 29 15:33:40 CEST 2014
On Sun, Apr 20, 2014 at 04:22:48PM +0530, akash.goel at intel.com wrote:
> From: Akash Goel <akash.goel at intel.com>
>
> This patch changes the return type of panel fitter configuration
> functions from 'void', so that an error could be returned back to
> User space, either during the modeset time or when the 'border' property
> is being set, if the configuation is not valid.
> This addresses the review comment from Ville, given on the previous patch.
>
> Signed-off-by: Akash Goel <akash.goel at intel.com>
Please reorder the patches so that this patch comes before you add the
manual panel fitting stuff. Otherwise it's hard to evaluate the error
paths in the new code.
> ---
> drivers/gpu/drm/i915/intel_display.c | 5 +++--
> drivers/gpu/drm/i915/intel_dp.c | 15 +++++++++------
> drivers/gpu/drm/i915/intel_drv.h | 6 +++---
> drivers/gpu/drm/i915/intel_lvds.c | 11 ++++++-----
> drivers/gpu/drm/i915/intel_panel.c | 28 ++++++++++++++++------------
> 5 files changed, 37 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 8ff99bf..d7303be 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -10018,9 +10018,10 @@ static int intel_set_mode(struct drm_crtc *crtc,
> return ret;
> }
>
> -void intel_crtc_restore_mode(struct drm_crtc *crtc)
> +int intel_crtc_restore_mode(struct drm_crtc *crtc)
> {
> - intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, crtc->primary->fb);
> + return intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y,
> + crtc->primary->fb);
> }
>
> #undef for_each_intel_crtc_masked
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index b50b170..ad108e2 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -778,12 +778,15 @@ intel_dp_compute_config(struct intel_encoder *encoder,
> if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) {
> intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
> adjusted_mode);
> - if (!HAS_PCH_SPLIT(dev))
> - intel_gmch_panel_fitting(intel_crtc, pipe_config,
> - intel_connector->panel.fitting_mode);
> - else
> - intel_pch_panel_fitting(intel_crtc, pipe_config,
> - intel_connector->panel.fitting_mode);
> + if (!HAS_PCH_SPLIT(dev)) {
> + if (!intel_gmch_panel_fitting(intel_crtc, pipe_config,
> + intel_connector->panel.fitting_mode))
> + return false;
> + } else {
> + if (!intel_pch_panel_fitting(intel_crtc, pipe_config,
> + intel_connector->panel.fitting_mode))
> + return false;
> + }
> }
>
> if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK)
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index f00d075..bed4941 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -704,7 +704,7 @@ void intel_mark_busy(struct drm_device *dev);
> void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
> struct intel_ring_buffer *ring);
> void intel_mark_idle(struct drm_device *dev);
> -void intel_crtc_restore_mode(struct drm_crtc *crtc);
> +int intel_crtc_restore_mode(struct drm_crtc *crtc);
> void intel_crtc_update_dpms(struct drm_crtc *crtc);
> void intel_encoder_destroy(struct drm_encoder *encoder);
> void intel_connector_dpms(struct drm_connector *, int mode);
> @@ -888,10 +888,10 @@ int intel_panel_init(struct intel_panel *panel,
> void intel_panel_fini(struct intel_panel *panel);
> void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
> struct drm_display_mode *adjusted_mode);
> -void intel_pch_panel_fitting(struct intel_crtc *crtc,
> +bool intel_pch_panel_fitting(struct intel_crtc *crtc,
> struct intel_crtc_config *pipe_config,
> int fitting_mode);
> -void intel_gmch_panel_fitting(struct intel_crtc *crtc,
> +bool intel_gmch_panel_fitting(struct intel_crtc *crtc,
> struct intel_crtc_config *pipe_config,
> int fitting_mode);
> void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
> diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
> index 1b1541d..e0ef79d 100644
> --- a/drivers/gpu/drm/i915/intel_lvds.c
> +++ b/drivers/gpu/drm/i915/intel_lvds.c
> @@ -307,12 +307,13 @@ static bool intel_lvds_compute_config(struct intel_encoder *intel_encoder,
> if (HAS_PCH_SPLIT(dev)) {
> pipe_config->has_pch_encoder = true;
>
> - intel_pch_panel_fitting(intel_crtc, pipe_config,
> - intel_connector->panel.fitting_mode);
> + if (!intel_pch_panel_fitting(intel_crtc, pipe_config,
> + intel_connector->panel.fitting_mode))
> + return false;
> } else {
> - intel_gmch_panel_fitting(intel_crtc, pipe_config,
> - intel_connector->panel.fitting_mode);
> -
> + if (!intel_gmch_panel_fitting(intel_crtc, pipe_config,
> + intel_connector->panel.fitting_mode))
> + return false;
> }
>
> /*
> diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> index 3dbb774..748c98c 100644
> --- a/drivers/gpu/drm/i915/intel_panel.c
> +++ b/drivers/gpu/drm/i915/intel_panel.c
> @@ -57,7 +57,7 @@ intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
> drm_mode_set_crtcinfo(adjusted_mode, 0);
> }
>
> -void
> +bool
> intel_pch_manual_panel_fitting(struct intel_crtc *intel_crtc,
> struct intel_crtc_config *pipe_config)
> {
> @@ -89,7 +89,7 @@ intel_pch_manual_panel_fitting(struct intel_crtc *intel_crtc,
>
> if ((dst_width == 0) || (dst_height == 0)) {
> DRM_ERROR("Invalid border size input\n");
> - return;
> + return false;
> }
>
> pf_horizontal_ratio = panel_fitter_scaling(src_width, dst_width);
> @@ -97,10 +97,10 @@ intel_pch_manual_panel_fitting(struct intel_crtc *intel_crtc,
>
> if (pf_horizontal_ratio > MAX_DOWNSCALE_RATIO) {
> DRM_ERROR("width is too small\n");
> - return;
> + return false;
> } else if (pf_vertical_ratio > MAX_DOWNSCALE_RATIO) {
> DRM_ERROR("height is too small\n");
> - return;
> + return false;
> }
>
> x = intel_crtc->border[PANEL_BORDER_LEFT];
> @@ -109,10 +109,11 @@ intel_pch_manual_panel_fitting(struct intel_crtc *intel_crtc,
> pipe_config->pch_pfit.pos = (x << 16) | y;
> pipe_config->pch_pfit.size = (dst_width << 16) | dst_height;
> pipe_config->pch_pfit.enabled = pipe_config->pch_pfit.size != 0;
> + return true;
> }
>
> /* adjusted_mode has been preset to be the panel's fixed mode */
> -void
> +bool
> intel_pch_panel_fitting(struct intel_crtc *intel_crtc,
> struct intel_crtc_config *pipe_config,
> int fitting_mode)
> @@ -180,13 +181,14 @@ intel_pch_panel_fitting(struct intel_crtc *intel_crtc,
>
> default:
> WARN(1, "bad panel fit mode: %d\n", fitting_mode);
> - return;
> + return false;
> }
>
> done:
> pipe_config->pch_pfit.pos = (x << 16) | y;
> pipe_config->pch_pfit.size = (width << 16) | height;
> pipe_config->pch_pfit.enabled = pipe_config->pch_pfit.size != 0;
> + return true;
> }
>
> static void
> @@ -353,7 +355,7 @@ static void i9xx_scale_aspect(struct intel_crtc_config *pipe_config,
> }
> }
>
> -void intel_gmch_manual_panel_fitting(struct intel_crtc *intel_crtc,
> +bool intel_gmch_manual_panel_fitting(struct intel_crtc *intel_crtc,
> struct intel_crtc_config *pipe_config)
> {
> struct drm_device *dev = intel_crtc->base.dev;
> @@ -385,7 +387,7 @@ void intel_gmch_manual_panel_fitting(struct intel_crtc *intel_crtc,
>
> if ((dst_width == 0) || (dst_height == 0)) {
> DRM_ERROR("Invalid border size input\n");
> - return;
> + return false;
> }
>
> pf_horizontal_ratio = panel_fitter_scaling(src_width, dst_width);
> @@ -393,10 +395,10 @@ void intel_gmch_manual_panel_fitting(struct intel_crtc *intel_crtc,
>
> if (pf_horizontal_ratio > MAX_DOWNSCALE_RATIO) {
> DRM_ERROR("width is too small\n");
> - return;
> + return false;
> } else if (pf_vertical_ratio > MAX_DOWNSCALE_RATIO) {
> DRM_ERROR("height is too small\n");
> - return;
> + return false;
> }
>
> if (dst_width != tot_width)
> @@ -430,9 +432,10 @@ void intel_gmch_manual_panel_fitting(struct intel_crtc *intel_crtc,
>
> pipe_config->gmch_pfit.control = pfit_control;
> pipe_config->gmch_pfit.lvds_border_bits = border;
> + return true;
> }
>
> -void intel_gmch_panel_fitting(struct intel_crtc *intel_crtc,
> +bool intel_gmch_panel_fitting(struct intel_crtc *intel_crtc,
> struct intel_crtc_config *pipe_config,
> int fitting_mode)
> {
> @@ -490,7 +493,7 @@ void intel_gmch_panel_fitting(struct intel_crtc *intel_crtc,
> break;
> default:
> WARN(1, "bad panel fit mode: %d\n", fitting_mode);
> - return;
> + return false;
> }
>
> /* 965+ wants fuzzy fitting */
> @@ -512,6 +515,7 @@ out:
> pipe_config->gmch_pfit.control = pfit_control;
> pipe_config->gmch_pfit.pgm_ratios = pfit_pgm_ratios;
> pipe_config->gmch_pfit.lvds_border_bits = border;
> + return true;
> }
>
> static u32 intel_panel_compute_brightness(struct intel_connector *connector,
> --
> 1.9.2
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Ville Syrjälä
Intel OTC
More information about the Intel-gfx
mailing list