Commit 60c9df14 authored by Radek Polak's avatar Radek Polak

Merge branch 'master' into gta02_with_2_6_29_kernel

Conflicts:
	devices/neo/custom.cpp
	devices/neo/server/neohardware.cpp
	devices/neo/src/devtools/scripts/usb-device.sh
	devices/neo/src/plugins/multiplexers/neo/neomultiplexer.cpp
	devices/neo/src/plugins/phonevendors/neo/vendor_neo.cpp
	doc/txt/debian_rootfs_howto.txt
	src/3rdparty/applications/neocontrol/neocontrol.cpp
parents 3e1b6561 3457ab6c
......@@ -17,7 +17,7 @@ git submodule update
* Create and enter debian chroot:
sudo scripts/qtmoko-chroot.sh
sudo scripts/qtmoko-chroot-armhf.sh
* Build it:
......@@ -153,7 +153,7 @@ PC build
* Create and enter debian chroot:
sudo scripts/qtmoko-chroot.sh
sudo scripts/qtmoko-chroot-armhf.sh
mkdir -p /root/qte/build-pc
cd /root/qte/build-pc
......
qtmoko (58-1) unstable; urgency=low
* gta02 kernel upgrade to 2.6.39
* gta04 kernel upgrade to latest Neil's 3.7
* hack to stop vibrating after resume
* show end call button after 2s to avoid unwanted press
* improved colors in qmplayer encoding
* better name of encoded movie in qmplayer
* using emdebian for some packages
* using glamo-mplayer as package
* suspend in locked screen is now after 3s
-- Radek Polak <psonek2@seznam.cz> Sun, 01 Dec 2013 21:16:00 +0100
qtmoko (57-1) unstable; urgency=low
* clever charging for gta04
* charging log
* better sysfs for gta04 in neocontrol
-- Radek Polak <psonek2@seznam.cz> Sat, 14 Sep 2013 11:20:00 +0100
qtmoko (56-1) unstable; urgency=low
* optimise removed messages on IMAP server (Neil Jerram)
......
......@@ -25,6 +25,7 @@
#include <QLabel>
#include <QDesktopWidget>
#include <QProcess>
#include <QSettings>
#include <QPowerSourceProvider>
#include <qcontentset.h>
......@@ -84,8 +85,12 @@ ac(QPowerSource::Wall, "PrimaryAC", this)
, battery(QPowerSource::Battery, "NeoBattery", this)
, batteryVso("/UI/Battery", this)
, vsoPortableHandsfree("/Hardware/Accessories/PortableHandsfree")
, chargeLog("/var/log/charging")
, lastLogDt()
, ueventSocket(this)
, timer(this)
, chargingLogInterval(300)
, maxChargeCurrent(-1)
{
qLog(Hardware) << "gta04 hardware";
......@@ -108,12 +113,35 @@ ac(QPowerSource::Wall, "PrimaryAC", this)
QtopiaIpcAdaptor::connect(adaptor, MESSAGE(headphonesInserted(bool)),
this, SLOT(headphonesInserted(bool)));
// Y sets usb charging limit to 600mA which can be too high and causes
// charging voltage drops. We will set limit manually to prevent this.
qWriteFile("/sys/module/twl4030_charger/parameters/allow_usb", "N");
QSettings cfg("Trolltech", "qpe");
cfg.beginGroup("Charging");
chargingLogInterval = cfg.value("LogInterval", 300).toInt();
}
NeoHardware::~NeoHardware()
{
}
void NeoHardware::setMaxChargeCurrent(int newValue)
{
if (newValue < 100000)
newValue = 100000;
if (newValue > MAX_CURRENT)
newValue = MAX_CURRENT;
if (maxChargeCurrent == newValue)
return;
char buf[7];
maxChargeCurrent = newValue;
sprintf(buf, "%d", maxChargeCurrent);
qWriteFile("/sys/class/power_supply/twl4030_usb/max_current", buf);
}
// Parse uevent string and return given attribute value. Example uevent file:
// POWER_SUPPLY_NAME=bq27000-battery
// POWER_SUPPLY_STATUS=Full
......@@ -149,31 +177,62 @@ static int getIntAttr(const char *name, QByteArray & uevent)
return str.toInt();
}
void NeoHardware::logCharge(QDateTime now, int chargeNow)
{
if (lastLogDt.secsTo(now) < chargingLogInterval)
return;
lastLogDt = now;
if (!chargeLog.exists())
return;
QString newEntry =
now.toString("yyyy-MM-dd hh:mm:ss") + "\t" +
QString::number(chargeNow) + "\n";
if (!chargeLog.open(QIODevice::WriteOnly | QIODevice::Append))
return;
chargeLog.write(newEntry.toLatin1().constData());
chargeLog.close();
// When user selects fast updates, use timer to update status because
// uevent does not trigger that fast.
if (chargingLogInterval < 300)
QTimer::singleShot(1000 * chargingLogInterval, this, SLOT(updateStatus()));
}
void NeoHardware::updateStatus()
{
QDateTime now = QDateTime::currentDateTime();
// Determine charging via USB
QByteArray twlVbus =
qReadFile("/sys/bus/platform/devices/twl4030_usb/vbus");
if (twlVbus.contains("on"))
bool chargerOn = twlVbus.contains("on");
if (chargerOn)
ac.setAvailability(QPowerSource::Available);
else
ac.setAvailability(QPowerSource::NotAvailable);
battery.setCharging(chargerOn);
// Update battery status
QByteArray uevent =
qReadFile("/sys/class/power_supply/bq27000-battery/uevent");
bool charging = uevent.contains("POWER_SUPPLY_STATUS=Charging");
battery.setCharging(charging);
int timeToEmpty = getIntAttr("POWER_SUPPLY_TIME_TO_EMPTY_NOW=", uevent);
if (timeToEmpty >= 0)
battery.setTimeRemaining(timeToEmpty / 60);
int capacity = getIntAttr("POWER_SUPPLY_CAPACITY=", uevent);
int chargeNow = getIntAttr("POWER_SUPPLY_CHARGE_NOW=", uevent);
if (capacity < 0) {
// Handle uncalibrated battery - it does not have POWER_SUPPLY_CAPACITY
// and we compute capacity from charge_now and charge_full_design.
// http://lists.goldelico.com/pipermail/gta04-owner/2013-February/003903.html
int chargeNow = getIntAttr("POWER_SUPPLY_CHARGE_NOW=", uevent);
// http://lists.goldelico.com/pipermail/gta04-owner/2013-February/003903.html
int chargeFullDesign =
getIntAttr("POWER_SUPPLY_CHARGE_FULL_DESIGN=", uevent);
capacity = (chargeNow * 100) / chargeFullDesign;
......@@ -182,8 +241,46 @@ void NeoHardware::updateStatus()
if (capacity > 0)
battery.setCharge(capacity);
int currentNow = getIntAttr("POWER_SUPPLY_CURRENT_NOW=", uevent) / 1000;
batteryVso.setAttribute("current_now", QString::number(currentNow));
int currentNow = getIntAttr("POWER_SUPPLY_CURRENT_NOW=", uevent);
batteryVso.setAttribute("current_now", QString::number(currentNow / 1000));
// Now we will try to set max_current so that phone charges reliably.
int chargerVoltage = -1;
if (chargerOn) {
if (maxChargeCurrent < 0)
setMaxChargeCurrent(INIT_CURRENT);
QByteArray chargerUevent =
qReadFile("/sys/class/power_supply/twl4030_usb/uevent");
chargerVoltage = getIntAttr("POWER_SUPPLY_VOLTAGE_NOW=", chargerUevent);
// Warn if charging voltage drops too low
if (chargerVoltage < 4500000 && chargerVoltage > 0)
qWarning() << "Charging voltage dropped to " << chargerVoltage <<
", charging might not restart when battery gets low";
// Battery discharges
if (currentNow > 0 || capacity <= 90) {
// Increase charging current until 600mA, but make sure that
// voltage wont drop under 4.5V, for more info see:
// http://lists.goldelico.com/pipermail/gta04-owner/2013-September/004963.html
if (chargerVoltage > 4600000 && chargerVoltage != oldChargerVoltage) {
setMaxChargeCurrent(maxChargeCurrent + CURRENT_PLUS);
QTimer::singleShot(200, this, SLOT(updateStatus()));
}
} else if (currentNow < -50000 && oldChargeNow != chargeNow) { // Battery is finishing charging
setMaxChargeCurrent(maxChargeCurrent + currentNow / 2); // slow charging down under 50mA
}
oldChargerVoltage = chargerVoltage;
} else if (maxChargeCurrent > INIT_CURRENT) {
maxChargeCurrent = -1;
}
oldChargeNow = chargeNow;
// Charging log
logCharge(now, chargeNow);
}
#define UEVENT_BUFFER_SIZE 1024
......@@ -204,8 +301,8 @@ void NeoHardware::uevent()
void NeoHardware::shutdownRequested()
{
qLog(PowerManagement) << __PRETTY_FUNCTION__;
QtopiaServerApplication::instance()->shutdown(QtopiaServerApplication::
ShutdownSystem);
QtopiaServerApplication::instance()->
shutdown(QtopiaServerApplication::ShutdownSystem);
}
void NeoHardware::headphonesInserted(bool b)
......
......@@ -21,9 +21,11 @@
#ifndef NEOHARDWARE_H
#define NEOHARDWARE_H
#include <QFile>
#include <QTimer>
#include <QObject>
#include <QProcess>
#include <QDateTime>
#include <QTcpSocket>
#include <QtopiaIpcAdaptor>
#include <QPowerSourceProvider>
......@@ -38,6 +40,17 @@ class QSocketNotifier;
class QtopiaIpcAdaptor;
class QSpeakerPhoneAccessoryProvider;
// Initial charging current - we will raise it until charging voltage does not
// drop under 4.6V
#define INIT_CURRENT 100000
// Max charging current
#define MAX_CURRENT 600000
// Max value used to raise charging current. We cant raise with large numbers
// because charging voltage could drop below 4.4V and made charging unreliable
#define CURRENT_PLUS 50000
class NeoHardware : public QObject
{
Q_OBJECT
......@@ -50,12 +63,20 @@ private:
QPowerSourceProvider battery;
QValueSpaceObject batteryVso;
QValueSpaceObject vsoPortableHandsfree;
QFile chargeLog; // power supply log
QDateTime lastLogDt;
QTcpSocket ueventSocket;
QTimer timer;
int chargingLogInterval;
int maxChargeCurrent;
int oldChargeNow;
int oldChargerVoltage;
bool hasSmartBattery;
QtopiaIpcAdaptor *adaptor;
QtopiaIpcAdaptor *audioMgr;
void setMaxChargeCurrent(int newValue);
void logCharge(QDateTime now, int chargeNow);
private slots:
void headphonesInserted(bool);
void shutdownRequested();
......
......@@ -85,9 +85,7 @@ bool NeoSuspend::canSuspend() const
static int readChargeNow()
{
QString chargeNowStr =
qReadFile("/sys/class/power_supply/bq27000-battery/charge_now");
return chargeNowStr.toInt();
return qReadSysfsInt("/sys/class/power_supply/bq27000-battery/charge_now");
}
bool NeoSuspend::suspend()
......@@ -126,9 +124,7 @@ bool NeoSuspend::wake()
QString::number(avgCurrent));
// Read and update current_now. It should contain the current in suspend
QString currentNowStr =
qReadFile("/sys/class/power_supply/bq27000-battery/current_now");
int currentNow = currentNowStr.toInt() / 1000;
int currentNow = qReadSysfsInt("/sys/class/power_supply/bq27000-battery/current_now") / 1000;
batteryVso.setAttribute("current_now_in_suspend",
QString::number(currentNow));
......
[DeepSleep]
Active=never
[OPSYS]
Value="AT_OPSYS=0,2"
[Multiplexing]
Active=no
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment