mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-21 01:02:48 +08:00
tici: speedup power save setting (#29100)
* speedup * update type --------- Co-authored-by: Comma Device <device@comma.ai> old-commit-hash: d92c9aef23fc789d50bfd03ae09a3abbf23a8429
This commit is contained in:
+15
-7
@@ -1,4 +1,4 @@
|
||||
import glob
|
||||
from functools import cache
|
||||
from typing import Optional, List
|
||||
|
||||
def gpio_init(pin: int, output: bool) -> None:
|
||||
@@ -25,12 +25,20 @@ def gpio_read(pin: int) -> Optional[bool]:
|
||||
|
||||
return val
|
||||
|
||||
def get_irq_for_action(action: str) -> List[int]:
|
||||
ret = []
|
||||
for fn in glob.glob('/sys/kernel/irq/*/actions'):
|
||||
with open(fn) as f:
|
||||
@cache
|
||||
def get_irq_action(irq: int) -> List[str]:
|
||||
try:
|
||||
with open(f"/sys/kernel/irq/{irq}/actions") as f:
|
||||
actions = f.read().strip().split(',')
|
||||
if action in actions:
|
||||
irq = int(fn.split('/')[-2])
|
||||
return actions
|
||||
except FileNotFoundError:
|
||||
return []
|
||||
|
||||
def get_irqs_for_action(action: str) -> List[str]:
|
||||
ret = []
|
||||
with open("/proc/interrupts") as f:
|
||||
for l in f.readlines():
|
||||
irq = l.split(':')[0].strip()
|
||||
if irq.isdigit() and action in get_irq_action(irq):
|
||||
ret.append(irq)
|
||||
return ret
|
||||
|
||||
Reference in New Issue
Block a user