Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
drivers
gpu
drm
nouveau
core
subdev
therm
base.c
Go to the documentation of this file.
1
/*
2
* Copyright 2012 The Nouveau community
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
* OTHER DEALINGS IN THE SOFTWARE.
21
*
22
* Authors: Martin Peres
23
*/
24
25
#include <
core/object.h
>
26
#include <
core/device.h
>
27
28
#include <
subdev/bios.h
>
29
30
#include "
priv.h
"
31
32
int
33
nouveau_therm_attr_get
(
struct
nouveau_therm
*
therm
,
34
enum
nouveau_therm_attr_type
type
)
35
{
36
struct
nouveau_therm_priv
*
priv
= (
void
*)therm;
37
38
switch
(type) {
39
case
NOUVEAU_THERM_ATTR_FAN_MIN_DUTY
:
40
return
priv->
bios_fan
.min_duty;
41
case
NOUVEAU_THERM_ATTR_FAN_MAX_DUTY
:
42
return
priv->
bios_fan
.max_duty;
43
case
NOUVEAU_THERM_ATTR_FAN_MODE
:
44
return
priv->
fan
.mode;
45
case
NOUVEAU_THERM_ATTR_THRS_FAN_BOOST
:
46
return
priv->
bios_sensor
.thrs_fan_boost.temp;
47
case
NOUVEAU_THERM_ATTR_THRS_FAN_BOOST_HYST
:
48
return
priv->
bios_sensor
.thrs_fan_boost.hysteresis;
49
case
NOUVEAU_THERM_ATTR_THRS_DOWN_CLK
:
50
return
priv->
bios_sensor
.thrs_down_clock.temp;
51
case
NOUVEAU_THERM_ATTR_THRS_DOWN_CLK_HYST
:
52
return
priv->
bios_sensor
.thrs_down_clock.hysteresis;
53
case
NOUVEAU_THERM_ATTR_THRS_CRITICAL
:
54
return
priv->
bios_sensor
.thrs_critical.temp;
55
case
NOUVEAU_THERM_ATTR_THRS_CRITICAL_HYST
:
56
return
priv->
bios_sensor
.thrs_critical.hysteresis;
57
case
NOUVEAU_THERM_ATTR_THRS_SHUTDOWN
:
58
return
priv->
bios_sensor
.thrs_shutdown.temp;
59
case
NOUVEAU_THERM_ATTR_THRS_SHUTDOWN_HYST
:
60
return
priv->
bios_sensor
.thrs_shutdown.hysteresis;
61
}
62
63
return
-
EINVAL
;
64
}
65
66
int
67
nouveau_therm_attr_set
(
struct
nouveau_therm
*
therm
,
68
enum
nouveau_therm_attr_type
type
,
int
value
)
69
{
70
struct
nouveau_therm_priv
*
priv
= (
void
*)therm;
71
72
switch
(type) {
73
case
NOUVEAU_THERM_ATTR_FAN_MIN_DUTY
:
74
if
(value < 0)
75
value = 0;
76
if
(value > priv->
bios_fan
.max_duty)
77
value = priv->
bios_fan
.max_duty;
78
priv->
bios_fan
.min_duty =
value
;
79
return
0;
80
case
NOUVEAU_THERM_ATTR_FAN_MAX_DUTY
:
81
if
(value < 0)
82
value = 0;
83
if
(value < priv->
bios_fan
.min_duty)
84
value = priv->
bios_fan
.min_duty;
85
priv->
bios_fan
.max_duty =
value
;
86
return
0;
87
case
NOUVEAU_THERM_ATTR_FAN_MODE
:
88
return
nouveau_therm_fan_set_mode
(therm, value);
89
case
NOUVEAU_THERM_ATTR_THRS_FAN_BOOST
:
90
priv->
bios_sensor
.thrs_fan_boost.temp =
value
;
91
return
0;
92
case
NOUVEAU_THERM_ATTR_THRS_FAN_BOOST_HYST
:
93
priv->
bios_sensor
.thrs_fan_boost.hysteresis =
value
;
94
return
0;
95
case
NOUVEAU_THERM_ATTR_THRS_DOWN_CLK
:
96
priv->
bios_sensor
.thrs_down_clock.temp =
value
;
97
return
0;
98
case
NOUVEAU_THERM_ATTR_THRS_DOWN_CLK_HYST
:
99
priv->
bios_sensor
.thrs_down_clock.hysteresis =
value
;
100
return
0;
101
case
NOUVEAU_THERM_ATTR_THRS_CRITICAL
:
102
priv->
bios_sensor
.thrs_critical.temp =
value
;
103
return
0;
104
case
NOUVEAU_THERM_ATTR_THRS_CRITICAL_HYST
:
105
priv->
bios_sensor
.thrs_critical.hysteresis =
value
;
106
return
0;
107
case
NOUVEAU_THERM_ATTR_THRS_SHUTDOWN
:
108
priv->
bios_sensor
.thrs_shutdown.temp =
value
;
109
return
0;
110
case
NOUVEAU_THERM_ATTR_THRS_SHUTDOWN_HYST
:
111
priv->
bios_sensor
.thrs_shutdown.hysteresis =
value
;
112
return
0;
113
}
114
115
return
-
EINVAL
;
116
}
117
118
int
119
nouveau_therm_init
(
struct
nouveau_object
*
object
)
120
{
121
struct
nouveau_therm
*
therm
= (
void
*)
object
;
122
struct
nouveau_therm_priv
*
priv
= (
void
*)therm;
123
int
ret
;
124
125
ret =
nouveau_subdev_init
(&therm->
base
);
126
if
(ret)
127
return
ret
;
128
129
if
(priv->
fan
.percent >= 0)
130
therm->
fan_set
(therm, priv->
fan
.percent);
131
132
return
0;
133
}
134
135
int
136
nouveau_therm_fini
(
struct
nouveau_object
*
object
,
bool
suspend
)
137
{
138
struct
nouveau_therm
*
therm
= (
void
*)
object
;
139
struct
nouveau_therm_priv
*
priv
= (
void
*)therm;
140
141
priv->
fan
.percent = therm->
fan_get
(therm);
142
143
return
nouveau_subdev_fini
(&therm->
base
, suspend);
144
}
Generated on Thu Jan 10 2013 13:32:23 for Linux Kernel by
1.8.2