【RK3399 Android10, 支持温控风扇】

文章目录

  • 【RK3399 Android10, 支持温控风扇】
    • 需求描述
    • patch

【RK3399 Android10, 支持温控风扇】

需求描述

3399 Android10 的风扇,希望能做成温度控制的风扇,通过设置不同测温度阈值来实行不同的风速

patch

kernel

0020-feat-rochchip-system-monitor-add-temperature-notifye.patch

From 92116bdb9aa3efc280dd9c2699e8e82642860343 Mon Sep 17 00:00:00 2001
From: liangji <[email protected]>
Date: Tue, 26 Dec 2023 15:50:42 +0800
Subject: [PATCH 20/24] feat: rochchip system monitor add temperature notifyer

Change-Id: I8a561b9fdcaf4d15a8ee9e827eb3a350e342f55c
Signed-off-by: liangji <[email protected]>
---
 drivers/soc/rockchip/rockchip_system_monitor.c | 42 ++++++++++++++++++++++++--
 include/soc/rockchip/rockchip_system_monitor.h | 26 ++++++++++++++++
 2 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/rockchip/rockchip_system_monitor.c b/drivers/soc/rockchip/rockchip_system_monitor.c
index 8a84d02..fcd980be 100644
--- a/drivers/soc/rockchip/rockchip_system_monitor.c
+++ b/drivers/soc/rockchip/rockchip_system_monitor.c
@@ -64,6 +64,7 @@ struct system_monitor {
   
 
 	struct thermal_zone_device *tz;
 	struct delayed_work thermal_work;
+	int last_temp;
 	int offline_cpus_temp;
 	int temp_hysteresis;
 	unsigned int delay;
@@ -84,6 +85,7 @@ static LIST_HEAD(monitor_dev_list);
 static struct system_monitor *system_monitor;
 static atomic_t monitor_in_suspend;
 
+static BLOCKING_NOTIFIER_HEAD(system_monitor_notifier_list);
 static BLOCKING_NOTIFIER_HEAD(system_status_notifier_list);
 
 int rockchip_register_system_status_notifier(struct notifier_block *nb)
@@ -1167,6 +1169,31 @@ void rockchip_system_monitor_unregister(struct monitor_dev_info *info)
 }
 EXPORT_SYMBOL(rockchip_system_monitor_unregister);
 
+int rockchip_system_monitor_register_notifier(struct notifier_block *nb)
+{
   
+	return blocking_notifier_chain_register(&system_monitor_notifier_list, nb);
+}
+EXPORT_SYMBOL(rockchip_system_monitor_register_notifier);
+
+void rockchip_system_monitor_unregister_notifier(struct notifier_block *nb)
+{
   
+	blocking_notifier_chain_unregister(&system_monitor_notifier_list, nb);
+}
+EXPORT_SYMBOL(rockchip_system_monitor_unregister_notifier);
+
+static int rockchip_system_monitor_temp_notify(int temp)
+{
   
+	struct system_monitor_event_data event_data;
+	int ret;
+
+	event_data.temp = temp;
+	ret = blocking_notifier_call_chain(&system_monitor_notifier_list,
+					   SYSTEM_MONITOR_CHANGE_TEMP,
+					   (void *)&event_data);
+
+	return notifier_to_errno(ret);
+}
+
 static int rockchip_system_monitor_parse_dt(struct system_monitor *monitor)
 {
   
 	struct device_node *np = monitor->dev->of_node;
@@ -1266,7 +1293,7 @@ static void rockchip_system_monitor_thermal_update(void)
 {
   
 	int temp, ret;
 	struct monitor_dev_info *info;
-	static int last_temp = INT_MAX;
+	//static int last_temp = INT_MAX;
 
 	ret = thermal_zone_get_temp(system_monitor->tz, &temp);
 	if (ret || temp == THERMAL_TEMP_INVALID)
@@ -1274,9 +1301,15 @@ static void rockchip_system_monitor_thermal_update(void)
 
 	dev_dbg(system_monitor->dev, "temperature=%d\n", temp);
 
-	if (temp < last_temp && last_temp - temp <= 2000)
+	//if (temp < last_temp && last_temp - temp <= 2000)
+	if (temp < system_monitor->last_temp &&
+	    system_monitor->last_temp - temp <= 2000)
 		goto out;
-	last_temp = temp;
+	//last_temp = temp;
+	system_monitor->last_temp = temp;
+
+	rockchip_system_monitor_temp_notify(temp);
+
 
 	down_read(

你可能感兴趣的:(elasticsearch,大数据,搜索引擎)