summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-12-08 15:17:16 (UTC)
committer mickeyl <mickeyl>2003-12-08 15:17:16 (UTC)
commit7f2f736597490fd1592d7ed1f40e4abf824673c0 (patch) (side-by-side diff)
tree542b6f52b3556f1f4f04c18c15446c73a867ebdc
parentb1182e6a5069c7109f824a916e566c9c1954ded8 (diff)
downloadopie-7f2f736597490fd1592d7ed1f40e4abf824673c0.zip
opie-7f2f736597490fd1592d7ed1f40e4abf824673c0.tar.gz
opie-7f2f736597490fd1592d7ed1f40e4abf824673c0.tar.bz2
Rot270 is not a Direction, but a Rotation. treke, is this fix correct?
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie/odevice.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 5038cc9..e24e043 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1859,385 +1859,385 @@ QValueList <OLed> Zaurus::ledList ( ) const
}
QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
{
QValueList <OLedState> vl;
if ( l == Led_Mail )
vl << Led_Off << Led_On << Led_BlinkSlow;
return vl;
}
OLedState Zaurus::ledState ( OLed which ) const
{
if ( which == Led_Mail )
return m_leds [0];
else
return Led_Off;
}
bool Zaurus::setLedState ( OLed which, OLedState st )
{
if (!m_embedix) // Currently not supported on non_embedix kernels
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;
}
}
}
return false;
}
bool Zaurus::setSoftSuspend ( bool soft )
{
if (!m_embedix) {
/* non-Embedix kernels dont have kernel autosuspend */
return ODevice::setSoftSuspend( soft );
}
bool res = false;
int fd;
if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
(( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
if ( sources >= 0 ) {
if ( soft )
sources &= ~APM_EVT_POWER_BUTTON;
else
sources |= APM_EVT_POWER_BUTTON;
if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
res = true;
else
perror ( "APM_IOCGEVTSRC" );
}
else
perror ( "APM_IOCGEVTSRC" );
::close ( fd );
}
else
perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
return res;
}
bool Zaurus::setDisplayBrightness ( int bright )
{
// FIXME The C7x0 have a proc-interface (/proc/drivers/corgi-bl) which
// is nice to use. Currently it exposes 16+1 levels. Implement this!
// (or wait for kergoth unifying the interfaces in the OpenZaurus kernel.)
bool res = false;
int fd;
if ( bright > 255 )
bright = 255;
if ( bright < 0 )
bright = 0;
if (m_embedix) {
if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
if ( bright && !bl )
bl = 1;
res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
::close ( fd );
}
} else {
#define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
::close ( fd );
}
}
return res;
}
bool Zaurus::suspend ( )
{
qDebug("ODevice::suspend");
if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
return false;
bool res = false;
struct timeval tvs, tvn;
::gettimeofday ( &tvs, 0 );
::sync ( ); // flush fs caches
res = ( ::system ( "apm --suspend" ) == 0 );
// This is needed because the iPAQ apm implementation is asynchronous and we
// can not be sure when exactly the device is really suspended
// This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
if ( res ) {
do { // Yes, wait 15 seconds. This APM bug sucks big time.
::usleep ( 200 * 1000 );
::gettimeofday ( &tvn, 0 );
} while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
}
QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
return res;
}
Transformation Zaurus::rotation ( ) const
{
Transformation rot;
int handle = 0;
int retval = 0;
switch ( d-> m_model ) {
case Model_Zaurus_SLC7x0:
handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
if (handle == -1) {
return Rot270;
} else {
retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
::close (handle);
if (retval == 2 )
rot = Rot0;
else
rot = Rot270;
}
break;
case Model_Zaurus_SLA300:
case Model_Zaurus_SLB600:
case Model_Zaurus_SL5500:
case Model_Zaurus_SL5000:
default:
rot = d-> m_rotation;
break;
}
return rot;
}
ODirection Zaurus::direction ( ) const
{
ODirection dir;
int handle = 0;
int retval = 0;
switch ( d-> m_model ) {
case Model_Zaurus_SLC7x0:
handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
if (handle == -1) {
- dir = Rot270;
+ dir = CW;
} else {
retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
::close (handle);
if (retval == 2 )
dir = CCW;
else
dir = CW;
}
break;
case Model_Zaurus_SLA300:
case Model_Zaurus_SLB600:
case Model_Zaurus_SL5500:
case Model_Zaurus_SL5000:
default:
dir = d-> m_direction;
break;
}
return dir;
}
int Zaurus::displayBrightnessResolution ( ) const
{
if (m_embedix)
return 5;
else
return 256;
}
/**************************************************
*
* SIMpad
*
**************************************************/
void SIMpad::init ( )
{
d-> m_vendorstr = "SIEMENS";
d-> m_vendor = Vendor_SIEMENS;
QFile f ( "/proc/hal/model" );
//TODO Implement model checking
//FIXME For now we assume an SL4
d-> m_modelstr = "SL4";
d-> m_model = Model_SIMpad_SL4;
switch ( d-> m_model ) {
default:
d-> m_rotation = Rot0;
d-> m_direction = CCW;
d-> m_holdtime = 1000; // 1000ms
break;
}
f. setName ( "/etc/familiar-version" );
if ( f. open ( IO_ReadOnly )) {
d-> m_systemstr = "Familiar";
d-> m_system = System_Familiar;
QTextStream ts ( &f );
d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
f. close ( );
} else {
f. setName ( "/etc/oz_version" );
if ( f. open ( IO_ReadOnly )) {
d-> m_systemstr = "OpenEmbedded/SIMpad";
d-> m_system = System_OpenZaurus;
QTextStream ts ( &f );
ts.setDevice ( &f );
d-> m_sysverstr = ts. readLine ( );
f. close ( );
}
}
m_leds [0] = m_leds [1] = Led_Off;
m_power_timer = 0;
}
void SIMpad::initButtons ( )
{
if ( d-> m_buttons )
return;
if ( isQWS( ) )
QWSServer::setKeyboardFilter ( this );
d-> m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
s_button *sb = simpad_buttons + i;
ODeviceButton b;
if (( sb-> model & d-> m_model ) == d-> m_model ) {
b. setKeycode ( sb-> code );
b. setUserText ( QObject::tr ( "Button", sb-> utext ));
b. setPixmap ( Resource::loadPixmap ( sb-> pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction ));
d-> m_buttons-> append ( b );
}
}
reloadButtonMapping ( );
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
}
// SIMpad boardcontrol register CS3
#define SIMPAD_BOARDCONTROL "/proc/cs3"
#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
#define SIMPAD_EN1 0x0004 // This is only for EPROM's
#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
#define SIMPAD_DISPLAY_ON 0x0010
#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
#define SIMPAD_MQ_RESET 0x0040
#define SIMPAD_PCMCIA_RESET 0x0080
#define SIMPAD_DECT_POWER_ON 0x0100
#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
#define SIMPAD_RS232_ON 0x0400
#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
#define SIMPAD_LED2_ON 0x1000
#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
#define SIMPAD_RESET_SIMCARD 0x8000
//SIMpad touchscreen backlight strength control
#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
#define SIMPAD_BACKLIGHT_MASK 0x00a10044
QValueList <OLed> SIMpad::ledList ( ) const
{
QValueList <OLed> vl;
vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
//vl << Led_Mail; //TODO find out if LED1 is accessible anyway
return vl;
}
QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
{
QValueList <OLedState> vl;
if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
vl << Led_Off << Led_On;
//else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
//vl << Led_Off;
return vl;
}
OLedState SIMpad::ledState ( OLed l ) const
{
switch ( l ) {
case Led_Power:
return m_leds [0];
//case Led_Mail:
// return m_leds [1];
default:
return Led_Off;
}
}
bool SIMpad::setLedState ( OLed l, OLedState st )
{
static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
if ( l == Led_Power ) {
if ( fd >= 0 ) {
LED_IN leds;
::memset ( &leds, 0, sizeof( leds ));
leds. TotalTime = 0;
leds. OnTime = 0;
leds. OffTime = 1;
leds. OffOnBlink = 2;
switch ( st ) {
case Led_Off : leds. OffOnBlink = 0; break;
case Led_On : leds. OffOnBlink = 1; break;
case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
}
{
/*TODO Implement this like that: