@@ -27,6 +27,7 @@
#include <acpi/button.h>
#include <linux/pm_runtime.h>
+#include <linux/vga_switcheroo.h>
#include <drm/drmP.h>
#include <drm/drm_edid.h>
@@ -148,7 +149,13 @@ nouveau_connector_ddc_detect(struct drm_connector *connector)
break;
} else
if (nv_encoder->i2c) {
- if (nvkm_probe_i2c(nv_encoder->i2c, 0x50))
+ int ret;
+ if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS)
+ vga_switcheroo_lock_ddc(dev->pdev);
+ ret = nvkm_probe_i2c(nv_encoder->i2c, 0x50);
+ if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS)
+ vga_switcheroo_unlock_ddc();
+ if (ret)
break;
}
}
@@ -259,7 +266,9 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
nv_encoder = nouveau_connector_ddc_detect(connector);
if (nv_encoder && (i2c = nv_encoder->i2c) != NULL) {
- nv_connector->edid = drm_get_edid(connector, i2c);
+ nv_connector->edid = nv_encoder->dcb->type == DCB_OUTPUT_LVDS ?
+ drm_get_edid_switcheroo(connector, i2c) :
+ drm_get_edid(connector, i2c);
drm_mode_connector_update_edid_property(connector,
nv_connector->edid);
if (!nv_connector->edid) {