Skip to content

Commit

Permalink
Revert "Switch: Fix Clock speed menus on mariko. (#1822)"
Browse files Browse the repository at this point in the history
This reverts commit 1ad4374.
ToKe79 committed Jan 16, 2023
1 parent 9574e4d commit e7da101
Showing 5 changed files with 49 additions and 391 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
PKG_NAME="switch-cpu-profile"
PKG_VERSION="2.0"
PKG_VERSION="1.1"
PKG_DEPENDS_TARGET="Python3"
PKG_TOOLCHAIN="manual"

makeinstall_target() {
mkdir -p ${INSTALL}/usr/bin
cp -v ${PKG_DIR}/scripts/cpu-profile ${INSTALL}/usr/bin
#cp -v ${PKG_DIR}/scripts/cpu-profile ${INSTALL}/usr/bin
touch ${INSTALL}/usr/bin/cpu-profile
chmod +x ${INSTALL}/usr/bin/cpu-profile
}

Original file line number Diff line number Diff line change
@@ -15,9 +15,9 @@ For now the profile is not retained and is set to default speed when rebooting.
PROFILE_FILE = "/sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq"
OVERCLOCK_FILE = "/sys/kernel/tegra_cpufreq/overclock"
SAVED_PROFILE_FILE = "/storage/.config/.cpu_profile"
SERIAL_FILE = "/sys/firmware/devicetree/base/serial-number"

