All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rajat Jain <rajatja@google.com>
To: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Sean Paul" <sean@poorly.run>, "David Airlie" <airlied@linux.ie>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Jani Nikula" <jani.nikula@linux.intel.com>,
	"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Chris Wilson" <chris@chris-wilson.co.uk>,
	"Imre Deak" <imre.deak@intel.com>,
	"José Roberto de Souza" <jose.souza@intel.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org, gregkh@linuxfoundation.org,
	mathewk@google.com,
	"Daniel Thompson" <daniel.thompson@linaro.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Pavel Machek" <pavel@denx.de>,
	seanpaul@google.com, "Duncan Laurie" <dlaurie@google.com>,
	jsbarnes@google.com, "Thierry Reding" <thierry.reding@gmail.com>
Cc: Rajat Jain <rajatja@google.com>, rajatxjain@gmail.com
Subject: [PATCH v2 2/3] drm/i915: Lookup and attach ACPI device node for connectors
Date: Mon,  4 Nov 2019 11:41:46 -0800	[thread overview]
Message-ID: <20191104194147.185642-2-rajatja@google.com> (raw)
In-Reply-To: <20191104194147.185642-1-rajatja@google.com>

Lookup and attach ACPI nodes for intel connectors. The lookup is done
in compliance with ACPI Spec 6.3
https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
(Ref: Pages 1119 - 1123).

This can be useful for any connector specific platform properties. (This
will be used for privacy screen in next patch).

Signed-off-by: Rajat Jain <rajatja@google.com>
Change-Id: I798e70714a4402554c8cd2a8e58268353f75814f
---
v2: formed by splitting the original patch into ACPI lookup, and privacy
    screen property. Also move it into i915 now that I found existing code
    in i915 that can be re-used.

 drivers/gpu/drm/i915/display/intel_acpi.c     | 50 +++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_acpi.h     |  4 +-
 .../drm/i915/display/intel_display_types.h    |  3 ++
 drivers/gpu/drm/i915/display/intel_dp.c       |  4 ++
 4 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_acpi.c b/drivers/gpu/drm/i915/display/intel_acpi.c
index 748d9b3125dd..0c10516430b1 100644
--- a/drivers/gpu/drm/i915/display/intel_acpi.c
+++ b/drivers/gpu/drm/i915/display/intel_acpi.c
@@ -243,3 +243,53 @@ void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev)
 	}
 	drm_connector_list_iter_end(&conn_iter);
 }
+
+/*
+ * Ref: ACPI Spec 6.3
+ * https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
+ * Pages 1119 - 1123 describe, what I believe, a standard way of
+ * identifying / addressing "display panels" in the ACPI. It provides
+ * a way for the ACPI to define devices for the display panels attached
+ * to the system. It thus provides a way for the BIOS to export any panel
+ * specific properties to the system via ACPI (like device trees).
+ *
+ * The following functions looks up the ACPI node for a connector and returns
+ * it. Technically it is independent from the i915 code, and
+ * ideally may be called for all connectors. It is generally a good idea to
+ * be able to attach an ACPI node to describe anything if needed. (This can
+ * help in future for other panel specific features maybe). However, it
+ * needs an acpi device ID which is build using an index within a particular
+ * type of port (Ref to the pages of spec mentioned above, and to code in
+ * intel_populate_acpi_ids_for_all_connectors()). This device index
+ * unfortunately is not available in DRM code, so currently its call is
+ * originated from i915 driver. If in future this is useful for other drivers
+ * and we can find a generic way of getting a device index, we should move this
+ * function to drm code, maybe.
+ */
+void intel_connector_lookup_acpi_node(struct intel_connector *intel_connector)
+{
+	struct drm_device *drm_dev = intel_connector->base.dev;
+	struct device *dev = &drm_dev->pdev->dev;
+	struct acpi_device *conn_dev;
+	u64 conn_addr;
+
+	/*
+	 * Repopulate ACPI IDs for all connectors is needed because the display
+	 * index may have changed as a result of hotplugging and unplugging
+	 * connectors
+	 */
+	intel_populate_acpi_ids_for_all_connectors(drm_dev);
+
+	/* Build the _ADR to look for */
+	conn_addr = intel_connector->acpi_device_id;
+	conn_addr |= ACPI_DEVICE_ID_SCHEME;
+	conn_addr |= ACPI_BIOS_CAN_DETECT;
+
+	DRM_DEV_INFO(dev, "Looking for connector ACPI node at _ADR=%llX\n",
+		     conn_addr);
+
+	/* Look up the connector device, under the PCI device */
+	conn_dev = acpi_find_child_device(ACPI_COMPANION(dev), conn_addr,
+					  false);
+	intel_connector->acpi_handle = conn_dev ? conn_dev->handle : NULL;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_acpi.h b/drivers/gpu/drm/i915/display/intel_acpi.h
index 8f6d850df6fa..61a4392fac4a 100644
--- a/drivers/gpu/drm/i915/display/intel_acpi.h
+++ b/drivers/gpu/drm/i915/display/intel_acpi.h
@@ -9,14 +9,16 @@
 #include "intel_display_types.h"
 
 #ifdef CONFIG_ACPI
+void intel_connector_lookup_acpi_node(struct intel_connector *connector);
 void intel_register_dsm_handler(void);
 void intel_unregister_dsm_handler(void);
 void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev);
 #else
+static inline void
+intel_connector_lookup_acpi_node(struct intel_connector *connector) { return; }
 static inline void intel_register_dsm_handler(void) { return; }
 static inline void intel_unregister_dsm_handler(void) { return; }
 static inline void
-static inline void
 intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev) { }
 #endif /* CONFIG_ACPI */
 
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 449abaea619f..c2706afc069b 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -400,6 +400,9 @@ struct intel_connector {
 	/* ACPI device id for ACPI and driver cooperation */
 	u32 acpi_device_id;
 
+	/* ACPI handle corresponding to this connector display, if found */
+	void *acpi_handle;
+
 	/* Reads out the current hw, returning true if the connector is enabled
 	 * and active (i.e. dpms ON state). */
 	bool (*get_hw_state)(struct intel_connector *);
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index f865615172a5..4fac408a4299 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -45,6 +45,7 @@
 #include "i915_debugfs.h"
 #include "i915_drv.h"
 #include "i915_trace.h"
+#include "intel_acpi.h"
 #include "intel_atomic.h"
 #include "intel_audio.h"
 #include "intel_connector.h"
@@ -6333,6 +6334,7 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 {
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
 	enum port port = dp_to_dig_port(intel_dp)->base.port;
+	struct intel_connector *intel_connector = to_intel_connector(connector);
 
 	if (!IS_G4X(dev_priv) && port != PORT_A)
 		intel_attach_force_audio_property(connector);
@@ -6354,6 +6356,8 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 
 		connector->state->scaling_mode = DRM_MODE_SCALE_ASPECT;
 
+		/* Lookup the ACPI node corresponding to the connector */
+		intel_connector_lookup_acpi_node(intel_connector);
 	}
 }
 
-- 
2.24.0.rc1.363.gb1bccd3e3d-goog


WARNING: multiple messages have this Message-ID (diff)
From: Rajat Jain <rajatja@google.com>
To: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Sean Paul" <sean@poorly.run>, "David Airlie" <airlied@linux.ie>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Jani Nikula" <jani.nikula@linux.intel.com>,
	"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Chris Wilson" <chris@chris-wilson.co.uk>,
	"Imre Deak" <imre.deak@intel.com>,
	"José Roberto de Souza" <jose.souza@intel.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org, gregkh@linuxfoundation.org,
	mathewk@google.com,
	"Daniel Thompson" <daniel.thompson@linaro.org>,
	"Jonathan Corbet" <corbet@lwn.net>
Cc: Rajat Jain <rajatja@google.com>, rajatxjain@gmail.com
Subject: [PATCH v2 2/3] drm/i915: Lookup and attach ACPI device node for connectors
Date: Mon,  4 Nov 2019 11:41:46 -0800	[thread overview]
Message-ID: <20191104194147.185642-2-rajatja@google.com> (raw)
In-Reply-To: <20191104194147.185642-1-rajatja@google.com>

Lookup and attach ACPI nodes for intel connectors. The lookup is done
in compliance with ACPI Spec 6.3
https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
(Ref: Pages 1119 - 1123).

This can be useful for any connector specific platform properties. (This
will be used for privacy screen in next patch).

Signed-off-by: Rajat Jain <rajatja@google.com>
Change-Id: I798e70714a4402554c8cd2a8e58268353f75814f
---
v2: formed by splitting the original patch into ACPI lookup, and privacy
    screen property. Also move it into i915 now that I found existing code
    in i915 that can be re-used.

 drivers/gpu/drm/i915/display/intel_acpi.c     | 50 +++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_acpi.h     |  4 +-
 .../drm/i915/display/intel_display_types.h    |  3 ++
 drivers/gpu/drm/i915/display/intel_dp.c       |  4 ++
 4 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_acpi.c b/drivers/gpu/drm/i915/display/intel_acpi.c
index 748d9b3125dd..0c10516430b1 100644
--- a/drivers/gpu/drm/i915/display/intel_acpi.c
+++ b/drivers/gpu/drm/i915/display/intel_acpi.c
@@ -243,3 +243,53 @@ void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev)
 	}
 	drm_connector_list_iter_end(&conn_iter);
 }
+
+/*
+ * Ref: ACPI Spec 6.3
+ * https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
+ * Pages 1119 - 1123 describe, what I believe, a standard way of
+ * identifying / addressing "display panels" in the ACPI. It provides
+ * a way for the ACPI to define devices for the display panels attached
+ * to the system. It thus provides a way for the BIOS to export any panel
+ * specific properties to the system via ACPI (like device trees).
+ *
+ * The following functions looks up the ACPI node for a connector and returns
+ * it. Technically it is independent from the i915 code, and
+ * ideally may be called for all connectors. It is generally a good idea to
+ * be able to attach an ACPI node to describe anything if needed. (This can
+ * help in future for other panel specific features maybe). However, it
+ * needs an acpi device ID which is build using an index within a particular
+ * type of port (Ref to the pages of spec mentioned above, and to code in
+ * intel_populate_acpi_ids_for_all_connectors()). This device index
+ * unfortunately is not available in DRM code, so currently its call is
+ * originated from i915 driver. If in future this is useful for other drivers
+ * and we can find a generic way of getting a device index, we should move this
+ * function to drm code, maybe.
+ */
+void intel_connector_lookup_acpi_node(struct intel_connector *intel_connector)
+{
+	struct drm_device *drm_dev = intel_connector->base.dev;
+	struct device *dev = &drm_dev->pdev->dev;
+	struct acpi_device *conn_dev;
+	u64 conn_addr;
+
+	/*
+	 * Repopulate ACPI IDs for all connectors is needed because the display
+	 * index may have changed as a result of hotplugging and unplugging
+	 * connectors
+	 */
+	intel_populate_acpi_ids_for_all_connectors(drm_dev);
+
+	/* Build the _ADR to look for */
+	conn_addr = intel_connector->acpi_device_id;
+	conn_addr |= ACPI_DEVICE_ID_SCHEME;
+	conn_addr |= ACPI_BIOS_CAN_DETECT;
+
+	DRM_DEV_INFO(dev, "Looking for connector ACPI node at _ADR=%llX\n",
+		     conn_addr);
+
+	/* Look up the connector device, under the PCI device */
+	conn_dev = acpi_find_child_device(ACPI_COMPANION(dev), conn_addr,
+					  false);
+	intel_connector->acpi_handle = conn_dev ? conn_dev->handle : NULL;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_acpi.h b/drivers/gpu/drm/i915/display/intel_acpi.h
index 8f6d850df6fa..61a4392fac4a 100644
--- a/drivers/gpu/drm/i915/display/intel_acpi.h
+++ b/drivers/gpu/drm/i915/display/intel_acpi.h
@@ -9,14 +9,16 @@
 #include "intel_display_types.h"
 
 #ifdef CONFIG_ACPI
+void intel_connector_lookup_acpi_node(struct intel_connector *connector);
 void intel_register_dsm_handler(void);
 void intel_unregister_dsm_handler(void);
 void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev);
 #else
+static inline void
+intel_connector_lookup_acpi_node(struct intel_connector *connector) { return; }
 static inline void intel_register_dsm_handler(void) { return; }
 static inline void intel_unregister_dsm_handler(void) { return; }
 static inline void
-static inline void
 intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev) { }
 #endif /* CONFIG_ACPI */
 
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 449abaea619f..c2706afc069b 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -400,6 +400,9 @@ struct intel_connector {
 	/* ACPI device id for ACPI and driver cooperation */
 	u32 acpi_device_id;
 
+	/* ACPI handle corresponding to this connector display, if found */
+	void *acpi_handle;
+
 	/* Reads out the current hw, returning true if the connector is enabled
 	 * and active (i.e. dpms ON state). */
 	bool (*get_hw_state)(struct intel_connector *);
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index f865615172a5..4fac408a4299 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -45,6 +45,7 @@
 #include "i915_debugfs.h"
 #include "i915_drv.h"
 #include "i915_trace.h"
+#include "intel_acpi.h"
 #include "intel_atomic.h"
 #include "intel_audio.h"
 #include "intel_connector.h"
@@ -6333,6 +6334,7 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 {
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
 	enum port port = dp_to_dig_port(intel_dp)->base.port;
+	struct intel_connector *intel_connector = to_intel_connector(connector);
 
 	if (!IS_G4X(dev_priv) && port != PORT_A)
 		intel_attach_force_audio_property(connector);
@@ -6354,6 +6356,8 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 
 		connector->state->scaling_mode = DRM_MODE_SCALE_ASPECT;
 
+		/* Lookup the ACPI node corresponding to the connector */
+		intel_connector_lookup_acpi_node(intel_connector);
 	}
 }
 
