-rw-r--r-- | libopie/odevice.cpp | 81 |
1 files changed, 28 insertions, 53 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 993aedf..62dc9d4 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -732,385 +732,386 @@ QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | |||
732 | /** | 732 | /** |
733 | * @return the state for a given OLed | 733 | * @return the state for a given OLed |
734 | */ | 734 | */ |
735 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 735 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
736 | { | 736 | { |
737 | return Led_Off; | 737 | return Led_Off; |
738 | } | 738 | } |
739 | 739 | ||
740 | /** | 740 | /** |
741 | * Set the state for a LED | 741 | * Set the state for a LED |
742 | * @param which Which OLed to use | 742 | * @param which Which OLed to use |
743 | * @param st The state to set | 743 | * @param st The state to set |
744 | * @return success or failure | 744 | * @return success or failure |
745 | */ | 745 | */ |
746 | bool ODevice::setLedState ( OLed which, OLedState st ) | 746 | bool ODevice::setLedState ( OLed which, OLedState st ) |
747 | { | 747 | { |
748 | Q_UNUSED( which ) | 748 | Q_UNUSED( which ) |
749 | Q_UNUSED( st ) | 749 | Q_UNUSED( st ) |
750 | return false; | 750 | return false; |
751 | } | 751 | } |
752 | 752 | ||
753 | /** | 753 | /** |
754 | * @return if the device has a light sensor | 754 | * @return if the device has a light sensor |
755 | */ | 755 | */ |
756 | bool ODevice::hasLightSensor ( ) const | 756 | bool ODevice::hasLightSensor ( ) const |
757 | { | 757 | { |
758 | return false; | 758 | return false; |
759 | } | 759 | } |
760 | 760 | ||
761 | /** | 761 | /** |
762 | * @return a value from the light senso | 762 | * @return a value from the light senso |
763 | */ | 763 | */ |
764 | int ODevice::readLightSensor ( ) | 764 | int ODevice::readLightSensor ( ) |
765 | { | 765 | { |
766 | return -1; | 766 | return -1; |
767 | } | 767 | } |
768 | 768 | ||
769 | /** | 769 | /** |
770 | * @return the light sensor resolution whatever that is ;) | 770 | * @return the light sensor resolution whatever that is ;) |
771 | */ | 771 | */ |
772 | int ODevice::lightSensorResolution ( ) const | 772 | int ODevice::lightSensorResolution ( ) const |
773 | { | 773 | { |
774 | return 0; | 774 | return 0; |
775 | } | 775 | } |
776 | 776 | ||
777 | /** | 777 | /** |
778 | * @return a list with CPU frequencies supported by the hardware | 778 | * @return a list with CPU frequencies supported by the hardware |
779 | */ | 779 | */ |
780 | const QStrList &ODevice::allowedCpuFrequencies ( ) const | 780 | const QStrList &ODevice::allowedCpuFrequencies ( ) const |
781 | { | 781 | { |
782 | return *d->m_cpu_frequencies; | 782 | return *d->m_cpu_frequencies; |
783 | } | 783 | } |
784 | 784 | ||
785 | 785 | ||
786 | /** | 786 | /** |
787 | * Set desired CPU frequency | 787 | * Set desired CPU frequency |
788 | * | 788 | * |
789 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 789 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
790 | */ | 790 | */ |
791 | bool ODevice::setCurrentCpuFrequency(uint index) | 791 | bool ODevice::setCurrentCpuFrequency(uint index) |
792 | { | 792 | { |
793 | if (index >= d->m_cpu_frequencies->count()) | 793 | if (index >= d->m_cpu_frequencies->count()) |
794 | return false; | 794 | return false; |
795 | 795 | ||
796 | char *freq = d->m_cpu_frequencies->at(index); | 796 | char *freq = d->m_cpu_frequencies->at(index); |
797 | qWarning("set freq to %s", freq); | 797 | qWarning("set freq to %s", freq); |
798 | 798 | ||
799 | int fd; | 799 | int fd; |
800 | 800 | ||
801 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 801 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
802 | char writeCommand[50]; | 802 | char writeCommand[50]; |
803 | const int count = sprintf(writeCommand, "%s\n", freq); | 803 | const int count = sprintf(writeCommand, "%s\n", freq); |
804 | int res = (::write(fd, writeCommand, count) != -1); | 804 | int res = (::write(fd, writeCommand, count) != -1); |
805 | ::close(fd); | 805 | ::close(fd); |
806 | return res; | 806 | return res; |
807 | } | 807 | } |
808 | 808 | ||
809 | return false; | 809 | return false; |
810 | } | 810 | } |
811 | 811 | ||
812 | 812 | ||
813 | /** | 813 | /** |
814 | * @return a list of hardware buttons | 814 | * @return a list of hardware buttons |
815 | */ | 815 | */ |
816 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 816 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
817 | { | 817 | { |
818 | initButtons ( ); | 818 | initButtons ( ); |
819 | 819 | ||
820 | return *d-> m_buttons; | 820 | return *d-> m_buttons; |
821 | } | 821 | } |
822 | 822 | ||
823 | /** | 823 | /** |
824 | * @return The amount of time that would count as a hold | 824 | * @return The amount of time that would count as a hold |
825 | */ | 825 | */ |
826 | uint ODevice::buttonHoldTime ( ) const | 826 | uint ODevice::buttonHoldTime ( ) const |
827 | { | 827 | { |
828 | return d-> m_holdtime; | 828 | return d-> m_holdtime; |
829 | } | 829 | } |
830 | 830 | ||
831 | /** | 831 | /** |
832 | * This method return a ODeviceButton for a key code | 832 | * This method return a ODeviceButton for a key code |
833 | * or 0 if no special hardware button is available for the device | 833 | * or 0 if no special hardware button is available for the device |
834 | * | 834 | * |
835 | * @return The devicebutton or 0l | 835 | * @return The devicebutton or 0l |
836 | * @see ODeviceButton | 836 | * @see ODeviceButton |
837 | */ | 837 | */ |
838 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 838 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
839 | { | 839 | { |
840 | initButtons ( ); | 840 | initButtons ( ); |
841 | 841 | ||
842 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 842 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
843 | if ( (*it). keycode ( ) == code ) | 843 | if ( (*it). keycode ( ) == code ) |
844 | return &(*it); | 844 | return &(*it); |
845 | } | 845 | } |
846 | return 0; | 846 | return 0; |
847 | } | 847 | } |
848 | 848 | ||
849 | void ODevice::reloadButtonMapping ( ) | 849 | void ODevice::reloadButtonMapping ( ) |
850 | { | 850 | { |
851 | initButtons ( ); | 851 | initButtons ( ); |
852 | 852 | ||
853 | Config cfg ( "ButtonSettings" ); | 853 | Config cfg ( "ButtonSettings" ); |
854 | 854 | ||
855 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 855 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
856 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 856 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
857 | QString group = "Button" + QString::number ( i ); | 857 | QString group = "Button" + QString::number ( i ); |
858 | 858 | ||
859 | QCString pch, hch; | 859 | QCString pch, hch; |
860 | QCString pm, hm; | 860 | QCString pm, hm; |
861 | QByteArray pdata, hdata; | 861 | QByteArray pdata, hdata; |
862 | 862 | ||
863 | if ( cfg. hasGroup ( group )) { | 863 | if ( cfg. hasGroup ( group )) { |
864 | cfg. setGroup ( group ); | 864 | cfg. setGroup ( group ); |
865 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 865 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
866 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 866 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
867 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 867 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
868 | 868 | ||
869 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 869 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
870 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 870 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
871 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 871 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
872 | } | 872 | } |
873 | 873 | ||
874 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 874 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
875 | 875 | ||
876 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 876 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
877 | } | 877 | } |
878 | } | 878 | } |
879 | 879 | ||
880 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 880 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
881 | { | 881 | { |
882 | initButtons ( ); | 882 | initButtons ( ); |
883 | 883 | ||
884 | QString mb_chan; | 884 | QString mb_chan; |
885 | 885 | ||
886 | if ( button >= (int) d-> m_buttons-> count ( )) | 886 | if ( button >= (int) d-> m_buttons-> count ( )) |
887 | return; | 887 | return; |
888 | 888 | ||
889 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 889 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
890 | b. setPressedAction ( action ); | 890 | b. setPressedAction ( action ); |
891 | 891 | ||
892 | mb_chan=b. pressedAction ( ). channel ( ); | 892 | mb_chan=b. pressedAction ( ). channel ( ); |
893 | 893 | ||
894 | Config buttonFile ( "ButtonSettings" ); | 894 | Config buttonFile ( "ButtonSettings" ); |
895 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 895 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
896 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 896 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
897 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 897 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
898 | 898 | ||
899 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 899 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
900 | 900 | ||
901 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 901 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
902 | } | 902 | } |
903 | 903 | ||
904 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 904 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
905 | { | 905 | { |
906 | initButtons ( ); | 906 | initButtons ( ); |
907 | 907 | ||
908 | if ( button >= (int) d-> m_buttons-> count ( )) | 908 | if ( button >= (int) d-> m_buttons-> count ( )) |
909 | return; | 909 | return; |
910 | 910 | ||
911 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 911 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
912 | b. setHeldAction ( action ); | 912 | b. setHeldAction ( action ); |
913 | 913 | ||
914 | Config buttonFile ( "ButtonSettings" ); | 914 | Config buttonFile ( "ButtonSettings" ); |
915 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 915 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
916 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 916 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
917 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 917 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
918 | 918 | ||
919 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 919 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
920 | 920 | ||
921 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 921 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
922 | } | 922 | } |
923 | void ODevice::virtual_hook( int id, void* data ) { | 923 | void ODevice::virtual_hook( int id, void* data ) { |
924 | 924 | Q_UNUSED(id); | |
925 | Q_UNUSED(data); | ||
925 | } | 926 | } |
926 | 927 | ||
927 | 928 | ||
928 | 929 | ||
929 | /************************************************** | 930 | /************************************************** |
930 | * | 931 | * |
931 | * iPAQ | 932 | * iPAQ |
932 | * | 933 | * |
933 | **************************************************/ | 934 | **************************************************/ |
934 | 935 | ||
935 | void iPAQ::init ( ) | 936 | void iPAQ::init ( ) |
936 | { | 937 | { |
937 | d-> m_vendorstr = "HP"; | 938 | d-> m_vendorstr = "HP"; |
938 | d-> m_vendor = Vendor_HP; | 939 | d-> m_vendor = Vendor_HP; |
939 | 940 | ||
940 | QFile f ( "/proc/hal/model" ); | 941 | QFile f ( "/proc/hal/model" ); |
941 | 942 | ||
942 | if ( f. open ( IO_ReadOnly )) { | 943 | if ( f. open ( IO_ReadOnly )) { |
943 | QTextStream ts ( &f ); | 944 | QTextStream ts ( &f ); |
944 | 945 | ||
945 | d-> m_modelstr = "H" + ts. readLine ( ); | 946 | d-> m_modelstr = "H" + ts. readLine ( ); |
946 | 947 | ||
947 | if ( d-> m_modelstr == "H3100" ) | 948 | if ( d-> m_modelstr == "H3100" ) |
948 | d-> m_model = Model_iPAQ_H31xx; | 949 | d-> m_model = Model_iPAQ_H31xx; |
949 | else if ( d-> m_modelstr == "H3600" ) | 950 | else if ( d-> m_modelstr == "H3600" ) |
950 | d-> m_model = Model_iPAQ_H36xx; | 951 | d-> m_model = Model_iPAQ_H36xx; |
951 | else if ( d-> m_modelstr == "H3700" ) | 952 | else if ( d-> m_modelstr == "H3700" ) |
952 | d-> m_model = Model_iPAQ_H37xx; | 953 | d-> m_model = Model_iPAQ_H37xx; |
953 | else if ( d-> m_modelstr == "H3800" ) | 954 | else if ( d-> m_modelstr == "H3800" ) |
954 | d-> m_model = Model_iPAQ_H38xx; | 955 | d-> m_model = Model_iPAQ_H38xx; |
955 | else if ( d-> m_modelstr == "H3900" ) | 956 | else if ( d-> m_modelstr == "H3900" ) |
956 | d-> m_model = Model_iPAQ_H39xx; | 957 | d-> m_model = Model_iPAQ_H39xx; |
957 | else | 958 | else |
958 | d-> m_model = Model_Unknown; | 959 | d-> m_model = Model_Unknown; |
959 | 960 | ||
960 | f. close ( ); | 961 | f. close ( ); |
961 | } | 962 | } |
962 | 963 | ||
963 | switch ( d-> m_model ) { | 964 | switch ( d-> m_model ) { |
964 | case Model_iPAQ_H31xx: | 965 | case Model_iPAQ_H31xx: |
965 | case Model_iPAQ_H38xx: | 966 | case Model_iPAQ_H38xx: |
966 | d-> m_rotation = Rot90; | 967 | d-> m_rotation = Rot90; |
967 | break; | 968 | break; |
968 | case Model_iPAQ_H36xx: | 969 | case Model_iPAQ_H36xx: |
969 | case Model_iPAQ_H37xx: | 970 | case Model_iPAQ_H37xx: |
970 | case Model_iPAQ_H39xx: | 971 | case Model_iPAQ_H39xx: |
971 | default: | 972 | default: |
972 | d-> m_rotation = Rot270; | 973 | d-> m_rotation = Rot270; |
973 | break; | 974 | break; |
974 | } | 975 | } |
975 | 976 | ||
976 | f. setName ( "/etc/familiar-version" ); | 977 | f. setName ( "/etc/familiar-version" ); |
977 | if ( f. open ( IO_ReadOnly )) { | 978 | if ( f. open ( IO_ReadOnly )) { |
978 | d-> m_systemstr = "Familiar"; | 979 | d-> m_systemstr = "Familiar"; |
979 | d-> m_system = System_Familiar; | 980 | d-> m_system = System_Familiar; |
980 | 981 | ||
981 | QTextStream ts ( &f ); | 982 | QTextStream ts ( &f ); |
982 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 983 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
983 | 984 | ||
984 | f. close ( ); | 985 | f. close ( ); |
985 | } else { | 986 | } else { |
986 | f. setName ( "/etc/oz_version" ); | 987 | f. setName ( "/etc/oz_version" ); |
987 | 988 | ||
988 | if ( f. open ( IO_ReadOnly )) { | 989 | if ( f. open ( IO_ReadOnly )) { |
989 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 990 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
990 | d-> m_system = System_Familiar; | 991 | d-> m_system = System_Familiar; |
991 | 992 | ||
992 | QTextStream ts ( &f ); | 993 | QTextStream ts ( &f ); |
993 | ts.setDevice ( &f ); | 994 | ts.setDevice ( &f ); |
994 | d-> m_sysverstr = ts. readLine ( ); | 995 | d-> m_sysverstr = ts. readLine ( ); |
995 | f. close ( ); | 996 | f. close ( ); |
996 | } | 997 | } |
997 | } | 998 | } |
998 | 999 | ||
999 | 1000 | ||
1000 | 1001 | ||
1001 | 1002 | ||
1002 | 1003 | ||
1003 | m_leds [0] = m_leds [1] = Led_Off; | 1004 | m_leds [0] = m_leds [1] = Led_Off; |
1004 | 1005 | ||
1005 | m_power_timer = 0; | 1006 | m_power_timer = 0; |
1006 | 1007 | ||
1007 | } | 1008 | } |
1008 | 1009 | ||
1009 | void iPAQ::initButtons ( ) | 1010 | void iPAQ::initButtons ( ) |
1010 | { | 1011 | { |
1011 | if ( d-> m_buttons ) | 1012 | if ( d-> m_buttons ) |
1012 | return; | 1013 | return; |
1013 | 1014 | ||
1014 | if ( isQWS( ) ) | 1015 | if ( isQWS( ) ) |
1015 | QWSServer::setKeyboardFilter ( this ); | 1016 | QWSServer::setKeyboardFilter ( this ); |
1016 | 1017 | ||
1017 | d-> m_buttons = new QValueList <ODeviceButton>; | 1018 | d-> m_buttons = new QValueList <ODeviceButton>; |
1018 | 1019 | ||
1019 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 1020 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
1020 | i_button *ib = ipaq_buttons + i; | 1021 | i_button *ib = ipaq_buttons + i; |
1021 | ODeviceButton b; | 1022 | ODeviceButton b; |
1022 | 1023 | ||
1023 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 1024 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
1024 | b. setKeycode ( ib-> code ); | 1025 | b. setKeycode ( ib-> code ); |
1025 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1026 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1026 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1027 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1027 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 1028 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
1028 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 1029 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
1029 | 1030 | ||
1030 | d-> m_buttons-> append ( b ); | 1031 | d-> m_buttons-> append ( b ); |
1031 | } | 1032 | } |
1032 | } | 1033 | } |
1033 | reloadButtonMapping ( ); | 1034 | reloadButtonMapping ( ); |
1034 | 1035 | ||
1035 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1036 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1036 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1037 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1037 | } | 1038 | } |
1038 | 1039 | ||
1039 | 1040 | ||
1040 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 1041 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
1041 | 1042 | ||
1042 | typedef struct { | 1043 | typedef struct { |
1043 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 1044 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
1044 | unsigned char TotalTime; /* Units of 5 seconds */ | 1045 | unsigned char TotalTime; /* Units of 5 seconds */ |
1045 | unsigned char OnTime; /* units of 100m/s */ | 1046 | unsigned char OnTime; /* units of 100m/s */ |
1046 | unsigned char OffTime; /* units of 100m/s */ | 1047 | unsigned char OffTime; /* units of 100m/s */ |
1047 | } LED_IN; | 1048 | } LED_IN; |
1048 | 1049 | ||
1049 | typedef struct { | 1050 | typedef struct { |
1050 | unsigned char mode; | 1051 | unsigned char mode; |
1051 | unsigned char pwr; | 1052 | unsigned char pwr; |
1052 | unsigned char brightness; | 1053 | unsigned char brightness; |
1053 | } FLITE_IN; | 1054 | } FLITE_IN; |
1054 | 1055 | ||
1055 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 1056 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
1056 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 1057 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
1057 | 1058 | ||
1058 | 1059 | ||
1059 | QValueList <OLed> iPAQ::ledList ( ) const | 1060 | QValueList <OLed> iPAQ::ledList ( ) const |
1060 | { | 1061 | { |
1061 | QValueList <OLed> vl; | 1062 | QValueList <OLed> vl; |
1062 | vl << Led_Power; | 1063 | vl << Led_Power; |
1063 | 1064 | ||
1064 | if ( d-> m_model == Model_iPAQ_H38xx ) | 1065 | if ( d-> m_model == Model_iPAQ_H38xx ) |
1065 | vl << Led_BlueTooth; | 1066 | vl << Led_BlueTooth; |
1066 | return vl; | 1067 | return vl; |
1067 | } | 1068 | } |
1068 | 1069 | ||
1069 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 1070 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
1070 | { | 1071 | { |
1071 | QValueList <OLedState> vl; | 1072 | QValueList <OLedState> vl; |
1072 | 1073 | ||
1073 | if ( l == Led_Power ) | 1074 | if ( l == Led_Power ) |
1074 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 1075 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
1075 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 1076 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
1076 | vl << Led_Off; // << Led_On << ??? | 1077 | vl << Led_Off; // << Led_On << ??? |
1077 | 1078 | ||
1078 | return vl; | 1079 | return vl; |
1079 | } | 1080 | } |
1080 | 1081 | ||
1081 | OLedState iPAQ::ledState ( OLed l ) const | 1082 | OLedState iPAQ::ledState ( OLed l ) const |
1082 | { | 1083 | { |
1083 | switch ( l ) { | 1084 | switch ( l ) { |
1084 | case Led_Power: | 1085 | case Led_Power: |
1085 | return m_leds [0]; | 1086 | return m_leds [0]; |
1086 | case Led_BlueTooth: | 1087 | case Led_BlueTooth: |
1087 | return m_leds [1]; | 1088 | return m_leds [1]; |
1088 | default: | 1089 | default: |
1089 | return Led_Off; | 1090 | return Led_Off; |
1090 | } | 1091 | } |
1091 | } | 1092 | } |
1092 | 1093 | ||
1093 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 1094 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
1094 | { | 1095 | { |
1095 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 1096 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
1096 | 1097 | ||
1097 | if ( l == Led_Power ) { | 1098 | if ( l == Led_Power ) { |
1098 | if ( fd >= 0 ) { | 1099 | if ( fd >= 0 ) { |
1099 | LED_IN leds; | 1100 | LED_IN leds; |
1100 | ::memset ( &leds, 0, sizeof( leds )); | 1101 | ::memset ( &leds, 0, sizeof( leds )); |
1101 | leds. TotalTime = 0; | 1102 | leds. TotalTime = 0; |
1102 | leds. OnTime = 0; | 1103 | leds. OnTime = 0; |
1103 | leds. OffTime = 1; | 1104 | leds. OffTime = 1; |
1104 | leds. OffOnBlink = 2; | 1105 | leds. OffOnBlink = 2; |
1105 | 1106 | ||
1106 | switch ( st ) { | 1107 | switch ( st ) { |
1107 | case Led_Off : leds. OffOnBlink = 0; break; | 1108 | case Led_Off : leds. OffOnBlink = 0; break; |
1108 | case Led_On : leds. OffOnBlink = 1; break; | 1109 | case Led_On : leds. OffOnBlink = 1; break; |
1109 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1110 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1110 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1111 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1111 | } | 1112 | } |
1112 | 1113 | ||
1113 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 1114 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
1114 | m_leds [0] = st; | 1115 | m_leds [0] = st; |
1115 | return true; | 1116 | return true; |
1116 | } | 1117 | } |
@@ -1784,385 +1785,359 @@ OLedState SIMpad::ledState ( OLed l ) const | |||
1784 | return m_leds [0]; | 1785 | return m_leds [0]; |
1785 | //case Led_Mail: | 1786 | //case Led_Mail: |
1786 | //return m_leds [1]; | 1787 | //return m_leds [1]; |
1787 | default: | 1788 | default: |
1788 | return Led_Off; | 1789 | return Led_Off; |
1789 | } | 1790 | } |
1790 | } | 1791 | } |
1791 | 1792 | ||
1792 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 1793 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
1793 | { | 1794 | { |
1794 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 1795 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
1795 | 1796 | ||
1796 | if ( l == Led_Power ) { | 1797 | if ( l == Led_Power ) { |
1797 | if ( fd >= 0 ) { | 1798 | if ( fd >= 0 ) { |
1798 | LED_IN leds; | 1799 | LED_IN leds; |
1799 | ::memset ( &leds, 0, sizeof( leds )); | 1800 | ::memset ( &leds, 0, sizeof( leds )); |
1800 | leds. TotalTime = 0; | 1801 | leds. TotalTime = 0; |
1801 | leds. OnTime = 0; | 1802 | leds. OnTime = 0; |
1802 | leds. OffTime = 1; | 1803 | leds. OffTime = 1; |
1803 | leds. OffOnBlink = 2; | 1804 | leds. OffOnBlink = 2; |
1804 | 1805 | ||
1805 | switch ( st ) { | 1806 | switch ( st ) { |
1806 | case Led_Off : leds. OffOnBlink = 0; break; | 1807 | case Led_Off : leds. OffOnBlink = 0; break; |
1807 | case Led_On : leds. OffOnBlink = 1; break; | 1808 | case Led_On : leds. OffOnBlink = 1; break; |
1808 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1809 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1809 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1810 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1810 | } | 1811 | } |
1811 | 1812 | ||
1812 | { | 1813 | { |
1813 | /*TODO Implement this like that: | 1814 | /*TODO Implement this like that: |
1814 | read from cs3 | 1815 | read from cs3 |
1815 | && with SIMPAD_LED2_ON | 1816 | && with SIMPAD_LED2_ON |
1816 | write to cs3 */ | 1817 | write to cs3 */ |
1817 | m_leds [0] = st; | 1818 | m_leds [0] = st; |
1818 | return true; | 1819 | return true; |
1819 | } | 1820 | } |
1820 | } | 1821 | } |
1821 | } | 1822 | } |
1822 | return false; | 1823 | return false; |
1823 | } | 1824 | } |
1824 | 1825 | ||
1825 | 1826 | ||
1826 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1827 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1827 | { | 1828 | { |
1828 | //TODO | 1829 | //TODO |
1829 | return false; | 1830 | return false; |
1830 | } | 1831 | } |
1831 | 1832 | ||
1832 | void SIMpad::timerEvent ( QTimerEvent * ) | 1833 | void SIMpad::timerEvent ( QTimerEvent * ) |
1833 | { | 1834 | { |
1834 | killTimer ( m_power_timer ); | 1835 | killTimer ( m_power_timer ); |
1835 | m_power_timer = 0; | 1836 | m_power_timer = 0; |
1836 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 1837 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
1837 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 1838 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
1838 | } | 1839 | } |
1839 | 1840 | ||
1840 | 1841 | ||
1841 | void SIMpad::alarmSound ( ) | 1842 | void SIMpad::alarmSound ( ) |
1842 | { | 1843 | { |
1843 | #ifndef QT_NO_SOUND | 1844 | #ifndef QT_NO_SOUND |
1844 | static Sound snd ( "alarm" ); | 1845 | static Sound snd ( "alarm" ); |
1845 | int fd; | 1846 | int fd; |
1846 | int vol; | 1847 | int vol; |
1847 | bool vol_reset = false; | 1848 | bool vol_reset = false; |
1848 | 1849 | ||
1849 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1850 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1850 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1851 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1851 | Config cfg ( "qpe" ); | 1852 | Config cfg ( "qpe" ); |
1852 | cfg. setGroup ( "Volume" ); | 1853 | cfg. setGroup ( "Volume" ); |
1853 | 1854 | ||
1854 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1855 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1855 | if ( volalarm < 0 ) | 1856 | if ( volalarm < 0 ) |
1856 | volalarm = 0; | 1857 | volalarm = 0; |
1857 | else if ( volalarm > 100 ) | 1858 | else if ( volalarm > 100 ) |
1858 | volalarm = 100; | 1859 | volalarm = 100; |
1859 | volalarm |= ( volalarm << 8 ); | 1860 | volalarm |= ( volalarm << 8 ); |
1860 | 1861 | ||
1861 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1862 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1862 | vol_reset = true; | 1863 | vol_reset = true; |
1863 | } | 1864 | } |
1864 | } | 1865 | } |
1865 | 1866 | ||
1866 | snd. play ( ); | 1867 | snd. play ( ); |
1867 | while ( !snd. isFinished ( )) | 1868 | while ( !snd. isFinished ( )) |
1868 | qApp-> processEvents ( ); | 1869 | qApp-> processEvents ( ); |
1869 | 1870 | ||
1870 | if ( fd >= 0 ) { | 1871 | if ( fd >= 0 ) { |
1871 | if ( vol_reset ) | 1872 | if ( vol_reset ) |
1872 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1873 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1873 | ::close ( fd ); | 1874 | ::close ( fd ); |
1874 | } | 1875 | } |
1875 | #endif | 1876 | #endif |
1876 | } | 1877 | } |
1877 | 1878 | ||
1878 | 1879 | ||
1879 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm | 1880 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm |
1880 | { | 1881 | { |
1881 | qDebug( "ODevice for SIMpad: suspend()" ); | 1882 | qDebug( "ODevice for SIMpad: suspend()" ); |
1882 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 1883 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
1883 | return false; | 1884 | return false; |
1884 | 1885 | ||
1885 | bool res = false; | 1886 | bool res = false; |
1886 | 1887 | ||
1887 | struct timeval tvs, tvn; | 1888 | struct timeval tvs, tvn; |
1888 | ::gettimeofday ( &tvs, 0 ); | 1889 | ::gettimeofday ( &tvs, 0 ); |
1889 | 1890 | ||
1890 | ::sync ( ); // flush fs caches | 1891 | ::sync ( ); // flush fs caches |
1891 | res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) | 1892 | res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) |
1892 | 1893 | ||
1893 | return res; | 1894 | return res; |
1894 | } | 1895 | } |
1895 | 1896 | ||
1896 | 1897 | ||
1897 | bool SIMpad::setSoftSuspend ( bool soft ) | 1898 | bool SIMpad::setSoftSuspend ( bool soft ) |
1898 | { | 1899 | { |
1899 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 1900 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
1900 | return false; | 1901 | return false; |
1901 | } | 1902 | } |
1902 | 1903 | ||
1903 | 1904 | ||
1904 | bool SIMpad::setDisplayStatus ( bool on ) | 1905 | bool SIMpad::setDisplayStatus ( bool on ) |
1905 | { | 1906 | { |
1906 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 1907 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
1907 | 1908 | ||
1908 | bool res = false; | 1909 | bool res = false; |
1909 | int fd; | 1910 | int fd; |
1910 | 1911 | ||
1911 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 1912 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
1912 | 1913 | ||
1913 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 1914 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
1914 | res = ( ::system( (const char*) cmdline ) == 0 ); | 1915 | res = ( ::system( (const char*) cmdline ) == 0 ); |
1915 | ::close ( fd ); | 1916 | ::close ( fd ); |
1916 | } | 1917 | } |
1917 | return res; | 1918 | return res; |
1918 | } | 1919 | } |
1919 | 1920 | ||
1920 | 1921 | ||
1921 | bool SIMpad::setDisplayBrightness ( int bright ) | 1922 | bool SIMpad::setDisplayBrightness ( int bright ) |
1922 | { | 1923 | { |
1923 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 1924 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
1924 | bool res = false; | 1925 | bool res = false; |
1925 | int fd; | 1926 | int fd; |
1926 | 1927 | ||
1927 | if ( bright > 255 ) | 1928 | if ( bright > 255 ) |
1928 | bright = 255; | 1929 | bright = 255; |
1929 | if ( bright < 0 ) | 1930 | if ( bright < 0 ) |
1930 | bright = 0; | 1931 | bright = 0; |
1931 | 1932 | ||
1932 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 1933 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
1933 | int value = 255 - bright; | 1934 | int value = 255 - bright; |
1934 | const int mask = SIMPAD_BACKLIGHT_MASK; | 1935 | const int mask = SIMPAD_BACKLIGHT_MASK; |
1935 | value = value << 8; | 1936 | value = value << 8; |
1936 | value += mask; | 1937 | value += mask; |
1937 | char writeCommand[100]; | 1938 | char writeCommand[100]; |
1938 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 1939 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
1939 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 1940 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
1940 | ::close ( fd ); | 1941 | ::close ( fd ); |
1941 | } | 1942 | } |
1942 | return res; | 1943 | return res; |
1943 | } | 1944 | } |
1944 | 1945 | ||
1945 | 1946 | ||
1946 | int SIMpad::displayBrightnessResolution ( ) const | 1947 | int SIMpad::displayBrightnessResolution ( ) const |
1947 | { | 1948 | { |
1948 | switch ( model ( )) { | 1949 | switch ( model ( )) { |
1949 | case Model_SIMpad_CL4: | 1950 | case Model_SIMpad_CL4: |
1950 | case Model_SIMpad_SL4: | 1951 | case Model_SIMpad_SL4: |
1951 | case Model_SIMpad_SLC: | 1952 | case Model_SIMpad_SLC: |
1952 | case Model_SIMpad_TSinus: | 1953 | case Model_SIMpad_TSinus: |
1953 | return 255; //TODO find out if this is save | 1954 | return 255; //TODO find out if this is save |
1954 | 1955 | ||
1955 | default: | 1956 | default: |
1956 | return 2; | 1957 | return 2; |
1957 | } | 1958 | } |
1958 | } | 1959 | } |
1959 | 1960 | ||
1960 | /************************************************** | 1961 | /************************************************** |
1961 | * | 1962 | * |
1962 | * Ramses | 1963 | * Ramses |
1963 | * | 1964 | * |
1964 | **************************************************/ | 1965 | **************************************************/ |
1965 | 1966 | ||
1966 | void Ramses::init() | 1967 | void Ramses::init() |
1967 | { | 1968 | { |
1968 | d->m_vendorstr = "M und N"; | 1969 | d->m_vendorstr = "M und N"; |
1969 | d->m_vendor = Vendor_MundN; | 1970 | d->m_vendor = Vendor_MundN; |
1970 | 1971 | ||
1971 | QFile f("/proc/sys/board/ramses"); | 1972 | QFile f("/proc/sys/board/ramses"); |
1972 | 1973 | ||
1973 | d->m_modelstr = "Ramses"; | 1974 | d->m_modelstr = "Ramses"; |
1974 | d->m_model = Model_Ramses_MNCI; | 1975 | d->m_model = Model_Ramses_MNCI; |
1975 | 1976 | ||
1976 | d->m_rotation = Rot0; | 1977 | d->m_rotation = Rot180; |
1977 | d->m_holdtime = 1000; | 1978 | d->m_direction = CW; |
1979 | d->m_holdtime = 1000; | ||
1978 | 1980 | ||
1979 | f.setName("/etc/oz_version"); | 1981 | f.setName("/etc/oz_version"); |
1980 | 1982 | ||
1981 | if (f.open(IO_ReadOnly)) { | 1983 | if (f.open(IO_ReadOnly)) { |
1982 | d->m_systemstr = "OpenEmbedded/Ramses"; | 1984 | d->m_systemstr = "OpenEmbedded/Ramses"; |
1983 | d->m_system = System_OpenZaurus; | 1985 | d->m_system = System_OpenZaurus; |
1984 | 1986 | ||
1985 | QTextStream ts(&f); | 1987 | QTextStream ts(&f); |
1986 | ts.setDevice(&f); | 1988 | ts.setDevice(&f); |
1987 | d->m_sysverstr = ts.readLine(); | 1989 | d->m_sysverstr = ts.readLine(); |
1988 | f.close(); | 1990 | f.close(); |
1989 | } | 1991 | } |
1990 | 1992 | ||
1991 | m_power_timer = 0; | 1993 | m_power_timer = 0; |
1992 | 1994 | ||
1993 | #ifdef QT_QWS_ALLOW_OVERCLOCK | 1995 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
1994 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** | 1996 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** |
1995 | #define OC(x...) x | 1997 | #define OC(x...) x |
1996 | #else | 1998 | #else |
1997 | #define OC(x...) | 1999 | #define OC(x...) |
1998 | #endif | 2000 | #endif |
1999 | 2001 | ||
2000 | 2002 | ||
2001 | // This table is true for a Intel XScale PXA 255 | 2003 | // This table is true for a Intel XScale PXA 255 |
2002 | 2004 | ||
2003 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | 2005 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 |
2004 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | 2006 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem |
2005 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | 2007 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 |
2006 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | 2008 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem |
2007 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | 2009 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 |
2008 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | 2010 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem |
2009 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | 2011 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 |
2010 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | 2012 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 |
2011 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | 2013 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus |
2012 | 2014 | ||
2013 | } | 2015 | } |
2014 | 2016 | ||
2015 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 2017 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
2016 | { | 2018 | { |
2017 | Q_UNUSED( keycode ); | 2019 | Q_UNUSED( keycode ); |
2018 | Q_UNUSED( modifiers ); | 2020 | Q_UNUSED( modifiers ); |
2019 | Q_UNUSED( isPress ); | 2021 | Q_UNUSED( isPress ); |
2020 | Q_UNUSED( autoRepeat ); | 2022 | Q_UNUSED( autoRepeat ); |
2021 | return false; | 2023 | return false; |
2022 | } | 2024 | } |
2023 | 2025 | ||
2024 | void Ramses::timerEvent(QTimerEvent *) | 2026 | void Ramses::timerEvent(QTimerEvent *) |
2025 | { | 2027 | { |
2026 | killTimer(m_power_timer); | 2028 | killTimer(m_power_timer); |
2027 | m_power_timer = 0; | 2029 | m_power_timer = 0; |
2028 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 2030 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
2029 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 2031 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
2030 | } | 2032 | } |
2031 | 2033 | ||
2032 | 2034 | ||
2033 | bool Ramses::setSoftSuspend(bool soft) | 2035 | bool Ramses::setSoftSuspend(bool soft) |
2034 | { | 2036 | { |
2035 | qDebug("Ramses::setSoftSuspend(%d)", soft); | 2037 | Q_UNUSED(soft); |
2036 | #if 0 | 2038 | return true; |
2037 | bool res = false; | 2039 | } |
2038 | int fd; | ||
2039 | |||
2040 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || | ||
2041 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { | ||
2042 | |||
2043 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | ||
2044 | 2040 | ||
2045 | if (sources >= 0) { | 2041 | bool Ramses::suspend() |
2046 | if (soft) | 2042 | { |
2047 | sources &= ~APM_EVT_POWER_BUTTON; | 2043 | //qDebug("Ramses::suspend()"); |
2048 | else | 2044 | if ( !isQWS() ) // only qwsserver is allowed to suspend |
2049 | sources |= APM_EVT_POWER_BUTTON; | 2045 | return false; |
2050 | 2046 | ||
2051 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | 2047 | bool res = false; |
2052 | res = true; | 2048 | int fd; |
2053 | else | ||
2054 | perror("APM_IOCGEVTSRC"); | ||
2055 | } | ||
2056 | else | ||
2057 | perror("APM_IOCGEVTSRC"); | ||
2058 | 2049 | ||
2050 | if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { | ||
2051 | res = ( ::write ( fd, "1", 1 ) != -1 ); | ||
2059 | ::close(fd); | 2052 | ::close(fd); |
2060 | } | 2053 | } |
2061 | else | 2054 | return res; |
2062 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | ||
2063 | |||
2064 | return res; | ||
2065 | #else | ||
2066 | return true; | ||
2067 | #endif | ||
2068 | } | ||
2069 | |||
2070 | bool Ramses::suspend ( ) | ||
2071 | { | ||
2072 | qDebug("Ramses::suspend"); | ||
2073 | return false; | ||
2074 | } | 2055 | } |
2075 | 2056 | ||
2076 | /** | 2057 | /** |
2077 | * This sets the display on or off | 2058 | * This sets the display on or off |
2078 | */ | 2059 | */ |
2079 | bool Ramses::setDisplayStatus(bool on) | 2060 | bool Ramses::setDisplayStatus(bool on) |
2080 | { | 2061 | { |
2081 | qDebug("Ramses::setDisplayStatus(%d)", on); | 2062 | //qDebug("Ramses::setDisplayStatus(%d)", on); |
2082 | #if 0 | ||
2083 | bool res = false; | 2063 | bool res = false; |
2084 | int fd; | 2064 | int fd; |
2085 | 2065 | ||
2086 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { | 2066 | if ((fd = ::open ("/dev/fb/1", O_RDWR)) >= 0) { |
2087 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 2067 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2088 | ::close(fd); | 2068 | ::close(fd); |
2089 | } | 2069 | } |
2090 | return res; | 2070 | return res; |
2091 | #else | ||
2092 | return true; | ||
2093 | #endif | ||
2094 | } | 2071 | } |
2095 | 2072 | ||
2096 | 2073 | ||
2097 | /* | 2074 | /* |
2098 | * We get something between 0..255 into us | 2075 | * We get something between 0..255 into us |
2099 | */ | 2076 | */ |
2100 | bool Ramses::setDisplayBrightness(int bright) | 2077 | bool Ramses::setDisplayBrightness(int bright) |
2101 | { | 2078 | { |
2102 | qDebug("Ramses::setDisplayBrightness(%d)", bright); | 2079 | //qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2103 | bool res = false; | 2080 | bool res = false; |
2104 | int fd; | 2081 | int fd; |
2105 | 2082 | ||
2106 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 2083 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2107 | 2084 | ||
2108 | if (bright > 255 ) | 2085 | if (bright > 255 ) |
2109 | bright = 255; | 2086 | bright = 255; |
2110 | if (bright < 0) | 2087 | if (bright < 0) |
2111 | bright = 0; | 2088 | bright = 0; |
2112 | 2089 | ||
2113 | // Turn backlight completely off | 2090 | // Turn backlight completely off |
2114 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | 2091 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { |
2115 | char writeCommand[10]; | 2092 | char writeCommand[10]; |
2116 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | 2093 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); |
2117 | res = (::write(fd, writeCommand, count) != -1); | 2094 | res = (::write(fd, writeCommand, count) != -1); |
2118 | ::close(fd); | 2095 | ::close(fd); |
2119 | } | 2096 | } |
2120 | 2097 | ||
2121 | // scale backlight brightness to hardware | 2098 | // scale backlight brightness to hardware |
2122 | bright = 500-(bright * 500 / 255); | 2099 | if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) { |
2123 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { | 2100 | //qDebug(" %d -> pwm1", bright); |
2124 | qDebug(" %d -> pwm1", bright); | ||
2125 | char writeCommand[100]; | 2101 | char writeCommand[100]; |
2126 | const int count = sprintf(writeCommand, "%d\n", bright); | 2102 | const int count = sprintf(writeCommand, "%d\n", bright); |
2127 | res = (::write(fd, writeCommand, count) != -1); | 2103 | res = (::write(fd, writeCommand, count) != -1); |
2128 | ::close(fd); | 2104 | ::close(fd); |
2129 | } | 2105 | } |
2130 | return res; | 2106 | return res; |
2131 | } | 2107 | } |
2132 | 2108 | ||
2133 | 2109 | ||
2134 | int Ramses::displayBrightnessResolution() const | 2110 | int Ramses::displayBrightnessResolution() const |
2135 | { | 2111 | { |
2136 | return 32; | 2112 | return 256; |
2137 | } | 2113 | } |
2138 | 2114 | ||
2139 | bool Ramses::setDisplayContrast(int contr) | 2115 | bool Ramses::setDisplayContrast(int contr) |
2140 | { | 2116 | { |
2141 | qDebug("Ramses::setDisplayContrast(%d)", contr); | 2117 | //qDebug("Ramses::setDisplayContrast(%d)", contr); |
2142 | bool res = false; | 2118 | bool res = false; |
2143 | int fd; | 2119 | int fd; |
2144 | 2120 | ||
2145 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) | 2121 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2146 | 2122 | ||
2147 | if (contr > 255 ) | 2123 | if (contr > 255 ) |
2148 | contr = 255; | 2124 | contr = 255; |
2149 | if (contr < 0) | 2125 | if (contr < 0) |
2150 | contr = 0; | 2126 | contr = 0; |
2151 | contr = 90 - (contr * 20 / 255); | ||
2152 | 2127 | ||
2153 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | 2128 | if ((fd = ::open("/proc/sys/board/lcd_contrast", O_WRONLY)) >= 0) { |
2154 | qDebug(" %d -> pwm0", contr); | 2129 | //qDebug(" %d -> pwm0", contr); |
2155 | char writeCommand[100]; | 2130 | char writeCommand[100]; |
2156 | const int count = sprintf(writeCommand, "%d\n", contr); | 2131 | const int count = sprintf(writeCommand, "%d\n", contr); |
2157 | res = (::write(fd, writeCommand, count) != -1); | 2132 | res = (::write(fd, writeCommand, count) != -1); |
2158 | res = true; | 2133 | res = true; |
2159 | ::close(fd); | 2134 | ::close(fd); |
2160 | } | 2135 | } |
2161 | return res; | 2136 | return res; |
2162 | } | 2137 | } |
2163 | 2138 | ||
2164 | 2139 | ||
2165 | int Ramses::displayContrastResolution() const | 2140 | int Ramses::displayContrastResolution() const |
2166 | { | 2141 | { |
2167 | return 20; | 2142 | return 256; |
2168 | } | 2143 | } |