aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_panel.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2014-11-07 08:19:46 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-11-14 04:29:20 -0500
commit0962c3c9c7d38d938b3b8ca861487b245ffdc150 (patch)
tree820a7dcf19b9221f450ff67ae31f7eed9129ff99 /drivers/gpu/drm/i915/intel_panel.c
parent6517d2734d22b09d3c9dc44fe6879f013a716d19 (diff)
drm/i915: Register the backlight device after the modeset init
Currently we register the backlight device as soon as we register the connector. That means we can get backlight requests from userspace already before reading out the current modeset hardware state. That means we don't yet know the current crtc->encoder->connector mapping, which causes problems for VLV/CHV which need to know the current pipe in order to figure out which BLC registers to poke. Currently we just ignore such requests fairly deep in the backlight code which means the backlight device brightness property will get out of sync with our backlight.level and the actual hardware state. Fix the problem by delaying the backlight device registration until the entire modeset init has been performed. And we also move the backlight unregisteration to happen as the first thing during the modeset cleanup so that we also won't be bothered with userspace backlight requested during teardown. This is a real world problem on machines using systemd, because systemd, for some reason, wants to restore the backlight to the level it used last time. And that happens as soon as it sees the backlight device appearing in the system. Sometimes the userspace access makes it through before the modeset init, sometimes not. v2: Do not lie to the user in the debug prints (Jani) Include connector name in the prints (Jani) Fix a typo in the commit message (Jani) Reviewed-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_panel.c')
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 69bbfbaa4680..708642a9e19b 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -1041,6 +1041,9 @@ static int intel_backlight_device_register(struct intel_connector *connector)
1041 if (WARN_ON(panel->backlight.device)) 1041 if (WARN_ON(panel->backlight.device))
1042 return -ENODEV; 1042 return -ENODEV;
1043 1043
1044 if (!panel->backlight.present)
1045 return 0;
1046
1044 WARN_ON(panel->backlight.max == 0); 1047 WARN_ON(panel->backlight.max == 0);
1045 1048
1046 memset(&props, 0, sizeof(props)); 1049 memset(&props, 0, sizeof(props));
@@ -1076,6 +1079,10 @@ static int intel_backlight_device_register(struct intel_connector *connector)
1076 panel->backlight.device = NULL; 1079 panel->backlight.device = NULL;
1077 return -ENODEV; 1080 return -ENODEV;
1078 } 1081 }
1082
1083 DRM_DEBUG_KMS("Connector %s backlight sysfs interface registered\n",
1084 connector->base.name);
1085
1079 return 0; 1086 return 0;
1080} 1087}
1081 1088
@@ -1302,15 +1309,12 @@ int intel_panel_setup_backlight(struct drm_connector *connector, enum pipe pipe)
1302 return ret; 1309 return ret;
1303 } 1310 }
1304 1311
1305 intel_backlight_device_register(intel_connector);
1306
1307 panel->backlight.present = true; 1312 panel->backlight.present = true;
1308 1313
1309 DRM_DEBUG_KMS("backlight initialized, %s, brightness %u/%u, " 1314 DRM_DEBUG_KMS("Connector %s backlight initialized, %s, brightness %u/%u\n",
1310 "sysfs interface %sregistered\n", 1315 connector->name,
1311 panel->backlight.enabled ? "enabled" : "disabled", 1316 panel->backlight.enabled ? "enabled" : "disabled",
1312 panel->backlight.level, panel->backlight.max, 1317 panel->backlight.level, panel->backlight.max);
1313 panel->backlight.device ? "" : "not ");
1314 1318
1315 return 0; 1319 return 0;
1316} 1320}
@@ -1321,7 +1325,6 @@ void intel_panel_destroy_backlight(struct drm_connector *connector)
1321 struct intel_panel *panel = &intel_connector->panel; 1325 struct intel_panel *panel = &intel_connector->panel;
1322 1326
1323 panel->backlight.present = false; 1327 panel->backlight.present = false;
1324 intel_backlight_device_unregister(intel_connector);
1325} 1328}
1326 1329
1327/* Set up chip specific backlight functions */ 1330/* Set up chip specific backlight functions */
@@ -1384,3 +1387,19 @@ void intel_panel_fini(struct intel_panel *panel)
1384 drm_mode_destroy(intel_connector->base.dev, 1387 drm_mode_destroy(intel_connector->base.dev,
1385 panel->downclock_mode); 1388 panel->downclock_mode);
1386} 1389}
1390
1391void intel_backlight_register(struct drm_device *dev)
1392{
1393 struct intel_connector *connector;
1394
1395 list_for_each_entry(connector, &dev->mode_config.connector_list, base.head)
1396 intel_backlight_device_register(connector);
1397}
1398
1399void intel_backlight_unregister(struct drm_device *dev)
1400{
1401 struct intel_connector *connector;
1402
1403 list_for_each_entry(connector, &dev->mode_config.connector_list, base.head)
1404 intel_backlight_device_unregister(connector);
1405}