summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Side-by-side diff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie/odevice.cpp61
1 files changed, 58 insertions, 3 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index f808960..4b5a54e 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -51,48 +51,49 @@
#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
using namespace Opie;
class ODeviceData {
public:
QString m_vendorstr;
OVendor m_vendor;
QString m_modelstr;
OModel m_model;
QString m_systemstr;
OSystem m_system;
QString m_sysverstr;
Transformation m_rotation;
ODirection m_direction;
QValueList <ODeviceButton> *m_buttons;
uint m_holdtime;
+ QStrList *m_cpu_frequencies;
};
class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
protected:
virtual void init ( );
virtual void initButtons ( );
public:
virtual bool setSoftSuspend ( bool soft );
virtual bool setDisplayBrightness ( int b );
virtual int displayBrightnessResolution ( ) const;
virtual void alarmSound ( );
virtual QValueList <OLed> ledList ( ) const;
virtual QValueList <OLedState> ledStateList ( OLed led ) const;
virtual OLedState ledState ( OLed led ) const;
virtual bool setLedState ( OLed led, OLedState st );
virtual bool hasLightSensor ( ) const;
virtual int readLightSensor ( );
virtual int lightSensorResolution ( ) const;
@@ -402,48 +403,49 @@ ODevice *ODevice::inst ( )
/**************************************************
*
* common
*
**************************************************/
ODevice::ODevice ( )
{
d = new ODeviceData;
d-> m_modelstr = "Unknown";
d-> m_model = Model_Unknown;
d-> m_vendorstr = "Unknown";
d-> m_vendor = Vendor_Unknown;
d-> m_systemstr = "Unknown";
d-> m_system = System_Unknown;
d-> m_sysverstr = "0.0";
d-> m_rotation = Rot0;
d-> m_direction = CW;
d-> m_holdtime = 1000; // 1000ms
d-> m_buttons = 0;
+ d-> m_cpu_frequencies = new QStrList;
}
void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
{
if ( msg == "deviceButtonMappingChanged()" ) {
reloadButtonMapping ( );
}
}
void ODevice::init ( )
{
}
/**
* This method initialises the button mapping
*/
void ODevice::initButtons ( )
{
if ( d-> m_buttons )
return;
// Simulation uses iPAQ 3660 device buttons
qDebug ( "init Buttons" );
@@ -752,48 +754,88 @@ bool ODevice::setLedState ( OLed which, OLedState st )
* @return if the device has a light sensor
*/
bool ODevice::hasLightSensor ( ) const
{
return false;
}
/**
* @return a value from the light senso
*/
int ODevice::readLightSensor ( )
{
return -1;
}
/**
* @return the light sensor resolution whatever that is ;)
*/
int ODevice::lightSensorResolution ( ) const
{
return 0;
}
/**
+ * @return a list with valid CPU frequency
+ */
+QStrList &ODevice::cpuFrequencies ( ) const
+{
+qWarning("ODevice::cpuFrequencies: m_cpu_frequencies is %d", (int) d->m_cpu_frequencies);
+ return *d->m_cpu_frequencies;
+}
+
+
+/**
+ * Set desired cpu frequency
+ *
+ * @param index index into d->m_cpu_frequencies of the frequency to be set
+ */
+bool ODevice::setCpuFrequency(uint index)
+{
+ if (index >= d->m_cpu_frequencies->count())
+ return false;
+
+ char *freq = d->m_cpu_frequencies->at(index);
+ qWarning("set freq to %s", freq);
+
+ //TODO: do the change in /proc/sys/cpu/0/speed
+
+ return false;
+}
+
+/**
+ * Returns current frequency index out of d->m_cpu_frequencies
+ */
+uint ODevice::cpuFrequency() const
+{
+ // TODO: get freq from /proc/sys/cpu/0/speed and return index
+
+ return 0;
+}
+
+
+
+/**
* @return a list of hardware buttons
*/
const QValueList <ODeviceButton> &ODevice::buttons ( )
{
initButtons ( );
return *d-> m_buttons;
}
/**
* @return The amount of time that would count as a hold
*/
uint ODevice::buttonHoldTime ( ) const
{
return d-> m_holdtime;
}
/**
* This method return a ODeviceButton for a key code
* or 0 if no special hardware button is available for the device
*
* @return The devicebutton or 0l
* @see ODeviceButton
*/
@@ -1929,48 +1971,53 @@ void Ramses::init()
d->m_vendor = Vendor_MundN;
QFile f("/proc/sys/board/ramses");
d->m_modelstr = "Ramses";
d->m_model = Model_Ramses_MNCI;
d->m_rotation = Rot0;
d->m_holdtime = 1000;
f.setName("/etc/oz_version");
if (f.open(IO_ReadOnly)) {
d->m_systemstr = "OpenEmbedded/Ramses";
d->m_system = System_OpenZaurus;
QTextStream ts(&f);
ts.setDevice(&f);
d->m_sysverstr = ts.readLine();
f.close();
}
m_power_timer = 0;
+qWarning("adding freq");
+ d->m_cpu_frequencies->append("100");
+ d->m_cpu_frequencies->append("200");
+ d->m_cpu_frequencies->append("300");
+ d->m_cpu_frequencies->append("400");
}
bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
{
Q_UNUSED( keycode );
Q_UNUSED( modifiers );
Q_UNUSED( isPress );
Q_UNUSED( autoRepeat );
return false;
}
void Ramses::timerEvent(QTimerEvent *)
{
killTimer(m_power_timer);
m_power_timer = 0;
QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
}
bool Ramses::setSoftSuspend(bool soft)
{
qDebug("Ramses::setSoftSuspend(%d)", soft);
#if 0
@@ -1989,96 +2036,104 @@ bool Ramses::setSoftSuspend(bool soft)
sources |= APM_EVT_POWER_BUTTON;
if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
res = true;
else
perror("APM_IOCGEVTSRC");
}
else
perror("APM_IOCGEVTSRC");
::close(fd);
}
else
perror("/dev/apm_bios or /dev/misc/apm_bios");
return res;
#else
return true;
#endif
}
bool Ramses::suspend ( )
{
qDebug("Ramses::suspend");
+ return false;
}
/**
* This sets the display on or off
*/
bool Ramses::setDisplayStatus(bool on)
{
qDebug("Ramses::setDisplayStatus(%d)", on);
#if 0
bool res = false;
int fd;
if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
::close(fd);
}
return res;
#else
return true;
#endif
}
/*
* We get something between 0..255 into us
*/
bool Ramses::setDisplayBrightness(int bright)
{
qDebug("Ramses::setDisplayBrightness(%d)", bright);
bool res = false;
int fd;
// pwm1 brighness: 20 steps 500..0 (dunkel->hell)
if (bright > 255 )
bright = 255;
if (bright < 0)
bright = 0;
- bright = 500-(bright * 500 / 255);
+ // Turn backlight completely off
+ if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
+ char writeCommand[10];
+ const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
+ res = (::write(fd, writeCommand, count) != -1);
+ ::close(fd);
+ }
+
+ // scale backlight brightness to hardware
+ bright = 500-(bright * 500 / 255);
if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
qDebug(" %d -> pwm1", bright);
char writeCommand[100];
const int count = sprintf(writeCommand, "%d\n", bright);
res = (::write(fd, writeCommand, count) != -1);
::close(fd);
- } else {
- qWarning("no write");
}
return res;
}
int Ramses::displayBrightnessResolution() const
{
return 32;
}
bool Ramses::setDisplayContrast(int contr)
{
qDebug("Ramses::setDisplayContrast(%d)", contr);
bool res = false;
int fd;
// pwm0 contrast: 20 steps 79..90 (dunkel->hell)
if (contr > 255 )
contr = 255;
if (contr < 0)
contr = 0;
contr = 90 - (contr * 20 / 255);