author | mickeyl <mickeyl> | 2004-01-13 18:32:19 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-13 18:32:19 (UTC) |
commit | 061ccf5b9d384b1f24d203e96f1f04ccf1dcf133 (patch) (unidiff) | |
tree | ec1fc064f001edba92e58116cdc35fc909b5cdd6 /libopie2/opiecore/device/odevice_jornada.cpp | |
parent | 59f7fa0a480bf921a67ad42fc1fe018b1be44192 (diff) | |
download | opie-061ccf5b9d384b1f24d203e96f1f04ccf1dcf133.zip opie-061ccf5b9d384b1f24d203e96f1f04ccf1dcf133.tar.gz opie-061ccf5b9d384b1f24d203e96f1f04ccf1dcf133.tar.bz2 |
- rewrite device detection
- cleanup
- split odevice stuff into header and cpp files
- Note for next buildsystem: Don't link all header files but distinguish
between public and private headers, e.g. odevice.h is public while
odevice_ipaq.h is private.
Diffstat (limited to 'libopie2/opiecore/device/odevice_jornada.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.cpp | 76 |
1 files changed, 6 insertions, 70 deletions
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp index bcd03ed..37bd6e9 100644 --- a/libopie2/opiecore/device/odevice_jornada.cpp +++ b/libopie2/opiecore/device/odevice_jornada.cpp | |||
@@ -18,25 +18,25 @@ | |||
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.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> |
@@ -44,30 +44,25 @@ | |||
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 | #ifndef ARRAY_SIZE | 56 | /* KERNEL */ |
57 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
58 | #endif | ||
59 | |||
60 | // _IO and friends are only defined in kernel headers ... | ||
61 | |||
62 | #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 )) |
63 | 58 | ||
64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 59 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
65 | #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)) |
66 | #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)) |
67 | #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)) |
68 | 63 | ||
69 | typedef struct { | 64 | typedef struct { |
70 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 65 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
71 | unsigned char TotalTime; /* Units of 5 seconds */ | 66 | unsigned char TotalTime; /* Units of 5 seconds */ |
72 | unsigned char OnTime; /* units of 100m/s */ | 67 | unsigned char OnTime; /* units of 100m/s */ |
73 | unsigned char OffTime; /* units of 100m/s */ | 68 | unsigned char OffTime; /* units of 100m/s */ |
@@ -75,140 +70,81 @@ typedef struct { | |||
75 | 70 | ||
76 | typedef struct { | 71 | typedef struct { |
77 | unsigned char mode; | 72 | unsigned char mode; |
78 | unsigned char pwr; | 73 | unsigned char pwr; |
79 | unsigned char brightness; | 74 | unsigned char brightness; |
80 | } FLITE_IN; | 75 | } FLITE_IN; |
81 | 76 | ||
82 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 77 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
83 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 78 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
84 | 79 | ||
85 | using namespace Opie; | 80 | using namespace Opie; |
86 | 81 | ||
87 | class Jornada : public ODevice | ||
88 | { | ||
89 | |||
90 | protected: | ||
91 | virtual void init(); | ||
92 | |||
93 | public: | ||
94 | virtual bool setSoftSuspend ( bool soft ); | ||
95 | virtual bool setDisplayBrightness ( int b ); | ||
96 | virtual int displayBrightnessResolution() const; | ||
97 | static bool isJornada(); | ||
98 | }; | ||
99 | |||
100 | |||
101 | bool Jornada::isJornada() | ||
102 | { | ||
103 | QFile f( "/proc/cpuinfo" ); | ||
104 | if ( f. open ( IO_ReadOnly ) ) { | ||
105 | QTextStream ts ( &f ); | ||
106 | QString line; | ||
107 | while( line = ts. readLine() ) { | ||
108 | if ( line. left ( 8 ) == "Hardware" ) { | ||
109 | int loc = line. find ( ":" ); | ||
110 | if ( loc != -1 ) { | ||
111 | QString model = line.mid( loc + 2 ).simplifyWhiteSpace( ); | ||
112 | return ( model == "HP Jornada 56x" ); | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | return false; | ||
118 | } | ||
119 | |||
120 | void Jornada::init() | 82 | void Jornada::init() |
121 | { | 83 | { |
122 | d->m_vendorstr = "HP"; | 84 | d->m_vendorstr = "HP"; |
123 | d->m_vendor = Vendor_HP; | 85 | d->m_vendor = Vendor_HP; |
124 | d->m_modelstr = "Jornada 56x"; | 86 | d->m_modelstr = "Jornada 56x"; |
125 | d->m_model = Model_Jornada_56x; | 87 | d->m_model = Model_Jornada_56x; |
126 | d->m_systemstr = "Familiar"; | 88 | d->m_systemstr = "Familiar"; |
127 | d->m_system = System_Familiar; | 89 | d->m_system = System_Familiar; |
128 | d->m_rotation = Rot0; | 90 | d->m_rotation = Rot0; |
129 | 91 | ||
130 | QFile f ( "/etc/familiar-version" ); | 92 | QFile f ( "/etc/familiar-version" ); |
131 | f. setName ( "/etc/familiar-version" ); | 93 | f. setName ( "/etc/familiar-version" ); |
132 | if ( f. open ( IO_ReadOnly )) { | 94 | if ( f. open ( IO_ReadOnly )) { |
133 | 95 | ||
134 | QTextStream ts ( &f ); | 96 | QTextStream ts ( &f ); |
135 | d->m_sysverstr = ts. readLine(). mid ( 10 ); | 97 | d->m_sysverstr = ts. readLine(). mid ( 10 ); |
136 | 98 | ||
137 | f. close(); | 99 | f. close(); |
138 | } | 100 | } |
139 | } | 101 | } |
140 | 102 | ||
141 | #if 0 | ||
142 | void Jornada::initButtons() | ||
143 | { | ||
144 | if ( d->m_buttons ) | ||
145 | return; | ||
146 | |||
147 | // Simulation uses iPAQ 3660 device buttons | ||
148 | |||
149 | qDebug ( "init Buttons" ); | ||
150 | d->m_buttons = new QValueList <ODeviceButton>; | ||
151 | |||
152 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | ||
153 | i_button *ib = ipaq_buttons + i; | ||
154 | ODeviceButton b; | ||
155 | |||
156 | if (( ib->model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | ||
157 | b. setKeycode ( ib->code ); | ||
158 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | ||
159 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | ||
160 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | ||
161 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | ||
162 | d->m_buttons->append ( b ); | ||
163 | } | ||
164 | } | ||
165 | reloadButtonMapping(); | ||
166 | |||
167 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | ||
168 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | ||
169 | } | ||
170 | #endif | ||
171 | 103 | ||
172 | int Jornada::displayBrightnessResolution() const | 104 | int Jornada::displayBrightnessResolution() const |
173 | { | 105 | { |
106 | return 0; | ||
174 | } | 107 | } |
175 | 108 | ||
109 | |||
176 | bool Jornada::setDisplayBrightness( int bright ) | 110 | bool Jornada::setDisplayBrightness( int bright ) |
177 | { | 111 | { |
178 | bool res = false; | 112 | bool res = false; |
179 | int fd; | 113 | int fd; |
180 | 114 | ||
181 | if ( bright > 255 ) | 115 | if ( bright > 255 ) |
182 | bright = 255; | 116 | bright = 255; |
183 | if ( bright < 0 ) | 117 | if ( bright < 0 ) |
184 | bright = 0; | 118 | bright = 0; |
185 | 119 | ||
186 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 120 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
187 | FLITE_IN bl; | 121 | FLITE_IN bl; |
188 | bl. mode = 1; | 122 | bl. mode = 1; |
189 | bl. pwr = bright ? 1 : 0; | 123 | bl. pwr = bright ? 1 : 0; |
190 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; | 124 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; |
191 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 125 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
192 | ::close ( fd ); | 126 | ::close ( fd ); |
193 | } | 127 | } |
194 | return res; | 128 | return res; |
195 | } | 129 | } |
196 | 130 | ||
131 | |||
197 | bool Jornada::setSoftSuspend( bool soft ) | 132 | bool Jornada::setSoftSuspend( bool soft ) |
198 | { | 133 | { |
199 | bool res = false; | 134 | bool res = false; |
200 | int fd; | 135 | int fd; |
201 | 136 | ||
202 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 137 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
203 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 138 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
204 | res = true; | 139 | res = true; |
205 | else | 140 | else |
206 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 141 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
207 | 142 | ||
208 | ::close ( fd ); | 143 | ::close ( fd ); |
209 | } | 144 | } |
210 | else | 145 | else |
211 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 146 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
212 | 147 | ||
213 | return res; | 148 | return res; |
214 | } | 149 | } |
150 | |||