Search This Blog

Showing posts with label notebook. Show all posts
Showing posts with label notebook. Show all posts

Tuesday, December 28, 2021

Custom keyboard layout in Wayland

Unfortunately, the configuration at the and of this post does not work for Wayland Qt applications, like konsole, kate. A colleage from KDE Brazil telegram channel pointed me to a working solution.

Update 28/12/2021: the configuration below works for X11/XWayland applications only.

Going forward with migrating to Wayland. There are several smalls things to fix in my setup, one of them is adding a custom layout to workaround the fact that my child broken the Up key of my laptop's keyboard. I had mapped F9 to Up using $HOME/.Xmodmap, which does not work in Wayland. I have figure out how to that in Wayland [1] [2] and maybe this can help other people.

Create this file to configure XDG_CONFIG_HOME variable:

# /etc/profile.d/xdg.sh
export XDG_CONFIG_HOME=$HOME/.config

Create the $HOME/.config/xkb/rules/evdev.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xkbConfigRegistry SYSTEM "xkb.dtd">

<xkbConfigRegistry version="1.1">

  <layoutList>

    <layout>

      <configItem>

        <name>lvs</name> <!-- Change to any name you want -->

        <shortDescription>Layout LVS</shortDescription> <!-- Same here -->

        <description>Layout com F8, F9 e F10 remapeadas</description> <!-- Any description you want -->

        <countryList>

          <iso3166Id>US</iso3166Id> <!-- Add your country to this list -->

          <iso3166Id>BR</iso3166Id> <!-- My country: Brazil -->

        </countryList>

        <languageList>

          <iso639Id>eng</iso639Id> <!-- Layout language -->

          <iso639Id>por</iso639Id> <!-- Brazilian Portuguese -->

        </languageList>

      </configItem>

    </layout>

  </layoutList>

</xkbConfigRegistry>


Create a file $HOME/.config/xkb/symbols/lvs (the file name have to match the layout name in evdev.xml) with the actual changes you need. I just copied the file with the symbols I wanted to change to save time:

cp /usr/share/X11/xkb/symbols/srvr_ctrl $HOME/.config/xkb/symbols/lvs

Then I removed all lines that should not be changed. The final file is the following (the actual changes are in bold):

partial function_keys

xkb_symbols "fkey2vt" {

    key <FK08> {

        type="CTRL+ALT",

        symbols[Group1]= [ Prior, F8, F8, F8, XF86_Switch_VT_8 ]

    };

    key <FK09> {

        type="CTRL+ALT",

        symbols[Group1]= [ Up, Prior, F9, F9, XF86_Switch_VT_9 ]

    };

};

Comparing all this to the .Xmodmap it seems way more complicated :-( This is my .Xmodmap:

! 74 = F8 

keycode 74 = Prior                                            

! 75 = F9                                  
keycode 75 = Up Prior

You need to restart startplasma-wayland so the changes take affect. The best part is that it also works with X11, so I removed my .Xmodmap.

PS: the Up key does not work in konsole to show the previous command when running in wayland, even with an external keyboard with a physical Up key. That works in X11.

Saturday, December 25, 2021

Nvidia optimus with wayland. Help needed.

I have given a try on wayland and it works in my notebook (Gigabyte p34v5) when using only the Intel gpu (/dev/dri/card0) and mesa. Now I have been trying to make it work with the Nvidia gpu (GeForce GTX 970M, /dev/dri/card1) using proprietary driver. The thing about that gpu is that is uses optimus and thus need the following command to work with X11:

# /usr/share/sddm/scripts/Xsetup file
xrandr --setprovideroutputsource modesetting NVIDIA-0

There is just a blank screen on sddm whithout that command (the Nvidia gpu is not physically connected to the display, it needs the Intel gpu to send image to any display, the command above connects the Nvidia gpu to the Intel one). Since xrandr does not work with wayland I am kind of stuck trying figure out the equivalent of that command for wayland. I have tried the following environment variable to no avail:

WLR_DRM_DEVICES=card1:card0

My current startwayland.sh script is:

# card0: intel
# card1: nvidia
export WLR_DRM_DEVICES=card1:card0
export KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0
export XDG_RUNTIME_DIR=/tmp/1001
export XDG_SESSION_TYPE=wayland
export QT_QPA_PLATFORM=wayland
export GBM_BACKEND=nvidia-drm
export __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/10_nvidia.json:/usr/share/glvnd/egl_vendor.d/50_mesa.json
export EGL_PLATFORM=wayland
export EGL_LOG_LEVEL=debug
export QT_LOGGING_RULES="kwin*=true"
export KWIN_GL_DEBUG=1
export WAYLAND_DEBUG=1
unset DISPLAY
mkdir -m 0700 -p $XDG_RUNTIME_DIR

if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; then
    export $(dbus-launch)
    sleep 1
fi


kwin_wayland --xwayland --exit-with-session=konsole 2>&1 | tee -a kwin_wayland_log.txt

I am using kwin_wayland instead of plasma-wayland so less programs are started during my tests.

EGL is correctly initialized on both gpu by what can be seen on kwin_wayland_log.txt, though nvidia-drivers uses version 1.5 and mesa uses version 1.4.

The first relevant error is "kwin_wayland_drm: swapping buffers failed on output KWin::DrmOutput(0x559b35fd8d30, name="eDP-1", geometry=QRect(0,0 1920x1080), scale=1)". eDP-1 is my laptop's LCD and W2486 is an external monitor.

There is no screen update after I launch kwin_wayland similar to what happens with X11 without the xrandr command. I need to log through ssh to 'chvt' to a different virtual terminal or kill kwin_wayland to use laptop again. I guess I just need to instruct kwin_wayland to connect the output of nvidia gpu to intel's one to make everything work. I just do not know how to do that.

My environment:

x11-drivers/nvidia-drivers-495.46-r10:0/495 to use Nvidia's new GBM support instead of EGLStream
gui-libs/egl-wayland-1.1.9:0
gui-libs/eglexternalplatform-1.1:0
media-libs/mesa-21.3.2:0
dev-qt/qtwayland-5.15.2-r16:5/5.15.2 with patch Don't block in QWaylandDisplay::flushRequests
kde-plasma/kwin-9999:5 this is a git build of commit 445946382379b65701259bc1f75c92227348db31 from Dec 15 2021 so I can use platforms/drm: use gbm with NVidia driver 495+.

Have someone successfully run plasma-wayland with nvidia's optimus and gbm instead of EGLStream?

Thursday, August 2, 2012

Tux on Ice and swap

Strictly speaking this is off topic since it is not KDE related, anyway it looks interesting for those who use suspend to disk in Linux, specially the Tux on Ice flavor of the available suspend implementations for Linux.

I have been using Tux on Ice for years and also for years I have been suffering from segfaults in several programs after resume from disk. With my old notebook I workarounded this problem by cleaning the swap partition (swapoff -a; swapon -a) before suspending. That works but, as you may be thinking, it is damn slow if there are hundreds of MB in swap partition.

When I bought my current notebook I elimated any swap partition and started using a swap file instead. Resizing partitions is a slow process and not always safe, resizing a file is much easier (just delete it and recreate it :-)). Using swap file was something I wanted to do for a long time back then. Well, the swap partition problem was fixed but not the segfaults.

