diff options
author | jay_wang <Jay_Wang@compal.com> | 2017-05-12 11:53:33 +0800 |
---|---|---|
committer | Alain Vongsouvanh <alainv@google.com> | 2017-05-13 16:34:13 +0000 |
commit | 88484a22c0ca87e18978ec6f1f4ac37394b6bd4e (patch) | |
tree | da4fe17cc23e23053ab4d60fe69a0c90adf7c551 | |
parent | 679449ca235229894f0efe76f780378a09f3bca8 (diff) |
charger: Add notify LLOB sensor of the temperature statusandroid-wear-7.1.1_r0.20
Using the netlink method to notify LLOB of the temperature status
Bug: 35993239
Change-Id: Ifeaff0e5555ec4c7636b029273b1f5e82c17aa91
-rw-r--r-- | drivers/power/smb23x-charger.c | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/drivers/power/smb23x-charger.c b/drivers/power/smb23x-charger.c index b30a3fc2cd1d..8e962213ddb7 100644 --- a/drivers/power/smb23x-charger.c +++ b/drivers/power/smb23x-charger.c @@ -85,7 +85,7 @@ static void udp_exit(void) pr_debug(" netlink sock remove successfully\n"); } -static void udp_sendmsg(int power_status) +static void udp_sendmsg_charging(int power_status) { static bool last_status = false; if(power_status != 0 && last_status==false){ @@ -100,6 +100,50 @@ static void udp_sendmsg(int power_status) } } +static void udp_sendmsg_tempature(int value) +{ + const int thresholdTempRaising=2; + const int thresholdTempFalling=2; + static int compareTemp=0; + static int tempStatus=0; + int currentTemp=value/10; + + if(compareTemp==0){ + compareTemp=currentTemp; + } + else if( currentTemp!=compareTemp ){ + if( (currentTemp-compareTemp)>=thresholdTempRaising ){ + //Raising + if( (tempStatus&0x03)==0 ){ + tempStatus=1; + } + compareTemp=currentTemp; + } + else if( (compareTemp-currentTemp)>=thresholdTempFalling ){ + //falling + if( (tempStatus&0x0C)==0 ){ + tempStatus=4; + } + compareTemp=currentTemp; + } + else if( ((currentTemp>compareTemp)&&(tempStatus&0x03)) || + ((currentTemp<compareTemp)&&(tempStatus&0x0C)) ){ + compareTemp=currentTemp; + } + } + + if((tempStatus&0x0F)==1){ + udp_broadcast(1,"TempRaising\0", 12); + tempStatus=tempStatus|0x02; + pr_debug("Tempature raising\n"); + } + else if((tempStatus&0x0F)==4){ + udp_broadcast(1,"TempFalling\0", 12); + tempStatus=tempStatus|0x08; + pr_debug("Tempature falling\n"); + } +} + struct smb23x_wakeup_source { struct wakeup_source source; unsigned long enabled_bitmap; @@ -2759,6 +2803,7 @@ static int smb23x_battery_get_property(struct power_supply *psy, break; case POWER_SUPPLY_PROP_TEMP: val->intval = smb23x_get_prop_batt_temp(chip); + udp_sendmsg_tempature(val->intval); break; case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: val->intval = chip->reg_addr; @@ -2859,7 +2904,7 @@ static int smb23x_battery_set_property(struct power_supply *psy, pr_info("Charger plug, state=%d\n", chip->charger_plugin); power_supply_changed(chip->usb_psy); - udp_sendmsg(chip->charger_plugin); + udp_sendmsg_charging(chip->charger_plugin); break; case POWER_SUPPLY_PROP_CHARGING_ENABLED: smb23x_charging_enable(chip, val->intval); |