1b164 [Solved] Sysctl Brightness - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Desktop Usage > Mobile Computing

Mobile Computing This forum discusses issues related to running FreeBSD on notebooks, laptops, and other mobile equipment.

Reply
 
Thread Tools Display Modes
  #1  
Old April 20th, 2012, 01:08
Draucia Draucia is offline
Junior Member
 
Join Date: Sep 2011
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
Default Sysctl Brightness

I'm trying to change my laptop brightness (Toshiba l505). Fn keys don't work, but I don't mind. xbacklight doesn't work, and I can't seem to get sysctl to work. I've loaded acpi_video, but whenever I do:

Code:
sudo sysctl hw.acpi.video.<device>.active
it says unknown oid. I've tried lcd, crt, tv, lcd0, crt0, and tv0 as the <device> and it always says unkown oid. I've also tried acpi_toshiba.

I've tried:

Code:
sudo sysctl hw.acpi.toshiba.lcd_brightness=0
But it still says unknown oid. This max brightness is hurting my eyes.


Any help is appreciated.

Last edited by Draucia; April 23rd, 2012 at 20:37. Reason: Proper formatting: http://forums.freebsd.org/showthread.php?t=8816
Reply With Quote
  #2  
Old April 20th, 2012, 05:13
aa aa is offline
Junior Member
 
Join Date: Mar 2012
Posts: 47
Thanks: 0
Thanked 9 Times in 9 Posts
Default

Just type sysctl hw.acpi to enumerate all recognized variables under hw.acpi
Reply With Quote
  #3  
Old April 20th, 2012, 11:26
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Administrator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 9,928
Thanks: 30
Thanked 1,924 Times in 1,350 Posts
Default

I found that my laptop (not a Toshiba) does respond to the brightness Fn keys when in the BIOS. Try that.
__________________
FreeBSD Forums: Information for New Members | FreeBSD Forums Rules
FreeBSD Resources: The FreeBSD Handbook | Manuals | FAQ | Wiki
Before you post: How to ask questions the smart way
If you must know .. So, what does an Administrator/Moderator do?
---> Do not PM me with FreeBSD questions. I do not work here. <---
Reply With Quote
The Following User Says Thank You to DutchDaemon For This Useful Post:
zeissoctopus (April 23rd, 2012)
  #4  
Old April 20th, 2012, 20:45
Draucia Draucia is offline
Junior Member
 
Join Date: Sep 2011
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by aa View Post
Just type sysctl hw.acpi to enumerate all recognized variables under hw.acpi
When I do so, here is the output:

Code:
 
hw.acpi.supported_sleep_state: S3 S4 S5
hw.acpi.power_button_state: S5
hw.acpi.sleep_button_state: S3
hw.acpi.lid_switch_state: NONE
hw.acpi.standby_state: NONE
hw.acpi.suspend_state: S3
hw.acpi.sleep_delay: 1
hw.acpi.s4bios: 0
hw.acpi.verbose: 0
hw.acpi.disable_on_reboot: 0
hw.acpi.handle_reboot: 1
hw.acpi.reset_video: 0
hw.acpi.cpu.cx_lowest: C1
hw.acpi.acline: 1
hw.acpi.battery.life: 100
hw.acpi.battery.time: -1
hw.acpi.battery.state: 0
hw.acpi.battery.units: 1
hw.acpi.battery.info_expire: 5
hw.acpi.thermal.min_runtime: 0
hw.acpi.thermal.polling_rate: 10
hw.acpi.thermal.user_override: 0
hw.acpi.thermal.tz0.temperature: 47.0C
hw.acpi.thermal.tz0.active: -1
hw.acpi.thermal.tz0.passive_cooling: 1
hw.acpi.thermal.tz0.thermal_flags: 0
hw.acpi.thermal.tz0._PSV: 104.0C
hw.acpi.thermal.tz0._HOT: -1
hw.acpi.thermal.tz0._CRT: 104.0C
hw.acpi.thermal.tz0._ACx: 70.0C -1 -1 -1 -1 -1 -1 -1 -1 -1
hw.acpi.thermal.tz0._TC1: 2
hw.acpi.thermal.tz0._TC2: 5
hw.acpi.thermal.tz0._TSP: 300
I don't understand. There is nothing related to brightness and anything related to hw.acpi.toshiba even though I did
Code:
kldload acpi_toshiba
Am I doing something wrong?

Quote:
Originally Posted by DutchDaemon View Post
I found that my laptop (not a Toshiba) does respond to the brightness Fn keys when in the BIOS. Try that.
Tried it, doesn't work.
Reply With Quote
  #5  
Old April 22nd, 2012, 12:05
Draucia Draucia is offline
Junior Member
 
Join Date: Sep 2011
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I still haven't been able to solve this issue. Is it just not possible on my laptop because hw.acpi.video doesn't support it?

Last edited by DutchDaemon; April 22nd, 2012 at 17:11.
Reply With Quote
  #6  
Old April 23rd, 2012, 20:15
JonathanBSD JonathanBSD is offline
Junior Member
 
Join Date: Apr 2012
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Default

I have the same laptop with the same problem, the only work around I found was installing the package xbrightness, download that, then in X type "xbrightness 22000" - I find that number to be a good setting, of course you can adjust the number to whatever you want.

You can also then leave X and the brightness setting will remain until you next reboot.

Last edited by DutchDaemon; April 23rd, 2012 at 23:57.
Reply With Quote
The Following User Says Thank You to JonathanBSD For This Useful Post:
Draucia (April 23rd, 2012)
  #7  
Old April 23rd, 2012, 20:37
Draucia Draucia is offline
Junior Member
 
Join Date: Sep 2011
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by JonathanBSD View Post
I have the same laptop with the same problem, the only work around I found was installing
the package xbrightness, download that, then in X type "xbrightness 22000" - I find that number to be a good setting, of course you can adjust the number to whatever you want.

You can also then leave X and the brightness setting will remain until you next reboot.
Wow this works great. It can lower the brightness more than the keys could. Thanks a lot.
Reply With Quote
  #8  
Old April 23rd, 2012, 22:53
JonathanBSD JonathanBSD is offline
Junior Member
 
Join Date: Apr 2012
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Default

No problem. Also, since we have the same laptop, I wonder did you manage to get your RTL819 wireless card working with NDIS? I haven't managed to do it and I'm stuck with wired for now!

Last edited by DutchDaemon; April 23rd, 2012 at 23:57.
Reply With Quote
  #9  
Old April 23rd, 2012, 23:00
Draucia Draucia is offline
Junior Member
 
Join Date: Sep 2011
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by JonathanBSD View Post
No problem. Also, since we have the same laptop, I wonder did you manage to get your RTL819 wireless card working with dnis? I haven't managed to do it and i'm stuck with wired for now!
RTL819 Wireless card? I have the Intel Wifi Link 5100AGN. I didn't have to do anything special to get this it work. My whole laptop model is L505 - S6959. You might have a model that's slightly different.
Reply With Quote
  #10  
Old September 5th, 2012, 22:20
Rul Rul is offline
Junior Member
 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

excuse me cuz i'm noob
im trying PCBSD for the first time, using 9.1RC1, have the same problem with brightness fn keys. I've followed this workarounds, and tried to install xbrightness, but don't know how. App cafe doesn't contain it, and /usr/ports/ doesn't exist in my 9.1RC1 installation,
Would somebody be kind and give me some cable?. Thanx
Reply With Quote
  #11  
Old September 6th, 2012, 00:12
CanOfBees CanOfBees is offline
Junior Member
 
Join Date: Mar 2010
Posts: 27
Thanks: 7
Thanked 0 Times in 0 Posts
Default

Hi Rul,

1) First `su` to root
su -
2) and then add the binary package for xbrightness:
pkg_add -r xbrightness
3) After you've installed the package, run the command:
xbrightness 9000 or something.

