View Single Post
Old 09-25-2019, 05:04 PM   #100
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,915
Karma: 146918083
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by geek1011 View Post
There is a way to do that. After seeing all the roundabout stuff in this thread, I decided to have a quick look and see if there is any way to increase the maximum timeout. Here are a few notes I made while looking into this:

Code:
N3PowerWorkflowManager::setupAlarm is called (this seems to be what allows it to power off during a sleep, etc):
    Gets PowerSettings::getAutoOffMinutes and PowerSettings::getAutoSleepMinutes
    Runs ::configureWakup for ::powerOff and ::requestSleep depending on values of autoOffMinutes autoSleepMinutes
    ::configureWakeup:
        Multiplies provided minutes by 60000 (min -> ms)
        Schedules a wakeup, when triggered, calls the provided function

N3PowerWorkflowManager::pollBattery (does the check, called through Qt's object system):
    Gets PowerSettings::getAutoOffMinutes and PowerSettings::getAutoSleepMinutes
    Multiplies each by 60000 (min -> ms)
    Compares with PowerManager::timeLastUsed
    Performs an action if needed

It seems that these two locations are the only ones which matter.

From a quick glance, it appears that it should be fine to patch these multipliers as long as they fit in a 64-bit signed
integer. But, note that the multiplier is a 32-bit signed integer. But, to be safe, don't make the largest possible timeout
longer than 596 hours (~35800 minutes), as I haven't checked all the places where it is used.
And here is a quick patch I put together for 4.15.12920 (untested, but it should work):

Code:
Larger Sleep/Power-off timeouts:
  - Enabled: no
  # Multiplier in N3PowerWorkflowManager::configureWakeup
  - ReplaceBytes: {Offset: 0xA1194C, FindH: 04 FB 05 F5, ReplaceH: 4F EA C5 45} # mul r5(dest), r4(multiplier), r5(mins)  -> lsl r5, r5, #19
  # Multiplier in N3PowerWorkflowManager::pollBattery
  - ReplaceBytes: {Offset: 0xA13692, FindH: 08 FB 00 F8, ReplaceH: 4F EA C0 48} # mul r8(dest), r8(multiplier), r0(mins)  -> lsl r8, r0, #19
  - ReplaceBytes: {Offset: 0xA136C2, FindH: 02 FB 00 F2, ReplaceH: 4F EA C0 42} # mul r2(dest), r2(multiplier), r0(mins)  -> lsl r2, r0, #19
  # Menu text
  - BaseAddress: 0xD48754
  - ReplaceString: {Offset: 0, Find: "5 mins\0", Replace: "8m"}
  - ReplaceString: {Offset: 8, Find: "10 mins", Replace: "34m"}
  - ReplaceString: {Offset: 16, Find: "15 mins", Replace: "1h1m"}
  - ReplaceString: {Offset: 24, Find: "30 mins", Replace: "4h4m"}
  - ReplaceString: {Offset: 32, Find: "45 mins", Replace: "12h5m"}
  - ReplaceString: {Offset: 38, Find: "60 mins", Replace: "24h1m"}
  # Values
  - BaseAddress: 0
  - ReplaceInt: {Offset: 0xACF230, Find: 5,  Replace: 1}
  - ReplaceInt: {Offset: 0xACF3F6, Find: 5,  Replace: 1}
  - ReplaceInt: {Offset: 0xACF288, Find: 10, Replace: 4}
  - ReplaceInt: {Offset: 0xACF432, Find: 10, Replace: 4}
  - ReplaceInt: {Offset: 0xACF2C4, Find: 15, Replace: 7}
  - ReplaceInt: {Offset: 0xACF46C, Find: 15, Replace: 7}
  - ReplaceInt: {Offset: 0xACF300, Find: 30, Replace: 28}
  - ReplaceInt: {Offset: 0xACF4A6, Find: 30, Replace: 28}
  - ReplaceInt: {Offset: 0xACF33C, Find: 45, Replace: 83}
  - ReplaceInt: {Offset: 0xACF4E0, Find: 45, Replace: 83}
  - ReplaceInt: {Offset: 0xACF378, Find: 60, Replace: 165}
  - ReplaceInt: {Offset: 0xACF518, Find: 60, Replace: 165}
And for custom values:
Spoiler:
Code:
python3>>> lsls=19; hrfrac=lambda ms: ms/1000/60/60; print("\n".join([f"{n} {int(hrfrac(n<<lsls))}h{int((hrfrac(n<<lsls)%1)*60)}m" for n in range(1, 255)]))
1 0h8m
2 0h17m
3 0h26m
4 0h34m
5 0h43m
6 0h52m
7 1h1m
8 1h9m
9 1h18m
10 1h27m
11 1h36m
12 1h44m
13 1h53m
14 2h2m
15 2h11m
16 2h19m
17 2h28m
18 2h37m
19 2h46m
20 2h54m
21 3h3m
22 3h12m
23 3h20m
24 3h29m
25 3h38m
26 3h47m
27 3h55m
28 4h4m
29 4h13m
30 4h22m
31 4h30m
32 4h39m
33 4h48m
34 4h57m
35 5h5m
36 5h14m
37 5h23m
38 5h32m
39 5h40m
40 5h49m
41 5h58m
42 6h7m
43 6h15m
44 6h24m
45 6h33m
46 6h41m
47 6h50m
48 6h59m
49 7h8m
50 7h16m
51 7h25m
52 7h34m
53 7h43m
54 7h51m
55 8h0m
56 8h9m
57 8h18m
58 8h26m
59 8h35m
60 8h44m
61 8h53m
62 9h1m
63 9h10m
64 9h19m
65 9h27m
66 9h36m
67 9h45m
68 9h54m
69 10h2m
70 10h11m
71 10h20m
72 10h29m
73 10h37m
74 10h46m
75 10h55m
76 11h4m
77 11h12m
78 11h21m
79 11h30m
80 11h39m
81 11h47m
82 11h56m
83 12h5m
84 12h14m
85 12h22m
86 12h31m
87 12h40m
88 12h48m
89 12h57m
90 13h6m
91 13h15m
92 13h23m
93 13h32m
94 13h41m
95 13h50m
96 13h58m
97 14h7m
98 14h16m
99 14h25m
100 14h33m
101 14h42m
102 14h51m
103 15h0m
104 15h8m
105 15h17m
106 15h26m
107 15h34m
108 15h43m
109 15h52m
110 16h1m
111 16h9m
112 16h18m
113 16h27m
114 16h36m
115 16h44m
116 16h53m
117 17h2m
118 17h11m
119 17h19m
120 17h28m
121 17h37m
122 17h46m
123 17h54m
124 18h3m
125 18h12m
126 18h21m
127 18h29m
128 18h38m
129 18h47m
130 18h55m
131 19h4m
132 19h13m
133 19h22m
134 19h30m
135 19h39m
136 19h48m
137 19h57m
138 20h5m
139 20h14m
140 20h23m
141 20h32m
142 20h40m
143 20h49m
144 20h58m
145 21h7m
146 21h15m
147 21h24m
148 21h33m
149 21h41m
150 21h50m
151 21h59m
152 22h8m
153 22h16m
154 22h25m
155 22h34m
156 22h43m
157 22h51m
158 23h0m
159 23h9m
160 23h18m
161 23h26m
162 23h35m
163 23h44m
164 23h53m
165 24h1m
166 24h10m
167 24h19m
168 24h28m
169 24h36m
170 24h45m
171 24h54m
172 25h2m
173 25h11m
174 25h20m
175 25h29m
176 25h37m
177 25h46m
178 25h55m
179 26h4m
180 26h12m
181 26h21m
182 26h30m
183 26h39m
184 26h47m
185 26h56m
186 27h5m
187 27h14m
188 27h22m
189 27h31m
190 27h40m
191 27h48m
192 27h57m
193 28h6m
194 28h15m
195 28h23m
196 28h32m
197 28h41m
198 28h50m
199 28h58m
200 29h7m
201 29h16m
202 29h25m
203 29h33m
204 29h42m
205 29h51m
206 30h0m
207 30h8m
208 30h17m
209 30h26m
210 30h35m
211 30h43m
212 30h52m
213 31h1m
214 31h9m
215 31h18m
216 31h27m
217 31h36m
218 31h44m
219 31h53m
220 32h2m
221 32h11m
222 32h19m
223 32h28m
224 32h37m
225 32h46m
226 32h54m
227 33h3m
228 33h12m
229 33h21m
230 33h29m
231 33h38m
232 33h47m
233 33h55m
234 34h4m
235 34h13m
236 34h22m
237 34h30m
238 34h39m
239 34h48m
240 34h57m
241 35h5m
242 35h14m
243 35h23m
244 35h32m
245 35h40m
246 35h49m
247 35h58m
248 36h7m
249 36h15m
250 36h24m
251 36h33m
252 36h42m
253 36h50m
254 36h59m
Can this patch be converted to work with current 4.17 firmware if it doesn't work as is?
JSWolf is offline   Reply With Quote