-- 
2.24.0.rc1.363.gb1bccd3e3d-goog

WARNING: multiple messages have this Message-ID (diff)
From: Rajat Jain <rajatja@google.com>
To: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Sean Paul" <sean@poorly.run>, "David Airlie" <airlied@linux.ie>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Jani Nikula" <jani.nikula@linux.intel.com>,
	"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Chris Wilson" <chris@chris-wilson.co.uk>,
	"Imre Deak" <imre.deak@intel.com>,
	"José Roberto de Souza" <jose.souza@intel.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org, gregkh@linuxfoundation.org,
	mathewk@google.com,
	"Daniel Thompson" <daniel.thompson@linaro.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Pavel Machek" <pavel@denx.de>,
	seanpaul@google.com, "Duncan Laurie" <dlaurie@google.com>,
	jsbarnes@google.com, "Thierry Reding" <thierry.reding@gmail.com>
Cc: Rajat Jain <rajatja@google.com>, rajatxjain@gmail.com
Subject: [PATCH v2 2/3] drm/i915: Lookup and attach ACPI device node for connectors
Date: Mon,  4 Nov 2019 11:41:46 -0800	[thread overview]
Message-ID: <20191104194147.185642-2-rajatja@google.com> (raw)
Message-ID: <20191104194146.DiPAcM0WngacU1qV6aClB2-7EaLSWf-AbVjrNiKkogI@z> (raw)
In-Reply-To: <20191104194147.185642-1-rajatja@google.com>

Lookup and attach ACPI nodes for intel connectors. The lookup is done
in compliance with ACPI Spec 6.3
https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
(Ref: Pages 1119 - 1123).

This can be useful for any connector specific platform properties. (This
will be used for privacy screen in next patch).

Signed-off-by: Rajat Jain <rajatja@google.com>
Change-Id: I798e70714a4402554c8cd2a8e58268353f75814f
---
v2: formed by splitting the original patch into ACPI lookup, and privacy
    screen property. Also move it into i915 now that I found existing code
    in i915 that can be re-used.

 drivers/gpu/drm/i915/display/intel_acpi.c     | 50 +++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_acpi.h     |  4 +-
 .../drm/i915/display/intel_display_types.h    |  3 ++
 drivers/gpu/drm/i915/display/intel_dp.c       |  4 ++
 4 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_acpi.c b/drivers/gpu/drm/i915/display/intel_acpi.c
index 748d9b3125dd..0c10516430b1 100644
--- a/drivers/gpu/drm/i915/display/intel_acpi.c
+++ b/drivers/gpu/drm/i915/display/intel_acpi.c
@@ -243,3 +243,53 @@ void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev)
 	}
 	drm_connector_list_iter_end(&conn_iter);
 }
