Пример #1
0
static void rk2918_get_bat_capacity(struct rk2918_battery_data *bat)
{
    s32 deltatime = 0;
    ktime_t ktmietmp;
    struct timespec ts;
    
	ktmietmp = ktime_get_real();
    ts = ktime_to_timespec(ktmietmp);
	deltatime = ts.tv_sec - batteryspendcnt;
	
	if (first_flag || (openfailflag && (openfailcount > 1))) 
	//多次打开,刚开始采样时不准,多次采样。。
	{
	     if(first_flag == 1)
	     		first_flag--;
	     openfailcount--;
	  printk("%s,first_flag=%d,openfailflag=%d,openfailcount=%d\n",__func__,first_flag,openfailflag,openfailcount);   		
	    gBatCapacity = rk2918_battery_load_capacity();
	    if (gBatCapacity == 0) gBatCapacity = 1;
	}
	else if ((deltatime > 1) && (first_flag == 0) &&(!time_chg_flag))//处理休眠之后的电量回复,如果超过十分钟
	{	
		//printk("---->time_chg_flag =%d\n", time_chg_flag);
        gBatCapacity = rk2918_battery_resume_get_Capacity(deltatime);
	}
	else
	{
        gBatCapacity = rk2918_get_bat_capacity_ext(gBatVoltage);
        
    }
	if(time_chg_flag)
		time_chg_flag = 0;
    batteryspendcnt = ts.tv_sec;
	
}
Пример #2
0
static void rk2918_get_bat_capacity(struct rk2918_battery_data *bat)
{

    int deltatime = 0;
	struct timespec now;
	getnstimeofday(&now);
	deltatime = now.tv_sec-batteryspendcnt1;
	if (resumeflag == 1)
		printk("%s..batteryspendcnt1=%d  now.tv_sec=%d,deltatime=%d\n",__FUNCTION__,batteryspendcnt1,(unsigned long)now.tv_sec,deltatime);


	//if (first_flag || (openfailcount > 1)) 
	if (first_flag || (openfailflag && (openfailcount > 1))) 
	//多次打开,刚开始采样时不准,多次采样。。
	{
	     if(first_flag == 1)
	     		first_flag= 0;
	     		
	    openfailcount--;
	  	//printk("%s,first_flag=%d,openfailflag=%d,openfailcount=%d\n",__func__,first_flag,openfailflag,openfailcount);   		
	  	
	    gBatCapacity = rk2918_battery_load_capacity();
	    if (gBatCapacity == 0) gBatCapacity = 1;
	}

	else if ((resumeflag == 1) && (deltatime > 700) && (first_flag == 0))//处理休眠之后的电量回复,如果超过十分钟
	{		
			resumeflag = 0;
        	gBatCapacity = rk2918_battery_resume_get_Capacity(deltatime);
        
	}
	else
	{
			resumeflag = 0;
			gBatCapacity = rk2918_get_bat_capacity_ext(gBatVoltage);
        /*	
        	if(deltatime>1)
        	{
			if(gBatCapacity--<2)
				gBatCapacity  = 50;

			if(gBatCapacity==15)
				gBatCapacity = 4;
			batteryspendcnt = ktmietmp.tv.sec;
        	}
        */        
      }
	batteryspendcnt1 = now.tv_sec;
	
}
Пример #3
0
static void rk2918_get_bat_capacity(struct rk2918_battery_data *bat)
{
    int deltatime = 0;
    ktime_t ktmietmp;
    struct timespec ts;
    
	ktmietmp = ktime_get_real();
  	ts = ktime_to_timespec(ktmietmp);
	deltatime = ts.tv_sec - batteryspendcnt;
	//deltatime = ktmietmp.tv.sec - batteryspendcnt;

	if (first_flag || (openfailflag && (openfailcount > 1))) 
	//多次打开,刚开始采样时不准,多次采样。。
	{
	     if(first_flag == 1)
	     		first_flag--;
	     openfailcount--;
	  printk("%s,first_flag=%d,openfailflag=%d,openfailcount=%d\n",__func__,first_flag,openfailflag,openfailcount);   		
	    gBatCapacity = rk2918_battery_load_capacity();
	    if (gBatCapacity == 0) 
			gBatCapacity = 1;
	}

	else if ((deltatime > 600) && (first_flag == 0))//处理休眠之后的电量回复,如果超过十分钟
	{		
        	gBatCapacity = rk2918_battery_resume_get_Capacity(deltatime);
	}
	else
	{
        	gBatCapacity = rk2918_get_bat_capacity_ext(gBatVoltage);
        /*	
        	if(deltatime>1)
        	{
			if(gBatCapacity--<2)
				gBatCapacity  = 50;

			if(gBatCapacity==15)
				gBatCapacity = 4;
			batteryspendcnt = ktmietmp.tv.sec;
        	}
        */
        
    }
    //batteryspendcnt = ktmietmp.tv.sec;
    batteryspendcnt=ts.tv_sec;
	
}