|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
Linux动态频率调节系统CPUFreq之了解一下其它的API$ j) l; W7 n$ ~
. o2 X$ n% |4 A* o1 E6 H
, v& @+ S% y! I- X# J7 Scpufreq的核心层除了提供上面几节讨论的注册governor,注册cpufreq_driver等API外,还提供了其他一些辅助的API,以方便其它模块的使用。
. v) N& l, G* q+ J1 O3 n! g+ U' e; \2 H) ?
6 O/ ~+ y3 p9 n1 i- int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list);
- int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list);/ p7 J0 Y& P3 K% ]- q' W
; W0 e! N' Z! N* w6 F* S
! P; z' ~' W I& R* M# i0 _( |( i) j+ o$ a* {5 k) `
以上两个API用于注册和注销cpufreq系统的通知消息,第二个参数可以选择通知的类型,可以有以下两种类型:+ N0 L% p# s( `$ p2 ?
! N7 I2 T5 r& B) I- y: @3 C
: b3 h3 y! I5 {/ `5 M8 ^- CPUFREQ_TRANSITION_NOTIFIER 收到频率变更通知
- CPUFREQ_POLICY_NOTIFIER 收到policy更新通知
# `. Q, \; W5 g1 u" b
, c% P" y; ^% o9 e" Y
& ~9 u/ g( E1 k& f7 C4 \4 G0 M, b2 Q( ~5 Z( m/ k1 n! a, `
- int cpufreq_driver_target(struct cpufreq_policy *policy, m+ r2 |2 G- \+ q! ^/ P
: A( @3 i- S$ U unsigned int target_freq, z4 X/ c( N' F6 B! r
unsigned int relation);
# ]. n' y& h, r' Y3 Z( @1 M- int __cpufreq_driver_target(struct cpufreq_policy *policy,
! _0 T1 Q K. K+ `. n0 ~$ h2 u - R, J7 W! |) r$ i/ [
unsigned int target_freq,% N6 b( J6 w* j
unsigned int relation);: w; P, M, a% p" m
+ _* V6 d3 y; ?
G! _, G5 ^3 |& b2 R! J4 G以上两个API用来设置cpu的工作频率,区别在于cpufreq_driver_target是带锁的版本,而__cpufreq_driver_target是不带锁的版本,如果确定是在governor的上下文中,使用不带锁的版本,否则需要使用带锁的版本。4 F% |5 U) Q) ]# t) G o; b( G
" w' W+ m) l; k9 N9 T6 e1 Y( n4 B4 _4 I6 ]8 f" M% A [
- void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max);
! y7 ?$ M* |4 S C) f2 d + s7 H: h* T+ Q6 i! q( x
9 `, W; O1 Z8 P, \6 Z: p
' q1 T7 l& J0 u w4 ]3 q
这个API用来检查并重新设定policy的最大和最小频率。
E0 e1 I0 J1 l- J8 c- W' E# Y: E0 o, L
, Z& n, P+ f j* z) Y5 z- int cpufreq_update_policy(unsigned int cpu);9 k5 e: K2 K1 {4 {
, w/ Z6 y$ H4 f |" H1 ~; S* Y2 g" e+ c
2 M5 E, z/ t- i5 L
这个API用来触发cpufreq核心进行policy的更新操作。
, t5 w* p. E( U! q" A$ N& K! c5 ~$ y) F& [' F
( x: j D, ]9 V! z$ K- [" w) A2 [* R; H; X4 ^6 L) e' C2 E
8 P& d* x7 M9 T. |9 X* q1 G8 r. v: h! J4 r! w
$ j* z) U7 r/ L% D7 J3 W7 e( w, g- U
" b& Z* r- c* A
) {' m1 I# ~4 d' }
% d5 n- D7 _8 M8 j" j
|
|