+
+/*
+ * Ref: ACPI Spec 6.3
+ * https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
+ * Pages 1119 - 1123 describe, what I believe, a standard way of
+ * identifying / addressing "display panels" in the ACPI. It provides
+ * a way for the ACPI to define devices for the display panels attached
+ * to the system. It thus provides a way for the BIOS to export any panel
+ * specific properties to the system via ACPI (like device trees).
+ *
+ * The following functions looks up the ACPI node for a connector and returns
+ * it. Technically it is independent from the i915 code, and
+ * ideally may be called for all connectors. It is generally a good idea to
+ * be able to attach an ACPI node to describe anything if needed. (This can
+ * help in future for other panel specific features maybe). However, it
+ * needs an acpi device ID which is build using an index within a particular
+ * type of port (Ref to the pages of spec mentioned above, and to code in
+ * intel_populate_acpi_ids_for_all_connectors()). This device index
+ * unfortunately is not available in DRM code, so currently its call is
+ * originated from i915 driver. If in future this is useful for other drivers
+ * and we can find a generic way of getting a device index, we should move this
+ * function to drm code, maybe.
+ */
+void intel_connector_lookup_acpi_node(struct intel_connector *intel_connector)
+{
+	struct drm_device *drm_dev = intel_connector->base.dev;
+	struct device *dev = &drm_dev->pdev->dev;
+	struct acpi_device *conn_dev;
+	u64 conn_addr;
+
+	/*
+	 * Repopulate ACPI IDs for all connectors is needed because the display
+	 * index may have changed as a result of hotplugging and unplugging
+	 * connectors
+	 */
+	intel_populate_acpi_ids_for_all_connectors(drm_dev);
+
+	/* Build the _ADR to look for */
+	conn_addr = intel_connector->acpi_device_id;
+	conn_addr |= ACPI_DEVICE_ID_SCHEME;
+	conn_addr |= ACPI_BIOS_CAN_DETECT;
+
+	DRM_DEV_INFO(dev, "Looking for connector ACPI node at _ADR=%llX\n",
+		     conn_addr);
+
+	/* Look up the connector device, under the PCI device */
+	conn_dev = acpi_find_child_device(ACPI_COMPANION(dev), conn_addr,
+					  false);
+	intel_connector->acpi_handle = conn_dev ? conn_dev->handle : NULL;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_acpi.h b/drivers/gpu/drm/i915/display/intel_acpi.h
index 8f6d850df6fa..61a4392fac4a 100644
--- a/drivers/gpu/drm/i915/display/intel_acpi.h
+++ b/drivers/gpu/drm/i915/display/intel_acpi.h
@@ -9,14 +9,16 @@
 #include "intel_display_types.h"
 
 #ifdef CONFIG_ACPI
+void intel_connector_lookup_acpi_node(struct intel_connector *connector);
 void intel_register_dsm_handler(void);
 void intel_unregister_dsm_handler(void);
 void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev);
 #else
+static inline void
+intel_connector_lookup_acpi_node(struct intel_connector *connector) { return; }
 static inline void intel_register_dsm_handler(void) { return; }
 static inline void intel_unregister_dsm_handler(void) { return; }
 static inline void
-static inline void
 intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev) { }
 #endif /* CONFIG_ACPI */
 
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 449abaea619f..c2706afc069b 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -400,6 +400,9 @@ struct intel_connector {
 	/* ACPI device id for ACPI and driver cooperation */
 	u32 acpi_device_id;
 
+	/* ACPI handle corresponding to this connector display, if found */
+	void *acpi_handle;
+
 	/* Reads out the current hw, returning true if the connector is enabled
 	 * and active (i.e. dpms ON state). */
 	bool (*get_hw_state)(struct intel_connector *);
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index f865615172a5..4fac408a4299 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -45,6 +45,7 @@
 #include "i915_debugfs.h"
 #include "i915_drv.h"
 #include "i915_trace.h"
+#include "intel_acpi.h"
 #include "intel_atomic.h"
 #include "intel_audio.h"
 #include "intel_connector.h"
@@ -6333,6 +6334,7 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 {
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
 	enum port port = dp_to_dig_port(intel_dp)->base.port;
+	struct intel_connector *intel_connector = to_intel_connector(connector);
 
 	if (!IS_G4X(dev_priv) && port != PORT_A)
 		intel_attach_force_audio_property(connector);
@@ -6354,6 +6356,8 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 
 		connector->state->scaling_mode = DRM_MODE_SCALE_ASPECT;
 
+		/* Lookup the ACPI node corresponding to the connector */
+		intel_connector_lookup_acpi_node(intel_connector);
 	}
 }
 
-- 
2.24.0.rc1.363.gb1bccd3e3d-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: Rajat Jain <rajatja@google.com>
To: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Sean Paul" <sean@poorly.run>, "David Airlie" <airlied@linux.ie>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Jani Nikula" <jani.nikula@linux.intel.com>,
	"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Chris Wilson" <chris@chris-wilson.co.uk>,
	"Imre Deak" <imre.deak@intel.com>,
	"José Roberto de Souza" <jose.souza@intel.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org, gregkh@linuxfoundation.org,
	mathewk@google.com,
	"Daniel Thompson" <daniel.thompson@linaro.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Pavel Machek" <pavel@denx.de>,
	seanpaul@google.com, "Duncan Laurie" <dlaurie@google.com>,
	jsbarnes@google.com, "Thierry Reding" <thierry.reding@gmail.com>
Cc: Rajat Jain <rajatja@google.com>, rajatxjain@gmail.com
Subject: [Intel-gfx] [PATCH v2 2/3] drm/i915: Lookup and attach ACPI device node for connectors
Date: Mon,  4 Nov 2019 11:41:46 -0800	[thread overview]
Message-ID: <20191104194147.185642-2-rajatja@google.com> (raw)
Message-ID: <20191104194146.jLsCnTd6fsa_XRmxB_we3xiRDmWuBZ3goIqD37eEP2Y@z> (raw)
In-Reply-To: <20191104194147.185642-1-rajatja@google.com>

