3.13 i915 brightness settings broken when going from docked -> undocked (original) (raw)

Jani Nikula jani.nikula at intel.com
Tue Feb 25 00:36:57 PST 2014


On Sun, 23 Feb 2014, Josh Boyer <jwboyer at fedoraproject.org> wrote:

On Thu, Feb 20, 2014 at 07:31:41PM -0500, Josh Boyer wrote:

On Wed, Feb 19, 2014 at 9:20 PM, Josh Boyer <jwboyer at fedoraproject.org> wrote:

Hi All,

We've had a rather weird report[1] of the brightness adjustments being broken in a specific case with Thinkpad x220 hardware (SandyBridge based). If you boot the machine with it in a dock and then undock, the brightness adjustments do not work. That is with either the FN keys or the GNOME brightness slider. I can see that the value of /sys/class/backlight/acpivideo0/brightness increases/decreases but /sys/class/backlight/intelbacklight/brightness doesn't reflect any changes. With 3.12 this works, and oddly with 3.14-rc1 it works (specifically, it starts working around v3.13-10231-g53d8ab2 which is right after the first DRM merge for 3.14). With 3.13, if I undock and echo a higher value in the intelbacklightbrightness sysfs entry, the brightness will actually increase so it can be done manually, but it does not work as you'd expect. I'm in the middle of trying to do a reverse bisect for which patch fixes it in the 3.14-rcX series, but that's taking a while. I thought I'd email and see if anyone already knows about this situation, what patch in 3.13 broke this, and which one then fixed it again. Thus far all I've gathered is that backlight handling is confusing. The reverse bisect between 3.13 and 3.14-rc1 didn't prove fruitful, either because I messed it up or there's a combination of things that fix the issue. So instead I did a regular git bisect between 3.12 and 3.13 to see which commit broke things and caused the above behavior. That landed me at: Author: Jesse Barnes <jbarnes at virtuousgeek.org> Date: Thu Oct 31 18:55:49 2013 +0200 drm/i915: make backlight functions take a connector I have no idea if that makes sense or not, but it's at least something that seems to be in a relevant area of code. Does anyone involved in that know why it would cause the above symptoms on 3.13, and which commit(s) fix it in 3.14-rc1?

This makes perfect sense. The problem with that commit is that the ACPI handler part assumes the output with backlight is on pipe A, which may not be the case. Particularly when booted in the dock.

I presume this can be "fixed" by disabling/enabling the outputs with xrandr after undocking. Also, if you disable the ACPI video backlight handling, userspace should use the native backlight interface (intel_backlight) which is unaffected. Neither of these is the real fix, of course.

Since nobody is replying I poked around a bit myself. The one commit that looks somewhat relevant in 3.14-rc1 seems to be:

commit c91c9f32843a1b433de5a1ead4789a6bc8d3d914 Author: Jani Nikula <jani.nikula at intel.com> Date: Fri Nov 8 16:48:55 2013 +0200 drm/i915: make asle notifications update backlight on all connectors

This is the right fix, but obviously we didn't take your scenario into account at the time (as the commit message still thinks this would only affect baytrail).

That doesn't apply cleanly on 3.13 because of the other reworks that went in first, so I came up with the patch below. It seems to fix it for my machine, but I'm waiting for confirmation from the original bug reporter still. Maybe this will elicit some comments?

Yup, see comments below. ;)

josh

Backport of upstream commit c91c9f328 --- drivers/gpu/drm/i915/i915drv.h | 1 + drivers/gpu/drm/i915/intelopregion.c | 31 ++++++------------------------- drivers/gpu/drm/i915/intelpanel.c | 4 ++++ 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/i915/i915drv.h b/drivers/gpu/drm/i915/i915drv.h index 221ac62..d6d4349 100644 --- a/drivers/gpu/drm/i915/i915drv.h +++ b/drivers/gpu/drm/i915/i915drv.h @@ -1371,6 +1371,7 @@ typedef struct drmi915private { /* backlight */ struct { + bool present; int level; bool enabled; spinlockt lock; /* bl registers and the above bl fields */ diff --git a/drivers/gpu/drm/i915/intelopregion.c b/drivers/gpu/drm/i915/intelopregion.c index 6d69a9b..b2a51ae 100644 --- a/drivers/gpu/drm/i915/intelopregion.c +++ b/drivers/gpu/drm/i915/intelopregion.c @@ -414,38 +414,19 @@ static u32 aslesetbacklight(struct drmdevice *dev, u32 bclp) return ASLCBACKLIGHTFAILED; mutexlock(&dev->modeconfig.mutex); - /* - * Could match the OpRegion connector here instead, but we'd also need - * to verify the connector could handle a backlight call. - */ - listforeachentry(encoder, &dev->modeconfig.encoderlist, head) - if (encoder->crtc == crtc) { - found = true; - break; - } - - if (!found) { - ret = ASLCBACKLIGHTFAILED; - goto out; - } - listforeachentry(connector, &dev->modeconfig.connectorlist, head) - if (connector->encoder == encoder) - intelconnector = tointelconnector(connector); - - if (!intelconnector) { - ret = ASLCBACKLIGHTFAILED; - goto out; + DRMDEBUGKMS("updating opregion backlight %d/255\n", bclp); + listforeachentry(connector, &dev->modeconfig.connectorlist, head) { + intelconnector = tointelconnector(connector); + if (devpriv->backlight.present) + intelpanelsetbacklight(intelconnector, bclp, 255); }

This is not correct because in v3.13 dev_priv->backlight is still driver global, not per connector. This means that if you have at least one connector with backlight control, the backlight is attempted to change on all connectors. In your case, I'm not sure if it leads to anything more than extra adjusting of the same backlight.

If you move the 'bool present' field to intel_connector or intel_panel, I think this is all right.

BR, Jani.

- DRMDEBUGKMS("updating opregion backlight %d/255\n", bclp); - intelpanelsetbacklight(intelconnector, bclp, 255); iowrite32(DIVROUNDUP(bclp * 100, 255) | ASLECBLVVALID, &asle->cblv); -out: mutexunlock(&dev->modeconfig.mutex); - return ret; + return 0; } static u32 aslesetalsillum(struct drmdevice *dev, u32 alsi) diff --git a/drivers/gpu/drm/i915/intelpanel.c b/drivers/gpu/drm/i915/intelpanel.c index e6f782d..fa7b984 100644 --- a/drivers/gpu/drm/i915/intelpanel.c +++ b/drivers/gpu/drm/i915/intelpanel.c @@ -832,6 +832,9 @@ int intelpanelsetupbacklight(struct drmconnector *connector) devpriv->backlight.device = NULL; return -ENODEV; } + + devpriv->backlight.present = true; + return 0; } @@ -839,6 +842,7 @@ void intelpaneldestroybacklight(struct drmdevice *dev) { struct drmi915private *devpriv = dev->devprivate; if (devpriv->backlight.device) { + devpriv->backlight.present = false; backlightdeviceunregister(devpriv->backlight.device); devpriv->backlight.device = NULL; } -- 1.8.5.3

-- Jani Nikula, Intel Open Source Technology Center



More information about the dri-devel mailing list