gnome-power-manager and blanking (removal of bodges)

I’ve been working with the xorg people upstream, trying to sort out all the remaining blanking problems properly, rather than just working around the problem. I’ll explain the key issues:

gnome-power-manager uses a counter inside Xorg called IDLETIME. This counter is incremented only when the user does not move the mouse, or click some keys. When the user clicks something, the IDLECOUNTER is reset. Unfortunately, the IDLETIME counter was also being reset (in two places!) when the DPMS level is set. Now, this doesn’t affect most users of IDLETIME, as the screen doesn’t blank that often. For the most part, IDLETIME was a welcome addition to the X server.

For gnome-power-manager, we set up a XSync alarm for IDLE counter being over a certain value, and then we set up a XSync alarm for the IDLE counter being reset. When the alarm goes off we wait the policy time for the “display sleep” and then turn off the panel using DPMS. Which then resets the idletime, which turns the panel back on. Urgh.

So, what we do is handle the reset event, and if the event is less than a few milliseconds since we did a DPMS action, we ignore the alarm. Of course, if we ignore the alarm, then we don’t get the reset event when the user moves the mouse and the IDLECOUNTER gets reset. So, in this case, gnome-power-manager sets up a 1ms timeout when we detect an alarm a small time since a DPMS event. This triggers almost immediately, and so we get the alarm fired practically straight away.

Except, due to another X bug, if we set an alarm value on the timer that’s already been passed, we don’t get the alarm fired. So, if you’ve got a high load value, or a slow system, you could miss the alarm. So, we had to raise the bodge alarm value to 50ms, rather than 1ms. Urgh.

But then, there’s a nice 50ms race between the two timers, and 50ms is a small amount of time in human terms, right? No. When the user is reading something, and the display blanks, most users move the mouse pretty much straight away. If you hit this 50ms race (which some people seem able to do, me included) then gnome-power-manager misses the reset event, and if configured to do so, gnome-power-manager will still think your idle, and then go on to suspend your system. Urgh.

So, the only way to fix gnome-power-manager and remove all these ugly kludges would be to fix the xserver. I’ve sent two patches to xorg-devel which remove the IDLECOUNTER reset when DPMS off is sent. The second upstream patch is here.

So, I’ll remove the kludges from gnome-power-manager git master today and will depend on a runtime version of the xserver that has these patches applied. If you are trying to run gnome-power-manager with a broken version of X, gnome-power-manager will warn you in the notification area. Distributors will just need to patch xserver with my previous patch and the current one to have all the issues resolved with git master.

edit: updated with links to the signed off patches in xserver!

Blanking in gnome-power-manager (fixed!)

So, Peter Hutterer is my new best friend. Peter has found and patched the bug in the X server that was causing the failure of negative transition triggers in XSync. For you and me, that means that XIDLETIME now works as expected, and gnome-session and gnome-power-manager do the right thing. This means no more random blanking when typing.

There’s a pending Fedora 11 update here and a build for rawhide here — it should be tagged for F12alpha, but no promises at this stage.

The important patch for the xserver is here and I urge all distros to cherry-pick this commit into their stable branch, as this affects a lot of users. Hopefully this is the end to the saga of accidental screen blanking.

GtkPlug, and browser plugins

Anyone familiar with GtkPlug? I’m having issues with the PackageKit XEmbed browser plugin — unless I set the sizes for the widgets using gtk_widget_set_size_request, or set the widgets to expand to all the space, I get widgets with close to zero width and height:

The line across the widget is meant to be a GtkButton! Ideas welcome, and experts rewarded by beer! If anyone has examples of how to do a browser plugin with GTK controls, that would be great too. Thanks!

Firefox plugin woes

The PackageKit browser plugin hasn’t had a lot of love recently. It was written in C++ a few months ago by Owen, but started to bitrot over the last few xulrunner releases.

I’ve spruced up the code, and ported everything to C (using GObject where possible) and now it all seems to work with one exception: invalidaterect doesn’t seem to work where I think it’s supposed to.

