shithub: riscv

Download patch

ref: 526f63106b232665a8288ebf2d79c8ad659a2e37
parent: d602374635334d3bc02e108c1cf14604e6e7854a
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Sep 12 07:00:18 EDT 2023

reform/pm: fix lcd pwm cycle setting precision

--- a/sys/src/cmd/reform/pm.c
+++ b/sys/src/cmd/reform/pm.c
@@ -8,8 +8,6 @@
 
 enum
 {
-	Mhz = 1000*1000,
-	Pwmsrcclk = 25*Mhz,
 	Kbdlightmax = 8,
 
 	Scharge = 0,
@@ -254,8 +252,7 @@
 	}
 
 	if(k == Lcd){
-		v = Pwmsrcclk / rd(pwm2, PWMSAR);
-		wr(pwm2, PWMPR, (Pwmsrcclk/(v*p[0]/100))-2);
+		wr(pwm2, PWMPR, (p[0] ? 100*rd(pwm2, PWMSAR)/p[0] : 0)-1);
 		return 0;
 	}else if(k == Kbd && openhidctl(&hidkb, udidkb) == 0){
 		v = Kbdlightmax*p[0]/100;
@@ -285,8 +282,9 @@
 
 	SET(m);
 	if(k == Lcd){
-		m = Pwmsrcclk / rd(pwm2, PWMSAR);
-		v[0] = Pwmsrcclk / (rd(pwm2, PWMPR)+2);
+		m = rd(pwm2, PWMPR)+1;
+		v[0] = m ? rd(pwm2, PWMSAR)*100/m : 0;
+		return;
 	}else if(k == Kbd){
 		m = 100;
 		v[0] = kbdlight;