nx: power: Rework again

Looks like cpl doesn't parse more than 3 properly.

Change-Id: Ic67132c4df86f986e2777a2d9580f6b9f96b89a2
This commit is contained in:
tmakin authored and Nolen Johnson committed 2024-05-28 19:55:24 +00:00
1 parent f67524ec06
commit cb90242a59
2 files changed
+63 -34

No files matched your search

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 The LineageOS Project
* Copyright (C) 2024 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,21 +29,15 @@ import android.util.Log;
import android.view.IWindowManager;
import android.view.WindowManagerPolicyConstants;
import com.nvidia.NvAppProfiles;
import com.nvidia.NvCPLSvc.INvCPLRemoteService;
import com.nvidia.framework.NvConstants;
import vendor.nvidia.hardware.graphics.display.V1_0.INvDisplay;
public class DockService extends Service {
private static final String TAG = DockService.class.getSimpleName();
private static final int MODE_UNDOCKED = 0;
private static final int MODE_DOCKED = 1;
private static final int MODE_ODIN_VALI_UNDOCKED_PERF = 2;
private static final int MODE_MODIN_FRIG_UNDOCKED_PERF = 3;
private static final int MODE_ODIN_DOCKED_PERF = 4;
private static final int MODE_MODIN_FRIG_DOCKED_PERF = 5;
final private Receiver mReceiver = new Receiver();
private INvDisplay mDisplayService;
private IWindowManager mWindowManager;
@@ -92,26 +86,16 @@ public class DockService extends Service {
}
try {
if (perfMode) {
if (connected) {
DisplayUtils.setFanProfile("Cool");
DisplayUtils.setPowerMode(mNvCPLSvc, sku.equals("odin")
? MODE_ODIN_DOCKED_PERF
: MODE_MODIN_FRIG_DOCKED_PERF);
} else {
DisplayUtils.setFanProfile("Console");
DisplayUtils.setPowerMode(mNvCPLSvc, (sku.equals("odin") || sku.equals("vali"))
? MODE_ODIN_VALI_UNDOCKED_PERF
: MODE_MODIN_FRIG_UNDOCKED_PERF);
}
if (connected) {
DisplayUtils.setFanProfile(perfMode ? "Cool" : "Console");
DisplayUtils.setPowerMode(mNvCPLSvc, perfMode ?
NvConstants.NV_POWER_MODE_MAX_PERF :
NvConstants.NV_POWER_MODE_OPTIMIZED);
} else {
if (connected) {
DisplayUtils.setFanProfile("Console");
DisplayUtils.setPowerMode(mNvCPLSvc, MODE_DOCKED);
} else {
DisplayUtils.setFanProfile("Handheld");
DisplayUtils.setPowerMode(mNvCPLSvc, MODE_UNDOCKED);
}
DisplayUtils.setFanProfile(perfMode ? "Cool" : "Handheld");
DisplayUtils.setPowerMode(mNvCPLSvc, perfMode ?
NvConstants.NV_POWER_MODE_OPTIMIZED :
NvConstants.NV_POWER_MODE_BATTERY_SAVER);
}
} catch (RemoteException e) {
Log.e(TAG, "Failed to set power profiles");
+51 -6
View File
@@ -1,7 +1,52 @@
# Key modin/frig Docked Perf odin Docked Perf modin/frig Undocked Perf odin/vali Undocked Perf Docked Norm Undocked Norm
NV_DEFAULT_MODE 5
# FORMAT:
# panelresolution=[xres]X[yres], such as panelresolution=1280X720
# powernode1 maxperf optimized maxbatterylife
# powernode2 maxperf optimized maxbatterylife
# ......
# powernoden maxperf optimized maxbatterylife
# panelresolution=[xres]X[yres], such as panelresolution=1920X1080
# powernode1 maxperf optimized maxbatterylife
# powernode2 maxperf optimized maxbatterylife
# ......
# powernoden maxperf optimized maxbatterylife
# ......
# ......
# panelresolution=[xres]X[yres], such as panelresolution=1920X1200
# powernode1 maxperf optimized maxbatterylife
# powernode2 maxperf optimized maxbatterylife
# ......
# powernoden maxperf optimized maxbatterylife
#
# NOTES:
# The panelresolution is the lcd panel resolution.
# No space should exist in panelresolution=[xres]X[yres].
# panelresolution=720X1280 equals with panelresolution=1280X720.
# For panelresolution=-1X-1, it should be the last set of power settings in this file.
# When your panel resolution is found in this file,
# it will use the set of power settings followed by your panel resolution.
# When your panel resolution is not found in this file, it will use the default power settings.
# The power settings followed by panelresolution=-1X-1 is the default power settings.
# powernode is the sysfs or variable we need to write and it is followed by three ints.
# maxperf, optimized, maxbatterylife are the three ints for different power modes.
#
# Default power mode: can be set to 0, 1, or 2
NV_DEFAULT_MODE 1
panelresolution=-1X-1
NV_MAX_FREQ 1963500 1785000 1785000 1785000 1785000 1428000
NV_MIN_FREQ 0 0 0 0 0 0
NV_MAX_GPU_FREQ 1267200 921600 1075000 844000 768000 460800
NV_MIN_GPU_FREQ 0 0 0 0 0 0
NV_FPSLIMIT 0 0 0
NV_MAX_CORES 0 0 0
NV_MIN_CORES 2 2 2
NV_MAX_FREQ 0 0 1428000
NV_MIN_FREQ 900000 0 0
NV_MAX_GPU_FREQ 0 0 768000
NV_MIN_GPU_FREQ 0 0 0
NV_HYPERVOLT_ALPHA 50 0 0
NV_APM_CPU_BOOST 5 0 0
NV_APM_GPU_BOOST 5 0 0
NV_APM_FRT_BOOST 5 0 0
NV_APM_PRETHROTTLE 0 1 1
NV_APM_FRT_MIN 20 15 15
NV_APM_LOADAPPFRT 0 1 1
NV_PBC_SYSPOWER_CAP 15000 11000 8500
NV_PBC_BATCURRENT_CAP 5000 5000 4100
NV_FAN_STATE_CAP 7 3 2
NV_FAN_STATE_MAP 80/110/150/200/255 80/110/150/200/255 80/110/150/200/255