Last week I looked more deeply into the problem to figure out how to solve it for good or at least find a faster workaround. One thing that I noticed in my /var/log/message is the failed memory allocation below:


Jul 24 09:22:14 evolucao kernel: [81109.228445] [fglrx] IRQ 46 Disabled
Jul 24 09:22:15 evolucao kernel: [81109.228526] [fglrx] Preparing suspend fglrx in kernel.
Jul 24 09:22:15 evolucao kernel: [81109.228538] kworker/u:8: page allocation failure: order:10, mode:0x20
Jul 24 09:22:15 evolucao kernel: [81109.228540] Pid: 26030, comm: kworker/u:8 Tainted: P       A   O 3.4.6-lvs #9
Jul 24 09:22:15 evolucao kernel: [81109.228542] Call Trace:
Jul 24 09:22:16 evolucao kernel: [81109.228552]  [] warn_alloc_failed+0x108/0x11d
Jul 24 09:22:16 evolucao kernel: [81109.228559]  [] ? number.clone.1+0x129/0x229
Jul 24 09:22:16 evolucao kernel: [81109.228562]  [] __alloc_pages_nodemask+0x61e/0x6c3
Jul 24 09:22:17 evolucao kernel: [81109.228566]  [] cache_alloc_refill+0x276/0x4fb
Jul 24 09:22:17 evolucao kernel: [81109.228568]  [] __kmalloc+0x9d/0x144
Jul 24 09:22:17 evolucao kernel: [81109.228617]  [] ? KCL_MEM_SmallBufferAllocAtomic+0x19/0x1b [fglrx]
Jul 24 09:22:17 evolucao kernel: [81109.228640]  [] KCL_MEM_SmallBufferAllocAtomic+0x19/0x1b [fglrx]
Jul 24 09:22:18 evolucao kernel: [81109.228669]  [] libip_resume+0x253/0x5c0 [fglrx]
Jul 24 09:22:19 evolucao kernel: [81109.228704]  [] ? mc_heap_get_reserved_blocks_info+0x17e/0x2a0 [fglrx]
Jul 24 09:22:19 evolucao kernel: [81109.228725]  [] ? KCL_MEM_SmallBufferAllocAtomic+0x19/0x1b [fglrx]
Jul 24 09:22:20 evolucao kernel: [81109.228758]  [] ? firegl_pm_save_framebuffer+0x204/0x300 [fglrx]
Jul 24 09:22:20 evolucao kernel: [81109.228785]  [] ? firegl_cail_powerdown+0x8d/0x240 [fglrx]
Jul 24 09:22:20 evolucao kernel: [81109.228812]  [] ? libip_suspend+0x22/0x50 [fglrx]
Jul 24 09:22:21 evolucao kernel: [81109.228831]  [] ? ip_firegl_lseek+0xeb8/0x17ef [fglrx]
Jul 24 09:22:21 evolucao kernel: [81109.228835]  [] ? pci_legacy_suspend+0x35/0xb8
Jul 24 09:22:21 evolucao kernel: [81109.228838]  [] ? pci_pm_freeze+0x43/0x8b
Jul 24 09:22:21 evolucao kernel: [81109.228844]  [] ? device_pm_wait_for_dev+0x24/0x24
Jul 24 09:22:21 evolucao kernel: [81109.228846]  [] ? pci_pm_poweroff+0x98/0x98
Jul 24 09:22:21 evolucao kernel: [81109.228849]  [] ? dpm_run_callback.clone.4+0x2a/0x58
Jul 24 09:22:22 evolucao kernel: [81109.228851]  [] ? __device_suspend+0x145/0x1c4
Jul 24 09:22:22 evolucao kernel: [81109.228856]  [] ? async_schedule+0x12/0x12
Jul 24 09:22:22 evolucao kernel: [81109.228858]  [] ? async_suspend+0x1a/0x85
Jul 24 09:22:22 evolucao kernel: [81109.228861]  [] ? async_run_entry_fn+0xa3/0x159
Jul 24 09:22:22 evolucao kernel: [81109.228865]  [] ? process_one_work+0x214/0x393
Jul 24 09:22:22 evolucao kernel: [81109.228868]  [] ? need_to_create_worker+0x19/0x32
Jul 24 09:22:22 evolucao kernel: [81109.228871]  [] ? worker_thread+0x17e/0x243
Jul 24 09:22:23 evolucao kernel: [81109.228875]  [] ? preempt_schedule+0x35/0x48
Jul 24 09:22:23 evolucao kernel: [81109.228877]  [] ? manage_workers.clone.17+0x16e/0x16e
Jul 24 09:22:23 evolucao kernel: [81109.228880]  [] ? kthread+0x84/0x8c
Jul 24 09:22:23 evolucao kernel: [81109.228883]  [] ? kernel_thread_helper+0x4/0x10
Jul 24 09:22:23 evolucao kernel: [81109.228885]  [] ? kthread_freezable_should_stop+0x4d/0x4d
Jul 24 09:22:23 evolucao kernel: [81109.228888]  [] ? gs_change+0xb/0xb


