int thread_fn(void *data)
{
  short cpu_temp,gpu_temp,max_temp;
  set_current_state(TASK_INTERRUPTIBLE);
  while(!kthread_should_stop())
  {
    SLEEP_MILLI_SEC(30000);
    cpu_temp = 0;
    gpu_temp = 0;
    cpu_temp = read_ec(0xA8);
    gpu_temp = read_ec(0xAF);
    max_temp = get_max(cpu_temp, gpu_temp);
    if (max_temp < 60) {
      fanSpeed = minFanSpeed;
    }

    if (max_temp > 60) {
      fanSpeed = minFanSpeed+20;
    }

    if (max_temp > 70) {
      fanSpeed = minFanSpeed+40;
    }

    if (max_temp > 80) {
      fanSpeed = maxFanSpeed;
    }
    set_speed(fanSpeed);
    printk(KERN_INFO "cpu temp: %d, gpu temp: %d, fan speed: %d", cpu_temp, gpu_temp, fanSpeed);
    schedule();
    set_current_state(TASK_INTERRUPTIBLE);
  }
  set_current_state(TASK_RUNNING);
  return 0;
}
Exemplo n.º 2
0
/*****************************************************************************
*   driving logic
*****************************************************************************/
int main( int argc, char *argv[]) {
    AsyncAPI api;

    // successful write(): prime AsyncAPI with some data
    write( api, "abcd");
    // successful read(): retrieve it
    std::string data( read( api) );
    assert( data == "abcd");

    // successful write_ec()
    AsyncAPI::errorcode ec( write_ec( api, "efgh") );
    assert( ec == 0);

    // write_ec() with error
    api.inject_error(1);
    ec = write_ec( api, "ijkl");
    assert( ec == 1);

    // write() with error
    std::string thrown;
    api.inject_error(2);
    try {
        write(api, "mnop");
    } catch ( std::exception const& e) {
        thrown = e.what();
    }
    assert( thrown == make_exception("write", 2).what() );

    // successful read_ec()
//[callbacks_read_ec_call
    std::tie( ec, data) = read_ec( api);
//]
    assert( ! ec);
    assert( data == "efgh");         // last successful write_ec()

    // read_ec() with error
    api.inject_error(3);
    std::tie( ec, data) = read_ec( api);
    assert( ec == 3);
    // 'data' in unspecified state, don't test

    // read() with error
    thrown.clear();
    api.inject_error(4);
    try {
        data = read(api);
    } catch ( std::exception const& e) {
        thrown = e.what();
    }
    assert( thrown == make_exception("read", 4).what() );

    std::cout << "done." << std::endl;

    return EXIT_SUCCESS;
}
Exemplo n.º 3
0
static bool
read_keyboard_status (bool *status)
{
  uint8_t tmp;
  if (! read_ec (&tmp)) return 0;

  *status = ((tmp & TABLET_MODE) == 0);
  return 1;
}
Exemplo n.º 4
0
uint8_t read_smbus(ec_dev_t* dev, uint8_t reg)
{
    return read_ec(dev, reg+dev->smbus_offset);
}