author | schurig <schurig> | 2003-06-05 14:53:05 (UTC) |
---|---|---|
committer | schurig <schurig> | 2003-06-05 14:53:05 (UTC) |
commit | 9fe856c57c5df5a74f9276f500070f2d90cfe091 (patch) (unidiff) | |
tree | 36ed349f9746897b4f2870a2e41c8845dfe1e0e2 | |
parent | 76d25975a76699fedeca6917c530991071fcf4fa (diff) | |
download | opie-9fe856c57c5df5a74f9276f500070f2d90cfe091.zip opie-9fe856c57c5df5a74f9276f500070f2d90cfe091.tar.gz opie-9fe856c57c5df5a74f9276f500070f2d90cfe091.tar.bz2 |
added ODevice::setDisplayContrast(), ODevice::displayContrast() as virtual function,
which will break binary compatibility, but zecke said I shoud for now do it this way.
assorted Ramses specific patches
-rw-r--r-- | libopie/odevice.cpp | 225 | ||||
-rw-r--r-- | libopie/odevice.h | 2 |
2 files changed, 142 insertions, 85 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index d86654e..160568b 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -90,3 +90,3 @@ public: | |||
90 | 90 | ||
91 | virtual QValueList <OLed> ledList ( ) const; | 91 | virtual QValueList <OLed> ledList ( ) const; |
92 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 92 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
@@ -123,3 +123,3 @@ public: | |||
123 | 123 | ||
124 | virtual QValueList <OLed> ledList ( ) const; | 124 | virtual QValueList <OLed> ledList ( ) const; |
125 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 125 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
@@ -149,3 +149,3 @@ public: | |||
149 | 149 | ||
150 | virtual QValueList <OLed> ledList ( ) const; | 150 | virtual QValueList <OLed> ledList ( ) const; |
151 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 151 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
@@ -166,3 +166,2 @@ protected: | |||
166 | virtual void init ( ); | 166 | virtual void init ( ); |
167 | virtual void initButtons ( ); | ||
168 | 167 | ||
@@ -170,2 +169,3 @@ public: | |||
170 | virtual bool setSoftSuspend ( bool soft ); | 169 | virtual bool setSoftSuspend ( bool soft ); |
170 | virtual bool suspend ( ); | ||
171 | 171 | ||
@@ -174,2 +174,4 @@ public: | |||
174 | virtual int displayBrightnessResolution ( ) const; | 174 | virtual int displayBrightnessResolution ( ) const; |
175 | virtual bool setDisplayContrast ( int b ); | ||
176 | virtual int displayContrastResolution ( ) const; | ||
175 | 177 | ||
@@ -184,9 +186,9 @@ struct i_button { | |||
184 | uint model; | 186 | uint model; |
185 | Qt::Key code; | 187 | Qt::Key code; |
186 | char *utext; | 188 | char *utext; |
187 | char *pix; | 189 | char *pix; |
188 | char *fpressedservice; | 190 | char *fpressedservice; |
189 | char *fpressedaction; | 191 | char *fpressedaction; |
190 | char *fheldservice; | 192 | char *fheldservice; |
191 | char *fheldaction; | 193 | char *fheldaction; |
192 | } ipaq_buttons [] = { | 194 | } ipaq_buttons [] = { |
@@ -355,3 +357,3 @@ struct r_button { | |||
355 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 357 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
356 | "devicebuttons/simpad_menu", | 358 | "devicebuttons/z_menu", |
357 | "QPE/TaskBar", "toggleMenu()", | 359 | "QPE/TaskBar", "toggleMenu()", |
@@ -495,2 +497,3 @@ bool ODevice::suspend ( ) | |||
495 | { | 497 | { |
498 | qDebug("ODevice::suspend"); | ||
496 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 499 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
@@ -538,2 +541,4 @@ bool ODevice::setDisplayStatus ( bool on ) | |||
538 | { | 541 | { |
542 | qDebug("ODevice::setDisplayStatus(%d)", on); | ||
543 | |||
539 | if ( d-> m_model == Model_Unknown ) | 544 | if ( d-> m_model == Model_Unknown ) |
@@ -561,2 +566,5 @@ bool ODevice::setDisplayBrightness ( int p) | |||
561 | 566 | ||
567 | /** | ||
568 | * @return return the max value for the brightness settings slider | ||
569 | */ | ||
562 | int ODevice::displayBrightnessResolution ( ) const | 570 | int ODevice::displayBrightnessResolution ( ) const |
@@ -567,2 +575,21 @@ int ODevice::displayBrightnessResolution ( ) const | |||
567 | /** | 575 | /** |
576 | * This sets the display contrast | ||
577 | * @return success or failure | ||
578 | */ | ||
579 | bool ODevice::setDisplayContrast ( int p) | ||
580 | { | ||
581 | Q_UNUSED( p ) | ||
582 | return false; | ||
583 | } | ||
584 | |||
585 | /** | ||
586 | * @return return the max value for the brightness settings slider | ||
587 | * or 0 if the device doesn't support setting of a contrast | ||
588 | */ | ||
589 | int ODevice::displayContrastResolution ( ) const | ||
590 | { | ||
591 | return 0; | ||
592 | } | ||
593 | |||
594 | /** | ||
568 | * This returns the vendor as string | 595 | * This returns the vendor as string |
@@ -672,3 +699,2 @@ void ODevice::touchSound ( ) | |||
672 | { | 699 | { |
673 | |||
674 | #ifndef QT_NO_SOUND | 700 | #ifndef QT_NO_SOUND |
@@ -1895,3 +1921,3 @@ int SIMpad::displayBrightnessResolution ( ) const | |||
1895 | 1921 | ||
1896 | void Ramses::init ( ) | 1922 | void Ramses::init() |
1897 | { | 1923 | { |
@@ -1900,3 +1926,3 @@ void Ramses::init ( ) | |||
1900 | 1926 | ||
1901 | QFile f( "/proc/sys/board/ramses" ); | 1927 | QFile f("/proc/sys/board/ramses"); |
1902 | 1928 | ||
@@ -1905,9 +1931,8 @@ void Ramses::init ( ) | |||
1905 | 1931 | ||
1906 | d->m_rotation = Rot180; | 1932 | d->m_rotation = Rot0; |
1907 | d->m_direction = CCW; | ||
1908 | d->m_holdtime = 1000; | 1933 | d->m_holdtime = 1000; |
1909 | 1934 | ||
1910 | f.setName( "/etc/oz_version" ); | 1935 | f.setName("/etc/oz_version"); |
1911 | 1936 | ||
1912 | if ( f.open( IO_ReadOnly )) { | 1937 | if (f.open(IO_ReadOnly)) { |
1913 | d->m_systemstr = "OpenEmbedded/Ramses"; | 1938 | d->m_systemstr = "OpenEmbedded/Ramses"; |
@@ -1915,6 +1940,6 @@ void Ramses::init ( ) | |||
1915 | 1940 | ||
1916 | QTextStream ts ( &f ); | 1941 | QTextStream ts(&f); |
1917 | ts.setDevice ( &f ); | 1942 | ts.setDevice(&f); |
1918 | d->m_sysverstr = ts.readLine ( ); | 1943 | d->m_sysverstr = ts.readLine(); |
1919 | f.close ( ); | 1944 | f.close(); |
1920 | } | 1945 | } |
@@ -1925,35 +1950,8 @@ void Ramses::init ( ) | |||
1925 | 1950 | ||
1926 | void Ramses::initButtons ( ) | 1951 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
1927 | { | 1952 | { |
1928 | if ( d->m_buttons ) | 1953 | Q_UNUSED( keycode ); |
1929 | return; | 1954 | Q_UNUSED( modifiers ); |
1930 | 1955 | Q_UNUSED( isPress ); | |
1931 | if ( isQWS( ) ) | 1956 | Q_UNUSED( autoRepeat ); |
1932 | QWSServer::setKeyboardFilter ( this ); | ||
1933 | |||
1934 | d->m_buttons = new QValueList <ODeviceButton>; | ||
1935 | |||
1936 | for ( uint i = 0; i < ( sizeof( ramses_buttons ) / sizeof( s_button )); i++ ) { | ||
1937 | r_button *rb = ramses_buttons + i; | ||
1938 | ODeviceButton b; | ||
1939 | |||
1940 | if (( rb->model & d->m_model ) == d->m_model ) { | ||
1941 | b.setKeycode( rb->code ); | ||
1942 | b.setUserText( QObject::tr ( "Button", rb->utext )); | ||
1943 | b.setPixmap( Resource::loadPixmap ( rb->pix )); | ||
1944 | b.setFactoryPresetPressedAction( OQCopMessage ( makeChannel ( rb->fpressedservice ), rb->fpressedaction )); | ||
1945 | b.setFactoryPresetHeldAction( OQCopMessage ( makeChannel ( rb->fheldservice ), rb->fheldaction )); | ||
1946 | |||
1947 | d->m_buttons->append( b ); | ||
1948 | } | ||
1949 | } | ||
1950 | reloadButtonMapping(); | ||
1951 | |||
1952 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | ||
1953 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | ||
1954 | } | ||
1955 | |||
1956 | bool Ramses::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | ||
1957 | { | ||
1958 | //TODO | ||
1959 | return false; | 1957 | return false; |
@@ -1961,8 +1959,8 @@ bool Ramses::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, | |||
1961 | 1959 | ||
1962 | void Ramses::timerEvent ( QTimerEvent * ) | 1960 | void Ramses::timerEvent(QTimerEvent *) |
1963 | { | 1961 | { |
1964 | killTimer ( m_power_timer ); | 1962 | killTimer(m_power_timer); |
1965 | m_power_timer = 0; | 1963 | m_power_timer = 0; |
1966 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 1964 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
1967 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 1965 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
1968 | } | 1966 | } |
@@ -1970,4 +1968,6 @@ void Ramses::timerEvent ( QTimerEvent * ) | |||
1970 | 1968 | ||
1971 | bool Ramses::setSoftSuspend ( bool soft ) | 1969 | bool Ramses::setSoftSuspend(bool soft) |
1972 | { | 1970 | { |
1971 | qDebug("Ramses::setSoftSuspend(%d)", soft); | ||
1972 | #if 0 | ||
1973 | bool res = false; | 1973 | bool res = false; |
@@ -1975,9 +1975,9 @@ bool Ramses::setSoftSuspend ( bool soft ) | |||
1975 | 1975 | ||
1976 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1976 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
1977 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1977 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
1978 | 1978 | ||
1979 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1979 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources |
1980 | 1980 | ||
1981 | if ( sources >= 0 ) { | 1981 | if (sources >= 0) { |
1982 | if ( soft ) | 1982 | if (soft) |
1983 | sources &= ~APM_EVT_POWER_BUTTON; | 1983 | sources &= ~APM_EVT_POWER_BUTTON; |
@@ -1986,16 +1986,24 @@ bool Ramses::setSoftSuspend ( bool soft ) | |||
1986 | 1986 | ||
1987 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1987 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources |
1988 | res = true; | 1988 | res = true; |
1989 | else | 1989 | else |
1990 | perror ( "APM_IOCGEVTSRC" ); | 1990 | perror("APM_IOCGEVTSRC"); |
1991 | } | 1991 | } |
1992 | else | 1992 | else |
1993 | perror ( "APM_IOCGEVTSRC" ); | 1993 | perror("APM_IOCGEVTSRC"); |
1994 | 1994 | ||
1995 | ::close ( fd ); | 1995 | ::close(fd); |
1996 | } | 1996 | } |
1997 | else | 1997 | else |
1998 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1998 | perror("/dev/apm_bios or /dev/misc/apm_bios"); |
1999 | 1999 | ||
2000 | return res; | 2000 | return res; |
2001 | #else | ||
2002 | return true; | ||
2003 | #endif | ||
2004 | } | ||
2005 | |||
2006 | bool Ramses::suspend ( ) | ||
2007 | { | ||
2008 | qDebug("Ramses::suspend"); | ||
2001 | } | 2009 | } |
@@ -2005,4 +2013,6 @@ bool Ramses::setSoftSuspend ( bool soft ) | |||
2005 | */ | 2013 | */ |
2006 | bool Ramses::setDisplayStatus ( bool on ) | 2014 | bool Ramses::setDisplayStatus(bool on) |
2007 | { | 2015 | { |
2016 | qDebug("Ramses::setDisplayStatus(%d)", on); | ||
2017 | #if 0 | ||
2008 | bool res = false; | 2018 | bool res = false; |
@@ -2010,7 +2020,10 @@ bool Ramses::setDisplayStatus ( bool on ) | |||
2010 | 2020 | ||
2011 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { | 2021 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { |
2012 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 2022 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2013 | ::close ( fd ); | 2023 | ::close(fd); |
2014 | } | 2024 | } |
2015 | return res; | 2025 | return res; |
2026 | #else | ||
2027 | return true; | ||
2028 | #endif | ||
2016 | } | 2029 | } |
@@ -2018,5 +2031,8 @@ bool Ramses::setDisplayStatus ( bool on ) | |||
2018 | 2031 | ||
2019 | bool Ramses::setDisplayBrightness ( int bright ) | 2032 | /* |
2033 | * We get something between 0..255 into us | ||
2034 | */ | ||
2035 | bool Ramses::setDisplayBrightness(int bright) | ||
2020 | { | 2036 | { |
2021 | qDebug( "ODevice for Ramses: setDisplayBrightness( %d )", bright ); | 2037 | qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2022 | bool res = false; | 2038 | bool res = false; |
@@ -2024,12 +2040,51 @@ bool Ramses::setDisplayBrightness ( int bright ) | |||
2024 | 2040 | ||
2025 | if ( bright > 255 ) | 2041 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2026 | bright = 100; | 2042 | |
2027 | if ( bright < 0 ) | 2043 | if (bright > 255 ) |
2044 | bright = 255; | ||
2045 | if (bright < 0) | ||
2028 | bright = 0; | 2046 | bright = 0; |
2047 | bright = 500-(bright * 500 / 255); | ||
2029 | 2048 | ||
2030 | if (( fd = ::open ( "/proc/sys/board/pwm0", O_WRONLY )) >= 0 ) { | 2049 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2050 | qDebug(" %d -> pwm1", bright); | ||
2031 | char writeCommand[100]; | 2051 | char writeCommand[100]; |
2032 | const int count = sprintf( writeCommand, "%d\n", bright); | 2052 | const int count = sprintf(writeCommand, "%d\n", bright); |
2033 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 2053 | res = (::write(fd, writeCommand, count) != -1); |
2034 | ::close ( fd ); | 2054 | ::close(fd); |
2055 | } else { | ||
2056 | qWarning("no write"); | ||
2057 | } | ||
2058 | return res; | ||
2059 | } | ||
2060 | |||
2061 | |||
2062 | int Ramses::displayBrightnessResolution() const | ||
2063 | { | ||
2064 | return 32; | ||
2065 | } | ||
2066 | |||
2067 | bool Ramses::setDisplayContrast(int contr) | ||
2068 | { | ||
2069 | qDebug("Ramses::setDisplayContrast(%d)", contr); | ||
2070 | bool res = false; | ||
2071 | int fd; | ||
2072 | |||
2073 | // pwm0 contrast: 35 steps 65..100 (dunkel->hell) | ||
2074 | |||
2075 | if (contr > 255 ) | ||
2076 | contr = 255; | ||
2077 | if (contr < 0) | ||
2078 | contr = 0; | ||
2079 | contr = 65 + (contr * 350 / 255); | ||
2080 | |||
2081 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | ||
2082 | qDebug(" %d -> pwm0", contr); | ||
2083 | char writeCommand[100]; | ||
2084 | const int count = sprintf(writeCommand, "%d\n", contr); | ||
2085 | res = (::write(fd, writeCommand, count) != -1); | ||
2086 | res = true; | ||
2087 | ::close(fd); | ||
2088 | } else { | ||
2089 | qWarning("no write"); | ||
2035 | } | 2090 | } |
@@ -2039,5 +2094,5 @@ bool Ramses::setDisplayBrightness ( int bright ) | |||
2039 | 2094 | ||
2040 | int Ramses::displayBrightnessResolution ( ) const | 2095 | int Ramses::displayContrastResolution() const |
2041 | { | 2096 | { |
2042 | return 100; | 2097 | return 32; |
2043 | } | 2098 | } |
diff --git a/libopie/odevice.h b/libopie/odevice.h index 5829440..6c4830e 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -183,2 +183,4 @@ public: | |||
183 | virtual int displayBrightnessResolution ( ) const; | 183 | virtual int displayBrightnessResolution ( ) const; |
184 | virtual bool setDisplayContrast ( int contrast ); | ||
185 | virtual int displayContrastResolution ( ) const; | ||
184 | 186 | ||