Hello, I'm trying to get devicekit-power to work on the FreeRunner. I'm using version 010, currently available in Debian.
devicekit-power can enumerate all the power devices available; however, the battery is still reported as line_power: # devkit-power -e /org/freedesktop/DeviceKit/Power/devices/line_power_battery /org/freedesktop/DeviceKit/Power/devices/line_power_adapter /org/freedesktop/DeviceKit/Power/devices/line_power_ac /org/freedesktop/DeviceKit/Power/devices/line_power_usb This is the content of the battery sysfs directory: # uname -a Linux ciapino 2.6.29-20090702.gitd1c828aa #1 PREEMPT Fri Jul 24 22:35:01 UTC 2009 armv4tl GNU/Linux # ls /sys/class/power_supply/battery/ capacity current_now online status temp type charge_full device power subsystem time_to_empty_now uevent charge_now health present technology time_to_full_now voltage_now There is still no 2.6.30 available for the FreeRunner to the best of my knowledge. In dkp-device-supply.c, it seems that if "online" is there, then it's a line_power: if (sysfs_file_exists (native_path, "online")) { g_object_set (device, "type", DKP_DEVICE_TYPE_LINE_POWER, NULL); } else { /* this is correct, UPS and CSR are not in the kernel */ g_object_set (device, "type", DKP_DEVICE_TYPE_BATTERY, NULL); } Attached is a patch that decides based on the "type" value instead. With that patch, it works better: # devkit-power -e /org/freedesktop/DeviceKit/Power/devices/battery_battery /org/freedesktop/DeviceKit/Power/devices/line_power_adapter /org/freedesktop/DeviceKit/Power/devices/line_power_ac /org/freedesktop/DeviceKit/Power/devices/line_power_usb But the battery information returned is rather incomplete: # devkit-power -i /org/freedesktop/DeviceKit/Power/devices/battery native-path: /sys/class/power_supply/battery power supply: yes updated: Wed Sep 30 17:25:36 2009 (15 seconds ago) has history: yes has statistics: yes battery present: yes rechargeable: yes state: charging energy: 0 Wh energy-empty: 0 Wh energy-full: 0 Wh energy-full-design: 0 Wh energy-rate: 0 W voltage: 4.174 V percentage: 0% technology: lithium-ion For your reference, these are the contents of the uevent entry for the battery: # cat /sys/class/power_supply/battery/uevent PHYSDEVPATH=/devices/platform/s3c24xx_pwm.0/hdq.0/bq27000-battery.0 PHYSDEVBUS=platform PHYSDEVDRIVER=bq27000-battery POWER_SUPPLY_NAME=battery POWER_SUPPLY_TYPE=Battery POWER_SUPPLY_STATUS=Charging POWER_SUPPLY_HEALTH=Good POWER_SUPPLY_VOLTAGE_NOW=4174000 POWER_SUPPLY_CURRENT_NOW=0 POWER_SUPPLY_CHARGE_FULL=1122229 POWER_SUPPLY_CHARGE_NOW=1122229 POWER_SUPPLY_TEMP=211 POWER_SUPPLY_TECHNOLOGY=Li-ion POWER_SUPPLY_PRESENT=1 POWER_SUPPLY_TIME_TO_EMPTY_NOW=3932100 POWER_SUPPLY_TIME_TO_FULL_NOW=3932100 POWER_SUPPLY_CAPACITY=100 POWER_SUPPLY_ONLINE=1 At this point I stop digging, waiting to hear from you. Ciao, Enrico -- GPG key: 4096R/E7AD5568 2009-05-08 Enrico Zini <enr...@enricozini.org>
diff --git a/src/dkp-device-supply.c b/src/dkp-device-supply.c index fb091a3..e6b7ea0 100644 --- a/src/dkp-device-supply.c +++ b/src/dkp-device-supply.c @@ -636,6 +636,8 @@ dkp_device_supply_coldplug (DkpDevice *device) gboolean ret; GUdevDevice *d; const gchar *native_path; + gchar* device_type; + int is_set; dkp_device_supply_reset_values (supply); @@ -648,11 +650,33 @@ dkp_device_supply_coldplug (DkpDevice *device) if (native_path == NULL) egg_error ("could not get native path"); - if (sysfs_file_exists (native_path, "online")) { - g_object_set (device, "type", DKP_DEVICE_TYPE_LINE_POWER, NULL); - } else { - /* this is correct, UPS and CSR are not in the kernel */ - g_object_set (device, "type", DKP_DEVICE_TYPE_BATTERY, NULL); + // First try to detect using the device type + is_set = 0; + device_type = dkp_device_supply_get_string(native_path, "type"); + if (device_type != NULL) + { + if (strcasecmp(device_type, "mains") == 0) + { + g_object_set (device, "type", DKP_DEVICE_TYPE_LINE_POWER, NULL); + is_set = 1; + } + else if (strcasecmp(device_type, "battery") == 0) + { + g_object_set (device, "type", DKP_DEVICE_TYPE_BATTERY, NULL); + is_set = 1; + } + g_free(device_type); + device_type = NULL; + } + // If reading the device type did not work, use the previous method + if (!is_set) + { + if (sysfs_file_exists (native_path, "online")) { + g_object_set (device, "type", DKP_DEVICE_TYPE_LINE_POWER, NULL); + } else { + /* this is correct, UPS and CSR are not in the kernel */ + g_object_set (device, "type", DKP_DEVICE_TYPE_BATTERY, NULL); + } } /* coldplug values */
signature.asc
Description: Digital signature
_______________________________________________ Smartphones-userland mailing list Smartphones-userland@linuxtogo.org http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/smartphones-userland