Message ID | 20220311172428.14685-8-ville.syrjala@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/i915: DRRS fixes/cleanups and start of static DRRS | expand |
On Fri, 11 Mar 2022, Ville Syrjala <ville.syrjala@linux.intel.com> wrote: > From: Ville Syrjälä <ville.syrjala@linux.intel.com> > > Several connectors want to return the fixed_mode from .get_modes(), > add a helper to do that (and hide the details inside intel_panel.c). > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Nice! Reviewed-by: Jani Nikula <jani.nikula@intel.com> One note below. > --- > drivers/gpu/drm/i915/display/intel_dp.c | 13 ++----------- > drivers/gpu/drm/i915/display/intel_dsi.c | 21 +-------------------- > drivers/gpu/drm/i915/display/intel_dvo.c | 14 +------------- > drivers/gpu/drm/i915/display/intel_lvds.c | 9 +-------- > drivers/gpu/drm/i915/display/intel_panel.c | 18 ++++++++++++++++++ > drivers/gpu/drm/i915/display/intel_panel.h | 1 + > 6 files changed, 24 insertions(+), 52 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c > index 92a2651a71a7..3c97cd5853cc 100644 > --- a/drivers/gpu/drm/i915/display/intel_dp.c > +++ b/drivers/gpu/drm/i915/display/intel_dp.c > @@ -4588,17 +4588,8 @@ static int intel_dp_get_modes(struct drm_connector *connector) > } > > /* Also add fixed mode, which may or may not be present in EDID */ > - if (intel_dp_is_edp(intel_attached_dp(intel_connector)) && > - intel_connector->panel.fixed_mode) { > - struct drm_display_mode *mode; > - > - mode = drm_mode_duplicate(connector->dev, > - intel_connector->panel.fixed_mode); > - if (mode) { > - drm_mode_probed_add(connector, mode); > - num_modes++; > - } > - } > + if (intel_dp_is_edp(intel_attached_dp(intel_connector))) > + num_modes += intel_panel_get_modes(intel_connector); Maybe we could even remove the intel_dp_is_edp() check in the future. It's basically redundant. > > if (num_modes) > return num_modes; > diff --git a/drivers/gpu/drm/i915/display/intel_dsi.c b/drivers/gpu/drm/i915/display/intel_dsi.c > index 37f280b1f179..389a8c24cdc1 100644 > --- a/drivers/gpu/drm/i915/display/intel_dsi.c > +++ b/drivers/gpu/drm/i915/display/intel_dsi.c > @@ -34,26 +34,7 @@ int intel_dsi_tlpx_ns(const struct intel_dsi *intel_dsi) > > int intel_dsi_get_modes(struct drm_connector *connector) > { > - struct drm_i915_private *i915 = to_i915(connector->dev); > - struct intel_connector *intel_connector = to_intel_connector(connector); > - struct drm_display_mode *mode; > - > - drm_dbg_kms(&i915->drm, "\n"); > - > - if (!intel_connector->panel.fixed_mode) { > - drm_dbg_kms(&i915->drm, "no fixed mode\n"); > - return 0; > - } > - > - mode = drm_mode_duplicate(connector->dev, > - intel_connector->panel.fixed_mode); > - if (!mode) { > - drm_dbg_kms(&i915->drm, "drm_mode_duplicate failed\n"); > - return 0; > - } > - > - drm_mode_probed_add(connector, mode); > - return 1; > + return intel_panel_get_modes(to_intel_connector(connector)); > } > > enum drm_mode_status intel_dsi_mode_valid(struct drm_connector *connector, > diff --git a/drivers/gpu/drm/i915/display/intel_dvo.c b/drivers/gpu/drm/i915/display/intel_dvo.c > index 0367e6a1bac7..d4670889d26c 100644 > --- a/drivers/gpu/drm/i915/display/intel_dvo.c > +++ b/drivers/gpu/drm/i915/display/intel_dvo.c > @@ -333,8 +333,6 @@ intel_dvo_detect(struct drm_connector *connector, bool force) > static int intel_dvo_get_modes(struct drm_connector *connector) > { > struct drm_i915_private *dev_priv = to_i915(connector->dev); > - const struct drm_display_mode *fixed_mode = > - to_intel_connector(connector)->panel.fixed_mode; > int num_modes; > > /* > @@ -348,17 +346,7 @@ static int intel_dvo_get_modes(struct drm_connector *connector) > if (num_modes) > return num_modes; > > - if (fixed_mode) { > - struct drm_display_mode *mode; > - > - mode = drm_mode_duplicate(connector->dev, fixed_mode); > - if (mode) { > - drm_mode_probed_add(connector, mode); > - num_modes++; > - } > - } > - > - return num_modes; > + return intel_panel_get_modes(to_intel_connector(connector)); > } > > static const struct drm_connector_funcs intel_dvo_connector_funcs = { > diff --git a/drivers/gpu/drm/i915/display/intel_lvds.c b/drivers/gpu/drm/i915/display/intel_lvds.c > index 3842417e06b0..5449d69fbae5 100644 > --- a/drivers/gpu/drm/i915/display/intel_lvds.c > +++ b/drivers/gpu/drm/i915/display/intel_lvds.c > @@ -476,19 +476,12 @@ static int intel_lvds_compute_config(struct intel_encoder *intel_encoder, > static int intel_lvds_get_modes(struct drm_connector *connector) > { > struct intel_connector *intel_connector = to_intel_connector(connector); > - struct drm_device *dev = connector->dev; > - struct drm_display_mode *mode; > > /* use cached edid if we have one */ > if (!IS_ERR_OR_NULL(intel_connector->edid)) > return drm_add_edid_modes(connector, intel_connector->edid); > > - mode = drm_mode_duplicate(dev, intel_connector->panel.fixed_mode); > - if (mode == NULL) > - return 0; > - > - drm_mode_probed_add(connector, mode); > - return 1; > + return intel_panel_get_modes(intel_connector); > } > > static const struct drm_connector_helper_funcs intel_lvds_connector_helper_funcs = { > diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c > index 3ad246791da5..222328d4e7a1 100644 > --- a/drivers/gpu/drm/i915/display/intel_panel.c > +++ b/drivers/gpu/drm/i915/display/intel_panel.c > @@ -59,6 +59,24 @@ intel_panel_downclock_mode(struct intel_connector *connector, > return connector->panel.downclock_mode; > } > > +int intel_panel_get_modes(struct intel_connector *connector) > +{ > + int num_modes = 0; > + > + if (connector->panel.fixed_mode) { > + struct drm_display_mode *mode; > + > + mode = drm_mode_duplicate(connector->base.dev, > + connector->panel.fixed_mode); > + if (mode) { > + drm_mode_probed_add(&connector->base, mode); > + num_modes++; > + } > + } > + > + return num_modes; > +} > + > int intel_panel_compute_config(struct intel_connector *connector, > struct drm_display_mode *adjusted_mode) > { > diff --git a/drivers/gpu/drm/i915/display/intel_panel.h b/drivers/gpu/drm/i915/display/intel_panel.h > index 7ce7e995853f..051b86450156 100644 > --- a/drivers/gpu/drm/i915/display/intel_panel.h > +++ b/drivers/gpu/drm/i915/display/intel_panel.h > @@ -30,6 +30,7 @@ intel_panel_fixed_mode(struct intel_connector *connector, > const struct drm_display_mode * > intel_panel_downclock_mode(struct intel_connector *connector, > const struct drm_display_mode *adjusted_mode); > +int intel_panel_get_modes(struct intel_connector *connector); > enum drm_mode_status > intel_panel_mode_valid(struct intel_connector *connector, > const struct drm_display_mode *mode);
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index 92a2651a71a7..3c97cd5853cc 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -4588,17 +4588,8 @@ static int intel_dp_get_modes(struct drm_connector *connector) } /* Also add fixed mode, which may or may not be present in EDID */ - if (intel_dp_is_edp(intel_attached_dp(intel_connector)) && - intel_connector->panel.fixed_mode) { - struct drm_display_mode *mode; - - mode = drm_mode_duplicate(connector->dev, - intel_connector->panel.fixed_mode); - if (mode) { - drm_mode_probed_add(connector, mode); - num_modes++; - } - } + if (intel_dp_is_edp(intel_attached_dp(intel_connector))) + num_modes += intel_panel_get_modes(intel_connector); if (num_modes) return num_modes; diff --git a/drivers/gpu/drm/i915/display/intel_dsi.c b/drivers/gpu/drm/i915/display/intel_dsi.c index 37f280b1f179..389a8c24cdc1 100644 --- a/drivers/gpu/drm/i915/display/intel_dsi.c +++ b/drivers/gpu/drm/i915/display/intel_dsi.c @@ -34,26 +34,7 @@ int intel_dsi_tlpx_ns(const struct intel_dsi *intel_dsi) int intel_dsi_get_modes(struct drm_connector *connector) { - struct drm_i915_private *i915 = to_i915(connector->dev); - struct intel_connector *intel_connector = to_intel_connector(connector); - struct drm_display_mode *mode; - - drm_dbg_kms(&i915->drm, "\n"); - - if (!intel_connector->panel.fixed_mode) { - drm_dbg_kms(&i915->drm, "no fixed mode\n"); - return 0; - } - - mode = drm_mode_duplicate(connector->dev, - intel_connector->panel.fixed_mode); - if (!mode) { - drm_dbg_kms(&i915->drm, "drm_mode_duplicate failed\n"); - return 0; - } - - drm_mode_probed_add(connector, mode); - return 1; + return intel_panel_get_modes(to_intel_connector(connector)); } enum drm_mode_status intel_dsi_mode_valid(struct drm_connector *connector, diff --git a/drivers/gpu/drm/i915/display/intel_dvo.c b/drivers/gpu/drm/i915/display/intel_dvo.c index 0367e6a1bac7..d4670889d26c 100644 --- a/drivers/gpu/drm/i915/display/intel_dvo.c +++ b/drivers/gpu/drm/i915/display/intel_dvo.c @@ -333,8 +333,6 @@ intel_dvo_detect(struct drm_connector *connector, bool force) static int intel_dvo_get_modes(struct drm_connector *connector) { struct drm_i915_private *dev_priv = to_i915(connector->dev); - const struct drm_display_mode *fixed_mode = - to_intel_connector(connector)->panel.fixed_mode; int num_modes; /* @@ -348,17 +346,7 @@ static int intel_dvo_get_modes(struct drm_connector *connector) if (num_modes) return num_modes; - if (fixed_mode) { - struct drm_display_mode *mode; - - mode = drm_mode_duplicate(connector->dev, fixed_mode); - if (mode) { - drm_mode_probed_add(connector, mode); - num_modes++; - } - } - - return num_modes; + return intel_panel_get_modes(to_intel_connector(connector)); } static const struct drm_connector_funcs intel_dvo_connector_funcs = { diff --git a/drivers/gpu/drm/i915/display/intel_lvds.c b/drivers/gpu/drm/i915/display/intel_lvds.c index 3842417e06b0..5449d69fbae5 100644 --- a/drivers/gpu/drm/i915/display/intel_lvds.c +++ b/drivers/gpu/drm/i915/display/intel_lvds.c @@ -476,19 +476,12 @@ static int intel_lvds_compute_config(struct intel_encoder *intel_encoder, static int intel_lvds_get_modes(struct drm_connector *connector) { struct intel_connector *intel_connector = to_intel_connector(connector); - struct drm_device *dev = connector->dev; - struct drm_display_mode *mode; /* use cached edid if we have one */ if (!IS_ERR_OR_NULL(intel_connector->edid)) return drm_add_edid_modes(connector, intel_connector->edid); - mode = drm_mode_duplicate(dev, intel_connector->panel.fixed_mode); - if (mode == NULL) - return 0; - - drm_mode_probed_add(connector, mode); - return 1; + return intel_panel_get_modes(intel_connector); } static const struct drm_connector_helper_funcs intel_lvds_connector_helper_funcs = { diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c index 3ad246791da5..222328d4e7a1 100644 --- a/drivers/gpu/drm/i915/display/intel_panel.c +++ b/drivers/gpu/drm/i915/display/intel_panel.c @@ -59,6 +59,24 @@ intel_panel_downclock_mode(struct intel_connector *connector, return connector->panel.downclock_mode; } +int intel_panel_get_modes(struct intel_connector *connector) +{ + int num_modes = 0; + + if (connector->panel.fixed_mode) { + struct drm_display_mode *mode; + + mode = drm_mode_duplicate(connector->base.dev, + connector->panel.fixed_mode); + if (mode) { + drm_mode_probed_add(&connector->base, mode); + num_modes++; + } + } + + return num_modes; +} + int intel_panel_compute_config(struct intel_connector *connector, struct drm_display_mode *adjusted_mode) { diff --git a/drivers/gpu/drm/i915/display/intel_panel.h b/drivers/gpu/drm/i915/display/intel_panel.h index 7ce7e995853f..051b86450156 100644 --- a/drivers/gpu/drm/i915/display/intel_panel.h +++ b/drivers/gpu/drm/i915/display/intel_panel.h @@ -30,6 +30,7 @@ intel_panel_fixed_mode(struct intel_connector *connector, const struct drm_display_mode * intel_panel_downclock_mode(struct intel_connector *connector, const struct drm_display_mode *adjusted_mode); +int intel_panel_get_modes(struct intel_connector *connector); enum drm_mode_status intel_panel_mode_valid(struct intel_connector *connector, const struct drm_display_mode *mode);