author | llornkcor <llornkcor> | 2006-07-14 20:15:58 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2006-07-14 20:15:58 (UTC) |
commit | 20b8c8eb22b5498647430da49986f75b78cf2d79 (patch) (side-by-side diff) | |
tree | 0309ad594266a40cf17959b5c0d322933b6256ca /libopie2 | |
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 | 255 |
2 files changed, 76 insertions, 186 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 @@ -75,4 +75,5 @@ enum OModel { Model_Jornada_56x = ( Model_Jornada | 0x0001 ), Model_Jornada_720 = ( Model_Jornada | 0x0002 ), + Model_Jornada_820 = ( Model_Jornada | 0x0003 ), Model_Zaurus = ( 2 << 16 ), @@ -126,4 +127,10 @@ enum OModel { Model_HTC_All = ( Model_HTC | 0xffff ), Model_HTC_Universal = ( Model_HTC | 0x0001 ), + Model_HTC_Alpine = ( Model_HTC | 0x0002 ), + Model_HTC_Apache = ( Model_HTC | 0x0003 ), + Model_HTC_Beetles = ( Model_HTC | 0x0004 ), + Model_HTC_Blueangel = ( Model_HTC | 0x0005 ), + Model_HTC_Himalaya = ( Model_HTC | 0x0006 ), + Model_HTC_Magician = ( Model_HTC | 0x0007 ), Model_Motorola = ( 9 << 17 ), 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 @@ -117,39 +117,13 @@ struct htc_button htc_buttons_universal [] = { }; -struct htc_button htc_buttons_6000 [] = { - { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), - "devicebuttons/z_calendar", - "datebook", "nextView()", - "today", "raise()" }, - { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), - "devicebuttons/z_contact", - "addressbook", "raise()", - "addressbook", "beamBusinessCard()" }, - { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), - "devicebuttons/z_home", - "QPE/Launcher", "home()", - "buttonsettings", "raise()" }, - { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), - "devicebuttons/z_menu", - "QPE/TaskBar", "toggleMenu()", - "QPE/TaskBar", "toggleStartMenu()" }, - { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), - "devicebuttons/z_mail", - "opiemail", "raise()", - "opiemail", "newMail()" }, - { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Rotate Button"), - "devicebuttons/z_rotate", - 0, - "QPE/Rotation", "rotateDefault()" }, - { Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), - "devicebuttons/z_hinge3", - "QPE/VMemo", "toggleRecord()", - "sound", "raise()" }, -}; -// FIXME This gets unnecessary complicated. We should think about splitting the HTC -// class up into individual classes. We would need three classes // -// HTC-Universal (PXA-model w/ 640x480 lcd, for Universal) +// HTC-Universal (PXA-model w/ 480x640 3.6" lcd) +// HTC-Alpine (PXA-model w/ 240x320 3.5" lcd) +// HTC-Apache (PXA-model w/ 240x320 2.8" lcd) +// HTC-Beetles (PXA-model w/ 240x240 3.0" lcd) +// HTC-Blueangel (PXA-model w/ 240x320 3.5" lcd) +// HTC-Himalaya (PXA-model w/ 240x320 3.5" lcd) +// HTC-Magician (PXA-model w/ 240x320 2.8" lcd) void HTC::init(const QString& cpu_info) @@ -160,33 +134,7 @@ void HTC::init(const QString& cpu_info) setAPMTimeOut( 15000 ); - // generic distribution code already scanned /etc/issue at that point - - // embedix releases contain "Embedix <version> | Linux for Embedded Devices" - if ( d->m_sysverstr.contains( "embedix", false ) ) - { - d->m_vendorstr = "HTC"; - d->m_vendor = Vendor_HTC; - d->m_systemstr = "OpenEmbedded"; - d->m_system = System_OpenEmbedded; - m_embedix = true; - } - else - { - d->m_vendorstr = "Xanadux Team"; - d->m_systemstr = "Familiar"; - d->m_system = System_Familiar; - // sysver already gathered - - // OpenHTC sometimes uses the 2.4 (embedix) kernel, check if this is one - FILE *uname = popen("uname -r", "r"); - QFile f; - QString line; - if ( f.open(IO_ReadOnly, uname) ) { - QTextStream ts ( &f ); - line = ts.readLine(); - m_embedix = line.startsWith( "2.4." ); - f.close(); - } - pclose(uname); - } + d->m_vendorstr = "Xanadux Team"; + d->m_systemstr = "Familiar"; + d->m_system = System_Familiar; // check the HTC model @@ -198,18 +146,52 @@ void HTC::init(const QString& cpu_info) model = cpu_info; + d->m_model = Model_HTC_Universal; + d->m_modelstr = "Unknown HTC"; + if ( model == "HTC Universal" ) { d->m_model = Model_HTC_Universal; d->m_modelstr = "HTC Universal"; - } else { - d->m_model = Model_HTC_Universal; - d->m_modelstr = "Unknown HTC"; + } + if ( model == "HTC Alpine" ) { + d->m_model = Model_HTC_Alpine; + d->m_modelstr = "HTC Alpine"; + } + if ( model == "HTC Apache" ) { + d->m_model = Model_HTC_Apache; + d->m_modelstr = "HTC Apache"; + } + if ( model == "HTC Beetles" ) { + d->m_model = Model_HTC_Beetles; + d->m_modelstr = "HTC Beetles"; + } + if ( model == "HTC Blueangel" ) { + d->m_model = Model_HTC_Blueangel; + d->m_modelstr = "HTC Blueangel"; + } + if ( model == "HTC Himalaya" ) { + d->m_model = Model_HTC_Himalaya; + d->m_modelstr = "HTC Himalaya"; + } + if ( model == "HTC Magician" ) { + d->m_model = Model_HTC_Magician; + d->m_modelstr = "HTC Magician"; } - // set path to backlight device in kernel 2.6 + + // set path to backlight device switch ( d->m_model ) { case Model_HTC_Universal: + case Model_HTC_Magician: + case Model_HTC_Alpine: + case Model_HTC_Beetles: + case Model_HTC_Apache: + m_backlightdev = "/sys/class/backlight/pxa2xx-fb/"; + break; + case Model_HTC_Blueangel: + case Model_HTC_Himalaya: + m_backlightdev = "/sys/class/backlight/w100fb/"; + break; default: -// m_backlightdev = "/sys/class/backlight/corgi-bl/"; m_backlightdev = "/sys/class/backlight/pxafb/"; } @@ -236,8 +218,5 @@ void HTC::init(const QString& cpu_info) m_leds[0] = Led_Off; - if ( m_embedix ) - qDebug( "HTC::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); - else - qDebug( "HTC::init() - Using the 2.6 Xanadux HAL on a %s", (const char*) d->m_modelstr ); + qDebug( "HTC::init() - Using the 2.6 Xanadux on a %s", (const char*) d->m_modelstr ); } @@ -379,33 +358,5 @@ OLedState HTC::ledState( OLed which ) const bool HTC::setLedState( OLed which, OLedState st ) { - // Currently not supported on non_embedix kernels - if (!m_embedix) - { - qDebug( "HTC::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); - return false; - } - - static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); - - if ( which == Led_Mail ) { - if ( fd >= 0 ) { - struct sharp_led_status leds; - ::memset ( &leds, 0, sizeof( leds )); - leds. which = SHARP_LED_MAIL_EXISTS; - bool ok = true; - - switch ( st ) { - case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; - case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; - case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; - default : ok = false; - } - - if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { - m_leds [0] = st; - return true; - } - } - } + qDebug( "HTC::setLedState: ODevice handling not yet implemented" ); return false; } @@ -413,21 +364,8 @@ bool HTC::setLedState( OLed which, OLedState st ) int HTC::displayBrightnessResolution() const { -/* MV */ - return 16; - int res = 1; - if (m_embedix) - { - int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); - if ( fd ) - { - int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); - ::close( fd ); - return value ? value : res; - } - } - else - { - int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); + + int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); + if ( fd ) { @@ -436,5 +374,5 @@ int HTC::displayBrightnessResolution() const ::close( fd ); } - } + return res; } @@ -442,6 +380,4 @@ int HTC::displayBrightnessResolution() const bool HTC::setDisplayBrightness( int bright ) { -/* MV */ - return false; //qDebug( "HTC::setDisplayBrightness( %d )", bright ); @@ -454,23 +390,11 @@ bool HTC::setDisplayBrightness( int bright ) int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; - if ( m_embedix ) + int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); + if ( fd ) { - int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); - if ( fd ) - { - res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); - ::close( fd ); - } - } - else - { - int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); - if ( fd ) - { - char buf[100]; - int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); - res = ( ::write( fd, &buf[0], len ) == 0 ); - ::close( fd ); - } + char buf[100]; + int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); + res = ( ::write( fd, &buf[0], len ) == 0 ); + ::close( fd ); } return res; @@ -479,29 +403,15 @@ bool HTC::setDisplayBrightness( int bright ) bool HTC::setDisplayStatus( bool on ) { -/* MV */ - return false; bool res = false; - if ( m_embedix ) - { - int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); - if ( fd ) - { - int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; - res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); - ::close ( fd ); - } - } - else + + int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); + if ( fd ) { - int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); - if ( fd ) - { - char buf[10]; - buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; - buf[1] = '\0'; - res = ( ::write( fd, &buf[0], 2 ) == 0 ); - ::close( fd ); - } + char buf[10]; + buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; + buf[1] = '\0'; + res = ( ::write( fd, &buf[0], 2 ) == 0 ); + ::close( fd ); } return res; @@ -554,30 +464,4 @@ bool HTC::hasHingeSensor() const OHingeStatus HTC::readHingeSensor() const { - if (m_embedix) - { - int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); - if (handle == -1) - { - qWarning("HTC::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror - return CASE_UNKNOWN; - } - else - { - int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); - ::close (handle); - if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) - { - qDebug( "HTC::readHingeSensor() - result = %d", retval ); - return static_cast<OHingeStatus>( retval ); - } - else - { - qWarning("HTC::readHingeSensor() - couldn't compute hinge status!" ); - return CASE_UNKNOWN; - } - } - } - else - { /* * The HTC Universal keyboard is event source 1 in kernel 2.6. @@ -609,5 +493,4 @@ OHingeStatus HTC::readHingeSensor() const return switch1 ? CASE_CLOSED : CASE_UNKNOWN; } - } } |