Lookup and attach ACPI nodes for intel connectors. The lookup is done
in compliance with ACPI Spec 6.3
https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
(Ref: Pages 1119 - 1123).

This can be useful for any connector specific platform properties. (This
will be used for privacy screen in next patch).

Signed-off-by: Rajat Jain <rajatja@google.com>
Change-Id: I798e70714a4402554c8cd2a8e58268353f75814f
---
v2: formed by splitting the original patch into ACPI lookup, and privacy
    screen property. Also move it into i915 now that I found existing code
    in i915 that can be re-used.

 drivers/gpu/drm/i915/display/intel_acpi.c     | 50 +++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_acpi.h     |  4 +-
 .../drm/i915/display/intel_display_types.h    |  3 ++
 drivers/gpu/drm/i915/display/intel_dp.c       |  4 ++
 4 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_acpi.c b/drivers/gpu/drm/i915/display/intel_acpi.c
index 748d9b3125dd..0c10516430b1 100644
--- a/drivers/gpu/drm/i915/display/intel_acpi.c
+++ b/drivers/gpu/drm/i915/display/intel_acpi.c
@@ -243,3 +243,53 @@ void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev)
 	}
 	drm_connector_list_iter_end(&conn_iter);
 }
+
+/*
+ * Ref: ACPI Spec 6.3
+ * https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
+ * Pages 1119 - 1123 describe, what I believe, a standard way of
+ * identifying / addressing "display panels" in the ACPI. It provides
+ * a way for the ACPI to define devices for the display panels attached
+ * to the system. It thus provides a way for the BIOS to export any panel
+ * specific properties to the system via ACPI (like device trees).
+ *
+ * The following functions looks up the ACPI node for a connector and returns
+ * it. Technically it is independent from the i915 code, and
+ * ideally may be called for all connectors. It is generally a good idea to
+ * be able to attach an ACPI node to describe anything if needed. (This can
+ * help in future for other panel specific features maybe). However, it
+ * needs an acpi device ID which is build using an index within a particular
+ * type of port (Ref to the pages of spec mentioned above, and to code in
+ * intel_populate_acpi_ids_for_all_connectors()). This device index
+ * unfortunately is not available in DRM code, so currently its call is
+ * originated from i915 driver. If in future this is useful for other drivers
+ * and we can find a generic way of getting a device index, we should move this
+ * function to drm code, maybe.
+ */
+void intel_connector_lookup_acpi_node(struct intel_connector *intel_connector)
+{
+	struct drm_device *drm_dev = intel_connector->base.dev;
+	struct device *dev = &drm_dev->pdev->dev;
+	struct acpi_device *conn_dev;
+	u64 conn_addr;
+
+	/*
+	 * Repopulate ACPI IDs for all connectors is needed because the display
+	 * index may have changed as a result of hotplugging and unplugging
+	 * connectors
+	 */
+	intel_populate_acpi_ids_for_all_connectors(drm_dev);
+
+	/* Build the _ADR to look for */
+	conn_addr = intel_connector->acpi_device_id;
+	conn_addr |= ACPI_DEVICE_ID_SCHEME;
+	conn_addr |= ACPI_BIOS_CAN_DETECT;
+
+	DRM_DEV_INFO(dev, "Looking for connector ACPI node at _ADR=%llX\n",
+		     conn_addr);
+
+	/* Look up the connector device, under the PCI device */
+	conn_dev = acpi_find_child_device(ACPI_COMPANION(dev), conn_addr,
+					  false);
+	intel_connector->acpi_handle = conn_dev ? conn_dev->handle : NULL;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_acpi.h b/drivers/gpu/drm/i915/display/intel_acpi.h
index 8f6d850df6fa..61a4392fac4a 100644
--- a/drivers/gpu/drm/i915/display/intel_acpi.h
+++ b/drivers/gpu/drm/i915/display/intel_acpi.h
@@ -9,14 +9,16 @@
 #include "intel_display_types.h"
 
 #ifdef CONFIG_ACPI
+void intel_connector_lookup_acpi_node(struct intel_connector *connector);
 void intel_register_dsm_handler(void);
 void intel_unregister_dsm_handler(void);
 void intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev);
 #else
+static inline void
+intel_connector_lookup_acpi_node(struct intel_connector *connector) { return; }
 static inline void intel_register_dsm_handler(void) { return; }
 static inline void intel_unregister_dsm_handler(void) { return; }
 static inline void
