Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[BUG freedesktop.org] backlight in console changes
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
dmitrio
Tux's lil' helper
Tux's lil' helper


Joined: 10 Dec 2002
Posts: 115
Location: Pago Pago

PostPosted: Wed Jun 18, 2014 6:45 am    Post subject: [BUG freedesktop.org] backlight in console changes Reply with quote

Hi,

after updating kernel to 3.15.x backlight in console changes to minimum when switching from xorg to console.
but when switching back from console to xorg, brightness goes back to max as it was before switching.
Initial boot keeps maximum brightness in console through the boot process.

Fn+brightness keys (ThinkPad T410) are functional to increase and decrease brightness, both in console and in xorg.

Code:

# lsof -r1 /sys/class/backlight/acpi_video0/
# lsof -r1 /sys/class/backlight/intel_backlight/
# auditctl -w /sys/class/backlight/acpi_video0/ -p war -k blwatch
# auditctl -w /sys/class/backlight/intel_backlight/ -p war -k blwatch

can not pinpoint the responsible process

Code:

zcat /proc/config.gz | grep -i think

CONFIG_THINKPAD_ACPI=m
CONFIG_THINKPAD_ACPI_ALSA_SUPPORT=y
# CONFIG_THINKPAD_ACPI_DEBUGFACILITIES is not set
# CONFIG_THINKPAD_ACPI_DEBUG is not set
CONFIG_THINKPAD_ACPI_UNSAFE_LEDS=y
CONFIG_THINKPAD_ACPI_VIDEO=y
CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y


Code:

# lsmod | grep think

thinkpad_ec             3503  2 hdaps,tp_smapi
thinkpad_acpi          53325  0


in lilo.conf I have tried without success
Code:

append="acpi_osi='!Windows 2012'"


What other options do I have to find what process is changing backlight
or maybe someone got a solution for that annoyance?
_________________

... Leaving ground, destination is unknown,
into the darkness and far away from home,
Will your dream come true and what will you find,
when fate is your guide ...


Last edited by dmitrio on Mon Jul 21, 2014 7:57 am; edited 1 time in total
Back to top
View user's profile Send private message
CrankyPenguin
Apprentice
Apprentice


Joined: 19 Jun 2003
Posts: 270

PostPosted: Thu Jun 26, 2014 5:59 am    Post subject: Reply with quote

I have a Lenovo X240 so my situation may be similar to yours.

Have you enabled framebuffers and backlight control in them? Specifically, have you set CONFIG_FB_BACKLIGHT on? If so that may be causing the framebuffer to take control of the backlight and cause confusion. I also, in response to another issue, added "acpi_backlight=vendor" to my kernel commandline. This removed the /sys/class/backlight/acpi_video0 entries and leaves me only with the intel_backlight. This is working fine for me and may fix your problem although I can't guarantee it.
_________________
Linux, the OS for the obsessive-compulsive speed freak in all of us.
Back to top
View user's profile Send private message
dmitrio
Tux's lil' helper
Tux's lil' helper


Joined: 10 Dec 2002
Posts: 115
Location: Pago Pago

PostPosted: Thu Jun 26, 2014 3:30 pm    Post subject: kernel tweak? Reply with quote

Thanks for the answer,

I even could not turn FB backlight on when compiled 3.15.1 today,
thought to play with it.

Code:

$ zgrep -i fb_backlight /proc/config.gz
# CONFIG_FB_BACKLIGHT is not set



kernel commandline "acpi_backlight=vendor"
indeed fix the issue, but as well it has disabled ability to change brightness through special keys, in console and Xorg.

I will keep digging.
_________________

... Leaving ground, destination is unknown,
into the darkness and far away from home,
Will your dream come true and what will you find,
when fate is your guide ...
Back to top
View user's profile Send private message
CrankyPenguin
Apprentice
Apprentice


Joined: 19 Jun 2003
Posts: 270

PostPosted: Thu Jun 26, 2014 8:41 pm    Post subject: Reply with quote

I ue that commandline and can change my brightness via the keys. I use acpid and not automatic hardware brightness and make updates to the intel_backlight sys files. I've appended my acpid actions files below.

Code:

#!/bin/bash

# Set the static decrement value.  Keep in mind that this will
# be done twice.
DecVal=20

# Set the Minimum we will accept.
MinVal=0

# Get the current brightness value.
CurrVal=$(cat /sys/class/backlight/intel_backlight/brightness);

# Set the new value minus the decrement value.
NewVal=$(($CurrVal - $DecVal));
echo $NewVal

# Set it to the threshold of the min value.
ThresholdVal=$(($NewVal>$MinVal?$NewVal:$MinVal))
echo $ThresholdVal

# Set the new value directly.
echo -n $ThresholdVal > /sys/class/backlight/intel_backlight/brightness

logger "[ACPI] brightnessdown |$CurrVal| |$NewVal| |$ThresholdVal|"


Code:
#!/bin/bash

# Set the static increment value.  Keep in mind that this will
# be done twice.
IncVal=20

# Get the Maximum value for use.
MaxVal=$(cat /sys/class/backlight/intel_backlight/max_brightness);

# Get the current brightness value.
CurrVal=$(cat /sys/class/backlight/intel_backlight/brightness);

# Set the new value minus the decrement value.
NewVal=$(($CurrVal + $IncVal));
echo $NewVal

# Set it to the threshold of the max value.
ThresholdVal=$(($NewVal<$MaxVal?$NewVal:$MaxVal))
echo $ThresholdVal

# Set the new value directly.
echo -n $ThresholdVal > /sys/class/backlight/intel_backlight/brightness

logger "[ACPI] brightnessup |$CurrVal| |$NewVal| |$ThresholdVal|"

_________________
Linux, the OS for the obsessive-compulsive speed freak in all of us.
Back to top
View user's profile Send private message
dmitrio
Tux's lil' helper
Tux's lil' helper


Joined: 10 Dec 2002
Posts: 115
Location: Pago Pago

PostPosted: Sat Jul 05, 2014 5:49 am    Post subject: acpi actions Reply with quote

sorry for delay,
I have started googling around for acpi rules and ended up writing a wiki article
still WIP but hopefully it will help someone else
_________________

... Leaving ground, destination is unknown,
into the darkness and far away from home,
Will your dream come true and what will you find,
when fate is your guide ...
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sat Jul 05, 2014 6:19 am    Post subject: Reply with quote

CrankyPenguin wrote:
Code:
# Get the current brightness value.
CurrVal=$(cat /sys/class/backlight/intel_backlight/brightness);

CrankyPenguin ... that would be a UUoC, you can avoid such things by using 'read' ...

Code:
read -r CurrVal < "/sys/class/backlight/intel_backlight/brightness"

best ... khay
Back to top
View user's profile Send private message
dmitrio
Tux's lil' helper
Tux's lil' helper


Joined: 10 Dec 2002
Posts: 115
Location: Pago Pago

PostPosted: Sat Jul 05, 2014 9:32 am    Post subject: solution from arch wiki Reply with quote

Arch wiki has another solution
which i have hard time to comprehend, since it does not check brightness limits

Code:

/etc/acpi/handlers/bl
#!/bin/sh
bl_dev=/sys/class/backlight/acpi_video0
step=1

case $1 in
  -) echo $(($(< $bl_dev/brightness) - $step)) >$bl_dev/brightness;;
  +) echo $(($(< $bl_dev/brightness) + $step)) >$bl_dev/brightness;;
esac


Code:

/etc/acpi/events/bl_d
event=video/brightnessdown
action=/etc/acpi/handlers/bl -


Code:

/etc/acpi/events/bl_u
event=video/brightnessup
action=/etc/acpi/handlers/bl +

_________________

... Leaving ground, destination is unknown,
into the darkness and far away from home,
Will your dream come true and what will you find,
when fate is your guide ...
Back to top
View user's profile Send private message
haarp
Guru
Guru


Joined: 31 Oct 2007
Posts: 516

PostPosted: Sat Jul 05, 2014 11:32 am    Post subject: Re: acpi actions Reply with quote

dmitrio wrote:
sorry for delay,
I have started googling around for acpi rules and ended up writing a wiki article
still WIP but hopefully it will help someone else

I disagree with that wiki article on many points and have some additional information:

a)
tp_smapi? for this, that module is not needed. You probably mean thinkpad_acpi.

b)
acpi_backlight=vendor shouldn't be used as it breaks backlight under X without special scripts. You're better off filing a bug for kernel 3.15 to fix the behavior.

c)
You don't need acpid to handle the buttons if your desktop environment does it properly (I assume most would) or can be configured to do so (Xfce can).

