FEATURE: Added platform detection and got for Backlight and Bluetooth working on GTA02

git-svn-id: http://www.neo1973-germany.de/svn@91 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
kriss 2008-07-31 00:21:45 +00:00
parent 25e1cb447f
commit b0d2be73a9
3 changed files with 81 additions and 21 deletions

View file

@ -296,12 +296,24 @@ class BluetoothPanel(gtk.VBox):
def toggle_power(self, event):
print "Toggleing Power state!"
if not self.get_power_state():
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER, 1)
""" power off """
if detect_device_type() == "GTA01" and detect_revision() == "":
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER_GTA01, 1)
else:
# invers, bugreport filed under #1703
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER_GTA02, 0)
self.list_store1.clear()
self.list_store1.append(("Scanning for ", "Peers...", False))
self.update_btn.set_active(True)
else:
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER, 0)
""" power on (and reset) """
if detect_device_type() == "GTA01" and detect_revision() == "":
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER_GTA01, 0)
else:
# invers, bugreport filed under #1703
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER_GTA02, 1)
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_RESET_GTA02, 0)
self.power_state_cbtn.set_active(self.get_power_state())
@ -332,7 +344,10 @@ class BluetoothPanel(gtk.VBox):
def get_power_state(self):
power_value = get_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER)
if detect_device_type() == "GTA01" and detect_revision() == "":
power_value = get_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER_GTA01)
else:
power_value = get_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER_GTA02)
## value will be empty if sysfs entry does not exist
if len(power_value) > 0:

View file

@ -20,6 +20,23 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
################################################################################
############################ platform detection ################################
################################################################################
def detect_device_type():
cpuinfo = open("/proc/cpuinfo").read(1024)
if "GTA02" in cpuinfo:
return "GTA02"
else:
return "GTA01"
def detect_revision():
cpuinfo = open("/proc/cpuinfo").read(1024)
if "Revision\t: 0240" in cpuinfo:
return "0240"
else:
return ""
################################################################################
#################################### GUI #######################################
@ -31,14 +48,20 @@ GSM_Panel_Instance = None
################################################################################
############################# used in Screen Panel #############################
################################################################################
SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS = "/sys/class/backlight/gta01-bl/brightness"
SYSFS_ENTRY_BACKLIGHT_POWER = "/sys/class/backlight/gta01-bl/power" # reverse
SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS_GTA01 = "/sys/class/backlight/gta01-bl/brightness"
SYSFS_ENTRY_BACKLIGHT_POWER_GTA01 = "/sys/class/backlight/gta01-bl/power" # reverse
SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS_GTA02 = "/sys/class/backlight/pcf50633-bl/brightness"
SYSFS_ENTRY_BACKLIGHT_POWER_GTA02 = "/sys/class/backlight/pcf50633-bl/bl_power"
################################################################################
############################ used in Bluetooth Panel ###########################
################################################################################
SYSFS_ENTRY_BLUETOOTH_POWER = "/sys/bus/platform/devices/gta01-pm-bt.0/power_on"
SYSFS_ENTRY_BLUETOOTH_POWER_GTA01 = "/sys/bus/platform/devices/gta01-pm-bt.0/power_on"
SYSFS_ENTRY_BLUETOOTH_POWER_GTA02 = "/sys/bus/platform/devices/neo1973-pm-bt.0/power_on"
SYSFS_ENTRY_BLUETOOTH_RESET_GTA02 = "/sys/bus/platform/devices/neo1973-pm-bt.0/reset"
HCICONFIG_CMD = "hciconfig" ## using $PATH
#HCICONFIG_CMD = "/sbin/hciconfig" ## openembedded
#HCICONFIG_CMD = "/usr/sbin/hciconfig" ## ubuntu

View file

@ -37,13 +37,22 @@ class ScreenPanel(gtk.VBox):
def toggle_backlight(self, widget):
print "trying to toggle the backlight"
value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER)
if value.find("1") != -1:
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER, 0)
value = "1"
else:
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER, 1)
value = "0"
if detect_device_type() == "GTA01":
value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER_GTA01)
if value.find("1") != -1:
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER_GTA01, 0)
value = "1"
else:
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER_GTA01, 1)
value = "0"
else:
value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER_GTA02)
if value.find("1") != -1:
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER_GTA02, 0)
value = "1"
else:
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER_GTA02, 1)
value = "0"
def toggle_orientation(self, widget):
print "trying to toggle screen orientation"
@ -67,10 +76,15 @@ class ScreenPanel(gtk.VBox):
def bl_level_changed(self, widget):
tmp_value = widget.value
tmp_value = tmp_value * 50
print "trying to set backlight to %s" % tmp_value
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS, tmp_value)
print "trying to set backlight to %s" % widget.value
if detect_device_type() == "GTA01":
tmp_value = widget.value
tmp_value = tmp_value * 50
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS_GTA01, tmp_value)
else:
tmp_value = widget.value
tmp_value = int((tmp_value/100.0) * 64)
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS_GTA02, tmp_value)
def create_notebook_page(self):
self.set_border_width(0)
@ -80,11 +94,19 @@ class ScreenPanel(gtk.VBox):
level_box = gtk.VBox(False, 0)
level_box.set_border_width(15)
init_value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS)
if len(init_value) > 0:
init_value = float(init_value) / 50
if detect_device_type() == "GTA01":
init_value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS_GTA01)
if len(init_value) > 0:
init_value = float(init_value) / 50
else:
init_value = 50
else:
init_value = 50
init_value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS_GTA02)
if len(init_value) > 0:
init_value = int((float(init_value) / 64.0) * 100)
else:
init_value = 0.5
## scale to set backlight level