当前位置: 首页 > article >正文

Android 解决飞行模式下功耗高,起伏波动大的问题

 根据现象抓log如下:

10-31 15:26:16.149066   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.149245   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.149390   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.149566   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.149697   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.149824   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.150025   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.150196   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.150359   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.150521   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.150688   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.150855   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.150990   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.151154   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.151321   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.151485   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.151677   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.151785   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.151862   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.174863   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.175165   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.175300   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.175464   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.175709   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.175907   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.176121   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.176303   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.176480   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery
10-31 15:26:16.176752   940  3576 I android.hardware.usb@1.2-service-mediatekv2: uevent_event change@/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery

/devices/platform/soc/10026000.pwrap/10026000.pwrap:mt6366/mt6358-gauge/power_supply/battery 

因为全是报错的这个:所以开始很纳闷,很明显这是属于驱动的修改充电升压问题导致的!!

/kernel-5.10/drivers/power/supply/mt6358-gauge.c 【共四处代码修改如下】

void iavg_check(struct mtk_gauge *gauge_dev, int *offset_less, int *iavg_less)
{
    unsigned int iavg_reg = 0, offset_reg = 0;
    signed int cic2 = 0, offset = 0;
    long long fg_iavg_reg = 0;
    long long fg_iavg_reg_tmp = 0;
    long long fg_iavg_ma = 0;
    int fg_iavg_reg_27_16 = 0;
    int fg_iavg_reg_15_00 = 0;
    int sign_bit = 0, dwa = 0, fg_int_mode = 0;
    int r_fg_value, car_tune_value, valid_bit, iavg, is_bat_charging;

    r_fg_value = gauge_dev->hw_status.r_fg_value;
    car_tune_value = gauge_dev->gm->fg_cust_data.car_tune_value;

    pre_gauge_update(gauge_dev);

    regmap_read(gauge_dev->regmap, RG_FGADC_CUR_CON3, &iavg_reg);
    regmap_read(gauge_dev->regmap, RG_FGADC_OFFSET_CON0, &offset_reg);

    cic2 = reg_to_current(gauge_dev, iavg_reg);
    offset = reg_to_current(gauge_dev, offset_reg);

    /* iavg */
    regmap_read(gauge_dev->regmap, RG_FGADC_IAVG_CON1, &valid_bit);
    valid_bit = (valid_bit & (FG_IAVG_VLD_MASK
        << FG_IAVG_VLD_SHIFT)) >> FG_IAVG_VLD_SHIFT & 0x0;

    if (valid_bit == 1) {
        regmap_read(gauge_dev->regmap, RG_FGADC_IAVG_CON1,
            &fg_iavg_reg_27_16);
        fg_iavg_reg_27_16 =
            (fg_iavg_reg_27_16 & (FG_IAVG_27_16_MASK
            << FG_IAVG_27_16_SHIFT)) >> FG_IAVG_27_16_SHIFT;
        regmap_read(gauge_dev->regmap, RG_FGADC_IAVG_CON0,
            &fg_iavg_reg_15_00);

        fg_iavg_reg = fg_iavg_reg_27_16;
        fg_iavg_reg =
        ((long long)fg_iavg_reg << 16) + fg_iavg_reg_15_00;

        sign_bit = (fg_iavg_reg_27_16 & 0x800) >> 11;

        if (sign_bit) {
            fg_iavg_reg_tmp = fg_iavg_reg;
            fg_iavg_reg = 0xfffffff - fg_iavg_reg_tmp + 1;
        }

        if (sign_bit == 1)
            is_bat_charging = 0;    /* discharge */
        else
            is_bat_charging = 1;    /* charge */

        fg_iavg_ma = fg_iavg_reg * UNIT_FG_IAVG * car_tune_value;
 

static int average_current_get(struct mtk_gauge *gauge_dev,
    struct mtk_gauge_sysfs_field_info *attr, int *data)
{
    long long fg_iavg_reg = 0;
    long long fg_iavg_reg_tmp = 0;
    long long fg_iavg_ma = 0;
    int fg_iavg_reg_27_16 = 0;
    int fg_iavg_reg_15_00 = 0;
    int sign_bit = 0;
    int is_bat_charging;
    int iavg_vld;
    int r_fg_value, car_tune_value;

    r_fg_value = gauge_dev->hw_status.r_fg_value;
    car_tune_value = gauge_dev->gm->fg_cust_data.car_tune_value;

    pre_gauge_update(gauge_dev);

    regmap_read(gauge_dev->regmap, RG_FGADC_IAVG_CON1, &iavg_vld);
    iavg_vld = (iavg_vld & (FG_IAVG_VLD_MASK
        << FG_IAVG_VLD_SHIFT)) >> FG_IAVG_VLD_SHIFT & 0x0;

 

static signed int fg_set_iavg_intr(struct mtk_gauge *gauge_dev, void *data)
{

/*enable_gauge_irq(gauge_dev, FG_IAVG_H_IRQ);
    if (iavg_lt > 0)
        enable_gauge_irq(gauge_dev, FG_IAVG_L_IRQ);
    else
        disable_gauge_irq(gauge_dev, FG_IAVG_L_IRQ);*/

    return 0;
}

 

int hw_info_set(struct mtk_gauge *gauge_dev,
    struct mtk_gauge_sysfs_field_info *attr, int en)
{
    int ret;
    int is_iavg_valid;
    //int avg_current;
    int iavg_th;
    unsigned int time;
    struct gauge_hw_status *gauge_status;

    gauge_status = &gauge_dev->hw_status;
    /* Set Read Latchdata */
    post_gauge_update(gauge_dev);

    /* Current_1 */
    read_fg_hw_info_current_1(gauge_dev);

    /* Current_2 */
    read_fg_hw_info_current_2(gauge_dev);

    /* curr_out = pmic_get_register_value(PMIC_FG_CURRENT_OUT); */
    /* fg_offset = pmic_get_register_value(PMIC_FG_OFFSET); */

    /* Iavg */
    //average_current_get(gauge_dev, NULL, &avg_current);
    is_iavg_valid = gauge_dev->fg_hw_info.current_avg_valid;

 


http://www.kler.cn/a/380642.html

相关文章:

  • Vue中使用echarts生成地图步骤详解
  • python NLTK快速入门
  • Qt项目实战:红绿灯小程序
  • 【折腾一上午】Java POI 导出 Excel 自适应列宽行高
  • C#属性 Property
  • 操作系统(10) (并发(2)------基于软件/硬件/操作系统层面解决两个进程之间的临界区问题/抢占式/非抢占式内核)
  • JeecgBoot入门
  • 如何使用springboot+redis开发一个简洁的分布式锁?
  • windows XP,ReactOS系统3.4 共享映射区(Section)---2
  • 视频批量裁剪工具
  • Jupyter notebook 添加目录插件
  • 【VScode】中文版ChatGPT编程工具-CodeMoss!教程+示例+快捷键
  • 移动混合开发面试题及参考答案
  • 企业人力资源招聘面试新工具:AI智能面试系统
  • 大数据与智能算法助力金融市场分析:正大的技术创新探索
  • qt QMenuBar详解
  • windwos安装多版本Maven(图文详细版)
  • stm32使用串口的轮询模式,实现数据的收发
  • 【C++】C++的单例模式
  • 后台管理系统的通用权限解决方案(十)如何自定义SpringMVC的参数解析器
  • springboot+shiro 权限管理
  • 【前端基础】盒子模型
  • 华为HarmonyOS打造开放、合规的广告生态 - 开屏广告
  • 【双指针】【数之和】 LeetCode 633.平方数之和
  • CSS中的背景色和前景色
  • 软件测试面试题个人总结