d)
HOWEVER, by default some buttons are mapped to keycodes that X can't handle or has no keysym for (brilliant, I know). So the following might be useful. It modifies the udev defaults slightly to fix the key combinations that otherwise wouldn't work in X:
/etc/udev/hwdb.d/thinkpad_keyboard.hwdb
Code:
# To debug key presses and access scan code mapping data of
# an input device use the commonly available tool: evtest(1).

# A list of possible keycodes is available under
# https://github.com/torvalds/linux/blob/master/include/uapi/linux/input.h

### common
keyboard:name:ThinkPad Extra Buttons:dmi:bvn*:bvr*:bd*:svnLENOVO*:pn*
 KEYBOARD_KEY_00=prog2          # Fn+F1
 KEYBOARD_KEY_08=media          # Fn+F9; should be undock, but X has no keysym
 KEYBOARD_KEY_0a=prog3          # Fn+F11
 KEYBOARD_KEY_13=search         # Fn+Space; should be zoom, but X can't handle keycode
# KEYBOARD_KEY_18=              # Fn+1 (might need hotkey unmasking)
# KEYBOARD_KEY_19=              # Fn+2 (same)

### X61t display buttons
keyboard:dmi:bvn*:bvr*:bd*:svnLENOVO*:pnThinkPad*X6*:pvr*
 KEYBOARD_KEY_67=screenlock     # small unlabelled button
 KEYBOARD_KEY_6C=f21            # rotate button (f21 = XF86TouchpadToggle)
 KEYBOARD_KEY_68=config         # rectangle thing button (config = XF86Tools; was:screenlock)


e)
Thinkpad W700/701 users that use the nvidia propietary driver must add
"EnableACPIBrightnessHotkeys" "false"
to the device section of their GPU in xorg.conf, or brightness changing will be ridiculously broken.

f)
There are additional hotkeys, like Fn+1 and Fn+2 that can be unlocked by changing the thinkpad_acpi hotkey mask (module parameter or in /proc/acpi/ibm/hotkey). However, users of the Nvidia driver will notice that the driver will fuck up their custom hotkey mask! Nvidia actually dares to mess with completely unrelated kernel modules. I have binary-patched the nvidia-driver to prevent this:
/etc/portage/patches/x11-drivers/nvidia-drivers/dont-fuck-with-thinkpad-hotkeys.patch
Code:
Prevent nvidia from fucking with thinkpad_acpi hotkeys. Created with:
sed -i -e 's/0xffbf/      /' nvidia_drv.so
http://forums.fedoraforum.org/showthread.php?t=277541

--- /usr/lib/xorg/modules/drivers/nvidia_drv.so   2013-05-24 15:04:38.000000000 +0200
+++ /tmp/nvidia_drv.so   2013-05-24 15:03:58.874036976 +0200
@@ -7631,7 +7631,7 @@
 Error reading from /sys/devices/platform/dock.*/docked file%dUnable to parse /sys/devices/platform/dock.*/docked fileACPI: the system is docked
 ACPI: the system is undocked
 Unable to find /sys/devices/platform/dock.*/docked file. Kernel version may be less than 2.6.20 or dock.ko driver may not be presentACPI: failed to determine the system's docking state: %s
