drm/i915: Extract intel_panel_vbt_sdvo_fixed_mode()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 23 Mar 2022 18:29:32 +0000 (20:29 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 29 Mar 2022 13:35:33 +0000 (16:35 +0300)
We have a function for duplicating the VBT LFP mode. Add the same
for the VBT SDVO mode.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220323182935.4701-7-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/display/intel_panel.c
drivers/gpu/drm/i915/display/intel_panel.h
drivers/gpu/drm/i915/display/intel_sdvo.c

index bd606d0..7f59db8 100644 (file)
@@ -272,6 +272,26 @@ intel_panel_vbt_lfp_fixed_mode(struct intel_connector *connector)
        return fixed_mode;
 }
 
+struct drm_display_mode *
+intel_panel_vbt_sdvo_fixed_mode(struct intel_connector *connector)
+{
+       struct drm_i915_private *i915 = to_i915(connector->base.dev);
+       struct drm_display_mode *fixed_mode;
+
+       if (!i915->vbt.sdvo_lvds_vbt_mode)
+               return NULL;
+
+       fixed_mode = drm_mode_duplicate(&i915->drm,
+                                       i915->vbt.sdvo_lvds_vbt_mode);
+       if (!fixed_mode)
+               return NULL;
+
+       /* Guarantee the mode is preferred */
+       fixed_mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
+
+       return fixed_mode;
+}
+
 /* adjusted_mode has been preset to be the panel's fixed mode */
 static int pch_panel_fitting(struct intel_crtc_state *crtc_state,
                             const struct drm_connector_state *conn_state)
index 9704ac8..7e32c90 100644 (file)
@@ -48,5 +48,7 @@ struct drm_display_mode *
 intel_panel_edid_fixed_mode(struct intel_connector *connector);
 struct drm_display_mode *
 intel_panel_vbt_lfp_fixed_mode(struct intel_connector *connector);
+struct drm_display_mode *
+intel_panel_vbt_sdvo_fixed_mode(struct intel_connector *connector);
 
 #endif /* __INTEL_PANEL_H__ */
index a2061b1..27b3d3a 100644 (file)
@@ -2301,16 +2301,10 @@ static int intel_sdvo_get_lvds_modes(struct drm_connector *connector)
         * Fetch modes from VBT. For SDVO prefer the VBT mode since some
         * SDVO->LVDS transcoders can't cope with the EDID mode.
         */
-       if (dev_priv->vbt.sdvo_lvds_vbt_mode != NULL) {
-               newmode = drm_mode_duplicate(connector->dev,
-                                            dev_priv->vbt.sdvo_lvds_vbt_mode);
-               if (newmode != NULL) {
-                       /* Guarantee the mode is preferred */
-                       newmode->type = (DRM_MODE_TYPE_PREFERRED |
-                                        DRM_MODE_TYPE_DRIVER);
-                       drm_mode_probed_add(connector, newmode);
-                       num_modes++;
-               }
+       newmode = intel_panel_vbt_sdvo_fixed_mode(to_intel_connector(connector));
+       if (newmode) {
+               drm_mode_probed_add(connector, newmode);
+               num_modes++;
        }
 
        /*