-rw-r--r-- | libopie/odevice.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 71ed9e4..9373ef9 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1472,48 +1472,61 @@ int iPAQ::readLightSensor ( ) | |||
1472 | buffer [4] = 0; | 1472 | buffer [4] = 0; |
1473 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1473 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1474 | 1474 | ||
1475 | if ( *endptr != 0 ) | 1475 | if ( *endptr != 0 ) |
1476 | val = -1; | 1476 | val = -1; |
1477 | } | 1477 | } |
1478 | ::close ( fd ); | 1478 | ::close ( fd ); |
1479 | } | 1479 | } |
1480 | 1480 | ||
1481 | return val; | 1481 | return val; |
1482 | } | 1482 | } |
1483 | 1483 | ||
1484 | int iPAQ::lightSensorResolution ( ) const | 1484 | int iPAQ::lightSensorResolution ( ) const |
1485 | { | 1485 | { |
1486 | return 256; | 1486 | return 256; |
1487 | } | 1487 | } |
1488 | 1488 | ||
1489 | /************************************************** | 1489 | /************************************************** |
1490 | * | 1490 | * |
1491 | * Zaurus | 1491 | * Zaurus |
1492 | * | 1492 | * |
1493 | **************************************************/ | 1493 | **************************************************/ |
1494 | 1494 | ||
1495 | // Check whether this device is the sharp zaurus.. | 1495 | // Check whether this device is the sharp zaurus.. |
1496 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | ||
1497 | // class up into individual classes. We need three classes | ||
1498 | // | ||
1499 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | ||
1500 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | ||
1501 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) | ||
1502 | // | ||
1503 | // Only question right now is: Do we really need to do it? Because as soon | ||
1504 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | ||
1505 | // Zaurus models (concerning apm, backlight, buttons, etc.) | ||
1506 | // | ||
1507 | // Comments? - mickeyl. | ||
1508 | |||
1496 | bool Zaurus::isZaurus() | 1509 | bool Zaurus::isZaurus() |
1497 | { | 1510 | { |
1498 | 1511 | ||
1499 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! | 1512 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! |
1500 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ | 1513 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ |
1501 | return true; | 1514 | return true; |
1502 | } | 1515 | } |
1503 | 1516 | ||
1504 | // On non-embedix kernels, we have to look closer. | 1517 | // On non-embedix kernels, we have to look closer. |
1505 | bool is_zaurus = false; | 1518 | bool is_zaurus = false; |
1506 | QFile f ( "/proc/cpuinfo" ); | 1519 | QFile f ( "/proc/cpuinfo" ); |
1507 | if ( f. open ( IO_ReadOnly ) ) { | 1520 | if ( f. open ( IO_ReadOnly ) ) { |
1508 | QString model; | 1521 | QString model; |
1509 | QFile f ( "/proc/cpuinfo" ); | 1522 | QFile f ( "/proc/cpuinfo" ); |
1510 | 1523 | ||
1511 | QTextStream ts ( &f ); | 1524 | QTextStream ts ( &f ); |
1512 | QString line; | 1525 | QString line; |
1513 | while( line = ts. readLine ( ) ) { | 1526 | while( line = ts. readLine ( ) ) { |
1514 | if ( line. left ( 8 ) == "Hardware" ) | 1527 | if ( line. left ( 8 ) == "Hardware" ) |
1515 | break; | 1528 | break; |
1516 | } | 1529 | } |
1517 | int loc = line. find ( ":" ); | 1530 | int loc = line. find ( ":" ); |
1518 | if ( loc != -1 ) | 1531 | if ( loc != -1 ) |
1519 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1532 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
@@ -1602,48 +1615,49 @@ void Zaurus::init ( ) | |||
1602 | } else if ( model == "SHARP Husky" ) { | 1615 | } else if ( model == "SHARP Husky" ) { |
1603 | d-> m_model = Model_Zaurus_SLC7x0; | 1616 | d-> m_model = Model_Zaurus_SLC7x0; |
1604 | d-> m_modelstr = "Zaurus SL-C760"; | 1617 | d-> m_modelstr = "Zaurus SL-C760"; |
1605 | } else if ( model == "SHARP Poodle" ) { | 1618 | } else if ( model == "SHARP Poodle" ) { |
1606 | d-> m_model = Model_Zaurus_SLB600; | 1619 | d-> m_model = Model_Zaurus_SLB600; |
1607 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1620 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1608 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 1621 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
1609 | d-> m_model = Model_Zaurus_SL5500; | 1622 | d-> m_model = Model_Zaurus_SL5500; |
1610 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1623 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1611 | } else { | 1624 | } else { |
1612 | d-> m_model = Model_Zaurus_SL5500; | 1625 | d-> m_model = Model_Zaurus_SL5500; |
1613 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1626 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1614 | } | 1627 | } |
1615 | 1628 | ||
1616 | bool flipstate = false; | 1629 | bool flipstate = false; |
1617 | switch ( d-> m_model ) { | 1630 | switch ( d-> m_model ) { |
1618 | case Model_Zaurus_SLA300: | 1631 | case Model_Zaurus_SLA300: |
1619 | d-> m_rotation = Rot0; | 1632 | d-> m_rotation = Rot0; |
1620 | break; | 1633 | break; |
1621 | case Model_Zaurus_SLC7x0: | 1634 | case Model_Zaurus_SLC7x0: |
1622 | // Note: need to 1) set flipstate based on physical screen orientation | 1635 | // Note: need to 1) set flipstate based on physical screen orientation |
1623 | // and 2) check to see if the user overrode the rotation direction | 1636 | // and 2) check to see if the user overrode the rotation direction |
1624 | // using appearance, and if so, remove that item from the Config to | 1637 | // using appearance, and if so, remove that item from the Config to |
1625 | // ensure the rotate applet flips us back to the previous state. | 1638 | // ensure the rotate applet flips us back to the previous state. |
1639 | // treke said he has patches for detecting the phys. so where are they, treke? -mickeyl. | ||
1626 | if ( flipstate ) { | 1640 | if ( flipstate ) { |
1627 | // 480x640 | 1641 | // 480x640 |
1628 | d-> m_rotation = Rot0; | 1642 | d-> m_rotation = Rot0; |
1629 | d-> m_direction = CW; | 1643 | d-> m_direction = CW; |
1630 | } else { | 1644 | } else { |
1631 | // 640x480 | 1645 | // 640x480 |
1632 | d-> m_rotation = Rot270; | 1646 | d-> m_rotation = Rot270; |
1633 | d-> m_direction = CCW; | 1647 | d-> m_direction = CCW; |
1634 | } | 1648 | } |
1635 | break; | 1649 | break; |
1636 | case Model_Zaurus_SLB600: | 1650 | case Model_Zaurus_SLB600: |
1637 | case Model_Zaurus_SL5500: | 1651 | case Model_Zaurus_SL5500: |
1638 | case Model_Zaurus_SL5000: | 1652 | case Model_Zaurus_SL5000: |
1639 | default: | 1653 | default: |
1640 | d-> m_rotation = Rot270; | 1654 | d-> m_rotation = Rot270; |
1641 | break; | 1655 | break; |
1642 | } | 1656 | } |
1643 | m_leds [0] = Led_Off; | 1657 | m_leds [0] = Led_Off; |
1644 | } | 1658 | } |
1645 | 1659 | ||
1646 | void Zaurus::initButtons ( ) | 1660 | void Zaurus::initButtons ( ) |
1647 | { | 1661 | { |
1648 | if ( d-> m_buttons ) | 1662 | if ( d-> m_buttons ) |
1649 | return; | 1663 | return; |
@@ -1915,48 +1929,51 @@ bool Zaurus::setSoftSuspend ( bool soft ) | |||
1915 | if ( soft ) | 1929 | if ( soft ) |
1916 | sources &= ~APM_EVT_POWER_BUTTON; | 1930 | sources &= ~APM_EVT_POWER_BUTTON; |
1917 | else | 1931 | else |
1918 | sources |= APM_EVT_POWER_BUTTON; | 1932 | sources |= APM_EVT_POWER_BUTTON; |
1919 | 1933 | ||
1920 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1934 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1921 | res = true; | 1935 | res = true; |
1922 | else | 1936 | else |
1923 | perror ( "APM_IOCGEVTSRC" ); | 1937 | perror ( "APM_IOCGEVTSRC" ); |
1924 | } | 1938 | } |
1925 | else | 1939 | else |
1926 | perror ( "APM_IOCGEVTSRC" ); | 1940 | perror ( "APM_IOCGEVTSRC" ); |
1927 | 1941 | ||
1928 | ::close ( fd ); | 1942 | ::close ( fd ); |
1929 | } | 1943 | } |
1930 | else | 1944 | else |
1931 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1945 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1932 | 1946 | ||
1933 | return res; | 1947 | return res; |
1934 | } | 1948 | } |
1935 | 1949 | ||
1936 | 1950 | ||
1937 | bool Zaurus::setDisplayBrightness ( int bright ) | 1951 | bool Zaurus::setDisplayBrightness ( int bright ) |
1938 | { | 1952 | { |
1953 | // FIXME The C7x0 have a proc-interface (/proc/drivers/corgi-bl) which | ||
1954 | // is nice to use. Currently it exposes 16+1 levels. Implement this! | ||
1955 | // (or wait for kergoth unifying the interfaces in the OpenZaurus kernel.) | ||
1939 | bool res = false; | 1956 | bool res = false; |
1940 | int fd; | 1957 | int fd; |
1941 | 1958 | ||
1942 | if ( bright > 255 ) | 1959 | if ( bright > 255 ) |
1943 | bright = 255; | 1960 | bright = 255; |
1944 | if ( bright < 0 ) | 1961 | if ( bright < 0 ) |
1945 | bright = 0; | 1962 | bright = 0; |
1946 | 1963 | ||
1947 | if (m_embedix) { | 1964 | if (m_embedix) { |
1948 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1965 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1949 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1966 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1950 | if ( bright && !bl ) | 1967 | if ( bright && !bl ) |
1951 | bl = 1; | 1968 | bl = 1; |
1952 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1969 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1953 | ::close ( fd ); | 1970 | ::close ( fd ); |
1954 | } | 1971 | } |
1955 | } else { | 1972 | } else { |
1956 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 1973 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ |
1957 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 1974 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { |
1958 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | 1975 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); |
1959 | ::close ( fd ); | 1976 | ::close ( fd ); |
1960 | } | 1977 | } |
1961 | } | 1978 | } |
1962 | return res; | 1979 | return res; |