[Intel-gfx] [PATCH] drm/i915: added i2c symlink to hdmi connector
Oleg Vasilev
oleg.vasilev at intel.com
Fri May 17 16:21:09 UTC 2019
Currently, the i2c adapter was available only under DP connectors.
This patch adds i2c adapter symlink to hdmi connector in order to make
this behaviour consistent.
The initial motivation of this patch was to make igt i2c subtest
patch [1] work on all connectors.
[1]: https://patchwork.freedesktop.org/series/60357/
Signed-off-by: Oleg Vasilev <oleg.vasilev at intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
Cc: Imre Deak <imre.deak at intel.com>
Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
Cc: Jani Nikula <jani.nikula at intel.com>
---
drivers/gpu/drm/i915/intel_hdmi.c | 35 +++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index 2a4086cf2692..b8ae67297878 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -2658,6 +2658,37 @@ static void chv_hdmi_pre_enable(struct intel_encoder *encoder,
chv_phy_release_cl2_override(encoder);
}
+static struct i2c_adapter *
+intel_hdmi_get_i2c_adapter(struct drm_connector *connector)
+{
+ struct intel_encoder *intel_encoder = intel_attached_encoder(connector);
+ struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base);
+ struct drm_device *dev = intel_encoder->base.dev;
+ struct drm_i915_private *dev_priv = to_i915(dev);
+
+ return intel_gmbus_get_adapter(dev_priv, intel_hdmi->ddc_bus);
+}
+
+static void intel_hdmi_create_i2c_symlink(struct drm_connector *connector)
+{
+ struct i2c_adapter *adapter = intel_hdmi_get_i2c_adapter(connector);
+ struct kobject *i2c_kobj = &adapter->dev.kobj;
+ struct kobject *connector_kobj = &connector->kdev->kobj;
+
+ int ret = sysfs_create_link(connector_kobj, i2c_kobj, i2c_kobj->name);
+
+ WARN(ret != 0, "Failed to create i2c symlink\n");
+}
+
+static void intel_hdmi_delete_i2c_symlink(struct drm_connector *connector)
+{
+ struct i2c_adapter *adapter = intel_hdmi_get_i2c_adapter(connector);
+ struct kobject *i2c_kobj = &adapter->dev.kobj;
+ struct kobject *connector_kobj = &connector->kdev->kobj;
+
+ sysfs_remove_link(connector_kobj, i2c_kobj->name);
+}
+
static int
intel_hdmi_connector_register(struct drm_connector *connector)
{
@@ -2669,11 +2700,15 @@ intel_hdmi_connector_register(struct drm_connector *connector)
i915_debugfs_connector_add(connector);
+ intel_hdmi_create_i2c_symlink(connector);
+
return ret;
}
static void intel_hdmi_destroy(struct drm_connector *connector)
{
+ intel_hdmi_delete_i2c_symlink(connector);
+
if (intel_attached_hdmi(connector)->cec_notifier)
cec_notifier_put(intel_attached_hdmi(connector)->cec_notifier);
--
2.21.0
More information about the Intel-gfx
mailing list