Merge tag 'drm-misc-next-2018-11-07' of git://anongit.freedesktop.org/drm/drm-misc...
[sfrench/cifs-2.6.git] / drivers / gpu / drm / drm_connector.c
index 1e40e5decbe91a4f709305d5259b5b7c0425e617..aa18b1d7d3e4df837de8561ae10322d31ff5159c 100644 (file)
@@ -260,9 +260,7 @@ int drm_connector_init(struct drm_device *dev,
 
        if (connector_type != DRM_MODE_CONNECTOR_VIRTUAL &&
            connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
-               drm_object_attach_property(&connector->base,
-                                             config->edid_property,
-                                             0);
+               drm_connector_attach_edid_property(connector);
 
        drm_object_attach_property(&connector->base,
                                      config->dpms_property, 0);
@@ -294,6 +292,24 @@ out_put:
 }
 EXPORT_SYMBOL(drm_connector_init);
 
+/**
+ * drm_connector_attach_edid_property - attach edid property.
+ * @connector: the connector
+ *
+ * Some connector types like DRM_MODE_CONNECTOR_VIRTUAL do not get a
+ * edid property attached by default.  This function can be used to
+ * explicitly enable the edid property in these cases.
+ */
+void drm_connector_attach_edid_property(struct drm_connector *connector)
+{
+       struct drm_mode_config *config = &connector->dev->mode_config;
+
+       drm_object_attach_property(&connector->base,
+                                  config->edid_property,
+                                  0);
+}
+EXPORT_SYMBOL(drm_connector_attach_edid_property);
+
 /**
  * drm_connector_attach_encoder - attach a connector to an encoder
  * @connector: connector to attach
@@ -379,7 +395,8 @@ void drm_connector_cleanup(struct drm_connector *connector)
        /* The connector should have been removed from userspace long before
         * it is finally destroyed.
         */
-       if (WARN_ON(connector->registered))
+       if (WARN_ON(connector->registration_state ==
+                   DRM_CONNECTOR_REGISTERED))
                drm_connector_unregister(connector);
 
        if (connector->tile_group) {
@@ -436,7 +453,7 @@ int drm_connector_register(struct drm_connector *connector)
                return 0;
 
        mutex_lock(&connector->mutex);
-       if (connector->registered)
+       if (connector->registration_state != DRM_CONNECTOR_INITIALIZING)
                goto unlock;
 
        ret = drm_sysfs_connector_add(connector);
@@ -456,7 +473,7 @@ int drm_connector_register(struct drm_connector *connector)
 
        drm_mode_object_register(connector->dev, &connector->base);
 
-       connector->registered = true;
+       connector->registration_state = DRM_CONNECTOR_REGISTERED;
        goto unlock;
 
 err_debugfs:
@@ -478,7 +495,7 @@ EXPORT_SYMBOL(drm_connector_register);
 void drm_connector_unregister(struct drm_connector *connector)
 {
        mutex_lock(&connector->mutex);
-       if (!connector->registered) {
+       if (connector->registration_state != DRM_CONNECTOR_REGISTERED) {
                mutex_unlock(&connector->mutex);
                return;
        }
@@ -489,7 +506,7 @@ void drm_connector_unregister(struct drm_connector *connector)
        drm_sysfs_connector_remove(connector);
        drm_debugfs_connector_remove(connector);
 
-       connector->registered = false;
+       connector->registration_state = DRM_CONNECTOR_UNREGISTERED;
        mutex_unlock(&connector->mutex);
 }
 EXPORT_SYMBOL(drm_connector_unregister);