photo of Macallan

Rants & Ramblings

Some more Gdium support

,

Backlight control now works as expected - not just on and off, and the hotkeys work everywhere, not just in X.
Controlling the backlight level is kinda funky - on other graphics chips there is usually a register somewhere near the other flat panel interface registers, you poke an 8 bit value into which may or may not be linear ( Rage 128 is like that for example ). On Gdium it isn't quite that easy. The SM502 has a bunch of GPIO pins which can be used as plain old on-and-off GPIOs or other things, like serial interfaces, flat panel interfaces, i2c buses and so on. Three of them can be run as Pulse Width Modulation outputs, and one of those controls the backlight level. This has the following advantages:
  • on/off is simple - run the output as GPIO and simply turn it on and off with a write to the appropriated GPIO_DATA register.
  • no dedicated backlight control hardware ( don't need it if you don't use a flat panel )

It makes backlight control a little bit more complicated. It works like this: there's a 96MHz clock, a power-of-two divider and two counters - one defines how many clock cycles the output should remain high or low respectively. A side effect is that you can't get all on or all off that way - it has to be at least one cycle on and one cycle off, so these have to be special cased and handled by switching to GPIO mode. Otherwise, brightness is controlled by feeding the PWM output to the backlight with a capacitor to smooth it out, you get any given level by programming the PWM to output ~20kHz and adjust the duty cycle according to the level you want.
With this, backlight control works properly.
The hotkeys required more hackery to work though - the Fn key is not handled by the keyboard controller at all, it's not even reported as a modifier - it's Just Another Key. OpenBSD just added a special keycode translation hook which seems redundant given that we already have code in place to handle the Fn key on some newer Apple laptops. What I ended up doing is to recycle as much code from the Apple keyboard hack, catch the Fn key before translation, use a special translation table if Fn is down. While there I also added code to translate USB keycodes directly to PMF events, that way the hotkeys work everywhere. I had to make the code optional since there is no easy way to detect a Gdium keyboard from the ukbd driver's point of view - the keyboard controller is a generic Cypress part, just going by the CPU class we're running on seems wrong since there is nothing which prevents other MIPS or even Loongson boxes from using the same keyboard controller.

Gdium supportMisguided attempts on saving money and How Not To Do Things

Write a comment

New comments have been disabled for this post.