-failed to communicate the new docking status to the NVIDIA kernel moduleACPI: failed to determine the system's current docking state: %s/proc/acpi/ibm%s%s/hotkeyr+mask:mask:      0x%x0xffbf0x%xDOS setting: <%d>/type/sys/class/power_supply//onlineACPI: AC state file path: %sACPI: failed to read the AC power state from file %sMains/state/proc/acpi/ac_adapter/on-lineoff-lineACPI: failed to create a UNIX domain socket; the NVIDIA X driver will be unable to receive and respond to ACPI event notifications./var/run/acpid.socketACPI: failed to connect to the ACPI event daemon; the daemon may not be running or the "AcpidSocketPath" X configuration option may not be set correctly.  When the ACPI event daemon is available, the NVIDIA X driver will try to use it to receive ACPI event notifications.  For details, please see the "ConnectToAcpid" and "AcpidSocketPath" X configuration options in Appendix B: X Config Options in the README.ACPI: failed to add a UNIX domain socket descriptor to the X server's polling list; the NVIDIA X driver will not be able to receive and handle ACPI event notifications.current:current: %d
+failed to communicate the new docking status to the NVIDIA kernel moduleACPI: failed to determine the system's current docking state: %s/proc/acpi/ibm%s%s/hotkeyr+mask:mask:      0x%x      0x%xDOS setting: <%d>/type/sys/class/power_supply//onlineACPI: AC state file path: %sACPI: failed to read the AC power state from file %sMains/state/proc/acpi/ac_adapter/on-lineoff-lineACPI: failed to create a UNIX domain socket; the NVIDIA X driver will be unable to receive and respond to ACPI event notifications./var/run/acpid.socketACPI: failed to connect to the ACPI event daemon; the daemon may not be running or the "AcpidSocketPath" X configuration option may not be set correctly.  When the ACPI event daemon is available, the NVIDIA X driver will try to use it to receive ACPI event notifications.  For details, please see the "ConnectToAcpid" and "AcpidSocketPath" X configuration options in Appendix B: X Config Options in the README.ACPI: failed to add a UNIX domain socket descriptor to the X server's polling list; the NVIDIA X driver will not be able to receive and handle ACPI event notifications.current:current: %d
 /proc/acpi/video%s/%s%s/%s/brightnesslevels:ACPI: brightness file %s has more than supported levels: %d
  %sdevice_id:device_id:    0x%xACPI: failed to retrieve AC power state information from %s, trying %sACPI: AC power state information is not available under /sys/class/power_supply/ , nor under /proc/acpi/ac_adapter/ACPI: the system is running on AC powerACPI: the system is running on battery powerACPI: failed to determine the system's current power sourceACPI: failed to register for ACPI hotkey events: failed to open "%s" and failed to fall back to the vendor-specific directories under "%s".%s/%s/state%s/%s/infoACPI: invalid device ID in the file %sACPI: the driver will respond to display change hotkey switches by inferring the new display device combination, rather than getting the new display device combination from the ACPI subsystem.%s/%s/DOS1.1.148.25the X server is new enough to receive ACPI hotkey eventsthe X server is patched to receive ACPI hotkey events, but the "EnableACPIHotkeys" option is set to "False"the X server is too old to receive ACPI hotkey events, but the "EnableACPIHotkeys" option is set to "True"disabledACPI display change hotkey events %s: %s%s.wUnable to read/write the DOS (Enable/Disable output switching) file path underACPI brightness change hotkey events enabled.ACPI brightness change hotkey events disabled: The "EnableACPIBrightnessHotkeys" option is set to "False"enabledUnable to find the DOS (Enable/Disable output switching) file path underACPI: Error: %s %s. The NVIDIA X driver will not be able to respond to ACPI display change hotkey events.Unable to find the brightness file path underACPI: Error: %s %s. The NVIDIA X driver will not be able to respond to ACPI brightness change hotkey events.state:state:     0x%xquery:query:     0x%xACPI: failed to calculate the new display mask for a display change hotkey eventACPI: failed to handle a display change hotkey eventACPI: the connection to the ACPI event daemon was broken; the driver will attempt to reconnect, but any notifications of ACPI events sent in the meantime will not reach the NVIDIA X driver.ACPI: failed to schedule a timer callback; the NVIDIA X driver will be unable to reconnect to the ACPI event daemon.ACPI: received event: %s
 %20s %20s %x %x  ACPI event: %s %s %x %x
Back to top
View user's profile Send private message
dmitrio
Tux's lil' helper
Tux's lil' helper


Joined: 10 Dec 2002
Posts: 115
Location: Pago Pago

PostPosted: Sat Jul 05, 2014 12:08 pm    Post subject: Re: acpi actions Reply with quote

haarp wrote:

a)
tp_smapi? for this, that module is not needed. You probably mean thinkpad_acpi.

b)
acpi_backlight=vendor shouldn't be used as it breaks backlight under X without special scripts. You're better off filing a bug for kernel 3.15 to fix the behavior.

c)
You don't need acpid to handle the buttons if your desktop environment does it properly (I assume most would) or can be configured to do so (Xfce can).

d)
HOWEVER, by default some buttons are mapped to keycodes that X can't handle or has no keysym for (brilliant, I know). So the following might be useful. It modifies the udev defaults slightly to fix the key combinations that otherwise wouldn't work in X:
/etc/udev/hwdb.d/thinkpad_keyboard.hwdb
Code:
# To debug key presses and access scan code mapping data of
# an input device use the commonly available tool: evtest(1).

