/* * Copyright 2012 The Nouveau community * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Authors: Martin Peres
*/ #include"priv.h"
#include <core/option.h> #include <subdev/pmu.h>
int
nvkm_therm_temp_get(struct nvkm_therm *therm)
{ if (therm->func->temp_get) return therm->func->temp_get(therm); return -ENODEV;
}
/* look for the trip point corresponding to the current temperature */
cur_trip = NULL; for (i = 0; i < therm->fan->bios.nr_fan_trip; i++) { if (temp >= trip[i].temp)
cur_trip = &trip[i];
}
/* account for the hysteresis cycle */ if (last_trip && temp <= (last_trip->temp) &&
temp > (last_trip->temp - last_trip->hysteresis))
cur_trip = last_trip;
/* handle the non-linear part first */ if (temp < linear_min_temp) return therm->fan->bios.min_duty; elseif (temp > linear_max_temp) return therm->fan->bios.max_duty;
/* we are in the linear zone */
duty = (temp - linear_min_temp);
duty *= (therm->fan->bios.max_duty - therm->fan->bios.min_duty);
duty /= (linear_max_temp - linear_min_temp);
duty += therm->fan->bios.min_duty; return duty;
}
staticint
nvkm_therm_update_linear(struct nvkm_therm *therm)
{
u8 min = therm->fan->bios.linear_min_temp;
u8 max = therm->fan->bios.linear_max_temp; return nvkm_therm_compute_linear_duty(therm, min, max);
}
/* The default PPWR ucode on fermi interferes with fan management */ if ((mode >= ARRAY_SIZE(name)) ||
(mode != NVKM_THERM_CTRL_NONE && nvkm_pmu_fan_controlled(device))) return -EINVAL;
/* do not allow automatic fan management if the thermal sensor is
* not available */ if (mode == NVKM_THERM_CTRL_AUTO &&
therm->func->temp_get(therm) < 0) return -EINVAL;
int
nvkm_therm_attr_get(struct nvkm_therm *therm, enum nvkm_therm_attr_type type)
{ switch (type) { case NVKM_THERM_ATTR_FAN_MIN_DUTY: return therm->fan->bios.min_duty; case NVKM_THERM_ATTR_FAN_MAX_DUTY: return therm->fan->bios.max_duty; case NVKM_THERM_ATTR_FAN_MODE: return therm->mode; case NVKM_THERM_ATTR_THRS_FAN_BOOST: return therm->bios_sensor.thrs_fan_boost.temp; case NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST: return therm->bios_sensor.thrs_fan_boost.hysteresis; case NVKM_THERM_ATTR_THRS_DOWN_CLK: return therm->bios_sensor.thrs_down_clock.temp; case NVKM_THERM_ATTR_THRS_DOWN_CLK_HYST: return therm->bios_sensor.thrs_down_clock.hysteresis; case NVKM_THERM_ATTR_THRS_CRITICAL: return therm->bios_sensor.thrs_critical.temp; case NVKM_THERM_ATTR_THRS_CRITICAL_HYST: return therm->bios_sensor.thrs_critical.hysteresis; case NVKM_THERM_ATTR_THRS_SHUTDOWN: return therm->bios_sensor.thrs_shutdown.temp; case NVKM_THERM_ATTR_THRS_SHUTDOWN_HYST: return therm->bios_sensor.thrs_shutdown.hysteresis;
}
return -EINVAL;
}
int
nvkm_therm_attr_set(struct nvkm_therm *therm, enum nvkm_therm_attr_type type, int value)
{ switch (type) { case NVKM_THERM_ATTR_FAN_MIN_DUTY: if (value < 0)
value = 0; if (value > therm->fan->bios.max_duty)
value = therm->fan->bios.max_duty;
therm->fan->bios.min_duty = value; return 0; case NVKM_THERM_ATTR_FAN_MAX_DUTY: if (value < 0)
value = 0; if (value < therm->fan->bios.min_duty)
value = therm->fan->bios.min_duty;
therm->fan->bios.max_duty = value; return 0; case NVKM_THERM_ATTR_FAN_MODE: return nvkm_therm_fan_mode(therm, value); case NVKM_THERM_ATTR_THRS_FAN_BOOST:
therm->bios_sensor.thrs_fan_boost.temp = value;
therm->func->program_alarms(therm); return 0; case NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST:
therm->bios_sensor.thrs_fan_boost.hysteresis = value;
therm->func->program_alarms(therm); return 0; case NVKM_THERM_ATTR_THRS_DOWN_CLK:
therm->bios_sensor.thrs_down_clock.temp = value;
therm->func->program_alarms(therm); return 0; case NVKM_THERM_ATTR_THRS_DOWN_CLK_HYST:
therm->bios_sensor.thrs_down_clock.hysteresis = value;
therm->func->program_alarms(therm); return 0; case NVKM_THERM_ATTR_THRS_CRITICAL:
therm->bios_sensor.thrs_critical.temp = value;
therm->func->program_alarms(therm); return 0; case NVKM_THERM_ATTR_THRS_CRITICAL_HYST:
therm->bios_sensor.thrs_critical.hysteresis = value;
therm->func->program_alarms(therm); return 0; case NVKM_THERM_ATTR_THRS_SHUTDOWN:
therm->bios_sensor.thrs_shutdown.temp = value;
therm->func->program_alarms(therm); return 0; case NVKM_THERM_ATTR_THRS_SHUTDOWN_HYST:
therm->bios_sensor.thrs_shutdown.hysteresis = value;
therm->func->program_alarms(therm); return 0;
}
if (therm->suspend >= 0) { /* restore the pwm value only when on manual or auto mode */ if (therm->suspend > 0)
nvkm_therm_fan_set(therm, true, therm->fan->percent);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.