From 2050ed82475d79bd4be5a31805ada0987e585951 Mon Sep 17 00:00:00 2001 From: skeezix Date: Wed, 18 Feb 2009 09:34:45 -0500 Subject: [PATCH] Added pnd_device.[ch] with basic clock setting support --- include/pnd_device.h | 16 +++++++++++++--- lib/pnd_device.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 lib/pnd_device.c diff --git a/include/pnd_device.h b/include/pnd_device.h index 6b05577..87fd6f1 100644 --- a/include/pnd_device.h +++ b/include/pnd_device.h @@ -9,9 +9,19 @@ extern "C" { // do we have a 'minimal' lib yet anywhere formalized? if not, we could // attempt to include it here. -// set clock speed - -// set LED on +// for reference material, see the Pandora wiki. Specifically, some good +// places to look: +// http://pandorawiki.org/Kernel_interface + +/* overall clock speed + * WARN: No boundaries are checked, so try to avoid setting clock to 2GHz :) + * NOTE: get-clock() is not implemented yet. + */ +#define PND_DEVICE_PROC_CLOCK "/proc/pandora/cpu_mhz_max" +unsigned char pnd_device_set_clock ( unsigned int c ); // returns >0 on success +unsigned int pnd_device_get_clock ( void ); // not implemented, returns 0 + +// set one or more LEDs on // suspend/hibernate/etc diff --git a/lib/pnd_device.c b/lib/pnd_device.c new file mode 100644 index 0000000..dc2fecc --- /dev/null +++ b/lib/pnd_device.c @@ -0,0 +1,34 @@ + +#include /* for FILE etc */ +#include /* for malloc */ +#include + +#include /* for open */ +#include +#include +#include + +#include "pnd_device.h" + +unsigned char pnd_device_set_clock ( unsigned int c ) { + char buffer [ 100 ]; + int f; + + sprint ( buffer, "%u", c ); + + if ( ( f = open ( PND_DEVICE_PROC_CLOCK, O_RDONLY ) ) < 0 ) { + return ( 0 ); + } + + if ( write ( f, buffer, strlen ( buffer ) ) < strlen ( buffer ) ) { + return ( 0 ); + } + + close ( f ); + + return ( 1 ); +} + +unsigned int pnd_device_get_clock ( void ) { + return ( 0 ); +} -- 2.39.2