drm/i915: Move backlight registration to connector registration
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 24 Jun 2016 13:00:15 +0000 (14:00 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 24 Jun 2016 13:43:14 +0000 (14:43 +0100)
Currently the backlight is being registered in the load phase (before
the display and its objects are registered). Move the backlight
registration into the analogous phase by performing it from the
connector registration, just after its creation.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1466773227-7994-3-git-send-email-chris@chris-wilson.co.uk
13 files changed:
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_crt.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_dp_mst.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_dsi.c
drivers/gpu/drm/i915/intel_dvo.c
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/i915/intel_lvds.c
drivers/gpu/drm/i915/intel_panel.c
drivers/gpu/drm/i915/intel_sdvo.c
drivers/gpu/drm/i915/intel_tv.c

index 6d96b14b53c859b2d232aaeb303bb470f270d440..42298a87db7e75865e7f1e53cd4baa2fb3223d94 100644 (file)
@@ -3734,6 +3734,7 @@ extern void intel_modeset_init_hw(struct drm_device *dev);
 extern void intel_modeset_init(struct drm_device *dev);
 extern void intel_modeset_gem_init(struct drm_device *dev);
 extern void intel_modeset_cleanup(struct drm_device *dev);
+extern int intel_connector_register(struct drm_connector *);
 extern void intel_connector_unregister(struct drm_connector *);
 extern int intel_modeset_vga_set_state(struct drm_device *dev, bool state);
 extern void intel_display_resume(struct drm_device *dev);
index e115bcc6766fed43752d5de420cc8c14cf18eb9c..8d7d48c74751da64633461108fe07e37113338a8 100644 (file)
@@ -743,6 +743,7 @@ static const struct drm_connector_funcs intel_crt_connector_funcs = {
        .dpms = drm_atomic_helper_connector_dpms,
        .detect = intel_crt_detect,
        .fill_modes = drm_helper_probe_single_connector_modes,
+       .late_register = intel_connector_register,
        .early_unregister = intel_connector_unregister,
        .destroy = intel_crt_destroy,
        .set_property = intel_crt_set_property,
index 1141b8699dbeeabc9848fa0df0d9967c0d8c941b..12897d11df60fa45c9da859e8e5e44605681ba8d 100644 (file)
@@ -16314,8 +16314,21 @@ void intel_modeset_gem_init(struct drm_device *dev)
                        c->state->plane_mask &= ~(1 << drm_plane_index(c->primary));
                }
        }
+}
+
+int intel_connector_register(struct drm_connector *connector)
+{
+       struct intel_connector *intel_connector = to_intel_connector(connector);
+       int ret;
+
+       ret = intel_backlight_device_register(intel_connector);
+       if (ret)
+               goto err;
+
+       return 0;
 
-       intel_backlight_register(dev);
+err:
+       return ret;
 }
 
 void intel_connector_unregister(struct drm_connector *connector)
