[Intel-gfx] [PATCH 08/10] drm/i915: Move the fixed mode to intel_panel

Jesse Barnes jbarnes at virtuousgeek.org
Fri Oct 19 19:09:26 CEST 2012


On Fri, 19 Oct 2012 14:51:50 +0300
Jani Nikula <jani.nikula at intel.com> wrote:

> Pave the way for sharing some logic between eDP and LVDS.
> 
> Based on earlier work by Chris Wilson <chris at chris-wilson.co.uk>
> 
> CC: Chris Wilson <chris at chris-wilson.co.uk>
> Signed-off-by: Jani Nikula <jani.nikula at intel.com>
> ---
>  drivers/gpu/drm/i915/intel_dp.c    |   29 ++++++++++++++++++-----------
>  drivers/gpu/drm/i915/intel_drv.h   |    6 ++++--
>  drivers/gpu/drm/i915/intel_lvds.c  |   36 ++++++++++++++++++------------------
>  drivers/gpu/drm/i915/intel_panel.c |   10 +++++++++-
>  4 files changed, 49 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index abbdfed..8c72477 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -122,9 +122,10 @@ intel_edp_target_clock(struct intel_encoder *intel_encoder,
>  		       struct drm_display_mode *mode)
>  {
>  	struct intel_dp *intel_dp = container_of(intel_encoder, struct intel_dp, base);
> +	struct intel_connector *intel_connector = intel_dp->attached_connector;
>  
> -	if (intel_dp->panel_fixed_mode)
> -		return intel_dp->panel_fixed_mode->clock;
> +	if (intel_connector->panel.fixed_mode)
> +		return intel_connector->panel.fixed_mode->clock;
>  	else
>  		return mode->clock;
>  }
> @@ -228,12 +229,14 @@ intel_dp_mode_valid(struct drm_connector *connector,
>  		    struct drm_display_mode *mode)
>  {
>  	struct intel_dp *intel_dp = intel_attached_dp(connector);
> +	struct intel_connector *intel_connector = to_intel_connector(connector);
> +	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
>  
> -	if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) {
> -		if (mode->hdisplay > intel_dp->panel_fixed_mode->hdisplay)
> +	if (is_edp(intel_dp) && fixed_mode) {
> +		if (mode->hdisplay > fixed_mode->hdisplay)
>  			return MODE_PANEL;
>  
> -		if (mode->vdisplay > intel_dp->panel_fixed_mode->vdisplay)
> +		if (mode->vdisplay > fixed_mode->vdisplay)
>  			return MODE_PANEL;
>  	}
>  
> @@ -700,14 +703,16 @@ intel_dp_mode_fixup(struct drm_encoder *encoder,
>  {
>  	struct drm_device *dev = encoder->dev;
>  	struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
> +	struct intel_connector *intel_connector = intel_dp->attached_connector;
>  	int lane_count, clock;
>  	int max_lane_count = intel_dp_max_lane_count(intel_dp);
>  	int max_clock = intel_dp_max_link_bw(intel_dp) == DP_LINK_BW_2_7 ? 1 : 0;
>  	int bpp, mode_rate;
>  	static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 };
>  
> -	if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) {
> -		intel_fixed_panel_mode(intel_dp->panel_fixed_mode, adjusted_mode);
> +	if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) {
> +		intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
> +				       adjusted_mode);
>  		intel_pch_panel_fitting(dev, DRM_MODE_SCALE_FULLSCREEN,
>  					mode, adjusted_mode);
>  	}
> @@ -2406,6 +2411,7 @@ intel_dp_detect(struct drm_connector *connector, bool force)
>  static int intel_dp_get_modes(struct drm_connector *connector)
>  {
>  	struct intel_dp *intel_dp = intel_attached_dp(connector);
> +	struct intel_connector *intel_connector = to_intel_connector(connector);
>  	struct drm_device *dev = intel_dp->base.base.dev;
>  	int ret;
>  
> @@ -2417,9 +2423,10 @@ static int intel_dp_get_modes(struct drm_connector *connector)
>  		return ret;
>  
>  	/* if eDP has no EDID, fall back to fixed mode */
> -	if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) {
> +	if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) {
>  		struct drm_display_mode *mode;
> -		mode = drm_mode_duplicate(dev, intel_dp->panel_fixed_mode);
> +		mode = drm_mode_duplicate(dev,
> +					  intel_connector->panel.fixed_mode);
>  		if (mode) {
>  			drm_mode_probed_add(connector, mode);
>  			return 1;
> @@ -2638,6 +2645,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
>  		return;
>  	}
>  	intel_encoder = &intel_dp->base;
> +	intel_dp->attached_connector = intel_connector;
>  
>  	if (HAS_PCH_SPLIT(dev) && output_reg == PCH_DP_D)
>  		if (intel_dpd_is_edp(dev))
> @@ -2829,7 +2837,6 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
>  			if (fixed_mode)
>  				fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
>  		}
> -		intel_dp->panel_fixed_mode = fixed_mode;
>  
>  		ironlake_edp_panel_vdd_off(intel_dp, false);
>  	}
> @@ -2837,7 +2844,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
>  	intel_encoder->hot_plug = intel_dp_hot_plug;
>  
>  	if (is_edp(intel_dp)) {
> -		intel_panel_init(&intel_connector->panel);
> +		intel_panel_init(&intel_connector->panel, fixed_mode);
>  		intel_panel_setup_backlight(connector);
>  	}
>  
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index df00f21..ae0467a 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -164,6 +164,7 @@ struct intel_encoder {
>  };
>  
>  struct intel_panel {
> +	struct drm_display_mode *fixed_mode;
>  };
>  
>  struct intel_connector {
> @@ -364,11 +365,11 @@ struct intel_dp {
>  	int panel_power_cycle_delay;
>  	int backlight_on_delay;
>  	int backlight_off_delay;
> -	struct drm_display_mode *panel_fixed_mode;  /* for eDP */
>  	struct delayed_work panel_vdd_work;
>  	bool want_panel_vdd;
>  	struct edid *edid; /* cached EDID for eDP */
>  	int edid_mode_count;
> +	struct intel_connector *attached_connector;
>  };
>  
>  static inline struct drm_crtc *
> @@ -442,7 +443,8 @@ extern void intel_flush_display_plane(struct drm_i915_private *dev_priv,
>  				      enum plane plane);
>  
>  /* intel_panel.c */
> -extern int intel_panel_init(struct intel_panel *panel);
> +extern int intel_panel_init(struct intel_panel *panel,
> +			    struct drm_display_mode *fixed_mode);
>  extern void intel_panel_fini(struct intel_panel *panel);
>  
>  extern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,
> diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
> index db1b1b7..ced6947 100644
> --- a/drivers/gpu/drm/i915/intel_lvds.c
> +++ b/drivers/gpu/drm/i915/intel_lvds.c
> @@ -45,7 +45,6 @@ struct intel_lvds_connector {
>  	struct intel_connector base;
>  
>  	struct notifier_block lid_notifier;
> -	struct drm_display_mode *fixed_mode;
>  	struct edid *edid;
>  	int fitting_mode;
>  };
> @@ -178,8 +177,8 @@ static void intel_disable_lvds(struct intel_encoder *encoder)
>  static int intel_lvds_mode_valid(struct drm_connector *connector,
>  				 struct drm_display_mode *mode)
>  {
> -	struct intel_lvds_connector *lvds_connector = to_lvds_connector(connector);
> -	struct drm_display_mode *fixed_mode = lvds_connector->fixed_mode;
> +	struct intel_connector *intel_connector = to_intel_connector(connector);
> +	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
>  
>  	if (mode->hdisplay > fixed_mode->hdisplay)
>  		return MODE_PANEL;
> @@ -277,7 +276,8 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
>  	 * with the panel scaling set up to source from the H/VDisplay
>  	 * of the original mode.
>  	 */
> -	intel_fixed_panel_mode(lvds_connector->fixed_mode, adjusted_mode);
> +	intel_fixed_panel_mode(lvds_connector->base.panel.fixed_mode,
> +			       adjusted_mode);
>  
>  	if (HAS_PCH_SPLIT(dev)) {
>  		intel_pch_panel_fitting(dev, lvds_connector->fitting_mode,
> @@ -464,7 +464,7 @@ static int intel_lvds_get_modes(struct drm_connector *connector)
>  	if (lvds_connector->edid)
>  		return drm_add_edid_modes(connector, lvds_connector->edid);
>  
> -	mode = drm_mode_duplicate(dev, lvds_connector->fixed_mode);
> +	mode = drm_mode_duplicate(dev, lvds_connector->base.panel.fixed_mode);
>  	if (mode == NULL)
>  		return 0;
>  
> @@ -922,6 +922,7 @@ bool intel_lvds_init(struct drm_device *dev)
>  	struct drm_connector *connector;
>  	struct drm_encoder *encoder;
>  	struct drm_display_mode *scan; /* *modes, *bios_mode; */
> +	struct drm_display_mode *fixed_mode = NULL;
>  	struct drm_crtc *crtc;
>  	u32 lvds;
>  	int pipe;
> @@ -1045,20 +1046,17 @@ bool intel_lvds_init(struct drm_device *dev)
>  
>  	list_for_each_entry(scan, &connector->probed_modes, head) {
>  		if (scan->type & DRM_MODE_TYPE_PREFERRED) {
> -			lvds_connector->fixed_mode = drm_mode_duplicate(dev, scan);
> -			intel_find_lvds_downclock(dev,
> -						  lvds_connector->fixed_mode,
> -						  connector);
> +			fixed_mode = drm_mode_duplicate(dev, scan);
> +			intel_find_lvds_downclock(dev, fixed_mode, connector);
>  			goto out;
>  		}
>  	}
>  
>  	/* Failed to get EDID, what about VBT? */
>  	if (dev_priv->lfp_lvds_vbt_mode) {
> -		lvds_connector->fixed_mode =
> -			drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode);
> -		if (lvds_connector->fixed_mode) {
> -			lvds_connector->fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
> +		fixed_mode = drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode);
> +		if (fixed_mode) {
> +			fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
>  			goto out;
>  		}
>  	}
> @@ -1078,15 +1076,15 @@ bool intel_lvds_init(struct drm_device *dev)
>  	crtc = intel_get_crtc_for_pipe(dev, pipe);
>  
>  	if (crtc && (lvds & LVDS_PORT_EN)) {
> -		lvds_connector->fixed_mode = intel_crtc_mode_get(dev, crtc);
> -		if (lvds_connector->fixed_mode) {
> -			lvds_connector->fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
> +		fixed_mode = intel_crtc_mode_get(dev, crtc);
> +		if (fixed_mode) {
> +			fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
>  			goto out;
>  		}
>  	}
>  
>  	/* If we still don't have a mode after all that, give up. */
> -	if (!lvds_connector->fixed_mode)
> +	if (!fixed_mode)
>  		goto failed;
>  
>  out:
> @@ -1108,7 +1106,7 @@ out:
>  	}
>  	drm_sysfs_connector_add(connector);
>  
> -	intel_panel_init(&intel_connector->panel);
> +	intel_panel_init(&intel_connector->panel, fixed_mode);
>  	intel_panel_setup_backlight(connector);
>  
>  	return true;
> @@ -1117,6 +1115,8 @@ failed:
>  	DRM_DEBUG_KMS("No LVDS modes found, disabling.\n");
>  	drm_connector_cleanup(connector);
>  	drm_encoder_cleanup(encoder);
> +	if (fixed_mode)
> +		drm_mode_destroy(dev, fixed_mode);
>  	kfree(lvds_encoder);
>  	kfree(lvds_connector);
>  	return false;
> diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> index 4c64ebc..e91a0bb 100644
> --- a/drivers/gpu/drm/i915/intel_panel.c
> +++ b/drivers/gpu/drm/i915/intel_panel.c
> @@ -465,11 +465,19 @@ void intel_panel_destroy_backlight(struct drm_device *dev)
>  }
>  #endif
>  
> -int intel_panel_init(struct intel_panel *panel)
> +int intel_panel_init(struct intel_panel *panel,
> +		     struct drm_display_mode *fixed_mode)
>  {
> +	panel->fixed_mode = fixed_mode;
> +
>  	return 0;
>  }
>  
>  void intel_panel_fini(struct intel_panel *panel)
>  {
> +	struct intel_connector *intel_connector =
> +		container_of(panel, struct intel_connector, panel);
> +
> +	if (panel->fixed_mode)
> +		drm_mode_destroy(intel_connector->base.dev, panel->fixed_mode);
>  }

Reviewed-by: Jesse Barnes <jbarnes at virtuousgeek.org>


-- 
Jesse Barnes, Intel Open Source Technology Center



More information about the Intel-gfx mailing list