/* * Copyright 2013 Red Hat Inc. * * 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: Ben Skeggs
*/ #include"priv.h"
if (therm) {
ret = nvkm_therm_cstate(therm, pstate->fanspeed, +1); if (ret && ret != -ENODEV) {
nvkm_error(subdev, "failed to raise fan speed: %d\n", ret); return ret;
}
}
if (volt) {
ret = nvkm_volt_set_id(volt, cstate->voltage,
pstate->base.voltage, clk->temp, +1); if (ret && ret != -ENODEV) {
nvkm_error(subdev, "failed to raise voltage: %d\n", ret); return ret;
}
}
ret = clk->func->calc(clk, cstate); if (ret == 0) {
ret = clk->func->prog(clk);
clk->func->tidy(clk);
}
if (volt) {
ret = nvkm_volt_set_id(volt, cstate->voltage,
pstate->base.voltage, clk->temp, -1); if (ret && ret != -ENODEV)
nvkm_error(subdev, "failed to lower voltage: %d\n", ret);
}
if (therm) {
ret = nvkm_therm_cstate(therm, pstate->fanspeed, -1); if (ret && ret != -ENODEV)
nvkm_error(subdev, "failed to lower fan speed: %d\n", ret);
}
/****************************************************************************** * Adjustment triggers
*****************************************************************************/ staticint
nvkm_clk_ustate_update(struct nvkm_clk *clk, int req)
{ struct nvkm_pstate *pstate; int i = 0;
if (!clk->allow_reclock) return -ENOSYS;
if (req != -1 && req != -2) {
list_for_each_entry(pstate, &clk->states, head) { if (pstate->pstate == req) break;
i++;
}
if (pstate->pstate != req) return -EINVAL;
req = i;
}
return req + 2;
}
staticint
nvkm_clk_nstate(struct nvkm_clk *clk, constchar *mode, int arglen)
{ int ret = 1;
if (clk->allow_reclock && !strncasecmpz(mode, "auto", arglen)) return -2;
if (strncasecmpz(mode, "disabled", arglen)) { char save = mode[arglen]; long v;
((char *)mode)[arglen] = '\0'; if (!kstrtol(mode, 0, &v)) {
ret = nvkm_clk_ustate_update(clk, v); if (ret < 0)
ret = 1;
}
((char *)mode)[arglen] = save;
}
return ret - 2;
}
int
nvkm_clk_ustate(struct nvkm_clk *clk, int req, int pwr)
{ int ret = nvkm_clk_ustate_update(clk, req); if (ret >= 0) { if (ret -= 2, pwr) clk->ustate_ac = ret; else clk->ustate_dc = ret; return nvkm_pstate_calc(clk, true);
} return ret;
}
int
nvkm_clk_astate(struct nvkm_clk *clk, int req, int rel, bool wait)
{ if (!rel) clk->astate = req; if ( rel) clk->astate += rel;
clk->astate = min(clk->astate, clk->state_nr - 1);
clk->astate = max(clk->astate, 0); return nvkm_pstate_calc(clk, wait);
}
int
nvkm_clk_tstate(struct nvkm_clk *clk, u8 temp)
{ if (clk->temp == temp) return 0;
clk->temp = temp; return nvkm_pstate_calc(clk, false);
}
int
nvkm_clk_dstate(struct nvkm_clk *clk, int req, int rel)
{ if (!rel) clk->dstate = req; if ( rel) clk->dstate += rel;
clk->dstate = min(clk->dstate, clk->state_nr - 1);
clk->dstate = max(clk->dstate, 0); return nvkm_pstate_calc(clk, true);
}
int
nvkm_clk_pwrsrc(struct nvkm_device *device)
{ if (device->clk) return nvkm_pstate_calc(device->clk, false); return 0;
}
/****************************************************************************** * subdev base class implementation
*****************************************************************************/
/* If no pstates are provided, try and fetch them from the BIOS */ if (!func->pstates) {
idx = 0; do {
ret = nvkm_pstate_new(clk, idx++);
} while (ret == 0);
} else { for (idx = 0; idx < func->nr_pstates; idx++)
list_add_tail(&func->pstates[idx].head, &clk->states);
clk->state_nr = func->nr_pstates;
}
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.