Be careful what you install, though, as some ports/packages can interfere with the base system that PC-BSD uses. For more information about ports & packages, check out the FreeBSD handbook here: http://www.freebsd.org/doc/en_US.ISO...ook/ports.html. Also, take a look at the PC-BSD handbook (here: http://wiki.pcbsd.org/index.php/PC-BSD_Users_Handbook) &, if you haven't, drop by the PC-BSD forums.

Cheers!
Reply With Quote
  #12  
Old September 6th, 2012, 00:38
Rul Rul is offline
Junior Member
 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

SOLVED! (not exactly), 9.1RC1 Toshiba brightness Fn keys don't work, but..
sudo portsnap fetch
sudo portsnap extract
cd /usr/ports/x11/xbrightness
sudo make install clean
sudo xbrightness 33000 1.3
http://disjunkt.com/xbrightness/

Now i'm comfortable for rebuilding the whole code of this pretty OS, XDD
Reply With Quote
  #13  
Old November 3rd, 2012, 09:01
franck-porcher franck-porcher is offline
Junior Member
 
Join Date: Dec 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sysctl brightness all-in-one draft solution

I was able to produce the following working solution :

Quote:
<Button push event>
|
v
Captured by the system
and forwarded as an ACPI "Notify"
event to the devd sub-system
|
v
devd daemon (using /etc/devd.conf)
is configured to respond to this
ACPI Notify event by triggering some
(custom) user-space software
|
v
(Custom) user-space software runs in turn to
handle the suitable action(s) needed
to take care of the low-level button pushed event
Though this solution now enables a perfect handling of my ThinkPad R61i brightness-up/brightness-down buttons, it will need to be tested and tuned against different hardware.

1)First, configure the system to bring all the necessary modules needed to have the sysctl sub-system logically "maps" the available hardware as correctly as possible.

In my case, I'm using a Lenovo ThinkPad R61i. The modules to access apci video variables are acpi_ibm and acpi_video. Check the available documentation to see which ones would be relevant for your particular hardware (generic acpi_<oem>)

These modules need to be available and loaded. They could either be included in the built-in kernel, or be brought in at boot time thru via loader by adding the following lines in /boot/loader.conf :

Code:
# ACPI for IBM ThinkPad
acpi_ibm_load="YES"
acpi_video_load="YES"
2)Second, configure the devd sub-system in order to properly capture the low-level events generated by pushing the brightness-up/brightness-down button.

For my R61i, the brightness-up (resp. brightnes-down) button is Fn-16 (resp. Fn-17) that are propagated to the devd sub-system as ACPI event :Notify=0x10 (resp. Notify=0x11).

Devd configuration I use to respond to these events and trigger the user-space code /usr/local/bin/acpi_ibm_exec.sh NOTIFY_EVENT OEM_NAME, where OEM name is "ibm" in my case (depends one the acpi_<oem> module loaded :

/etc/devd.conf
Code:
# ACPI Brightness up/down trap for IBM Thinkpad
notify 5 {
   match "system"          "ACPI";
   action "/usr/local/bin/acpi_generic_exec.sh $notify ibm";
};
Upon pressing the brightness-up button (Fn-16 -> 0x10 in hex) of my ThinkPad R61i, the typical call will be /usr/local/bin/acpi_ibm_exec.sh "0x10" ibm

3) Third, provide the user-space software.

/usr/local/bin/acpi_ibm_exec.sh is a (Bash) shell script which I put in /usr/local/bin for convenience. This shell script in turn calls the binary /usr/local/bin/xgradbrightness(1).

This "compilation" was inspired by acpi_ibm(4) and xbrightness(1) :

/usr/local/bin/acpi_ibm_exec.sh
Code:
#!/usr/local/bin/bash
#
# acpi_ibm_exec.sh
# Usage: $0 event oem_name
#
# Copyright (C) 2012 Franck Porcher,Ph.D. <franck.porcher@franckys.com>
export PATH="/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin"

