01> thermal温度检测处理函数:kernel-3.18/drivers/misc/mediatek/thermal/common/coolers/mtk_cooler_bcct.c
static void mtk_cl_bcct_set_bcct_limit(void) { /* TODO: optimize */ int i = 0; int min_limit = 65535; for (; i < MAX_NUM_INSTANCE_MTK_COOLER_BCCT; i++) { unsigned long curr_state; MTK_CL_BCCT_GET_CURR_STATE(curr_state, cl_bcct_state[i]); if (1 == curr_state) { int limit; MTK_CL_BCCT_GET_LIMIT(limit, cl_bcct_state[i]); //计算温度对应电流函数A; if ((min_limit > limit) && (limit > 0)) min_limit = limit; } } if (min_limit != cl_bcct_cur_limit) { cl_bcct_cur_limit = min_limit; if (65535 <= cl_bcct_cur_limit) { //mtk默认65000,也就是函数A值小于该值走else; set_bat_charging_current_limit(-1); //line_charging中减流实际动作函数; mtk_cooler_bcct_dprintk_always("mtk_cl_bcct_set_bcct_limit() limit=-1 "); } else { set_bat_charging_current_limit(cl_bcct_cur_limit); //走此 mtk_cooler_bcct_dprintk_always("mtk_cl_bcct_set_bcct_limit() limit=%d ", cl_bcct_cur_limit); } mtk_cooler_bcct_dprintk_always("mtk_cl_bcct_set_bcct_limit() real limit=%d ", get_bat_charging_current_level() / 100); } }
---
在 thermal.conf表中打开过温检测后,该程序10s扫描2次,周一5秒;
在:
static int mtk_cl_bcct_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { mtk_cooler_bcct_dprintk("mtk_cl_bcct_set_cur_state() %s %lu ", cdev->type, state); printk("mtk_cl_bcct_set_cur_state() %s %lu ", cdev->type, state); //state为软件部分判断温度后识别值,传入kernel;(值为0,1) MTK_CL_BCCT_SET_CURR_STATE(state, *((unsigned long *)cdev->devdata)); mtk_cl_bcct_set_bcct_limit(); mtk_cooler_bcct_dprintk("mtk_cl_bcct_set_cur_state() %s limit=%d ", cdev->type, get_bat_charging_current_level() / 100); return 0; }
02>line_charging中:
①引入lcm亮度检测函数:
extern unsigned int mt_get_bl_brightness(void);
②对set_bat_charging_current_limit()函数处理:
unsigned int set_bat_charging_current_limit(int current_limit) { battery_log(BAT_LOG_CRTI, "[BATTERY] set_bat_charging_current_limit (%d) ", current_limit); if (current_limit != -1) { g_bcct_flag = 1; if (current_limit < 70) g_temp_CC_value = CHARGE_CURRENT_0_00_MA; else if (current_limit < 200) g_temp_CC_value = CHARGE_CURRENT_70_00_MA;
改为:
unsigned int set_bat_charging_current_limit(int current_limit) { battery_log(BAT_LOG_CRTI, "[BATTERY] set_bat_charging_current_limit (%d) ", current_limit); if ( (current_limit != -1) && (mt_get_bl_brightness() != 0) ) { g_bcct_flag = 1; if (current_limit < 70) g_temp_CC_value = CHARGE_CURRENT_0_00_MA; else if (current_limit < 200) g_temp_CC_value = CHARGE_CURRENT_70_00_MA; else if (current_limit < 300)
log:
<3>[ 730.985645] (0)[181:bat_thread_kthr]AvgVbat=(3761,3896),AvgI=(688,1029),VChr=5213,AvgT=(25,25),SOC=(3,3),UI_SOC=3,ZCV=3777 bcct:0:0 I:120000
---
<3>[ 812.105116] (0)[181:bat_thread_kthr]AvgVbat=(3783,3790),AvgI=(688,573),VChr=5166,AvgT=(25,25),SOC=(4,4),UI_SOC=4,ZCV=3738 bcct:1:0 I:65000
---
<7>[ 1201.987442] (0)[4115:kworker/0:0][name:mtk_cooler_bcct&][thermal/cooler/bcct]mtk_cl_bcct_set_bcct_limit() limit=650 <7>[ 1201.987461] (0)[4115:kworker/0:0][name:mtk_cooler_bcct&][thermal/cooler/bcct]mtk_cl_bcct_set_bcct_limit() real limit=1200
--
-
adb shell system/vendor/bin/thermal_manager vendor/etc/.tp/.ht120.mtc
2)关闭之后验证,获取配置的cmd:
adb shell cat data/.tp/.settings
如果是120则是:vendor/etc/.tp/.ht120.mtc
--------