summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
authormickeyl <mickeyl>2003-12-29 16:51:07 (UTC)
committer mickeyl <mickeyl>2003-12-29 16:51:07 (UTC)
commit8224dfc07a698d4c40cb240d315dc81b67512015 (patch) (side-by-side diff)
tree0cdbb05aab54948421c873ccd25881caf1e474c5 /libopie/odevice.cpp
parentdae677b6e29e2a0efb7128bcc4b0d87bf2b535dd (diff)
downloadopie-8224dfc07a698d4c40cb240d315dc81b67512015.zip
opie-8224dfc07a698d4c40cb240d315dc81b67512015.tar.gz
opie-8224dfc07a698d4c40cb240d315dc81b67512015.tar.bz2
- add fine granular backlight support for devices with the corgi backlight interface
- add hinge sensor framework for devices with hinge sensors
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie/odevice.cpp90
1 files changed, 78 insertions, 12 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index e24e043..bc09e92 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -141,4 +141,7 @@ public:
virtual bool setLedState ( OLed led, OLedState st );
+ virtual bool hasHingeSensor() const;
+ virtual OHingeStatus readHingeSensor();
+
static bool isZaurus();
@@ -824,5 +827,5 @@ bool ODevice::hasLightSensor ( ) const
/**
- * @return a value from the light senso
+ * @return a value from the light sensor
*/
int ODevice::readLightSensor ( )
@@ -832,5 +835,5 @@ int ODevice::readLightSensor ( )
/**
- * @return the light sensor resolution whatever that is ;)
+ * @return the light sensor resolution
*/
int ODevice::lightSensorResolution ( ) const
@@ -840,4 +843,20 @@ int ODevice::lightSensorResolution ( ) const
/**
+ * @return if the device has a hinge sensor
+ */
+bool ODevice::hasHingeSensor ( ) const
+{
+ return false;
+}
+
+/**
+ * @return a value from the hinge sensor
+ */
+OHingeStatus ODevice::readHingeSensor ( )
+{
+ return CASE_UNKNOWN;
+}
+
+/**
* @return a list with CPU frequencies supported by the hardware
*/
@@ -1946,16 +1965,28 @@ bool Zaurus::setSoftSuspend ( bool soft )
bool Zaurus::setDisplayBrightness ( int bright )
{
-// FIXME The C7x0 have a proc-interface (/proc/drivers/corgi-bl) which
-// is nice to use. Currently it exposes 16+1 levels. Implement this!
-// (or wait for kergoth unifying the interfaces in the OpenZaurus kernel.)
bool res = false;
int fd;
- if ( bright > 255 )
- bright = 255;
- if ( bright < 0 )
- bright = 0;
+ if ( bright > 255 ) bright = 255;
+ if ( bright < 0 ) bright = 0;
- if (m_embedix) {
+ if ( m_embedix )
+ {
+ if ( d->m_model == Model_Zaurus_SLC7x0 )
+ {
+ // special treatment for devices with the corgi backlight interface
+ if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
+ {
+ if ( bright > 0x11 ) bright = 0x11;
+ char writeCommand[100];
+ const int count = sprintf( writeCommand, "0x%x\n", bright );
+ res = ( ::write ( fd, writeCommand, count ) != -1 );
+ ::close ( fd );
+ }
+ return res;
+ }
+ else
+ {
+ // standard treatment for devices with the dumb embedix frontlight interface
if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
@@ -1965,5 +1996,9 @@ bool Zaurus::setDisplayBrightness ( int bright )
::close ( fd );
}
- } else {
+ }
+ }
+ else
+ {
+ // special treatment for the OpenZaurus unified interface
#define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
@@ -2074,9 +2109,40 @@ int Zaurus::displayBrightnessResolution ( ) const
{
if (m_embedix)
- return 5;
+ return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5;
else
return 256;
}
+bool Zaurus::hasHingeSensor() const
+{
+ return d->m_model == Model_Zaurus_SLC7x0;
+}
+
+OHingeStatus Zaurus::readHingeSensor()
+{
+ int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
+ if (handle == -1)
+ {
+ qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
+ return CASE_UNKNOWN;
+ }
+ else
+ {
+ int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
+ ::close (handle);
+ if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
+ {
+ qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
+ return static_cast<OHingeStatus>( retval );
+ }
+ else
+ {
+ qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
+ return CASE_UNKNOWN;
+ }
+ }
+}
+
+
/**************************************************
*