-static inline void
 intel_populate_acpi_ids_for_all_connectors(struct drm_device *drm_dev) { }
 #endif /* CONFIG_ACPI */
 
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 449abaea619f..c2706afc069b 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -400,6 +400,9 @@ struct intel_connector {
 	/* ACPI device id for ACPI and driver cooperation */
 	u32 acpi_device_id;
 
+	/* ACPI handle corresponding to this connector display, if found */
+	void *acpi_handle;
+
 	/* Reads out the current hw, returning true if the connector is enabled
 	 * and active (i.e. dpms ON state). */
 	bool (*get_hw_state)(struct intel_connector *);
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index f865615172a5..4fac408a4299 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -45,6 +45,7 @@
 #include "i915_debugfs.h"
 #include "i915_drv.h"
 #include "i915_trace.h"
+#include "intel_acpi.h"
 #include "intel_atomic.h"
 #include "intel_audio.h"
 #include "intel_connector.h"
@@ -6333,6 +6334,7 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 {
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
 	enum port port = dp_to_dig_port(intel_dp)->base.port;
+	struct intel_connector *intel_connector = to_intel_connector(connector);
 
 	if (!IS_G4X(dev_priv) && port != PORT_A)
 		intel_attach_force_audio_property(connector);
@@ -6354,6 +6356,8 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 
 		connector->state->scaling_mode = DRM_MODE_SCALE_ASPECT;
 
+		/* Lookup the ACPI node corresponding to the connector */
+		intel_connector_lookup_acpi_node(intel_connector);
 	}
 }
 
