author | mickeyl <mickeyl> | 2003-12-29 16:51:07 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-12-29 16:51:07 (UTC) |
commit | 8224dfc07a698d4c40cb240d315dc81b67512015 (patch) (unidiff) | |
tree | 0cdbb05aab54948421c873ccd25881caf1e474c5 | |
parent | dae677b6e29e2a0efb7128bcc4b0d87bf2b535dd (diff) | |
download | opie-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
-rw-r--r-- | libopie/odevice.cpp | 90 | ||||
-rw-r--r-- | libopie/odevice.h | 10 |
2 files changed, 88 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: | |||
141 | virtual bool setLedState ( OLed led, OLedState st ); | 141 | virtual bool setLedState ( OLed led, OLedState st ); |
142 | 142 | ||
143 | virtual bool hasHingeSensor() const; | ||
144 | virtual OHingeStatus readHingeSensor(); | ||
145 | |||
143 | static bool isZaurus(); | 146 | static bool isZaurus(); |
144 | 147 | ||
@@ -824,5 +827,5 @@ bool ODevice::hasLightSensor ( ) const | |||
824 | 827 | ||
825 | /** | 828 | /** |
826 | * @return a value from the light senso | 829 | * @return a value from the light sensor |
827 | */ | 830 | */ |
828 | int ODevice::readLightSensor ( ) | 831 | int ODevice::readLightSensor ( ) |
@@ -832,5 +835,5 @@ int ODevice::readLightSensor ( ) | |||
832 | 835 | ||
833 | /** | 836 | /** |
834 | * @return the light sensor resolution whatever that is ;) | 837 | * @return the light sensor resolution |
835 | */ | 838 | */ |
836 | int ODevice::lightSensorResolution ( ) const | 839 | int ODevice::lightSensorResolution ( ) const |
@@ -840,4 +843,20 @@ int ODevice::lightSensorResolution ( ) const | |||
840 | 843 | ||
841 | /** | 844 | /** |
845 | * @return if the device has a hinge sensor | ||
846 | */ | ||
847 | bool ODevice::hasHingeSensor ( ) const | ||
848 | { | ||
849 | return false; | ||
850 | } | ||
851 | |||
852 | /** | ||
853 | * @return a value from the hinge sensor | ||
854 | */ | ||
855 | OHingeStatus ODevice::readHingeSensor ( ) | ||
856 | { | ||
857 | return CASE_UNKNOWN; | ||
858 | } | ||
859 | |||
860 | /** | ||
842 | * @return a list with CPU frequencies supported by the hardware | 861 | * @return a list with CPU frequencies supported by the hardware |
843 | */ | 862 | */ |
@@ -1946,16 +1965,28 @@ bool Zaurus::setSoftSuspend ( bool soft ) | |||
1946 | bool Zaurus::setDisplayBrightness ( int bright ) | 1965 | bool Zaurus::setDisplayBrightness ( int bright ) |
1947 | { | 1966 | { |
1948 | // FIXME The C7x0 have a proc-interface (/proc/drivers/corgi-bl) which | ||
1949 | // is nice to use. Currently it exposes 16+1 levels. Implement this! | ||
1950 | // (or wait for kergoth unifying the interfaces in the OpenZaurus kernel.) | ||
1951 | bool res = false; | 1967 | bool res = false; |
1952 | int fd; | 1968 | int fd; |
1953 | 1969 | ||
1954 | if ( bright > 255 ) | 1970 | if ( bright > 255 ) bright = 255; |
1955 | bright = 255; | 1971 | if ( bright < 0 ) bright = 0; |
1956 | if ( bright < 0 ) | ||
1957 | bright = 0; | ||
1958 | 1972 | ||
1959 | if (m_embedix) { | 1973 | if ( m_embedix ) |
1974 | { | ||
1975 | if ( d->m_model == Model_Zaurus_SLC7x0 ) | ||
1976 | { | ||
1977 | // special treatment for devices with the corgi backlight interface | ||
1978 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) | ||
1979 | { | ||
1980 | if ( bright > 0x11 ) bright = 0x11; | ||
1981 | char writeCommand[100]; | ||
1982 | const int count = sprintf( writeCommand, "0x%x\n", bright ); | ||
1983 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | ||
1984 | ::close ( fd ); | ||
1985 | } | ||
1986 | return res; | ||
1987 | } | ||
1988 | else | ||
1989 | { | ||
1990 | // standard treatment for devices with the dumb embedix frontlight interface | ||
1960 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1991 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1961 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1992 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
@@ -1965,5 +1996,9 @@ bool Zaurus::setDisplayBrightness ( int bright ) | |||
1965 | ::close ( fd ); | 1996 | ::close ( fd ); |
1966 | } | 1997 | } |
1967 | } else { | 1998 | } |
1999 | } | ||
2000 | else | ||
2001 | { | ||
2002 | // special treatment for the OpenZaurus unified interface | ||
1968 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 2003 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ |
1969 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 2004 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { |
@@ -2074,9 +2109,40 @@ int Zaurus::displayBrightnessResolution ( ) const | |||
2074 | { | 2109 | { |
2075 | if (m_embedix) | 2110 | if (m_embedix) |
2076 | return 5; | 2111 | return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; |
2077 | else | 2112 | else |
2078 | return 256; | 2113 | return 256; |
2079 | } | 2114 | } |
2080 | 2115 | ||
2116 | bool Zaurus::hasHingeSensor() const | ||
2117 | { | ||
2118 | return d->m_model == Model_Zaurus_SLC7x0; | ||
2119 | } | ||
2120 | |||
2121 | OHingeStatus Zaurus::readHingeSensor() | ||
2122 | { | ||
2123 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | ||
2124 | if (handle == -1) | ||
2125 | { | ||
2126 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | ||
2127 | return CASE_UNKNOWN; | ||
2128 | } | ||
2129 | else | ||
2130 | { | ||
2131 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | ||
2132 | ::close (handle); | ||
2133 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | ||
2134 | { | ||
2135 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | ||
2136 | return static_cast<OHingeStatus>( retval ); | ||
2137 | } | ||
2138 | else | ||
2139 | { | ||
2140 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | ||
2141 | return CASE_UNKNOWN; | ||
2142 | } | ||
2143 | } | ||
2144 | } | ||
2145 | |||
2146 | |||
2081 | /************************************************** | 2147 | /************************************************** |
2082 | * | 2148 | * |
diff --git a/libopie/odevice.h b/libopie/odevice.h index 8273761..ee0b0ec 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -144,4 +144,11 @@ enum ODirection { | |||
144 | }; | 144 | }; |
145 | 145 | ||
146 | enum OHingeStatus { | ||
147 | CASE_CLOSED = 3, | ||
148 | CASE_PORTRAIT = 2, | ||
149 | CASE_LANDSCAPE = 0, | ||
150 | CASE_UNKNOWN = 1, | ||
151 | }; | ||
152 | |||
146 | /** | 153 | /** |
147 | * A singleton which gives informations about device specefic option | 154 | * A singleton which gives informations about device specefic option |
@@ -223,4 +230,7 @@ public: | |||
223 | virtual int lightSensorResolution ( ) const; | 230 | virtual int lightSensorResolution ( ) const; |
224 | 231 | ||
232 | virtual bool hasHingeSensor ( ) const; | ||
233 | virtual OHingeStatus readHingeSensor ( ); | ||
234 | |||
225 | const QStrList &allowedCpuFrequencies() const; | 235 | const QStrList &allowedCpuFrequencies() const; |
226 | bool setCurrentCpuFrequency(uint index); | 236 | bool setCurrentCpuFrequency(uint index); |