I’m setting up the plugin with some default content, which gets shown to the screen. I’m then doing a PackageKit query, and a few ms later I get the results. I then update some internal state, and call the invalidaterect for the whole drawing area, expecting a GraphicsExpose event to render the new content. But alas, invalidaterect seems to do nothing.

I’ve even tried adding a forceredraw call after invalidaterect, but that also gets ignored. If I manually resize the epiphany/firefox window then the GraphicsExpose event gets called, and the plugin then shows the correct state. This is a windowless plugin and nsplugginwrapper has been removed, and so I think I’m doing everything by the book, so to speak. Help welcomed, and anyone pointing out the bug will be rewarded with a beverage of your choice. Code is here. Thanks.

Updating shared libraries

I want to add functionality to PackageKit to detect when a new version of a shared library is installed, and there are applications still using the old version that no longer exists. We can then inform the user if they need to restart the computer or log off and back on if the library was updated for a security vulnerability.

Does anyone have any example code (preferably written in C, although I’m not that bothered) that I could use? I think this would be quite nice functionality in future versions of PackageKit.

Thanks.

HALectomy of gnome-power-manager complete

This morning I committed a rather largish (23 files changed, 28 insertions, 1551 deletions) patch:

commit f884a1ae954d14928a6a7055d4d4b182fbb2a3bc
Author: Richard Hughes <richard_at_hughsie.com>
Date:   Fri Jul 3 13:49:05 2009 +0100
    HAL is no longer a dependency of gnome-power-manager

This means that gnome power manager in git master no longer needs HAL to compile or run. This is a quite a significant moment, as now it relies just on the thriving DeviceKit* stack, rather than the old lumbering HAL.

Just a word of warning: You’ll need DeviceKit-power 009 (released in a few days time) if you want to use g-p-m in git master without loosing your ability to change your backlight, or to set the lid action preferences. It’ll still compile with 008, but 009 is very much recommended.

Dell Mini 10v and the touchpad of death

The Dell Mini 10v does have a very nice keyboard. But then it also has a very bad mousepad. The buttons are actually on the trackpad, so if you click you end up moving, or if you’re dragging you end up shooting across the screen. Pain.

Anyway, there’s a fairly nice workaround by setting the System->Preferences->Mouse values to “Scrolling: disabled” and enabling “Mouse clicks with the touchpad“. All you have to do then is remember not to click the physical buttons, but tap instead. Not perfect, but saves you wanting to hurt someone. Bug for a proper fix is filed here.

Dell Mini 10 and BCM4312

I’ve just been bought a Dell Mini 10 by my employer, Red Hat.

I’ve wiped Ubuntu, and installed Fedora 11 on the machine, as it’s what I’m familiar with, and the kernel seems to be a bit more up to date than what it came with. Kudos to Dell for shipping with any Linux, I’m sure most people don’t care that much what “version” of Linx they are using.

Now, the interesting part: most stuff “just works”. The screen is fantastic, the keyboard is pretty good considering it’s so small, and the backlight seems to DTRT. It also weighs about one thousandths of a gram, or something in that order or magnitude.

Now, what doesn’t work: the Broadcom BCM4312 network device. Now, somebody has reversed engineered the Broadcom hardware and has published really good specs about the 43xx hardware, and the 4312 is no exception. The 4312 seems to be a LP PHY, so a little different than what the kernel knows about already. There’s already enough code in the wireless-testing kernel tree thanks to Michael Buesch (but EXPERIMENTAL and BROKEN) to get the chip operational, and recognised by NetworkManager, by alas, 95% of the setup code is needs to be written.

Now, all it would take is for a couple of expert network hackers to take the spec, and implement the engine setup in a few days of hacking. Unfortunately for me, I’m no network hacker, and am crazy busy with PackageKit/DeviceKit/PolicyKit work. That said, if no-one steps up to the mark in the next few weeks, I’ll have a go and submit some patches.

There’s also the firmware issue. Using b43-fwcutter I can get working firmware, but this doesn’t feel very “Fedora” as you have to use the Windows non-free driver and cut the binary data from it. I’ve tried to push through the open firmware package into Fedora, but this only supports a few of the older Broadcom cards. It wouldn’t take much to add support for the newer cards, although that’s probably a task for someone very familiar with the hardware, like for instance, Broadcom.

Now, Broadcom, I’m sure the open source community would really appreciate an engineer-day per week (I guess circa $12,000pa plus some good PR) for the open drivers and firmware. If that were to happen, and Linux support for Broadcom networking goes from 10% done to 90% done, I’m sure a whole lot more vendors would ship with your hardware inside. Whether or not that would translate to greater than $12k’s extra profit is left as an exercise for the reader.

For me, so the notebook is at least useful, I’ve replaced the Broadcom card with an Intel 5100AGN mini PCIe half height card with free drivers and distributable firmware. It cost £10, brand new.

I’ll still be testing the Broadcom free b43 driver, and hopefully be hacking on b43 in a few weeks if nobody beats me to it and my TODO list reduces in size.

edit: I’ve been informed the specs are not by Broadcom, they are reversed engineered. Wow.

abrt and pk-debuginfo-install

Recently I’ve been looking at the abrt project. It’s looking pretty good so far, with one notable exception: Currently they install the debugging packages using the Fedora script debuginfo-install, and scrape the standard out for errors, and inject to standard in an unconditional ‘Y’ to anything that looks like a question. The script is also used by gdb to ask the user to install certain debuginfo packages. It’s not great form to ask the user to run a random command, when the program is more than capable.

Program received signal SIGINT, Interrupt.
0x00a63422 in __kernel_vsyscall ()
Missing separate debuginfos, use: debuginfo-install DeviceKit-003-1.i586 DeviceKit-power-009-0.74.20090628git.fc11.i586 GConf2-2.26.2-1.fc11.i586

Now, some explaining. Fedora stores debuginfo packages in separate debuginfo repositories. This means the install-debuginfo script has to enable sources, get the deps of the packages to install, and install as many of the debuginfo packages as it can find, and then disable the sources it enabled. This is all horribly Fedora specific, and of course has to be done as root.

[hughsie@hughsie-laptop src]$ debuginfo-install DeviceKit-003-1.i586 DeviceKit-power-009-0.74.20090628git.fc11.i586 GConf2-2.26.2-1.fc11.i586
You must be root to run this command.

For a cool trick, I’ve make a PackageKit version of this script, called pk-install-debuginfo. It does exactly the same thing as the Fedora debuginfo-install script, but runs as the user and uses all the PK methods underneath the hood. So in theory pk-install-debuginfo would run on Kubuntu or on Foresight (or the others too) with a little tweaking.

[hughsie@hughsie-laptop ~]$ pk-debuginfo-install DeviceKit-003-1.i586
1. Getting sources list...OK. Found 10 enabled and 29 disabled sources.
2. Finding debugging sources...OK. Found 4 disabled debuginfo repos.
3. Enabling debugging sources...OK. Enabled 4 debugging sources.
4. Finding debugging packages...OK. Found 1 packages:
5. Finding packages that depend on these packages...OK. No extra packages required.
Found 1 packages to install:
1    DeviceKit-debuginfo-003-1(i586)    fedora-debuginfo
6. Installing packages...OK.
7. Disabling sources previously enabled...OK. Disabled 4 debugging sources.

Except it won’t, as other distros do things differently. I’m guessing some store the debuginfo files in the main repositories (and hence no sources need to be enabled), and some others call the files -dbg rather than -debuginfo. So now I need your help. If your distro does things differently from the Fedora way, please tell me how, and I’ll add support for it in pk-install-debuginfo.

Of course, if the sources are signed and no repos need to be enabled, then things just install without authentication. This is how it’s supposed to work. I’ve also added a man page and I’ll be adding a config file for pk-install-debuginfo soon.

Of course, if you don’t like the idea, just pass –disable-debuginfo-install to the configure script when compiling PackageKit. Comments welcome.