You must be thinking in blaming fglrx for this problem but I use the opensource driver in my old notebook, which probably still has this problem (I still own my old notebook). Moreover, in the first months after buying my current notebook I used to use the opensource drivers with it too, so I am almost sure this problem is not related to that allocation failure above. OBS: I changed to the proprietary ATI driver because only with it my notebook's fan keeps quiet without the "silent" speed button that comes with my notebook. The silent button also limits the cores' clock to almost 1 GHz below the maximum clock and having to press it everytime I want full CPU power or restart the notebook is really annoying. For someone who uses Gentoo I used to press that button quite often when I used the opensource driver. Unfortunately, the GPU does not inform its power profile to the kernel so the opensource driver's dynamic profile does not work with it. I am stuck to the proprietary driver until someone can fix that issue. I hope this news allows someone to finally implement the dynamic profile for my GPU.

Turning back to the segfault problem, some days ago I tried something different. Tux On Ice works with swap partition, swap files and also with a dedicated file to store the image. I decided to split my 4 GB swap file into two: one 2 GB file for swap and another 2 GB file for the hibernate image. My notebook came with 4 GB of RAM memory and I usually do not need more than 1 GB of swap even when I run two virtual machines, Chromium, Firefox and several other programs running in parallel, so I can afford a smaller swap file (again: swap files are really easy to resize :-)). Guess what? There has been no segfaults so far :-D. I also love the fact that Tux on Ice compresses the RAM image using all available cores before saving it.

I do not know if the vanilla suspend implementation in the Linux kernel also suffers from this problem. By what I could find on the Internet it may be affected as well. As far as I know the vanilla suspend does not allow using anything but swap partitions to store the image (not even swap files). So if you have this problem you can give Tux on Ice a try.

I did a final test by suspending to disk with chromium, VirtualBox, Amarok, kmail, konversation, kopete and skype running. The command free reported "-/+ buffers/cache: 2310964 KB", which means about 59%  of the available RAM memory used by applications (excluding buffers and disck cache). There was also 666844 KB in my swap file. The suspend process was not that fast but (about 20s). Resuming took much more time (about 2 minutes until the Plasma Desktop reappears). There was a lot of disk activity and the swap usage went from 666844 KB to 1027240 KB and then down to 879456 KB in a period of two minutes after which I could finally type commands in konsole. However everything is still working, no segfault and Amarok kept playing the same song I was listening to when I suspended my notebook :-) I am now at the fifth day running without reboots and segfaults, the swap usage dropped to 353112 KB during this period.

The failed memory allocation I talked about above happened this time and everything still works with fglrx (including kwin's effects). Well, I have found a fast suspend/resume configuration at last (as long as there was not much data in swap). If I close the memory hungry programs (like VirtualBox and Chromium) before suspending then it suspends in about 10s and resumes in about 15s, half of that time running pm-utils' scripts That is not that bad :-)

Wednesday, July 27, 2011

E-sata, solid, and udisks (part 2)


In my first post about e-sata, solid and udisks I wrote about how to hack udisks to inform solid that a disk attached to a specified sata port is actually a removable disk. Udisks-1.0.3 includes a modified patch that allows to do that without applying the patch ourselves. We still need to add the udev rule to indicate which sata port is to be considered "non system internal". The udev rules is slightly diferent from the one I wrote about in my last Solid post:

File /etc/udev/rules.d/99-esata.rules
DEVPATH=="/devices/pci0000:00/0000:00:1f.2/host4/*", ENV{UDISKS_SYSTEM_INTERNAL}="0"

Change the DEVPATH to match your e-sata port. You can find it using the command:

Code
evolucao ~ # find /sys/devices/ -name sdb
/sys/devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0/block/sdb


Then reload udev rules after creating/editing the file above: udevadm control --reload-rules

Now the bad news: udisks includes several attributes to a disk, among then are "system internal" and "removable". Removable means removable media (like optical discs, card readers, etc). System internal means the device is "fixed" to the computer, it cannot be removed without turning the computer off, like sata disks. E-sata is in between those two, for sure it is not system internal and technically it is not removable media according to udisks criteria too.

Currently Solid uses udisks' eject command to eject e-sata disks but since an e-sata disk is not removable media and the disk has not actually been removed (detached from the e-sata port) udisks signals that a new disk is available and kded remounts the disk right after the eject command succeeds (bug #277517).


We could use udisks' detach command instead of eject, but udisks seems to refuse to use it with devices with removable flag set to false, which is the case for e-sata disks. Anyway, sometimes we just want to unmount the partition but not turn the disk off, in that case udisks' detach command is inadequate since you will need to turn the disk off and on to use it again.

I think:  1. Solid should stop using udisks' eject command for e-sata partitions (/dev/sdb1, /dev/sdb2, etc) and use the umount command instead. 2. For the entire e-sata disk (/dev/sdb) we should use udisks' detach command, but that will only work when 3. someone fixes udisks to allow executing the detach command for all non system internal devices and not only for the removable ones.

We can do #1 right now. #2 requires some GUI to call the detach command, something that can be used in device notifier plasmoid. #3 is upstream bug :-/

When I have more time I will try to solve this, but for now I am busy and with a dead line approaching, so if someone wants to take the task to fix this problem feel free to do it.

Wednesday, March 30, 2011

E-sata, solid, and udisks


Last year I wrote about how to hack hal to recognise disks attached to an e-sata port as removable. Now that udisks is the default disk manager in Solid I will explain how to hack udisks to do the same:

  1. The hal hack is just a xml file that overrides disk's removable flag. With udisks things are a bit more complicated. I had to apply this patch to udisks and recompile it. The patch adds the flag UDISKS_FORCE_SYSTEM_INTERNAL, which lets us mark the disk as internal or external (AKA removable).
  2. Restart udisks. Just kill it and it will restart automatically: killall udisks-daemon # as root
  3. After that we need to add an udev rule which will actually mark the disk as removable:
  4. File /etc/udev/rules.d/99-esata.rules
    DEVPATH=="/devices/pci0000:00/0000:00:1f.2/host4/*", ENV{UDISKS_FORCE_SYSTEM_INTERNAL}="0"
    Change the DEVPATH to match your e-sata port. You can find it using the command:
    Code
    evolucao ~ # find /sys/devices/ -name sdb
    /sys/devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0/block/sdb
  5. Reload udev rules: udevadm control --reload-rules