index d4e037e20fa10865a40cb864d2aa65bcaeaf5295..30d410173816a2400e5f23b7ff599d5693eaa87c 100644 (file)
@@ -4507,6 +4507,11 @@ static int
 intel_dp_connector_register(struct drm_connector *connector)
 {
        struct intel_dp *intel_dp = intel_attached_dp(connector);
+       int ret;
+
+       ret = intel_connector_register(connector);
+       if (ret)
+               return ret;
 
        i915_debugfs_connector_add(connector);
 
index 89e7c98f5693059ffeac7e08954b092f5d8b8870..5f88e12575acefe9978f5dcb536b82ea7aa41410 100644 (file)
@@ -336,6 +336,7 @@ static const struct drm_connector_funcs intel_dp_mst_connector_funcs = {
        .fill_modes = drm_helper_probe_single_connector_modes,
        .set_property = intel_dp_mst_set_property,
        .atomic_get_property = intel_connector_atomic_get_property,
+       .late_register = intel_connector_register,
        .early_unregister = intel_connector_unregister,
        .destroy = intel_dp_mst_connector_destroy,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
index ca2de043b9ced2668a944ed4e9129ab008c80a81..3156d8df7921fb3bf2eb879170913d30d2dd728c 100644 (file)
@@ -1506,11 +1506,15 @@ extern struct drm_display_mode *intel_find_panel_downclock(
                                struct drm_device *dev,
                                struct drm_display_mode *fixed_mode,
                                struct drm_connector *connector);
-void intel_backlight_register(struct drm_device *dev);
 
 #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
+int intel_backlight_device_register(struct intel_connector *connector);
 void intel_backlight_device_unregister(struct intel_connector *connector);
 #else /* CONFIG_BACKLIGHT_CLASS_DEVICE */
+static int intel_backlight_device_register(struct intel_connector *connector)
+{
+       return 0;
+}
 static inline void intel_backlight_device_unregister(struct intel_connector *connector)
 {
 }
index ae2dcaf1b52e8dd1edc1def38ab3daefb5451788..80cc0f9de6c99065f88b93b4ff1a328d5e1ef898 100644 (file)
@@ -1390,6 +1390,7 @@ static const struct drm_connector_helper_funcs intel_dsi_connector_helper_funcs
 static const struct drm_connector_funcs intel_dsi_connector_funcs = {
        .dpms = drm_atomic_helper_connector_dpms,
        .detect = intel_dsi_detect,
+       .late_register = intel_connector_register,
        .early_unregister = intel_connector_unregister,
        .destroy = intel_dsi_connector_destroy,
        .fill_modes = drm_helper_probe_single_connector_modes,
index 60e4ddf2ec6d2efe80f8894e9d7ac94467d02ae5..669eae46ffa940b9cfa0a4163a29ec494f4bac0f 100644 (file)
@@ -341,6 +341,7 @@ static void intel_dvo_destroy(struct drm_connector *connector)
 static const struct drm_connector_funcs intel_dvo_connector_funcs = {
        .dpms = drm_atomic_helper_connector_dpms,
        .detect = intel_dvo_detect,
+       .late_register = intel_connector_register,
        .early_unregister = intel_connector_unregister,
        .destroy = intel_dvo_destroy,
        .fill_modes = drm_helper_probe_single_connector_modes,
index fb21626ada645dbb0e594e162d6b6cc308fa9ebe..48ca48c9faff96d19f59b5fce43a7a27394b8a12 100644 (file)
@@ -1774,6 +1774,7 @@ static const struct drm_connector_funcs intel_hdmi_connector_funcs = {
        .fill_modes = drm_helper_probe_single_connector_modes,
        .set_property = intel_hdmi_set_property,
        .atomic_get_property = intel_connector_atomic_get_property,
+       .late_register = intel_connector_register,
        .early_unregister = intel_connector_unregister,
        .destroy = intel_hdmi_destroy,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
index 6306c5499587812c08a318b5b8396ab2efad88cb..d4d06fb8de2e1796f016d774fb08fcd522de12f3 100644 (file)
@@ -555,6 +555,7 @@ static const struct drm_connector_funcs intel_lvds_connector_funcs = {
        .fill_modes = drm_helper_probe_single_connector_modes,
        .set_property = intel_lvds_set_property,
        .atomic_get_property = intel_connector_atomic_get_property,
+       .late_register = intel_connector_register,
        .early_unregister = intel_connector_unregister,
        .destroy = intel_lvds_destroy,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
index bf721781c259d0e1ba716335680b46f92a28b7c1..3c0b97f0bfae58037aa7cca28a1752d2d3d7a775 100644 (file)
@@ -1163,7 +1163,7 @@ static const struct backlight_ops intel_backlight_device_ops = {
        .get_brightness = intel_backlight_device_get_brightness,
 };
 
-static int intel_backlight_device_register(struct intel_connector *connector)
+int intel_backlight_device_register(struct intel_connector *connector)
 {
        struct intel_panel *panel = &connector->panel;
        struct backlight_properties props;
@@ -1225,11 +1225,6 @@ void intel_backlight_device_unregister(struct intel_connector *connector)
                panel->backlight.device = NULL;
        }
 }
-#else /* CONFIG_BACKLIGHT_CLASS_DEVICE */
-static int intel_backlight_device_register(struct intel_connector *connector)
-{
-       return 0;
-}
 #endif /* CONFIG_BACKLIGHT_CLASS_DEVICE */
 
 /*
@@ -1809,11 +1804,3 @@ void intel_panel_fini(struct intel_panel *panel)
                drm_mode_destroy(intel_connector->base.dev,
                                panel->downclock_mode);
 }
-
-void intel_backlight_register(struct drm_device *dev)
-{
-       struct intel_connector *connector;
-
-       for_each_intel_connector(dev, connector)
-               intel_backlight_device_register(connector);
-}
index 580cc876a90fd6d78393415c4f9556b02390d963..c0c0a65fabf3dc95089bcf15b6f7b5d9126bb147 100644 (file)
@@ -2181,6 +2181,11 @@ static int
 intel_sdvo_connector_register(struct drm_connector *connector)
 {
        struct intel_sdvo *sdvo = intel_attached_sdvo(connector);
+       int ret;
+
+       ret = intel_connector_register(connector);
+       if (ret)
+               return ret;
 
        return sysfs_create_link(&connector->kdev->kobj,
                                 &sdvo->ddc.dev.kobj,
index 4ce70a9f9df2daa92e2704c13eef4e91b94426ef..83fe6706a1885917853c7a59ac60e92028bbc7ed 100644 (file)
@@ -1501,6 +1501,7 @@ out:
 static const struct drm_connector_funcs intel_tv_connector_funcs = {
        .dpms = drm_atomic_helper_connector_dpms,
        .detect = intel_tv_detect,
+       .late_register = intel_connector_register,
        .early_unregister = intel_connector_unregister,
        .destroy = intel_tv_destroy,
        .set_property = intel_tv_set_property,