# A list of possible keycodes is available under
# https://github.com/torvalds/linux/blob/master/include/uapi/linux/input.h

### common
keyboard:name:ThinkPad Extra Buttons:dmi:bvn*:bvr*:bd*:svnLENOVO*:pn*
 KEYBOARD_KEY_00=prog2          # Fn+F1
 KEYBOARD_KEY_08=media          # Fn+F9; should be undock, but X has no keysym
 KEYBOARD_KEY_0a=prog3          # Fn+F11
 KEYBOARD_KEY_13=search         # Fn+Space; should be zoom, but X can't handle keycode
# KEYBOARD_KEY_18=              # Fn+1 (might need hotkey unmasking)
# KEYBOARD_KEY_19=              # Fn+2 (same)

### X61t display buttons
keyboard:dmi:bvn*:bvr*:bd*:svnLENOVO*:pnThinkPad*X6*:pvr*
 KEYBOARD_KEY_67=screenlock     # small unlabelled button
 KEYBOARD_KEY_6C=f21            # rotate button (f21 = XF86TouchpadToggle)
 KEYBOARD_KEY_68=config         # rectangle thing button (config = XF86Tools; was:screenlock)


e)
Thinkpad W700/701 users that use the nvidia propietary driver must add
"EnableACPIBrightnessHotkeys" "false"
to the device section of their GPU in xorg.conf, or brightness changing will be ridiculously broken.

f)
There are additional hotkeys, like Fn+1 and Fn+2 that can be unlocked by changing the thinkpad_acpi hotkey mask (module parameter or in /proc/acpi/ibm/hotkey). However, users of the Nvidia driver will notice that the driver will fuck up their custom hotkey mask! Nvidia actually dares to mess with completely unrelated kernel modules. I have binary-patched the nvidia-driver to prevent this:
/etc/portage/patches/x11-drivers/nvidia-drivers/dont-fuck-with-thinkpad-hotkeys.patch


First of all thank you for your input, I really appreciate it.
Since I don't use Fn+keys I was never actually dare to check them, but when the console backlight started misbehave, I decided to check on Fn buttons.
Some of the initial configuration has been forgotten long time ago, thanks for helping me with it.

a.
I have updated kernel config requirement for thinkpad_acpi

b.
If it is a kernel bug, than yes, definitely need to be filed. [DONE see below]

c.
Note for desktops has been placed in the article

d.
acpi solution would work in console as well, as in xorg, that was another reason to explore that matter, involving udev - going to mess everything even worse for the next update, but this information should be at least listed [DONE]

e.
I would not mind some help with other models of thinkpads
_________________

... Leaving ground, destination is unknown,
into the darkness and far away from home,
Will your dream come true and what will you find,
when fate is your guide ...


Last edited by dmitrio on Sun Jul 06, 2014 2:00 am; edited 1 time in total
Back to top
View user's profile Send private message
CrankyPenguin
Apprentice
Apprentice


Joined: 19 Jun 2003
Posts: 270

PostPosted: Sat Jul 05, 2014 9:07 pm    Post subject: Reply with quote

dmitrio: I like you prefer the acpi solution as it works in console and while acpi=vendor does work although I agree that it is probably best filed as a bug.

Thank you Khay, I will take a look at the use of read that you recommend.
_________________
Linux, the OS for the obsessive-compulsive speed freak in all of us.
Back to top
View user's profile Send private message
dmitrio
Tux's lil' helper
Tux's lil' helper


Joined: 10 Dec 2002
Posts: 115
Location: Pago Pago

PostPosted: Sun Jul 06, 2014 2:00 am    Post subject: bug report filed Reply with quote

bug report filed at bugzilla.kernel.org
_________________

... Leaving ground, destination is unknown,
into the darkness and far away from home,
Will your dream come true and what will you find,
when fate is your guide ...
Back to top
View user's profile Send private message
dmitrio
Tux's lil' helper
Tux's lil' helper


Joined: 10 Dec 2002
Posts: 115
Location: Pago Pago

PostPosted: Wed Jul 09, 2014 9:25 am    Post subject: xorg bug Reply with quote

actually it is not a kernel bug, rather xorg,
so if open another bug on freedesktop.org
_________________

... Leaving ground, destination is unknown,
into the darkness and far away from home,
Will your dream come true and what will you find,
when fate is your guide ...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum