Kernel interface
Warning: this is preliminary and is subject to change until release.
In case you need to write low level code (you can't/don't want to use high level libs like SDL), you can use kernel interface. This is the recommended way to access hardware (as opposed to GP2X style of accessing chip registers by mmap'ing /dev/mem), because in case hardware changes are needed in future, they could be handled by kernel and all programs would still work. It also should allow several programs to work at the same time and should be more stable.
Contents
Input
Buttons, keypad, touchscreen and nubs are all exposed through Linux event interface (EVDEV). All devices are represented by /dev/input/eventX files, which can be opened, read end queried (using ioctl calls). The reads can be synchronous (the read will only return when user does something, like presses the button), or asynchronous (the system will report what changed since the last time you asked).
Warning: don't hardcode device filenames in your program! For example, currently /dev/input/event2 represents game buttons, but in future it may become touchscreen. Scan input device names instead, example:
for (i = 0; 1; i++)
{
sprintf(name, "/dev/input/event%i", i);
fd = open(name, O_RDONLY);
if (fd < 0) break; /* no more devices */
ioctl(fd, EVIOCGNAME(sizeof(name)), name);
if (strcmp(name, "gpio-keys") == 0)
return fd; /* found the buttons! */
close(fd); /* we don't need this device */
}
List of device names:
name | description |
---|---|
omap_twl4030keypad | keypad |
gpio-keys | game buttons |
ADS784x Touchscreen | touchscreen |
vsense66 | left nub |
vsense67 | right nub |
Sample code: evtest.c pnd_test_inputs.c
Touchscreen
Event interface returns uncalibrated values directly from driver, so you need to use tslib or manage calibration yourself (using data from /etc/pointercal).
Sound
Pandora uses ALSA, but it has OSS emulation enabled too, so GP2X code should work.
Video
Framebuffer device (/dev/fb0) is supported. More to come..
Misc
Some things can be controlled through files in /proc/pandora/:
- /proc/pandora/cpu_mhz_max - if cpufreq is enabled, sets maximum allowed cpu clock, if not, just sets CPU clock to value supplied (echo 600 > /proc/pandora/cpu_mhz_max).
- /proc/pandora/wait_vsync - if you read this file, your process will block until next vsync interrupt (note: this might change to fbdev ioctl).
more to come..