@@ -27,6 +27,7 @@
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/i2c.h>
+#include <linux/vga_switcheroo.h>
#include <drm/drm_dp_helper.h>
#include <drm/drmP.h>
@@ -239,6 +240,19 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
void *buffer, size_t size)
{
+ struct pci_dev *pdev = to_pci_dev(aux->dev);
+ struct drm_dp_aux *proxy_aux;
+
+ if (aux->connector &&
+ aux->connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+ vga_switcheroo_set_aux(pdev, aux);
+ proxy_aux = vga_switcheroo_get_aux(pdev);
+ if (proxy_aux && proxy_aux != aux) {
+ DRM_DEBUG_KMS("Using vga_switcheroo active client as proxy\n");
+ aux = proxy_aux;
+ }
+ }
+
return drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, buffer,
size);
}
@@ -1379,6 +1379,18 @@ struct edid *drm_get_edid(struct drm_connector *connector,
{
struct edid *edid;
struct pci_dev *pdev = connector->dev->pdev;
+ struct i2c_adapter *proxy_ddc;
+
+ if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
+ connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+ vga_switcheroo_set_ddc(pdev, adapter);
+ proxy_ddc = vga_switcheroo_get_ddc(pdev);
+ if (proxy_ddc && proxy_ddc != adapter) {
+ DRM_DEBUG_KMS("Using vga_switcheroo active client as proxy\n");
+ adapter = proxy_ddc;
+ pdev = to_pci_dev(proxy_ddc->dev.parent);
+ }
+ }
vga_switcheroo_lock_ddc(pdev);