-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.cpp | 54 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.h | 3 |
2 files changed, 37 insertions, 20 deletions
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp index ad2f830..75c9fc5 100644 --- a/libopie2/opiecore/device/odevice_jornada.cpp +++ b/libopie2/opiecore/device/odevice_jornada.cpp | |||
@@ -1,150 +1,166 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_jornada.h" | 30 | #include "odevice_jornada.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | /* KERNEL */ | 56 | /* KERNEL */ |
57 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 57 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
58 | 58 | ||
59 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 59 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
60 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 60 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
61 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 61 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
62 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 62 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
63 | 63 | ||
64 | typedef struct { | 64 | typedef struct { |
65 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 65 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
66 | unsigned char TotalTime; /* Units of 5 seconds */ | 66 | unsigned char TotalTime; /* Units of 5 seconds */ |
67 | unsigned char OnTime; /* units of 100m/s */ | 67 | unsigned char OnTime; /* units of 100m/s */ |
68 | unsigned char OffTime; /* units of 100m/s */ | 68 | unsigned char OffTime; /* units of 100m/s */ |
69 | } LED_IN; | 69 | } LED_IN; |
70 | 70 | ||
71 | typedef struct { | 71 | typedef struct { |
72 | unsigned char mode; | 72 | unsigned char mode; |
73 | unsigned char pwr; | 73 | unsigned char pwr; |
74 | unsigned char brightness; | 74 | unsigned char brightness; |
75 | } FLITE_IN; | 75 | } FLITE_IN; |
76 | 76 | ||
77 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 77 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
78 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 78 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
79 | 79 | ||
80 | using namespace Opie::Core::Internal; | 80 | using namespace Opie::Core::Internal; |
81 | 81 | ||
82 | void Jornada::init(const QString&) | 82 | void Jornada::init(const QString&) |
83 | { | 83 | { |
84 | d->m_vendorstr = "HP"; | 84 | d->m_vendorstr = "HP"; |
85 | d->m_vendor = Vendor_HP; | 85 | d->m_vendor = Vendor_HP; |
86 | d->m_modelstr = "Jornada 56x"; | 86 | d->m_modelstr = "Jornada 56x"; |
87 | d->m_model = Model_Jornada_56x; | 87 | d->m_model = Model_Jornada_56x; |
88 | d->m_systemstr = "Familiar"; | 88 | d->m_systemstr = "Familiar"; |
89 | d->m_system = System_Familiar; | 89 | d->m_system = System_Familiar; |
90 | d->m_rotation = Rot0; | 90 | d->m_rotation = Rot0; |
91 | 91 | ||
92 | QFile f ( "/etc/familiar-version" ); | 92 | QFile f ( "/etc/familiar-version" ); |
93 | f.setName ( "/etc/familiar-version" ); | 93 | f.setName ( "/etc/familiar-version" ); |
94 | if ( f.open ( IO_ReadOnly )) { | 94 | if ( f.open ( IO_ReadOnly )) { |
95 | 95 | ||
96 | QTextStream ts ( &f ); | 96 | QTextStream ts ( &f ); |
97 | d->m_sysverstr = ts.readLine().mid( 10 ); | 97 | d->m_sysverstr = ts.readLine().mid( 10 ); |
98 | 98 | ||
99 | f. close(); | 99 | f. close(); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | int Jornada::displayBrightnessResolution() const | 104 | int Jornada::displayBrightnessResolution() const |
105 | { | 105 | { |
106 | return 0; | 106 | return 255; |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | bool Jornada::setDisplayBrightness( int bright ) | 110 | bool Jornada::setDisplayBrightness( int bright ) |
111 | { | 111 | { |
112 | bool res = false; | 112 | bool res = false; |
113 | int fd; | 113 | int fd; |
114 | 114 | ||
115 | if ( bright > 255 ) | 115 | if ( bright > 255 ) |
116 | bright = 255; | 116 | bright = 255; |
117 | if ( bright < 0 ) | 117 | if ( bright < 0 ) |
118 | bright = 0; | 118 | bright = 0; |
119 | 119 | ||
120 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 120 | QString cmdline; |
121 | FLITE_IN bl; | 121 | |
122 | bl. mode = 1; | 122 | int value = 255 - bright; |
123 | bl. pwr = bright ? 1 : 0; | 123 | if ( !bright ) |
124 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; | 124 | cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power"); |
125 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 125 | else |
126 | ::close ( fd ); | 126 | cmdline = QString().sprintf( "echo 1 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", value ); |
127 | } | 127 | |
128 | res = ( ::system( (const char*) cmdline ) == 0 ); | ||
129 | |||
128 | return res; | 130 | return res; |
129 | } | 131 | } |
130 | 132 | ||
131 | 133 | ||
132 | bool Jornada::setSoftSuspend( bool soft ) | 134 | bool Jornada::suspend( ) |
135 | { | ||
136 | qDebug("ODevice::suspend"); | ||
137 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | ||
138 | return false; | ||
139 | |||
140 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | ||
141 | return false; | ||
142 | |||
143 | bool res = false; | ||
144 | ODevice::sendSuspendmsg(); | ||
145 | |||
146 | struct timeval tvs, tvn; | ||
147 | ::gettimeofday ( &tvs, 0 ); | ||
148 | |||
149 | ::sync(); // flush fs caches | ||
150 | res = ( ::system ( "apm --suspend" ) == 0 ); | ||
151 | |||
152 | return res; | ||
153 | } | ||
154 | |||
155 | bool Jornada::setDisplayStatus ( bool on ) | ||
133 | { | 156 | { |
134 | bool res = false; | 157 | bool res = false; |
135 | int fd; | 158 | int fd; |
136 | 159 | ||
137 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 160 | QString cmdline = QString().sprintf( "echo %d > /sys/class/lcd/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/power", on ? "1" : "0",on ? "1" : "0" ); |
138 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | ||
139 | res = true; | ||
140 | else | ||
141 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | ||
142 | 161 | ||
143 | ::close ( fd ); | 162 | res = ( ::system( (const char*) cmdline ) == 0 ); |
144 | } | ||
145 | else | ||
146 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | ||
147 | 163 | ||
148 | return res; | 164 | return res; |
149 | } | 165 | } |
150 | 166 | ||
diff --git a/libopie2/opiecore/device/odevice_jornada.h b/libopie2/opiecore/device/odevice_jornada.h index fddfe34..2a9e821 100644 --- a/libopie2/opiecore/device/odevice_jornada.h +++ b/libopie2/opiecore/device/odevice_jornada.h | |||
@@ -1,53 +1,54 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef ODEVICE_JORNADA | 30 | #ifndef ODEVICE_JORNADA |
31 | #define ODEVICE_JORNADA | 31 | #define ODEVICE_JORNADA |
32 | 32 | ||
33 | #include <opie2/odevice.h> | 33 | #include <opie2/odevice.h> |
34 | 34 | ||
35 | namespace Opie { | 35 | namespace Opie { |
36 | namespace Core { | 36 | namespace Core { |
37 | namespace Internal { | 37 | namespace Internal { |
38 | class Jornada : public ODevice | 38 | class Jornada : public ODevice |
39 | { | 39 | { |
40 | 40 | ||
41 | protected: | 41 | protected: |
42 | virtual void init(const QString&); | 42 | virtual void init(const QString&); |
43 | 43 | ||
44 | public: | 44 | public: |
45 | virtual bool setSoftSuspend ( bool soft ); | 45 | virtual bool suspend ( ); |
46 | virtual bool setDisplayBrightness ( int b ); | 46 | virtual bool setDisplayBrightness ( int b ); |
47 | virtual bool setDisplayStatus ( bool on); | ||
47 | virtual int displayBrightnessResolution() const; | 48 | virtual int displayBrightnessResolution() const; |
48 | }; | 49 | }; |
49 | } | 50 | } |
50 | } | 51 | } |
51 | } | 52 | } |
52 | #endif | 53 | #endif |
53 | 54 | ||