summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2005-01-01 17:34:32 (UTC)
committer mickeyl <mickeyl>2005-01-01 17:34:32 (UTC)
commita62cf9bfb9814a6f5ce5aa8d59fbe5b0cfb8414a (patch) (side-by-side diff)
treece7f0961815c32782c92009efc197a606b0ab86b /libopie2
parent8467a23d6a7f4b52619b60462c8ba80d8a736a9e (diff)
downloadopie-a62cf9bfb9814a6f5ce5aa8d59fbe5b0cfb8414a.zip
opie-a62cf9bfb9814a6f5ce5aa8d59fbe5b0cfb8414a.tar.gz
opie-a62cf9bfb9814a6f5ce5aa8d59fbe5b0cfb8414a.tar.bz2
clean up a bit and start w/ introducing SL-6000 support
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp124
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h47
2 files changed, 85 insertions, 86 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index ebe1949..1894e15 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,16 +1,16 @@
/*
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
- =.
+ =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
@@ -98,25 +98,26 @@ struct z_button z_buttons_c700 [] = {
"QPE/TaskBar", "toggleStartMenu()" },
{ Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
"devicebuttons/z_hinge",
"QPE/Rotation", "rotateDefault()",
"QPE/Dummy", "doNothing()" },
};
// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
// class up into individual classes. We need three classes
//
// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
-// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
+// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000)
+// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000)
//
// Only question right now is: Do we really need to do it? Because as soon
// as the OpenZaurus kernel is ready, there will be a unified interface for all
// Zaurus models (concerning apm, backlight, buttons, etc.)
//
// Comments? - mickeyl.
void Zaurus::init(const QString& cpu_info)
{
// 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 ) )
@@ -125,25 +126,25 @@ void Zaurus::init(const QString& cpu_info)
d->m_vendor = Vendor_Sharp;
d->m_systemstr = "Zaurus";
d->m_system = System_Zaurus;
m_embedix = true;
}
else
{
d->m_vendorstr = "OpenZaurus Team";
d->m_systemstr = "OpenZaurus";
d->m_system = System_OpenZaurus;
// sysver already gathered
- // Openzaurus sometimes uses the embedix kernel, check if this is one
+ // OpenZaurus sometimes uses the 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();
int loc = line. find ( "embedix" );
if ( loc != -1 )
m_embedix = true;
else
m_embedix = false;
f.close();
@@ -158,51 +159,51 @@ void Zaurus::init(const QString& cpu_info)
model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
else
model = cpu_info;
if ( model == "SHARP Corgi" ) {
d->m_model = Model_Zaurus_SLC7x0;
d->m_modelstr = "Zaurus SL-C700";
} else if ( model == "SHARP Shepherd" ) {
d->m_model = Model_Zaurus_SLC7x0;
d->m_modelstr = "Zaurus SL-C750";
} else if ( model == "SHARP Husky" ) {
d->m_model = Model_Zaurus_SLC7x0;
- d->m_modelstr = "Zaurus SL-C760";
+ d->m_modelstr = "Zaurus SL-C760 or SL-C860";
} else if ( model == "SHARP Poodle" ) {
d->m_model = Model_Zaurus_SLB600;
d->m_modelstr = "Zaurus SL-B500 or SL-5600";
} else if ( model == "Sharp-Collie" || model == "Collie" ) {
d->m_model = Model_Zaurus_SL5500;
d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
} else if ( model == "SHARP Tosa" ) {
d->m_model = Model_Zaurus_SL6000;
d->m_modelstr = "Zaurus SL-6000";
} else {
d->m_model = Model_Zaurus_SL5500;
d->m_modelstr = "Unkown Zaurus";
}
// set initial rotation
- switch ( d->m_model ) {
- case Model_Zaurus_SL6000:
+ switch( d->m_model ) {
+ case Model_Zaurus_SL6000: // fallthrough
case Model_Zaurus_SLA300:
d->m_rotation = Rot0;
break;
case Model_Zaurus_SLC7x0:
d->m_rotation = rotation();
d->m_direction = direction();
break;
- case Model_Zaurus_SLB600:
- case Model_Zaurus_SL5500:
+ case Model_Zaurus_SLB600: // fallthrough
+ case Model_Zaurus_SL5500: // fallthrough
case Model_Zaurus_SL5000:
default:
d->m_rotation = Rot270;
break;
}
m_leds [0] = Led_Off;
}
void Zaurus::initButtons()
{
if ( d->m_buttons )
return;
@@ -231,101 +232,40 @@ void Zaurus::initButtons()
b. setPixmap ( Resource::loadPixmap ( zb->pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
zb->fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ),
zb->fheldaction ));
d->m_buttons->append ( b );
}
reloadButtonMapping();
}
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-
-//#include <asm/sharp_char.h> // including kernel headers is evil ...
-
-#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
-
-#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
-#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
-
-#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
-#define SHARP_BUZ_KEYSOUND 2 /* key sound */
-#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
-/* --- for SHARP_BUZZER device --- */
-
-//#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
-//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
-
-#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
-#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
-#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
-#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
-#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
-
-//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
-//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
-
-//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
-//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
-//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
-//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
-//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
-//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
-//#define SHARP_PDA_APPSTART 9 /* application start */
-//#define SHARP_PDA_APPQUIT 10 /* application ends */
-
-//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
-//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
-//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
-//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
-//
-
-#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
-#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
-
-#define SHARP_IOCTL_GET_ROTATION 0x413c
typedef struct sharp_led_status {
-int which; /* select which LED status is wanted. */
-int status; /* set new led status if you call SHARP_LED_SETSTATUS */
+ int which; /* select which LED status is wanted. */
+ int status; /* set new led status if you call SHARP_LED_SETSTATUS */
} sharp_led_status;
-#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
-
-#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
-#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
-#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
-
-// #include <asm/sharp_apm.h> // including kernel headers is evil ...
-
-#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
-#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
-#define APM_EVT_POWER_BUTTON (1 << 0)
-
-#define FL_IOCTL_STEP_CONTRAST 100
-
-
-void Zaurus::buzzer ( int sound )
+void Zaurus::buzzer( int sound )
{
#ifndef QT_NO_SOUND
Sound *snd = 0;
// Not all devices have real sound
if ( d->m_model == Model_Zaurus_SLC7x0
- || d->m_model == Model_Zaurus_SLB600 ){
+ || d->m_model == Model_Zaurus_SLB600
+ || d->m_model == Model_Zaurus_SL6000 ) {
switch ( sound ){
case SHARP_BUZ_TOUCHSOUND: {
static Sound touch_sound("touchsound");
snd = &touch_sound;
}
break;
case SHARP_BUZ_KEYSOUND: {
static Sound key_sound( "keysound" );
snd = &key_sound;
}
break;
@@ -334,51 +274,51 @@ void Zaurus::buzzer ( int sound )
static Sound alarm_sound("alarm");
snd = &alarm_sound;
}
break;
}
}
// If a soundname is defined, we expect that this device has
// sound capabilities.. Otherwise we expect to have the buzzer
// device..
if ( snd && snd->isFinished() ){
changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
- snd-> play();
+ snd->play();
} else if( !snd ) {
int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
if ( fd >= 0 ) {
::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
::close ( fd );
}
}
#endif
}
void Zaurus::playAlarmSound()
{
- buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
+ buzzer( SHARP_BUZ_SCHEDULE_ALARM );
}
void Zaurus::playTouchSound()
{
- buzzer ( SHARP_BUZ_TOUCHSOUND );
+ buzzer( SHARP_BUZ_TOUCHSOUND );
}
void Zaurus::playKeySound()
{
- buzzer ( SHARP_BUZ_KEYSOUND );
+ buzzer( SHARP_BUZ_KEYSOUND );
}
QValueList <OLed> Zaurus::ledList() const
{
QValueList <OLed> vl;
vl << Led_Mail;
return vl;
}
QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
{
@@ -455,51 +395,65 @@ bool Zaurus::setSoftSuspend ( bool soft )
}
else
perror ( "APM_IOCGEVTSRC" );
::close ( fd );
}
else
perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
return res;
}
-
-bool Zaurus::setDisplayBrightness ( int bright )
+bool Zaurus::setDisplayBrightness( int bright )
{
//qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
bool res = false;
int fd;
if ( bright > 255 ) bright = 255;
if ( bright < 0 ) bright = 0;
if ( m_embedix )
{
if ( d->m_model == Model_Zaurus_SLC7x0 )
{
//qDebug( "using special treatment for devices with the corgi backlight interface" );
// special treatment for devices with the corgi backlight interface
if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
{
int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) );
char writeCommand[100];
- const int count = sprintf( writeCommand, "0x%x\n", value );
+ const int count = sprintf( writeCommand, "%x\n", value );
res = ( ::write ( fd, writeCommand, count ) != -1 );
::close ( fd );
}
return res;
}
else
+ if ( d->m_model == Model_Zaurus_SL6000 )
+ {
+ //qDebug( "using special treatment for devices with the tosa backlight interface" );
+ // special treatment for devices with the tosa backlight interface
+ if (( fd = ::open ( "/proc/driver/fl/tosa-bl", O_WRONLY )) >= 0 )
+ {
+ int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) );
+ char writeCommand[100];
+ const int count = sprintf( writeCommand, "%x\n", value );
+ res = ( ::write ( fd, writeCommand, count ) != -1 );
+ ::close ( fd );
+ }
+ return res;
+ }
+ else
{
// standard treatment for devices with the dumb embedix frontlight interface
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
@@ -605,27 +559,33 @@ ODirection Zaurus::direction() const
case Model_Zaurus_SL5000:
default:
dir = d->m_direction;
break;
}
return dir;
}
int Zaurus::displayBrightnessResolution() const
{
if (m_embedix)
- return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5;
+ {
+ if ( d->m_model == Model_Zaurus_SLC7x0 ) return 18;
+ if ( d->m_model == Model_Zaurus_SL6000 ) return 18;
+ return 5;
+ }
else
+ {
return 256;
+ }
}
bool Zaurus::hasHingeSensor() const
{
return d->m_model == Model_Zaurus_SLC7x0;
}
OHingeStatus Zaurus::readHingeSensor()
{
int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
if (handle == -1)
{
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index 76a40d6..dc21546 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -1,16 +1,16 @@
/*
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
- =.
+ =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
@@ -28,39 +28,78 @@
*/
#ifndef ODEVICE_ZAURUS
#define ODEVICE_ZAURUS
#include <opie2/odevice.h>
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
// _IO and friends are only defined in kernel headers ...
-
#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
-
#define OD_IO(type,number) OD_IOC(0,type,number,0)
#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
+// Audio
+#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
+
+#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
+#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
+
+#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
+#define SHARP_BUZ_KEYSOUND 2 /* key sound */
+#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
+
+#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
+#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
+#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
+#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
+#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
+
+// LED
+#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
+#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
+#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
+
+#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
+#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
+#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
+
+// Rotation and Power Management
+#define SHARP_IOCTL_GET_ROTATION 0x413c
+
+#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
+#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
+#define APM_EVT_POWER_BUTTON (1 << 0)
+
+// Brightness
+#define FL_IOCTL_STEP_CONTRAST 100
+
+#define CORGI_TOSA_BL_IOCTL_ON 1
+#define CORGI_TOSA_BL_IOCTL_OFF 2
+#define CORGI_TOSA_BL_IOCTL_STEP_CONTRAST 100
+#define CORGI_TOSA_BL_IOCTL_GET_STEP_CONTRAST 101
+#define CORGI_TOSA_BL_IOCTL_GET_STEP 102
+#define CORGI_BL_PROC_DEVICE corgi-bl
+#define TOSA_BL_PROC_DEVICE tosa-bl
namespace Opie {
namespace Core {
namespace Internal {
class Zaurus : public ODevice
{
-
protected:
virtual void init(const QString&);
virtual void initButtons();
public:
virtual bool setSoftSuspend ( bool soft );
virtual bool setDisplayBrightness ( int b );
virtual int displayBrightnessResolution() const;
virtual void playAlarmSound();
virtual void playKeySound();