author | llornkcor <llornkcor> | 2006-07-14 20:15:58 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2006-07-14 20:15:58 (UTC) |
commit | 20b8c8eb22b5498647430da49986f75b78cf2d79 (patch) (unidiff) | |
tree | 0309ad594266a40cf17959b5c0d322933b6256ca /libopie2/opiecore | |
parent | 36dece4760b1ac1799929221b49eb3bee98c2367 (diff) | |
download | opie-20b8c8eb22b5498647430da49986f75b78cf2d79.zip opie-20b8c8eb22b5498647430da49986f75b78cf2d79.tar.gz opie-20b8c8eb22b5498647430da49986f75b78cf2d79.tar.bz2 |
more htc universal stuff
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 7 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_htc.cpp | 221 |
2 files changed, 59 insertions, 169 deletions
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index 9afb92d..c2fa411 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h | |||
@@ -69,16 +69,17 @@ enum OModel { | |||
69 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x0006 ), | 69 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x0006 ), |
70 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x0007 ), | 70 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x0007 ), |
71 | Model_iPAQ_H191x = ( Model_iPAQ | 0x0008 ), | 71 | Model_iPAQ_H191x = ( Model_iPAQ | 0x0008 ), |
72 | Model_iPAQ_H1940 = ( Model_iPAQ | 0x0009 ), | 72 | Model_iPAQ_H1940 = ( Model_iPAQ | 0x0009 ), |
73 | Model_iPAQ_HX4700 = ( Model_iPAQ | 0x000A ), | 73 | Model_iPAQ_HX4700 = ( Model_iPAQ | 0x000A ), |
74 | Model_Jornada = ( 6 << 16 ), | 74 | Model_Jornada = ( 6 << 16 ), |
75 | Model_Jornada_56x = ( Model_Jornada | 0x0001 ), | 75 | Model_Jornada_56x = ( Model_Jornada | 0x0001 ), |
76 | Model_Jornada_720 = ( Model_Jornada | 0x0002 ), | 76 | Model_Jornada_720 = ( Model_Jornada | 0x0002 ), |
77 | Model_Jornada_820 = ( Model_Jornada | 0x0003 ), | ||
77 | 78 | ||
78 | Model_Zaurus = ( 2 << 16 ), | 79 | Model_Zaurus = ( 2 << 16 ), |
79 | 80 | ||
80 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ), | 81 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ), |
81 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ), | 82 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ), |
82 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ), | 83 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ), |
83 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ), | 84 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ), |
84 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ), | 85 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ), |
@@ -120,16 +121,22 @@ enum OModel { | |||
120 | Model_MyPal_All = ( Model_MyPal | 0xffff ), | 121 | Model_MyPal_All = ( Model_MyPal | 0xffff ), |
121 | Model_MyPal_620 = ( Model_MyPal | 0x0001 ), | 122 | Model_MyPal_620 = ( Model_MyPal | 0x0001 ), |
122 | Model_MyPal_716 = ( Model_MyPal | 0x0002 ), | 123 | Model_MyPal_716 = ( Model_MyPal | 0x0002 ), |
123 | Model_MyPal_730 = ( Model_MyPal | 0x0003 ), | 124 | Model_MyPal_730 = ( Model_MyPal | 0x0003 ), |
124 | 125 | ||
125 | Model_HTC = ( 9 << 16 ), | 126 | Model_HTC = ( 9 << 16 ), |
126 | Model_HTC_All = ( Model_HTC | 0xffff ), | 127 | Model_HTC_All = ( Model_HTC | 0xffff ), |
127 | Model_HTC_Universal = ( Model_HTC | 0x0001 ), | 128 | Model_HTC_Universal = ( Model_HTC | 0x0001 ), |
129 | Model_HTC_Alpine = ( Model_HTC | 0x0002 ), | ||
130 | Model_HTC_Apache = ( Model_HTC | 0x0003 ), | ||
131 | Model_HTC_Beetles = ( Model_HTC | 0x0004 ), | ||
132 | Model_HTC_Blueangel = ( Model_HTC | 0x0005 ), | ||
133 | Model_HTC_Himalaya = ( Model_HTC | 0x0006 ), | ||
134 | Model_HTC_Magician = ( Model_HTC | 0x0007 ), | ||
128 | 135 | ||
129 | Model_Motorola = ( 9 << 17 ), | 136 | Model_Motorola = ( 9 << 17 ), |
130 | Model_Motorola_All = ( Model_Motorola | 0xffff ), | 137 | Model_Motorola_All = ( Model_Motorola | 0xffff ), |
131 | Model_Motorola_EZX = ( Model_Motorola | 0x0001 ), | 138 | Model_Motorola_EZX = ( Model_Motorola | 0x0001 ), |
132 | 139 | ||
133 | }; | 140 | }; |
134 | 141 | ||
135 | /** | 142 | /** |
diff --git a/libopie2/opiecore/device/odevice_htc.cpp b/libopie2/opiecore/device/odevice_htc.cpp index a40308d..c21e10d 100644 --- a/libopie2/opiecore/device/odevice_htc.cpp +++ b/libopie2/opiecore/device/odevice_htc.cpp | |||
@@ -111,111 +111,93 @@ struct htc_button htc_buttons_universal [] = { | |||
111 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), | 111 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), |
112 | "devicebuttons/z_hinge2", | 112 | "devicebuttons/z_hinge2", |
113 | "QPE/Rotation", "rotateDefault()",0}, | 113 | "QPE/Rotation", "rotateDefault()",0}, |
114 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), | 114 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), |
115 | "devicebuttons/z_hinge3", | 115 | "devicebuttons/z_hinge3", |
116 | "QPE/Rotation", "rotateDefault()",0}, | 116 | "QPE/Rotation", "rotateDefault()",0}, |
117 | }; | 117 | }; |
118 | 118 | ||
119 | struct htc_button htc_buttons_6000 [] = { | ||
120 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | ||
121 | "devicebuttons/z_calendar", | ||
122 | "datebook", "nextView()", | ||
123 | "today", "raise()" }, | ||
124 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | ||
125 | "devicebuttons/z_contact", | ||
126 | "addressbook", "raise()", | ||
127 | "addressbook", "beamBusinessCard()" }, | ||
128 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | ||
129 | "devicebuttons/z_home", | ||
130 | "QPE/Launcher", "home()", | ||
131 | "buttonsettings", "raise()" }, | ||
132 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | ||
133 | "devicebuttons/z_menu", | ||
134 | "QPE/TaskBar", "toggleMenu()", | ||
135 | "QPE/TaskBar", "toggleStartMenu()" }, | ||
136 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | ||
137 | "devicebuttons/z_mail", | ||
138 | "opiemail", "raise()", | ||
139 | "opiemail", "newMail()" }, | ||
140 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Rotate Button"), | ||
141 | "devicebuttons/z_rotate", | ||
142 | 0, | ||
143 | "QPE/Rotation", "rotateDefault()" }, | ||
144 | { Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | ||
145 | "devicebuttons/z_hinge3", | ||
146 | "QPE/VMemo", "toggleRecord()", | ||
147 | "sound", "raise()" }, | ||
148 | }; | ||
149 | 119 | ||
150 | // FIXME This gets unnecessary complicated. We should think about splitting the HTC | ||
151 | // class up into individual classes. We would need three classes | ||
152 | // | 120 | // |
153 | // HTC-Universal (PXA-model w/ 640x480 lcd, for Universal) | 121 | // HTC-Universal (PXA-model w/ 480x640 3.6" lcd) |
122 | // HTC-Alpine (PXA-model w/ 240x320 3.5" lcd) | ||
123 | // HTC-Apache (PXA-model w/ 240x320 2.8" lcd) | ||
124 | // HTC-Beetles (PXA-model w/ 240x240 3.0" lcd) | ||
125 | // HTC-Blueangel (PXA-model w/ 240x320 3.5" lcd) | ||
126 | // HTC-Himalaya (PXA-model w/ 240x320 3.5" lcd) | ||
127 | // HTC-Magician (PXA-model w/ 240x320 2.8" lcd) | ||
154 | 128 | ||
155 | void HTC::init(const QString& cpu_info) | 129 | void HTC::init(const QString& cpu_info) |
156 | { | 130 | { |
157 | qDebug( "HTC::init()" ); | 131 | qDebug( "HTC::init()" ); |
158 | // Set the time to wait until the system is really suspended | 132 | // Set the time to wait until the system is really suspended |
159 | // the delta between apm --suspend and sleeping | 133 | // the delta between apm --suspend and sleeping |
160 | setAPMTimeOut( 15000 ); | 134 | setAPMTimeOut( 15000 ); |
161 | 135 | ||
162 | // generic distribution code already scanned /etc/issue at that point - | ||
163 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | ||
164 | if ( d->m_sysverstr.contains( "embedix", false ) ) | ||
165 | { | ||
166 | d->m_vendorstr = "HTC"; | ||
167 | d->m_vendor = Vendor_HTC; | ||
168 | d->m_systemstr = "OpenEmbedded"; | ||
169 | d->m_system = System_OpenEmbedded; | ||
170 | m_embedix = true; | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | d->m_vendorstr = "Xanadux Team"; | 136 | d->m_vendorstr = "Xanadux Team"; |
175 | d->m_systemstr = "Familiar"; | 137 | d->m_systemstr = "Familiar"; |
176 | d->m_system = System_Familiar; | 138 | d->m_system = System_Familiar; |
177 | // sysver already gathered | ||
178 | |||
179 | // OpenHTC sometimes uses the 2.4 (embedix) kernel, check if this is one | ||
180 | FILE *uname = popen("uname -r", "r"); | ||
181 | QFile f; | ||
182 | QString line; | ||
183 | if ( f.open(IO_ReadOnly, uname) ) { | ||
184 | QTextStream ts ( &f ); | ||
185 | line = ts.readLine(); | ||
186 | m_embedix = line.startsWith( "2.4." ); | ||
187 | f.close(); | ||
188 | } | ||
189 | pclose(uname); | ||
190 | } | ||
191 | 139 | ||
192 | // check the HTC model | 140 | // check the HTC model |
193 | QString model; | 141 | QString model; |
194 | int loc = cpu_info.find( ":" ); | 142 | int loc = cpu_info.find( ":" ); |
195 | if ( loc != -1 ) | 143 | if ( loc != -1 ) |
196 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 144 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
197 | else | 145 | else |
198 | model = cpu_info; | 146 | model = cpu_info; |
199 | 147 | ||
148 | d->m_model = Model_HTC_Universal; | ||
149 | d->m_modelstr = "Unknown HTC"; | ||
150 | |||
200 | if ( model == "HTC Universal" ) { | 151 | if ( model == "HTC Universal" ) { |
201 | d->m_model = Model_HTC_Universal; | 152 | d->m_model = Model_HTC_Universal; |
202 | d->m_modelstr = "HTC Universal"; | 153 | d->m_modelstr = "HTC Universal"; |
203 | } else { | ||
204 | d->m_model = Model_HTC_Universal; | ||
205 | d->m_modelstr = "Unknown HTC"; | ||
206 | } | 154 | } |
155 | if ( model == "HTC Alpine" ) { | ||
156 | d->m_model = Model_HTC_Alpine; | ||
157 | d->m_modelstr = "HTC Alpine"; | ||
158 | } | ||
159 | if ( model == "HTC Apache" ) { | ||
160 | d->m_model = Model_HTC_Apache; | ||
161 | d->m_modelstr = "HTC Apache"; | ||
162 | } | ||
163 | if ( model == "HTC Beetles" ) { | ||
164 | d->m_model = Model_HTC_Beetles; | ||
165 | d->m_modelstr = "HTC Beetles"; | ||
166 | } | ||
167 | if ( model == "HTC Blueangel" ) { | ||
168 | d->m_model = Model_HTC_Blueangel; | ||
169 | d->m_modelstr = "HTC Blueangel"; | ||
170 | } | ||
171 | if ( model == "HTC Himalaya" ) { | ||
172 | d->m_model = Model_HTC_Himalaya; | ||
173 | d->m_modelstr = "HTC Himalaya"; | ||
174 | } | ||
175 | if ( model == "HTC Magician" ) { | ||
176 | d->m_model = Model_HTC_Magician; | ||
177 | d->m_modelstr = "HTC Magician"; | ||
178 | } | ||
179 | |||
207 | 180 | ||
208 | // set path to backlight device in kernel 2.6 | 181 | // set path to backlight device |
209 | switch ( d->m_model ) | 182 | switch ( d->m_model ) |
210 | { | 183 | { |
211 | case Model_HTC_Universal: | 184 | case Model_HTC_Universal: |
185 | case Model_HTC_Magician: | ||
186 | case Model_HTC_Alpine: | ||
187 | case Model_HTC_Beetles: | ||
188 | case Model_HTC_Apache: | ||
189 | m_backlightdev = "/sys/class/backlight/pxa2xx-fb/"; | ||
190 | break; | ||
191 | case Model_HTC_Blueangel: | ||
192 | case Model_HTC_Himalaya: | ||
193 | m_backlightdev = "/sys/class/backlight/w100fb/"; | ||
194 | break; | ||
212 | default: | 195 | default: |
213 | // m_backlightdev = "/sys/class/backlight/corgi-bl/"; | ||
214 | m_backlightdev = "/sys/class/backlight/pxafb/"; | 196 | m_backlightdev = "/sys/class/backlight/pxafb/"; |
215 | } | 197 | } |
216 | 198 | ||
217 | // set initial rotation | 199 | // set initial rotation |
218 | switch( d->m_model ) | 200 | switch( d->m_model ) |
219 | { | 201 | { |
220 | case Model_HTC_Universal: | 202 | case Model_HTC_Universal: |
221 | initHingeSensor(); | 203 | initHingeSensor(); |
@@ -230,20 +212,17 @@ void HTC::init(const QString& cpu_info) | |||
230 | switch( d->m_model ) | 212 | switch( d->m_model ) |
231 | { | 213 | { |
232 | default: | 214 | default: |
233 | d->m_qteDriver = "Transformed"; | 215 | d->m_qteDriver = "Transformed"; |
234 | } | 216 | } |
235 | 217 | ||
236 | m_leds[0] = Led_Off; | 218 | m_leds[0] = Led_Off; |
237 | 219 | ||
238 | if ( m_embedix ) | 220 | qDebug( "HTC::init() - Using the 2.6 Xanadux on a %s", (const char*) d->m_modelstr ); |
239 | qDebug( "HTC::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); | ||
240 | else | ||
241 | qDebug( "HTC::init() - Using the 2.6 Xanadux HAL on a %s", (const char*) d->m_modelstr ); | ||
242 | } | 221 | } |
243 | 222 | ||
244 | void HTC::initButtons() | 223 | void HTC::initButtons() |
245 | { | 224 | { |
246 | qDebug( "HTC::initButtons()" ); | 225 | qDebug( "HTC::initButtons()" ); |
247 | if ( d->m_buttons ) | 226 | if ( d->m_buttons ) |
248 | return; | 227 | return; |
249 | 228 | ||
@@ -373,142 +352,73 @@ OLedState HTC::ledState( OLed which ) const | |||
373 | if ( which == Led_Mail ) | 352 | if ( which == Led_Mail ) |
374 | return m_leds [0]; | 353 | return m_leds [0]; |
375 | else | 354 | else |
376 | return Led_Off; | 355 | return Led_Off; |
377 | } | 356 | } |
378 | 357 | ||
379 | bool HTC::setLedState( OLed which, OLedState st ) | 358 | bool HTC::setLedState( OLed which, OLedState st ) |
380 | { | 359 | { |
381 | // Currently not supported on non_embedix kernels | 360 | qDebug( "HTC::setLedState: ODevice handling not yet implemented" ); |
382 | if (!m_embedix) | ||
383 | { | ||
384 | qDebug( "HTC::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); | ||
385 | return false; | ||
386 | } | ||
387 | |||
388 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | ||
389 | |||
390 | if ( which == Led_Mail ) { | ||
391 | if ( fd >= 0 ) { | ||
392 | struct sharp_led_status leds; | ||
393 | ::memset ( &leds, 0, sizeof( leds )); | ||
394 | leds. which = SHARP_LED_MAIL_EXISTS; | ||
395 | bool ok = true; | ||
396 | |||
397 | switch ( st ) { | ||
398 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | ||
399 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | ||
400 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | ||
401 | default : ok = false; | ||
402 | } | ||
403 | |||
404 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | ||
405 | m_leds [0] = st; | ||
406 | return true; | ||
407 | } | ||
408 | } | ||
409 | } | ||
410 | return false; | 361 | return false; |
411 | } | 362 | } |
412 | 363 | ||
413 | int HTC::displayBrightnessResolution() const | 364 | int HTC::displayBrightnessResolution() const |
414 | { | 365 | { |
415 | /* MV */ | ||
416 | return 16; | ||
417 | |||
418 | int res = 1; | 366 | int res = 1; |
419 | if (m_embedix) | 367 | |
420 | { | ||
421 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); | ||
422 | if ( fd ) | ||
423 | { | ||
424 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); | ||
425 | ::close( fd ); | ||
426 | return value ? value : res; | ||
427 | } | ||
428 | } | ||
429 | else | ||
430 | { | ||
431 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); | 368 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); |
369 | |||
432 | if ( fd ) | 370 | if ( fd ) |
433 | { | 371 | { |
434 | char buf[100]; | 372 | char buf[100]; |
435 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 373 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
436 | ::close( fd ); | 374 | ::close( fd ); |
437 | } | 375 | } |
438 | } | 376 | |
439 | return res; | 377 | return res; |
440 | } | 378 | } |
441 | 379 | ||
442 | bool HTC::setDisplayBrightness( int bright ) | 380 | bool HTC::setDisplayBrightness( int bright ) |
443 | { | 381 | { |
444 | /* MV */ | ||
445 | return false; | ||
446 | 382 | ||
447 | //qDebug( "HTC::setDisplayBrightness( %d )", bright ); | 383 | //qDebug( "HTC::setDisplayBrightness( %d )", bright ); |
448 | bool res = false; | 384 | bool res = false; |
449 | 385 | ||
450 | if ( bright > 255 ) bright = 255; | 386 | if ( bright > 255 ) bright = 255; |
451 | if ( bright < 0 ) bright = 0; | 387 | if ( bright < 0 ) bright = 0; |
452 | 388 | ||
453 | int numberOfSteps = displayBrightnessResolution(); | 389 | int numberOfSteps = displayBrightnessResolution(); |
454 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 390 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
455 | 391 | ||
456 | if ( m_embedix ) | ||
457 | { | ||
458 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | ||
459 | if ( fd ) | ||
460 | { | ||
461 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); | ||
462 | ::close( fd ); | ||
463 | } | ||
464 | } | ||
465 | else | ||
466 | { | ||
467 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); | 392 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); |
468 | if ( fd ) | 393 | if ( fd ) |
469 | { | 394 | { |
470 | char buf[100]; | 395 | char buf[100]; |
471 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 396 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
472 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 397 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
473 | ::close( fd ); | 398 | ::close( fd ); |
474 | } | 399 | } |
475 | } | ||
476 | return res; | 400 | return res; |
477 | } | 401 | } |
478 | 402 | ||
479 | bool HTC::setDisplayStatus( bool on ) | 403 | bool HTC::setDisplayStatus( bool on ) |
480 | { | 404 | { |
481 | /* MV */ | ||
482 | return false; | ||
483 | 405 | ||
484 | bool res = false; | 406 | bool res = false; |
485 | if ( m_embedix ) | 407 | |
486 | { | ||
487 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | ||
488 | if ( fd ) | ||
489 | { | ||
490 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; | ||
491 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); | ||
492 | ::close ( fd ); | ||
493 | } | ||
494 | } | ||
495 | else | ||
496 | { | ||
497 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); | 408 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); |
498 | if ( fd ) | 409 | if ( fd ) |
499 | { | 410 | { |
500 | char buf[10]; | 411 | char buf[10]; |
501 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 412 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
502 | buf[1] = '\0'; | 413 | buf[1] = '\0'; |
503 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 414 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
504 | ::close( fd ); | 415 | ::close( fd ); |
505 | } | 416 | } |
506 | } | ||
507 | return res; | 417 | return res; |
508 | } | 418 | } |
509 | 419 | ||
510 | Transformation HTC::rotation() const | 420 | Transformation HTC::rotation() const |
511 | { | 421 | { |
512 | qDebug( "HTC::rotation()" ); | 422 | qDebug( "HTC::rotation()" ); |
513 | Transformation rot; | 423 | Transformation rot; |
514 | 424 | ||
@@ -548,42 +458,16 @@ ODirection HTC::direction() const | |||
548 | 458 | ||
549 | bool HTC::hasHingeSensor() const | 459 | bool HTC::hasHingeSensor() const |
550 | { | 460 | { |
551 | return d->m_model == Model_HTC_Universal; | 461 | return d->m_model == Model_HTC_Universal; |
552 | } | 462 | } |
553 | 463 | ||
554 | OHingeStatus HTC::readHingeSensor() const | 464 | OHingeStatus HTC::readHingeSensor() const |
555 | { | 465 | { |
556 | if (m_embedix) | ||
557 | { | ||
558 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | ||
559 | if (handle == -1) | ||
560 | { | ||
561 | qWarning("HTC::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | ||
562 | return CASE_UNKNOWN; | ||
563 | } | ||
564 | else | ||
565 | { | ||
566 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | ||
567 | ::close (handle); | ||
568 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | ||
569 | { | ||
570 | qDebug( "HTC::readHingeSensor() - result = %d", retval ); | ||
571 | return static_cast<OHingeStatus>( retval ); | ||
572 | } | ||
573 | else | ||
574 | { | ||
575 | qWarning("HTC::readHingeSensor() - couldn't compute hinge status!" ); | ||
576 | return CASE_UNKNOWN; | ||
577 | } | ||
578 | } | ||
579 | } | ||
580 | else | ||
581 | { | ||
582 | /* | 466 | /* |
583 | * The HTC Universal keyboard is event source 1 in kernel 2.6. | 467 | * The HTC Universal keyboard is event source 1 in kernel 2.6. |
584 | * Hinge status is reported via Input System Switchs 0 and 1 like that: | 468 | * Hinge status is reported via Input System Switchs 0 and 1 like that: |
585 | * | 469 | * |
586 | * ------------------------- | 470 | * ------------------------- |
587 | * | SW0 | SW1 | CASE | | 471 | * | SW0 | SW1 | CASE | |
588 | * |-----|-----|-----------| | 472 | * |-----|-----|-----------| |
589 | * | 0 0 Unknown | | 473 | * | 0 0 Unknown | |
@@ -604,17 +488,16 @@ OHingeStatus HTC::readHingeSensor() const | |||
604 | { | 488 | { |
605 | return switch1 ? CASE_LANDSCAPE : CASE_PORTRAIT; | 489 | return switch1 ? CASE_LANDSCAPE : CASE_PORTRAIT; |
606 | } | 490 | } |
607 | else | 491 | else |
608 | { | 492 | { |
609 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; | 493 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; |
610 | } | 494 | } |
611 | } | 495 | } |
612 | } | ||
613 | 496 | ||
614 | void HTC::initHingeSensor() | 497 | void HTC::initHingeSensor() |
615 | { | 498 | { |
616 | if ( m_embedix ) return; | 499 | if ( m_embedix ) return; |
617 | 500 | ||
618 | m_hinge.setName( "/dev/input/event1" ); | 501 | m_hinge.setName( "/dev/input/event1" ); |
619 | if ( !m_hinge.open( IO_ReadOnly ) ) | 502 | if ( !m_hinge.open( IO_ReadOnly ) ) |
620 | { | 503 | { |