GalliumOS / galliumos-distro

Docs, issues, and artwork sources for GalliumOS
https://galliumos.org/
GNU General Public License v2.0
347 stars 11 forks source link

Dell chromebook 13 ( LULU) screen brightness issue #241

Closed titonbarua closed 7 years ago

titonbarua commented 8 years ago

Issue:

Screen brightness adjustment does not work. The brightness keys work as intended. The notification of screen brightness also change as usual. But no actual change takes place. Brightness slider on the panel plugin was also useless. I've done some research regarding it. I think the problem might be related to permission issues of xfpm-power-backlight-helper program.

xfpm-power-backlight-helper works perfectly

Trying to execute pkexec xfpm-power-backlight-helper --set-brightness 500 displays policykit permission dialogue, which does indeed change brightness after authorization.

Brightness can be increased by directly messing in sysfs

Brightness can be controlled by directly writing to /sys/class/backlight/intel_backlight/. I've written a small python3 script which can be used to change brightness. The source code is available at the bottom(in case it helps anyone).

Hardware:

Contents of my /etc/lsb-release:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=15.04
DISTRIB_CODENAME=vivid
DISTRIB_DESCRIPTION="GalliumOS 1.0"

xfce4-power-manager package version

1.4.3-0ubuntu1-galliumos14

Custom brightness control script

This must be run as root. Also, python3 must be installed.

#!/usr/bin/env python3
import sys

STEP_PERCENT = 0.1
BRIGHTNESS_FILE = "/sys/class/backlight/intel_backlight/brightness"
MAX_BRIGHTNESS_FILE = "/sys/class/backlight/intel_backlight/max_brightness"

min_b = 1
with open(MAX_BRIGHTNESS_FILE) as f:
    max_b = int(f.read())

with open(BRIGHTNESS_FILE) as f:
    current_b = int(f.read())

USAGE = """\
Usage: {prog} inc | dec| set <percent>
Description: Adjusts brightness on Dell chromebook 13.
Example:
    # Increment brightness by 10%:
    {prog} inc 

    # Decrement brightness by 10%:
    {prog} dec

    # Set brightness to 50%:
    {prog} set 50
"""

def print_usage():
    print(USAGE.format(prog=sys.argv[0]))

if len(sys.argv) > 1:
    cmd = sys.argv[1]
    if cmd == 'inc':
        step = STEP_PERCENT * max_b
        target_b = int(min(max_b, current_b + step))

    elif cmd == 'dec':
        step = STEP_PERCENT * max_b
        target_b = int(max(min_b, current_b - step))

    elif cmd == 'set':
        try:
            val_percent = abs(float(sys.argv[2]) / 100)
            target_b = int(min(max_b, max(1, val_percent * max_b)))
        except (KeyError, ValueError, TypeError):
            print(USAGE)
            sys.exit(1)
    else:
        print(USAGE)
        sys.exit(1)

    with open(BRIGHTNESS_FILE, 'w') as f:
        f.write("{}\n".format(target_b))
else:
    print(USAGE)
    sys.exit(1)
titonbarua commented 8 years ago

Also, the policykit action file found in /usr/share/polkit-1/actions/org.xfce.power.policy:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>

  <vendor>XFCE Power Manager</vendor>
  <vendor_url>http://goodies.xfce.org/projects/applications/xfce4-power-manager</vendor_url>
  <icon_name>battery</icon_name>

  <action id="org.xfce.power.backlight-helper">

    <description>Modify the laptop display brightness</description>
    <message>Authentication is required to modify the laptop display brightness</message>
    <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/sbin/xfpm-power-backlight-helper</annotate>
  </action>

  <action id="org.xfce.power.xfce4-pm-helper">

    <description>Suspend or hibernate the system</description>
    <message>Authentication is required to place the system in suspend or hibernate mode</message>
    <defaults>
      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/sbin/xfce4-pm-helper</annotate>
  </action>

</policyconfig>
reynhout commented 8 years ago

Previous discussion: #148, #176. I think @coolstar had said it was a bug in his firmware which he intended to fix, but I guess he can't fix it without compromising Windows compatibility..?

We don't have confirmation yet that the workaround for CoolStar firmware on Broadwell work fine/don't interfere with factory/other firmware on Broadwell, but we do know that the workaround causes problems for all firmware on Haswell. So we're waiting for data before deciding how to proceed.

titonbarua commented 8 years ago

Thank you @reynhout . I should have searched harder in the existing issues.

reynhout commented 8 years ago

@titonbarua There's good info in the other issues, but your investigation is very helpful too. We didn't know whether the problem was possible to work around in the OS (vs kernel params or firmware)...but you've demonstrated that it is, which is awesome. Not sure what the eventual solution will be, but it definitely opens up possibilities. So thank you! :)

titonbarua commented 8 years ago

@reynhout , i feel honored! :)

Finally, I've tried the solution suggested by @coolstar and it worked perfectly. I am listing the steps in a friendly manner to help anyone bumping this thread:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash tpm_tis.interrupts=0 i915.enable_ips=0 acpi_backlight=vendor"

After this, I was able to modify brightness with both the plugin slider and keyboard controls.

reynhout commented 7 years ago

This should be resolved in later ISOs and current kernels. Please re-open if the issue persists.