From bdb26eaa6d09382c7d0d3f9638e6bb7ac643b02f Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Wed, 25 Dec 2024 15:50:09 +0800 Subject: [PATCH] Thermal/dummy: Add temperature jump to test hysteresis Log z:cpu-thermal t:50 t:1 h:16 l:0 c:fan0 s:0|(invalid) z:cpu-thermal t:47 t:1 h:16 l:0 c:fan0 s:0|(invalid) z:cpu-thermal t:52 t:1 h:16 l:0 c:fan0 s:0|(invalid) z:cpu-thermal t:49 t:1 h:16 l:0 c:fan0 s:0|(invalid) z:cpu-thermal t:54 t:1 h:16 l:0 c:fan0 s:0|(invalid) z:cpu-thermal t:51 t:1 h:16 l:0 c:fan0 s:0|(invalid) z:cpu-thermal t:56 t:1 h:16 l:0 c:fan0 s:0|(invalid) Signed-off-by: wangjianyu3 --- drivers/thermal/thermal_dummy.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/thermal_dummy.c b/drivers/thermal/thermal_dummy.c index 969268b54bb..9db3b7cdcf2 100644 --- a/drivers/thermal/thermal_dummy.c +++ b/drivers/thermal/thermal_dummy.c @@ -48,6 +48,7 @@ struct dummy_zone_device_s { int temperature; bool raising; + bool temp_jump; }; struct dummy_cooling_device_s @@ -109,9 +110,9 @@ static int dummy_cpufreq_resume (FAR struct cpufreq_policy *driver); static const struct thermal_zone_trip_s g_dummy_trips[] = { - {.name = "cpu_crit", .temp = 90, .hyst = 10, .type = THERMAL_CRITICAL}, - {.name = "cpu_alert1", .temp = 70, .hyst = 10, .type = THERMAL_HOT}, - {.name = "cpu_alert0", .temp = 60, .hyst = 10, .type = THERMAL_NORMAL}, + {.name = "cpu_crit", .temp = 90, .hyst = 5, .type = THERMAL_CRITICAL}, + {.name = "cpu_alert1", .temp = 70, .hyst = 5, .type = THERMAL_HOT}, + {.name = "cpu_alert0", .temp = 60, .hyst = 5, .type = THERMAL_NORMAL}, }; static const struct thermal_zone_map_s g_dummy_maps[] = @@ -161,6 +162,7 @@ static struct dummy_zone_device_s g_dummy_zone = { .temperature = 45, .raising = true, + .temp_jump = true, }; /* Cooling Device - fan0 */ @@ -264,7 +266,8 @@ static int dummy_zdev_get_temp(FAR struct thermal_zone_device_s *zdev, s->temperature--; } - *temp = s->temperature; + *temp = s->temperature + (s->temp_jump ? 2 : -2); + s->temp_jump = !s->temp_jump; return OK; }