-- 
2.24.0.rc1.363.gb1bccd3e3d-goog

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-11-04 19:41 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23  0:12 [PATCH] drm: Add support for integrated privacy screens Rajat Jain
2019-10-23  0:12 ` [Intel-gfx] " Rajat Jain
2019-10-23  0:12 ` Rajat Jain
2019-10-23  9:21 ` Daniel Vetter
2019-10-23  9:21   ` [Intel-gfx] " Daniel Vetter
2019-10-23  9:21   ` Daniel Vetter
2019-10-23  9:21   ` Daniel Vetter
2019-10-24  1:48 ` ✗ Fi.CI.BUILD: failure for " Patchwork
2019-10-24  1:48   ` [Intel-gfx] " Patchwork
2019-10-24  7:01   ` Jani Nikula
2019-10-24  7:01     ` [Intel-gfx] " Jani Nikula
2019-10-24 18:18     ` Rajat Jain
2019-10-24 18:18       ` [Intel-gfx] " Rajat Jain
2019-10-24 11:06 ` [PATCH] " Pavel Machek
2019-10-24 11:06   ` [Intel-gfx] " Pavel Machek
2019-10-24 11:06   ` Pavel Machek
2019-10-24 11:06   ` Pavel Machek
2019-10-24 11:20 ` Thierry Reding
2019-10-24 11:20   ` [Intel-gfx] " Thierry Reding
2019-10-24 11:20   ` Thierry Reding
2019-10-24 20:45   ` Rajat Jain
2019-10-24 20:45     ` Rajat Jain
2019-10-24 20:45     ` Rajat Jain
2019-10-25 11:36     ` Thierry Reding
2019-10-25 11:36       ` [Intel-gfx] " Thierry Reding
2019-10-25 11:36       ` Thierry Reding
2019-10-25 19:00       ` Rajat Jain
2019-10-25 19:00         ` [Intel-gfx] " Rajat Jain
2019-10-25 19:00         ` Rajat Jain
2019-10-25 19:00         ` Rajat Jain
2019-10-25 19:03       ` Daniel Vetter
2019-10-25 19:03         ` [Intel-gfx] " Daniel Vetter
2019-10-25 19:03         ` Daniel Vetter
2019-10-25 19:03         ` Daniel Vetter
2019-10-28  8:12         ` Pekka Paalanen
2019-10-28  8:12           ` [Intel-gfx] " Pekka Paalanen
2019-10-28  8:12           ` Pekka Paalanen
2019-10-26 11:07       ` [Intel-gfx] " Daniel Stone
2019-10-26 11:07         ` Daniel Stone
2019-10-26 11:07         ` Daniel Stone
2019-10-26 17:18         ` Daniel Vetter
2019-10-26 17:18           ` Daniel Vetter
2019-10-26 17:18           ` Daniel Vetter
2019-10-24 18:57 ` kbuild test robot
2019-10-24 18:57   ` kbuild test robot
2019-10-24 18:57   ` [Intel-gfx] " kbuild test robot
2019-10-24 18:57   ` kbuild test robot
2019-10-24 18:57   ` kbuild test robot
2019-10-24 19:44 ` kbuild test robot
2019-10-24 19:44   ` kbuild test robot
2019-10-24 19:44   ` [Intel-gfx] " kbuild test robot
2019-10-24 19:44   ` kbuild test robot
2019-10-24 19:44   ` kbuild test robot
2019-11-04 19:41 ` [PATCH v2 1/3] drm/i915: Move the code to populate ACPI device ID into intel_acpi Rajat Jain
2019-11-04 19:41   ` [Intel-gfx] " Rajat Jain
2019-11-04 19:41   ` Rajat Jain
2019-11-04 19:41   ` Rajat Jain
2019-11-04 19:41   ` Rajat Jain [this message]
2019-11-04 19:41     ` [Intel-gfx] [PATCH v2 2/3] drm/i915: Lookup and attach ACPI device node for connectors Rajat Jain
2019-11-04 19:41     ` Rajat Jain
2019-11-04 19:41     ` Rajat Jain
2019-11-20 14:50     ` Jani Nikula
2019-11-20 14:50       ` [Intel-gfx] " Jani Nikula
2019-11-20 14:50       ` Jani Nikula
2019-11-20 14:50       ` Jani Nikula
2019-12-05  9:34       ` Rajat Jain
2019-12-05  9:34         ` [Intel-gfx] " Rajat Jain
2019-12-05  9:34         ` Rajat Jain
2019-11-04 19:41   ` [PATCH v2 3/3] drm/i915: Add support for integrated privacy screens Rajat Jain
2019-11-04 19:41     ` [Intel-gfx] " Rajat Jain
2019-11-04 19:41     ` Rajat Jain
2019-11-04 19:41     ` Rajat Jain
2019-11-12 19:12     ` Rajat Jain
2019-11-12 19:12       ` [Intel-gfx] " Rajat Jain
2019-11-12 19:12       ` Rajat Jain
2019-11-12 19:12     ` Rajat Jain
2019-11-12 19:12       ` [Intel-gfx] " Rajat Jain
2019-11-12 19:12       ` Rajat Jain
2019-11-12 19:12       ` Rajat Jain
2019-11-20 15:10       ` Jani Nikula
2019-11-20 15:10         ` [Intel-gfx] " Jani Nikula
2019-11-20 15:10         ` Jani Nikula
2019-11-20 15:10         ` Jani Nikula
2019-11-20 21:35         ` Rajat Jain
2019-11-20 21:35           ` [Intel-gfx] " Rajat Jain
2019-11-20 21:35           ` Rajat Jain
2019-11-20 21:35           ` Rajat Jain
2019-11-20 15:04     ` Jani Nikula
2019-11-20 15:04       ` [Intel-gfx] " Jani Nikula
2019-11-20 15:04       ` Jani Nikula
2019-11-20 15:04       ` Jani Nikula
2019-12-05  9:34       ` Rajat Jain
2019-12-05  9:34         ` [Intel-gfx] " Rajat Jain
2019-12-05  9:34         ` Rajat Jain
2019-12-20 20:39         ` Rajat Jain
2019-12-20 20:39           ` [Intel-gfx] " Rajat Jain
2019-12-20 20:39           ` Rajat Jain
2019-11-20 14:40   ` [PATCH v2 1/3] drm/i915: Move the code to populate ACPI device ID into intel_acpi Jani Nikula
2019-11-20 14:40     ` [Intel-gfx] " Jani Nikula
2019-11-20 14:40     ` Jani Nikula
2019-11-20 14:40     ` Jani Nikula
2019-12-05  9:34     ` Rajat Jain
2019-12-05  9:34       ` [Intel-gfx] " Rajat Jain
2019-12-05  9:34       ` Rajat Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191104194147.185642-2-rajatja@google.com \
    --to=rajatja@google.com \
    --cc=airlied@linux.ie \
    --cc=chris@chris-wilson.co.uk \
    --cc=corbet@lwn.net \
    --cc=daniel.thompson@linaro.org \
    --cc=daniel@ffwll.ch \
    --cc=dlaurie@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=jose.souza@intel.com \
    --cc=jsbarnes@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mathewk@google.com \
    --cc=mripard@kernel.org \
    --cc=pavel@denx.de \
    --cc=rajatxjain@gmail.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=sean@poorly.run \
    --cc=seanpaul@google.com \
    --cc=thierry.reding@gmail.com \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.