if [ -z "$1" -o -z "$2" ]
then
    echo "usage: $0 acpi_event oem_name"
    exit 1
fi

NOTIFY=$(echo $1)

case ${NOTIFY} in
    0x10) #(Fn-10) BRIGHTNESS UP
          possible_levels_asc=( $(  sysctl -n hw.acpi.video.lcd0.levels     \
                                  | while read -d ' ' x; do echo "$x"; done \
                                  | sort -nu
                               ))
          actual_level=$(sysctl -n hw.acpi.video.lcd0.brightness)
          i=0
          max_i=${#possible_levels_asc[@]}
          while (( i < max_i ))
          do
            if (( actual_level == ${possible_levels_asc[i]} ))
            then
                if (( i == (max_i - 1) ))
                then
                    xgradbrightness max
                else
                    actual_level=${possible_levels_asc[i + 1]}
                    if xgradbrightness $((65535 * actual_level / 100))
                    then
                        sysctl hw.acpi.video.lcd0.brightness=$actual_level
                    fi
                fi
                break
            else
                (( i++ ))
            fi
          done
          ;;

    0x11) #(Fn-11) BRIGHTNESS DOWN
          possible_levels_desc=( $(  sysctl -n hw.acpi.video.lcd0.levels     \
                                   | while read -d ' ' x; do echo "$x"; done \
                                   | sort -rnu
                                ))
          actual_level=$(sysctl -n hw.acpi.video.lcd0.brightness)
          i=0
          max_i=${#possible_levels_desc[@]}
          while (( i < max_i ))
          do
            if (( actual_level == ${possible_levels_desc[i]} ))
            then
                if (( i == (max_i - 1) ))
                then
                    xgradbrightness min
                else
                    actual_level=${possible_levels_desc[i + 1]}
                    if xgradbrightness $((65535 * actual_level / 100))
                    then
                        sysctl hw.acpi.video.lcd0.brightness=$actual_level
                    fi
                fi
                break
            else
                (( i++ ))
            fi
          done
          ;;

        *)
         ;;
esac
xgradbrightness.c
Code:
/*
 * LICENCE TYPE : BSD
 *
 * Copyright 2012 Franck Porcher, Ph.D <franck.porcher@franckys.com>
 * Inspired by x11/xbrightness (see x11/xbrightness/work/AUTHORS)
 */

#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/xf86vmode.h>
#include <math.h>

#define BRIGHTNESS_MAX      65535
#define BRIGHTNESS_MIN      0
#define BRIGHTNESS_DEFAULT  65535
#define STEPS_DEFAULT       5000
#define DISPLAY_DEFAULT     ":0"

/*
 * Usage
 */
static void usage(char *arg) {
    fprintf (stderr, "%s builds a brightness ramp for X11.\n\n", arg);
    fprintf (stderr, "Usage:  %s [-h] [BRIGHTNESS] [STEP] [DISPLAY] \n", arg);
    fprintf (stderr, "Where :\n");
    fprintf (stderr, "    - BRIGHTNESS is the requested brightness. It can be a number from 0 to 65535, the word 'max' or the word 'min' (de
faults to max)\n");
    fprintf (stderr, "    - STEPS      is the number of steps (>= 1) to step-by-step progressively adjust the screen to the requested bright
ness (defaults to 5000)\n");
    fprintf (stderr, "    - DISPLAY    is the name of the X11 display to use (defaults to :0)\n\n");
    fprintf (stderr, "Copyright(C) Franck Porcher, Ph.D <franck.porcher@franckys.com>.\n");
    exit(0);
}

/*
 * Main
 */
int main(int argc, char *argv[]) {
    Display *dpy;
    int i,j;
    int screen, ramp_size;
    unsigned short *ramp;
    double level, delta_level;
    double brightness, delta_step;

    /**** Defaults ****/
    unsigned short brightness_requested = BRIGHTNESS_MAX;
    unsigned short steps = STEPS_DEFAULT;
    char *display = DISPLAY_DEFAULT;

    /**** Parameters ****/
    if (argc >= 2) {
        if (! strcmp(argv[1], "-h")) {
            usage(argv[0]);
        }

        if (! strcmp(argv[1], "max")) {
            brightness_requested = BRIGHTNESS_MAX;
        }
        else if (! strcmp(argv[1], "min")) {
            brightness_requested = BRIGHTNESS_MIN;
        }
        else {
            brightness_requested = atoi(argv[1]);
        }
    }

    if (argc >= 3) {
        steps = atoi(argv[2]);
    }

    if (argc >= 4) {
       display = argv[3];
    }

    /**** Setup ****/
    if ( (dpy = XOpenDisplay(display)) == NULL) {
        fprintf (stderr, "%s: unable to open default display '%s'.\n", argv[0], display);
        exit(1);
    }
    screen = DefaultScreen(dpy);

    /**** main portion ****/
    if (   XF86VidModeGetGammaRampSize(dpy, screen, &ramp_size )
        && (ramp = (unsigned short *) malloc(ramp_size * sizeof(unsigned short)))
        && XF86VidModeGetGammaRamp(dpy, screen, ramp_size, ramp, ramp, ramp)
    ) {
        /* "steps" steps by step progressive monitor's screen brightness adjustment.
         *  from "actual brightness", given by ramp[ramp_size-1],
         *  to   "requested brightness", given by 1st argument
         */ 

        brightness = (double)ramp[ramp_size-1];
        delta_step = ((double)brightness_requested - brightness)/steps;

        for (j=0; j<steps; j++) {
            brightness += delta_step;   /* progressive goal */

            delta_level = brightness/(ramp_size-1);
            level = 0.0;
            /* ramp[0] is always 0 whatever brightness,
             * so we start modifying ramp at index 1,
             * saving tiny fractions of precious time
             */
            for (i=1; i<ramp_size; i++) {
                level  += delta_level;
                ramp[i] = (unsigned short)level;
            }
            XF86VidModeSetGammaRamp(dpy, screen, ramp_size, ramp, ramp, ramp);
        }
    }
    XCloseDisplay(dpy);
    exit(0);
}
Imakefile
Code:
        DEPLIBS = $(DEPXXF86VMLIB) XawClientDepLibs
  SYS_LIBRARIES = MathLibrary
LOCAL_LIBRARIES = $(XXF86VMLIB) XawClientLibs
           SRCS = xgradbrightness.c 
           OBJS = xgradbrightness.o

ComplexProgramTarget(xgradbrightness)
INSTALL
Code:
xmkmf && make && make install
Wish you good success. Please report your mileage, your experience, and your suggestions.
This could become a tiny package on its own.

FP.
Reply With Quote
  #14  
Old November 4th, 2012, 08:44
franck-porcher franck-porcher is offline
Junior Member
 
Join Date: Dec 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Forgot to mention that the script being called by sys daemons, you'll have to give them the right to access your X display, that is (though you will remember that when you push your brighten-up/down buttons and see nothing happening...�e ):

Code:
# Log into your CLI, then
[~user]$ xhost +
There might be a better way, but I do not know it...

Cheers

--FP.
Reply With Quote
Reply

Tags
acpi brightness

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Solved] /etc/rc.d/sysctl: WARNING: sysctl current does not exist. ccc General 7 March 8th, 2012 06:10
desktop brightness not working on laptop fluca1978 Mobile Computing 16 February 15th, 2012 15:34
brightness control TCE Mobile Computing 10 May 10th, 2010 03:34
Fn Brightness keys don'twork, Script+Bindkeys ikbendeman Userland Programming & Scripting 6 March 14th, 2010 22:38
How to adjust BRIGHTNESS SCREEN ? setti Mobile Computing 4 August 11th, 2009 17:38


All times are GMT +1. The time now is 06:39.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0