linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI Battery: Added capacity
@ 2012-04-06  0:38 srinivas pandruvada
  2012-04-07  1:28 ` Len Brown
  0 siblings, 1 reply; 4+ messages in thread
From: srinivas pandruvada @ 2012-04-06  0:38 UTC (permalink / raw)
  To: linux-acpi; +Cc: srinivas pandruvada

Added Capacity field, which is a pre-defined power_supply
property. Calculating capacity using current charge/energy and
full charge/energy.
Some user mode implementations are relying on capacity field to
show battery strength and power down decision.

Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
---
 drivers/acpi/battery.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index fcc13ac..997b369 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -251,6 +251,13 @@ static int acpi_battery_get_property(struct power_supply *psy,
 		else
 			val->intval = battery->capacity_now * 1000;
 		break;
+	case POWER_SUPPLY_PROP_CAPACITY:
+		if (battery->capacity_now && battery->full_charge_capacity)
+			val->intval = battery->capacity_now * 100/
+					battery->full_charge_capacity;
+		else
+			val->intval = 0;
+		break;
 	case POWER_SUPPLY_PROP_MODEL_NAME:
 		val->strval = battery->model_number;
 		break;
@@ -277,6 +284,7 @@ static enum power_supply_property charge_battery_props[] = {
 	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
 	POWER_SUPPLY_PROP_CHARGE_FULL,
 	POWER_SUPPLY_PROP_CHARGE_NOW,
+	POWER_SUPPLY_PROP_CAPACITY,
 	POWER_SUPPLY_PROP_MODEL_NAME,
 	POWER_SUPPLY_PROP_MANUFACTURER,
 	POWER_SUPPLY_PROP_SERIAL_NUMBER,
@@ -293,6 +301,7 @@ static enum power_supply_property energy_battery_props[] = {
 	POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
 	POWER_SUPPLY_PROP_ENERGY_FULL,
 	POWER_SUPPLY_PROP_ENERGY_NOW,
+	POWER_SUPPLY_PROP_CAPACITY,
 	POWER_SUPPLY_PROP_MODEL_NAME,
 	POWER_SUPPLY_PROP_MANUFACTURER,
 	POWER_SUPPLY_PROP_SERIAL_NUMBER,
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ACPI Battery: Added capacity
  2012-04-06  0:38 [PATCH] ACPI Battery: Added capacity srinivas pandruvada
@ 2012-04-07  1:28 ` Len Brown
  2012-04-09 14:59   ` Pandruvada, Srinivas
  0 siblings, 1 reply; 4+ messages in thread
From: Len Brown @ 2012-04-07  1:28 UTC (permalink / raw)
  To: srinivas pandruvada; +Cc: linux-acpi

Can't this be computed in user-space?

-L

On 04/05/2012 08:38 PM, srinivas pandruvada wrote:

> Added Capacity field, which is a pre-defined power_supply
> property. Calculating capacity using current charge/energy and
> full charge/energy.
> Some user mode implementations are relying on capacity field to
> show battery strength and power down decision.
> 
> Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
> ---
>  drivers/acpi/battery.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index fcc13ac..997b369 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -251,6 +251,13 @@ static int acpi_battery_get_property(struct power_supply *psy,
>  		else
>  			val->intval = battery->capacity_now * 1000;
>  		break;
> +	case POWER_SUPPLY_PROP_CAPACITY:
> +		if (battery->capacity_now && battery->full_charge_capacity)
> +			val->intval = battery->capacity_now * 100/
> +					battery->full_charge_capacity;
> +		else
> +			val->intval = 0;
> +		break;
>  	case POWER_SUPPLY_PROP_MODEL_NAME:
>  		val->strval = battery->model_number;
>  		break;
> @@ -277,6 +284,7 @@ static enum power_supply_property charge_battery_props[] = {
>  	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
>  	POWER_SUPPLY_PROP_CHARGE_FULL,
>  	POWER_SUPPLY_PROP_CHARGE_NOW,
> +	POWER_SUPPLY_PROP_CAPACITY,
>  	POWER_SUPPLY_PROP_MODEL_NAME,
>  	POWER_SUPPLY_PROP_MANUFACTURER,
>  	POWER_SUPPLY_PROP_SERIAL_NUMBER,
> @@ -293,6 +301,7 @@ static enum power_supply_property energy_battery_props[] = {
>  	POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
>  	POWER_SUPPLY_PROP_ENERGY_FULL,
>  	POWER_SUPPLY_PROP_ENERGY_NOW,
> +	POWER_SUPPLY_PROP_CAPACITY,
>  	POWER_SUPPLY_PROP_MODEL_NAME,
>  	POWER_SUPPLY_PROP_MANUFACTURER,
>  	POWER_SUPPLY_PROP_SERIAL_NUMBER,



^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] ACPI Battery: Added capacity
  2012-04-07  1:28 ` Len Brown
@ 2012-04-09 14:59   ` Pandruvada, Srinivas
  2012-06-01 23:00     ` Len Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Pandruvada, Srinivas @ 2012-04-09 14:59 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-acpi@vger.kernel.org

This can be computed in user space. But this patch is targeting ANDROID, where this needs change in Android framework. Other battery drivers are providing this field, so added this field in ACPI battery also.

Thanks,
Srinivas

-----Original Message-----
From: Len Brown [mailto:lenb417@gmail.com] On Behalf Of Len Brown
Sent: Friday, April 06, 2012 6:29 PM
To: Pandruvada, Srinivas
Cc: linux-acpi@vger.kernel.org
Subject: Re: [PATCH] ACPI Battery: Added capacity

Can't this be computed in user-space?

-L

On 04/05/2012 08:38 PM, srinivas pandruvada wrote:

> Added Capacity field, which is a pre-defined power_supply property. 
> Calculating capacity using current charge/energy and full 
> charge/energy.
> Some user mode implementations are relying on capacity field to show 
> battery strength and power down decision.
> 
> Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
> ---
>  drivers/acpi/battery.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 
> fcc13ac..997b369 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -251,6 +251,13 @@ static int acpi_battery_get_property(struct power_supply *psy,
>  		else
>  			val->intval = battery->capacity_now * 1000;
>  		break;
> +	case POWER_SUPPLY_PROP_CAPACITY:
> +		if (battery->capacity_now && battery->full_charge_capacity)
> +			val->intval = battery->capacity_now * 100/
> +					battery->full_charge_capacity;
> +		else
> +			val->intval = 0;
> +		break;
>  	case POWER_SUPPLY_PROP_MODEL_NAME:
>  		val->strval = battery->model_number;
>  		break;
> @@ -277,6 +284,7 @@ static enum power_supply_property charge_battery_props[] = {
>  	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
>  	POWER_SUPPLY_PROP_CHARGE_FULL,
>  	POWER_SUPPLY_PROP_CHARGE_NOW,
> +	POWER_SUPPLY_PROP_CAPACITY,
>  	POWER_SUPPLY_PROP_MODEL_NAME,
>  	POWER_SUPPLY_PROP_MANUFACTURER,
>  	POWER_SUPPLY_PROP_SERIAL_NUMBER,
> @@ -293,6 +301,7 @@ static enum power_supply_property energy_battery_props[] = {
>  	POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
>  	POWER_SUPPLY_PROP_ENERGY_FULL,
>  	POWER_SUPPLY_PROP_ENERGY_NOW,
> +	POWER_SUPPLY_PROP_CAPACITY,
>  	POWER_SUPPLY_PROP_MODEL_NAME,
>  	POWER_SUPPLY_PROP_MANUFACTURER,
>  	POWER_SUPPLY_PROP_SERIAL_NUMBER,



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ACPI Battery: Added capacity
  2012-04-09 14:59   ` Pandruvada, Srinivas
@ 2012-06-01 23:00     ` Len Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Len Brown @ 2012-06-01 23:00 UTC (permalink / raw)
  To: Pandruvada, Srinivas; +Cc: linux-acpi@vger.kernel.org

On 04/09/2012 10:59 AM, Pandruvada, Srinivas wrote:

> This can be computed in user space. But this patch is targeting ANDROID, where this needs change in Android framework. Other battery drivers are providing this field, so added this field in ACPI battery also.

okay.

Applied.

thanks,
Len Brown, Intel Open Source Technology Center


> -----Original Message-----
> From: Len Brown [mailto:lenb417@gmail.com] On Behalf Of Len Brown
> Sent: Friday, April 06, 2012 6:29 PM
> To: Pandruvada, Srinivas
> Cc: linux-acpi@vger.kernel.org
> Subject: Re: [PATCH] ACPI Battery: Added capacity
> 
> Can't this be computed in user-space?
> 
> -L
> 
> On 04/05/2012 08:38 PM, srinivas pandruvada wrote:
> 
>> Added Capacity field, which is a pre-defined power_supply property. 
>> Calculating capacity using current charge/energy and full 
>> charge/energy.
>> Some user mode implementations are relying on capacity field to show 
>> battery strength and power down decision.
>>
>> Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
>> ---
>>  drivers/acpi/battery.c |    9 +++++++++
>>  1 files changed, 9 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 
>> fcc13ac..997b369 100644
>> --- a/drivers/acpi/battery.c
>> +++ b/drivers/acpi/battery.c
>> @@ -251,6 +251,13 @@ static int acpi_battery_get_property(struct power_supply *psy,
>>  		else
>>  			val->intval = battery->capacity_now * 1000;
>>  		break;
>> +	case POWER_SUPPLY_PROP_CAPACITY:
>> +		if (battery->capacity_now && battery->full_charge_capacity)
>> +			val->intval = battery->capacity_now * 100/
>> +					battery->full_charge_capacity;
>> +		else
>> +			val->intval = 0;
>> +		break;
>>  	case POWER_SUPPLY_PROP_MODEL_NAME:
>>  		val->strval = battery->model_number;
>>  		break;
>> @@ -277,6 +284,7 @@ static enum power_supply_property charge_battery_props[] = {
>>  	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
>>  	POWER_SUPPLY_PROP_CHARGE_FULL,
>>  	POWER_SUPPLY_PROP_CHARGE_NOW,
>> +	POWER_SUPPLY_PROP_CAPACITY,
>>  	POWER_SUPPLY_PROP_MODEL_NAME,
>>  	POWER_SUPPLY_PROP_MANUFACTURER,
>>  	POWER_SUPPLY_PROP_SERIAL_NUMBER,
>> @@ -293,6 +301,7 @@ static enum power_supply_property energy_battery_props[] = {
>>  	POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
>>  	POWER_SUPPLY_PROP_ENERGY_FULL,
>>  	POWER_SUPPLY_PROP_ENERGY_NOW,
>> +	POWER_SUPPLY_PROP_CAPACITY,
>>  	POWER_SUPPLY_PROP_MODEL_NAME,
>>  	POWER_SUPPLY_PROP_MANUFACTURER,
>>  	POWER_SUPPLY_PROP_SERIAL_NUMBER,
> 
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-01 23:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-06  0:38 [PATCH] ACPI Battery: Added capacity srinivas pandruvada
2012-04-07  1:28 ` Len Brown
2012-04-09 14:59   ` Pandruvada, Srinivas
2012-06-01 23:00     ` Len Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).