That is it :-)

There is already a bug entry about the e-sata problem in udisks' bugzilla. In fact, I found the UDISKS_FORCE_SYSTEM_INTERNAL patch in that bug entry.

Tuesday, September 21, 2010

E-sata and Solid



Some days ago a guy asked in the kde-hardware-devel mailing list how to make disks connected to an e-sata port to behave like removable disk in KDE. I have a notebook (Sager np7652) with one e-sata port and had this problem too, but have never tried to fix that, until now. I think what I have found can help other people too so I am writing this post.

After some tries I found a way to tell hald that my disks' partitions come from a removable disk. That works but have an inconvinience, I needed to create one configuration file per partition. Some more tries and finally I got to configure hald to treat all disks connected to my e-sata controller as removable:

  1. Add this file to your system:

    File /etc/hal/fdi/policy/40-e-sata.fdi
    <?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->
    
    <deviceinfo version="0.2">
      <device>
        <match key="linux.sysfs_path" contains="/sys/devices/pci0000:00/0000:00:1f.2/host4/">
          <merge key="volume.ignore" type="bool">false</merge>
          <merge key="@block.storage_device:storage.removable" type="bool">true</merge>
        </match>
      </device>
    </deviceinfo>
    
  2. Change the contains part to match your e-sata controller's. You can find it using the command:
    Code
    evolucao ~ # find /sys/devices/ -name sdb
    /sys/devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0/block/sdb
    
  3. Restart hald: /etc/init.d/hald restart
  4. That's it :-)

The strange thing is that the file /sys/class/block/sdb/removable contains 0, it should contains 1 since the disk is removable. Maybe it is a kernel bug.

Hal is deprecated for some years now, KDE SC, more precisely Solid, is the only desktop/library that uses it extensively. When we, Solid metal-workers, finish Solid transition to udisk and upower probably hal is gonna vanish for ever.

In less than two weeks there will a Solid Sprint in Madri (Spain), I will be there :-), and we are going to discuss how far we are from the end of this transition. Honestly I like hal, it is flexible from users point of view. I have never used udisk and I do not know if it possible to workaround a problem in the kernel such as this one about disks connected to a e-sata controller using udisk. I hope it is.

Wednesday, August 18, 2010

Hotkey buttons and udev

As many notebooks out there mine has some hotkey buttons for (de)activate the wifi card, bluetooth controller, webcam, etc. With the buttons sometimes the notebook also has leds to indicate which hardware is activated at the moment, unfortunately my notebook only has leds for wifi and bluetooth, not for the webcam. More unfortunately yet the leds for wifi and bluetooth is the same led but with different color to indicate when only one of them are activated, but I must say Clevo, the manufacturer of my notebooks' barebone, did not make a good choice selecting the colors orange and green :-( It is very difficult to distinguish between the states wifi on / bluetooth off and wifi off / bluetooth on. Even the state wifi on / bluetooth on is not easy to notice. To minimize that problem I created some udev rules and some scripts to open a KDE notification dialog every time they are activated or deactivated. Everybody in Linux "world" must have heard of udev, the system daemon which receives events from the kernel and run programs or scripts based on rules storared in /etc/udev/rules.d or /lib/udev/rules.d. In my case I added my rules to /etc/udev/rules.d:
File /etc/udev/rules.d/50-lvs-rfkill.rules
SUBSYSTEM=="rfkill", RUN+="lvs-rfkill.sh"
File /etc/udev/rules.d/50-lvs-webcam.rules
# Change the idProduct and idVendor attributes to your camera's.
# Use lsusb to find them.
SUBSYSTEM=="video4linux", ATTRS{idProduct}=="0343", ATTRS{idVendor}=="5986", RUN+="lvs-webcam.sh"
Then run this to reload the rules:
Reload udev rules
udevadm control --reload-rules 
Now we need to create the scripts lvs-rfkill.sh and lvs-webcam.sh and give execution permission to them (chmod 755):
File /lib/udev/lvs-rfkill.sh
#!/bin/sh

find_display()
{
    if [ -r "/proc/$1/environ" ]
    then
        perl -ne 'if ( /DISPLAY=([^:]+){0,1}(:\d+)(.\d+){0,1}/ )
         { print "$1$2$3\n"; }' &lt; /proc/$1/environ
    fi

    return 0
}

user_loop()
{
    OLD_DISPLAY=$DISPLAY
    ps -C kwrapper -C kwrapper4 h -o pid,user | while read pid user
    do
        grep -q ksmserver /proc/$pid/cmdline &> /dev/null || continue
        export DISPLAY=$(find_display $pid)
        su - $user -c "$1"
    done
    export DISPLAY=$OLD_DISPLAY
    unset OLD_DISPLAY
    sleep 1
}

title=
msg=
case $RFKILL_TYPE in
    wlan)
        title="Wireless"

        case $ACTION in
            add|change)
                case $RFKILL_STATE in
                    0)
                        msg="Wireless disabled"
                    ;;
                        
                    1)
                        msg="Wireless enabled"
                    ;;

                    2)
                        msg="Wireless disabled by hardware"
                    ;;
                esac
            ;;

            remove)
                msg="Wireless disabled"
            ;;
        esac
    ;;

    bluetooth)
        title="Bluetooth"

        case $ACTION in
            add)
                msg="Bluetooth enabled"
                echo 1 > /sys/$DEVPATH/state
            ;;

            remove)
                msg="Bluetooth disabled"
            ;;
        esac
    ;;
esac

if [ "$msg" != "" ]
then
    user_loop "$(ls /usr/kde/*/bin/kdialog | tail -n 1) \
        --title \"$title\" --passivepopup \"$msg\" 3"
fi
File /lib/udev/lvs-webcam.sh
#!/bin/sh

find_display()
{
    if [ -r "/proc/$1/environ" ]
    then
        perl -ne 'if ( /DISPLAY=([^:]+){0,1}(:\d+)(.\d+){0,1}/ )
            { print "$1$2$3\n"; }' &lt; /proc/$1/environ
    fi

    return 0
}

user_loop()
{
    OLD_DISPLAY=$DISPLAY
    ps -C kwrapper -C kwrapper4 h -o pid,user | while read pid user
    do
        grep -q ksmserver /proc/$pid/cmdline &> /dev/null || continue
        export DISPLAY=$(find_display $pid)
        su - $user -c "$1"
    done
    export DISPLAY=$OLD_DISPLAY
    unset OLD_DISPLAY
    sleep 1
}

title="Webcam"
msg="Webcam"

case $ACTION in
    add)
        msg="$msg enabled"
    ;;

    remove)
        msg="$msg disabled"
    ;;
esac

user_loop "$(ls /usr/kde/*/bin/kdialog | tail -n 1) \
    --title \"$title\" --passivepopup \"$msg\" 3"
Now every time you turn wifi/bluetooth/webcam on/off a notification will appear near KDE's notification tray icon:

Wednesday, June 23, 2010

Sager NP7652: finally



Yesterday, I finally got my Sager NP7652 laptop (Clevo W765CUH barebone) in my hands. The LCD was replaced and there is no dead pixels (so far). I copied my Gentoo installation from my old Acer Ferrari 4005 to it to avoid the loooooong process of installing Gentoo from the begining, also because my Internet connection is slow and it would take almost a week to download the source code for all ebuilds. The configuration (click on the image to see it completely):





More info about this laptop on Xoticpc and Notebook Review.


TuxMobil - Linux on Laptops, Notebooks, PDAs and Mobile Phones

This report is listed at
TuxMobil - Linux compatibility guides for laptops, notebooks, PDAs, mobile phones and GPS devices.

ACPI

Battery
/proc/acpi/battery/BAT0/state does not show the "present rate", which prevents KDE's powerdevil to measure how much remaining time I still have. I had this problem with my Acer Ferrari 4005 too, a BIOS update solved the problem that time. Unfortunately Sager has discontinued this laptop, which was released less than six months ago, those notebook sellers must be kidding to discontinue a notebook so fast. So until I find a BIOS update to solve this problem I am using the kernel's CONFIG_ACPI_CUSTOM_DSDT feature to replace the BIOS's DSDT by one I have edited by hand. To use the new DSDT:

  1. Download it
  2. Enable  CONFIG_ACPI_CUSTOM_DSDT: make menu_config -> Power management and ACPI options -> ACPI (Advanced Configuration and Power Interface) Support -> Custom DSDT Table file to include. Select the downloaded file.
  3. Compile and install the new kernel.
  4. Reboot, that is it.

Here is the diff of the original DSDT.

Fans
The fans run at full speed since kernel boots up, but if you press the third hot key button (the one with a M surrounded by an elipse) the fans run quietly, this is called "silent mode". If you press it again the fans run at full speed again. OBS: the processor will *not* run at full power when in silent mode. OBS2: when using ATI proprietary drivers (ati-drivers ebuild) instead of the opensource drivers (xf86-video-ati ebuild) the fans run quietly.

Speedstep
Driver: acpi-cpufreq.ko.

I tried to use phc-intel to undervolt the CPU C-states but it did not work as expected. It seems this Core i7 620m CPU recognise the undervolt and automatically reduces CPU performance instead of allowing it to crash. Do not worry, the crash is part of the tweaking process to get the voltage values to configure the phc-intel module. I tried all values from 20 mW to 1 mV at 2667 MHz clock and the CPU did not crash but the performance decreased when compiling the kernel. Since this CPU has turbo mode capability I guess it is it that is automatically decreasing CPU performance to avoid the crash. The clock stayed at 2667 MHz, but compiling the kernel was much more slower using 1 mV than with 20 mW.

Suspend to Disk
I am using TuxOnIce for suspend to disk. To install it:

  • Apply the patch against the kernel.
  • Enable it  make menu_config -> Power management and ACPI options ->Enhanced Hibernation (TuxOnIce) -> File Allocator, Swap Allocator (if you have a swap partition), Userspace User Interface support and install the new kernel.
  • Install pm-utils ebuild/package: emerge -v pm-utils
  • Edit /etc/pm/config.d/gentoo and change the line with SLEEP_MODULE to SLEEP_MODULE="tuxonice". Now KDE's powerdevil plasmoid will use TuxOnIce to hibernate.

Sometimes some programs setfaults after resume (if one of them is the init program then system will crash). If I clean the swap space up (swapoff -a; swapon -a) before suspending then there is no segfault but that is damn slow if there several hundreds of MB in the swap file. Well, I tried a different approach and created a dedicated hibernate file that seems to also fix the problem and is pretty fast too, so do:

Configure Tux On Ice
# echo "TuxOnIce" > /hibernation-file
# dd if=/dev/zero bs=1M count=2048 >> /hibernation-file
# echo /hibernation-file > /sys/power/tuxonice/file/target
# cat /sys/power/tuxonice/resume
UUID=ea1d2e190cfe4901ac80645f47046980:0x56f8000

Change the resume kernel parameter to the new inode location:
Kernel parameter
resume=/dev/sda6:0x56f8000

Add the line below to /etc/hibernate/common.conf
/etc/hibernate/common.conf
ProcSetting file/target /hibernation-file


Bluetooth
Cambridge Silicon Radio bluetooth controller, driver: btusb.ko.

Card Reader
JMicron SD/MS Host controllers, Secure Digital driver: sdhci-pci.ko, Memory Stick driver: jmb38x_ms.ko. Tested with SD and MS PRO Duo cards. Not tested but should work as well: MS, MS PRO, MS Duo, Mini-SD, MMC and RS cards.

DVD Burning
Works as expected, at least when burning an iso image to a DVD-r media (8x speed).

Finger Print Reader
Works with fingerprint-gui 1.04, just execute the command below to avoid the error message "ABSOpen() failed -1086 (An internal error occurred (pt: tfmerr -1086).)":

mkdir -m700 /var/upek_data/

Hot Key Buttons
All buttons working:

  1. E-mail.
  2. Internet (Web Browser).
  3. Toggle Silient Mode (for power saving). When enabled, Silent Mode will reduce fan noise and save power consumption. Note this may reduce computer performance.

I have configured udev to make show a KDE notification when the wifi, bluetooth or webcam is activated / desactivated. You can do the same for the silent hot key button using khotkey section in KDE's systemsettings, no need to go for udev.

Modem
Does not work yet: Re: AW: agere softmodem HDA + Intel Ibex Peak High Definition Audio

Sata and e-Sata
Intel Ibex Peak 4 port SATA AHCI controller, driver ahci.ko. To compile the driver: make menu config -> Device Drivers ->  Serial ATA and Parallel ATA drivers ->  AHCI SATA support

This is what I do before switching my e-Sata HD off:

  1. umount all partitions.
  2. echo 1 > /sys/block/sdb/device/delete

When issuing the last command the following lines appears in dmesg:

[40049.014691] sd 4:0:0:0: [sdb] Synchronizing SCSI cache
[40049.014851] sd 4:0:0:0: [sdb] Stopping disk
[40049.341191] ata5.00: disabled



You configure hald and udisks to thread "e-sata" disks as removable. Udisks is the default disk manager in KDE SC 4.6.x, so it is preferable.

Sound Card
Intel Ibex Peak HDA sound card, driver: snd-hda-intel.ko. Playback and internal microphone tested with Skype, all working. I moved my old /etc/asound.conf to /etc/asound.ferrari, it is not needed anymore because this sound card multiplex audio streamings without dmix alsa plugin. I do not have any s/pdif receiver so I cannot test it.

Just a side note: when the power save mode is enabled (echo 1 > /sys/module/snd_hda_intel/parameters/power_save) every time you change the volumes with a mixer or some program starts to play something there is a short crack sound in the speakers. It sounds even when all volume channels are mute or using earphone. That is annoying, so I prefer to disable the power save mode (echo 0 > /sys/module/snd_hda_intel/parameters/power_save).

USB
Intel Ibex Peak EHCI controller, drivers: ehci-hcd.ko and uhci-hcd.ko.

Video
ATI HD4570 video card, driver: xf86-video-ati-6.13.0, firmware: radeon-ucode-20100408. Working with KMS+DRI2, Googleearth and Kwin's composite effects work together too!!!. To use the firmware enable make menuconfig -> Device Drivers -> Generic Driver Options -> Include in-kernel firmware blobs in kernel binary. Then type "radeon/R700_rlc.bin" in "External firmware blobs to build into the kernel binary", copy /lib/firmware/radeon/R700_rlc.bin to /usr/src/linux/firmware/radeon/ and compile the kernel.

Relevant ebuilds (packages) I am using:

  • kernel 2.6.33.4
  • xf86-video-ati-6.13.0
  • radeon-ucode-20100408
  • xorg-server-1.8.1-r1
  • mesa-7.8.2
  • libdrm-2.4.19

Proprietary Driver (fglrx.ko)
Using ati-drivers ebuild brings one big advantage: the GPU runs cooler and the fans run quieter (as quiet as in Windows 7). I think it also helps with battery time, but I have not measure it. That only works as long as Xorg is running, if you to go the console (Ctrl+Alt+F1) the GPU fans start to run at full speed. Going back to Xorg makes them run quiter again. The 3D performance is noticeably better with ati-drivers.

One disadvantage in using ati-drivers is that you have to disable KMS (kernel modsetting) and the radeon kernel module. Otherwise the LCD gets blank when Xorg starts and you will have to restart the notebook to restore the video card to the correct state. Using composite (3D effects) while playing movies usually makes the movie flicker. To solve that problem DRI2 and KMS were created but since we cannot use KMS with ati-drivers I thought I would have to disable the 3D effects when using mplayer. Fortunately there is no flicker :-). In my old notebook (Ferrari 4005, ATI x700 card) the flickering is very annoying. I still own the Ferrari 4005, anyone here wants to buy a Ferrari notebook? :-) The battery still holds 72% of the original manufacturer capacity (around 3400 mAh) and everything works in Linux, accept the svideo port and the card reader, which does not read SD cards anymore, but reads Memory Stick (weird, hugh?) It comes with a bluetooth mouse too.

Unfortunately several important aticonfig commands do not work with this card:

evolucao ~ # aticonfig --adapter=0 --od-getclocks --od-gettemperature
Adapter 0 - ATI Mobility Radeon HD 4500 Series
                            Core (MHz)    Memory (MHz)
           Current Clocks :    680           500
             Current Peak :    680           500
  Configurable Peak Range : [680-680]     [500-500]
                 GPU load :    0%
ERROR - Get temperature failed for Adapter 0 - ATI Mobility Radeon HD 4500 Series

GPU load always stays at 0% and the thermal sensors are not compatible with aticonfig. Everest in Windows 7 is able to get the GPU temperature. As you can also notice the GPU and Memory clocks cannot be changed.

VGA Port
Works as expected. KDE has this beautiful and effecient kcm module to configure multiple monitors and it works great with the ATI HD4570:


HDMI Port
Work as expected (both video and audio). You need to configure /etc/asound.conf to route audio to the sound card that the video card (ati 4570) registers or use pulseaudio.

Webcam
BisonCam NB Pro webcam, driver: uvcvideo.ko. To compile the driver: make menu config -> Device Drivers -> Multimedia support -> Video capture adapters -> V4L USB devices -> USB Video Class (UVC)

Wired Ethernet
JMicron JMC250 gigabit ethernet PCI-e, driver jme.ko. To compile the driver: make menu config -> Device Drivers -> Network device support ->  Ethernet (1000 Mbit) ->  JMicron(R) PCI-Express Gigabit Ethernet support

Wireless
Intel WiFi Link 6000, driver: iwlagn.ko, firmware: iwl6000-ucode-9.193.4.1.

Gentoo Specific
In /etc/make.conf:
  • CHOST="x86_64-pc-linux-gnu"
  • CFLAGS="-O2 -march=core2 -pipe -fomit-frame-pointer -msse3 -msse4 -mcx16 -mpopcnt -msahf"
  • LDFLAGS="${LDFLAGS} -Wl,-O1"
  • VIDEO_CARDS="vesa radeon"
  • ALSA_CARDS="snd-hda-intel usb-audio"
Symbolic link: /etc/make.profile -> ../usr/portage/profiles/default/linux/amd64/10.0/desktop/kde . It is ironic the fact that Gentoo use amd64 profile for an Intel processor.

    File /etc/modules.autoload.d/kernel-2.6
    microcode # for updating CPU's microcode
    acpi-cpufreq # for CPU frequency scaling
    cdc-acm # for my 3G modem
    fglrx # for the video card
    vboxdrv # for VirtualBox
    vboxnetflt # idem
    vboxnetadp # idem
    
    All other drivers are automaticaly loaded by udev during boot initialization. Except for fglrx.ko and the three VirtualBox drivers (vboxdrv.ko, vboxnetflt.ko, vboxnetadp.ko) all other drivers are included in the vanilla Linux kernel. fglrx.ko is compiled by the x11-drivers/ati-drivers ebuild and the three VirtualBox drivers are compiled by the app-emulation/virtualbox-modules ebuild

    Things yet to Test
    • Express card slot
    • Multi-gesture touchpad

    lspci output:
    00:00.0 Host bridge: Intel Corporation Arrandale DRAM Controller (rev 12)
    00:01.0 PCI bridge: Intel Corporation Arrandale PCI Express x16 Root Port (rev 12)
    00:16.0 Communication controller: Intel Corporation Ibex Peak HECI Controller (rev 06)
    00:1a.0 USB Controller: Intel Corporation Ibex Peak USB2 Enhanced Host Controller (rev 06)
    00:1b.0 Audio device: Intel Corporation Ibex Peak High Definition Audio (rev 06)
    00:1c.0 PCI bridge: Intel Corporation Ibex Peak PCI Express Root Port 1 (rev 06)
    00:1c.1 PCI bridge: Intel Corporation Ibex Peak PCI Express Root Port 2 (rev 06)
    00:1c.2 PCI bridge: Intel Corporation Ibex Peak PCI Express Root Port 3 (rev 06)
    00:1c.3 PCI bridge: Intel Corporation Ibex Peak PCI Express Root Port 4 (rev 06)
    00:1d.0 USB Controller: Intel Corporation Ibex Peak USB2 Enhanced Host Controller (rev 06)
    00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev a6)
    00:1f.0 ISA bridge: Intel Corporation Ibex Peak LPC Interface Controller (rev 06)
    00:1f.2 SATA controller: Intel Corporation Ibex Peak 4 port SATA AHCI Controller (rev 06)
    00:1f.3 SMBus: Intel Corporation Ibex Peak SMBus Controller (rev 06)
    02:00.0 VGA compatible controller: ATI Technologies Inc M92 [Mobility Radeon HD 4500 Series]
    02:00.1 Audio device: ATI Technologies Inc R700 Audio Device [Radeon HD 4000 Series]
    06:00.0 Network controller: Intel Corporation WiFi Link 6000 Series (rev 35)
    07:00.0 System peripheral: JMicron Technology Corp. SD/MMC Host Controller (rev 80)
    07:00.2 SD Host controller: JMicron Technology Corp. Standard SD Host Controller (rev 80)
    07:00.3 System peripheral: JMicron Technology Corp. MS Host Controller (rev 80)
    07:00.5 Ethernet controller: JMicron Technology Corp. JMC250 PCI Express Gigabit Ethernet (rev 03)
    ff:00.0 Host bridge: Intel Corporation QuickPath Architecture Generic Non-core Registers (rev 02)
    ff:00.1 Host bridge: Intel Corporation QuickPath Architecture System Address Decoder (rev 02)
    ff:02.0 Host bridge: Intel Corporation QPI Link 0 (rev 02)
    ff:02.1 Host bridge: Intel Corporation QPI Physical 0 (rev 02)
    ff:02.2 Host bridge: Intel Corporation Device 2d12 (rev 02)
    ff:02.3 Host bridge: Intel Corporation Device 2d13 (rev 02)

    lsusb output:
    Bus 002 Device 006: ID 5986:0343 Acer, Inc -> webcam
    Bus 002 Device 003: ID 147e:1000 Upek -> fingerprint reader
    Bus 002 Device 002: ID 8087:0020 
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
    Bus 001 Device 003: ID 03eb:0902 Atmel Corp. 4-Port Hub
    Bus 001 Device 002: ID 8087:0020 
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

    Saturday, March 27, 2010

    Sager NP7652

    My new notebook/laptop has arrived yesterday, unfortunately with one stuck pixel :-((((((((((((((((((((((((((((((((((((((((((((((((((((((( I have searched for ways to fix it, tried some things and it seems to be fixed now. The notebook is turned off now and I am using my old notebook (Acer Ferrari 4005). Honestly, I am with fear to turn the notebook on and see the dead pixel revived from the dead (or it would be from the living :-/). When I feel more relieved for solving this problem once and for all I will write a review/howto about how Gentoo Linux run on it. Update: as I feared when I turn the notebook on the stuck pixel is there again :-((((((((((((((((((((((((((((((((( Update2: today I have left the notebook to be sent back to Sager to replace the LCD, I do not stand that bright/stuck pixel. Let's see if Sager support is better than their quality control.

    Meu novo notebook/laptop chegou ontem, infelizmente, com um stuck pixel :-((((((((((((((((((((((((((((((((((((((((((((((((((((((( Fiquei um tempão procurando maneiras para corrigí-o, tentei algumas coisas e parece estar consertado agora. O notebook está desligado agora e estou usando meu antigo notebook (Acer Ferrari 4005). Honestamente, estou com medo de ligar o notebook e ver o dead pixel ressuscitado dentre os mortos (ou seria dentre os vivos :-/). Quanto estiver mais aliviado em resolver esse problema de uma vez por todas vou escrever uma avaliação/howto sobre como o Gentoo Linux roda nele. Atualização: como eu temia quanto eu ligo o notebook o stuck pixel está lá novamente :-(((((((((((((((((((((((((((((((((( Atualização 2: hoje eu dexei o notebook para ser enviado de volta para a Sager para trocar o LCD, eu não suporto aquele pixel brilhante. Vamos ver se o suporte da Sager é melhor do que o controle de qualidade deles.

    Sunday, February 14, 2010

    Notebook cooler (2)

    The Cooler Master R9-NBC-BWCB-GP has arrived today. Well, it does not cool as good I hoped, but at least it has a extra USB port, which is helpfull. Here in Minas Gerais is very hot these days, my room at afternoon is about 30 to 32 degrees Celsius. My notebook's hard drive stay at 45C in with this notebook cooler. Unfortunately the hard drive and south bridge of my notebook are in the front, where R9-NBC-BWCB-GP is less effective, so I put my notebook as above as possible so the air flux hit the hard drive, it works better this way. I am using a external keyboard, if I would use the notebook at that position and the R9-NBC-BWCB-GP on my lap I would risk let the notebook drop to the floor. I think there must be better notebook coolers out there, this one is the second I have bought and I am not satisfied yet.

    O ooler Master R9-NBC-BWCB-GP chegou hoje. Bem, ele não esfria tanto quanto gostaria, mas pelo menos ele tem uma porta extra, o que é útil. Aqui em Minas Gerais está muito quente estes dias, meu quarto à tarde fica entre 30 e 32 graus Celsius. O HD do meu notebook fica em 45C com este notebook cooler. Infelizmente o disco rígido e o south bridge do meu notebook ficam na parte da frente, onde o R9-NBC-BWCB-GP é menos eficiente, então eu coloquei o notebook mais pra cima para que o fluxo de ar atinja o HD, ele funciona melhor assim. Eu usando um teclado externo, se eu usar o notebook nesta posição com o R9-NBC-BWCB-GP no colo eu arriscaria deixar o notebook cair no chão. Eu acho que deve haver notebook coolers melhores por aí, este é o segundo que eu compro e ainda não estou satisfeito.

    Tuesday, February 9, 2010

    Notebook cooler

    I have ordered one of those Cooler Master R9-NBC-BWCB-GP notebook cooler. I was given very good review on Amazon. Let's see if it really deserves the good reputation. It will probably arrive here next Saturday or Monday (if the Carnival does not make it to get late).

    Comprei um desses notebook cooler R9-NBC-BWCB-GP da Cooler Master. Ele teve boas recomendações no site da Amazon. Vamos ver se ele realmente merece a boa reputação. Ele deverá chegar aqui no próximo sábado ou segunda (isso se o Carnaval não atrasar a entrega).

    Friday, February 5, 2010

    Future Acquisition / Futura Aquisição: SAGER NP7652

    Very interesting this new Sager NP7652 notebook. It has almost all those things I like in my current notebook (Acer Ferrari 4005) and very good price. The only things I would lose compared to F4005 would be: one less USB port, one less speed button, no expansion port, no DVI, no S-video, no infra-red and no fireware ports. Well, I would only miss the USB and S-video ports, the other ones are not that usefull anyway (I have never used the expansion and firewire ports, and have used the DVI and infra-red only for testing). I just would like to have the option to buy faster memory (1066 MHz is good, but I would like to buy 1333 MHz instead). In the future I will probably buy a USB 3.0 express card to have two more USB ports. More info about this notebook, including videos and benchmarks.

    Muito interessante este novo notebook Sager NP7652. Ele tem quase todas as coisas que eu gosto no meu notebook atual (Acer Ferrari 4005) e um ótimo preco. As únicas coisas que eu perderia comparado com o F4005 seriam: uma porta USB a menos, um botão de atalho a menos e portas de expansão, DVI, S-video, infra-vermelho e firewire. Bem, I sentiria falta das portas USB e S-vide, as outras nem tanto (nunca usei as portas de expansão e firewire, e só usei DVI e infra-vermelho para testes). Gostaria de ter a opção de comprar memórias mais rápidas (1066 MHz é bom mas gostaria de comprar 1333 MHz). No futuro devo comprar um cartão express USB 3.0 para ter duas portas USB a mais. Mais informações sobre esse notebook, includindo vídeos e avaliações de desempenho.

    ATI/AMD x700 + KMS + DRI2

    Hi all, a new blog today (after almost a year hehe). Yesterday I tried to make KMS work in my notebook (Ferrari 4005), it is a old notebook but I like it a lot, it has some neat things in there. For those that do not know what KMS is read this. In short KMS is a new graphical infra-estructure for Linux kernel that solves the ethernal conflicts betweewn kernel's graphical drivers (be it text mode driver, framebuffer vesa driver or framebuffer chipset specific driver) and Xorg's drivers. Whoever used the Ctrl+Alt+Fx key combination in Xorg knows that there is a delay when changing from Xorg to text mode, with KMS that today is gone and the graphical driver is, in theory, much less sucetible to problems. Well, I followed the instruction in here and now I have KMS working with my x700 video card (rv410 chipset) :-) and it works really great :-)) One of the bonus of using KMS is that is also solves the conflicts between DRI2 and composite effects (like the famous Cube Effect), which means that I can use composite effects and Googleearth together, that one is the main reason I configured KMS in my notebook. I also had to apply those two patches to solve a problem with suspend (tuxonice).

    Olá a todos, um novo blog hoje (depois de quase um ano hehe). Ontem eu tentei fazer o KMS funcionar no meu notebook (Ferrari 405), é um notebook antigo mas eu gosto muito dele, ele tem umas coisas bem arrumadinhas nele. Pra quem não sabe o que é KMS leia isso. Resumindo, KMS é uma infra-estrutura de vídeo para o kernel do Linux que resolve o eterno conflitos entre os drivers gráficos do kernel (seja o driver modo texto, o driver vesa de framebuffer ou o driver de framebuffer específico de cada chipset) e o driver de vídeo do Xorg. Quem já usou a combinação de teclas Ctrl+Alt+Fx no Xorg sabe que existe um atraso quando se muda do Xorg para o modo texto, com o KMS não existe mais atraso e o driver gráfico é, em teoria, muito menos sucestível a problemas. Bem, eu segui as instruções daqui e agora eu tenho o KMS funcionando com a minha placa de vídeo x700 (chipset rv410) :-) e funciona muito bem :-)) Um dos bonus de usar o KMS é que ele também resolve os conflitos entre o DRI2 e os efeitos composite (como o famoso efeito de Cubo), o que significa que eu agora eu posso usar os efeitos composite junto com o Googleearth, aliás essa é a razão principal de eu ter configurado o KMS no meu notebook. Também tive que aplicar esses dois patches para resolver um problem com o suspend (tuxonice).