Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • X xbacklight
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 2
    • Issues 2
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • xorg
  • app
  • xbacklight
  • Issues
  • #3

Closed
Open
Created Sep 30, 2013 by Bugzilla Migration User@bugzilla-migration

[App/xbacklight] Incorrect behaviour when using -dec and then -inc with the same argument

Submitted by Nicola Lamacchia

Assigned to Xorg Project Team

Link to original bug (#69974)

Description

Created attachment 86859 Fix the bug

On my Samsung NC10 I experience the following:

$ xrandr --verbose
...
    BACKLIGHT: 8 (0x00000008)    range:  (0,8)
    Backlight: 8 (0x00000008)    range:  (0,8)
...
$ xbacklight -dec 10 # this works
$ xrandr --verbose
...
    BACKLIGHT: 7 (0x00000007)    range:  (0,8)
    Backlight: 7 (0x00000007)    range:  (0,8)
...
$ xbacklight -inc 10 # this doesn't work, nothing happens
$ xrandr --verbose
...
    BACKLIGHT: 7 (0x00000007)    range:  (0,8)
    Backlight: 7 (0x00000007)    range:  (0,8)
...

I've had a look to the code (xbacklight.c commit a4c00b26):

[...line 263]
double    	cur, new, step;
double	min, max;
double	set;
[...line 287]
set = value * (max - min) / 100;
switch (op) {
[...line 292]
case Inc:
    new = cur + set;
    break;
case Dec:
    new = cur - set;
    break;
[...line 308]
        cur = new;
[...line 311]
    backlight_set (conn, output, (long) cur);
[...]

Doing some math as C does:

# suppose
value = 15
max = 8
min = 0
cur = 7

set = value * (max - min) / 100 = 15 * (8 - 0) / 100 = 1.2

# decrease by 15%
op = Dec => new = 7 - 1.2 = 5.8
as per line 311 -> (long) cur => 5.8 -> 5 (toward zero)

now: cur = 5 (initial cur - 2)

# then increase by 15%
op = Inc => new = 5 + 1.2 = 6.2
Toward zero => 6.8 -> 6

now: cur = 6 (initial cur - 1)

'set' should be rounded at line 287 to avoid this inconsistent behaviour. I've attached a possible solution.

Attachment 86859, "Fix the bug":
0001-Add-missing-type-cast.patch

Version: git

Assignee
Assign to
Time tracking