Logo Search packages:      
Sourcecode: vaiostat version File versions  Download package

static int write_status_info ( char *  page,
char **  start,
off_t  off,
int  count,
int *  eof,
void *  data 
) [static]

write message to proc file system

Parameters:
page output buffer
start 
off 
count 
eof 
data 
Returns:
buffer length

Definition at line 133 of file vaiostat.c.

References ecr_get16(), and ecr_get8().

Referenced by vaio_init_module().

{
      int len = 0;
      int v1,v11,v21,v12,v22,v3;
      int ac, mt1, mt2, sec_left, h_left, m_left;

      if ( off > 0 )
            return 0;

      /* get LCD brightness level */
      v1 = ecr_get8( LCD_LEVEL ) / (255/LCD_NUM_STEPS);
      len += sprintf( page+len,
                  "lcd_lvl\t : %d\n"
                  ,v1
                  );

      /* get power source / remaining information */
      v3 = ecr_get16( PWR_SRCS );

      //  battery 1
      mt1 = ecr_get16( B0_MAXRT1 ) / 7;
      v11 = ecr_get16( B0_LFTTK1 );
      v21 = ecr_get16( B0_FULTK1 );
      
      //  battery 2
      if (v3 & 0x2) {
            mt2 = ecr_get16( B0_MAXRT2 ) / 7;
            v12 = ecr_get16( B0_LFTTK2 );
            v22 = ecr_get16( B0_FULTK2 );
            }
      else {      
            mt2 = 0;
            v12 = 0;
            v22 = 1;
            }                 
      
      ac = (v3 & 0x4);
      sec_left = (mt1 * v11 / v21) + (mt2 * v12 / v22 ) ;

      if ( ac ) {
            sec_left = 0;
            h_left = 0;
            m_left = 0;
      }
      else {
            h_left = sec_left / 3600;
            m_left = (sec_left % 3600) / 60 ;
      }

      len += sprintf( page+len,
                  "pw_src\t : %s%s%s\n"
                  "pw_lvl\t : %d/%d %d/%d %d%% %d%% %d%% %d %d:%.2d\n"
                  , (ac ? "AC " : "" )
                  , (v3 & 0x1 ? "BAT1 " : "" )
                  , (v3 & 0x2 ? "BAT2 " : "" )
      //  bat1 remaining/full, bat2 remaining/full
                  , v11, v21, v12, v22
      //  bat1 percent, bat2 percent, (bat1+bat2) percent, sec h min remaining
                  , 100*v11/v21, 100*v12/v22, 100*(v11+v12)/(v21+v22)
                  , sec_left, h_left, m_left
                  );
      
      /* print out the status message buffer */
      if ( len <= off+count ) *eof = 1;
      *start = page + off;
      len -= off;
      if ( len > count ) len = count;
      if ( len < 0 ) len = 0;

      return len;
}


Generated by  Doxygen 1.6.0   Back to index