欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > Android >内容正文

Android

android 调整cpu频率,[IMX6DL][Android4.4] CPU频率调节模式以及降频方法

发布时间:2023/12/20 Android 47 豆豆
生活随笔 收集整理的这篇文章主要介绍了 android 调整cpu频率,[IMX6DL][Android4.4] CPU频率调节模式以及降频方法 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

Kernel branch: 3.0.35

CPU的频率调节模式:

1. Performance.  不考虑耗电,只用最高频率。

2. Interactive.  直接上最高频率,然后看CPU负荷慢慢降低。

3. Powersave.    通常以最低频率运行,流畅度会受影响,一般不会用这个吧!

4. Userspace.    可以在用户空间手动调节频率。

5. Ondemand.    定期检查负载,根据负载来调节频率。

cpu频率相关的目录:

root@tek_mx6:/sys/devices/system/cpu/cpuX, X表示cpu number.

root@tek_mx6:/sys/devices/system/cpu/cpu0/cpufreq # ls

affected_cpus

cpuinfo_cur_freq

cpuinfo_max_freq

cpuinfo_min_freq

cpuinfo_transition_latency

related_cpus

scaling_available_frequencies

scaling_available_governors

scaling_cur_freq

scaling_driver

scaling_governor

scaling_max_freq

scaling_min_freq

scaling_setspeed

stats

工作模式:

当前支持的cpu调节模式可通过scaling_available_frequencies查看,

root@tek_mx6:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_available_governors

interactive conservative ondemand userspace powersave performance

可通过defconfig编译进去:

kernel_imx/arch/arm/configs/imx6_tek_android_defconfig:

CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y

......

CONFIG_CPU_FREQ_GOV_PERFORMANCE=y

CONFIG_CPU_FREQ_GOV_POWERSAVE=y

CONFIG_CPU_FREQ_GOV_USERSPACE=y

CONFIG_CPU_FREQ_GOV_ONDEMAND=y

CONFIG_CPU_FREQ_GOV_INTERACTIVE=y

CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y

默认使用了performance,不过freescale在boot完成后改成了interactive.

device/fsl/tek_mx6/init.rc:

on property:sys.boot_completed=1

# Set default CPU frequency governor

# Set timer 40ms, min sample 60ms,hispeed at cpufreq MAX freq in freq_table at load 40%

write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor interactive

最终可通过scaling_governor文件查看。

工作频率:

当前支持的cpu调节模式可通过 scaling_available_frequencies 查看。

root@tek_mx6:/sys/devices/system/cpu/cpu0/cpufreq # cat scaling_available_frequencies

vailable_frequencies

996000 792000 396000

当前工作频率可通过scaling_cur_freq查看。

支持的频率以及最大频率是在文件:

kernel_imx/arch/arm/mach-mx6/cpu_op-mx6.c

struct cpu_op *mx6_get_cpu_op(int *op)

{

if (cpu_is_mx6dl()) {

if (arm_max_freq == CPU_AT_1_2GHz) {

*op = num_cpu_op = ARRAY_SIZE(mx6dl_cpu_op_1_2G);

return mx6dl_cpu_op_1_2G;

} else if (arm_max_freq == CPU_AT_1GHz) {

*op = num_cpu_op = ARRAY_SIZE(mx6dl_cpu_op_1G);

return mx6dl_cpu_op_1G;

} else {

*op = num_cpu_op = ARRAY_SIZE(mx6dl_cpu_op);

return mx6dl_cpu_op;

}

} else if (cpu_is_mx6q()) {

......

} else {

......

}

}根据平台以及默认的最大频率来选择对应的频率列表。

所以降频有两种方法:

1. 直接编译静态修改频率列表。

2. 通过scaling_max_freq文件动态写入。

总结

以上是生活随笔为你收集整理的android 调整cpu频率,[IMX6DL][Android4.4] CPU频率调节模式以及降频方法的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。