drm/i915: move VBT based LVDS presence check to intel_bios.c
authorJani Nikula <jani.nikula@intel.com>
Wed, 16 Mar 2016 10:43:30 +0000 (12:43 +0200)
committerJani Nikula <jani.nikula@intel.com>
Wed, 16 Mar 2016 16:28:26 +0000 (18:28 +0200)
Hide knowledge about VBT child devices in intel_bios.c.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1458125015-7931-2-git-send-email-jani.nikula@intel.com
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_bios.c
drivers/gpu/drm/i915/intel_lvds.c

index 3724edda74368fde005581db0cf234c40d70e55a..c3c8663573bca2905ba569b2c50c9d23ada5373a 100644 (file)
@@ -3354,6 +3354,7 @@ extern void intel_i2c_reset(struct drm_device *dev);
 int intel_bios_init(struct drm_i915_private *dev_priv);
 bool intel_bios_is_valid_vbt(const void *buf, size_t size);
 bool intel_bios_is_tv_present(struct drm_i915_private *dev_priv);
+bool intel_bios_is_lvds_present(struct drm_i915_private *dev_priv, u8 *i2c_pin);
 
 /* intel_opregion.c */
 #ifdef CONFIG_ACPI
index d5e6da01adaa733d566ec86d8c1b9386c112928b..4f7eba36a8493c9be707a7b73eab9a2a24c4e8f2 100644 (file)
@@ -1472,3 +1472,53 @@ bool intel_bios_is_tv_present(struct drm_i915_private *dev_priv)
 
        return false;
 }
+
+/**
+ * intel_bios_is_lvds_present - is LVDS present in VBT
+ * @dev_priv:  i915 device instance
+ * @i2c_pin:   i2c pin for LVDS if present
+ *
+ * Return true if LVDS is present. If no child devices were parsed from VBT,
+ * assume LVDS is present.
+ */
+bool intel_bios_is_lvds_present(struct drm_i915_private *dev_priv, u8 *i2c_pin)
+{
+       int i;
+
+       if (!dev_priv->vbt.child_dev_num)
+               return true;
+
+       for (i = 0; i < dev_priv->vbt.child_dev_num; i++) {
+               union child_device_config *uchild = dev_priv->vbt.child_dev + i;
+               struct old_child_dev_config *child = &uchild->old;
+
+               /* If the device type is not LFP, continue.
+                * We have to check both the new identifiers as well as the
+                * old for compatibility with some BIOSes.
+                */
+               if (child->device_type != DEVICE_TYPE_INT_LFP &&
+                   child->device_type != DEVICE_TYPE_LFP)
+                       continue;
+
+               if (intel_gmbus_is_valid_pin(dev_priv, child->i2c_pin))
+                       *i2c_pin = child->i2c_pin;
+
+               /* However, we cannot trust the BIOS writers to populate
+                * the VBT correctly.  Since LVDS requires additional
+                * information from AIM blocks, a non-zero addin offset is
+                * a good indicator that the LVDS is actually present.
+                */
+               if (child->addin_offset)
+                       return true;
+
+               /* But even then some BIOS writers perform some black magic
+                * and instantiate the device without reference to any
+                * additional data.  Trust that if the VBT was written into
+                * the OpRegion then they have validated the LVDS's existence.
+                */
+               if (dev_priv->opregion.vbt)
+                       return true;
+       }
+
+       return false;
+}
index cbd1b0d547ee6692d9030c1d3b4195b4ecf5b548..766ba566fef10c5d2d2d22d653a0ade1a21694b5 100644 (file)
@@ -775,57 +775,6 @@ static const struct dmi_system_id intel_no_lvds[] = {
        { }     /* terminating entry */
 };
 
-/*
- * Enumerate the child dev array parsed from VBT to check whether
- * the LVDS is present.
- * If it is present, return 1.
- * If it is not present, return false.
- * If no child dev is parsed from VBT, it assumes that the LVDS is present.
- */
-static bool lvds_is_present_in_vbt(struct drm_device *dev,
-                                  u8 *i2c_pin)
-{
-       struct drm_i915_private *dev_priv = dev->dev_private;
-       int i;
-
-       if (!dev_priv->vbt.child_dev_num)
-               return true;
-
-       for (i = 0; i < dev_priv->vbt.child_dev_num; i++) {
-               union child_device_config *uchild = dev_priv->vbt.child_dev + i;
-               struct old_child_dev_config *child = &uchild->old;
-
-               /* If the device type is not LFP, continue.
-                * We have to check both the new identifiers as well as the
-                * old for compatibility with some BIOSes.
-                */
-               if (child->device_type != DEVICE_TYPE_INT_LFP &&
-                   child->device_type != DEVICE_TYPE_LFP)
-                       continue;
-
-               if (intel_gmbus_is_valid_pin(dev_priv, child->i2c_pin))
-                       *i2c_pin = child->i2c_pin;
-
-               /* However, we cannot trust the BIOS writers to populate
-                * the VBT correctly.  Since LVDS requires additional
-                * information from AIM blocks, a non-zero addin offset is
-                * a good indicator that the LVDS is actually present.
-                */
-               if (child->addin_offset)
-                       return true;
-
-               /* But even then some BIOS writers perform some black magic
-                * and instantiate the device without reference to any
-                * additional data.  Trust that if the VBT was written into
-                * the OpRegion then they have validated the LVDS's existence.
-                */
-               if (dev_priv->opregion.vbt)
-                       return true;
-       }
-
-       return false;
-}
-
 static int intel_dual_link_lvds_callback(const struct dmi_system_id *id)
 {
        DRM_INFO("Forcing lvds to dual link mode on %s\n", id->ident);
@@ -982,7 +931,7 @@ void intel_lvds_init(struct drm_device *dev)
        }
 
        pin = GMBUS_PIN_PANEL;
-       if (!lvds_is_present_in_vbt(dev, &pin)) {
+       if (!intel_bios_is_lvds_present(dev_priv, &pin)) {
                if ((lvds & LVDS_PORT_EN) == 0) {
                        DRM_DEBUG_KMS("LVDS is not present in VBT\n");
                        return;