# Profiles list, in KHz - max 2091000
PROFILES_ERISTA = {
PROFILES = {
"Max Overdrive +3": "2091000",
"Max Overdrive +2": "1989000",
"Max Overdrive +1": "1887000",
@@ -30,41 +30,8 @@ PROFILES_ERISTA = {
"Powersaving Mode 3": "714000",
}

PROFILES_MARIKO = {
"Max Overdrive +3": "2295000",
"Max Overdrive +2": "2193000",
"Max Overdrive +1": "2091000",
"Maximum Performance": "1963500",
"Boost Performance 4": "1887000",
"Boost Performance 3": "1785000",
"Boost Performance 2": "1581000",
"Boost Performance 1": "1224000",
"Stock Performance": "1020000",
"Powersaving Mode 1": "918000",
"Powersaving Mode 2": "816000",
"Powersaving Mode 3": "714000"
}

# Default profile
DEFAULT_PROFILE = "Stock Performance"
def get_board():
try:
f=open(SERIAL_FILE, "r")
except IOError:
return -1
board_prefix=str(f.read().strip())
board_prefix=board_prefix[:3]

if board_prefix == "NXM":
return 1
elif board_prefix == "NXV":
return 1
elif board_prefix == "NXF":
return 1
elif board_prefix == "NXO":
return 0
else:
return -1

def get_saved_profile():
try:
@@ -76,42 +43,31 @@ def get_saved_profile():
return DEFAULT_PROFILE
else:
return NEW_DEFAULT_PROFILE

def save_profile(profile):
with open(SAVED_PROFILE_FILE, "w") as f:
f.write(profile)
f.flush()

def get_profile():
with open(PROFILE_FILE, "r") as f:
pstate = str(f.read().strip())

profile_code = pstate
board=get_board()
if board == 1:
for profile in PROFILES_MARIKO:
if profile_code == PROFILES_MARIKO[profile]:
return profile
elif board == 0:
for profile in PROFILES_ERISTA:
if profile_code == PROFILES_ERISTA[profile]:
return profile

for profile in PROFILES:
if profile_code == PROFILES[profile]:
return profile

raise Exception("Unknown profile code %s" % profile_code)


def apply_profile(profile):
board=get_board()
if board == 1:
if profile not in PROFILES_MARIKO:
raise Exception("Unknown profile %s" % profile)
elif board == 0:
if profile not in PROFILES_ERISTA:
raise Exception("Unknown profile %s" % profile)
if profile not in PROFILES:
raise Exception("Unknown profile %s" % profile)

with open(PROFILE_FILE, "w") as f:
if board == 1:
f.write(PROFILES_MARIKO[profile])
elif board == 0:
f.write(PROFILES_ERISTA[profile])
f.write(PROFILES[profile])
f.flush()
print(("Applied profile %s" % profile))

@@ -128,61 +84,45 @@ def print_usage():
Usage :
cpu-profile init
Sets the default profile - should be called on boot
cpu-profile list
Lists all the available profiles and their corresponding frequency
cpu-profile set <profile>
Sets the current profile to <profile>
cpu-profile get
Gets the current profile name
''')


def print_profiles():
print("Format : <name> - <freq in KHz> [* : enabled] [d : reboot default]")
board=get_board()

max_profile_name_length = max([len(x) for x in list(PROFILES.keys())])

current_profile = get_profile()

for profile in reversed(list(PROFILES.keys())):
profile_name = profile
profile_freq = PROFILES[profile]
is_default = (profile_name == DEFAULT_PROFILE)
is_current = (current_profile == profile_name)
padding = " " * (max_profile_name_length - len(profile_name))
print("%s%s - %s %s %s" % (profile_name, padding, profile_freq, "*" if is_current else " ", "d" if is_default else ""))

if board == 1:
max_profile_name_length = max([len(x) for x in list(PROFILES_MARIKO.keys())])
for profile in reversed(list(PROFILES_MARIKO.keys())):
profile_name = profile
profile_freq = PROFILES_MARIKO[profile]
is_default = (profile_name == DEFAULT_PROFILE)
is_current = (current_profile == profile_name)
padding = " " * (max_profile_name_length - len(profile_name))
print("%s%s - %s %s %s" % (profile_name, padding, profile_freq, "*" if is_current else " ", "d" if is_default else ""))
elif board == 0:
max_profile_name_length = max([len(x) for x in list(PROFILES_ERISTA.keys())])
for profile in reversed(list(PROFILES_ERISTA.keys())):
profile_name = profile
profile_freq = PROFILES_ERISTA[profile]
is_default = (profile_name == DEFAULT_PROFILE)
is_current = (current_profile == profile_name)
padding = " " * (max_profile_name_length - len(profile_name))
print("%s%s - %s %s %s" % (profile_name, padding, profile_freq, "*" if is_current else " ", "d" if is_default else ""))

# Main
if __name__ == "__main__":
argc = len(sys.argv)
if argc == 2:
if sys.argv[1] == "init":
unlock_full_power()
apply_profile(get_saved_profile())
unlock_full_power()
elif sys.argv[1] == "get":
print(get_profile())
elif sys.argv[1] == "list":
print_profiles()
elif sys.argv[1] == "board-info":
x=get_board()
if x == 1:
print("M")
elif x == 0:
print("E")
else:
print("Not A Switch")
else:
print_usage()
elif argc == 3:
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
PKG_NAME="switch-gpu-profile"
PKG_VERSION="2.0"
PKG_VERSION="1.1"
PKG_DEPENDS_TARGET="Python3"
PKG_TOOLCHAIN="manual"

makeinstall_target() {
mkdir -p ${INSTALL}/usr/bin
cp -v ${PKG_DIR}/scripts/gpu-profile ${INSTALL}/usr/bin
chmod +x ${INSTALL}/usr/bin/gpu-profile
#cp -v ${PKG_DIR}/scripts/gpu-profile ${INSTALL}/usr/bin
touch ${INSTALL}/usr/bin/cpu-profile
chmod +x ${INSTALL}/usr/bin/cpu-profile

}

Original file line number Diff line number Diff line change
@@ -17,10 +17,9 @@ L4T variant.
PROFILE_FILE_MAX = "/sys/devices/57000000.gpu/devfreq/57000000.gpu/max_freq"
PROFILE_FILE_MIN = "/sys/devices/57000000.gpu/devfreq/57000000.gpu/min_freq"
SAVED_PROFILE_FILE = "/storage/.config/.gpu_profile"
SERIAL_FILE = "/sys/firmware/devicetree/base/serial-number"

# Profiles list
PROFILES_ERISTA = {
PROFILES = {
"Docked Stock +2": "921600000", # 921 Mhz
"Docked Stock +1": "844800000", # 844 Mhz
"Docked Stock Mode": "768000000", # 768 Mhz
@@ -35,45 +34,9 @@ PROFILES_ERISTA = {
"Powersaving Mode": "76800000", # 76 Mhz
}

PROFILES_MARIKO = {
"Docked Stock +3": "998400000", #998 Mhz
"Docked Stock +2": "921600000", # 921 Mhz
"Docked Stock +1": "844800000", # 844 Mhz
"Docked Stock Mode": "768000000", # 768 Mhz
"Handheld Boost +3": "691200000", # 691 Mhz
"Handheld Boost +2": "614400000", # 614 Mhz
"Handheld Boost +1": "537600000", # 537 Mhz
"Handheld Boost Mode": "460800000", # 460 Mhz
"Handheld Stock +1": "384000000", # 384 Mhz
"Handheld Stock Mode": "307200000", # 307 Mhz
"Powersaving +2": "230400000", # 230 Mhz
"Powersaving +1": "153600000", # 153 Mhz
"Powersaving Mode": "76800000", # 76 Mhz
}


# Default profile
DEFAULT_PROFILE = "Handheld Stock Mode"

def get_board():
try:
f=open(SERIAL_FILE, "r")
except IOError:
return -1
board_prefix=str(f.read().strip())
board_prefix=board_prefix[:3]

if board_prefix == "NXM":
return 1
elif board_prefix == "NXV":
return 1
elif board_prefix == "NXF":
return 1
elif board_prefix == "NXO":
return 0
else:
return -1

def get_saved_profile():
try:
f=open(SAVED_PROFILE_FILE, "r")
@@ -84,41 +47,31 @@ def get_saved_profile():
return DEFAULT_PROFILE
else:
return NEW_DEFAULT_PROFILE

def save_profile(profile):
with open(SAVED_PROFILE_FILE, "w") as f:
f.write(profile)
f.flush()

def get_profile():
with open(PROFILE_FILE_MAX, "r") as f:
pstate = str(f.read().strip())
board=get_board()
if board == 1:
for profile in PROFILES_MARIKO:
if pstate == PROFILES_MARIKO[profile]:
return profile
elif board == 0:
for profile in PROFILES_ERISTA:
if pstate == PROFILES_ERISTA[profile]:
return profile

for profile in PROFILES:
if pstate == PROFILES[profile]:
return profile

raise Exception("Unknown profile %s" % pstate)



def apply_profile(profile):
board=get_board()
if profile not in PROFILES:
raise Exception("Unknown profile %s" % profile)

files = []
if board == 1:
if profile not in PROFILES_MARIKO:
raise Exception("Unknown profile %s" % profile)
cur_profile = int(PROFILES_MARIKO[get_profile()])
new_profile = int(PROFILES_MARIKO[profile])
elif board == 0:
if profile not in PROFILES_ERISTA:
raise Exception("Unknown profile %s" % profile)
cur_profile = int(PROFILES_ERISTA[get_profile()])
new_profile = int(PROFILES_ERISTA[profile])
cur_profile = int(PROFILES[get_profile()])
new_profile = int(PROFILES[profile])

if new_profile < cur_profile:
files = [
@@ -133,10 +86,7 @@ def apply_profile(profile):

for pfile in files:
with open(pfile, "w") as f:
if board == 1:
f.write(PROFILES_MARIKO[profile])
elif board == 0:
f.write(PROFILES_ERISTA[profile])
f.write(PROFILES[profile])
f.flush()
print(("Applied profile %s" % profile))

@@ -164,14 +114,6 @@ if __name__ == "__main__":
apply_profile(get_saved_profile())
elif sys.argv[1] == "get":
print(get_profile())
elif sys.argv[1] == "board-info":
x=get_board()
if x == 1:
print("M")
elif x == 0:
print("E")
else:
print("Not A Switch")
else:
print_usage()
elif argc == 3:

0 comments on commit e7da101

Please sign in to comment.