apply hostmode patch; refresh script; disable old patches
[kernel-power] / usbhost / hostmode.py
1 from PyQt4 import QtCore, QtGui
2 import os
3 import sys
4 import time
5 #import gtk
6 #import hildon
7
8
9 class Ui_MainWindow(object):
10     def setupUi(self, MainWindow):
11         MainWindow.setObjectName("MainWindow")
12         MainWindow.resize(800, 420)
13         self.centralwidget = QtGui.QWidget(MainWindow)
14         self.centralwidget.setObjectName("centralwidget")
15         self.pbHostModeE = QtGui.QPushButton(self.centralwidget)
16         self.pbHostModeE.setGeometry(QtCore.QRect(70, 140, 241, 70))
17         font = QtGui.QFont()
18         font.setFamily("Arial")
19         font.setPointSize(14)
20         self.pbHostModeE.setFont(font)
21         self.pbHostModeE.setObjectName("pbHostModeE")
22         self.pbHostModeD = QtGui.QPushButton(self.centralwidget)
23         self.pbHostModeD.setGeometry(QtCore.QRect(490, 140, 241, 70))
24         font = QtGui.QFont()
25         font.setFamily("Arial")
26         font.setPointSize(14)
27         self.pbHostModeD.setFont(font)
28         self.pbHostModeD.setObjectName("pbHostModeD")
29         self.quitButton = QtGui.QPushButton(self.centralwidget)
30         self.quitButton.setGeometry(QtCore.QRect(520, 280, 181, 51))
31         font = QtGui.QFont()
32         font.setFamily("Arial")
33         font.setPointSize(14)
34         self.quitButton.setFont(font)
35         self.quitButton.setObjectName("quitButton")
36         self.restartbme = QtGui.QPushButton(self.centralwidget)
37         self.restartbme.setGeometry(QtCore.QRect(660, 370, 140, 50))
38         font = QtGui.QFont()
39         font.setFamily("Arial")
40         font.setPointSize(14)
41         self.restartbme.setFont(font)
42         self.restartbme.setObjectName("restartbme")
43         self.mountsda1 = QtGui.QPushButton(self.centralwidget)
44         self.mountsda1.setGeometry(QtCore.QRect(100, 280, 181, 51))
45         font = QtGui.QFont()
46         font.setFamily("Arial")
47         font.setPointSize(14)
48         self.mountsda1.setFont(font)
49         self.mountsda1.setObjectName("mountsda1")
50         self.label = QtGui.QLabel(self.centralwidget)
51         self.label.setGeometry(QtCore.QRect(250, 10, 281, 31))
52         font = QtGui.QFont()
53         font.setFamily("Arial")
54         font.setPointSize(18)
55         font.setWeight(75)
56         font.setUnderline(True)
57         font.setBold(True)
58         self.label.setFont(font)
59         self.label.setObjectName("label")
60         MainWindow.setCentralWidget(self.centralwidget)
61
62         #connect buttons
63         QtCore.QObject.connect(self.pbHostModeE, QtCore.SIGNAL('clicked()'), self.doHostmodeE)
64         QtCore.QObject.connect(self.pbHostModeD, QtCore.SIGNAL('clicked()'), self.doHostmodeC)
65         QtCore.QObject.connect(self.restartbme, QtCore.SIGNAL('clicked()'), self.startbme)
66         QtCore.QObject.connect(self.mountsda1, QtCore.SIGNAL('clicked()'), self.mountdevsda1)
67         QtCore.QObject.connect(self.quitButton, QtCore.SIGNAL('clicked()'),QtGui.qApp, QtCore.SLOT('quit()'))
68
69         self.retranslateUi(MainWindow)
70         QtCore.QMetaObject.connectSlotsByName(MainWindow)
71
72     def retranslateUi(self, MainWindow):
73         MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "Host Mode Enabler", None, QtGui.QApplication.UnicodeUTF8))
74         self.pbHostModeE.setText(QtGui.QApplication.translate("MainWindow", "Hostmode VBUS", None, QtGui.QApplication.UnicodeUTF8))
75         self.pbHostModeD.setText(QtGui.QApplication.translate("MainWindow", "Hostmode CHARGING", None, QtGui.QApplication.UnicodeUTF8))
76         self.mountsda1.setText(QtGui.QApplication.translate("MainWindow", "mount /dev/sda1", None, QtGui.QApplication.UnicodeUTF8))
77         self.restartbme.setText(QtGui.QApplication.translate("MainWindow", "VBUS default", None, QtGui.QApplication.UnicodeUTF8))
78         self.quitButton.setText(QtGui.QApplication.translate("MainWindow", "Exit", None, QtGui.QApplication.UnicodeUTF8))
79         self.label.setText(QtGui.QApplication.translate("MainWindow", "USB Host Mode Enabler", None, QtGui.QApplication.UnicodeUTF8))
80
81     def doHostmodeE(self):
82         self.doHostmodeC()
83         dummy = os.popen('run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Connect the USB device NOW"')
84         time.sleep(0.5)
85         dummy = os.popen('/root/vboost.sh &').read()
86
87     def doHostmodeC(self):
88         dummy = os.popen('pcsuite-enable.sh').read()
89         os.popen('stop bme')
90         print "bme stopped"
91         os.popen('echo H >/proc/driver/musb_hdrc')
92         os.popen('echo host >/sys/devices/platform/musb_hdrc/mode')
93         os.popen('echo e > /proc/driver/musb_hdrc') 
94         os.popen('echo F > /proc/driver/musb_hdrc ')
95         os.popen('echo host >/sys/devices/platform/musb_hdrc/mode')
96         os.popen('echo H >/proc/driver/musb_hdrc')
97         os.popen('echo I > /proc/driver/musb_hdrc')
98         os.popen('echo host >/sys/devices/platform/musb_hdrc/mode')
99         os.popen('echo H >/proc/driver/musb_hdrc')
100         print "Done echoing commands"
101
102
103     def doConfig(self):
104         self.doHostmodeE()
105
106     def startbme(self):
107         bme = os.popen('i2cset -y -m 0x01 2 0x6b 0x01 0x00').read()
108         os.popen('start bme')
109
110     def mountdevsda1(self):
111         os.popen('mkdir -p /media/flash')
112         os.popen('mount /dev/sda1 /media/flash')
113
114         
115 class MyForm(QtGui.QMainWindow):
116         def __init__(self, parent=None):
117                 #build parent user interface
118                 QtGui.QWidget.__init__(self, parent)
119                 self.ui = Ui_MainWindow()
120                 self.ui.setupUi(self)
121
122 if __name__ == "__main__":
123         app = QtGui.QApplication(sys.argv)
124         MainWindow = QtGui.QMainWindow()
125         ui = Ui_MainWindow()
126         ui.setupUi(MainWindow)
127         MainWindow.show()
128         sys.exit(app.exec_())
129