[v2,19/22,EXPERIMENTAL] drm: Amend struct drm_dp_aux with connector attribute
diff mbox

Message ID 38d3a35d277771b86e59879c2db25f434e7fbcb2.1439288957.git.lukas@wunner.de
State New
Headers show

Commit Message

Lukas Wunner May 13, 2015, 7:50 p.m. UTC
On dual GPU laptops which cannot switch the AUX channel separately
from the main link and therefore rely on proxying through the
vga_switcheroo active client, we need to restrict this to eDP so
that only communication to the internal panel is proxied and not
to external DP-connected displays which cannot be switched between
GPUs, at least on the retina MacBook Pro. Therefore, amend struct
drm_dp_aux with a pointer to the connector that the AUX channel
belongs to so that we can check the connector type before using

It actually seems more intuitive that the parent of an AUX channel
is a specific connector rather than a device: The device an AUX
channel belongs to can be determined from the connector by following
connector->dev, but the connector an AUX channel belongs to cannot
be unambiguously determined from dev since a device may have multiple
DP connectors. Unfortunately we cannot remove the dev attribute since
the msm driver calls drm_dp_aux_register way before initializing the
connector, and the tegra driver uses a distinct of_device_id for the
AUX channel so that it initializes separately from the connector.
These two drivers set the newly added connector attribute in struct
drm_dp_aux in a delayed fashion, i.e. upon initializing the connector.
They are not known to be used for dual GPU laptops right now but maybe
they will be in the future, so it seems reasonable to set the attribute
in these drivers as well.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=88861
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=61115
Tested-by: Paul Hordiienko <pvt.gord@gmail.com>
    [MBP  6,2 2010  intel ILK + nvidia GT216  pre-retina]
Tested-by: William Brown <william@blackhats.net.au>
    [MBP  8,2 2011  intel SNB + amd turks     pre-retina]
Tested-by: Lukas Wunner <lukas@wunner.de>
    [MBP  9,1 2012  intel IVB + nvidia GK107  pre-retina]
Tested-by: Bruno Bierbaumer <bruno@bierbaumer.net>
    [MBP 11,3 2013  intel HSW + nvidia GK107  retina -- work in progress]

Signed-off-by: Lukas Wunner <lukas@wunner.de>
 drivers/gpu/drm/i915/intel_dp.c             | 1 +
 drivers/gpu/drm/msm/edp/edp_connector.c     | 2 ++
 drivers/gpu/drm/nouveau/nouveau_connector.c | 1 +
 drivers/gpu/drm/radeon/atombios_dp.c        | 1 +
 drivers/gpu/drm/tegra/sor.c                 | 1 +
 include/drm/drm_dp_helper.h                 | 5 +++++
 6 files changed, 11 insertions(+)

diff mbox

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 23aa4ff..2b5a8ae 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1066,6 +1066,7 @@  intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector *connector)
 	intel_dp->aux.name = name;
 	intel_dp->aux.dev = dev->dev;
+	intel_dp->aux.connector = &connector->base;
 	intel_dp->aux.transfer = intel_dp_aux_transfer;
 	DRM_DEBUG_KMS("registering %s bus for %s\n", name,
diff --git a/drivers/gpu/drm/msm/edp/edp_connector.c b/drivers/gpu/drm/msm/edp/edp_connector.c
index b4d1b46..5ca3df9 100644
--- a/drivers/gpu/drm/msm/edp/edp_connector.c
+++ b/drivers/gpu/drm/msm/edp/edp_connector.c
@@ -140,6 +140,8 @@  struct drm_connector *msm_edp_connector_init(struct msm_edp *edp)
 	drm_connector_helper_add(connector, &edp_connector_helper_funcs);
+	edp->ctrl->drm_aux->connector = connector;
 	/* We don't support HPD, so only poll status until connected. */
 	connector->polled = DRM_CONNECTOR_POLL_CONNECT;
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index ad59eab..1e5224f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -1149,6 +1149,7 @@  nouveau_connector_create(struct drm_device *dev, int index)
 	case DRM_MODE_CONNECTOR_DisplayPort:
 		nv_connector->aux.dev = dev->dev;
+		nv_connector->aux.connector = connector;
 		nv_connector->aux.transfer = nouveau_connector_aux_xfer;
 		ret = drm_dp_aux_register(&nv_connector->aux);
 		if (ret) {
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index f81e0d7..495e035 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -232,6 +232,7 @@  void radeon_dp_aux_init(struct radeon_connector *radeon_connector)
 	radeon_connector->ddc_bus->rec.hpd = radeon_connector->hpd.hpd;
 	radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev;
+	radeon_connector->ddc_bus->aux.connector = &radeon_connector->base;
 	if (ASIC_IS_DCE5(rdev)) {
 		if (radeon_auxch)
 			radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer_native;
diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
index 7591d89..372a05f 100644
--- a/drivers/gpu/drm/tegra/sor.c
+++ b/drivers/gpu/drm/tegra/sor.c
@@ -1480,6 +1480,7 @@  static int tegra_sor_init(struct host1x_client *client)
 	sor->output.connector.dpms = DRM_MODE_DPMS_OFF;
+	sor->dpaux->aux->connector = &sor->output.connector;
 	drm_encoder_init(drm, &sor->output.encoder, &tegra_sor_encoder_funcs,
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 2e86f64..c8e693e 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -658,6 +658,7 @@  struct drm_dp_aux_msg {
  * @name: user-visible name of this AUX channel and the I2C-over-AUX adapter
  * @ddc: I2C adapter that can be used for I2C-over-AUX communication
  * @dev: pointer to struct device that is the parent for this AUX channel
+ * @connector: pointer to connector that is the parent for this AUX channel
  * @hw_mutex: internal mutex used for locking transfers
  * @transfer: transfers a message representing a single AUX transaction
@@ -667,6 +668,9 @@  struct drm_dp_aux_msg {
  * The .name field may be used to specify the name of the I2C adapter. If set to
  * NULL, dev_name() of .dev will be used.
+ * The .connector field should be set to a pointer to the connector that
+ * the AUX channel belongs to.
+ *
  * Drivers provide a hardware-specific implementation of how transactions
  * are executed via the .transfer() function. A pointer to a drm_dp_aux_msg
  * structure describing the transaction is passed into this function. Upon
@@ -694,6 +698,7 @@  struct drm_dp_aux {
 	const char *name;
 	struct i2c_adapter ddc;
 	struct device *dev;
+	struct drm_connector *connector;
 	struct mutex hw_mutex;
 	ssize_t (*transfer)(struct drm_dp_aux *aux,
 			    struct drm_dp_aux_msg *msg);