[Desire Android Development] Droidzone:
Full Battery Charge for Extended Battery - Cameron Sino 2400 mAh

With this kernel code, I have enabled full charge characteristics for the Cameron Sino Extended battery 2400 mAh

The stock battery is 1400/1500 Mah, the full battery level polled is a max of 1500 only due to HTC Code limitation. The attached kernel (to upload later at request) makes it test whether the battery is an extended Cameron Sino or not. If it is, then the max MAh level is upped to 2400 mAh.. I have added additional debug lines to output some useful battery stats.

Code:

--- /home/droidzone/android/kernel/power_ds2784_patches/ds2784_battery.c.bak	2011-11-05 21:32:15.000000000 +0530
+++ /home/droidzone/android/kernel/bravo_2.6.35_gb-mr/drivers/power/ds2784_battery.c	2011-11-06 09:14:01.255605163 +0530
@@ -118,8 +118,11 @@ PS. 0 or other battery ID use the same p
/* Battery ID = 1: HT-E/Formosa 1400mAh */
#define BATT_ID_A	1
#define BATT_FULL_MAH_A	1400
-
#define BATT_FULL_MAH_DEFAULT	1500
+#define BATT_FULL_MAH_CAMERONSINO	2400
+#define BATT_ID_CAMERONSINO
+#define BATT_TYPE 0
+

/* Battery OVP and Charging stage define */
#define BATT_GOOD_STATE	0
@@ -145,6 +148,7 @@ PS. 0 or other battery ID use the same p
//#endif
static struct ds2784_device_info htc_batt_info;
static int htc_battery_initial;
+static int Batt_extended;
static int Full_40;
static int Full_30;
static int Full_20;
@@ -213,7 +217,7 @@ static int ds2784_blocking_notify(unsign
htc_batt_info.rep.charging_enabled = DISABLE;
chg_ctl = DISABLE;
v = DISABLE;
-	pr_info("[HTC_BATT] Unknow battery\n");
+	pr_info("[HTC_BATT] Unknown battery\n");
}

if (machine_is_passionc() || machine_is_bravoc()) {
@@ -285,8 +289,10 @@ ssize_t htc_battery_show_attr(struct dev
htc_batt_info.rep.full_level,
fake_temp
);
+	pr_info("[HTC_BATT] Battery ID is %d\n", htc_batt_info.rep.batt_id);
}
return len;
+
}

static int cable_status_handler_func(struct notifier_block *nfb,
@@ -388,8 +394,25 @@ static int Calculate_Full_mAh(struct ds2
int Upper_Full = 0;
int Lower_Full = 0;
int Delta_temp = 0;
-
-	Full_mAh = BATT_FULL_MAH_DEFAULT;
+
+	if (Batt_extended == 1) {
+	Full_mAh = BATT_FULL_MAH_CAMERONSINO;
+	pr_info("[HTC_BATT] Extended Battery detected and Charge Characteristics set\n");
+	pr_info("[HTC_BATT] Max Battery mAh is now set as %d\n", Full_mAh);
+	} else {
+	Full_mAh = BATT_FULL_MAH_DEFAULT;
+	pr_info("[HTC_BATT] Standard HTC Battery detected and Charge Characteristics set\n");
+	pr_info("[HTC_BATT] Max Battery mAh is now set as %d\n", Full_mAh);
+	}
+
+
+
+	/* BATT_FULL_MAH_CAMERONSINO
+	Droidzone's Hack
+	Full_mAh = BATT_FULL_MAH_CAMERONSINO;
+	Batt_extended
+
+	*/

/* Only calculate at initial */
if (htc_battery_initial == 0) {
@@ -484,12 +507,20 @@ ONLY check when battery driver init.
/*
Get Rsns, get from offset 69H . Rsnsp=1/Rsns
Judge if this is supported battery
+Extended Battery Charge Status fix by Droidzone
*/
mutex_lock(&htc_batt_info.lock);
-	if (di->raw[DS2784_REG_RSNSP] != BATT_RSNSP)
-	htc_batt_info.rep.batt_id = BATT_UNKNOWN;
-	else
-	htc_batt_info.rep.batt_id = BATT_FIRST_SOURCE;
+	if (di->raw[DS2784_REG_RSNSP] != BATT_RSNSP) {
+	pr_info("batt: Extended unsupported battery detected\n");
+	pr_info("batt: Re-enabling charge and status indicator - Droidzone\n");
+	pr_info("batt: Battery check overridden\n");
+	pr_info("batt: Dirty hack : Battery set as Cameron Sino\n");
+	Batt_extended = 1;
+	} else {
+	Batt_extended = 0;
+	}
+
+	htc_batt_info.rep.batt_id = BATT_FIRST_SOURCE;
mutex_unlock(&htc_batt_info.lock);

/*
@@ -548,6 +579,7 @@ Get ACR and Active Empty
/*
Set to local for reply to framework
*/
+	pr_info("[HTC_BATT] Battery Debug 1 - Calculating Battery Stats\n");
htc_batt_info.rep.batt_current = di->current_mA;
htc_batt_info.rep.batt_current_avg = di->current_avg_mA;
htc_batt_info.rep.batt_temp = di->temp_C;
@@ -558,6 +590,8 @@ Set to local for reply to framework
htc_batt_info.rep.acr = di->acr;
htc_batt_info.rep.active_empty = di->active_empty;
htc_batt_info.rep.full_bat = Calculate_Full_mAh(di);
+	pr_info("[HTC_BATT] Battery Debug 2 - Full mAh value is %d\n", htc_batt_info.rep.full_bat);
+	/*pr_info("Battery Debug 1 - Calculating Battery Stats\n"*/

/* After battery driver gets initialized, send rpc request to inquiry
@@ -575,6 +609,7 @@ pr_info("[HTC_BATT]RSNSP=%d,RARC=%d,Vol=
,di->voltage_mV
,di->current_mA
,di->temp_C);
+pr_info("[HTC_BATT] Battery reported Full Value is %d mAh\n", htc_batt_info.rep.full_bat);
mutex_unlock(&htc_batt_info.lock);
return 0;
}
@@ -871,6 +906,9 @@ if (machine_is_bravoc()) {
* user while we're maintaining a full charge
* (slowly draining to 95 and charging back
* to 100)
+	*
+	* Modified by Sibere Battfix
+	*
*/
if (htc_batt_info.rep.charging_source != 0) {
if (htc_batt_info.rep.level <= 99)