hocclk: format code
use clang format file provided for optimal formatting
This commit is contained in:
@@ -13,6 +13,7 @@ UseTab: Never
|
|||||||
IndentAccessModifiers: false
|
IndentAccessModifiers: false
|
||||||
AccessModifierOffset: 0
|
AccessModifierOffset: 0
|
||||||
NamespaceIndentation: All
|
NamespaceIndentation: All
|
||||||
|
IndentPPDirectives: BeforeHash
|
||||||
|
|
||||||
BreakBeforeBraces: Attach
|
BreakBeforeBraces: Attach
|
||||||
BraceWrapping:
|
BraceWrapping:
|
||||||
|
|||||||
@@ -24,17 +24,16 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#include "cpp_util.hpp"
|
#include "cpp_util.hpp"
|
||||||
|
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
|
|
||||||
#include <hocclk/client/ipc.h>
|
#include <hocclk/client/ipc.h>
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|||||||
@@ -24,17 +24,18 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define TESLA_INIT_IMPL
|
#define TESLA_INIT_IMPL
|
||||||
#include <tesla.hpp>
|
#include <tesla.hpp>
|
||||||
|
|
||||||
#include "ui/gui/fatal_gui.h"
|
#include "ui/gui/fatal_gui.h"
|
||||||
#include "ui/gui/main_gui.h"
|
#include "ui/gui/main_gui.h"
|
||||||
|
|
||||||
class AppOverlay : public tsl::Overlay
|
class AppOverlay : public tsl::Overlay {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
AppOverlay() {}
|
AppOverlay() {
|
||||||
~AppOverlay() {}
|
}
|
||||||
|
~AppOverlay() {
|
||||||
|
}
|
||||||
|
|
||||||
// virtual void initServices() override {
|
// virtual void initServices() override {
|
||||||
// rgltrInitialize();
|
// rgltrInitialize();
|
||||||
@@ -44,52 +45,41 @@ class AppOverlay : public tsl::Overlay
|
|||||||
hocclkIpcExit();
|
hocclkIpcExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::unique_ptr<tsl::Gui> loadInitialGui() override
|
virtual std::unique_ptr<tsl::Gui> loadInitialGui() override {
|
||||||
{
|
|
||||||
uint32_t apiVersion;
|
uint32_t apiVersion;
|
||||||
smInitialize();
|
smInitialize();
|
||||||
|
|
||||||
tsl::hlp::ScopeGuard smGuard([] { smExit(); });
|
tsl::hlp::ScopeGuard smGuard([] { smExit(); });
|
||||||
|
|
||||||
if(!hocclkIpcRunning())
|
if (!hocclkIpcRunning()) {
|
||||||
{
|
return initially<FatalGui>("hoc-clk is not running.\n\n"
|
||||||
return initially<FatalGui>(
|
|
||||||
"hoc-clk is not running.\n\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"Please make sure it is correctly\n\n"
|
"Please make sure it is correctly\n\n"
|
||||||
"installed and enabled.",
|
"installed and enabled.",
|
||||||
""
|
"");
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(R_FAILED(hocclkIpcInitialize()) || R_FAILED(hocclkIpcGetAPIVersion(&apiVersion)))
|
if (R_FAILED(hocclkIpcInitialize()) || R_FAILED(hocclkIpcGetAPIVersion(&apiVersion))) {
|
||||||
{
|
return initially<FatalGui>("Could not connect to hoc-clk.\n\n"
|
||||||
return initially<FatalGui>(
|
|
||||||
"Could not connect to hoc-clk.\n\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"Please make sure it is correctly\n\n"
|
"Please make sure it is correctly\n\n"
|
||||||
"installed and enabled.",
|
"installed and enabled.",
|
||||||
""
|
"");
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(HOCCLK_IPC_API_VERSION != apiVersion)
|
if (HOCCLK_IPC_API_VERSION != apiVersion) {
|
||||||
{
|
return initially<FatalGui>("Overlay not compatible with\n\n"
|
||||||
return initially<FatalGui>(
|
|
||||||
"Overlay not compatible with\n\n"
|
|
||||||
"the running hoc-clk version.\n\n"
|
"the running hoc-clk version.\n\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Please make sure everything is\n\n"
|
"Please make sure everything is\n\n"
|
||||||
"installed and up to date.",
|
"installed and up to date.",
|
||||||
""
|
"");
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return initially<MainGui>();
|
return initially<MainGui>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
|
||||||
return tsl::loop<AppOverlay>(argc, argv);
|
return tsl::loop<AppOverlay>(argc, argv);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,20 +24,18 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdint>
|
|
||||||
#include <hocclk/board.h>
|
#include <hocclk/board.h>
|
||||||
|
|
||||||
#define FREQ_DEFAULT_TEXT "Do not override"
|
#define FREQ_DEFAULT_TEXT "Do not override"
|
||||||
|
|
||||||
static inline std::string formatListFreqMHz(std::uint32_t mhz)
|
static inline std::string formatListFreqMHz(std::uint32_t mhz) {
|
||||||
{
|
if (mhz == 0) {
|
||||||
if(mhz == 0)
|
|
||||||
{
|
|
||||||
return FREQ_DEFAULT_TEXT;
|
return FREQ_DEFAULT_TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,17 +43,17 @@ static inline std::string formatListFreqMHz(std::uint32_t mhz)
|
|||||||
return std::string(buf, snprintf(buf, sizeof(buf), "%u MHz", mhz));
|
return std::string(buf, snprintf(buf, sizeof(buf), "%u MHz", mhz));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline std::string formatListFreqHz(uint32_t hz) { return formatListFreqMHz(hz / 1000000); }
|
static inline std::string formatListFreqHz(uint32_t hz) {
|
||||||
|
return formatListFreqMHz(hz / 1000000);
|
||||||
|
}
|
||||||
|
|
||||||
static inline std::string formatListFreqMem(uint32_t mhz, RamDisplayUnit unit)
|
static inline std::string formatListFreqMem(uint32_t mhz, RamDisplayUnit unit) {
|
||||||
{
|
|
||||||
if (mhz == 0)
|
if (mhz == 0)
|
||||||
return FREQ_DEFAULT_TEXT;
|
return FREQ_DEFAULT_TEXT;
|
||||||
|
|
||||||
uint32_t mts = mhz * 2;
|
uint32_t mts = mhz * 2;
|
||||||
char buf[24];
|
char buf[24];
|
||||||
switch(unit)
|
switch (unit) {
|
||||||
{
|
|
||||||
case RamDisplayUnit_MHz:
|
case RamDisplayUnit_MHz:
|
||||||
snprintf(buf, sizeof(buf), "%u MHz", mhz);
|
snprintf(buf, sizeof(buf), "%u MHz", mhz);
|
||||||
break;
|
break;
|
||||||
@@ -70,18 +68,15 @@ static inline std::string formatListFreqMem(uint32_t mhz, RamDisplayUnit unit)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline std::string formatListFreqHzMem(uint32_t hz, RamDisplayUnit unit)
|
static inline std::string formatListFreqHzMem(uint32_t hz, RamDisplayUnit unit) {
|
||||||
{
|
|
||||||
return formatListFreqMem(hz / 1000000, unit);
|
return formatListFreqMem(hz / 1000000, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline std::string formatMemClockKhzLabel(uint32_t khz, RamDisplayUnit unit)
|
static inline std::string formatMemClockKhzLabel(uint32_t khz, RamDisplayUnit unit) {
|
||||||
{
|
|
||||||
uint32_t mhz = khz / 1000;
|
uint32_t mhz = khz / 1000;
|
||||||
uint32_t mts = khz / 500;
|
uint32_t mts = khz / 500;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
switch(unit)
|
switch (unit) {
|
||||||
{
|
|
||||||
case RamDisplayUnit_MHz:
|
case RamDisplayUnit_MHz:
|
||||||
snprintf(buf, sizeof(buf), "%u MHz", mhz);
|
snprintf(buf, sizeof(buf), "%u MHz", mhz);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -28,49 +28,25 @@
|
|||||||
#include "base_menu_gui.h"
|
#include "base_menu_gui.h"
|
||||||
#include "freq_choice_gui.h"
|
#include "freq_choice_gui.h"
|
||||||
#include "value_choice_gui.h"
|
#include "value_choice_gui.h"
|
||||||
class AppProfileGui : public BaseMenuGui
|
class AppProfileGui : public BaseMenuGui {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
std::uint64_t applicationId;
|
std::uint64_t applicationId;
|
||||||
HocClkTitleProfileList *profileList;
|
HocClkTitleProfileList *profileList;
|
||||||
void openFreqChoiceGui(tsl::elm::ListItem *listItem, HocClkProfile profile, HocClkModule module);
|
void openFreqChoiceGui(tsl::elm::ListItem *listItem, HocClkProfile profile, HocClkModule module);
|
||||||
void addModuleListItem(HocClkProfile profile, HocClkModule module);
|
void addModuleListItem(HocClkProfile profile, HocClkModule module);
|
||||||
void addModuleListItemToggle(HocClkProfile profile, HocClkModule module);
|
void addModuleListItemToggle(HocClkProfile profile, HocClkModule module);
|
||||||
void openValueChoiceGui(
|
void openValueChoiceGui(tsl::elm::ListItem *listItem, std::uint32_t currentValue, const ValueRange &range, const std::string &categoryName,
|
||||||
tsl::elm::ListItem* listItem,
|
ValueChoiceListener listener, const ValueThresholds &thresholds = ValueThresholds(), bool enableThresholds = false,
|
||||||
std::uint32_t currentValue,
|
const std::map<std::uint32_t, std::string> &labels = {}, const std::vector<NamedValue> &namedValues = {},
|
||||||
const ValueRange& range,
|
bool showDefaultValue = true);
|
||||||
const std::string& categoryName,
|
std::string formatValueDisplay(std::uint32_t value, const std::vector<NamedValue> &namedValues, const std::string &suffix, std::uint32_t divisor,
|
||||||
ValueChoiceListener listener,
|
int decimalPlaces);
|
||||||
const ValueThresholds& thresholds = ValueThresholds(),
|
void addModuleListItemValue(HocClkProfile profile, HocClkModule module, const std::string &categoryName, std::uint32_t min, std::uint32_t max,
|
||||||
bool enableThresholds = false,
|
std::uint32_t step, const std::string &suffix, std::uint32_t divisor, int decimalPlaces, ValueThresholds thresholds,
|
||||||
const std::map<std::uint32_t, std::string>& labels = {},
|
std::vector<NamedValue> namedValues = {}, bool showDefaultValue = true);
|
||||||
const std::vector<NamedValue>& namedValues = {},
|
|
||||||
bool showDefaultValue = true
|
|
||||||
);
|
|
||||||
std::string formatValueDisplay(
|
|
||||||
std::uint32_t value,
|
|
||||||
const std::vector<NamedValue>& namedValues,
|
|
||||||
const std::string& suffix,
|
|
||||||
std::uint32_t divisor,
|
|
||||||
int decimalPlaces
|
|
||||||
);
|
|
||||||
void addModuleListItemValue(
|
|
||||||
HocClkProfile profile,
|
|
||||||
HocClkModule module,
|
|
||||||
const std::string& categoryName,
|
|
||||||
std::uint32_t min,
|
|
||||||
std::uint32_t max,
|
|
||||||
std::uint32_t step,
|
|
||||||
const std::string& suffix,
|
|
||||||
std::uint32_t divisor,
|
|
||||||
int decimalPlaces,
|
|
||||||
ValueThresholds thresholds,
|
|
||||||
std::vector<NamedValue> namedValues = {},
|
|
||||||
bool showDefaultValue = true
|
|
||||||
);
|
|
||||||
void addGovernorSection(HocClkProfile profile);
|
void addGovernorSection(HocClkProfile profile);
|
||||||
void addProfileUI(HocClkProfile profile);
|
void addProfileUI(HocClkProfile profile);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AppProfileGui(std::uint64_t applicationId, HocClkTitleProfileList *profileList);
|
AppProfileGui(std::uint64_t applicationId, HocClkTitleProfileList *profileList);
|
||||||
~AppProfileGui();
|
~AppProfileGui();
|
||||||
|
|||||||
@@ -24,16 +24,18 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "base_gui.h"
|
|
||||||
#include "../elements/base_frame.h"
|
#include "../elements/base_frame.h"
|
||||||
|
#include "base_gui.h"
|
||||||
|
|
||||||
|
|
||||||
void BaseFrame::draw(tsl::gfx::Renderer *renderer) {
|
void BaseFrame::draw(tsl::gfx::Renderer *renderer) {
|
||||||
tsl::elm::HeaderOverlayFrame::draw(renderer);
|
tsl::elm::HeaderOverlayFrame::draw(renderer);
|
||||||
this->gui->preDraw(renderer);
|
this->gui->preDraw(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <tesla.hpp>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <tesla.hpp>
|
||||||
|
|
||||||
|
|
||||||
#define LOGO_Y_REAL 65
|
#define LOGO_Y_REAL 65
|
||||||
|
|
||||||
@@ -71,14 +73,8 @@ static constexpr tsl::Color dynamicLogoRGB2 = tsl::Color( 2, 8, 11, 15);
|
|||||||
static constexpr tsl::Color STATIC_TEAL = tsl::Color(7, 15, 15, 15);
|
static constexpr tsl::Color STATIC_TEAL = tsl::Color(7, 15, 15, 15);
|
||||||
const std::string name = " Horizon OC";
|
const std::string name = " Horizon OC";
|
||||||
|
|
||||||
static s32 drawDynamicUltraText(
|
static s32 drawDynamicUltraText(tsl::gfx::Renderer *renderer, s32 startX, s32 y, u32 fontSize, const tsl::Color &staticColor,
|
||||||
tsl::gfx::Renderer* renderer,
|
bool useNotificationMethod = false) {
|
||||||
s32 startX,
|
|
||||||
s32 y,
|
|
||||||
u32 fontSize,
|
|
||||||
const tsl::Color& staticColor,
|
|
||||||
bool useNotificationMethod = false)
|
|
||||||
{
|
|
||||||
static constexpr double cycleDuration = 1.6;
|
static constexpr double cycleDuration = 1.6;
|
||||||
|
|
||||||
s32 currentX = startX;
|
s32 currentX = startX;
|
||||||
@@ -88,10 +84,10 @@ static s32 drawDynamicUltraText(
|
|||||||
|
|
||||||
const double waveScale = 2.0 * M_PI / cycleDuration;
|
const double waveScale = 2.0 * M_PI / cycleDuration;
|
||||||
|
|
||||||
for (size_t i = 0; i < name.size(); i++)
|
for (size_t i = 0; i < name.size(); i++) {
|
||||||
{
|
|
||||||
char letter = name[i];
|
char letter = name[i];
|
||||||
if (letter == '\0') break;
|
if (letter == '\0')
|
||||||
|
break;
|
||||||
|
|
||||||
double phase = waveScale * (timeNow + i * 0.12);
|
double phase = waveScale * (timeNow + i * 0.12);
|
||||||
|
|
||||||
@@ -103,15 +99,9 @@ static s32 drawDynamicUltraText(
|
|||||||
double glow = (cos(phase * 1.5) + 1.0) * 0.5;
|
double glow = (cos(phase * 1.5) + 1.0) * 0.5;
|
||||||
double brightness = 0.75 + glow * 0.25;
|
double brightness = 0.75 + glow * 0.25;
|
||||||
|
|
||||||
u8 r = static_cast<u8>(
|
u8 r = static_cast<u8>(((int)dynamicLogoRGB1.r + ((int)dynamicLogoRGB2.r - (int)dynamicLogoRGB1.r) * blend) * brightness);
|
||||||
((int)dynamicLogoRGB1.r + ((int)dynamicLogoRGB2.r - (int)dynamicLogoRGB1.r) * blend) * brightness
|
u8 g = static_cast<u8>(((int)dynamicLogoRGB1.g + ((int)dynamicLogoRGB2.g - (int)dynamicLogoRGB1.g) * blend) * brightness);
|
||||||
);
|
u8 b = static_cast<u8>(((int)dynamicLogoRGB1.b + ((int)dynamicLogoRGB2.b - (int)dynamicLogoRGB1.b) * blend) * brightness);
|
||||||
u8 g = static_cast<u8>(
|
|
||||||
((int)dynamicLogoRGB1.g + ((int)dynamicLogoRGB2.g - (int)dynamicLogoRGB1.g) * blend) * brightness
|
|
||||||
);
|
|
||||||
u8 b = static_cast<u8>(
|
|
||||||
((int)dynamicLogoRGB1.b + ((int)dynamicLogoRGB2.b - (int)dynamicLogoRGB1.b) * blend) * brightness
|
|
||||||
);
|
|
||||||
|
|
||||||
r = std::clamp<u8>(r, 0, 15);
|
r = std::clamp<u8>(r, 0, 15);
|
||||||
g = std::clamp<u8>(g, 0, 15);
|
g = std::clamp<u8>(g, 0, 15);
|
||||||
@@ -140,14 +130,7 @@ static s32 drawDynamicUltraText(
|
|||||||
void BaseGui::preDraw(tsl::gfx::Renderer *renderer) {
|
void BaseGui::preDraw(tsl::gfx::Renderer *renderer) {
|
||||||
renderer->drawBitmap(LOGO_X, LOGO_Y_REAL - LOGO_LABEL_FONT_SIZE, LOGO_IMG_W, LOGO_IMG_H, hoc_rgba);
|
renderer->drawBitmap(LOGO_X, LOGO_Y_REAL - LOGO_LABEL_FONT_SIZE, LOGO_IMG_W, LOGO_IMG_H, hoc_rgba);
|
||||||
|
|
||||||
drawDynamicUltraText(
|
drawDynamicUltraText(renderer, LOGO_TEXT_X, TEXT_Y, LOGO_LABEL_FONT_SIZE, STATIC_TEAL, false);
|
||||||
renderer,
|
|
||||||
LOGO_TEXT_X,
|
|
||||||
TEXT_Y,
|
|
||||||
LOGO_LABEL_FONT_SIZE,
|
|
||||||
STATIC_TEAL,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
static const std::string versionStr = "Version " + getVersionString() + " \"Gaea\"";
|
static const std::string versionStr = "Version " + getVersionString() + " \"Gaea\"";
|
||||||
static constexpr tsl::Color versionColor(9, 9, 9, 15);
|
static constexpr tsl::Color versionColor(9, 9, 9, 15);
|
||||||
@@ -166,14 +149,12 @@ void BaseGui::preDraw(tsl::gfx::Renderer* renderer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tsl::elm::Element* BaseGui::createUI()
|
tsl::elm::Element *BaseGui::createUI() {
|
||||||
{
|
|
||||||
BaseFrame *rootFrame = new BaseFrame(this, this->headerHeight());
|
BaseFrame *rootFrame = new BaseFrame(this, this->headerHeight());
|
||||||
rootFrame->setContent(this->baseUI());
|
rootFrame->setContent(this->baseUI());
|
||||||
return rootFrame;
|
return rootFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseGui::update()
|
void BaseGui::update() {
|
||||||
{
|
|
||||||
this->refresh();
|
this->refresh();
|
||||||
}
|
}
|
||||||
@@ -24,32 +24,36 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <tesla.hpp>
|
|
||||||
#include "../elements/base_frame.h"
|
|
||||||
#include <fstream>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <tesla.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "../style.h"
|
|
||||||
#include "../../ipc.h"
|
#include "../../ipc.h"
|
||||||
|
#include "../elements/base_frame.h"
|
||||||
|
#include "../style.h"
|
||||||
|
|
||||||
class BaseGui : public tsl::Gui
|
|
||||||
{
|
class BaseGui : public tsl::Gui {
|
||||||
public:
|
public:
|
||||||
BaseGui() {}
|
BaseGui() {
|
||||||
~BaseGui() {}
|
}
|
||||||
|
~BaseGui() {
|
||||||
|
}
|
||||||
virtual void preDraw(tsl::gfx::Renderer *renderer);
|
virtual void preDraw(tsl::gfx::Renderer *renderer);
|
||||||
void update() override;
|
void update() override;
|
||||||
tsl::elm::Element *createUI() override;
|
tsl::elm::Element *createUI() override;
|
||||||
virtual tsl::elm::Element *baseUI() = 0;
|
virtual tsl::elm::Element *baseUI() = 0;
|
||||||
virtual void refresh() {}
|
virtual void refresh() {
|
||||||
virtual u16 headerHeight() const { return HOC_HEADER_HEIGHT; }
|
}
|
||||||
|
virtual u16 headerHeight() const {
|
||||||
|
return HOC_HEADER_HEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern std::string getVersionString();
|
extern std::string getVersionString();
|
||||||
|
|||||||
@@ -24,23 +24,24 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "../format.h"
|
||||||
#include "base_menu_gui.h"
|
#include "base_menu_gui.h"
|
||||||
#include "fatal_gui.h"
|
#include "fatal_gui.h"
|
||||||
#include "../format.h"
|
|
||||||
|
|
||||||
#define TOP_Y_OFFSET 15
|
#define TOP_Y_OFFSET 15
|
||||||
|
|
||||||
// Cache hardware model to avoid repeated syscalls
|
// Cache hardware model to avoid repeated syscalls
|
||||||
|
|
||||||
BaseMenuGui::BaseMenuGui() : tempColors{ tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), }
|
BaseMenuGui::BaseMenuGui()
|
||||||
{
|
: tempColors{
|
||||||
|
tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0),
|
||||||
|
} {
|
||||||
tsl::initializeThemeVars();
|
tsl::initializeThemeVars();
|
||||||
this->context = nullptr;
|
this->context = nullptr;
|
||||||
this->lastContextUpdate = 0;
|
this->lastContextUpdate = 0;
|
||||||
this->listElement = nullptr;
|
this->listElement = nullptr;
|
||||||
|
|
||||||
|
|
||||||
// Pre-cache hardware model during initialization
|
// Pre-cache hardware model during initialization
|
||||||
IsAula();
|
IsAula();
|
||||||
IsMariko();
|
IsMariko();
|
||||||
@@ -59,9 +60,9 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
|||||||
BaseGui::preDraw(renderer);
|
BaseGui::preDraw(renderer);
|
||||||
|
|
||||||
// All constants pre-calculated and cached
|
// All constants pre-calculated and cached
|
||||||
const char* labels[] = {
|
const char *labels[] = { "App ID", "Profile", "CPU", "GPU", "MEM", "SoC", "Board",
|
||||||
"App ID", "Profile", "CPU", "GPU", "MEM", "SoC", "Board", "Skin", "Now", "Avg", "BAT", "PMIC", "Fan", IsAula() || this->context->isUsingRetroSuper ? "OLED" : "LCD", "FPS", "RES"
|
"Skin", "Now", "Avg", "BAT", "PMIC", "Fan", IsAula() || this->context->isUsingRetroSuper ? "OLED" : "LCD",
|
||||||
};
|
"FPS", "RES" };
|
||||||
|
|
||||||
static constexpr u32 dataPositions[6] = { 63 - 3 + 3, 200 - 1, 344 - 1 - 3, 200 - 1, 342 - 1, 321 - 1 };
|
static constexpr u32 dataPositions[6] = { 63 - 3 + 3, 200 - 1, 344 - 1 - 3, 200 - 1, 342 - 1, 321 - 1 };
|
||||||
|
|
||||||
@@ -74,7 +75,16 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
|||||||
}
|
}
|
||||||
positionsInitialized = true;
|
positionsInitialized = true;
|
||||||
}
|
}
|
||||||
static u32 positions[10] = {24-1, 310-labelWidths[1], 24-1, 192-labelWidths[3], 332-labelWidths[4], 24-1, 192 - labelWidths[6], 332-labelWidths[7], 192 - labelWidths[8], 332-labelWidths[9]};
|
static u32 positions[10] = { 24 - 1,
|
||||||
|
310 - labelWidths[1],
|
||||||
|
24 - 1,
|
||||||
|
192 - labelWidths[3],
|
||||||
|
332 - labelWidths[4],
|
||||||
|
24 - 1,
|
||||||
|
192 - labelWidths[6],
|
||||||
|
332 - labelWidths[7],
|
||||||
|
192 - labelWidths[8],
|
||||||
|
332 - labelWidths[9] };
|
||||||
|
|
||||||
static u32 maxProfileValueWidth = renderer->getTextDimensions("USB Charger", false, SMALL_TEXT_SIZE).first; // longest word
|
static u32 maxProfileValueWidth = renderer->getTextDimensions("USB Charger", false, SMALL_TEXT_SIZE).first; // longest word
|
||||||
|
|
||||||
@@ -108,7 +118,6 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
|||||||
|
|
||||||
y += 20; // Direct assignment (129 + 20)
|
y += 20; // Direct assignment (129 + 20)
|
||||||
|
|
||||||
|
|
||||||
renderer->drawString(displayStrings[5], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU real
|
renderer->drawString(displayStrings[5], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU real
|
||||||
renderer->drawString(displayStrings[6], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU real
|
renderer->drawString(displayStrings[6], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU real
|
||||||
renderer->drawString(displayStrings[7], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // MEM real
|
renderer->drawString(displayStrings[7], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // MEM real
|
||||||
@@ -125,7 +134,8 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
|||||||
renderer->drawString(displayStrings[8], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU voltage
|
renderer->drawString(displayStrings[8], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU voltage
|
||||||
renderer->drawString(displayStrings[9], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU voltage
|
renderer->drawString(displayStrings[9], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU voltage
|
||||||
|
|
||||||
renderer->drawStringWithColoredSections(displayStrings[10], false, {""}, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor, tsl::separatorColor);
|
renderer->drawStringWithColoredSections(displayStrings[10], false, { "" }, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor,
|
||||||
|
tsl::separatorColor);
|
||||||
|
|
||||||
renderer->drawString(displayStrings[19], false, positions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU Usage
|
renderer->drawString(displayStrings[19], false, positions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU Usage
|
||||||
renderer->drawString(displayStrings[17], false, positions[3], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU Usage
|
renderer->drawString(displayStrings[17], false, positions[3], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU Usage
|
||||||
@@ -181,15 +191,13 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
|||||||
|
|
||||||
renderer->drawString(labels[14], false, positions[4] + 9, y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // FPS label
|
renderer->drawString(labels[14], false, positions[4] + 9, y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // FPS label
|
||||||
renderer->drawString(displayStrings[26], false, dataPositions[2] + 6, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // FPS
|
renderer->drawString(displayStrings[26], false, dataPositions[2] + 6, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // FPS
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
y += 20;
|
y += 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optimized refresh - now does all the string formatting once per second
|
// Optimized refresh - now does all the string formatting once per second
|
||||||
void BaseMenuGui::refresh()
|
void BaseMenuGui::refresh() {
|
||||||
{
|
|
||||||
const u64 ticks = armGetSystemTick();
|
const u64 ticks = armGetSystemTick();
|
||||||
// Use cached comparison - 1 billion nanoseconds
|
// Use cached comparison - 1 billion nanoseconds
|
||||||
if (armTicksToNs(ticks - this->lastContextUpdate) <= 1000000000UL) [[likely]] {
|
if (armTicksToNs(ticks - this->lastContextUpdate) <= 1000000000UL) [[likely]] {
|
||||||
@@ -269,10 +277,12 @@ void BaseMenuGui::refresh()
|
|||||||
|
|
||||||
switch (configList.values[HocClkConfigValue_RAMVoltDisplayMode]) {
|
switch (configList.values[HocClkConfigValue_RAMVoltDisplayMode]) {
|
||||||
case RamDisplayMode_VDD2:
|
case RamDisplayMode_VDD2:
|
||||||
sprintf(displayStrings[10], "%u.%u mV", context->voltages[HocClkVoltage_EMCVDD2] / 1000U, (context->voltages[HocClkVoltage_EMCVDD2] % 1000U) / 100U);
|
sprintf(displayStrings[10], "%u.%u mV", context->voltages[HocClkVoltage_EMCVDD2] / 1000U,
|
||||||
|
(context->voltages[HocClkVoltage_EMCVDD2] % 1000U) / 100U);
|
||||||
break;
|
break;
|
||||||
case RamDisplayMode_VDDQ:
|
case RamDisplayMode_VDDQ:
|
||||||
sprintf(displayStrings[10], "%u.%u mV", context->voltages[HocClkVoltage_EMCVDDQ] / 1000U, (context->voltages[HocClkVoltage_EMCVDDQ] % 1000U) / 100U);
|
sprintf(displayStrings[10], "%u.%u mV", context->voltages[HocClkVoltage_EMCVDDQ] / 1000U,
|
||||||
|
(context->voltages[HocClkVoltage_EMCVDDQ] % 1000U) / 100U);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strcpy(displayStrings[10], "N/A");
|
strcpy(displayStrings[10], "N/A");
|
||||||
@@ -343,11 +353,9 @@ void BaseMenuGui::refresh()
|
|||||||
millis = context->temps[HocClkThermalSensor_MEM];
|
millis = context->temps[HocClkThermalSensor_MEM];
|
||||||
sprintf(displayStrings[30], "%u.%u", millis / 1000U, (millis % 1000U) / 100U);
|
sprintf(displayStrings[30], "%u.%u", millis / 1000U, (millis % 1000U) / 100U);
|
||||||
tempColors[HocClkThermalSensor_MEM] = tsl::GradientColor(millis * 0.001f);
|
tempColors[HocClkThermalSensor_MEM] = tsl::GradientColor(millis * 0.001f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tsl::elm::Element* BaseMenuGui::baseUI()
|
tsl::elm::Element *BaseMenuGui::baseUI() {
|
||||||
{
|
|
||||||
auto *list = new tsl::elm::List();
|
auto *list = new tsl::elm::List();
|
||||||
this->listElement = list;
|
this->listElement = list;
|
||||||
this->listUI();
|
this->listUI();
|
||||||
|
|||||||
@@ -24,16 +24,13 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../ipc.h"
|
#include "../../ipc.h"
|
||||||
#include "base_gui.h"
|
#include "base_gui.h"
|
||||||
|
|
||||||
class BaseMenuGui : public BaseGui
|
class BaseMenuGui : public BaseGui {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// u8 dockedHighestAllowedRefreshRate = 60;
|
// u8 dockedHighestAllowedRefreshRate = 60;
|
||||||
HocClkContext *context;
|
HocClkContext *context;
|
||||||
@@ -66,9 +63,7 @@ class BaseMenuGui : public BaseGui
|
|||||||
setsysGetProductModel(&HWmodel);
|
setsysGetProductModel(&HWmodel);
|
||||||
g_hardwareModelCached = true;
|
g_hardwareModelCached = true;
|
||||||
}
|
}
|
||||||
g_isMariko = (HWmodel == SetSysProductModel_Iowa ||
|
g_isMariko = (HWmodel == SetSysProductModel_Iowa || HWmodel == SetSysProductModel_Hoag || HWmodel == SetSysProductModel_Calcio ||
|
||||||
HWmodel == SetSysProductModel_Hoag ||
|
|
||||||
HWmodel == SetSysProductModel_Calcio ||
|
|
||||||
HWmodel == SetSysProductModel_Aula);
|
HWmodel == SetSysProductModel_Aula);
|
||||||
|
|
||||||
return g_isMariko;
|
return g_isMariko;
|
||||||
@@ -84,7 +79,9 @@ class BaseMenuGui : public BaseGui
|
|||||||
tsl::elm::Element *baseUI() override;
|
tsl::elm::Element *baseUI() override;
|
||||||
void refresh() override;
|
void refresh() override;
|
||||||
virtual void listUI() = 0;
|
virtual void listUI() = 0;
|
||||||
u16 headerHeight() const override { return HOC_BOX_BOTTOM + 9; }
|
u16 headerHeight() const override {
|
||||||
|
return HOC_BOX_BOTTOM + 9;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char displayStrings[48][32]; // Pre-formatted display strings
|
char displayStrings[48][32]; // Pre-formatted display strings
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -16,8 +16,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "misc_gui.h"
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "misc_gui.h"
|
||||||
|
|
||||||
std::vector<std::string> ConfigInfoStrings(HocClkConfigValue val, bool isMariko, bool isHoag);
|
std::vector<std::string> ConfigInfoStrings(HocClkConfigValue val, bool isMariko, bool isHoag);
|
||||||
|
|||||||
@@ -24,45 +24,37 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "fatal_gui.h"
|
#include "fatal_gui.h"
|
||||||
|
|
||||||
FatalGui::FatalGui(const std::string message, const std::string info)
|
FatalGui::FatalGui(const std::string message, const std::string info) {
|
||||||
{
|
|
||||||
this->message = message;
|
this->message = message;
|
||||||
this->info = info;
|
this->info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FatalGui::openWithResultCode(std::string tag, Result rc)
|
void FatalGui::openWithResultCode(std::string tag, Result rc) {
|
||||||
{
|
|
||||||
char rcStr[32];
|
char rcStr[32];
|
||||||
std::string info = tag;
|
std::string info = tag;
|
||||||
info.append(rcStr, snprintf(rcStr, sizeof(rcStr), "\n\n[0x%x] %04d-%04d", rc, R_MODULE(rc), R_DESCRIPTION(rc)));
|
info.append(rcStr, snprintf(rcStr, sizeof(rcStr), "\n\n[0x%x] %04d-%04d", rc, R_MODULE(rc), R_DESCRIPTION(rc)));
|
||||||
|
|
||||||
tsl::changeTo<FatalGui>(
|
tsl::changeTo<FatalGui>("Could not connect to hoc-clk sysmodule.\n\n"
|
||||||
"Could not connect to hoc-clk sysmodule.\n\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"Please make sure everything is\n\n"
|
"Please make sure everything is\n\n"
|
||||||
"correctly installed and enabled.",
|
"correctly installed and enabled.",
|
||||||
info
|
info);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tsl::elm::Element* FatalGui::baseUI()
|
tsl::elm::Element *FatalGui::baseUI() {
|
||||||
{
|
|
||||||
tsl::elm::CustomDrawer *drawer = new tsl::elm::CustomDrawer([this](tsl::gfx::Renderer *renderer, u16 x, u16 y, u16 w, u16 h) {
|
tsl::elm::CustomDrawer *drawer = new tsl::elm::CustomDrawer([this](tsl::gfx::Renderer *renderer, u16 x, u16 y, u16 w, u16 h) {
|
||||||
renderer->drawString("\uE150", false, 40, 210, 40, TEXT_COLOR);
|
renderer->drawString("\uE150", false, 40, 210, 40, TEXT_COLOR);
|
||||||
renderer->drawString("Fatal error", false, 100, 210, 30, TEXT_COLOR);
|
renderer->drawString("Fatal error", false, 100, 210, 30, TEXT_COLOR);
|
||||||
|
|
||||||
std::uint32_t txtY = 255;
|
std::uint32_t txtY = 255;
|
||||||
if(!this->message.empty())
|
if (!this->message.empty()) {
|
||||||
{
|
|
||||||
txtY += renderer->drawString(this->message.c_str(), false, 40, txtY, 23, TEXT_COLOR).second;
|
txtY += renderer->drawString(this->message.c_str(), false, 40, txtY, 23, TEXT_COLOR).second;
|
||||||
txtY += 55;
|
txtY += 55;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this->info.empty())
|
if (!this->info.empty()) {
|
||||||
{
|
|
||||||
renderer->drawString(this->info.c_str(), false, 40, txtY, 18, DESC_COLOR);
|
renderer->drawString(this->info.c_str(), false, 40, txtY, 18, DESC_COLOR);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -70,10 +62,9 @@ tsl::elm::Element* FatalGui::baseUI()
|
|||||||
return drawer;
|
return drawer;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FatalGui::handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft, HidAnalogStickState joyStickPosRight)
|
bool FatalGui::handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft,
|
||||||
{
|
HidAnalogStickState joyStickPosRight) {
|
||||||
if((keysDown & HidNpadButton_A) == HidNpadButton_A || (keysDown & HidNpadButton_B) == HidNpadButton_B)
|
if ((keysDown & HidNpadButton_A) == HidNpadButton_A || (keysDown & HidNpadButton_B) == HidNpadButton_B) {
|
||||||
{
|
|
||||||
while (tsl::Overlay::get()->getCurrentGui() != nullptr) {
|
while (tsl::Overlay::get()->getCurrentGui() != nullptr) {
|
||||||
tsl::goBack();
|
tsl::goBack();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,23 +24,23 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include "base_gui.h"
|
#include "base_gui.h"
|
||||||
|
|
||||||
class FatalGui : public BaseGui
|
class FatalGui : public BaseGui {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
std::string message;
|
std::string message;
|
||||||
std::string info;
|
std::string info;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FatalGui(const std::string message, const std::string info);
|
FatalGui(const std::string message, const std::string info);
|
||||||
~FatalGui() {}
|
~FatalGui() {
|
||||||
|
}
|
||||||
tsl::elm::Element *baseUI() override;
|
tsl::elm::Element *baseUI() override;
|
||||||
bool handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft, HidAnalogStickState joyStickPosRight);
|
bool handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft,
|
||||||
|
HidAnalogStickState joyStickPosRight);
|
||||||
static void openWithResultCode(std::string tag, Result rc);
|
static void openWithResultCode(std::string tag, Result rc);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,21 +24,13 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ult_ext.h"
|
|
||||||
#include "freq_choice_gui.h"
|
|
||||||
|
|
||||||
#include "../format.h"
|
#include "../format.h"
|
||||||
#include "fatal_gui.h"
|
#include "fatal_gui.h"
|
||||||
|
#include "freq_choice_gui.h"
|
||||||
|
#include "ult_ext.h"
|
||||||
|
|
||||||
FreqChoiceGui::FreqChoiceGui(std::uint32_t selectedHz,
|
FreqChoiceGui::FreqChoiceGui(std::uint32_t selectedHz, std::uint32_t *hzList, std::uint32_t hzCount, HocClkModule module, FreqChoiceListener listener,
|
||||||
std::uint32_t* hzList,
|
bool checkMax, std::map<uint32_t, std::string> labels) {
|
||||||
std::uint32_t hzCount,
|
|
||||||
HocClkModule module,
|
|
||||||
FreqChoiceListener listener,
|
|
||||||
bool checkMax,
|
|
||||||
std::map<uint32_t, std::string> labels)
|
|
||||||
{
|
|
||||||
this->selectedHz = selectedHz;
|
this->selectedHz = selectedHz;
|
||||||
this->hzList = hzList;
|
this->hzList = hzList;
|
||||||
this->hzCount = hzCount;
|
this->hzCount = hzCount;
|
||||||
@@ -49,13 +41,11 @@ FreqChoiceGui::FreqChoiceGui(std::uint32_t selectedHz,
|
|||||||
this->configList = new HocClkConfigValueList{};
|
this->configList = new HocClkConfigValueList{};
|
||||||
}
|
}
|
||||||
|
|
||||||
FreqChoiceGui::~FreqChoiceGui()
|
FreqChoiceGui::~FreqChoiceGui() {
|
||||||
{
|
|
||||||
delete this->configList;
|
delete this->configList;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsl::elm::ListItem* FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool selected, int safety)
|
tsl::elm::ListItem *FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool selected, int safety) {
|
||||||
{
|
|
||||||
std::string text;
|
std::string text;
|
||||||
if (module == HocClkModule_MEM)
|
if (module == HocClkModule_MEM)
|
||||||
text = formatListFreqHzMem(hz, (RamDisplayUnit)this->configList->values[HocClkConfigValue_RamDisplayUnit]);
|
text = formatListFreqHzMem(hz, (RamDisplayUnit)this->configList->values[HocClkConfigValue_RamDisplayUnit]);
|
||||||
@@ -70,11 +60,9 @@ tsl::elm::ListItem* FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool sel
|
|||||||
if (selected)
|
if (selected)
|
||||||
const_cast<std::string &>(rightText) = "\uE14B";
|
const_cast<std::string &>(rightText) = "\uE14B";
|
||||||
|
|
||||||
tsl::elm::ListItem* listItem =
|
tsl::elm::ListItem *listItem = new tsl::elm::ListItem(text, rightText, false);
|
||||||
new tsl::elm::ListItem(text, rightText, false);
|
|
||||||
|
|
||||||
switch (safety)
|
switch (safety) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
||||||
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
||||||
@@ -95,8 +83,7 @@ tsl::elm::ListItem* FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool sel
|
|||||||
else if (selected)
|
else if (selected)
|
||||||
listItem->setValueColor(tsl::infoTextColor);
|
listItem->setValueColor(tsl::infoTextColor);
|
||||||
|
|
||||||
listItem->setClickListener([this, hz](u64 keys)
|
listItem->setClickListener([this, hz](u64 keys) {
|
||||||
{
|
|
||||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
||||||
if (this->listener(hz)) {
|
if (this->listener(hz)) {
|
||||||
tsl::goBack();
|
tsl::goBack();
|
||||||
@@ -109,8 +96,7 @@ tsl::elm::ListItem* FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool sel
|
|||||||
return listItem;
|
return listItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreqChoiceGui::listUI()
|
void FreqChoiceGui::listUI() {
|
||||||
{
|
|
||||||
hocclkIpcGetConfigValues(this->configList);
|
hocclkIpcGetConfigValues(this->configList);
|
||||||
|
|
||||||
// Header based on CPU/GPU/MEM module
|
// Header based on CPU/GPU/MEM module
|
||||||
@@ -118,11 +104,9 @@ void FreqChoiceGui::listUI()
|
|||||||
this->listElement->addItem(new tsl::elm::CategoryHeader(moduleName));
|
this->listElement->addItem(new tsl::elm::CategoryHeader(moduleName));
|
||||||
|
|
||||||
// Default option
|
// Default option
|
||||||
this->listElement->addItem(
|
this->listElement->addItem(this->createFreqListItem(0, this->selectedHz == 0, 0));
|
||||||
this->createFreqListItem(0, this->selectedHz == 0, 0));
|
|
||||||
|
|
||||||
for (std::uint32_t i = 0; i < this->hzCount; i++)
|
for (std::uint32_t i = 0; i < this->hzCount; i++) {
|
||||||
{
|
|
||||||
std::uint32_t hz = this->hzList[i];
|
std::uint32_t hz = this->hzList[i];
|
||||||
uint32_t mhz = hz / 1000000;
|
uint32_t mhz = hz / 1000000;
|
||||||
|
|
||||||
@@ -160,15 +144,12 @@ void FreqChoiceGui::listUI()
|
|||||||
uint32_t danger_cpu;
|
uint32_t danger_cpu;
|
||||||
uint32_t danger_gpu;
|
uint32_t danger_gpu;
|
||||||
|
|
||||||
if (IsMariko())
|
if (IsMariko()) {
|
||||||
{
|
|
||||||
unsafe_cpu = this->configList->values[KipConfigValue_marikoCpuUVHigh] ? 2398 : 1964;
|
unsafe_cpu = this->configList->values[KipConfigValue_marikoCpuUVHigh] ? 2398 : 1964;
|
||||||
unsafe_gpu = 1229;
|
unsafe_gpu = 1229;
|
||||||
danger_cpu = this->configList->values[KipConfigValue_marikoCpuUVHigh] ? 2500 : 2398;
|
danger_cpu = this->configList->values[KipConfigValue_marikoCpuUVHigh] ? 2500 : 2398;
|
||||||
danger_gpu = 1306;
|
danger_gpu = 1306;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
unsafe_cpu = this->configList->values[KipConfigValue_eristaCpuUV] ? 2092 : 1786;
|
unsafe_cpu = this->configList->values[KipConfigValue_eristaCpuUV] ? 2092 : 1786;
|
||||||
if (this->configList->values[KipConfigValue_eristaGpuUV] == GPUUVLevel_NoUV) {
|
if (this->configList->values[KipConfigValue_eristaGpuUV] == GPUUVLevel_NoUV) {
|
||||||
unsafe_gpu = 922;
|
unsafe_gpu = 922;
|
||||||
@@ -202,16 +183,9 @@ void FreqChoiceGui::listUI()
|
|||||||
} else if (moduleName == "mem") {
|
} else if (moduleName == "mem") {
|
||||||
|
|
||||||
safety = 0;
|
safety = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->listElement->addItem(
|
this->listElement->addItem(this->createFreqListItem(hz, (mhz == this->selectedHz / 1000000), safety));
|
||||||
this->createFreqListItem(
|
|
||||||
hz,
|
|
||||||
(mhz == this->selectedHz / 1000000),
|
|
||||||
safety
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->listElement->jumpToItem("", "");
|
this->listElement->jumpToItem("", "");
|
||||||
|
|||||||
@@ -24,18 +24,17 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "base_menu_gui.h"
|
#include "base_menu_gui.h"
|
||||||
|
|
||||||
using FreqChoiceListener = std::function<bool(std::uint32_t hz)>;
|
using FreqChoiceListener = std::function<bool(std::uint32_t hz)>;
|
||||||
|
|
||||||
class FreqChoiceGui : public BaseMenuGui
|
class FreqChoiceGui : public BaseMenuGui {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
HocClkConfigValueList *configList;
|
HocClkConfigValueList *configList;
|
||||||
std::uint32_t selectedHz;
|
std::uint32_t selectedHz;
|
||||||
@@ -50,13 +49,8 @@ protected:
|
|||||||
tsl::elm::ListItem *createFreqListItem(std::uint32_t hz, bool selected, int safety);
|
tsl::elm::ListItem *createFreqListItem(std::uint32_t hz, bool selected, int safety);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FreqChoiceGui(std::uint32_t selectedHz,
|
FreqChoiceGui(std::uint32_t selectedHz, std::uint32_t *hzList, std::uint32_t hzCount, HocClkModule module, FreqChoiceListener listener,
|
||||||
std::uint32_t* hzList,
|
bool checkMax = true, std::map<uint32_t, std::string> labels = {});
|
||||||
std::uint32_t hzCount,
|
|
||||||
HocClkModule module,
|
|
||||||
FreqChoiceListener listener,
|
|
||||||
bool checkMax = true,
|
|
||||||
std::map<uint32_t, std::string> labels = {});
|
|
||||||
|
|
||||||
~FreqChoiceGui();
|
~FreqChoiceGui();
|
||||||
|
|
||||||
|
|||||||
@@ -25,13 +25,13 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "../../ipc.h"
|
#include "../../ipc.h"
|
||||||
#include "base_menu_gui.h"
|
#include "base_menu_gui.h"
|
||||||
#include "freq_choice_gui.h"
|
#include "freq_choice_gui.h"
|
||||||
#include <string>
|
|
||||||
#include "value_choice_gui.h"
|
#include "value_choice_gui.h"
|
||||||
class GlobalOverrideGui : public BaseMenuGui
|
class GlobalOverrideGui : public BaseMenuGui {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
std::map<HocClkModule, std::tuple<std::string, std::uint32_t, int>> customFormatModules;
|
std::map<HocClkModule, std::tuple<std::string, std::uint32_t, int>> customFormatModules;
|
||||||
tsl::elm::ListItem *listItems[HocClkModule_EnumMax];
|
tsl::elm::ListItem *listItems[HocClkModule_EnumMax];
|
||||||
@@ -40,34 +40,17 @@ class GlobalOverrideGui : public BaseMenuGui
|
|||||||
void addGovernorSection();
|
void addGovernorSection();
|
||||||
void addModuleListItem(HocClkModule module);
|
void addModuleListItem(HocClkModule module);
|
||||||
void addModuleToggleItem(HocClkModule module);
|
void addModuleToggleItem(HocClkModule module);
|
||||||
void openValueChoiceGui(
|
void openValueChoiceGui(tsl::elm::ListItem *listItem, std::uint32_t currentValue, const ValueRange &range, const std::string &categoryName,
|
||||||
tsl::elm::ListItem* listItem,
|
ValueChoiceListener listener, const ValueThresholds &thresholds, bool enableThresholds,
|
||||||
std::uint32_t currentValue,
|
const std::map<std::uint32_t, std::string> &labels, const std::vector<NamedValue> &namedValues, bool showDefaultValue);
|
||||||
const ValueRange& range,
|
void addModuleListItemValue(HocClkModule module, const std::string &categoryName, std::uint32_t min, std::uint32_t max, std::uint32_t step,
|
||||||
const std::string& categoryName,
|
const std::string &suffix, std::uint32_t divisor, int decimalPlaces, ValueThresholds thresholds = {},
|
||||||
ValueChoiceListener listener,
|
const std::vector<NamedValue> &namedValues = {}, bool showDefaultValue = true);
|
||||||
const ValueThresholds& thresholds,
|
|
||||||
bool enableThresholds,
|
|
||||||
const std::map<std::uint32_t, std::string>& labels,
|
|
||||||
const std::vector<NamedValue>& namedValues,
|
|
||||||
bool showDefaultValue
|
|
||||||
);
|
|
||||||
void addModuleListItemValue(
|
|
||||||
HocClkModule module,
|
|
||||||
const std::string& categoryName,
|
|
||||||
std::uint32_t min,
|
|
||||||
std::uint32_t max,
|
|
||||||
std::uint32_t step,
|
|
||||||
const std::string& suffix,
|
|
||||||
std::uint32_t divisor,
|
|
||||||
int decimalPlaces,
|
|
||||||
ValueThresholds thresholds = {},
|
|
||||||
const std::vector<NamedValue>& namedValues = {},
|
|
||||||
bool showDefaultValue = true
|
|
||||||
);
|
|
||||||
public:
|
public:
|
||||||
GlobalOverrideGui();
|
GlobalOverrideGui();
|
||||||
~GlobalOverrideGui() {}
|
~GlobalOverrideGui() {
|
||||||
|
}
|
||||||
void listUI() override;
|
void listUI() override;
|
||||||
void refresh() override;
|
void refresh() override;
|
||||||
void setModuleCustomFormat(HocClkModule module, const std::string &suffix, std::uint32_t divisor, int decimalPlaces);
|
void setModuleCustomFormat(HocClkModule module, const std::string &suffix, std::uint32_t divisor, int decimalPlaces);
|
||||||
|
|||||||
@@ -16,12 +16,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "info_gui.h"
|
|
||||||
#include "ult_ext.h"
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
InfoGui::InfoGui(std::string title, std::vector<std::string> strings)
|
#include "info_gui.h"
|
||||||
: m_title(std::move(title)), m_strings(std::move(strings)) {}
|
#include "ult_ext.h"
|
||||||
|
|
||||||
|
InfoGui::InfoGui(std::string title, std::vector<std::string> strings) : m_title(std::move(title)), m_strings(std::move(strings)) {
|
||||||
|
}
|
||||||
|
|
||||||
static constexpr s32 TEXT_SIZE = 16;
|
static constexpr s32 TEXT_SIZE = 16;
|
||||||
static constexpr s32 LINE_H = 22;
|
static constexpr s32 LINE_H = 22;
|
||||||
@@ -29,15 +30,16 @@ static constexpr s32 PARA_GAP = 10;
|
|||||||
static constexpr s32 MARGIN_L = 20;
|
static constexpr s32 MARGIN_L = 20;
|
||||||
static constexpr s32 MARGIN_R = 35;
|
static constexpr s32 MARGIN_R = 35;
|
||||||
|
|
||||||
static std::vector<std::string> wrapText(const std::string& text, s32 maxWidth)
|
static std::vector<std::string> wrapText(const std::string &text, s32 maxWidth) {
|
||||||
{
|
|
||||||
constexpr float CHAR_W = 10.0f;
|
constexpr float CHAR_W = 10.0f;
|
||||||
|
|
||||||
// Preserve leading whitespace as an indent prefix for wrapped continuation lines.
|
// Preserve leading whitespace as an indent prefix for wrapped continuation lines.
|
||||||
std::string indent;
|
std::string indent;
|
||||||
for (char c : text) {
|
for (char c : text) {
|
||||||
if (c == ' ') indent += ' ';
|
if (c == ' ')
|
||||||
else break;
|
indent += ' ';
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> lines;
|
std::vector<std::string> lines;
|
||||||
@@ -45,43 +47,39 @@ static std::vector<std::string> wrapText(const std::string& text, s32 maxWidth)
|
|||||||
std::string word, line = indent; // seed with indent so first word inherits it
|
std::string word, line = indent; // seed with indent so first word inherits it
|
||||||
bool first = true;
|
bool first = true;
|
||||||
while (ss >> word) {
|
while (ss >> word) {
|
||||||
std::string candidate = (first && !indent.empty()) ? indent + word
|
std::string candidate = (first && !indent.empty()) ? indent + word : line.empty() ? word : line + " " + word;
|
||||||
: line.empty() ? word
|
|
||||||
: line + " " + word;
|
|
||||||
first = false;
|
first = false;
|
||||||
if (static_cast<s32>(candidate.size() * CHAR_W) <= maxWidth)
|
if (static_cast<s32>(candidate.size() * CHAR_W) <= maxWidth)
|
||||||
line = std::move(candidate);
|
line = std::move(candidate);
|
||||||
else {
|
else {
|
||||||
if (!line.empty() && line != indent) lines.push_back(line);
|
if (!line.empty() && line != indent)
|
||||||
|
lines.push_back(line);
|
||||||
line = indent + word;
|
line = indent + word;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!line.empty() && line != indent) lines.push_back(line);
|
if (!line.empty() && line != indent)
|
||||||
if (lines.empty()) lines.emplace_back("");
|
lines.push_back(line);
|
||||||
|
if (lines.empty())
|
||||||
|
lines.emplace_back("");
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoGui::listUI()
|
void InfoGui::listUI() {
|
||||||
{
|
|
||||||
this->listElement->addItem(new tsl::elm::CategoryHeader(m_title));
|
this->listElement->addItem(new tsl::elm::CategoryHeader(m_title));
|
||||||
|
|
||||||
const s32 maxWidth = tsl::cfg::FramebufferWidth - MARGIN_L - MARGIN_R;
|
const s32 maxWidth = tsl::cfg::FramebufferWidth - MARGIN_L - MARGIN_R;
|
||||||
|
|
||||||
for (const auto ¶ : m_strings) {
|
for (const auto ¶ : m_strings) {
|
||||||
for (const auto &lineText : wrapText(para, maxWidth)) {
|
for (const auto &lineText : wrapText(para, maxWidth)) {
|
||||||
auto* d = new FocusableDrawer(
|
auto *d = new FocusableDrawer([lineText](tsl::gfx::Renderer *r, s32 x, s32 y, s32 w, s32 h) {
|
||||||
[lineText](tsl::gfx::Renderer* r, s32 x, s32 y, s32 w, s32 h) {
|
r->drawString((lineText + "\n").c_str(), false, x + MARGIN_L, y + LINE_H - 5, TEXT_SIZE, tsl::style::color::ColorText);
|
||||||
r->drawString((lineText + "\n").c_str(), false,
|
|
||||||
x + MARGIN_L, y + LINE_H - 5,
|
|
||||||
TEXT_SIZE, tsl::style::color::ColorText);
|
|
||||||
});
|
});
|
||||||
d->setBoundaries(0, 0, tsl::cfg::FramebufferWidth, LINE_H);
|
d->setBoundaries(0, 0, tsl::cfg::FramebufferWidth, LINE_H);
|
||||||
this->listElement->addItem(d, LINE_H);
|
this->listElement->addItem(d, LINE_H);
|
||||||
}
|
}
|
||||||
|
|
||||||
// paragraph gap
|
// paragraph gap
|
||||||
auto* gap = new tsl::elm::CustomDrawer(
|
auto *gap = new tsl::elm::CustomDrawer([](tsl::gfx::Renderer *, s32, s32, s32, s32) {});
|
||||||
[](tsl::gfx::Renderer*, s32, s32, s32, s32) {});
|
|
||||||
gap->setBoundaries(0, 0, tsl::cfg::FramebufferWidth, PARA_GAP);
|
gap->setBoundaries(0, 0, tsl::cfg::FramebufferWidth, PARA_GAP);
|
||||||
this->listElement->addItem(gap, PARA_GAP);
|
this->listElement->addItem(gap, PARA_GAP);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "base_menu_gui.h"
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class InfoGui : public BaseMenuGui
|
#include "base_menu_gui.h"
|
||||||
{
|
|
||||||
|
class InfoGui : public BaseMenuGui {
|
||||||
public:
|
public:
|
||||||
InfoGui(std::string title, std::vector<std::string> strings);
|
InfoGui(std::string title, std::vector<std::string> strings);
|
||||||
~InfoGui() = default;
|
~InfoGui() = default;
|
||||||
|
|||||||
@@ -15,136 +15,69 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
std::map<uint32_t, std::string> cpu_freq_label_m = {
|
std::map<uint32_t, std::string> cpu_freq_label_m = {
|
||||||
{612000000, "Sleep Mode"},
|
{ 612000000, "Sleep Mode" }, { 1020000000, "Stock" }, { 1224000000, "Dev OC" }, { 1785000000, "Boost Mode" },
|
||||||
{1020000000, "Stock"},
|
{ 1963000000, "Safe Max" }, { 2397000000, "Unsafe Max" }, { 2703000000, "Absolute Max" },
|
||||||
{1224000000, "Dev OC"},
|
|
||||||
{1785000000, "Boost Mode"},
|
|
||||||
{1963000000, "Safe Max"},
|
|
||||||
{2397000000, "Unsafe Max"},
|
|
||||||
{2703000000, "Absolute Max"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<uint32_t, std::string> cpu_freq_label_m_uv = {
|
std::map<uint32_t, std::string> cpu_freq_label_m_uv = {
|
||||||
{612000000, "Sleep Mode"},
|
{ 612000000, "Sleep Mode" }, { 1020000000, "Stock" }, { 1224000000, "Dev OC" }, { 1785000000, "Boost Mode" },
|
||||||
{1020000000, "Stock"},
|
{ 2397000000, "Safe Max" }, { 2499000000, "Unsafe Max" }, { 2703000000, "Absolute Max" },
|
||||||
{1224000000, "Dev OC"},
|
|
||||||
{1785000000, "Boost Mode"},
|
|
||||||
{2397000000, "Safe Max"},
|
|
||||||
{2499000000, "Unsafe Max"},
|
|
||||||
{2703000000, "Absolute Max"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<uint32_t, std::string> cpu_freq_label_e = {
|
std::map<uint32_t, std::string> cpu_freq_label_e = {
|
||||||
{612000000, "Sleep Mode"},
|
{ 612000000, "Sleep Mode" }, { 1020000000, "Stock" }, { 1224000000, "Dev OC" },
|
||||||
{1020000000, "Stock"},
|
{ 1785000000, "Safe Max" }, { 2091000000, "Unsafe Max" }, { 2397000000, "Absolute Max" },
|
||||||
{1224000000, "Dev OC"},
|
|
||||||
{1785000000, "Safe Max"},
|
|
||||||
{2091000000, "Unsafe Max"},
|
|
||||||
{2397000000, "Absolute Max"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<uint32_t, std::string> cpu_freq_label_e_uv = {
|
std::map<uint32_t, std::string> cpu_freq_label_e_uv = {
|
||||||
{612000000, "Sleep Mode"},
|
{ 612000000, "Sleep Mode" }, { 1020000000, "Stock" }, { 1224000000, "Dev OC" }, { 1785000000, "Boost Mode" },
|
||||||
{1020000000, "Stock"},
|
{ 2091000000, "Safe Max" }, { 2193000000, "Unsafe Max" }, { 2397000000, "Absolute Max" },
|
||||||
{1224000000, "Dev OC"},
|
|
||||||
{1785000000, "Boost Mode"},
|
|
||||||
{2091000000, "Safe Max"},
|
|
||||||
{2193000000, "Unsafe Max"},
|
|
||||||
{2397000000, "Absolute Max"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
std::map<uint32_t, std::string> gpu_freq_label_e = {
|
std::map<uint32_t, std::string> gpu_freq_label_e = {
|
||||||
{76800000, "Boost Mode"},
|
{ 76800000, "Boost Mode" }, { 307200000, "Handheld" }, { 345600000, "Handheld" }, { 384000000, "Handheld" },
|
||||||
{307200000, "Handheld"},
|
{ 422400000, "Handheld" }, { 460800000, "Handheld Safe Max" }, { 768000000, "Docked" }, { 921600000, "Safe Max" },
|
||||||
{345600000, "Handheld"},
|
{ 960000000, "Unsafe Max" }, { 1075200000, "Absolute Max" },
|
||||||
{384000000, "Handheld"},
|
|
||||||
{422400000, "Handheld"},
|
|
||||||
{460800000, "Handheld Safe Max"},
|
|
||||||
{768000000, "Docked"},
|
|
||||||
{921600000, "Safe Max"},
|
|
||||||
{960000000, "Unsafe Max"},
|
|
||||||
{1075200000, "Absolute Max"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<uint32_t, std::string> gpu_freq_label_e_uv = {
|
std::map<uint32_t, std::string> gpu_freq_label_e_uv = {
|
||||||
{76800000, "Boost Mode"},
|
{ 76800000, "Boost Mode" }, { 307200000, "Handheld" }, { 345600000, "Handheld" },
|
||||||
{307200000, "Handheld"},
|
{ 384000000, "Handheld" }, { 422400000, "Handheld" }, { 460800000, "Handheld Safe Max" },
|
||||||
{345600000, "Handheld"},
|
{ 768000000, "Docked" }, { 960000000, "Safe Max" }, { 1075200000, "Absolute Max" },
|
||||||
{384000000, "Handheld"},
|
|
||||||
{422400000, "Handheld"},
|
|
||||||
{460800000, "Handheld Safe Max"},
|
|
||||||
{768000000, "Docked"},
|
|
||||||
{960000000, "Safe Max"},
|
|
||||||
{1075200000, "Absolute Max"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<uint32_t, std::string> gpu_freq_label_m = {
|
std::map<uint32_t, std::string> gpu_freq_label_m = {
|
||||||
{76800000, "Boost Mode"},
|
{ 76800000, "Boost Mode" }, { 307200000, "Handheld" }, { 345600000, "Handheld" }, { 384000000, "Handheld" }, { 422400000, "Handheld" },
|
||||||
{307200000, "Handheld"},
|
{ 460800000, "Handheld" }, { 614400000, "Handheld Safe Max" }, { 768000000, "Docked" }, { 998400000, "Safe Max" },
|
||||||
{345600000, "Handheld"},
|
|
||||||
{384000000, "Handheld"},
|
|
||||||
{422400000, "Handheld"},
|
|
||||||
{460800000, "Handheld"},
|
|
||||||
{614400000, "Handheld Safe Max"},
|
|
||||||
{768000000, "Docked"},
|
|
||||||
{998400000, "Safe Max"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<uint32_t, std::string> gpu_freq_label_m_slt = {
|
std::map<uint32_t, std::string> gpu_freq_label_m_slt = {
|
||||||
{76800000, "Boost Mode"},
|
{ 76800000, "Boost Mode" }, { 307200000, "Handheld" }, { 345600000, "Handheld" }, { 384000000, "Handheld" },
|
||||||
{307200000, "Handheld"},
|
{ 422400000, "Handheld" }, { 460800000, "Handheld" }, { 614400000, "Handheld Safe Max" }, { 768000000, "Docked" },
|
||||||
{345600000, "Handheld"},
|
{ 1075200000, "Safe Max" }, { 1305600000, "Unsafe Max" }, { 1536000000, "Absolute Max" },
|
||||||
{384000000, "Handheld"},
|
|
||||||
{422400000, "Handheld"},
|
|
||||||
{460800000, "Handheld"},
|
|
||||||
{614400000, "Handheld Safe Max"},
|
|
||||||
{768000000, "Docked"},
|
|
||||||
{1075200000, "Safe Max"},
|
|
||||||
{1305600000, "Unsafe Max"},
|
|
||||||
{1536000000, "Absolute Max"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<uint32_t, std::string> gpu_freq_label_m_hiopt = {
|
std::map<uint32_t, std::string> gpu_freq_label_m_hiopt = {
|
||||||
{76800000, "Boost Mode"},
|
{ 76800000, "Boost Mode" }, { 307200000, "Handheld" }, { 345600000, "Handheld" }, { 384000000, "Handheld" },
|
||||||
{307200000, "Handheld"},
|
{ 422400000, "Handheld" }, { 460800000, "Handheld" }, { 614400000, "Handheld Safe Max" }, { 768000000, "Docked" },
|
||||||
{345600000, "Handheld"},
|
{ 1152000000, "Safe Max" }, { 1305600000, "Unsafe Max" }, { 1536000000, "Absolute Max" },
|
||||||
{384000000, "Handheld"},
|
|
||||||
{422400000, "Handheld"},
|
|
||||||
{460800000, "Handheld"},
|
|
||||||
{614400000, "Handheld Safe Max"},
|
|
||||||
{768000000, "Docked"},
|
|
||||||
{1152000000, "Safe Max"},
|
|
||||||
{1305600000, "Unsafe Max"},
|
|
||||||
{1536000000, "Absolute Max"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<uint32_t, std::string> gpu_freq_label_m_highuv = {
|
std::map<uint32_t, std::string> gpu_freq_label_m_highuv = {
|
||||||
{76800000, "Boost Mode"},
|
{ 76800000, "Boost Mode" }, { 307200000, "Handheld" }, { 384000000, "Handheld" },
|
||||||
{307200000, "Handheld"},
|
{ 460800000, "Handheld" }, { 614400000, "Handheld Safe Max" }, { 768000000, "Docked" },
|
||||||
{384000000, "Handheld"},
|
{ 1228800000, "Safe Max" }, { 1305600000, "Unsafe Max" }, { 1536000000, "Absolute Max" },
|
||||||
{460800000, "Handheld"},
|
|
||||||
{614400000, "Handheld Safe Max"},
|
|
||||||
{768000000, "Docked"},
|
|
||||||
{1228800000, "Safe Max"},
|
|
||||||
{1305600000, "Unsafe Max"},
|
|
||||||
{1536000000, "Absolute Max"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<uint32_t, std::string> *marikoUV[5]{
|
std::map<uint32_t, std::string> *marikoUV[5]{
|
||||||
&gpu_freq_label_m,
|
&gpu_freq_label_m, &gpu_freq_label_m_slt, &gpu_freq_label_m_hiopt, &gpu_freq_label_m_hiopt, &gpu_freq_label_m_highuv,
|
||||||
&gpu_freq_label_m_slt,
|
|
||||||
&gpu_freq_label_m_hiopt,
|
|
||||||
&gpu_freq_label_m_hiopt,
|
|
||||||
&gpu_freq_label_m_highuv,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
std::map<uint32_t, std::string> *eristaUV[3]{
|
std::map<uint32_t, std::string> *eristaUV[3]{
|
||||||
&gpu_freq_label_e,
|
&gpu_freq_label_e,
|
||||||
&gpu_freq_label_e_uv,
|
&gpu_freq_label_e_uv,
|
||||||
|
|||||||
@@ -24,16 +24,15 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "main_gui.h"
|
|
||||||
|
|
||||||
#include "fatal_gui.h"
|
|
||||||
#include "app_profile_gui.h"
|
|
||||||
#include "global_override_gui.h"
|
|
||||||
#include "misc_gui.h"
|
|
||||||
#include "about_gui.h"
|
#include "about_gui.h"
|
||||||
|
#include "app_profile_gui.h"
|
||||||
|
#include "fatal_gui.h"
|
||||||
|
#include "global_override_gui.h"
|
||||||
|
#include "main_gui.h"
|
||||||
|
#include "misc_gui.h"
|
||||||
#include "ult_ext.h"
|
#include "ult_ext.h"
|
||||||
|
|
||||||
|
|
||||||
tsl::elm::Element *MainGui::baseUI() {
|
tsl::elm::Element *MainGui::baseUI() {
|
||||||
auto *list = new BoxClippedList();
|
auto *list = new BoxClippedList();
|
||||||
this->listElement = list;
|
this->listElement = list;
|
||||||
@@ -41,8 +40,7 @@ tsl::elm::Element* MainGui::baseUI() {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainGui::listUI()
|
void MainGui::listUI() {
|
||||||
{
|
|
||||||
// this->enabledToggle = new tsl::elm::ToggleListItem("Enable", false);
|
// this->enabledToggle = new tsl::elm::ToggleListItem("Enable", false);
|
||||||
// enabledToggle->setStateChangedListener([this](bool state) {
|
// enabledToggle->setStateChangedListener([this](bool state) {
|
||||||
// Result rc = hocclkIpcSetEnabled(state);
|
// Result rc = hocclkIpcSetEnabled(state);
|
||||||
@@ -58,8 +56,7 @@ void MainGui::listUI()
|
|||||||
|
|
||||||
tsl::elm::ListItem *appProfileItem = new tsl::elm::ListItem("Edit App Profile");
|
tsl::elm::ListItem *appProfileItem = new tsl::elm::ListItem("Edit App Profile");
|
||||||
appProfileItem->setClickListener([this](u64 keys) {
|
appProfileItem->setClickListener([this](u64 keys) {
|
||||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->context) {
|
||||||
{
|
|
||||||
AppProfileGui::changeTo(this->context->applicationId);
|
AppProfileGui::changeTo(this->context->applicationId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -68,11 +65,9 @@ void MainGui::listUI()
|
|||||||
});
|
});
|
||||||
this->listElement->addItem(appProfileItem);
|
this->listElement->addItem(appProfileItem);
|
||||||
|
|
||||||
|
|
||||||
tsl::elm::ListItem *globalProfileItem = new tsl::elm::ListItem("Edit Global Profile");
|
tsl::elm::ListItem *globalProfileItem = new tsl::elm::ListItem("Edit Global Profile");
|
||||||
globalProfileItem->setClickListener([this](u64 keys) {
|
globalProfileItem->setClickListener([this](u64 keys) {
|
||||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->context) {
|
||||||
{
|
|
||||||
AppProfileGui::changeTo(HOCCLK_GLOBAL_PROFILE_TID);
|
AppProfileGui::changeTo(HOCCLK_GLOBAL_PROFILE_TID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -83,8 +78,7 @@ void MainGui::listUI()
|
|||||||
|
|
||||||
tsl::elm::ListItem *globalOverrideItem = new tsl::elm::ListItem("Temporary Overrides");
|
tsl::elm::ListItem *globalOverrideItem = new tsl::elm::ListItem("Temporary Overrides");
|
||||||
globalOverrideItem->setClickListener([this](u64 keys) {
|
globalOverrideItem->setClickListener([this](u64 keys) {
|
||||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->context) {
|
||||||
{
|
|
||||||
tsl::changeTo<GlobalOverrideGui>();
|
tsl::changeTo<GlobalOverrideGui>();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -97,8 +91,7 @@ void MainGui::listUI()
|
|||||||
|
|
||||||
tsl::elm::ListItem *miscItem = new tsl::elm::ListItem("Settings");
|
tsl::elm::ListItem *miscItem = new tsl::elm::ListItem("Settings");
|
||||||
miscItem->setClickListener([this](u64 keys) {
|
miscItem->setClickListener([this](u64 keys) {
|
||||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->context) {
|
||||||
{
|
|
||||||
tsl::changeTo<MiscGui>();
|
tsl::changeTo<MiscGui>();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -109,8 +102,7 @@ void MainGui::listUI()
|
|||||||
|
|
||||||
tsl::elm::ListItem *aboutItem = new tsl::elm::ListItem("About");
|
tsl::elm::ListItem *aboutItem = new tsl::elm::ListItem("About");
|
||||||
aboutItem->setClickListener([this](u64 keys) {
|
aboutItem->setClickListener([this](u64 keys) {
|
||||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->context) {
|
||||||
{
|
|
||||||
tsl::changeTo<AboutGui>();
|
tsl::changeTo<AboutGui>();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -118,11 +110,9 @@ void MainGui::listUI()
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
this->listElement->addItem(aboutItem);
|
this->listElement->addItem(aboutItem);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainGui::refresh()
|
void MainGui::refresh() {
|
||||||
{
|
|
||||||
BaseMenuGui::refresh();
|
BaseMenuGui::refresh();
|
||||||
// if(this->context)
|
// if(this->context)
|
||||||
//{
|
//{
|
||||||
|
|||||||
@@ -24,18 +24,20 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base_menu_gui.h"
|
#include "base_menu_gui.h"
|
||||||
|
|
||||||
class MainGui : public BaseMenuGui
|
class MainGui : public BaseMenuGui {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
MainGui() {}
|
MainGui() {
|
||||||
~MainGui() {}
|
}
|
||||||
|
~MainGui() {
|
||||||
|
}
|
||||||
tsl::elm::Element *baseUI() override;
|
tsl::elm::Element *baseUI() override;
|
||||||
void listUI() override;
|
void listUI() override;
|
||||||
void refresh() override;
|
void refresh() override;
|
||||||
u16 headerHeight() const override { return HOC_HEADER_HEIGHT - 25; }
|
u16 headerHeight() const override {
|
||||||
|
return HOC_HEADER_HEIGHT - 25;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -16,18 +16,18 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../../ipc.h"
|
|
||||||
#include "base_menu_gui.h"
|
|
||||||
#include <initializer_list>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <unordered_map>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../../ipc.h"
|
||||||
|
#include "base_menu_gui.h"
|
||||||
#include "freq_choice_gui.h"
|
#include "freq_choice_gui.h"
|
||||||
#include "value_choice_gui.h"
|
|
||||||
#include "info_gui.h"
|
#include "info_gui.h"
|
||||||
class MiscGui : public BaseMenuGui
|
#include "value_choice_gui.h"
|
||||||
{
|
#include <initializer_list>
|
||||||
|
#include <unordered_map>
|
||||||
|
class MiscGui : public BaseMenuGui {
|
||||||
public:
|
public:
|
||||||
MiscGui();
|
MiscGui();
|
||||||
~MiscGui();
|
~MiscGui();
|
||||||
@@ -47,33 +47,17 @@ protected:
|
|||||||
|
|
||||||
void addConfigToggle(HocClkConfigValue configVal, const char *altName, bool kip = false);
|
void addConfigToggle(HocClkConfigValue configVal, const char *altName, bool kip = false);
|
||||||
void addConfigTrackbar(HocClkConfigValue configVal, const char *altName, const ValueRange &range, bool kip = true);
|
void addConfigTrackbar(HocClkConfigValue configVal, const char *altName, const ValueRange &range, bool kip = true);
|
||||||
void addMappedConfigTrackbar(HocClkConfigValue configVal, const char* altName,
|
void addMappedConfigTrackbar(HocClkConfigValue configVal, const char *altName, std::vector<u32> vals, std::initializer_list<std::string> names,
|
||||||
std::vector<u32> vals,
|
bool kip = true);
|
||||||
std::initializer_list<std::string> names, bool kip = true);
|
void addConfigButton(HocClkConfigValue configVal, const char *altName, const ValueRange &range, const std::string &categoryName,
|
||||||
void addConfigButton(HocClkConfigValue configVal,
|
const ValueThresholds *thresholds, const std::map<uint32_t, std::string> &labels = {},
|
||||||
const char* altName,
|
const std::vector<NamedValue> &namedValues = {}, bool showDefaultValue = true, bool kip = false);
|
||||||
const ValueRange& range,
|
|
||||||
const std::string& categoryName,
|
|
||||||
const ValueThresholds* thresholds,
|
|
||||||
const std::map<uint32_t, std::string>& labels = {},
|
|
||||||
const std::vector<NamedValue>& namedValues = {},
|
|
||||||
bool showDefaultValue = true,
|
|
||||||
bool kip = false);
|
|
||||||
|
|
||||||
void addConfigButtonS(HocClkConfigValue configVal,
|
void addConfigButtonS(HocClkConfigValue configVal, const char *altName, const ValueRange &range, const std::string &categoryName,
|
||||||
const char* altName,
|
const ValueThresholds *thresholds, const std::map<uint32_t, std::string> &labels = {},
|
||||||
const ValueRange& range,
|
const std::vector<NamedValue> &namedValues = {}, bool showDefaultValue = true, const char *subText = nullptr,
|
||||||
const std::string& categoryName,
|
|
||||||
const ValueThresholds* thresholds,
|
|
||||||
const std::map<uint32_t, std::string>& labels = {},
|
|
||||||
const std::vector<NamedValue>& namedValues = {},
|
|
||||||
bool showDefaultValue = true,
|
|
||||||
const char* subText = nullptr,
|
|
||||||
bool kip = false);
|
bool kip = false);
|
||||||
void addFreqButton(HocClkConfigValue configVal,
|
void addFreqButton(HocClkConfigValue configVal, const char *altName, HocClkModule module, const std::map<uint32_t, std::string> &labels = {});
|
||||||
const char* altName,
|
|
||||||
HocClkModule module,
|
|
||||||
const std::map<uint32_t, std::string>& labels = {});
|
|
||||||
void updateConfigToggles();
|
void updateConfigToggles();
|
||||||
|
|
||||||
tsl::elm::ToggleListItem *enabledToggle;
|
tsl::elm::ToggleListItem *enabledToggle;
|
||||||
|
|||||||
@@ -17,11 +17,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <tesla.hpp>
|
#include <tesla.hpp>
|
||||||
|
|
||||||
#include "../elements/base_frame.h"
|
#include "../elements/base_frame.h"
|
||||||
|
|
||||||
|
|
||||||
class TopAnchoredList : public tsl::elm::List {
|
class TopAnchoredList : public tsl::elm::List {
|
||||||
public:
|
public:
|
||||||
TopAnchoredList() { m_hasSetInitialFocusHack = true; }
|
TopAnchoredList() {
|
||||||
|
m_hasSetInitialFocusHack = true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
class BoxClippedList : public tsl::elm::List {
|
class BoxClippedList : public tsl::elm::List {
|
||||||
public:
|
public:
|
||||||
@@ -34,7 +38,8 @@ public:
|
|||||||
|
|
||||||
class CompactCategoryHeader : public tsl::elm::CategoryHeader {
|
class CompactCategoryHeader : public tsl::elm::CategoryHeader {
|
||||||
public:
|
public:
|
||||||
CompactCategoryHeader(const std::string& text) : tsl::elm::CategoryHeader(text) {}
|
CompactCategoryHeader(const std::string &text) : tsl::elm::CategoryHeader(text) {
|
||||||
|
}
|
||||||
void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
||||||
this->setBoundaries(this->getX(), this->getY(), this->getWidth(), 33);
|
this->setBoundaries(this->getX(), this->getY(), this->getWidth(), 33);
|
||||||
}
|
}
|
||||||
@@ -47,25 +52,20 @@ private:
|
|||||||
bool visible;
|
bool visible;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ImageElement(const uint8_t* data, uint32_t w, uint32_t h)
|
ImageElement(const uint8_t *data, uint32_t w, uint32_t h) : tsl::elm::ListItem(""), imgData(data), imgWidth(w), imgHeight(h), visible(true) {
|
||||||
: tsl::elm::ListItem(""), imgData(data), imgWidth(w), imgHeight(h), visible(true) {}
|
}
|
||||||
|
|
||||||
void setVisible(bool v) {
|
void setVisible(bool v) {
|
||||||
visible = v;
|
visible = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
||||||
if (!visible) return;
|
if (!visible)
|
||||||
|
return;
|
||||||
|
|
||||||
// Draw image centered horizontally
|
// Draw image centered horizontally
|
||||||
u16 centerX = this->getX() + (this->getWidth() - imgWidth) / 2;
|
u16 centerX = this->getX() + (this->getWidth() - imgWidth) / 2;
|
||||||
renderer->drawBitmap(
|
renderer->drawBitmap(centerX, this->getY() + 10, imgWidth, imgHeight, imgData);
|
||||||
centerX,
|
|
||||||
this->getY() + 10,
|
|
||||||
imgWidth,
|
|
||||||
imgHeight,
|
|
||||||
imgData
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
virtual void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
||||||
@@ -96,15 +96,16 @@ private:
|
|||||||
bool visible;
|
bool visible;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HideableCategoryHeader(const std::string& title)
|
HideableCategoryHeader(const std::string &title) : tsl::elm::CategoryHeader(title), visible(true) {
|
||||||
: tsl::elm::CategoryHeader(title), visible(true) {}
|
}
|
||||||
|
|
||||||
void setVisible(bool v) {
|
void setVisible(bool v) {
|
||||||
visible = v;
|
visible = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
||||||
if (!visible) return;
|
if (!visible)
|
||||||
|
return;
|
||||||
tsl::elm::CategoryHeader::draw(renderer);
|
tsl::elm::CategoryHeader::draw(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,14 +120,14 @@ public:
|
|||||||
|
|
||||||
class FocusableDrawer : public tsl::elm::CustomDrawer {
|
class FocusableDrawer : public tsl::elm::CustomDrawer {
|
||||||
public:
|
public:
|
||||||
template<typename... Args>
|
template <typename... Args> FocusableDrawer(Args &&...args) : tsl::elm::CustomDrawer(std::forward<Args>(args)...) {
|
||||||
FocusableDrawer(Args&&... args) : tsl::elm::CustomDrawer(std::forward<Args>(args)...) {
|
|
||||||
m_isItem = true;
|
m_isItem = true;
|
||||||
}
|
}
|
||||||
Element *requestFocus(Element *, tsl::FocusDirection) override {
|
Element *requestFocus(Element *, tsl::FocusDirection) override {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
void drawHighlight(tsl::gfx::Renderer*) override {}
|
void drawHighlight(tsl::gfx::Renderer *) override {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class HideableCustomDrawer : public tsl::elm::Element {
|
class HideableCustomDrawer : public tsl::elm::Element {
|
||||||
@@ -135,8 +136,8 @@ private:
|
|||||||
u32 height;
|
u32 height;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HideableCustomDrawer(u32 h)
|
HideableCustomDrawer(u32 h) : Element(), visible(true), height(h) {
|
||||||
: Element(), visible(true), height(h) {}
|
}
|
||||||
|
|
||||||
void setVisible(bool v) {
|
void setVisible(bool v) {
|
||||||
visible = v;
|
visible = v;
|
||||||
|
|||||||
@@ -16,42 +16,25 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "ult_ext.h"
|
#include <iomanip>
|
||||||
#include "value_choice_gui.h"
|
#include <sstream>
|
||||||
|
|
||||||
#include "../format.h"
|
#include "../format.h"
|
||||||
#include "fatal_gui.h"
|
#include "fatal_gui.h"
|
||||||
#include <sstream>
|
#include "ult_ext.h"
|
||||||
#include <iomanip>
|
#include "value_choice_gui.h"
|
||||||
|
|
||||||
ValueChoiceGui::ValueChoiceGui(std::uint32_t selectedValue,
|
ValueChoiceGui::ValueChoiceGui(std::uint32_t selectedValue, const ValueRange &range, const std::string &categoryName, ValueChoiceListener listener,
|
||||||
const ValueRange& range,
|
const ValueThresholds &thresholds, bool enableThresholds, std::map<std::uint32_t, std::string> labels,
|
||||||
const std::string& categoryName,
|
std::vector<NamedValue> namedValues, bool showDefaultValue, bool showDNO)
|
||||||
ValueChoiceListener listener,
|
: selectedValue(selectedValue), range(range), categoryName(categoryName), listener(listener), thresholds(thresholds),
|
||||||
const ValueThresholds& thresholds,
|
enableThresholds(enableThresholds), labels(labels), namedValues(namedValues), showDefaultValue(showDefaultValue), showDNO(showDNO) {
|
||||||
bool enableThresholds,
|
|
||||||
std::map<std::uint32_t, std::string> labels,
|
|
||||||
std::vector<NamedValue> namedValues,
|
|
||||||
bool showDefaultValue,
|
|
||||||
bool showDNO)
|
|
||||||
: selectedValue(selectedValue),
|
|
||||||
range(range),
|
|
||||||
categoryName(categoryName),
|
|
||||||
listener(listener),
|
|
||||||
thresholds(thresholds),
|
|
||||||
enableThresholds(enableThresholds),
|
|
||||||
labels(labels),
|
|
||||||
namedValues(namedValues),
|
|
||||||
showDefaultValue(showDefaultValue),
|
|
||||||
showDNO(showDNO)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueChoiceGui::~ValueChoiceGui()
|
ValueChoiceGui::~ValueChoiceGui() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ValueChoiceGui::formatValue(std::uint32_t value)
|
std::string ValueChoiceGui::formatValue(std::uint32_t value) {
|
||||||
{
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
if (showDefaultValue) {
|
if (showDefaultValue) {
|
||||||
if (value == 0) {
|
if (value == 0) {
|
||||||
@@ -66,8 +49,7 @@ std::string ValueChoiceGui::formatValue(std::uint32_t value)
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ValueChoiceGui::getSafetyLevel(std::uint32_t value)
|
int ValueChoiceGui::getSafetyLevel(std::uint32_t value) {
|
||||||
{
|
|
||||||
if (thresholds.warning == 0 && thresholds.danger == 0) {
|
if (thresholds.warning == 0 && thresholds.danger == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -81,8 +63,7 @@ int ValueChoiceGui::getSafetyLevel(std::uint32_t value)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsl::elm::ListItem* ValueChoiceGui::createValueListItem(std::uint32_t value, bool selected, int safety)
|
tsl::elm::ListItem *ValueChoiceGui::createValueListItem(std::uint32_t value, bool selected, int safety) {
|
||||||
{
|
|
||||||
std::string text = formatValue(value);
|
std::string text = formatValue(value);
|
||||||
std::string rightText = "";
|
std::string rightText = "";
|
||||||
|
|
||||||
@@ -96,8 +77,7 @@ tsl::elm::ListItem* ValueChoiceGui::createValueListItem(std::uint32_t value, boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
tsl::elm::ListItem *listItem = new tsl::elm::ListItem(text, rightText, false);
|
tsl::elm::ListItem *listItem = new tsl::elm::ListItem(text, rightText, false);
|
||||||
switch (safety)
|
switch (safety) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
||||||
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
||||||
@@ -118,8 +98,7 @@ tsl::elm::ListItem* ValueChoiceGui::createValueListItem(std::uint32_t value, boo
|
|||||||
else if (selected)
|
else if (selected)
|
||||||
listItem->setValueColor(tsl::infoTextColor);
|
listItem->setValueColor(tsl::infoTextColor);
|
||||||
|
|
||||||
listItem->setClickListener([this, value](u64 keys)
|
listItem->setClickListener([this, value](u64 keys) {
|
||||||
{
|
|
||||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
||||||
if (this->listener(value)) {
|
if (this->listener(value)) {
|
||||||
tsl::goBack();
|
tsl::goBack();
|
||||||
@@ -131,16 +110,14 @@ tsl::elm::ListItem* ValueChoiceGui::createValueListItem(std::uint32_t value, boo
|
|||||||
return listItem;
|
return listItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsl::elm::ListItem* ValueChoiceGui::createNamedValueListItem(const NamedValue& namedValue, bool selected, int safety)
|
tsl::elm::ListItem *ValueChoiceGui::createNamedValueListItem(const NamedValue &namedValue, bool selected, int safety) {
|
||||||
{
|
|
||||||
std::string text = namedValue.name;
|
std::string text = namedValue.name;
|
||||||
if (selected) {
|
if (selected) {
|
||||||
const_cast<std::string &>(namedValue.rightText) = "\uE14B";
|
const_cast<std::string &>(namedValue.rightText) = "\uE14B";
|
||||||
}
|
}
|
||||||
|
|
||||||
tsl::elm::ListItem *listItem = new tsl::elm::ListItem(text, namedValue.rightText, false);
|
tsl::elm::ListItem *listItem = new tsl::elm::ListItem(text, namedValue.rightText, false);
|
||||||
switch (safety)
|
switch (safety) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
||||||
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
||||||
@@ -160,8 +137,7 @@ tsl::elm::ListItem* ValueChoiceGui::createNamedValueListItem(const NamedValue& n
|
|||||||
else if (selected)
|
else if (selected)
|
||||||
listItem->setValueColor(tsl::infoTextColor);
|
listItem->setValueColor(tsl::infoTextColor);
|
||||||
|
|
||||||
listItem->setClickListener([this, value = namedValue.value](u64 keys)
|
listItem->setClickListener([this, value = namedValue.value](u64 keys) {
|
||||||
{
|
|
||||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
||||||
if (this->listener(value)) {
|
if (this->listener(value)) {
|
||||||
tsl::goBack();
|
tsl::goBack();
|
||||||
@@ -173,8 +149,7 @@ tsl::elm::ListItem* ValueChoiceGui::createNamedValueListItem(const NamedValue& n
|
|||||||
return listItem;
|
return listItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValueChoiceGui::listUI()
|
void ValueChoiceGui::listUI() {
|
||||||
{
|
|
||||||
if (!categoryName.empty()) {
|
if (!categoryName.empty()) {
|
||||||
this->listElement->addItem(new tsl::elm::CategoryHeader(categoryName));
|
this->listElement->addItem(new tsl::elm::CategoryHeader(categoryName));
|
||||||
}
|
}
|
||||||
@@ -189,8 +164,7 @@ void ValueChoiceGui::listUI()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (namedValues.empty()) {
|
if (namedValues.empty()) {
|
||||||
for (std::uint32_t value = range.min; value <= range.max; value += range.step)
|
for (std::uint32_t value = range.min; value <= range.max; value += range.step) {
|
||||||
{
|
|
||||||
int safety = getSafetyLevel(value);
|
int safety = getSafetyLevel(value);
|
||||||
bool selected = (value == this->selectedValue);
|
bool selected = (value == this->selectedValue);
|
||||||
this->listElement->addItem(this->createValueListItem(value, selected, safety));
|
this->listElement->addItem(this->createValueListItem(value, selected, safety));
|
||||||
|
|||||||
@@ -17,11 +17,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <list>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base_menu_gui.h"
|
#include "base_menu_gui.h"
|
||||||
|
|
||||||
using ValueChoiceListener = std::function<bool(std::uint32_t value)>;
|
using ValueChoiceListener = std::function<bool(std::uint32_t value)>;
|
||||||
@@ -34,19 +35,19 @@ struct ValueRange {
|
|||||||
std::string suffix;
|
std::string suffix;
|
||||||
std::uint32_t divisor;
|
std::uint32_t divisor;
|
||||||
int decimalPlaces;
|
int decimalPlaces;
|
||||||
ValueRange()
|
ValueRange() : min(0), max(0), step(1), suffix(""), divisor(1), decimalPlaces(0) {
|
||||||
: min(0), max(0), step(1), suffix(""), divisor(1), decimalPlaces(0) {}
|
}
|
||||||
ValueRange(std::uint32_t min, std::uint32_t max, std::uint32_t step,
|
ValueRange(std::uint32_t min, std::uint32_t max, std::uint32_t step, const std::string &suffix = "", std::uint32_t divisor = 1,
|
||||||
const std::string& suffix = "", std::uint32_t divisor = 1, int decimalPlaces = 0)
|
int decimalPlaces = 0)
|
||||||
: min(min), max(max), step(step), suffix(suffix),
|
: min(min), max(max), step(step), suffix(suffix), divisor(divisor), decimalPlaces(decimalPlaces) {
|
||||||
divisor(divisor), decimalPlaces(decimalPlaces) {}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ValueThresholds {
|
struct ValueThresholds {
|
||||||
std::uint32_t warning;
|
std::uint32_t warning;
|
||||||
std::uint32_t danger;
|
std::uint32_t danger;
|
||||||
ValueThresholds(std::uint32_t warning = 0, std::uint32_t danger = 0)
|
ValueThresholds(std::uint32_t warning = 0, std::uint32_t danger = 0) : warning(warning), danger(danger) {
|
||||||
: warning(warning), danger(danger) {}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NamedValue {
|
struct NamedValue {
|
||||||
@@ -54,12 +55,11 @@ struct NamedValue {
|
|||||||
std::uint32_t value;
|
std::uint32_t value;
|
||||||
std::string rightText;
|
std::string rightText;
|
||||||
|
|
||||||
NamedValue(const std::string& name, std::uint32_t value, const std::string& rightText = "")
|
NamedValue(const std::string &name, std::uint32_t value, const std::string &rightText = "") : name(name), value(value), rightText(rightText) {
|
||||||
: name(name), value(value), rightText(rightText) {}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ValueChoiceGui : public BaseMenuGui
|
class ValueChoiceGui : public BaseMenuGui {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
std::uint32_t selectedValue;
|
std::uint32_t selectedValue;
|
||||||
ValueRange range;
|
ValueRange range;
|
||||||
@@ -78,35 +78,25 @@ protected:
|
|||||||
int getSafetyLevel(std::uint32_t value);
|
int getSafetyLevel(std::uint32_t value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ValueChoiceGui(std::uint32_t selectedValue,
|
ValueChoiceGui(std::uint32_t selectedValue, const ValueRange &range, const std::string &categoryName, ValueChoiceListener listener,
|
||||||
const ValueRange& range,
|
const ValueThresholds &thresholds = ValueThresholds(), bool enableThresholds = false,
|
||||||
const std::string& categoryName,
|
std::map<std::uint32_t, std::string> labels = {}, std::vector<NamedValue> namedValues = {}, bool showDefaultValue = true,
|
||||||
ValueChoiceListener listener,
|
|
||||||
const ValueThresholds& thresholds = ValueThresholds(),
|
|
||||||
bool enableThresholds = false,
|
|
||||||
std::map<std::uint32_t, std::string> labels = {},
|
|
||||||
std::vector<NamedValue> namedValues = {},
|
|
||||||
bool showDefaultValue = true,
|
|
||||||
bool showDNO = false);
|
bool showDNO = false);
|
||||||
~ValueChoiceGui();
|
~ValueChoiceGui();
|
||||||
|
|
||||||
void addNamedValue(const std::string& name, std::uint32_t value, const std::string& rightText = "")
|
void addNamedValue(const std::string &name, std::uint32_t value, const std::string &rightText = "") {
|
||||||
{
|
|
||||||
namedValues.emplace_back(name, value, rightText);
|
namedValues.emplace_back(name, value, rightText);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addNamedValues(const std::vector<NamedValue>& values)
|
void addNamedValues(const std::vector<NamedValue> &values) {
|
||||||
{
|
|
||||||
namedValues.insert(namedValues.end(), values.begin(), values.end());
|
namedValues.insert(namedValues.end(), values.begin(), values.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearNamedValues()
|
void clearNamedValues() {
|
||||||
{
|
|
||||||
namedValues.clear();
|
namedValues.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setShowDefaultValue(bool show)
|
void setShowDefaultValue(bool show) {
|
||||||
{
|
|
||||||
showDefaultValue = show;
|
showDefaultValue = show;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <tesla.hpp>
|
#include <tesla.hpp>
|
||||||
|
|||||||
@@ -24,31 +24,32 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../hos/apm_ext.h"
|
#include <battery.h>
|
||||||
#include <i2c.h>
|
|
||||||
#include <t210.h>
|
|
||||||
#include <max17050.h>
|
|
||||||
#include <tmp451.h>
|
|
||||||
#include <ipc_server.h>
|
|
||||||
#include <lockable_mutex.h>
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
#include <switch.h>
|
#include <i2c.h>
|
||||||
|
#include <max17050.h>
|
||||||
|
#include <notification.h>
|
||||||
#include <pwm.h>
|
#include <pwm.h>
|
||||||
#include <registers.h>
|
#include <registers.h>
|
||||||
#include <battery.h>
|
#include <switch.h>
|
||||||
#include "../display/display_refresh_rate.hpp"
|
#include <t210.h>
|
||||||
#include <notification.h>
|
#include <tmp451.h>
|
||||||
|
|
||||||
|
#include "../display/display_refresh_rate.hpp"
|
||||||
|
#include "../file/file_utils.hpp"
|
||||||
|
#include "../hos/apm_ext.h"
|
||||||
|
#include "../hos/integrations.hpp"
|
||||||
|
#include "../hos/rgltr.h"
|
||||||
|
#include "../tsensor/aotag.hpp"
|
||||||
|
#include "../tsensor/soctherm.hpp"
|
||||||
#include "board.hpp"
|
#include "board.hpp"
|
||||||
#include "board_fuse.hpp"
|
#include "board_fuse.hpp"
|
||||||
#include "board_load.hpp"
|
#include "board_load.hpp"
|
||||||
#include "board_volt.hpp"
|
|
||||||
#include "board_misc.hpp"
|
#include "board_misc.hpp"
|
||||||
#include "../tsensor/soctherm.hpp"
|
#include "board_volt.hpp"
|
||||||
#include "../tsensor/aotag.hpp"
|
#include <ipc_server.h>
|
||||||
#include "../hos/integrations.hpp"
|
#include <lockable_mutex.h>
|
||||||
#include "../file/file_utils.hpp"
|
|
||||||
#include "../hos/rgltr.h"
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
u64 clkVirtAddr, dsiVirtAddr, apbVirtAddr, fuseVirtAddr;
|
u64 clkVirtAddr, dsiVirtAddr, apbVirtAddr, fuseVirtAddr;
|
||||||
@@ -189,7 +190,10 @@ namespace board {
|
|||||||
|
|
||||||
StartMiscThread(pwmCheck, &iCon);
|
StartMiscThread(pwmCheck, &iCon);
|
||||||
|
|
||||||
display::DisplayRefreshConfig cfg = {.clkVirtAddr = clkVirtAddr, .dsiVirtAddr = dsiVirtAddr, .isLite = (GetConsoleType() == HocClkConsoleType_Hoag), .isRetroSUPER = integrations::GetRETROSuperStatus()};
|
display::DisplayRefreshConfig cfg = { .clkVirtAddr = clkVirtAddr,
|
||||||
|
.dsiVirtAddr = dsiVirtAddr,
|
||||||
|
.isLite = (GetConsoleType() == HocClkConsoleType_Hoag),
|
||||||
|
.isRetroSUPER = integrations::GetRETROSuperStatus() };
|
||||||
display::Initialize(&cfg);
|
display::Initialize(&cfg);
|
||||||
|
|
||||||
CacheDfllData();
|
CacheDfllData();
|
||||||
@@ -270,4 +274,4 @@ namespace board {
|
|||||||
return false; /* stub for now. */
|
return false; /* stub for now. */
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -26,16 +26,18 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
|
#include "../mapping/mem_map.hpp"
|
||||||
|
#include "board_freq.hpp"
|
||||||
#include "board_fuse.hpp"
|
#include "board_fuse.hpp"
|
||||||
#include "board_load.hpp"
|
#include "board_load.hpp"
|
||||||
#include "board_name.hpp"
|
#include "board_name.hpp"
|
||||||
#include "board_freq.hpp"
|
#include "board_profile.hpp"
|
||||||
#include "board_sensor.hpp"
|
#include "board_sensor.hpp"
|
||||||
#include "board_volt.hpp"
|
#include "board_volt.hpp"
|
||||||
#include "board_profile.hpp"
|
|
||||||
#include "../mapping/mem_map.hpp"
|
|
||||||
#define HOSSVC_HAS_CLKRST (hosversionAtLeast(8, 0, 0))
|
#define HOSSVC_HAS_CLKRST (hosversionAtLeast(8, 0, 0))
|
||||||
#define HOSSVC_HAS_TC (hosversionAtLeast(5, 0, 0))
|
#define HOSSVC_HAS_TC (hosversionAtLeast(5, 0, 0))
|
||||||
|
|
||||||
@@ -58,4 +60,4 @@ namespace board {
|
|||||||
FuseData *GetFuseData();
|
FuseData *GetFuseData();
|
||||||
bool IsUsingRetroSuperDisplay();
|
bool IsUsingRetroSuperDisplay();
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -24,24 +24,25 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
#include "../hos/apm_ext.h"
|
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include "../i2c/i2cDrv.h"
|
|
||||||
#include <t210.h>
|
|
||||||
#include <max17050.h>
|
#include <max17050.h>
|
||||||
|
#include <switch.h>
|
||||||
|
#include <t210.h>
|
||||||
#include <tmp451.h>
|
#include <tmp451.h>
|
||||||
#include <ipc_server.h>
|
|
||||||
#include <lockable_mutex.h>
|
|
||||||
#include "../display/display_refresh_rate.hpp"
|
#include "../display/display_refresh_rate.hpp"
|
||||||
|
#include "../file/config.hpp"
|
||||||
|
#include "../file/errors.hpp"
|
||||||
|
#include "../hos/apm_ext.h"
|
||||||
|
#include "../i2c/i2cDrv.h"
|
||||||
|
#include "../soc/gm20b.hpp"
|
||||||
|
#include "../soc/pllmb.hpp"
|
||||||
#include "board.hpp"
|
#include "board.hpp"
|
||||||
#include "board_name.hpp"
|
#include "board_name.hpp"
|
||||||
#include "../file/errors.hpp"
|
#include <ipc_server.h>
|
||||||
#include "../soc/pllmb.hpp"
|
#include <lockable_mutex.h>
|
||||||
#include "../file/config.hpp"
|
|
||||||
#include "../soc/gm20b.hpp"
|
|
||||||
#include "../file/config.hpp"
|
|
||||||
namespace board {
|
namespace board {
|
||||||
static u32 currentInjectedHz = 0;
|
static u32 currentInjectedHz = 0;
|
||||||
static u32 gMarikoGm20bCutoff = 1228800000;
|
static u32 gMarikoGm20bCutoff = 1228800000;
|
||||||
@@ -80,12 +81,12 @@ namespace board {
|
|||||||
ASSERT_RESULT_OK(pcvSetClockRate(moduleID, hz), "pcvSetClockRate");
|
ASSERT_RESULT_OK(pcvSetClockRate(moduleID, hz), "pcvSetClockRate");
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleCpuUv()
|
void HandleCpuUv() {
|
||||||
{
|
|
||||||
if (board::GetSocType() == HocClkSocType_Erista)
|
if (board::GetSocType() == HocClkSocType_Erista)
|
||||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000); // Erista tbreak is always 1581MHz
|
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000); // Erista tbreak is always 1581MHz
|
||||||
else
|
else
|
||||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh),
|
||||||
|
board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetHz(HocClkModule module, u32 hz) {
|
void SetHz(HocClkModule module, u32 hz) {
|
||||||
@@ -101,7 +102,8 @@ namespace board {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool useGm20b = (module == HocClkModule_GPU) && (GetSocType() == HocClkSocType_Mariko) && (hz % 38400000 == 0) && (hz % 76800000 != 0) && hz < gMarikoGm20bCutoff;
|
bool useGm20b = (module == HocClkModule_GPU) && (GetSocType() == HocClkSocType_Mariko) && (hz % 38400000 == 0) && (hz % 76800000 != 0) &&
|
||||||
|
hz < gMarikoGm20bCutoff;
|
||||||
|
|
||||||
u32 pcvHz = useGm20b ? ((hz + 76800000 - 1) / 76800000) * 76800000 : hz;
|
u32 pcvHz = useGm20b ? ((hz + 76800000 - 1) / 76800000) * 76800000 : hz;
|
||||||
|
|
||||||
@@ -181,7 +183,9 @@ namespace board {
|
|||||||
case HocClkModule_GPU:
|
case HocClkModule_GPU:
|
||||||
return t210ClkGpuFreq();
|
return t210ClkGpuFreq();
|
||||||
case HocClkModule_MEM:
|
case HocClkModule_MEM:
|
||||||
return config::GetConfigValue(HocClkConfigValue_MemoryFrequencyMeasurementMode) == MemoryFrequencyMeasurementMode_PLL ? pllmb::getRamClockRatePLLMB() : t210ClkMemFreq();
|
return config::GetConfigValue(HocClkConfigValue_MemoryFrequencyMeasurementMode) == MemoryFrequencyMeasurementMode_PLL
|
||||||
|
? pllmb::getRamClockRatePLLMB()
|
||||||
|
: t210ClkMemFreq();
|
||||||
case HocClkModule_Display:
|
case HocClkModule_Display:
|
||||||
return GetDisplayRate(hz);
|
return GetDisplayRate(hz);
|
||||||
default:
|
default:
|
||||||
@@ -197,7 +201,6 @@ namespace board {
|
|||||||
s32 tmpInMaxCount = maxCount;
|
s32 tmpInMaxCount = maxCount;
|
||||||
s32 tmpOutCount = 0;
|
s32 tmpOutCount = 0;
|
||||||
|
|
||||||
|
|
||||||
if (HOSSVC_HAS_CLKRST) {
|
if (HOSSVC_HAS_CLKRST) {
|
||||||
ClkrstSession session = {};
|
ClkrstSession session = {};
|
||||||
|
|
||||||
@@ -263,4 +266,4 @@ namespace board {
|
|||||||
void ResetToStockDisplay() {
|
void ResetToStockDisplay() {
|
||||||
display::SetRate(60);
|
display::SetRate(60);
|
||||||
}
|
}
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -25,16 +25,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <switch.h>
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
#include "../hos/apm_ext.h"
|
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <t210.h>
|
|
||||||
#include <max17050.h>
|
#include <max17050.h>
|
||||||
|
#include <switch.h>
|
||||||
|
#include <t210.h>
|
||||||
#include <tmp451.h>
|
#include <tmp451.h>
|
||||||
|
|
||||||
|
#include "../file/errors.hpp"
|
||||||
|
#include "../hos/apm_ext.h"
|
||||||
#include <ipc_server.h>
|
#include <ipc_server.h>
|
||||||
#include <lockable_mutex.h>
|
#include <lockable_mutex.h>
|
||||||
#include "../file/errors.hpp"
|
|
||||||
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
@@ -50,8 +52,7 @@ namespace board {
|
|||||||
void ResetToStock();
|
void ResetToStock();
|
||||||
void ResetToStockDisplay();
|
void ResetToStockDisplay();
|
||||||
|
|
||||||
template <typename Getter>
|
template <typename Getter> void ResetToStockModule(Getter getHzFunc, HocClkModule module) {
|
||||||
void ResetToStockModule(Getter getHzFunc, HocClkModule module) {
|
|
||||||
Result rc = 0;
|
Result rc = 0;
|
||||||
|
|
||||||
if (hosversionAtLeast(9, 0, 0)) {
|
if (hosversionAtLeast(9, 0, 0)) {
|
||||||
@@ -95,4 +96,4 @@ namespace board {
|
|||||||
ResetToStockModule([](const HocClkApmConfiguration &cfg) { return cfg.mem_hz; }, HocClkModule_MEM);
|
ResetToStockModule([](const HocClkApmConfiguration &cfg) { return cfg.mem_hz; }, HocClkModule_MEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -15,11 +15,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <fuse.h>
|
|
||||||
#include "board_fuse.hpp"
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <fuse.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
#include "board.hpp"
|
#include "board.hpp"
|
||||||
|
#include "board_fuse.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
@@ -78,4 +80,4 @@ namespace board {
|
|||||||
speedo.waferX = (speedo.waferX & BIT(8)) ? (speedo.waferX - 512) : speedo.waferX;
|
speedo.waferX = (speedo.waferX & BIT(8)) ? (speedo.waferX - 512) : speedo.waferX;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -37,4 +37,4 @@ namespace board {
|
|||||||
void ReadFuses(FuseData &speedo, u64 fuseVa);
|
void ReadFuses(FuseData &speedo, u64 fuseVa);
|
||||||
void SetGpuBracket(u16 gpuSpeedo, u8 &gpuBracket);
|
void SetGpuBracket(u16 gpuSpeedo, u8 &gpuBracket);
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -24,22 +24,24 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <switch.h>
|
#include <algorithm>
|
||||||
|
#include <battery.h>
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
#include "../hos/apm_ext.h"
|
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <t210.h>
|
#include <math.h>
|
||||||
#include <max17050.h>
|
#include <max17050.h>
|
||||||
|
#include <minIni.h>
|
||||||
|
#include <numeric>
|
||||||
|
#include <switch.h>
|
||||||
|
#include <t210.h>
|
||||||
#include <tmp451.h>
|
#include <tmp451.h>
|
||||||
|
|
||||||
|
#include "../hos/apm_ext.h"
|
||||||
|
#include "board.hpp"
|
||||||
|
#include "board_misc.hpp"
|
||||||
#include <ipc_server.h>
|
#include <ipc_server.h>
|
||||||
#include <lockable_mutex.h>
|
#include <lockable_mutex.h>
|
||||||
#include <algorithm>
|
|
||||||
#include <math.h>
|
|
||||||
#include <numeric>
|
|
||||||
#include <minIni.h>
|
|
||||||
#include <battery.h>
|
|
||||||
#include "board_misc.hpp"
|
|
||||||
#include "board.hpp"
|
|
||||||
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
@@ -65,7 +67,8 @@ namespace board {
|
|||||||
#define NVGPU_GPU_IOCTL_PMU_GET_GPU_LOAD 0x80044715
|
#define NVGPU_GPU_IOCTL_PMU_GET_GPU_LOAD 0x80044715
|
||||||
uint32_t gpu_load_array[gpu_samples_average] = { 0 };
|
uint32_t gpu_load_array[gpu_samples_average] = { 0 };
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
if (R_SUCCEEDED(nvCheck_load)) do {
|
if (R_SUCCEEDED(nvCheck_load))
|
||||||
|
do {
|
||||||
u32 temp;
|
u32 temp;
|
||||||
if (R_SUCCEEDED(nvIoctl(_fd, NVGPU_GPU_IOCTL_PMU_GET_GPU_LOAD, &temp))) {
|
if (R_SUCCEEDED(nvIoctl(_fd, NVGPU_GPU_IOCTL_PMU_GET_GPU_LOAD, &temp))) {
|
||||||
gpu_load_array[i++ % gpu_samples_average] = temp;
|
gpu_load_array[i++ % gpu_samples_average] = temp;
|
||||||
@@ -150,7 +153,7 @@ namespace board {
|
|||||||
namespace {
|
namespace {
|
||||||
constexpr u32 NVschedCtrlEnable = 0x00000601;
|
constexpr u32 NVschedCtrlEnable = 0x00000601;
|
||||||
constexpr u32 NVschedCtrlDisable = 0x00000602;
|
constexpr u32 NVschedCtrlDisable = 0x00000602;
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
void SetGpuSchedulingMode(GpuSchedulingMode mode, GpuSchedulingOverrideMethod method) {
|
void SetGpuSchedulingMode(GpuSchedulingMode mode, GpuSchedulingOverrideMethod method) {
|
||||||
if (R_FAILED(nvCheckSched) && method == GpuSchedulingOverrideMethod_NvService) {
|
if (R_FAILED(nvCheckSched) && method == GpuSchedulingOverrideMethod_NvService) {
|
||||||
@@ -160,7 +163,8 @@ namespace board {
|
|||||||
u32 temp;
|
u32 temp;
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case GpuSchedulingMode_DoNotOverride: break;
|
case GpuSchedulingMode_DoNotOverride:
|
||||||
|
break;
|
||||||
case GpuSchedulingMode_Disabled:
|
case GpuSchedulingMode_Disabled:
|
||||||
if (method == GpuSchedulingOverrideMethod_NvService) {
|
if (method == GpuSchedulingOverrideMethod_NvService) {
|
||||||
nvIoctl(_fd2, NVschedCtrlDisable, &temp);
|
nvIoctl(_fd2, NVschedCtrlDisable, &temp);
|
||||||
@@ -198,4 +202,4 @@ namespace board {
|
|||||||
nvCheckSched = nvSched;
|
nvCheckSched = nvSched;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -25,8 +25,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <switch.h>
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
@@ -37,4 +38,4 @@ namespace board {
|
|||||||
void SchedSetFD2(u32 fd2);
|
void SchedSetFD2(u32 fd2);
|
||||||
void NvSchedSucceed(Result nvSched);
|
void NvSchedSucceed(Result nvSched);
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -24,9 +24,9 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <pwm.h>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <pwm.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
@@ -68,4 +68,4 @@ namespace board {
|
|||||||
threadClose(&miscThread);
|
threadClose(&miscThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -26,9 +26,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
#include <pwm.h>
|
#include <pwm.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
@@ -36,4 +36,4 @@ namespace board {
|
|||||||
void ExitMiscThread();
|
void ExitMiscThread();
|
||||||
u8 GetFanLevel();
|
u8 GetFanLevel();
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -24,8 +24,9 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
#include "board.hpp"
|
#include "board.hpp"
|
||||||
|
|
||||||
namespace board {
|
namespace board {
|
||||||
@@ -50,4 +51,4 @@ namespace board {
|
|||||||
return hocclkFormatPowerSensor(sensor, pretty);
|
return hocclkFormatPowerSensor(sensor, pretty);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -25,8 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <switch.h>
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
@@ -35,4 +35,4 @@ namespace board {
|
|||||||
const char *GetThermalSensorName(HocClkThermalSensor sensor, bool pretty);
|
const char *GetThermalSensorName(HocClkThermalSensor sensor, bool pretty);
|
||||||
const char *GetPowerSensorName(HocClkPowerSensor sensor, bool pretty);
|
const char *GetPowerSensorName(HocClkPowerSensor sensor, bool pretty);
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -24,16 +24,17 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
#include "../hos/apm_ext.h"
|
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <t210.h>
|
|
||||||
#include <max17050.h>
|
#include <max17050.h>
|
||||||
|
#include <switch.h>
|
||||||
|
#include <t210.h>
|
||||||
#include <tmp451.h>
|
#include <tmp451.h>
|
||||||
|
|
||||||
|
#include "../hos/apm_ext.h"
|
||||||
|
#include "board.hpp"
|
||||||
#include <ipc_server.h>
|
#include <ipc_server.h>
|
||||||
#include <lockable_mutex.h>
|
#include <lockable_mutex.h>
|
||||||
#include "board.hpp"
|
|
||||||
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
@@ -60,4 +61,4 @@ namespace board {
|
|||||||
return HocClkProfile_Handheld;
|
return HocClkProfile_Handheld;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -28,7 +28,5 @@
|
|||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
HocClkProfile GetProfile();
|
HocClkProfile GetProfile();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,24 +24,26 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <hocclk.h>
|
|
||||||
#include <switch.h>
|
|
||||||
#include "../hos/apm_ext.h"
|
|
||||||
#include <i2c.h>
|
|
||||||
#include "../i2c/i2cDrv.h"
|
|
||||||
#include <t210.h>
|
|
||||||
#include <max17050.h>
|
|
||||||
#include <tmp451.h>
|
|
||||||
#include <ipc_server.h>
|
|
||||||
#include <lockable_mutex.h>
|
|
||||||
#include <cmath>
|
|
||||||
#include <battery.h>
|
#include <battery.h>
|
||||||
|
#include <cmath>
|
||||||
|
#include <hocclk.h>
|
||||||
|
#include <i2c.h>
|
||||||
|
#include <max17050.h>
|
||||||
#include <pwm.h>
|
#include <pwm.h>
|
||||||
#include "board.hpp"
|
#include <switch.h>
|
||||||
#include "../tsensor/soctherm.hpp"
|
#include <t210.h>
|
||||||
|
#include <tmp451.h>
|
||||||
|
|
||||||
|
#include "../file/config.hpp"
|
||||||
|
#include "../hos/apm_ext.h"
|
||||||
|
#include "../i2c/i2cDrv.h"
|
||||||
#include "../tsensor/aotag.hpp"
|
#include "../tsensor/aotag.hpp"
|
||||||
#include "../tsensor/bq24193.hpp"
|
#include "../tsensor/bq24193.hpp"
|
||||||
#include "../file/config.hpp"
|
#include "../tsensor/soctherm.hpp"
|
||||||
|
#include "board.hpp"
|
||||||
|
#include <ipc_server.h>
|
||||||
|
#include <lockable_mutex.h>
|
||||||
|
|
||||||
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
@@ -127,4 +129,4 @@ namespace board {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -33,4 +33,4 @@ namespace board {
|
|||||||
s32 GetTemperatureMilli(HocClkThermalSensor sensor);
|
s32 GetTemperatureMilli(HocClkThermalSensor sensor);
|
||||||
s32 GetPowerMw(HocClkPowerSensor sensor);
|
s32 GetPowerMw(HocClkPowerSensor sensor);
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -17,18 +17,20 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <switch.h>
|
#include <battery.h>
|
||||||
|
#include <cstring>
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
#include <memmem.h>
|
#include <memmem.h>
|
||||||
#include <registers.h>
|
#include <registers.h>
|
||||||
#include <cstring>
|
#include <switch.h>
|
||||||
#include <battery.h>
|
|
||||||
|
#include "../file/file_utils.hpp"
|
||||||
|
#include "../hos/rgltr.h"
|
||||||
|
#include "../i2c/i2cDrv.h"
|
||||||
#include "board.hpp"
|
#include "board.hpp"
|
||||||
#include "board_freq.hpp"
|
#include "board_freq.hpp"
|
||||||
#include "board_volt.hpp"
|
#include "board_volt.hpp"
|
||||||
#include "../file/file_utils.hpp"
|
|
||||||
#include "../i2c/i2cDrv.h"
|
|
||||||
#include "../hos/rgltr.h"
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
GpuVoltData voltData = {};
|
GpuVoltData voltData = {};
|
||||||
@@ -50,54 +52,30 @@ namespace board {
|
|||||||
u32 tune1_high;
|
u32 tune1_high;
|
||||||
};
|
};
|
||||||
|
|
||||||
EristaCpuUvEntry eristaCpuUvTableLowBracket[6] = { // <2118 CPU speedo
|
EristaCpuUvEntry eristaCpuUvTableLowBracket[6] = {
|
||||||
{0xFFEAD0FF, 0x25501d0},
|
// <2118 CPU speedo
|
||||||
{0xffff, 0x27007ff},
|
{ 0xFFEAD0FF, 0x25501d0 }, { 0xffff, 0x27007ff }, { 0xefff, 0x27407ff },
|
||||||
{0xefff, 0x27407ff},
|
{ 0xdfff, 0x27807ff }, { 0xdfdf, 0x27a07ff }, { 0xcfdf, 0x37007ff },
|
||||||
{0xdfff, 0x27807ff},
|
|
||||||
{0xdfdf, 0x27a07ff},
|
|
||||||
{0xcfdf, 0x37007ff},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EristaCpuUvEntry eristaCpuUvTableHighBracket[6] = {
|
EristaCpuUvEntry eristaCpuUvTableHighBracket[6] = {
|
||||||
{0xFFEAD0FF, 0x20091d9},
|
{ 0xFFEAD0FF, 0x20091d9 }, { 0xffff, 0x27007ff }, { 0xefff, 0x27407ff },
|
||||||
{0xffff, 0x27007ff},
|
{ 0xdfff, 0x27807ff }, { 0xdfdf, 0x27a07ff }, { 0xcfdf, 0x37007ff },
|
||||||
{0xefff, 0x27407ff},
|
|
||||||
{0xdfff, 0x27807ff},
|
|
||||||
{0xdfdf, 0x27a07ff},
|
|
||||||
{0xcfdf, 0x37007ff},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MarikoCpuUvEntry marikoCpuUvLow[12] = {
|
MarikoCpuUvEntry marikoCpuUvLow[12] = {
|
||||||
{0xffa0, 0xffff, 0x21107ff, 0},
|
{ 0xffa0, 0xffff, 0x21107ff, 0 }, { 0x0, 0xffdf, 0x21107ff, 0x27207ff }, { 0xffdf, 0xffdf, 0x21107ff, 0x27307ff },
|
||||||
{0x0, 0xffdf, 0x21107ff, 0x27207ff},
|
{ 0xffff, 0xffdf, 0x21107ff, 0x27407ff }, { 0x0, 0xffdf, 0x21607ff, 0x27707ff }, { 0x0, 0xffdf, 0x21607ff, 0x27807ff },
|
||||||
{0xffdf, 0xffdf, 0x21107ff, 0x27307ff},
|
{ 0x0, 0xdfff, 0x21607ff, 0x27b07ff }, { 0xdfff, 0xdfff, 0x21707ff, 0x27b07ff }, { 0xdfff, 0xdfff, 0x21707ff, 0x27c07ff },
|
||||||
{0xffff, 0xffdf, 0x21107ff, 0x27407ff},
|
{ 0xdfff, 0xdfff, 0x21707ff, 0x27d07ff }, { 0xdfff, 0xdfff, 0x21707ff, 0x27e07ff }, { 0xdfff, 0xdfff, 0x21707ff, 0x27f07ff },
|
||||||
{0x0, 0xffdf, 0x21607ff, 0x27707ff},
|
|
||||||
{0x0, 0xffdf, 0x21607ff, 0x27807ff},
|
|
||||||
{0x0, 0xdfff, 0x21607ff, 0x27b07ff},
|
|
||||||
{0xdfff, 0xdfff, 0x21707ff, 0x27b07ff},
|
|
||||||
{0xdfff, 0xdfff, 0x21707ff, 0x27c07ff},
|
|
||||||
{0xdfff, 0xdfff, 0x21707ff, 0x27d07ff},
|
|
||||||
{0xdfff, 0xdfff, 0x21707ff, 0x27e07ff},
|
|
||||||
{0xdfff, 0xdfff, 0x21707ff, 0x27f07ff},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MarikoCpuUvEntry marikoCpuUvHigh[12] = {
|
MarikoCpuUvEntry marikoCpuUvHigh[12] = {
|
||||||
{0x0, 0xffff, 0, 0},
|
{ 0x0, 0xffff, 0, 0 }, { 0x0, 0xffdf, 0, 0x27207ff }, { 0x0, 0xffdf, 0, 0x27307ff }, { 0x0, 0xffdf, 0, 0x27407ff },
|
||||||
{0x0, 0xffdf, 0, 0x27207ff},
|
{ 0x0, 0xffdf, 0, 0x27707ff }, { 0x0, 0xffdf, 0, 0x27807ff }, { 0x0, 0xdfff, 0, 0x27b07ff }, { 0x0, 0xdfff, 0, 0x27c07ff },
|
||||||
{0x0, 0xffdf, 0, 0x27307ff},
|
{ 0x0, 0xdfff, 0, 0x27d07ff }, { 0x0, 0xdfff, 0, 0x27e07ff }, { 0x0, 0xdfff, 0, 0x27f07ff }, { 0x0, 0xdfff, 0, 0x27f07ff },
|
||||||
{0x0, 0xffdf, 0, 0x27407ff},
|
|
||||||
{0x0, 0xffdf, 0, 0x27707ff},
|
|
||||||
{0x0, 0xffdf, 0, 0x27807ff},
|
|
||||||
{0x0, 0xdfff, 0, 0x27b07ff},
|
|
||||||
{0x0, 0xdfff, 0, 0x27c07ff},
|
|
||||||
{0x0, 0xdfff, 0, 0x27d07ff},
|
|
||||||
{0x0, 0xdfff, 0, 0x27e07ff},
|
|
||||||
{0x0, 0xdfff, 0, 0x27f07ff},
|
|
||||||
{0x0, 0xdfff, 0, 0x27f07ff},
|
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
void CacheDfllData() {
|
void CacheDfllData() {
|
||||||
Result rc = QueryMemoryMapping(&cldvfs, CLDVFS_REGION_BASE, CLDVFS_REGION_SIZE);
|
Result rc = QueryMemoryMapping(&cldvfs, CLDVFS_REGION_BASE, CLDVFS_REGION_SIZE);
|
||||||
@@ -422,33 +400,48 @@ namespace board {
|
|||||||
u32 baseVolt = 800;
|
u32 baseVolt = 800;
|
||||||
if (GetSocType() == HocClkSocType_Mariko) {
|
if (GetSocType() == HocClkSocType_Mariko) {
|
||||||
static const u32 ramTable[][22] = {
|
static const u32 ramTable[][22] = {
|
||||||
{ 2133, 2200, 2266, 2300, 2366, 2400, 2433, 2466, 2533, 2566, 2600, 2633, 2700, 2733, 2766, 2833, 2866, 2900, 2933, 3033, 3066, 3100, }, // Bracket 0
|
{
|
||||||
{ 2300, 2366, 2433, 2466, 2533, 2566, 2633, 2700, 2733, 2800, 2833, 2900, 2933, 2966, 3033, 3066, 3100, 3133, 3166, 3200, 3233, 3266, }, // Bracket 1
|
2133, 2200, 2266, 2300, 2366, 2400, 2433, 2466, 2533, 2566, 2600,
|
||||||
{ 2433, 2466, 2533, 2566, 2600, 2666, 2766, 2800, 2833, 2866, 2933, 2966, 3033, 3066, 3100, 3133, 3166, 3200, 3233, 3300, 3333, 3366, }, // Bracket 2
|
2633, 2700, 2733, 2766, 2833, 2866, 2900, 2933, 3033, 3066, 3100,
|
||||||
{ 2500, 2533, 2600, 2633, 2666, 2733, 2800, 2866, 2900, 2966, 3033, 3100, 3166, 3200, 3233, 3266, 3300, 3333, 3366, 3400, 3400, 3400, }, // Bracket 3
|
}, // Bracket 0
|
||||||
|
{
|
||||||
|
2300, 2366, 2433, 2466, 2533, 2566, 2633, 2700, 2733, 2800, 2833,
|
||||||
|
2900, 2933, 2966, 3033, 3066, 3100, 3133, 3166, 3200, 3233, 3266,
|
||||||
|
}, // Bracket 1
|
||||||
|
{
|
||||||
|
2433, 2466, 2533, 2566, 2600, 2666, 2766, 2800, 2833, 2866, 2933,
|
||||||
|
2966, 3033, 3066, 3100, 3133, 3166, 3200, 3233, 3300, 3333, 3366,
|
||||||
|
}, // Bracket 2
|
||||||
|
{
|
||||||
|
2500, 2533, 2600, 2633, 2666, 2733, 2800, 2866, 2900, 2966, 3033,
|
||||||
|
3100, 3166, 3200, 3233, 3266, 3300, 3333, 3366, 3400, 3400, 3400,
|
||||||
|
}, // Bracket 3
|
||||||
};
|
};
|
||||||
|
|
||||||
static const u32 gpuVoltArray[] = { 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, };
|
static const u32 gpuVoltArray[] = {
|
||||||
|
590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800,
|
||||||
|
};
|
||||||
|
|
||||||
if (freqMhz <= 1600) return 0; // DVFS doesnt work below 1600MHz, it will just use vMin
|
if (freqMhz <= 1600)
|
||||||
if (bracket >= std::size(ramTable)) bracket = 0;
|
return 0; // DVFS doesnt work below 1600MHz, it will just use vMin
|
||||||
|
if (bracket >= std::size(ramTable))
|
||||||
|
bracket = 0;
|
||||||
|
|
||||||
u32 bracketStart = ramTable[bracket][0];
|
u32 bracketStart = ramTable[bracket][0];
|
||||||
|
|
||||||
|
|
||||||
u32 rampStartVolt = (bracket == 0) ? 535 : 525; // Do not touch!
|
u32 rampStartVolt = (bracket == 0) ? 535 : 525; // Do not touch!
|
||||||
u32 rampSpan = 590 - rampStartVolt;
|
u32 rampSpan = 590 - rampStartVolt;
|
||||||
|
|
||||||
|
|
||||||
if (freqMhz >= 1633 && freqMhz < bracketStart) {
|
if (freqMhz >= 1633 && freqMhz < bracketStart) {
|
||||||
u32 raw = rampStartVolt + ((freqMhz - 1633) * rampSpan) / (bracketStart - 1633);
|
u32 raw = rampStartVolt + ((freqMhz - 1633) * rampSpan) / (bracketStart - 1633);
|
||||||
u32 volt = ((raw + 2) / 5) * 5;
|
u32 volt = ((raw + 2) / 5) * 5;
|
||||||
if (volt < rampStartVolt) volt = rampStartVolt;
|
if (volt < rampStartVolt)
|
||||||
if (volt > 590) volt = 590;
|
volt = rampStartVolt;
|
||||||
|
if (volt > 590)
|
||||||
|
volt = 590;
|
||||||
return volt;
|
return volt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
baseVolt = gpuVoltArray[std::size(gpuVoltArray) - 1];
|
baseVolt = gpuVoltArray[std::size(gpuVoltArray) - 1];
|
||||||
for (u32 i = 0; i < std::size(gpuVoltArray); ++i) {
|
for (u32 i = 0; i < std::size(gpuVoltArray); ++i) {
|
||||||
if (freqMhz <= ramTable[bracket][i]) {
|
if (freqMhz <= ramTable[bracket][i]) {
|
||||||
@@ -457,16 +450,93 @@ namespace board {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
struct DvfsEntry { u32 freq; u32 volt; };
|
struct DvfsEntry {
|
||||||
|
u32 freq;
|
||||||
|
u32 volt;
|
||||||
|
};
|
||||||
static const DvfsEntry ramTable[][19] = {
|
static const DvfsEntry ramTable[][19] = {
|
||||||
{ {1733,725}, {1800,730}, {1866,735}, {1920,740}, {1958,745}, {1996,750}, {2035,755}, {2073,760}, {2112,765}, {2131,770}, {2150,775}, {2169,780}, {2188,785}, {2227,790}, {2265,795}, {2304,800}, {2342,805}, {2380,810}, {2400,815} }, // Bracket 0
|
{ { 1733, 725 },
|
||||||
{ {1733,715}, {1800,720}, {1866,725}, {1920,730}, {1958,735}, {1996,740}, {2035,745}, {2073,750}, {2112,755}, {2131,760}, {2150,765}, {2169,770}, {2188,775}, {2227,780}, {2265,785}, {2304,790}, {2342,795}, {2380,800}, {2400,805} }, // Bracket 1
|
{ 1800, 730 },
|
||||||
{ {1733,705}, {1800,710}, {1866,715}, {1920,720}, {1958,725}, {1996,730}, {2035,735}, {2073,740}, {2112,745}, {2131,750}, {2150,755}, {2169,760}, {2188,765}, {2227,770}, {2265,775}, {2304,780}, {2342,785}, {2380,790}, {2400,795} }, // Bracket 2
|
{ 1866, 735 },
|
||||||
{ {1733,695}, {1800,700}, {1866,705}, {1920,710}, {1958,715}, {1996,720}, {2035,725}, {2073,730}, {2112,735}, {2131,740}, {2150,745}, {2169,750}, {2188,755}, {2227,760}, {2265,765}, {2304,770}, {2342,775}, {2380,780}, {2400,785} }, // Bracket 3
|
{ 1920, 740 },
|
||||||
|
{ 1958, 745 },
|
||||||
|
{ 1996, 750 },
|
||||||
|
{ 2035, 755 },
|
||||||
|
{ 2073, 760 },
|
||||||
|
{ 2112, 765 },
|
||||||
|
{ 2131, 770 },
|
||||||
|
{ 2150, 775 },
|
||||||
|
{ 2169, 780 },
|
||||||
|
{ 2188, 785 },
|
||||||
|
{ 2227, 790 },
|
||||||
|
{ 2265, 795 },
|
||||||
|
{ 2304, 800 },
|
||||||
|
{ 2342, 805 },
|
||||||
|
{ 2380, 810 },
|
||||||
|
{ 2400, 815 } }, // Bracket 0
|
||||||
|
{ { 1733, 715 },
|
||||||
|
{ 1800, 720 },
|
||||||
|
{ 1866, 725 },
|
||||||
|
{ 1920, 730 },
|
||||||
|
{ 1958, 735 },
|
||||||
|
{ 1996, 740 },
|
||||||
|
{ 2035, 745 },
|
||||||
|
{ 2073, 750 },
|
||||||
|
{ 2112, 755 },
|
||||||
|
{ 2131, 760 },
|
||||||
|
{ 2150, 765 },
|
||||||
|
{ 2169, 770 },
|
||||||
|
{ 2188, 775 },
|
||||||
|
{ 2227, 780 },
|
||||||
|
{ 2265, 785 },
|
||||||
|
{ 2304, 790 },
|
||||||
|
{ 2342, 795 },
|
||||||
|
{ 2380, 800 },
|
||||||
|
{ 2400, 805 } }, // Bracket 1
|
||||||
|
{ { 1733, 705 },
|
||||||
|
{ 1800, 710 },
|
||||||
|
{ 1866, 715 },
|
||||||
|
{ 1920, 720 },
|
||||||
|
{ 1958, 725 },
|
||||||
|
{ 1996, 730 },
|
||||||
|
{ 2035, 735 },
|
||||||
|
{ 2073, 740 },
|
||||||
|
{ 2112, 745 },
|
||||||
|
{ 2131, 750 },
|
||||||
|
{ 2150, 755 },
|
||||||
|
{ 2169, 760 },
|
||||||
|
{ 2188, 765 },
|
||||||
|
{ 2227, 770 },
|
||||||
|
{ 2265, 775 },
|
||||||
|
{ 2304, 780 },
|
||||||
|
{ 2342, 785 },
|
||||||
|
{ 2380, 790 },
|
||||||
|
{ 2400, 795 } }, // Bracket 2
|
||||||
|
{ { 1733, 695 },
|
||||||
|
{ 1800, 700 },
|
||||||
|
{ 1866, 705 },
|
||||||
|
{ 1920, 710 },
|
||||||
|
{ 1958, 715 },
|
||||||
|
{ 1996, 720 },
|
||||||
|
{ 2035, 725 },
|
||||||
|
{ 2073, 730 },
|
||||||
|
{ 2112, 735 },
|
||||||
|
{ 2131, 740 },
|
||||||
|
{ 2150, 745 },
|
||||||
|
{ 2169, 750 },
|
||||||
|
{ 2188, 755 },
|
||||||
|
{ 2227, 760 },
|
||||||
|
{ 2265, 765 },
|
||||||
|
{ 2304, 770 },
|
||||||
|
{ 2342, 775 },
|
||||||
|
{ 2380, 780 },
|
||||||
|
{ 2400, 785 } }, // Bracket 3
|
||||||
};
|
};
|
||||||
|
|
||||||
if (freqMhz <= 1600) return 0; // DVFS doesnt work below 1600MHz, it will just use vMin
|
if (freqMhz <= 1600)
|
||||||
if (bracket >= std::size(ramTable)) bracket = 0;
|
return 0; // DVFS doesnt work below 1600MHz, it will just use vMin
|
||||||
|
if (bracket >= std::size(ramTable))
|
||||||
|
bracket = 0;
|
||||||
|
|
||||||
const auto &entries = ramTable[bracket];
|
const auto &entries = ramTable[bracket];
|
||||||
baseVolt = entries[std::size(entries) - 1].volt;
|
baseVolt = entries[std::size(entries) - 1].volt;
|
||||||
@@ -480,4 +550,4 @@ namespace board {
|
|||||||
|
|
||||||
return baseVolt;
|
return baseVolt;
|
||||||
}
|
}
|
||||||
}
|
} // namespace board
|
||||||
@@ -16,8 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <switch.h>
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
|
|
||||||
namespace board {
|
namespace board {
|
||||||
|
|
||||||
@@ -50,4 +51,4 @@ namespace board {
|
|||||||
void PcvHijackGpuVolts(u32 vmin);
|
void PcvHijackGpuVolts(u32 vmin);
|
||||||
u32 GetMinimumGpuVmin(u32 freqMhz, u32 bracket);
|
u32 GetMinimumGpuVmin(u32 freqMhz, u32 bracket);
|
||||||
|
|
||||||
}
|
} // namespace board
|
||||||
|
|||||||
@@ -40,9 +40,7 @@ namespace AulaDisplay {
|
|||||||
if (mode == AulaDisplayColorMode_DoNotOverride)
|
if (mode == AulaDisplayColorMode_DoNotOverride)
|
||||||
return;
|
return;
|
||||||
// send display command to change color mode.
|
// send display command to change color mode.
|
||||||
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE_PARAM,
|
_display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE_PARAM, MIPI_DCS_PRIV_SM_SET_COLOR_MODE | (mode << 8), 0);
|
||||||
MIPI_DCS_PRIV_SM_SET_COLOR_MODE | (mode << 8), 0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace AulaDisplay
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
#include "../board/board.hpp"
|
#include "../board/board.hpp"
|
||||||
|
|
||||||
namespace AulaDisplay {
|
namespace AulaDisplay {
|
||||||
|
|||||||
@@ -184,7 +184,6 @@
|
|||||||
#define DSI_ENABLE BIT(29)
|
#define DSI_ENABLE BIT(29)
|
||||||
#define HDMI_ENABLE BIT(30)
|
#define HDMI_ENABLE BIT(30)
|
||||||
|
|
||||||
|
|
||||||
#define DC_DISP_DISP_MEM_HIGH_PRIORITY 0x403
|
#define DC_DISP_DISP_MEM_HIGH_PRIORITY 0x403
|
||||||
#define DC_DISP_DISP_MEM_HIGH_PRIORITY_TIMER 0x404
|
#define DC_DISP_DISP_MEM_HIGH_PRIORITY_TIMER 0x404
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "display_refresh_rate.hpp"
|
|
||||||
#include <string.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
|
#include "display_refresh_rate.hpp"
|
||||||
|
|
||||||
namespace display {
|
namespace display {
|
||||||
#define DSI_CLOCK_HZ 234000000llu
|
#define DSI_CLOCK_HZ 234000000llu
|
||||||
#define NVDISP_GET_MODE2 0x803C021B
|
#define NVDISP_GET_MODE2 0x803C021B
|
||||||
@@ -41,7 +42,8 @@ namespace display {
|
|||||||
static bool g_canChangeRefreshRateDocked = false;
|
static bool g_canChangeRefreshRateDocked = false;
|
||||||
static uint8_t g_lastVActiveSet = 0;
|
static uint8_t g_lastVActiveSet = 0;
|
||||||
|
|
||||||
static const uint8_t g_dockedRefreshRates[] = {40, 45, 50, 55, 60, 70, 72, 75, 80, 90, 95, 100, 110, 120, 130, 140, 144, 150, 160, 165, 170, 180, 190, 200, 210, 220, 230, 240};
|
static const uint8_t g_dockedRefreshRates[] = { 40, 45, 50, 55, 60, 70, 72, 75, 80, 90, 95, 100, 110, 120,
|
||||||
|
130, 140, 144, 150, 160, 165, 170, 180, 190, 200, 210, 220, 230, 240 };
|
||||||
// Calculate with this tool:
|
// Calculate with this tool:
|
||||||
|
|
||||||
// https://tomverbeure.github.io/video_timings_calculator?horiz_pixels=1920&vert_pixels=1080&refresh_rate=240&margins=false&interlaced=false&bpc=8&color_fmt=rgb444&video_opt=false&custom_hblank=80&custom_vblank=6
|
// https://tomverbeure.github.io/video_timings_calculator?horiz_pixels=1920&vert_pixels=1080&refresh_rate=240&margins=false&interlaced=false&bpc=8&color_fmt=rgb444&video_opt=false&custom_hblank=80&custom_vblank=6
|
||||||
@@ -119,13 +121,15 @@ namespace display {
|
|||||||
|
|
||||||
static uint8_t _getDockedRefreshRateIterator(uint32_t refreshRate) {
|
static uint8_t _getDockedRefreshRateIterator(uint32_t refreshRate) {
|
||||||
for (size_t i = 0; i < sizeof(g_dockedRefreshRates) / sizeof(g_dockedRefreshRates[0]); i++) {
|
for (size_t i = 0; i < sizeof(g_dockedRefreshRates) / sizeof(g_dockedRefreshRates[0]); i++) {
|
||||||
if (g_dockedRefreshRates[i] == refreshRate) return i;
|
if (g_dockedRefreshRates[i] == refreshRate)
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _changeOledElvssSettings(const uint32_t *offsets, const uint32_t *value, uint32_t size, uint32_t start) {
|
static void _changeOledElvssSettings(const uint32_t *offsets, const uint32_t *value, uint32_t size, uint32_t start) {
|
||||||
if (!g_config.dsiVirtAddr || !value || !size) return;
|
if (!g_config.dsiVirtAddr || !value || !size)
|
||||||
|
return;
|
||||||
|
|
||||||
volatile uint32_t *dsi = (uint32_t *)g_config.dsiVirtAddr;
|
volatile uint32_t *dsi = (uint32_t *)g_config.dsiVirtAddr;
|
||||||
|
|
||||||
@@ -165,7 +169,8 @@ namespace display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Initialize(const DisplayRefreshConfig *config) {
|
bool Initialize(const DisplayRefreshConfig *config) {
|
||||||
if (!config) return false;
|
if (!config)
|
||||||
|
return false;
|
||||||
|
|
||||||
g_config = *config;
|
g_config = *config;
|
||||||
g_initialized = true;
|
g_initialized = true;
|
||||||
@@ -191,17 +196,21 @@ namespace display {
|
|||||||
uint32_t values[] = { 2, 0, 0x83 };
|
uint32_t values[] = { 2, 0, 0x83 };
|
||||||
|
|
||||||
if (refresh_rate == 60) {
|
if (refresh_rate == 60) {
|
||||||
if (last_refresh_rate == 60) return;
|
if (last_refresh_rate == 60)
|
||||||
|
return;
|
||||||
} else if (refresh_rate == 45) {
|
} else if (refresh_rate == 45) {
|
||||||
if (last_refresh_rate == 45) return;
|
if (last_refresh_rate == 45)
|
||||||
|
return;
|
||||||
uint32_t vals[] = { 4, 1, 0 };
|
uint32_t vals[] = { 4, 1, 0 };
|
||||||
memcpy(values, vals, sizeof(vals));
|
memcpy(values, vals, sizeof(vals));
|
||||||
} else if (refresh_rate == 50) {
|
} else if (refresh_rate == 50) {
|
||||||
if (last_refresh_rate == 50) return;
|
if (last_refresh_rate == 50)
|
||||||
|
return;
|
||||||
uint32_t vals[] = { 3, 1, 0 };
|
uint32_t vals[] = { 3, 1, 0 };
|
||||||
memcpy(values, vals, sizeof(vals));
|
memcpy(values, vals, sizeof(vals));
|
||||||
} else if (refresh_rate == 55) {
|
} else if (refresh_rate == 55) {
|
||||||
if (last_refresh_rate == 55) return;
|
if (last_refresh_rate == 55)
|
||||||
|
return;
|
||||||
uint32_t vals[] = { 3, 1, 0 };
|
uint32_t vals[] = { 3, 1, 0 };
|
||||||
memcpy(values, vals, sizeof(vals));
|
memcpy(values, vals, sizeof(vals));
|
||||||
} else {
|
} else {
|
||||||
@@ -228,7 +237,8 @@ namespace display {
|
|||||||
uint8_t highestRefreshRate = 60;
|
uint8_t highestRefreshRate = 60;
|
||||||
uint32_t fd = fd_in;
|
uint32_t fd = fd_in;
|
||||||
|
|
||||||
if(!fd) nvOpen(&fd, "/dev/nvdisp-disp1");
|
if (!fd)
|
||||||
|
nvOpen(&fd, "/dev/nvdisp-disp1");
|
||||||
NvdcModeDB2 db2 = { 0 };
|
NvdcModeDB2 db2 = { 0 };
|
||||||
int rc = nvIoctl(fd, NVDISP_GET_MODE_DB2, &db2);
|
int rc = nvIoctl(fd, NVDISP_GET_MODE_DB2, &db2);
|
||||||
|
|
||||||
@@ -278,12 +288,14 @@ namespace display {
|
|||||||
// highestRefreshRate = 75;
|
// highestRefreshRate = 75;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fd_in) nvClose(fd);
|
if (!fd_in)
|
||||||
|
nvClose(fd);
|
||||||
g_dockedHighestRefreshRate = highestRefreshRate;
|
g_dockedHighestRefreshRate = highestRefreshRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _setPLLDHandheldRefreshRate(uint32_t new_refreshRate) {
|
static bool _setPLLDHandheldRefreshRate(uint32_t new_refreshRate) {
|
||||||
if (!g_config.clkVirtAddr) return false;
|
if (!g_config.clkVirtAddr)
|
||||||
|
return false;
|
||||||
|
|
||||||
uint32_t fd = 0;
|
uint32_t fd = 0;
|
||||||
if (nvOpen(&fd, "/dev/nvdisp-disp0")) {
|
if (nvOpen(&fd, "/dev/nvdisp-disp0")) {
|
||||||
@@ -307,7 +319,8 @@ namespace display {
|
|||||||
|
|
||||||
int rc = nvIoctl(fd, NVDISP_GET_PANEL_DATA, &dpaux);
|
int rc = nvIoctl(fd, NVDISP_GET_PANEL_DATA, &dpaux);
|
||||||
nvClose(fd);
|
nvClose(fd);
|
||||||
if (rc != 0x75c) return false;
|
if (rc != 0x75c)
|
||||||
|
return false;
|
||||||
|
|
||||||
PLLD_BASE base = { 0 };
|
PLLD_BASE base = { 0 };
|
||||||
PLLD_MISC misc = { 0 };
|
PLLD_MISC misc = { 0 };
|
||||||
@@ -315,7 +328,8 @@ namespace display {
|
|||||||
memcpy(&misc, (void *)(g_config.clkVirtAddr + 0xDC), 4);
|
memcpy(&misc, (void *)(g_config.clkVirtAddr + 0xDC), 4);
|
||||||
|
|
||||||
uint32_t value = ((base.PLLD_DIVN / base.PLLD_DIVM) * 10) / 4;
|
uint32_t value = ((base.PLLD_DIVN / base.PLLD_DIVM) * 10) / 4;
|
||||||
if (value == 0 || value == 80) return false;
|
if (value == 0 || value == 80)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (new_refreshRate > g_handheldModeRefreshRate.max) {
|
if (new_refreshRate > g_handheldModeRefreshRate.max) {
|
||||||
new_refreshRate = g_handheldModeRefreshRate.max;
|
new_refreshRate = g_handheldModeRefreshRate.max;
|
||||||
@@ -337,7 +351,8 @@ namespace display {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!skip) new_refreshRate = 60;
|
if (!skip)
|
||||||
|
new_refreshRate = 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t pixelClock = (9375 * ((4096 * ((2 * base.PLLD_DIVN) + 1)) + misc.PLLD_SDM_DIN)) / (8 * base.PLLD_DIVM);
|
uint32_t pixelClock = (9375 * ((4096 * ((2 * base.PLLD_DIVN) + 1)) + misc.PLLD_SDM_DIN)) / (8 * base.PLLD_DIVM);
|
||||||
@@ -380,8 +395,7 @@ namespace display {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!((display_b.vActive == 480 && display_b.hActive == 720) ||
|
if (!((display_b.vActive == 480 && display_b.hActive == 720) || (display_b.vActive == 720 && display_b.hActive == 1280) ||
|
||||||
(display_b.vActive == 720 && display_b.hActive == 1280) ||
|
|
||||||
(display_b.vActive == 1080 && display_b.hActive == 1920))) {
|
(display_b.vActive == 1080 && display_b.hActive == 1920))) {
|
||||||
nvClose(fd);
|
nvClose(fd);
|
||||||
return false;
|
return false;
|
||||||
@@ -426,7 +440,8 @@ namespace display {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itr == -1) itr = _getDockedRefreshRateIterator(60);
|
if (itr == -1)
|
||||||
|
itr = _getDockedRefreshRateIterator(60);
|
||||||
|
|
||||||
// Clamp to highest allowed refresh rate
|
// Clamp to highest allowed refresh rate
|
||||||
if (g_dockedRefreshRates[itr] > g_dockedHighestRefreshRate) {
|
if (g_dockedRefreshRates[itr] > g_dockedHighestRefreshRate) {
|
||||||
@@ -472,7 +487,8 @@ namespace display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool _setNvDispHandheldRefreshRate(uint32_t new_refreshRate) {
|
static bool _setNvDispHandheldRefreshRate(uint32_t new_refreshRate) {
|
||||||
if (!g_config.isRetroSUPER) return false;
|
if (!g_config.isRetroSUPER)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!g_config.displaySync) {
|
if (!g_config.displaySync) {
|
||||||
g_wasRetroSuperTurnedOff = false;
|
g_wasRetroSuperTurnedOff = false;
|
||||||
@@ -529,7 +545,8 @@ namespace display {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!skip) new_refreshRate = 60;
|
if (!skip)
|
||||||
|
new_refreshRate = 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_refreshRate == refreshRateNow) {
|
if (new_refreshRate == refreshRateNow) {
|
||||||
@@ -558,7 +575,8 @@ namespace display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SetRate(uint32_t new_refreshRate) {
|
bool SetRate(uint32_t new_refreshRate) {
|
||||||
if (!new_refreshRate || !g_initialized) return false;
|
if (!new_refreshRate || !g_initialized)
|
||||||
|
return false;
|
||||||
|
|
||||||
uint32_t fd = 0;
|
uint32_t fd = 0;
|
||||||
|
|
||||||
@@ -569,8 +587,7 @@ namespace display {
|
|||||||
else if ((!g_config.isRetroSUPER && g_config.isLite) || R_FAILED(nvOpen(&fd, "/dev/nvdisp-disp1"))) {
|
else if ((!g_config.isRetroSUPER && g_config.isLite) || R_FAILED(nvOpen(&fd, "/dev/nvdisp-disp1"))) {
|
||||||
if (_setPLLDHandheldRefreshRate(new_refreshRate) == false)
|
if (_setPLLDHandheldRefreshRate(new_refreshRate) == false)
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
struct dpaux_read {
|
struct dpaux_read {
|
||||||
uint32_t cmd;
|
uint32_t cmd;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
@@ -606,7 +623,8 @@ namespace display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GetRate(uint32_t *out_refreshRate, bool internal) {
|
bool GetRate(uint32_t *out_refreshRate, bool internal) {
|
||||||
if (!out_refreshRate || !g_initialized || !g_config.clkVirtAddr) return false;
|
if (!out_refreshRate || !g_initialized || !g_config.clkVirtAddr)
|
||||||
|
return false;
|
||||||
static uint32_t value = 60;
|
static uint32_t value = 60;
|
||||||
|
|
||||||
if (g_config.isRetroSUPER && !g_config.isDocked) {
|
if (g_config.isRetroSUPER && !g_config.isDocked) {
|
||||||
@@ -634,8 +652,7 @@ namespace display {
|
|||||||
} else {
|
} else {
|
||||||
g_wasRetroSuperTurnedOff = true;
|
g_wasRetroSuperTurnedOff = true;
|
||||||
}
|
}
|
||||||
}
|
} else if ((!g_config.isPossiblySpoofedRetro) || (g_config.isPossiblySpoofedRetro && !g_config.isRetroSUPER)) {
|
||||||
else if ((!g_config.isPossiblySpoofedRetro) || (g_config.isPossiblySpoofedRetro && !g_config.isRetroSUPER)) {
|
|
||||||
PLLD_BASE temp = { 0 };
|
PLLD_BASE temp = { 0 };
|
||||||
PLLD_MISC misc = { 0 };
|
PLLD_MISC misc = { 0 };
|
||||||
memcpy(&temp, (void *)(g_config.clkVirtAddr + 0xD0), 4);
|
memcpy(&temp, (void *)(g_config.clkVirtAddr + 0xD0), 4);
|
||||||
@@ -645,7 +662,8 @@ namespace display {
|
|||||||
|
|
||||||
if (value == 0 || value == 80) {
|
if (value == 0 || value == 80) {
|
||||||
// Docked mode
|
// Docked mode
|
||||||
if (g_config.isLite) return false;
|
if (g_config.isLite)
|
||||||
|
return false;
|
||||||
|
|
||||||
g_config.isDocked = true;
|
g_config.isDocked = true;
|
||||||
|
|
||||||
@@ -711,16 +729,14 @@ namespace display {
|
|||||||
} else {
|
} else {
|
||||||
value = 60;
|
value = 60;
|
||||||
}
|
}
|
||||||
}
|
} else if (!g_config.isRetroSUPER) {
|
||||||
else if (!g_config.isRetroSUPER) {
|
|
||||||
// Handheld mode
|
// Handheld mode
|
||||||
g_config.isDocked = false;
|
g_config.isDocked = false;
|
||||||
g_canChangeRefreshRateDocked = false;
|
g_canChangeRefreshRateDocked = false;
|
||||||
|
|
||||||
uint32_t pixelClock = (9375ULL * ((4096 * ((2 * temp.PLLD_DIVN) + 1)) + misc.PLLD_SDM_DIN)) / (8 * temp.PLLD_DIVM);
|
uint32_t pixelClock = (9375ULL * ((4096 * ((2 * temp.PLLD_DIVN) + 1)) + misc.PLLD_SDM_DIN)) / (8 * temp.PLLD_DIVM);
|
||||||
value = pixelClock / (DSI_CLOCK_HZ / 60);
|
value = pixelClock / (DSI_CLOCK_HZ / 60);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -733,4 +749,4 @@ namespace display {
|
|||||||
g_initialized = false;
|
g_initialized = false;
|
||||||
memset(&g_config, 0, sizeof(g_config));
|
memset(&g_config, 0, sizeof(g_config));
|
||||||
}
|
}
|
||||||
}
|
} // namespace display
|
||||||
@@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
namespace display {
|
namespace display {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t hFrontPorch;
|
uint16_t hFrontPorch;
|
||||||
@@ -124,4 +124,4 @@ namespace display {
|
|||||||
void CorrectOledGamma(uint32_t refresh_rate);
|
void CorrectOledGamma(uint32_t refresh_rate);
|
||||||
void SetAllowedDockedRatesIPC(uint32_t refreshRates, bool is720p);
|
void SetAllowedDockedRatesIPC(uint32_t refreshRates, bool is720p);
|
||||||
void Shutdown(void);
|
void Shutdown(void);
|
||||||
}
|
} // namespace display
|
||||||
@@ -24,29 +24,30 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.hpp"
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sstream>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <atomic>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
#include <atomic>
|
|
||||||
#include <initializer_list>
|
|
||||||
#include <minIni.h>
|
|
||||||
#include "../hos/apm_ext.h"
|
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <t210.h>
|
#include <map>
|
||||||
#include <max17050.h>
|
#include <max17050.h>
|
||||||
|
#include <minIni.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <t210.h>
|
||||||
#include <tmp451.h>
|
#include <tmp451.h>
|
||||||
#include <ipc_server.h>
|
#include <unistd.h>
|
||||||
#include <lockable_mutex.h>
|
|
||||||
#include "../board/board.hpp"
|
#include "../board/board.hpp"
|
||||||
|
#include "../hos/apm_ext.h"
|
||||||
|
#include "config.hpp"
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "file_utils.hpp"
|
#include "file_utils.hpp"
|
||||||
|
#include <initializer_list>
|
||||||
|
#include <ipc_server.h>
|
||||||
|
#include <lockable_mutex.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
namespace config {
|
namespace config {
|
||||||
|
|
||||||
@@ -83,7 +84,8 @@ namespace config {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t FindClockHzFromProfiles(std::uint64_t tid, HocClkModule module, std::initializer_list<HocClkProfile> profiles, u32 mhzMultiplier = 1000000) {
|
std::uint32_t FindClockHzFromProfiles(std::uint64_t tid, HocClkModule module, std::initializer_list<HocClkProfile> profiles,
|
||||||
|
u32 mhzMultiplier = 1000000) {
|
||||||
std::uint32_t mhz = 0;
|
std::uint32_t mhz = 0;
|
||||||
|
|
||||||
if (gLoaded) {
|
if (gLoaded) {
|
||||||
@@ -191,7 +193,7 @@ namespace config {
|
|||||||
gLoaded = true;
|
gLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
void Initialize() {
|
void Initialize() {
|
||||||
gPath = FILE_CONFIG_DIR "/config.ini";
|
gPath = FILE_CONFIG_DIR "/config.ini";
|
||||||
@@ -234,9 +236,13 @@ namespace config {
|
|||||||
return FindClockHzFromProfiles(tid, module, { HocClkProfile_Handheld }, returnRaw ? 1 : 1000000);
|
return FindClockHzFromProfiles(tid, module, { HocClkProfile_Handheld }, returnRaw ? 1 : 1000000);
|
||||||
case HocClkProfile_HandheldCharging:
|
case HocClkProfile_HandheldCharging:
|
||||||
case HocClkProfile_HandheldChargingUSB:
|
case HocClkProfile_HandheldChargingUSB:
|
||||||
return FindClockHzFromProfiles(tid, module, {HocClkProfile_HandheldChargingUSB, HocClkProfile_HandheldCharging, HocClkProfile_Handheld}, returnRaw ? 1 : 1000000);
|
return FindClockHzFromProfiles(tid, module,
|
||||||
|
{ HocClkProfile_HandheldChargingUSB, HocClkProfile_HandheldCharging, HocClkProfile_Handheld },
|
||||||
|
returnRaw ? 1 : 1000000);
|
||||||
case HocClkProfile_HandheldChargingOfficial:
|
case HocClkProfile_HandheldChargingOfficial:
|
||||||
return FindClockHzFromProfiles(tid, module, {HocClkProfile_HandheldChargingOfficial, HocClkProfile_HandheldCharging, HocClkProfile_Handheld}, returnRaw ? 1 : 1000000);
|
return FindClockHzFromProfiles(tid, module,
|
||||||
|
{ HocClkProfile_HandheldChargingOfficial, HocClkProfile_HandheldCharging, HocClkProfile_Handheld },
|
||||||
|
returnRaw ? 1 : 1000000);
|
||||||
case HocClkProfile_Docked:
|
case HocClkProfile_Docked:
|
||||||
return FindClockHzFromProfiles(tid, module, { HocClkProfile_Docked }, returnRaw ? 1 : 1000000);
|
return FindClockHzFromProfiles(tid, module, { HocClkProfile_Docked }, returnRaw ? 1 : 1000000);
|
||||||
default:
|
default:
|
||||||
@@ -273,9 +279,8 @@ namespace config {
|
|||||||
if (*mhz) {
|
if (*mhz) {
|
||||||
numProfiles++;
|
numProfiles++;
|
||||||
|
|
||||||
std::string key = std::string(board::GetProfileName((HocClkProfile)profile, false)) +
|
std::string key =
|
||||||
"_" +
|
std::string(board::GetProfileName((HocClkProfile)profile, false)) + "_" + board::GetModuleName((HocClkModule)module, false);
|
||||||
board::GetModuleName((HocClkModule)module, false);
|
|
||||||
std::string value = std::to_string(*mhz);
|
std::string value = std::to_string(*mhz);
|
||||||
|
|
||||||
keys.push_back(key);
|
keys.push_back(key);
|
||||||
@@ -484,4 +489,4 @@ namespace config {
|
|||||||
std::scoped_lock lock{ gConfigMutex };
|
std::scoped_lock lock{ gConfigMutex };
|
||||||
ini_puts(section, key, NULL, gPath.c_str());
|
ini_puts(section, key, NULL, gPath.c_str());
|
||||||
}
|
}
|
||||||
}
|
} // namespace config
|
||||||
|
|||||||
@@ -59,4 +59,4 @@ namespace config {
|
|||||||
|
|
||||||
extern uint64_t configValues[HocClkConfigValue_EnumMax];
|
extern uint64_t configValues[HocClkConfigValue_EnumMax];
|
||||||
|
|
||||||
}
|
} // namespace config
|
||||||
|
|||||||
@@ -24,11 +24,12 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "errors.hpp"
|
|
||||||
#include "file_utils.hpp"
|
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "errors.hpp"
|
||||||
|
#include "file_utils.hpp"
|
||||||
|
|
||||||
namespace errors {
|
namespace errors {
|
||||||
void ThrowException(const char *format, ...) {
|
void ThrowException(const char *format, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -38,4 +39,4 @@ namespace errors {
|
|||||||
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
||||||
// throw std::runtime_error(msg);
|
// throw std::runtime_error(msg);
|
||||||
}
|
}
|
||||||
}
|
} // namespace errors
|
||||||
|
|||||||
@@ -26,14 +26,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
#define ERROR_THROW(format, ...) errors::ThrowException(format "\n in %s:%u", ##__VA_ARGS__, __FILE__, __LINE__)
|
#define ERROR_THROW(format, ...) errors::ThrowException(format "\n in %s:%u", ##__VA_ARGS__, __FILE__, __LINE__)
|
||||||
#define ERROR_RESULT_THROW(rc, format, ...) ERROR_THROW(format "\n RC: [0x%x] %04d-%04d", ##__VA_ARGS__, rc, R_MODULE(rc), R_DESCRIPTION(rc))
|
#define ERROR_RESULT_THROW(rc, format, ...) ERROR_THROW(format "\n RC: [0x%x] %04d-%04d", ##__VA_ARGS__, rc, R_MODULE(rc), R_DESCRIPTION(rc))
|
||||||
#define ASSERT_RESULT_OK(rc, format, ...) \
|
#define ASSERT_RESULT_OK(rc, format, ...) \
|
||||||
if (R_FAILED(rc)) \
|
if (R_FAILED(rc)) { \
|
||||||
{ \
|
|
||||||
ERROR_RESULT_THROW(rc, "ASSERT_RESULT_OK: " format, ##__VA_ARGS__); \
|
ERROR_RESULT_THROW(rc, "ASSERT_RESULT_OK: " format, ##__VA_ARGS__); \
|
||||||
}
|
}
|
||||||
#define ASSERT_ENUM_VALID(n, v) \
|
#define ASSERT_ENUM_VALID(n, v) \
|
||||||
|
|||||||
@@ -24,12 +24,13 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "file_utils.hpp"
|
|
||||||
#include "../hos/apm_ext.h"
|
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <t210.h>
|
|
||||||
#include <max17050.h>
|
#include <max17050.h>
|
||||||
|
#include <t210.h>
|
||||||
#include <tmp451.h>
|
#include <tmp451.h>
|
||||||
|
|
||||||
|
#include "../hos/apm_ext.h"
|
||||||
|
#include "file_utils.hpp"
|
||||||
#include <ipc_server.h>
|
#include <ipc_server.h>
|
||||||
#include <lockable_mutex.h>
|
#include <lockable_mutex.h>
|
||||||
|
|
||||||
@@ -67,7 +68,7 @@ namespace fileUtils {
|
|||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
bool IsInitialized() {
|
bool IsInitialized() {
|
||||||
return g_has_initialized;
|
return g_has_initialized;
|
||||||
@@ -134,7 +135,8 @@ namespace fileUtils {
|
|||||||
struct timespec now;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_REALTIME, &now);
|
clock_gettime(CLOCK_REALTIME, &now);
|
||||||
|
|
||||||
fprintf(file, "%ld%03ld,%s,%016lx", now.tv_sec, now.tv_nsec / 1000000UL, hocclkFormatProfile(context->profile, false), context->applicationId);
|
fprintf(file, "%ld%03ld,%s,%016lx", now.tv_sec, now.tv_nsec / 1000000UL, hocclkFormatProfile(context->profile, false),
|
||||||
|
context->applicationId);
|
||||||
|
|
||||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||||
fprintf(file, ",%d", context->freqs[module]);
|
fprintf(file, ",%d", context->freqs[module]);
|
||||||
@@ -210,4 +212,4 @@ namespace fileUtils {
|
|||||||
fsExit();
|
fsExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace fileUtils
|
||||||
|
|||||||
@@ -26,13 +26,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
|
#include <string>
|
||||||
|
#include <switch.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#define FILE_CONFIG_DIR "/config/" CONFIG_DIR
|
#define FILE_CONFIG_DIR "/config/" CONFIG_DIR
|
||||||
#define FILE_FLAG_CHECK_INTERVAL_NS (10000ULL * 1000000000ULL)
|
#define FILE_FLAG_CHECK_INTERVAL_NS (10000ULL * 1000000000ULL)
|
||||||
@@ -50,4 +50,4 @@ namespace fileUtils {
|
|||||||
void LogLine(const char *format, ...);
|
void LogLine(const char *format, ...);
|
||||||
void WriteContextToCsv(const HocClkContext *context);
|
void WriteContextToCsv(const HocClkContext *context);
|
||||||
|
|
||||||
}
|
} // namespace fileUtils
|
||||||
|
|||||||
@@ -15,17 +15,17 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "kip.hpp"
|
|
||||||
#include "../i2c/i2cDrv.h"
|
|
||||||
#include "../board/board.hpp"
|
#include "../board/board.hpp"
|
||||||
#include "file_utils.hpp"
|
#include "../i2c/i2cDrv.h"
|
||||||
#include "../mgr/clock_manager.hpp"
|
#include "../mgr/clock_manager.hpp"
|
||||||
|
#include "file_utils.hpp"
|
||||||
|
#include "kip.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace kip {
|
namespace kip {
|
||||||
|
|
||||||
bool kipAvailable = false;
|
bool kipAvailable = false;
|
||||||
void SetKipData()
|
void SetKipData() {
|
||||||
{
|
|
||||||
// TODO: figure out if this REALLY causes issues (i doubt it)
|
// TODO: figure out if this REALLY causes issues (i doubt it)
|
||||||
// if(board::GetSocType() == HocClkSocType_Mariko) {
|
// if(board::GetSocType() == HocClkSocType_Mariko) {
|
||||||
// if(R_FAILED(I2c_BuckConverter_SetMvOut(&I2c_Mariko_DRAM_VDDQ, config::GetConfigValue(KipConfigValue_marikoEmcVddqVolt) / 1000))) {
|
// if(R_FAILED(I2c_BuckConverter_SetMvOut(&I2c_Mariko_DRAM_VDDQ, config::GetConfigValue(KipConfigValue_marikoEmcVddqVolt) / 1000))) {
|
||||||
@@ -152,7 +152,8 @@ namespace kip {
|
|||||||
configValues.values[KipCrc32] = (u64)crc32::checksum_file("sdmc:/atmosphere/kips/hoc.kip"); // write checksum
|
configValues.values[KipCrc32] = (u64)crc32::checksum_file("sdmc:/atmosphere/kips/hoc.kip"); // write checksum
|
||||||
|
|
||||||
if (config::SetConfigValues(&configValues, true)) {
|
if (config::SetConfigValues(&configValues, true)) {
|
||||||
fileUtils::LogLine("[kip] KIP data set. CRC32: %ld (Cust Rev %ld)", configValues.values[KipCrc32], configValues.values[KipConfigValue_custRev]);
|
fileUtils::LogLine("[kip] KIP data set. CRC32: %ld (Cust Rev %ld)", configValues.values[KipCrc32],
|
||||||
|
configValues.values[KipConfigValue_custRev]);
|
||||||
for (u64 i = KipConfigValue_hpMode; i < HocClkConfigValue_EnumMax; i++) {
|
for (u64 i = KipConfigValue_hpMode; i < HocClkConfigValue_EnumMax; i++) {
|
||||||
fileUtils::LogLine("%s: %ld", hocclkFormatConfigValue((HocClkConfigValue)i, false), configValues.values[i]);
|
fileUtils::LogLine("%s: %ld", hocclkFormatConfigValue((HocClkConfigValue)i, false), configValues.values[i]);
|
||||||
}
|
}
|
||||||
@@ -164,8 +165,7 @@ namespace kip {
|
|||||||
|
|
||||||
// I know this is very hacky, but the config system in the sysmodule doesn't really support writing
|
// I know this is very hacky, but the config system in the sysmodule doesn't really support writing
|
||||||
|
|
||||||
void GetKipData()
|
void GetKipData() {
|
||||||
{
|
|
||||||
FILE *fp = fopen("sdmc:/atmosphere/kips/hoc.kip", "rb");
|
FILE *fp = fopen("sdmc:/atmosphere/kips/hoc.kip", "rb");
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
@@ -192,7 +192,8 @@ namespace kip {
|
|||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if ((u64)crc32::checksum_file("sdmc:/atmosphere/kips/hoc.kip") != config::GetConfigValue(KipCrc32) && !config::GetConfigValue(HocClkConfigValue_IsFirstLoad)) {
|
if ((u64)crc32::checksum_file("sdmc:/atmosphere/kips/hoc.kip") != config::GetConfigValue(KipCrc32) &&
|
||||||
|
!config::GetConfigValue(HocClkConfigValue_IsFirstLoad)) {
|
||||||
MigrateKipData(cust_get_cust_rev(&table), cust_get_kip_version(&table));
|
MigrateKipData(cust_get_cust_rev(&table), cust_get_kip_version(&table));
|
||||||
SetKipData();
|
SetKipData();
|
||||||
notification::writeNotification("Horizon OC\nKIP has been updated\nPlease reboot your console");
|
notification::writeNotification("Horizon OC\nKIP has been updated\nPlease reboot your console");
|
||||||
@@ -294,7 +295,8 @@ namespace kip {
|
|||||||
|
|
||||||
if (sizeof(HocClkConfigValueList) <= sizeof(configValues)) {
|
if (sizeof(HocClkConfigValueList) <= sizeof(configValues)) {
|
||||||
if (config::SetConfigValues(&configValues, true)) {
|
if (config::SetConfigValues(&configValues, true)) {
|
||||||
fileUtils::LogLine("[kip] KIP loaded. CRC32: %ld (Cust Rev %ld)", configValues.values[KipCrc32], configValues.values[KipConfigValue_custRev]);
|
fileUtils::LogLine("[kip] KIP loaded. CRC32: %ld (Cust Rev %ld)", configValues.values[KipCrc32],
|
||||||
|
configValues.values[KipConfigValue_custRev]);
|
||||||
for (u64 i = KipConfigValue_hpMode; i < HocClkConfigValue_EnumMax; i++) {
|
for (u64 i = KipConfigValue_hpMode; i < HocClkConfigValue_EnumMax; i++) {
|
||||||
fileUtils::LogLine("%s: %ld", hocclkFormatConfigValue((HocClkConfigValue)i, false), configValues.values[i]);
|
fileUtils::LogLine("%s: %ld", hocclkFormatConfigValue((HocClkConfigValue)i, false), configValues.values[i]);
|
||||||
}
|
}
|
||||||
@@ -319,7 +321,8 @@ namespace kip {
|
|||||||
configValues.values[KipConfigValue_marikoGpuBootVolt] = 800;
|
configValues.values[KipConfigValue_marikoGpuBootVolt] = 800;
|
||||||
|
|
||||||
configValues.values[KipConfigValue_marikoGpuUV] += 2; // Raise UV levels
|
configValues.values[KipConfigValue_marikoGpuUV] += 2; // Raise UV levels
|
||||||
configValues.values[KipConfigValue_commonGpuVoltOffset] = (u32)(-(s64)(configValues.values[KipConfigValue_commonGpuVoltOffset])); // Migrate GPU Volt Offset
|
configValues.values[KipConfigValue_commonGpuVoltOffset] =
|
||||||
|
(u32)(-(s64)(configValues.values[KipConfigValue_commonGpuVoltOffset])); // Migrate GPU Volt Offset
|
||||||
// Raise min cpu vmin
|
// Raise min cpu vmin
|
||||||
if (configValues.values[KipConfigValue_eristaCpuVmin] < 750) {
|
if (configValues.values[KipConfigValue_eristaCpuVmin] < 750) {
|
||||||
configValues.values[KipConfigValue_eristaCpuVmin] = 750;
|
configValues.values[KipConfigValue_eristaCpuVmin] = 750;
|
||||||
@@ -332,5 +335,4 @@ namespace kip {
|
|||||||
}
|
}
|
||||||
config::SetConfigValues(&configValues, true);
|
config::SetConfigValues(&configValues, true);
|
||||||
}
|
}
|
||||||
}
|
} // namespace kip
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <switch.h>
|
#include <crc32.h>
|
||||||
#include <stdio.h>
|
#include <notification.h>
|
||||||
#include <string.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "file_utils.hpp"
|
#include "file_utils.hpp"
|
||||||
#include <notification.h>
|
|
||||||
#include <crc32.h>
|
|
||||||
|
|
||||||
namespace kip {
|
namespace kip {
|
||||||
extern bool kipAvailable;
|
extern bool kipAvailable;
|
||||||
@@ -114,7 +116,8 @@ namespace kip {
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
size_t r = fread(buf, 1, sizeof(buf), f);
|
size_t r = fread(buf, 1, sizeof(buf), f);
|
||||||
if (r < CUST_MAGIC_LEN) break;
|
if (r < CUST_MAGIC_LEN)
|
||||||
|
break;
|
||||||
|
|
||||||
for (size_t i = 0; i <= r - CUST_MAGIC_LEN; i++) {
|
for (size_t i = 0; i <= r - CUST_MAGIC_LEN; i++) {
|
||||||
if (memcmp(&buf[i], CUST_MAGIC, CUST_MAGIC_LEN) == 0) {
|
if (memcmp(&buf[i], CUST_MAGIC, CUST_MAGIC_LEN) == 0) {
|
||||||
@@ -131,22 +134,27 @@ namespace kip {
|
|||||||
static long cachedCustOffset = -1;
|
static long cachedCustOffset = -1;
|
||||||
|
|
||||||
static inline long cust_get_offset(FILE *f) {
|
static inline long cust_get_offset(FILE *f) {
|
||||||
if (cachedCustOffset >= 0) return cachedCustOffset;
|
if (cachedCustOffset >= 0)
|
||||||
|
return cachedCustOffset;
|
||||||
long off;
|
long off;
|
||||||
if (!cust_find_offset(f, &off)) return -1;
|
if (!cust_find_offset(f, &off))
|
||||||
|
return -1;
|
||||||
cachedCustOffset = off;
|
cachedCustOffset = off;
|
||||||
return off;
|
return off;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool cust_read_table_f(FILE *f, CustomizeTable *out) {
|
static inline bool cust_read_table_f(FILE *f, CustomizeTable *out) {
|
||||||
long off = cust_get_offset(f);
|
long off = cust_get_offset(f);
|
||||||
if (off < 0) return false;
|
if (off < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
fseek(f, 0, SEEK_END);
|
||||||
if (off + (long)sizeof(CustomizeTable) > ftell(f)) return false;
|
if (off + (long)sizeof(CustomizeTable) > ftell(f))
|
||||||
|
return false;
|
||||||
|
|
||||||
fseek(f, off, SEEK_SET);
|
fseek(f, off, SEEK_SET);
|
||||||
if (fread(out, 1, sizeof(CustomizeTable), f) != sizeof(CustomizeTable)) return false;
|
if (fread(out, 1, sizeof(CustomizeTable), f) != sizeof(CustomizeTable))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (memcmp(out->cust, CUST_MAGIC, CUST_MAGIC_LEN) != 0) {
|
if (memcmp(out->cust, CUST_MAGIC, CUST_MAGIC_LEN) != 0) {
|
||||||
cachedCustOffset = -1;
|
cachedCustOffset = -1;
|
||||||
@@ -157,10 +165,12 @@ namespace kip {
|
|||||||
|
|
||||||
static inline bool cust_write_table_f(FILE *f, const CustomizeTable *in) {
|
static inline bool cust_write_table_f(FILE *f, const CustomizeTable *in) {
|
||||||
long off = cust_get_offset(f);
|
long off = cust_get_offset(f);
|
||||||
if (off < 0) return false;
|
if (off < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
fseek(f, 0, SEEK_END);
|
||||||
if (off + (long)sizeof(CustomizeTable) > ftell(f)) return false;
|
if (off + (long)sizeof(CustomizeTable) > ftell(f))
|
||||||
|
return false;
|
||||||
|
|
||||||
fseek(f, off, SEEK_SET);
|
fseek(f, off, SEEK_SET);
|
||||||
bool ok = fwrite(in, 1, sizeof(CustomizeTable), f) == sizeof(CustomizeTable);
|
bool ok = fwrite(in, 1, sizeof(CustomizeTable), f) == sizeof(CustomizeTable);
|
||||||
@@ -170,7 +180,8 @@ namespace kip {
|
|||||||
|
|
||||||
static inline bool cust_read_table(const char *path, CustomizeTable *out) {
|
static inline bool cust_read_table(const char *path, CustomizeTable *out) {
|
||||||
FILE *f = fopen(path, "rb");
|
FILE *f = fopen(path, "rb");
|
||||||
if (!f) return false;
|
if (!f)
|
||||||
|
return false;
|
||||||
bool ok = cust_read_table_f(f, out);
|
bool ok = cust_read_table_f(f, out);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return ok;
|
return ok;
|
||||||
@@ -178,7 +189,8 @@ namespace kip {
|
|||||||
|
|
||||||
static inline bool cust_write_table(const char *path, const CustomizeTable *in) {
|
static inline bool cust_write_table(const char *path, const CustomizeTable *in) {
|
||||||
FILE *f = fopen(path, "r+b");
|
FILE *f = fopen(path, "r+b");
|
||||||
if (!f) return false;
|
if (!f)
|
||||||
|
return false;
|
||||||
bool ok = cust_write_table_f(f, in);
|
bool ok = cust_write_table_f(f, in);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return ok;
|
return ok;
|
||||||
@@ -196,174 +208,382 @@ namespace kip {
|
|||||||
#define CUST_WRITE_FIELD(path, field, val) \
|
#define CUST_WRITE_FIELD(path, field, val) \
|
||||||
do { \
|
do { \
|
||||||
CustomizeTable t; \
|
CustomizeTable t; \
|
||||||
if (!cust_read_table(path, &t)) return false; \
|
if (!cust_read_table(path, &t)) \
|
||||||
|
return false; \
|
||||||
t.field = (val); \
|
t.field = (val); \
|
||||||
return cust_write_table(path, &t); \
|
return cust_write_table(path, &t); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
// static inline bool cust_set_cust_rev(const char* p, u32 v) { CUST_WRITE_FIELD(p, custRev, v); }
|
// static inline bool cust_set_cust_rev(const char* p, u32 v) { CUST_WRITE_FIELD(p, custRev, v); }
|
||||||
// static inline bool cust_set_mtc_conf(const char* p, u32 v) { CUST_WRITE_FIELD(p, mtcConf, v); }
|
// static inline bool cust_set_mtc_conf(const char* p, u32 v) { CUST_WRITE_FIELD(p, mtcConf, v); }
|
||||||
static inline bool cust_set_hp_mode(const char* p, u32 v) { CUST_WRITE_FIELD(p, hpMode, v); }
|
static inline bool cust_set_hp_mode(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, hpMode, v);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool cust_set_common_emc_volt(const char* p, u32 v) { CUST_WRITE_FIELD(p, commonEmcMemVolt, v); }
|
static inline bool cust_set_common_emc_volt(const char *p, u32 v) {
|
||||||
static inline bool cust_set_erista_emc_max(const char* p, u32 v) { CUST_WRITE_FIELD(p, eristaEmcMaxClock, v); }
|
CUST_WRITE_FIELD(p, commonEmcMemVolt, v);
|
||||||
static inline bool cust_set_step_mode(const char* p, u32 v) { CUST_WRITE_FIELD(p, stepMode, v); }
|
}
|
||||||
static inline bool cust_set_mariko_emc_max(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoEmcMaxClock, v); }
|
static inline bool cust_set_erista_emc_max(const char *p, u32 v) {
|
||||||
static inline bool cust_set_mariko_emc_vddq(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoEmcVddqVolt, v); }
|
CUST_WRITE_FIELD(p, eristaEmcMaxClock, v);
|
||||||
static inline bool cust_set_emc_dvb_shift(const char* p, u32 v) { CUST_WRITE_FIELD(p, emcDvbShift, v); }
|
}
|
||||||
|
static inline bool cust_set_step_mode(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, stepMode, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_mariko_emc_max(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, marikoEmcMaxClock, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_mariko_emc_vddq(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, marikoEmcVddqVolt, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_emc_dvb_shift(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, emcDvbShift, v);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool cust_set_tRCD(const char* p, u32 v) { CUST_WRITE_FIELD(p, t1_tRCD, v); }
|
static inline bool cust_set_tRCD(const char *p, u32 v) {
|
||||||
static inline bool cust_set_tRP(const char* p, u32 v) { CUST_WRITE_FIELD(p, t2_tRP, v); }
|
CUST_WRITE_FIELD(p, t1_tRCD, v);
|
||||||
static inline bool cust_set_tRAS(const char* p, u32 v) { CUST_WRITE_FIELD(p, t3_tRAS, v); }
|
}
|
||||||
static inline bool cust_set_tRRD(const char* p, u32 v) { CUST_WRITE_FIELD(p, t4_tRRD, v); }
|
static inline bool cust_set_tRP(const char *p, u32 v) {
|
||||||
static inline bool cust_set_tRFC(const char* p, u32 v) { CUST_WRITE_FIELD(p, t5_tRFC, v); }
|
CUST_WRITE_FIELD(p, t2_tRP, v);
|
||||||
static inline bool cust_set_tRTW(const char* p, u32 v) { CUST_WRITE_FIELD(p, t6_tRTW, v); }
|
}
|
||||||
static inline bool cust_set_tWTR(const char* p, u32 v) { CUST_WRITE_FIELD(p, t7_tWTR, v); }
|
static inline bool cust_set_tRAS(const char *p, u32 v) {
|
||||||
static inline bool cust_set_tREFI(const char* p, u32 v) { CUST_WRITE_FIELD(p, t8_tREFI, v); }
|
CUST_WRITE_FIELD(p, t3_tRAS, v);
|
||||||
static inline bool cust_set_tRP_cap(const char* p, u32 v) { CUST_WRITE_FIELD(p, t2_tRP_cap, v); }
|
}
|
||||||
static inline bool cust_set_timing_emc_tbreak(const char* p, u32 v) { CUST_WRITE_FIELD(p, timingEmcTbreak, v); }
|
static inline bool cust_set_tRRD(const char *p, u32 v) {
|
||||||
static inline bool cust_set_low_tRTW(const char* p, u32 v) { CUST_WRITE_FIELD(p, low_t6_tRTW, v); }
|
CUST_WRITE_FIELD(p, t4_tRRD, v);
|
||||||
static inline bool cust_set_low_tWTR(const char* p, u32 v) { CUST_WRITE_FIELD(p, low_t7_tWTR, v); }
|
}
|
||||||
static inline bool cust_set_tRTW_fine_tune(const char* p, u32 v) { CUST_WRITE_FIELD(p, t6_tRTW_fine_tune, v); }
|
static inline bool cust_set_tRFC(const char *p, u32 v) {
|
||||||
static inline bool cust_set_tWTR_fine_tune(const char* p, u32 v) { CUST_WRITE_FIELD(p, t7_tWTR_fine_tune, v); }
|
CUST_WRITE_FIELD(p, t5_tRFC, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_tRTW(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, t6_tRTW, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_tWTR(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, t7_tWTR, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_tREFI(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, t8_tREFI, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_tRP_cap(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, t2_tRP_cap, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_timing_emc_tbreak(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, timingEmcTbreak, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_low_tRTW(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, low_t6_tRTW, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_low_tWTR(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, low_t7_tWTR, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_tRTW_fine_tune(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, t6_tRTW_fine_tune, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_tWTR_fine_tune(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, t7_tWTR_fine_tune, v);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool cust_set_read_latency_1333(const char* p, u32 v) { CUST_WRITE_FIELD(p, readLatency1333, v); }
|
static inline bool cust_set_read_latency_1333(const char *p, u32 v) {
|
||||||
static inline bool cust_set_read_latency_1600(const char* p, u32 v) { CUST_WRITE_FIELD(p, readLatency1600, v); }
|
CUST_WRITE_FIELD(p, readLatency1333, v);
|
||||||
static inline bool cust_set_read_latency_1866(const char* p, u32 v) { CUST_WRITE_FIELD(p, readLatency1866, v); }
|
}
|
||||||
static inline bool cust_set_read_latency_2133(const char* p, u32 v) { CUST_WRITE_FIELD(p, readLatency2133, v); }
|
static inline bool cust_set_read_latency_1600(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, readLatency1600, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_read_latency_1866(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, readLatency1866, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_read_latency_2133(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, readLatency2133, v);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool cust_set_write_latency_1333(const char* p, u32 v) { CUST_WRITE_FIELD(p, writeLatency1333, v); }
|
static inline bool cust_set_write_latency_1333(const char *p, u32 v) {
|
||||||
static inline bool cust_set_write_latency_1600(const char* p, u32 v) { CUST_WRITE_FIELD(p, writeLatency1600, v); }
|
CUST_WRITE_FIELD(p, writeLatency1333, v);
|
||||||
static inline bool cust_set_write_latency_1866(const char* p, u32 v) { CUST_WRITE_FIELD(p, writeLatency1866, v); }
|
}
|
||||||
static inline bool cust_set_write_latency_2133(const char* p, u32 v) { CUST_WRITE_FIELD(p, writeLatency2133, v); }
|
static inline bool cust_set_write_latency_1600(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, writeLatency1600, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_write_latency_1866(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, writeLatency1866, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_write_latency_2133(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, writeLatency2133, v);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool cust_set_erista_cpu_uv(const char* p, u32 v) { CUST_WRITE_FIELD(p, eristaCpuUV, v); }
|
static inline bool cust_set_erista_cpu_uv(const char *p, u32 v) {
|
||||||
static inline bool cust_set_eristaCpuVmin(const char* p, u32 v) { CUST_WRITE_FIELD(p, eristaCpuVmin, v); }
|
CUST_WRITE_FIELD(p, eristaCpuUV, v);
|
||||||
static inline bool cust_set_erista_cpu_max_volt(const char* p, u32 v) { CUST_WRITE_FIELD(p, eristaCpuMaxVolt, v); }
|
}
|
||||||
static inline bool cust_set_eristaCpuUnlock(const char* p, u32 v) { CUST_WRITE_FIELD(p, eristaCpuUnlock, v); }
|
static inline bool cust_set_eristaCpuVmin(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, eristaCpuVmin, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_erista_cpu_max_volt(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, eristaCpuMaxVolt, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_eristaCpuUnlock(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, eristaCpuUnlock, v);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool cust_set_mariko_cpu_uv_low(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoCpuUVLow, v); }
|
static inline bool cust_set_mariko_cpu_uv_low(const char *p, u32 v) {
|
||||||
static inline bool cust_set_mariko_cpu_uv_high(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoCpuUVHigh, v); }
|
CUST_WRITE_FIELD(p, marikoCpuUVLow, v);
|
||||||
static inline bool cust_set_mariko_cpu_low_vmin(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoCpuLowVmin, v); }
|
}
|
||||||
static inline bool cust_set_mariko_cpu_high_vmin(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoCpuHighVmin, v); }
|
static inline bool cust_set_mariko_cpu_uv_high(const char *p, u32 v) {
|
||||||
static inline bool cust_set_mariko_cpu_max_volt(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoCpuMaxVolt, v); }
|
CUST_WRITE_FIELD(p, marikoCpuUVHigh, v);
|
||||||
static inline bool cust_set_erista_cpu_boost(const char* p, u32 v) { CUST_WRITE_FIELD(p, eristaCpuBoostClock, v); }
|
}
|
||||||
static inline bool cust_set_mariko_cpu_boost(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoCpuBoostClock, v); }
|
static inline bool cust_set_mariko_cpu_low_vmin(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, marikoCpuLowVmin, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_mariko_cpu_high_vmin(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, marikoCpuHighVmin, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_mariko_cpu_max_volt(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, marikoCpuMaxVolt, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_erista_cpu_boost(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, eristaCpuBoostClock, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_mariko_cpu_boost(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, marikoCpuBoostClock, v);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool cust_set_erista_gpu_uv(const char* p, u32 v) { CUST_WRITE_FIELD(p, eristaGpuUV, v); }
|
static inline bool cust_set_erista_gpu_uv(const char *p, u32 v) {
|
||||||
static inline bool cust_set_erista_gpu_vmin(const char* p, u32 v) { CUST_WRITE_FIELD(p, eristaGpuVmin, v); }
|
CUST_WRITE_FIELD(p, eristaGpuUV, v);
|
||||||
static inline bool cust_set_mariko_gpu_uv(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoGpuUV, v); }
|
}
|
||||||
static inline bool cust_set_mariko_gpu_vmin(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoGpuVmin, v); }
|
static inline bool cust_set_erista_gpu_vmin(const char *p, u32 v) {
|
||||||
static inline bool cust_set_mariko_gpu_boot_volt(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoGpuBootVolt, v); }
|
CUST_WRITE_FIELD(p, eristaGpuVmin, v);
|
||||||
static inline bool cust_set_mariko_gpu_vmax(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoGpuVmax, v); }
|
}
|
||||||
static inline bool cust_set_common_gpu_offset(const char* p, u32 v) { CUST_WRITE_FIELD(p, commonGpuVoltOffset, v); }
|
static inline bool cust_set_mariko_gpu_uv(const char *p, u32 v) {
|
||||||
static inline bool cust_set_marikoCpuMaxClock(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoCpuMaxClock, v); }
|
CUST_WRITE_FIELD(p, marikoGpuUV, v);
|
||||||
static inline bool cust_set_marikoSocVmax(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoSocVmax, v); }
|
}
|
||||||
|
static inline bool cust_set_mariko_gpu_vmin(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, marikoGpuVmin, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_mariko_gpu_boot_volt(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, marikoGpuBootVolt, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_mariko_gpu_vmax(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, marikoGpuVmax, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_common_gpu_offset(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, commonGpuVoltOffset, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_marikoCpuMaxClock(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, marikoCpuMaxClock, v);
|
||||||
|
}
|
||||||
|
static inline bool cust_set_marikoSocVmax(const char *p, u32 v) {
|
||||||
|
CUST_WRITE_FIELD(p, marikoSocVmax, v);
|
||||||
|
}
|
||||||
|
|
||||||
/* GPU VOLT ARRAY HELPERS */
|
/* GPU VOLT ARRAY HELPERS */
|
||||||
static inline bool cust_set_erista_gpu_volt(const char *p, int idx, u32 v) {
|
static inline bool cust_set_erista_gpu_volt(const char *p, int idx, u32 v) {
|
||||||
if (idx < 0 || idx >= 27) return false;
|
if (idx < 0 || idx >= 27)
|
||||||
|
return false;
|
||||||
CustomizeTable t;
|
CustomizeTable t;
|
||||||
if (!cust_read_table(p, &t)) return false;
|
if (!cust_read_table(p, &t))
|
||||||
|
return false;
|
||||||
t.eristaGpuVoltArray[idx] = v;
|
t.eristaGpuVoltArray[idx] = v;
|
||||||
return cust_write_table(p, &t);
|
return cust_write_table(p, &t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool cust_set_mariko_gpu_volt(const char *p, int idx, u32 v) {
|
static inline bool cust_set_mariko_gpu_volt(const char *p, int idx, u32 v) {
|
||||||
if (idx < 0 || idx >= 24) return false;
|
if (idx < 0 || idx >= 24)
|
||||||
|
return false;
|
||||||
CustomizeTable t;
|
CustomizeTable t;
|
||||||
if (!cust_read_table(p, &t)) return false;
|
if (!cust_read_table(p, &t))
|
||||||
|
return false;
|
||||||
t.marikoGpuVoltArray[idx] = v;
|
t.marikoGpuVoltArray[idx] = v;
|
||||||
return cust_write_table(p, &t);
|
return cust_write_table(p, &t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 cust_get_field(const CustomizeTable *t, u32 offset) {
|
static inline u32 cust_get_field(const CustomizeTable *t, u32 offset) {
|
||||||
if (!t) return 0;
|
if (!t)
|
||||||
|
return 0;
|
||||||
return *(u32 *)((u8 *)t + offset);
|
return *(u32 *)((u8 *)t + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CUST_GET_FIELD(table, field) ((table) ? (table)->field : 0)
|
#define CUST_GET_FIELD(table, field) ((table) ? (table)->field : 0)
|
||||||
|
|
||||||
static inline u32 cust_get_cust_rev(const CustomizeTable* t) { return CUST_GET_FIELD(t, custRev); }
|
static inline u32 cust_get_cust_rev(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_kip_version(const CustomizeTable* t) { return CUST_GET_FIELD(t, kipVersion); }
|
return CUST_GET_FIELD(t, custRev);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_kip_version(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, kipVersion);
|
||||||
|
}
|
||||||
// static inline u32 cust_get_mtc_conf(const CustomizeTable* t) { return CUST_GET_FIELD(t, mtcConf); }
|
// static inline u32 cust_get_mtc_conf(const CustomizeTable* t) { return CUST_GET_FIELD(t, mtcConf); }
|
||||||
static inline u32 cust_get_hp_mode(const CustomizeTable* t) { return CUST_GET_FIELD(t, hpMode); }
|
static inline u32 cust_get_hp_mode(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, hpMode);
|
||||||
|
}
|
||||||
|
|
||||||
static inline u32 cust_get_common_emc_volt(const CustomizeTable* t) { return CUST_GET_FIELD(t, commonEmcMemVolt); }
|
static inline u32 cust_get_common_emc_volt(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_erista_emc_max(const CustomizeTable* t) { return CUST_GET_FIELD(t, eristaEmcMaxClock); }
|
return CUST_GET_FIELD(t, commonEmcMemVolt);
|
||||||
static inline u32 cust_get_step_mode(const CustomizeTable* t) { return CUST_GET_FIELD(t, stepMode); }
|
}
|
||||||
static inline u32 cust_get_mariko_emc_max(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoEmcMaxClock); }
|
static inline u32 cust_get_erista_emc_max(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_mariko_emc_vddq(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoEmcVddqVolt); }
|
return CUST_GET_FIELD(t, eristaEmcMaxClock);
|
||||||
static inline u32 cust_get_emc_dvb_shift(const CustomizeTable* t) { return CUST_GET_FIELD(t, emcDvbShift); }
|
}
|
||||||
|
static inline u32 cust_get_step_mode(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, stepMode);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_mariko_emc_max(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, marikoEmcMaxClock);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_mariko_emc_vddq(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, marikoEmcVddqVolt);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_emc_dvb_shift(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, emcDvbShift);
|
||||||
|
}
|
||||||
|
|
||||||
static inline u32 cust_get_tRCD(const CustomizeTable* t) { return CUST_GET_FIELD(t, t1_tRCD); }
|
static inline u32 cust_get_tRCD(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_tRP(const CustomizeTable* t) { return CUST_GET_FIELD(t, t2_tRP); }
|
return CUST_GET_FIELD(t, t1_tRCD);
|
||||||
static inline u32 cust_get_tRAS(const CustomizeTable* t) { return CUST_GET_FIELD(t, t3_tRAS); }
|
}
|
||||||
static inline u32 cust_get_tRRD(const CustomizeTable* t) { return CUST_GET_FIELD(t, t4_tRRD); }
|
static inline u32 cust_get_tRP(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_tRFC(const CustomizeTable* t) { return CUST_GET_FIELD(t, t5_tRFC); }
|
return CUST_GET_FIELD(t, t2_tRP);
|
||||||
static inline u32 cust_get_tRTW(const CustomizeTable* t) { return CUST_GET_FIELD(t, t6_tRTW); }
|
}
|
||||||
static inline u32 cust_get_tWTR(const CustomizeTable* t) { return CUST_GET_FIELD(t, t7_tWTR); }
|
static inline u32 cust_get_tRAS(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_tREFI(const CustomizeTable* t) { return CUST_GET_FIELD(t, t8_tREFI); }
|
return CUST_GET_FIELD(t, t3_tRAS);
|
||||||
static inline u32 cust_get_tRP_cap(const CustomizeTable* t) { return CUST_GET_FIELD(t, t2_tRP_cap); }
|
}
|
||||||
static inline u32 cust_get_timing_emc_tbreak(const CustomizeTable* t) { return CUST_GET_FIELD(t, timingEmcTbreak); }
|
static inline u32 cust_get_tRRD(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_low_t6_tRTW(const CustomizeTable* t) { return CUST_GET_FIELD(t, low_t6_tRTW); }
|
return CUST_GET_FIELD(t, t4_tRRD);
|
||||||
static inline u32 cust_get_low_t7_tWTR(const CustomizeTable* t) { return CUST_GET_FIELD(t, low_t7_tWTR); }
|
}
|
||||||
static inline u32 cust_get_tRTW_fine_tune(const CustomizeTable* t) { return CUST_GET_FIELD(t, t6_tRTW_fine_tune); }
|
static inline u32 cust_get_tRFC(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_tWTR_fine_tune(const CustomizeTable* t) { return CUST_GET_FIELD(t, t7_tWTR_fine_tune); }
|
return CUST_GET_FIELD(t, t5_tRFC);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_tRTW(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, t6_tRTW);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_tWTR(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, t7_tWTR);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_tREFI(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, t8_tREFI);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_tRP_cap(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, t2_tRP_cap);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_timing_emc_tbreak(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, timingEmcTbreak);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_low_t6_tRTW(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, low_t6_tRTW);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_low_t7_tWTR(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, low_t7_tWTR);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_tRTW_fine_tune(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, t6_tRTW_fine_tune);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_tWTR_fine_tune(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, t7_tWTR_fine_tune);
|
||||||
|
}
|
||||||
|
|
||||||
static inline u32 cust_get_read_latency_1333(const CustomizeTable* t) { return CUST_GET_FIELD(t, readLatency1333); }
|
static inline u32 cust_get_read_latency_1333(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_read_latency_1600(const CustomizeTable* t) { return CUST_GET_FIELD(t, readLatency1600); }
|
return CUST_GET_FIELD(t, readLatency1333);
|
||||||
static inline u32 cust_get_read_latency_1866(const CustomizeTable* t) { return CUST_GET_FIELD(t, readLatency1866); }
|
}
|
||||||
static inline u32 cust_get_read_latency_2133(const CustomizeTable* t) { return CUST_GET_FIELD(t, readLatency2133); }
|
static inline u32 cust_get_read_latency_1600(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, readLatency1600);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_read_latency_1866(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, readLatency1866);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_read_latency_2133(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, readLatency2133);
|
||||||
|
}
|
||||||
|
|
||||||
static inline u32 cust_get_write_latency_1333(const CustomizeTable* t) { return CUST_GET_FIELD(t, writeLatency1333); }
|
static inline u32 cust_get_write_latency_1333(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_write_latency_1600(const CustomizeTable* t) { return CUST_GET_FIELD(t, writeLatency1600); }
|
return CUST_GET_FIELD(t, writeLatency1333);
|
||||||
static inline u32 cust_get_write_latency_1866(const CustomizeTable* t) { return CUST_GET_FIELD(t, writeLatency1866); }
|
}
|
||||||
static inline u32 cust_get_write_latency_2133(const CustomizeTable* t) { return CUST_GET_FIELD(t, writeLatency2133); }
|
static inline u32 cust_get_write_latency_1600(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, writeLatency1600);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_write_latency_1866(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, writeLatency1866);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_write_latency_2133(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, writeLatency2133);
|
||||||
|
}
|
||||||
|
|
||||||
static inline u32 cust_get_erista_cpu_uv(const CustomizeTable* t) { return CUST_GET_FIELD(t, eristaCpuUV); }
|
static inline u32 cust_get_erista_cpu_uv(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_eristaCpuVmin(const CustomizeTable* t) { return CUST_GET_FIELD(t, eristaCpuVmin); }
|
return CUST_GET_FIELD(t, eristaCpuUV);
|
||||||
static inline u32 cust_get_erista_cpu_max_volt(const CustomizeTable* t) { return CUST_GET_FIELD(t, eristaCpuMaxVolt); }
|
}
|
||||||
static inline u32 cust_get_eristaCpuUnlock(const CustomizeTable* t) { return CUST_GET_FIELD(t, eristaCpuUnlock); }
|
static inline u32 cust_get_eristaCpuVmin(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, eristaCpuVmin);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_erista_cpu_max_volt(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, eristaCpuMaxVolt);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_eristaCpuUnlock(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, eristaCpuUnlock);
|
||||||
|
}
|
||||||
|
|
||||||
static inline u32 cust_get_mariko_cpu_uv_low(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoCpuUVLow); }
|
static inline u32 cust_get_mariko_cpu_uv_low(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_mariko_cpu_uv_high(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoCpuUVHigh); }
|
return CUST_GET_FIELD(t, marikoCpuUVLow);
|
||||||
static inline u32 cust_get_mariko_cpu_low_vmin(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoCpuLowVmin); }
|
}
|
||||||
static inline u32 cust_get_mariko_cpu_high_vmin(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoCpuHighVmin); }
|
static inline u32 cust_get_mariko_cpu_uv_high(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_mariko_cpu_max_volt(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoCpuMaxVolt); }
|
return CUST_GET_FIELD(t, marikoCpuUVHigh);
|
||||||
static inline u32 cust_get_erista_cpu_boost(const CustomizeTable* t) { return CUST_GET_FIELD(t, eristaCpuBoostClock); }
|
}
|
||||||
static inline u32 cust_get_mariko_cpu_boost(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoCpuBoostClock); }
|
static inline u32 cust_get_mariko_cpu_low_vmin(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_table_conf(const CustomizeTable* t) { return CUST_GET_FIELD(t, tableConf); }
|
return CUST_GET_FIELD(t, marikoCpuLowVmin);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_mariko_cpu_high_vmin(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, marikoCpuHighVmin);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_mariko_cpu_max_volt(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, marikoCpuMaxVolt);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_erista_cpu_boost(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, eristaCpuBoostClock);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_mariko_cpu_boost(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, marikoCpuBoostClock);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_table_conf(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, tableConf);
|
||||||
|
}
|
||||||
|
|
||||||
static inline u32 cust_get_erista_gpu_uv(const CustomizeTable* t) { return CUST_GET_FIELD(t, eristaGpuUV); }
|
static inline u32 cust_get_erista_gpu_uv(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_erista_gpu_vmin(const CustomizeTable* t) { return CUST_GET_FIELD(t, eristaGpuVmin); }
|
return CUST_GET_FIELD(t, eristaGpuUV);
|
||||||
static inline u32 cust_get_mariko_gpu_uv(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoGpuUV); }
|
}
|
||||||
static inline u32 cust_get_mariko_gpu_vmin(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoGpuVmin); }
|
static inline u32 cust_get_erista_gpu_vmin(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_mariko_gpu_boot_volt(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoGpuBootVolt); }
|
return CUST_GET_FIELD(t, eristaGpuVmin);
|
||||||
static inline u32 cust_get_mariko_gpu_vmax(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoGpuVmax); }
|
}
|
||||||
static inline u32 cust_get_common_gpu_offset(const CustomizeTable* t) { return CUST_GET_FIELD(t, commonGpuVoltOffset); }
|
static inline u32 cust_get_mariko_gpu_uv(const CustomizeTable *t) {
|
||||||
static inline u32 cust_get_marikoCpuMaxClock(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoCpuMaxClock); }
|
return CUST_GET_FIELD(t, marikoGpuUV);
|
||||||
static inline u32 cust_get_marikoSocVmax(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoSocVmax); }
|
}
|
||||||
|
static inline u32 cust_get_mariko_gpu_vmin(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, marikoGpuVmin);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_mariko_gpu_boot_volt(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, marikoGpuBootVolt);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_mariko_gpu_vmax(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, marikoGpuVmax);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_common_gpu_offset(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, commonGpuVoltOffset);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_marikoCpuMaxClock(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, marikoCpuMaxClock);
|
||||||
|
}
|
||||||
|
static inline u32 cust_get_marikoSocVmax(const CustomizeTable *t) {
|
||||||
|
return CUST_GET_FIELD(t, marikoSocVmax);
|
||||||
|
}
|
||||||
|
|
||||||
static inline u32 cust_get_erista_gpu_volt(const CustomizeTable *t, int idx) {
|
static inline u32 cust_get_erista_gpu_volt(const CustomizeTable *t, int idx) {
|
||||||
if (!t || idx < 0 || idx >= 27) return 0;
|
if (!t || idx < 0 || idx >= 27)
|
||||||
|
return 0;
|
||||||
return t->eristaGpuVoltArray[idx];
|
return t->eristaGpuVoltArray[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 cust_get_mariko_gpu_volt(const CustomizeTable *t, int idx) {
|
static inline u32 cust_get_mariko_gpu_volt(const CustomizeTable *t, int idx) {
|
||||||
if (!t || idx < 0 || idx >= 24) return 0;
|
if (!t || idx < 0 || idx >= 24)
|
||||||
|
return 0;
|
||||||
return t->marikoGpuVoltArray[idx];
|
return t->marikoGpuVoltArray[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DECL_ERISTA_GPU_VOLT_HELPER(freq, idx) \
|
#define DECL_ERISTA_GPU_VOLT_HELPER(freq, idx) \
|
||||||
static inline bool cust_set_erista_gpu_volt_##freq( \
|
static inline bool cust_set_erista_gpu_volt_##freq(const char *p, u32 v) { \
|
||||||
const char* p, u32 v) { \
|
|
||||||
return cust_set_erista_gpu_volt(p, idx, v); \
|
return cust_set_erista_gpu_volt(p, idx, v); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DECL_MARIKO_GPU_VOLT_HELPER(freq, idx) \
|
#define DECL_MARIKO_GPU_VOLT_HELPER(freq, idx) \
|
||||||
static inline bool cust_set_mariko_gpu_volt_##freq( \
|
static inline bool cust_set_mariko_gpu_volt_##freq(const char *p, u32 v) { \
|
||||||
const char* p, u32 v) { \
|
|
||||||
return cust_set_mariko_gpu_volt(p, idx, v); \
|
return cust_set_mariko_gpu_volt(p, idx, v); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,13 +643,15 @@ namespace kip {
|
|||||||
#define DECL_ERISTA_GPU_VOLT_GET(freq, idx) \
|
#define DECL_ERISTA_GPU_VOLT_GET(freq, idx) \
|
||||||
static inline u32 cust_get_erista_gpu_volt_##freq##_val(const char *p) { \
|
static inline u32 cust_get_erista_gpu_volt_##freq##_val(const char *p) { \
|
||||||
CustomizeTable t; \
|
CustomizeTable t; \
|
||||||
if (!cust_read_table(p, &t)) return 0; \
|
if (!cust_read_table(p, &t)) \
|
||||||
|
return 0; \
|
||||||
return cust_get_erista_gpu_volt(&t, idx); \
|
return cust_get_erista_gpu_volt(&t, idx); \
|
||||||
}
|
}
|
||||||
#define DECL_MARIKO_GPU_VOLT_GET(freq, idx) \
|
#define DECL_MARIKO_GPU_VOLT_GET(freq, idx) \
|
||||||
static inline u32 cust_get_mariko_gpu_volt_##freq##_val(const char *p) { \
|
static inline u32 cust_get_mariko_gpu_volt_##freq##_val(const char *p) { \
|
||||||
CustomizeTable t; \
|
CustomizeTable t; \
|
||||||
if (!cust_read_table(p, &t)) return 0; \
|
if (!cust_read_table(p, &t)) \
|
||||||
|
return 0; \
|
||||||
return cust_get_mariko_gpu_volt(&t, idx); \
|
return cust_get_mariko_gpu_volt(&t, idx); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,4 +710,4 @@ namespace kip {
|
|||||||
void MigrateKipData(u32 custRev, u32 version);
|
void MigrateKipData(u32 custRev, u32 version);
|
||||||
void SetKipData();
|
void SetKipData();
|
||||||
void GetKipData();
|
void GetKipData();
|
||||||
}
|
} // namespace kip
|
||||||
@@ -24,60 +24,50 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdatomic.h>
|
||||||
|
|
||||||
#include "apm_ext.h"
|
#include "apm_ext.h"
|
||||||
|
|
||||||
#include <stdatomic.h>
|
|
||||||
|
|
||||||
static Service g_apmSrv;
|
static Service g_apmSrv;
|
||||||
static Service g_apmSysSrv;
|
static Service g_apmSysSrv;
|
||||||
static atomic_size_t g_refCnt;
|
static atomic_size_t g_refCnt;
|
||||||
|
|
||||||
Result apmExtInitialize(void)
|
Result apmExtInitialize(void) {
|
||||||
{
|
|
||||||
g_refCnt++;
|
g_refCnt++;
|
||||||
|
|
||||||
if (serviceIsActive(&g_apmSrv))
|
if (serviceIsActive(&g_apmSrv)) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result rc = 0;
|
Result rc = 0;
|
||||||
|
|
||||||
rc = smGetService(&g_apmSrv, "apm");
|
rc = smGetService(&g_apmSrv, "apm");
|
||||||
if(R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
|
||||||
rc = smGetService(&g_apmSysSrv, "apm:sys");
|
rc = smGetService(&g_apmSysSrv, "apm:sys");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_FAILED(rc))
|
if (R_FAILED(rc)) {
|
||||||
{
|
|
||||||
apmExtExit();
|
apmExtExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void apmExtExit(void)
|
void apmExtExit(void) {
|
||||||
{
|
if (--g_refCnt == 0) {
|
||||||
if (--g_refCnt == 0)
|
|
||||||
{
|
|
||||||
serviceClose(&g_apmSrv);
|
serviceClose(&g_apmSrv);
|
||||||
serviceClose(&g_apmSysSrv);
|
serviceClose(&g_apmSysSrv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result apmExtGetPerformanceMode(u32* out_mode)
|
Result apmExtGetPerformanceMode(u32 *out_mode) {
|
||||||
{
|
|
||||||
return serviceDispatchOut(&g_apmSrv, 1, *out_mode);
|
return serviceDispatchOut(&g_apmSrv, 1, *out_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result apmExtSysRequestPerformanceMode(u32 mode)
|
Result apmExtSysRequestPerformanceMode(u32 mode) {
|
||||||
{
|
|
||||||
return serviceDispatchIn(&g_apmSysSrv, 0, mode);
|
return serviceDispatchIn(&g_apmSysSrv, 0, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result apmExtGetCurrentPerformanceConfiguration(u32* out_conf)
|
Result apmExtGetCurrentPerformanceConfiguration(u32 *out_conf) {
|
||||||
{
|
|
||||||
return serviceDispatchOut(&g_apmSysSrv, 7, *out_conf);
|
return serviceDispatchOut(&g_apmSysSrv, 7, *out_conf);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,10 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <hocclk/apm.h>
|
#include <hocclk/apm.h>
|
||||||
|
|
||||||
HocClkApmConfiguration hocclk_g_apm_configurations[] = {
|
HocClkApmConfiguration hocclk_g_apm_configurations[] = {
|
||||||
@@ -46,4 +45,3 @@ HocClkApmConfiguration hocclk_g_apm_configurations[] = {
|
|||||||
{ 0x9222000C, 1020000000, 76800000, 1331200000 },
|
{ 0x9222000C, 1020000000, 76800000, 1331200000 },
|
||||||
{ 0, 0, 0, 0 },
|
{ 0, 0, 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "integrations.hpp"
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <SaltyNX.h>
|
#include <SaltyNX.h>
|
||||||
|
|
||||||
|
#include "integrations.hpp"
|
||||||
#include "process_management.hpp"
|
#include "process_management.hpp"
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
namespace integrations {
|
namespace integrations {
|
||||||
|
|
||||||
@@ -38,7 +39,8 @@ namespace integrations {
|
|||||||
svcCloseHandle(saltysd);
|
svcCloseHandle(saltysd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == 66) return false;
|
if (i == 66)
|
||||||
|
return false;
|
||||||
svcSleepThread(1'000'000);
|
svcSleepThread(1'000'000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +76,7 @@ namespace integrations {
|
|||||||
gSharedMemoryUsed = true;
|
gSharedMemoryUsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
bool GetSysDockState() {
|
bool GetSysDockState() {
|
||||||
struct stat st = { 0 };
|
struct stat st = { 0 };
|
||||||
@@ -143,8 +145,10 @@ namespace integrations {
|
|||||||
resolutionLookup = 1;
|
resolutionLookup = 1;
|
||||||
return 0;
|
return 0;
|
||||||
} else if (resolutionLookup == 1) {
|
} else if (resolutionLookup == 1) {
|
||||||
if (gNxFps->renderCalls[0].calls != 0xFFFF) resolutionLookup = 2;
|
if (gNxFps->renderCalls[0].calls != 0xFFFF)
|
||||||
else return 0;
|
resolutionLookup = 2;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gNxFps->renderCalls[0].height == 0 ? gNxFps->viewportCalls[0].height : gNxFps->renderCalls[0].height;
|
return gNxFps->renderCalls[0].height == 0 ? gNxFps->viewportCalls[0].height : gNxFps->renderCalls[0].height;
|
||||||
@@ -152,4 +156,4 @@ namespace integrations {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace integrations
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
namespace integrations {
|
namespace integrations {
|
||||||
|
|
||||||
@@ -66,4 +66,4 @@ namespace integrations {
|
|||||||
u8 GetSaltyNXFPS();
|
u8 GetSaltyNXFPS();
|
||||||
u16 GetSaltyNXResolutionHeight();
|
u16 GetSaltyNXResolutionHeight();
|
||||||
|
|
||||||
}
|
} // namespace integrations
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "notification.h"
|
#include "notification.h"
|
||||||
|
|
||||||
namespace notification {
|
namespace notification {
|
||||||
@@ -40,4 +39,4 @@ namespace notification {
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace notification
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <ctime>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <ctime>
|
||||||
|
#include <string>
|
||||||
namespace notification {
|
namespace notification {
|
||||||
void writeNotification(const std::string &message);
|
void writeNotification(const std::string &message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@
|
|||||||
* ldo8 | XUSB, DP, MCU | 50000 | 800000 | 1050000 | 2800000 | 1.05V/2.8V (pcv)
|
* ldo8 | XUSB, DP, MCU | 50000 | 800000 | 1050000 | 2800000 | 1.05V/2.8V (pcv)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// GPIOs T210: 3: 3.3V, 5: CPU PMIC, 6: GPU PMIC, 7: DSI/VI 1.2V powered by ldo0.
|
// GPIOs T210: 3: 3.3V, 5: CPU PMIC, 6: GPU PMIC, 7: DSI/VI 1.2V powered by ldo0.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -24,19 +24,20 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "process_management.hpp"
|
|
||||||
#include "../file/file_utils.hpp"
|
|
||||||
#include "../file/errors.hpp"
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "../file/errors.hpp"
|
||||||
|
#include "../file/file_utils.hpp"
|
||||||
|
#include "process_management.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace processManagement {
|
namespace processManagement {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr u64 Qlaunch = 0x0100000000001000ULL;
|
constexpr u64 Qlaunch = 0x0100000000001000ULL;
|
||||||
constexpr u32 IsQlaunch = 0x20f;
|
constexpr u32 IsQlaunch = 0x20f;
|
||||||
Service pdmqryClone;
|
Service pdmqryClone;
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
void Initialize() {
|
void Initialize() {
|
||||||
Result rc = 0;
|
Result rc = 0;
|
||||||
@@ -54,7 +55,6 @@ namespace processManagement {
|
|||||||
serviceClone(pdmqrySrv, &pdmqryClone);
|
serviceClone(pdmqrySrv, &pdmqryClone);
|
||||||
serviceClose(pdmqrySrv);
|
serviceClose(pdmqrySrv);
|
||||||
memcpy(pdmqrySrv, &pdmqryClone, sizeof(Service));
|
memcpy(pdmqrySrv, &pdmqryClone, sizeof(Service));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitForQLaunch() {
|
void WaitForQLaunch() {
|
||||||
@@ -77,12 +77,15 @@ namespace processManagement {
|
|||||||
u64 PIDnow;
|
u64 PIDnow;
|
||||||
|
|
||||||
Result rc = pmdmntGetApplicationProcessId(&PIDnow);
|
Result rc = pmdmntGetApplicationProcessId(&PIDnow);
|
||||||
if(R_FAILED(rc)) return rc;
|
if (R_FAILED(rc))
|
||||||
|
return rc;
|
||||||
rc = pmdmntGetProgramId(&TIDnow, PIDnow);
|
rc = pmdmntGetProgramId(&TIDnow, PIDnow);
|
||||||
if(R_FAILED(rc)) return rc;
|
if (R_FAILED(rc))
|
||||||
|
return rc;
|
||||||
|
|
||||||
rc = pdmqryGetAvailablePlayEventRange(&total_entries, &start_entry_index, &end_entry_index);
|
rc = pdmqryGetAvailablePlayEventRange(&total_entries, &start_entry_index, &end_entry_index);
|
||||||
if (R_FAILED(rc)) return rc;
|
if (R_FAILED(rc))
|
||||||
|
return rc;
|
||||||
if (total_entries == last_total_entries) {
|
if (total_entries == last_total_entries) {
|
||||||
*outOfFocus = isOutOfFocus;
|
*outOfFocus = isOutOfFocus;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -92,10 +95,13 @@ namespace processManagement {
|
|||||||
PdmPlayEvent events[16];
|
PdmPlayEvent events[16];
|
||||||
s32 out = 0;
|
s32 out = 0;
|
||||||
s32 start_entry = end_entry_index - 15;
|
s32 start_entry = end_entry_index - 15;
|
||||||
if (start_entry < 0) start_entry = 0;
|
if (start_entry < 0)
|
||||||
|
start_entry = 0;
|
||||||
rc = pdmqryQueryPlayEvent(start_entry, events, sizeof(events) / sizeof(events[0]), &out);
|
rc = pdmqryQueryPlayEvent(start_entry, events, sizeof(events) / sizeof(events[0]), &out);
|
||||||
if (R_FAILED(rc)) return rc;
|
if (R_FAILED(rc))
|
||||||
if (out == 0) return 1;
|
return rc;
|
||||||
|
if (out == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
int itr = -1;
|
int itr = -1;
|
||||||
for (int i = out - 1; i >= 0; i--) {
|
for (int i = out - 1; i >= 0; i--) {
|
||||||
@@ -112,8 +118,6 @@ namespace processManagement {
|
|||||||
TID.parts.part[0] = events[i].event_data.applet.program_id[1];
|
TID.parts.part[0] = events[i].event_data.applet.program_id[1];
|
||||||
TID.parts.part[1] = events[i].event_data.applet.program_id[0];
|
TID.parts.part[1] = events[i].event_data.applet.program_id[0];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (TID.full != (TIDnow & ~0xFFF))
|
if (TID.full != (TIDnow & ~0xFFF))
|
||||||
continue;
|
continue;
|
||||||
else {
|
else {
|
||||||
@@ -121,9 +125,11 @@ namespace processManagement {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (itr == -1) return 1;
|
if (itr == -1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
bool isOut = events[itr].event_data.applet.event_type == PdmAppletEventType_OutOfFocus || events[itr].event_data.applet.event_type == PdmAppletEventType_OutOfFocus4;
|
bool isOut = events[itr].event_data.applet.event_type == PdmAppletEventType_OutOfFocus ||
|
||||||
|
events[itr].event_data.applet.event_type == PdmAppletEventType_OutOfFocus4;
|
||||||
*outOfFocus = isOut;
|
*outOfFocus = isOut;
|
||||||
isOutOfFocus = isOut;
|
isOutOfFocus = isOut;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -158,4 +164,4 @@ namespace processManagement {
|
|||||||
pdmqryExit();
|
pdmqryExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace processManagement
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
@@ -36,4 +35,4 @@ namespace processManagement {
|
|||||||
Result isApplicationOutOfFocus(bool *outOfFocus);
|
Result isApplicationOutOfFocus(bool *outOfFocus);
|
||||||
void Exit();
|
void Exit();
|
||||||
|
|
||||||
}
|
} // namespace processManagement
|
||||||
|
|||||||
@@ -19,25 +19,36 @@
|
|||||||
|
|
||||||
const char *PsmPowerRoleToStr(PsmPowerRole role) {
|
const char *PsmPowerRoleToStr(PsmPowerRole role) {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case PsmPowerRole_Sink: return "Sink";
|
case PsmPowerRole_Sink:
|
||||||
case PsmPowerRole_Source: return "Source";
|
return "Sink";
|
||||||
default: return "Unknown";
|
case PsmPowerRole_Source:
|
||||||
|
return "Source";
|
||||||
|
default:
|
||||||
|
return "Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *PsmInfoChargerTypeToStr(PsmInfoChargerType type) {
|
const char *PsmInfoChargerTypeToStr(PsmInfoChargerType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case PsmInfoChargerType_None: return "None";
|
case PsmInfoChargerType_None:
|
||||||
case PsmInfoChargerType_PD: return "USB-C PD";
|
return "None";
|
||||||
|
case PsmInfoChargerType_PD:
|
||||||
|
return "USB-C PD";
|
||||||
case PsmInfoChargerType_TypeC_1500mA:
|
case PsmInfoChargerType_TypeC_1500mA:
|
||||||
case PsmInfoChargerType_TypeC_3000mA: return "USB-C";
|
case PsmInfoChargerType_TypeC_3000mA:
|
||||||
case PsmInfoChargerType_DCP: return "USB DCP";
|
return "USB-C";
|
||||||
case PsmInfoChargerType_CDP: return "USB CDP";
|
case PsmInfoChargerType_DCP:
|
||||||
case PsmInfoChargerType_SDP: return "USB SDP";
|
return "USB DCP";
|
||||||
|
case PsmInfoChargerType_CDP:
|
||||||
|
return "USB CDP";
|
||||||
|
case PsmInfoChargerType_SDP:
|
||||||
|
return "USB SDP";
|
||||||
case PsmInfoChargerType_Apple_500mA:
|
case PsmInfoChargerType_Apple_500mA:
|
||||||
case PsmInfoChargerType_Apple_1000mA:
|
case PsmInfoChargerType_Apple_1000mA:
|
||||||
case PsmInfoChargerType_Apple_2000mA: return "Apple";
|
case PsmInfoChargerType_Apple_2000mA:
|
||||||
default: return "Unknown";
|
return "Apple";
|
||||||
|
default:
|
||||||
|
return "Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,9 +70,13 @@ PsmBatteryState PsmGetBatteryState(const PsmChargeInfo* info) {
|
|||||||
|
|
||||||
const char *PsmGetBatteryStateIcon(const PsmChargeInfo *info) {
|
const char *PsmGetBatteryStateIcon(const PsmChargeInfo *info) {
|
||||||
switch (PsmGetBatteryState(info)) {
|
switch (PsmGetBatteryState(info)) {
|
||||||
case PsmBatteryState_Discharging: return "\u25c0"; // ◀
|
case PsmBatteryState_Discharging:
|
||||||
case PsmBatteryState_ChargingPaused:return "| |";
|
return "\u25c0"; // ◀
|
||||||
case PsmBatteryState_FastCharging: return "\u25b6"; // ▶
|
case PsmBatteryState_ChargingPaused:
|
||||||
default: return "?";
|
return "| |";
|
||||||
|
case PsmBatteryState_FastCharging:
|
||||||
|
return "\u25b6"; // ▶
|
||||||
|
default:
|
||||||
|
return "?";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,7 @@ typedef enum {
|
|||||||
PsmPDC_AcceptedRDO = 3 // Received and accepted Request Data Object
|
PsmPDC_AcceptedRDO = 3 // Received and accepted Request Data Object
|
||||||
} PsmChargeInfoPDC; // BM92T series
|
} PsmChargeInfoPDC; // BM92T series
|
||||||
|
|
||||||
typedef enum {
|
typedef enum { PsmPowerRole_Sink = 1, PsmPowerRole_Source = 2 } PsmPowerRole;
|
||||||
PsmPowerRole_Sink = 1,
|
|
||||||
PsmPowerRole_Source = 2
|
|
||||||
} PsmPowerRole;
|
|
||||||
|
|
||||||
const char *PsmPowerRoleToStr(PsmPowerRole role);
|
const char *PsmPowerRoleToStr(PsmPowerRole role);
|
||||||
|
|
||||||
@@ -84,11 +81,7 @@ typedef enum {
|
|||||||
bool PsmIsChargerConnected(const PsmChargeInfo *info);
|
bool PsmIsChargerConnected(const PsmChargeInfo *info);
|
||||||
bool PsmIsCharging(const PsmChargeInfo *info);
|
bool PsmIsCharging(const PsmChargeInfo *info);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum { PsmBatteryState_Discharging, PsmBatteryState_ChargingPaused, PsmBatteryState_FastCharging } PsmBatteryState;
|
||||||
PsmBatteryState_Discharging,
|
|
||||||
PsmBatteryState_ChargingPaused,
|
|
||||||
PsmBatteryState_FastCharging
|
|
||||||
} PsmBatteryState;
|
|
||||||
|
|
||||||
PsmBatteryState PsmGetBatteryState(const PsmChargeInfo *info);
|
PsmBatteryState PsmGetBatteryState(const PsmChargeInfo *info);
|
||||||
const char *PsmGetBatteryStateIcon(const PsmChargeInfo *info);
|
const char *PsmGetBatteryStateIcon(const PsmChargeInfo *info);
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
#include "../util/service_guard.h"
|
#include "../util/service_guard.h"
|
||||||
#include "pwm.h"
|
#include "pwm.h"
|
||||||
|
|
||||||
@@ -37,10 +38,7 @@ Service* pwmGetServiceSession(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result pwmOpenSession2(PwmChannelSession *out, u32 device_code) {
|
Result pwmOpenSession2(PwmChannelSession *out, u32 device_code) {
|
||||||
return serviceDispatchIn(&g_pwmSrv, 2, device_code,
|
return serviceDispatchIn(&g_pwmSrv, 2, device_code, .out_num_objects = 1, .out_objects = &out->s, );
|
||||||
.out_num_objects = 1,
|
|
||||||
.out_objects = &out->s,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result pwmChannelSessionGetDutyCycle(PwmChannelSession *c, double *out) {
|
Result pwmChannelSessionGetDutyCycle(PwmChannelSession *c, double *out) {
|
||||||
|
|||||||
@@ -17,8 +17,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
#include "pcv_types.h"
|
#include "pcv_types.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Service s;
|
Service s;
|
||||||
} RgltrSession;
|
} RgltrSession;
|
||||||
|
|||||||
@@ -16,9 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
#include "rgltr.h"
|
#include "rgltr.h"
|
||||||
#include "rgltr_services.h" // for extern Service g_rgltrSrv, etc.
|
#include "rgltr_services.h" // for extern Service g_rgltrSrv, etc.
|
||||||
|
|
||||||
|
|
||||||
// Global service handle
|
// Global service handle
|
||||||
Service g_rgltrSrv;
|
Service g_rgltrSrv;
|
||||||
|
|
||||||
@@ -35,13 +37,7 @@ void rgltrExit(void) {
|
|||||||
|
|
||||||
Result rgltrOpenSession(RgltrSession *session_out, PowerDomainId module_id) {
|
Result rgltrOpenSession(RgltrSession *session_out, PowerDomainId module_id) {
|
||||||
const u32 in = (u32)module_id;
|
const u32 in = (u32)module_id;
|
||||||
return serviceDispatchIn(
|
return serviceDispatchIn(&g_rgltrSrv, 0, in, .out_num_objects = 1, .out_objects = &session_out->s);
|
||||||
&g_rgltrSrv,
|
|
||||||
0,
|
|
||||||
in,
|
|
||||||
.out_num_objects = 1,
|
|
||||||
.out_objects = &session_out->s
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result rgltrGetVoltage(RgltrSession *session, u32 *out_volt) {
|
Result rgltrGetVoltage(RgltrSession *session, u32 *out_volt) {
|
||||||
|
|||||||
@@ -18,8 +18,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <switch.h> // for Service, Result, hosversionBefore(), smGetService(), serviceClose(), etc.
|
#include <switch.h> // for Service, Result, hosversionBefore(), smGetService(), serviceClose(), etc.
|
||||||
|
|
||||||
#include "rgltr.h" // for RgltrSession, PowerDomainId, etc.
|
#include "rgltr.h" // for RgltrSession, PowerDomainId, etc.
|
||||||
|
|
||||||
|
|
||||||
extern Service g_rgltrSrv;
|
extern Service g_rgltrSrv;
|
||||||
|
|
||||||
Result rgltrInitialize(void);
|
Result rgltrInitialize(void);
|
||||||
|
|||||||
@@ -24,22 +24,15 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
|
|
||||||
#define I2C_CMD_SND 0
|
#define I2C_CMD_SND 0
|
||||||
#define I2C_CMD_RCV 1
|
#define I2C_CMD_RCV 1
|
||||||
|
|
||||||
Result i2csessionExtRegReceive(I2cSession* s, u8 in, void* out, u8 out_size)
|
Result i2csessionExtRegReceive(I2cSession *s, u8 in, void *out, u8 out_size) {
|
||||||
{
|
u8 cmdlist[5] = { I2C_CMD_SND | (I2cTransactionOption_Start << 6), sizeof(in), in,
|
||||||
u8 cmdlist[5] = {
|
|
||||||
I2C_CMD_SND | (I2cTransactionOption_Start << 6),
|
|
||||||
sizeof(in),
|
|
||||||
in,
|
|
||||||
|
|
||||||
I2C_CMD_RCV | (I2cTransactionOption_All << 6),
|
I2C_CMD_RCV | (I2cTransactionOption_All << 6), out_size };
|
||||||
out_size
|
|
||||||
};
|
|
||||||
|
|
||||||
return i2csessionExecuteCommandList(s, out, out_size, cmdlist, sizeof(cmdlist));
|
return i2csessionExecuteCommandList(s, out, out_size, cmdlist, sizeof(cmdlist));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,10 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|||||||
@@ -37,8 +37,12 @@ Result I2cSet_U8(I2cDevice dev, u8 reg, u8 val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result I2cRead_OutU8(I2cDevice dev, u8 reg, u8 *out) {
|
Result I2cRead_OutU8(I2cDevice dev, u8 reg, u8 *out) {
|
||||||
struct { u8 reg; } __attribute__((packed)) cmd;
|
struct {
|
||||||
struct { u8 val; } __attribute__((packed)) rec;
|
u8 reg;
|
||||||
|
} __attribute__((packed)) cmd;
|
||||||
|
struct {
|
||||||
|
u8 val;
|
||||||
|
} __attribute__((packed)) rec;
|
||||||
|
|
||||||
I2cSession _session;
|
I2cSession _session;
|
||||||
Result res = i2cOpenSession(&_session, dev);
|
Result res = i2cOpenSession(&_session, dev);
|
||||||
@@ -63,8 +67,12 @@ Result I2cRead_OutU8(I2cDevice dev, u8 reg, u8 *out) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result I2cRead_OutU16(I2cDevice dev, u8 reg, u16 *out) {
|
Result I2cRead_OutU16(I2cDevice dev, u8 reg, u16 *out) {
|
||||||
struct { u8 reg; } __attribute__((packed)) cmd;
|
struct {
|
||||||
struct { u16 val; } __attribute__((packed)) rec;
|
u8 reg;
|
||||||
|
} __attribute__((packed)) cmd;
|
||||||
|
struct {
|
||||||
|
u16 val;
|
||||||
|
} __attribute__((packed)) rec;
|
||||||
|
|
||||||
I2cSession _session;
|
I2cSession _session;
|
||||||
Result res = i2cOpenSession(&_session, dev);
|
Result res = i2cOpenSession(&_session, dev);
|
||||||
@@ -223,13 +231,20 @@ Result I2c_Bq24193_SetFastChargeCurrentLimit(u32 ma) {
|
|||||||
|
|
||||||
// Converts mA to the raw value for bits [2:0] of REG00
|
// Converts mA to the raw value for bits [2:0] of REG00
|
||||||
static u8 I2c_Bq24193_Convert_InputmA_Raw(u32 ma) {
|
static u8 I2c_Bq24193_Convert_InputmA_Raw(u32 ma) {
|
||||||
if (ma <= 100) return 0b000;
|
if (ma <= 100)
|
||||||
if (ma <= 150) return 0b001;
|
return 0b000;
|
||||||
if (ma <= 500) return 0b010;
|
if (ma <= 150)
|
||||||
if (ma <= 900) return 0b011;
|
return 0b001;
|
||||||
if (ma <= 1200) return 0b100;
|
if (ma <= 500)
|
||||||
if (ma <= 1500) return 0b101;
|
return 0b010;
|
||||||
if (ma <= 2000) return 0b110;
|
if (ma <= 900)
|
||||||
|
return 0b011;
|
||||||
|
if (ma <= 1200)
|
||||||
|
return 0b100;
|
||||||
|
if (ma <= 1500)
|
||||||
|
return 0b101;
|
||||||
|
if (ma <= 2000)
|
||||||
|
return 0b110;
|
||||||
return 0b111; // 3000mA max
|
return 0b111; // 3000mA max
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,9 +254,7 @@ Result I2c_Bq24193_SetInputCurrentLimit(u32 ma) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
u8 raw;
|
u8 raw;
|
||||||
Result res = I2cRead_OutU8(I2cDevice_Bq24193,
|
Result res = I2cRead_OutU8(I2cDevice_Bq24193, BQ24193_INPUT_SOURCE_CONTROL_REG, &raw);
|
||||||
BQ24193_INPUT_SOURCE_CONTROL_REG,
|
|
||||||
&raw);
|
|
||||||
if (R_FAILED(res))
|
if (R_FAILED(res))
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
@@ -259,15 +272,33 @@ Result I2c_Bq24193_GetInputCurrentLimit(u32 *ma) {
|
|||||||
return res;
|
return res;
|
||||||
|
|
||||||
switch (raw & 0x07) {
|
switch (raw & 0x07) {
|
||||||
case 0b000: *ma = 100; break;
|
case 0b000:
|
||||||
case 0b001: *ma = 150; break;
|
*ma = 100;
|
||||||
case 0b010: *ma = 500; break;
|
break;
|
||||||
case 0b011: *ma = 900; break;
|
case 0b001:
|
||||||
case 0b100: *ma = 1200; break;
|
*ma = 150;
|
||||||
case 0b101: *ma = 1500; break;
|
break;
|
||||||
case 0b110: *ma = 2000; break;
|
case 0b010:
|
||||||
case 0b111: *ma = 3000; break;
|
*ma = 500;
|
||||||
default: *ma = 0; break;
|
break;
|
||||||
|
case 0b011:
|
||||||
|
*ma = 900;
|
||||||
|
break;
|
||||||
|
case 0b100:
|
||||||
|
*ma = 1200;
|
||||||
|
break;
|
||||||
|
case 0b101:
|
||||||
|
*ma = 1500;
|
||||||
|
break;
|
||||||
|
case 0b110:
|
||||||
|
*ma = 2000;
|
||||||
|
break;
|
||||||
|
case 0b111:
|
||||||
|
*ma = 3000;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
*ma = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,11 +40,21 @@ typedef struct I2c_BuckConverter_Domain {
|
|||||||
u8 por_val;
|
u8 por_val;
|
||||||
} I2c_BuckConverter_Domain;
|
} I2c_BuckConverter_Domain;
|
||||||
|
|
||||||
const I2c_BuckConverter_Domain I2c_SOC = { I2cDevice_Max77620Pmic, I2c_Max77620_SD0VOLT_REG, 0x7F, 12500, 600000, 1400000, };
|
const I2c_BuckConverter_Domain I2c_SOC = {
|
||||||
const I2c_BuckConverter_Domain I2c_VDD2 = { I2cDevice_Max77620Pmic, I2c_Max77620_SD1VOLT_REG, 0x7F, 12500, 600000, 1350000, };
|
I2cDevice_Max77620Pmic, I2c_Max77620_SD0VOLT_REG, 0x7F, 12500, 600000, 1400000,
|
||||||
const I2c_BuckConverter_Domain I2c_Display = { I2cDevice_Max77620Pmic, I2c_Max77620_LDO0VOLT_REG, 0x3F, 25000, 800000, 1325000, };
|
};
|
||||||
const I2c_BuckConverter_Domain I2c_Erista_CPU = { I2cDevice_Max77621Cpu, I2c_Max77621_VOLT_REG, 0x7F, 6250, 606250, 1400000, };
|
const I2c_BuckConverter_Domain I2c_VDD2 = {
|
||||||
const I2c_BuckConverter_Domain I2c_Erista_GPU = { I2cDevice_Max77621Gpu, I2c_Max77621_VOLT_REG, 0x7F, 6250, 606250, 1400000, };
|
I2cDevice_Max77620Pmic, I2c_Max77620_SD1VOLT_REG, 0x7F, 12500, 600000, 1350000,
|
||||||
|
};
|
||||||
|
const I2c_BuckConverter_Domain I2c_Display = {
|
||||||
|
I2cDevice_Max77620Pmic, I2c_Max77620_LDO0VOLT_REG, 0x3F, 25000, 800000, 1325000,
|
||||||
|
};
|
||||||
|
const I2c_BuckConverter_Domain I2c_Erista_CPU = {
|
||||||
|
I2cDevice_Max77621Cpu, I2c_Max77621_VOLT_REG, 0x7F, 6250, 606250, 1400000,
|
||||||
|
};
|
||||||
|
const I2c_BuckConverter_Domain I2c_Erista_GPU = {
|
||||||
|
I2cDevice_Max77621Gpu, I2c_Max77621_VOLT_REG, 0x7F, 6250, 606250, 1400000,
|
||||||
|
};
|
||||||
const I2c_BuckConverter_Domain I2c_Mariko_CPU = { I2cDevice_Max77812_2, I2c_Max77812_CPUVOLT_REG, 0xFF, 5000, 250000, 1525000, 0x78 };
|
const I2c_BuckConverter_Domain I2c_Mariko_CPU = { I2cDevice_Max77812_2, I2c_Max77812_CPUVOLT_REG, 0xFF, 5000, 250000, 1525000, 0x78 };
|
||||||
const I2c_BuckConverter_Domain I2c_Mariko_GPU = { I2cDevice_Max77812_2, I2c_Max77812_GPUVOLT_REG, 0xFF, 5000, 250000, 1525000, 0x78 };
|
const I2c_BuckConverter_Domain I2c_Mariko_GPU = { I2cDevice_Max77812_2, I2c_Max77812_GPUVOLT_REG, 0xFF, 5000, 250000, 1525000, 0x78 };
|
||||||
const I2c_BuckConverter_Domain I2c_Mariko_DRAM_VDDQ = { I2cDevice_Max77812_2, I2c_Max77812_MEMVOLT_REG, 0xFF, 5000, 250000, 700000, 0x78 };
|
const I2c_BuckConverter_Domain I2c_Mariko_DRAM_VDDQ = { I2cDevice_Max77812_2, I2c_Max77812_MEMVOLT_REG, 0xFF, 5000, 250000, 700000, 0x78 };
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "max17050.h"
|
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
|
#include "max17050.h"
|
||||||
|
|
||||||
#define MAX17050_WAIT_NS 1000000000UL
|
#define MAX17050_WAIT_NS 1000000000UL
|
||||||
|
|
||||||
@@ -40,15 +40,13 @@ static u64 g_update_ticks = 0;
|
|||||||
static s32 g_power_now = 0;
|
static s32 g_power_now = 0;
|
||||||
static s32 g_power_avg = 0;
|
static s32 g_power_avg = 0;
|
||||||
|
|
||||||
static Result _max17050_get_power(s32 *out_mw_now, s32 *out_mw_avg)
|
static Result _max17050_get_power(s32 *out_mw_now, s32 *out_mw_avg) {
|
||||||
{
|
|
||||||
s64 ma, mv;
|
s64 ma, mv;
|
||||||
u16 values[3] = { 0 };
|
u16 values[3] = { 0 };
|
||||||
|
|
||||||
Result rc = i2csessionExtRegReceive(&g_i2c_session, MAX17050_VCELL, values, sizeof(values));
|
Result rc = i2csessionExtRegReceive(&g_i2c_session, MAX17050_VCELL, values, sizeof(values));
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
|
||||||
ma = (s16)values[1];
|
ma = (s16)values[1];
|
||||||
ma = ma * 1562500 / (MAX17050_BOARD_SNS_RESISTOR_UOHM * MAX17050_BOARD_CGAIN);
|
ma = ma * 1562500 / (MAX17050_BOARD_SNS_RESISTOR_UOHM * MAX17050_BOARD_CGAIN);
|
||||||
|
|
||||||
@@ -57,13 +55,11 @@ static Result _max17050_get_power(s32 *out_mw_now, s32 *out_mw_avg)
|
|||||||
*out_mw_now = ma * mv / 1000000;
|
*out_mw_now = ma * mv / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
|
||||||
rc = i2csessionExtRegReceive(&g_i2c_session, MAX17050_AvgVCELL, values, sizeof(u16));
|
rc = i2csessionExtRegReceive(&g_i2c_session, MAX17050_AvgVCELL, values, sizeof(u16));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
|
||||||
ma = (s16)values[2];
|
ma = (s16)values[2];
|
||||||
ma = ma * 1562500 / (MAX17050_BOARD_SNS_RESISTOR_UOHM * MAX17050_BOARD_CGAIN);
|
ma = ma * 1562500 / (MAX17050_BOARD_SNS_RESISTOR_UOHM * MAX17050_BOARD_CGAIN);
|
||||||
|
|
||||||
@@ -75,50 +71,42 @@ static Result _max17050_get_power(s32 *out_mw_now, s32 *out_mw_avg)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _max17050_update()
|
static void _max17050_update() {
|
||||||
{
|
|
||||||
u64 ticks = armGetSystemTick();
|
u64 ticks = armGetSystemTick();
|
||||||
if(armTicksToNs(ticks - g_update_ticks) <= MAX17050_WAIT_NS)
|
if (armTicksToNs(ticks - g_update_ticks) <= MAX17050_WAIT_NS) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_update_ticks = ticks;
|
g_update_ticks = ticks;
|
||||||
|
|
||||||
if(!serviceIsActive(&g_i2c_session.s))
|
if (!serviceIsActive(&g_i2c_session.s)) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_max17050_get_power(&g_power_now, &g_power_avg);
|
_max17050_get_power(&g_power_now, &g_power_avg);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result max17050Initialize(void)
|
Result max17050Initialize(void) {
|
||||||
{
|
|
||||||
Result rc = i2cInitialize();
|
Result rc = i2cInitialize();
|
||||||
|
|
||||||
if(R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
|
||||||
rc = i2cOpenSession(&g_i2c_session, I2cDevice_Max17050);
|
rc = i2cOpenSession(&g_i2c_session, I2cDevice_Max17050);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void max17050Exit(void)
|
void max17050Exit(void) {
|
||||||
{
|
|
||||||
i2csessionClose(&g_i2c_session);
|
i2csessionClose(&g_i2c_session);
|
||||||
i2cExit();
|
i2cExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 max17050PowerNow(void)
|
s32 max17050PowerNow(void) {
|
||||||
{
|
|
||||||
_max17050_update();
|
_max17050_update();
|
||||||
return g_power_now;
|
return g_power_now;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 max17050PowerAvg(void)
|
s32 max17050PowerAvg(void) {
|
||||||
{
|
|
||||||
_max17050_update();
|
_max17050_update();
|
||||||
return g_power_avg;
|
return g_power_avg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,10 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tmp451.h"
|
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
|
#include "tmp451.h"
|
||||||
|
|
||||||
#define TMP451_WAIT_NS 1000000000UL
|
#define TMP451_WAIT_NS 1000000000UL
|
||||||
|
|
||||||
@@ -33,37 +33,31 @@ static u64 g_update_ticks = 0;
|
|||||||
static s32 g_temp_pcb = 0;
|
static s32 g_temp_pcb = 0;
|
||||||
static s32 g_temp_soc = 0;
|
static s32 g_temp_soc = 0;
|
||||||
|
|
||||||
static Result _tmp451_get_temp(u8 reg, u8 dec_reg, s32* out)
|
static Result _tmp451_get_temp(u8 reg, u8 dec_reg, s32 *out) {
|
||||||
{
|
|
||||||
u8 val = 0;
|
u8 val = 0;
|
||||||
Result rc = i2csessionExtRegReceive(&g_i2c_session, reg, &val, sizeof(val));
|
Result rc = i2csessionExtRegReceive(&g_i2c_session, reg, &val, sizeof(val));
|
||||||
|
|
||||||
if(R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
|
||||||
*out = (s32)val * 1000;
|
*out = (s32)val * 1000;
|
||||||
rc = i2csessionExtRegReceive(&g_i2c_session, dec_reg, &val, sizeof(val));
|
rc = i2csessionExtRegReceive(&g_i2c_session, dec_reg, &val, sizeof(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
|
||||||
*out += ((s32)(val >> 4) * 625) / 10;
|
*out += ((s32)(val >> 4) * 625) / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _tmp451_update()
|
static void _tmp451_update() {
|
||||||
{
|
|
||||||
u64 ticks = armGetSystemTick();
|
u64 ticks = armGetSystemTick();
|
||||||
if(armTicksToNs(ticks - g_update_ticks) <= TMP451_WAIT_NS)
|
if (armTicksToNs(ticks - g_update_ticks) <= TMP451_WAIT_NS) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_update_ticks = ticks;
|
g_update_ticks = ticks;
|
||||||
|
|
||||||
if(!serviceIsActive(&g_i2c_session.s))
|
if (!serviceIsActive(&g_i2c_session.s)) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,32 +65,27 @@ static void _tmp451_update()
|
|||||||
_tmp451_get_temp(TMP451_SOC_TEMP_REG, TMP451_SOC_TMP_DEC_REG, &g_temp_soc);
|
_tmp451_get_temp(TMP451_SOC_TEMP_REG, TMP451_SOC_TMP_DEC_REG, &g_temp_soc);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result tmp451Initialize(void)
|
Result tmp451Initialize(void) {
|
||||||
{
|
|
||||||
Result rc = i2cInitialize();
|
Result rc = i2cInitialize();
|
||||||
|
|
||||||
if(R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
|
||||||
rc = i2cOpenSession(&g_i2c_session, I2cDevice_Tmp451);
|
rc = i2cOpenSession(&g_i2c_session, I2cDevice_Tmp451);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmp451Exit(void)
|
void tmp451Exit(void) {
|
||||||
{
|
|
||||||
i2csessionClose(&g_i2c_session);
|
i2csessionClose(&g_i2c_session);
|
||||||
i2cExit();
|
i2cExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 tmp451TempPcb(void)
|
s32 tmp451TempPcb(void) {
|
||||||
{
|
|
||||||
_tmp451_update();
|
_tmp451_update();
|
||||||
return g_temp_pcb;
|
return g_temp_pcb;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 tmp451TempSoc(void)
|
s32 tmp451TempSoc(void) {
|
||||||
{
|
|
||||||
_tmp451_update();
|
_tmp451_update();
|
||||||
return g_temp_soc;
|
return g_temp_soc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,10 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|||||||
@@ -24,14 +24,12 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ipc_server.h"
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
Result ipcServerInit(IpcServer* server, const char* name, u32 max_sessions)
|
#include "ipc_server.h"
|
||||||
{
|
|
||||||
if(max_sessions < 1 || max_sessions > (MAX_WAIT_OBJECTS - 1))
|
Result ipcServerInit(IpcServer *server, const char *name, u32 max_sessions) {
|
||||||
{
|
if (max_sessions < 1 || max_sessions > (MAX_WAIT_OBJECTS - 1)) {
|
||||||
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,27 +38,22 @@ Result ipcServerInit(IpcServer* server, const char* name, u32 max_sessions)
|
|||||||
server->count = 0;
|
server->count = 0;
|
||||||
|
|
||||||
Result rc = smRegisterService(&server->handles[0], server->srvName, false, max_sessions);
|
Result rc = smRegisterService(&server->handles[0], server->srvName, false, max_sessions);
|
||||||
if(R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
|
||||||
server->count = 1;
|
server->count = 1;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ipcServerExit(IpcServer* server)
|
Result ipcServerExit(IpcServer *server) {
|
||||||
{
|
for (u32 i = 0; i < server->count; i++) {
|
||||||
for(u32 i = 0; i < server->count; i++)
|
|
||||||
{
|
|
||||||
svcCloseHandle(server->handles[i]);
|
svcCloseHandle(server->handles[i]);
|
||||||
}
|
}
|
||||||
server->count = 0;
|
server->count = 0;
|
||||||
return smUnregisterService(server->srvName);
|
return smUnregisterService(server->srvName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _ipcServerAddSession(IpcServer* server, Handle session)
|
static Result _ipcServerAddSession(IpcServer *server, Handle session) {
|
||||||
{
|
if (server->count >= server->max) {
|
||||||
if(server->count >= server->max)
|
|
||||||
{
|
|
||||||
return MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
return MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,25 +62,21 @@ static Result _ipcServerAddSession(IpcServer* server, Handle session)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _ipcServerDeleteSession(IpcServer* server, u32 index)
|
static Result _ipcServerDeleteSession(IpcServer *server, u32 index) {
|
||||||
{
|
if (!index || index >= server->count) {
|
||||||
if(!index || index >= server->count)
|
|
||||||
{
|
|
||||||
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
svcCloseHandle(server->handles[index]);
|
svcCloseHandle(server->handles[index]);
|
||||||
|
|
||||||
for(u32 j = index; j < (server->count - 1); j++)
|
for (u32 j = index; j < (server->count - 1); j++) {
|
||||||
{
|
|
||||||
server->handles[j] = server->handles[j + 1];
|
server->handles[j] = server->handles[j + 1];
|
||||||
}
|
}
|
||||||
server->count--;
|
server->count--;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _ipcServerParseRequest(IpcServerRequest* r)
|
static Result _ipcServerParseRequest(IpcServerRequest *r) {
|
||||||
{
|
|
||||||
u8 *base = armGetTls();
|
u8 *base = armGetTls();
|
||||||
|
|
||||||
r->hipc = hipcParseRequest(base);
|
r->hipc = hipcParseRequest(base);
|
||||||
@@ -95,19 +84,16 @@ static Result _ipcServerParseRequest(IpcServerRequest* r)
|
|||||||
r->data.size = 0;
|
r->data.size = 0;
|
||||||
r->data.ptr = NULL;
|
r->data.ptr = NULL;
|
||||||
|
|
||||||
if(r->hipc.meta.type == CmifCommandType_Request)
|
if (r->hipc.meta.type == CmifCommandType_Request) {
|
||||||
{
|
|
||||||
IpcServerRawHeader *header = cmifGetAlignedDataStart(r->hipc.data.data_words, base);
|
IpcServerRawHeader *header = cmifGetAlignedDataStart(r->hipc.data.data_words, base);
|
||||||
size_t dataSize = r->hipc.meta.num_data_words * 4;
|
size_t dataSize = r->hipc.meta.num_data_words * 4;
|
||||||
|
|
||||||
if(!header || dataSize < sizeof(IpcServerRawHeader) || header->magic != CMIF_IN_HEADER_MAGIC)
|
if (!header || dataSize < sizeof(IpcServerRawHeader) || header->magic != CMIF_IN_HEADER_MAGIC) {
|
||||||
{
|
|
||||||
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
r->data.cmdId = header->cmdId;
|
r->data.cmdId = header->cmdId;
|
||||||
if(dataSize > sizeof(IpcServerRawHeader))
|
if (dataSize > sizeof(IpcServerRawHeader)) {
|
||||||
{
|
|
||||||
r->data.size = dataSize - sizeof(IpcServerRawHeader);
|
r->data.size = dataSize - sizeof(IpcServerRawHeader);
|
||||||
r->data.ptr = ((u8 *)header) + sizeof(IpcServerRawHeader);
|
r->data.ptr = ((u8 *)header) + sizeof(IpcServerRawHeader);
|
||||||
}
|
}
|
||||||
@@ -116,37 +102,30 @@ static Result _ipcServerParseRequest(IpcServerRequest* r)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _ipcServerPrepareResponse(Result rc, void* data, size_t dataSize)
|
static void _ipcServerPrepareResponse(Result rc, void *data, size_t dataSize) {
|
||||||
{
|
|
||||||
u8 *base = armGetTls();
|
u8 *base = armGetTls();
|
||||||
HipcRequest hipc = hipcMakeRequestInline(base,
|
HipcRequest hipc =
|
||||||
.type = CmifCommandType_Request,
|
hipcMakeRequestInline(base, .type = CmifCommandType_Request, .num_data_words = (sizeof(IpcServerRawHeader) + dataSize + 0x10) / 4, );
|
||||||
.num_data_words = (sizeof(IpcServerRawHeader) + dataSize + 0x10) / 4,
|
|
||||||
);
|
|
||||||
|
|
||||||
IpcServerRawHeader *rawHeader = cmifGetAlignedDataStart(hipc.data_words, base);
|
IpcServerRawHeader *rawHeader = cmifGetAlignedDataStart(hipc.data_words, base);
|
||||||
rawHeader->magic = CMIF_OUT_HEADER_MAGIC;
|
rawHeader->magic = CMIF_OUT_HEADER_MAGIC;
|
||||||
rawHeader->result = rc;
|
rawHeader->result = rc;
|
||||||
|
|
||||||
if(R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
|
||||||
memcpy(((u8 *)rawHeader) + sizeof(IpcServerRawHeader), data, dataSize);
|
memcpy(((u8 *)rawHeader) + sizeof(IpcServerRawHeader), data, dataSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _ipcServerProcessNewSession(IpcServer* server)
|
static Result _ipcServerProcessNewSession(IpcServer *server) {
|
||||||
{
|
|
||||||
Handle session;
|
Handle session;
|
||||||
Result rc = svcAcceptSession(&session, server->handles[0]);
|
Result rc = svcAcceptSession(&session, server->handles[0]);
|
||||||
if(R_SUCCEEDED(rc) && R_FAILED(rc = _ipcServerAddSession(server, session)))
|
if (R_SUCCEEDED(rc) && R_FAILED(rc = _ipcServerAddSession(server, session))) {
|
||||||
{
|
|
||||||
svcCloseHandle(session);
|
svcCloseHandle(session);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _ipcServerProcessSession(IpcServer* server, IpcServerRequestHandler handler, void* userdata, u32 handleIndex)
|
static Result _ipcServerProcessSession(IpcServer *server, IpcServerRequestHandler handler, void *userdata, u32 handleIndex) {
|
||||||
{
|
|
||||||
s32 unusedIndex;
|
s32 unusedIndex;
|
||||||
IpcServerRequest r;
|
IpcServerRequest r;
|
||||||
size_t dataSize = 0;
|
size_t dataSize = 0;
|
||||||
@@ -154,21 +133,14 @@ static Result _ipcServerProcessSession(IpcServer* server, IpcServerRequestHandle
|
|||||||
bool close = false;
|
bool close = false;
|
||||||
|
|
||||||
Result rc = svcReplyAndReceive(&unusedIndex, &server->handles[handleIndex], 1, 0, UINT64_MAX);
|
Result rc = svcReplyAndReceive(&unusedIndex, &server->handles[handleIndex], 1, 0, UINT64_MAX);
|
||||||
if(R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
|
||||||
rc = _ipcServerParseRequest(&r);
|
rc = _ipcServerParseRequest(&r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
switch (r.hipc.meta.type) {
|
||||||
switch(r.hipc.meta.type)
|
|
||||||
{
|
|
||||||
case CmifCommandType_Request:
|
case CmifCommandType_Request:
|
||||||
_ipcServerPrepareResponse(
|
_ipcServerPrepareResponse(handler(userdata, &r, data, &dataSize), data, dataSize);
|
||||||
handler(userdata, &r, data, &dataSize),
|
|
||||||
data,
|
|
||||||
dataSize
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case CmifCommandType_Close:
|
case CmifCommandType_Close:
|
||||||
_ipcServerPrepareResponse(0, NULL, 0);
|
_ipcServerPrepareResponse(0, NULL, 0);
|
||||||
@@ -180,42 +152,33 @@ static Result _ipcServerProcessSession(IpcServer* server, IpcServerRequestHandle
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = svcReplyAndReceive(&unusedIndex, &server->handles[handleIndex], 0, server->handles[handleIndex], 0);
|
rc = svcReplyAndReceive(&unusedIndex, &server->handles[handleIndex], 0, server->handles[handleIndex], 0);
|
||||||
if(rc == KERNELRESULT(TimedOut))
|
if (rc == KERNELRESULT(TimedOut)) {
|
||||||
{
|
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(R_FAILED(rc) || close)
|
if (R_FAILED(rc) || close) {
|
||||||
{
|
|
||||||
_ipcServerDeleteSession(server, handleIndex);
|
_ipcServerDeleteSession(server, handleIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ipcServerProcess(IpcServer* server, IpcServerRequestHandler handler, void* userdata)
|
Result ipcServerProcess(IpcServer *server, IpcServerRequestHandler handler, void *userdata) {
|
||||||
{
|
|
||||||
s32 handleIndex = -1;
|
s32 handleIndex = -1;
|
||||||
Result rc = svcWaitSynchronization(&handleIndex, server->handles, server->count, UINT64_MAX);
|
Result rc = svcWaitSynchronization(&handleIndex, server->handles, server->count, UINT64_MAX);
|
||||||
|
|
||||||
if(R_SUCCEEDED(rc) && (handleIndex < 0 || handleIndex >= server->count))
|
if (R_SUCCEEDED(rc) && (handleIndex < 0 || handleIndex >= server->count)) {
|
||||||
{
|
|
||||||
rc = MAKERESULT(Module_Libnx, LibnxError_NotFound);
|
rc = MAKERESULT(Module_Libnx, LibnxError_NotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
if (handleIndex) {
|
||||||
if(handleIndex)
|
|
||||||
{
|
|
||||||
rc = _ipcServerProcessSession(server, handler, userdata, handleIndex);
|
rc = _ipcServerProcessSession(server, handler, userdata, handleIndex);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
rc = _ipcServerProcessNewSession(server);
|
rc = _ipcServerProcessNewSession(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,45 +24,38 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
#define IPC_SERVER_EXT_RESPONSE_MAX_DATA_SIZE (0x100 - 0x10 - sizeof(IpcServerRawHeader))
|
#define IPC_SERVER_EXT_RESPONSE_MAX_DATA_SIZE (0x100 - 0x10 - sizeof(IpcServerRawHeader))
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
u64 magic;
|
u64 magic;
|
||||||
union
|
union {
|
||||||
{
|
|
||||||
u64 cmdId;
|
u64 cmdId;
|
||||||
u64 result;
|
u64 result;
|
||||||
};
|
};
|
||||||
} IpcServerRawHeader;
|
} IpcServerRawHeader;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
SmServiceName srvName;
|
SmServiceName srvName;
|
||||||
Handle handles[MAX_WAIT_OBJECTS];
|
Handle handles[MAX_WAIT_OBJECTS];
|
||||||
u32 max;
|
u32 max;
|
||||||
u32 count;
|
u32 count;
|
||||||
} IpcServer;
|
} IpcServer;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
u64 cmdId;
|
u64 cmdId;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
size_t size;
|
size_t size;
|
||||||
} IpcServerRequestData;
|
} IpcServerRequestData;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
HipcParsedRequest hipc;
|
HipcParsedRequest hipc;
|
||||||
IpcServerRequestData data;
|
IpcServerRequestData data;
|
||||||
} IpcServerRequest;
|
} IpcServerRequest;
|
||||||
|
|||||||
@@ -24,21 +24,22 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ipc_service.hpp"
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <switch.h>
|
|
||||||
#include "../hos/apm_ext.h"
|
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <t210.h>
|
|
||||||
#include <max17050.h>
|
#include <max17050.h>
|
||||||
|
#include <switch.h>
|
||||||
|
#include <t210.h>
|
||||||
#include <tmp451.h>
|
#include <tmp451.h>
|
||||||
|
|
||||||
|
#include "../file/config.hpp"
|
||||||
|
#include "../file/errors.hpp"
|
||||||
|
#include "../file/file_utils.hpp"
|
||||||
|
#include "../file/kip.hpp"
|
||||||
|
#include "../hos/apm_ext.h"
|
||||||
|
#include "../mgr/clock_manager.hpp"
|
||||||
|
#include "ipc_service.hpp"
|
||||||
#include <ipc_server.h>
|
#include <ipc_server.h>
|
||||||
#include <lockable_mutex.h>
|
#include <lockable_mutex.h>
|
||||||
#include "../file/file_utils.hpp"
|
|
||||||
#include "../file/errors.hpp"
|
|
||||||
#include "../mgr/clock_manager.hpp"
|
|
||||||
#include "../file/config.hpp"
|
|
||||||
#include "../file/kip.hpp"
|
|
||||||
namespace ipcService {
|
namespace ipcService {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -149,10 +150,8 @@ namespace ipcService {
|
|||||||
|
|
||||||
case HocClkIpcCmd_GetVersionString:
|
case HocClkIpcCmd_GetVersionString:
|
||||||
if (r->hipc.meta.num_recv_buffers >= 1) {
|
if (r->hipc.meta.num_recv_buffers >= 1) {
|
||||||
return GetVersionString(
|
return GetVersionString((char *)hipcGetBufferAddress(r->hipc.data.recv_buffers),
|
||||||
(char*)hipcGetBufferAddress(r->hipc.data.recv_buffers),
|
hipcGetBufferSize(r->hipc.data.recv_buffers));
|
||||||
hipcGetBufferSize(r->hipc.data.recv_buffers)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -179,7 +178,8 @@ namespace ipcService {
|
|||||||
if (r->data.size >= sizeof(std::uint64_t) && r->hipc.meta.num_recv_buffers >= 1) {
|
if (r->data.size >= sizeof(std::uint64_t) && r->hipc.meta.num_recv_buffers >= 1) {
|
||||||
size_t bufSize = hipcGetBufferSize(r->hipc.data.recv_buffers);
|
size_t bufSize = hipcGetBufferSize(r->hipc.data.recv_buffers);
|
||||||
if (bufSize >= sizeof(HocClkTitleProfileList)) {
|
if (bufSize >= sizeof(HocClkTitleProfileList)) {
|
||||||
return GetProfiles((std::uint64_t*)r->data.ptr, (HocClkTitleProfileList*)hipcGetBufferAddress(r->hipc.data.recv_buffers));
|
return GetProfiles((std::uint64_t *)r->data.ptr,
|
||||||
|
(HocClkTitleProfileList *)hipcGetBufferAddress(r->hipc.data.recv_buffers));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -223,12 +223,9 @@ namespace ipcService {
|
|||||||
case HocClkIpcCmd_GetFreqList:
|
case HocClkIpcCmd_GetFreqList:
|
||||||
if (r->data.size >= sizeof(HocClkIpc_GetFreqList_Args) && r->hipc.meta.num_recv_buffers >= 1) {
|
if (r->data.size >= sizeof(HocClkIpc_GetFreqList_Args) && r->hipc.meta.num_recv_buffers >= 1) {
|
||||||
*out_dataSize = sizeof(std::uint32_t);
|
*out_dataSize = sizeof(std::uint32_t);
|
||||||
return GetFreqList(
|
return GetFreqList((HocClkIpc_GetFreqList_Args *)r->data.ptr,
|
||||||
(HocClkIpc_GetFreqList_Args*)r->data.ptr,
|
|
||||||
(std::uint32_t *)hipcGetBufferAddress(r->hipc.data.recv_buffers),
|
(std::uint32_t *)hipcGetBufferAddress(r->hipc.data.recv_buffers),
|
||||||
hipcGetBufferSize(r->hipc.data.recv_buffers),
|
hipcGetBufferSize(r->hipc.data.recv_buffers), (std::uint32_t *)out_data);
|
||||||
(std::uint32_t*)out_data
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -259,7 +256,7 @@ namespace ipcService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
void Initialize() {
|
void Initialize() {
|
||||||
std::int32_t priority;
|
std::int32_t priority;
|
||||||
@@ -297,4 +294,4 @@ namespace ipcService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace ipcService
|
||||||
|
|||||||
@@ -35,4 +35,4 @@ namespace ipcService {
|
|||||||
void Exit();
|
void Exit();
|
||||||
void SetRunning(bool running);
|
void SetRunning(bool running);
|
||||||
|
|
||||||
}
|
} // namespace ipcService
|
||||||
|
|||||||
@@ -27,21 +27,20 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
|
#include "board/board.hpp"
|
||||||
|
#include "file/config.hpp"
|
||||||
#include "file/errors.hpp"
|
#include "file/errors.hpp"
|
||||||
#include "file/file_utils.hpp"
|
#include "file/file_utils.hpp"
|
||||||
#include "board/board.hpp"
|
|
||||||
#include "hos/process_management.hpp"
|
#include "hos/process_management.hpp"
|
||||||
#include "mgr/clock_manager.hpp"
|
|
||||||
#include "ipc/ipc_service.hpp"
|
#include "ipc/ipc_service.hpp"
|
||||||
#include "file/config.hpp"
|
#include "mgr/clock_manager.hpp"
|
||||||
|
|
||||||
|
|
||||||
#define INNER_HEAP_SIZE 0x40000
|
#define INNER_HEAP_SIZE 0x40000
|
||||||
|
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
void virtmemSetup(void);
|
void virtmemSetup(void);
|
||||||
|
|
||||||
extern std::uint32_t __start__;
|
extern std::uint32_t __start__;
|
||||||
@@ -72,8 +71,7 @@ extern "C"
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __libnx_initheap(void)
|
void __libnx_initheap(void) {
|
||||||
{
|
|
||||||
void *addr = nx_inner_heap;
|
void *addr = nx_inner_heap;
|
||||||
size_t size = nx_inner_heap_size;
|
size_t size = nx_inner_heap_size;
|
||||||
|
|
||||||
@@ -87,16 +85,13 @@ extern "C"
|
|||||||
virtmemSetup();
|
virtmemSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void __appInit(void)
|
void __appInit(void) {
|
||||||
{
|
if (R_FAILED(smInitialize())) {
|
||||||
if (R_FAILED(smInitialize()))
|
|
||||||
{
|
|
||||||
fatalThrow(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM));
|
fatalThrow(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result rc = setsysInitialize();
|
Result rc = setsysInitialize();
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
{
|
|
||||||
SetSysFirmwareVersion fw;
|
SetSysFirmwareVersion fw;
|
||||||
rc = setsysGetFirmwareVersion(&fw);
|
rc = setsysGetFirmwareVersion(&fw);
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc))
|
||||||
@@ -111,11 +106,9 @@ extern "C"
|
|||||||
rc = i2cInitialize();
|
rc = i2cInitialize();
|
||||||
if (R_FAILED(rc))
|
if (R_FAILED(rc))
|
||||||
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __appExit(void)
|
void __appExit(void) {
|
||||||
{
|
|
||||||
// CloseFanControllerThread();
|
// CloseFanControllerThread();
|
||||||
// fanExit();
|
// fanExit();
|
||||||
i2cExit();
|
i2cExit();
|
||||||
@@ -126,11 +119,9 @@ extern "C"
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
|
||||||
Result rc = fileUtils::Initialize();
|
Result rc = fileUtils::Initialize();
|
||||||
if (R_FAILED(rc))
|
if (R_FAILED(rc)) {
|
||||||
{
|
|
||||||
fatalThrow(rc);
|
fatalThrow(rc);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -145,7 +136,6 @@ int main(int argc, char** argv)
|
|||||||
clockManager::Initialize();
|
clockManager::Initialize();
|
||||||
ipcService::Initialize();
|
ipcService::Initialize();
|
||||||
|
|
||||||
|
|
||||||
clockManager::SetRunning(true);
|
clockManager::SetRunning(true);
|
||||||
config::SetEnabled(true);
|
config::SetEnabled(true);
|
||||||
ipcService::SetRunning(true);
|
ipcService::SetRunning(true);
|
||||||
@@ -154,8 +144,7 @@ int main(int argc, char** argv)
|
|||||||
// InitFanController(table);
|
// InitFanController(table);
|
||||||
// StartFanControllerThread();
|
// StartFanControllerThread();
|
||||||
|
|
||||||
while (clockManager::Running())
|
while (clockManager::Running()) {
|
||||||
{
|
|
||||||
clockManager::Tick();
|
clockManager::Tick();
|
||||||
clockManager::WaitForNextTick();
|
clockManager::WaitForNextTick();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
#include "../file/file_utils.hpp"
|
#include "../file/file_utils.hpp"
|
||||||
|
|
||||||
|
|
||||||
Result QueryMemoryMapping(u64 *virtaddr, u64 physaddr, u64 size) {
|
Result QueryMemoryMapping(u64 *virtaddr, u64 physaddr, u64 size) {
|
||||||
if (hosversionAtLeast(10, 0, 0)) {
|
if (hosversionAtLeast(10, 0, 0)) {
|
||||||
u64 out_size;
|
u64 out_size;
|
||||||
|
|||||||
@@ -24,32 +24,31 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "clock_manager.hpp"
|
|
||||||
#include <cstring>
|
|
||||||
#include "../file/file_utils.hpp"
|
|
||||||
#include "../board/board.hpp"
|
|
||||||
#include "../hos/process_management.hpp"
|
|
||||||
#include "../file/errors.hpp"
|
|
||||||
#include "../ipc/ipc_service.hpp"
|
|
||||||
#include "../file/kip.hpp"
|
|
||||||
#include <i2c.h>
|
|
||||||
#include "../i2c/i2cDrv.h"
|
|
||||||
#include "../display/display_refresh_rate.hpp"
|
|
||||||
#include <cstdio>
|
|
||||||
#include <crc32.h>
|
#include <crc32.h>
|
||||||
#include "../file/config.hpp"
|
#include <cstdio>
|
||||||
#include "../hos/integrations.hpp"
|
#include <cstring>
|
||||||
#include "../util/lockable_mutex.h"
|
#include <i2c.h>
|
||||||
#include "../file/kip.hpp"
|
|
||||||
#include "governor.hpp"
|
#include "../board/board.hpp"
|
||||||
#include "../display/aula.hpp"
|
#include "../display/aula.hpp"
|
||||||
|
#include "../display/display_refresh_rate.hpp"
|
||||||
|
#include "../file/config.hpp"
|
||||||
|
#include "../file/errors.hpp"
|
||||||
|
#include "../file/file_utils.hpp"
|
||||||
|
#include "../file/kip.hpp"
|
||||||
|
#include "../hos/integrations.hpp"
|
||||||
|
#include "../hos/process_management.hpp"
|
||||||
|
#include "../i2c/i2cDrv.h"
|
||||||
|
#include "../ipc/ipc_service.hpp"
|
||||||
#include "../soc/gm20b.hpp"
|
#include "../soc/gm20b.hpp"
|
||||||
|
#include "../util/lockable_mutex.h"
|
||||||
|
#include "clock_manager.hpp"
|
||||||
|
#include "governor.hpp"
|
||||||
|
|
||||||
#define HOSPPC_HAS_BOOST (hosversionAtLeast(7, 0, 0))
|
#define HOSPPC_HAS_BOOST (hosversionAtLeast(7, 0, 0))
|
||||||
|
|
||||||
namespace clockManager {
|
namespace clockManager {
|
||||||
|
|
||||||
|
|
||||||
bool gRunning = false;
|
bool gRunning = false;
|
||||||
LockableMutex gContextMutex;
|
LockableMutex gContextMutex;
|
||||||
HocClkContext gContext = {};
|
HocClkContext gContext = {};
|
||||||
@@ -59,8 +58,7 @@ namespace clockManager {
|
|||||||
std::uint64_t gLastPowerLogNs = 0;
|
std::uint64_t gLastPowerLogNs = 0;
|
||||||
std::uint64_t gLastCsvWriteNs = 0;
|
std::uint64_t gLastCsvWriteNs = 0;
|
||||||
|
|
||||||
bool IsAssignableHz(HocClkModule module, std::uint32_t hz)
|
bool IsAssignableHz(HocClkModule module, std::uint32_t hz) {
|
||||||
{
|
|
||||||
switch (module) {
|
switch (module) {
|
||||||
case HocClkModule_CPU:
|
case HocClkModule_CPU:
|
||||||
return hz >= 500000000;
|
return hz >= 500000000;
|
||||||
@@ -71,8 +69,7 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t GetMaxAllowedHz(HocClkModule module, HocClkProfile profile)
|
std::uint32_t GetMaxAllowedHz(HocClkModule module, HocClkProfile profile) {
|
||||||
{
|
|
||||||
if (config::GetConfigValue(HocClkConfigValue_UncappedClocks)) {
|
if (config::GetConfigValue(HocClkConfigValue_UncappedClocks)) {
|
||||||
return ~0; // Integer limit, uncapped clocks ON
|
return ~0; // Integer limit, uncapped clocks ON
|
||||||
} else {
|
} else {
|
||||||
@@ -144,8 +141,7 @@ namespace clockManager {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t GetNearestHz(HocClkModule module, std::uint32_t inHz, std::uint32_t maxHz)
|
std::uint32_t GetNearestHz(HocClkModule module, std::uint32_t inHz, std::uint32_t maxHz) {
|
||||||
{
|
|
||||||
std::uint32_t *freqs = &gFreqTable[module].list[0];
|
std::uint32_t *freqs = &gFreqTable[module].list[0];
|
||||||
size_t count = gFreqTable[module].count - 1;
|
size_t count = gFreqTable[module].count - 1;
|
||||||
|
|
||||||
@@ -163,21 +159,20 @@ namespace clockManager {
|
|||||||
return freqs[i];
|
return freqs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetToStockClocks()
|
void ResetToStockClocks() {
|
||||||
{
|
|
||||||
board::ResetToStockCpu();
|
board::ResetToStockCpu();
|
||||||
if (config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
if (config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
||||||
if (board::GetSocType() == HocClkSocType_Erista)
|
if (board::GetSocType() == HocClkSocType_Erista)
|
||||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000);
|
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000);
|
||||||
else
|
else
|
||||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh),
|
||||||
|
board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
||||||
}
|
}
|
||||||
|
|
||||||
board::ResetToStockGpu();
|
board::ResetToStockGpu();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigIntervalTimeout(HocClkConfigValue intervalMsConfigValue, std::uint64_t ns, std::uint64_t *lastLogNs)
|
bool ConfigIntervalTimeout(HocClkConfigValue intervalMsConfigValue, std::uint64_t ns, std::uint64_t *lastLogNs) {
|
||||||
{
|
|
||||||
std::uint64_t logInterval = config::GetConfigValue(intervalMsConfigValue) * 1000000ULL;
|
std::uint64_t logInterval = config::GetConfigValue(intervalMsConfigValue) * 1000000ULL;
|
||||||
bool shouldLog = logInterval && ((ns - *lastLogNs) > logInterval);
|
bool shouldLog = logInterval && ((ns - *lastLogNs) > logInterval);
|
||||||
|
|
||||||
@@ -188,8 +183,7 @@ namespace clockManager {
|
|||||||
return shouldLog;
|
return shouldLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshFreqTableRow(HocClkModule module)
|
void RefreshFreqTableRow(HocClkModule module) {
|
||||||
{
|
|
||||||
std::scoped_lock lock{ gContextMutex };
|
std::scoped_lock lock{ gContextMutex };
|
||||||
|
|
||||||
std::uint32_t freqs[HOCCLK_FREQ_LIST_MAX];
|
std::uint32_t freqs[HOCCLK_FREQ_LIST_MAX];
|
||||||
@@ -201,15 +195,16 @@ namespace clockManager {
|
|||||||
std::uint32_t *hz = &gFreqTable[module].list[0];
|
std::uint32_t *hz = &gFreqTable[module].list[0];
|
||||||
gFreqTable[module].count = 0;
|
gFreqTable[module].count = 0;
|
||||||
|
|
||||||
if (module == HocClkModule_GPU && board::GetSocType() == HocClkSocType_Mariko
|
if (module == HocClkModule_GPU && board::GetSocType() == HocClkSocType_Mariko &&
|
||||||
&& config::GetConfigValue(HocClkConfigValue_MarikoMiddleFreqs)) {
|
config::GetConfigValue(HocClkConfigValue_MarikoMiddleFreqs)) {
|
||||||
constexpr u32 kStep = 38400000;
|
constexpr u32 kStep = 38400000;
|
||||||
constexpr u32 kPcvStep = 76800000;
|
constexpr u32 kPcvStep = 76800000;
|
||||||
u32 kMax = ~0;
|
u32 kMax = ~0;
|
||||||
for (u32 i = 0; i < count; i++) {
|
for (u32 i = 0; i < count; i++) {
|
||||||
for (u32 j = 0; j < count; j++) {
|
for (u32 j = 0; j < count; j++) {
|
||||||
if (freqs[j] + kStep == freqs[i]) {
|
if (freqs[j] + kStep == freqs[i]) {
|
||||||
if (freqs[j] < kMax) kMax = freqs[j];
|
if (freqs[j] < kMax)
|
||||||
|
kMax = freqs[j];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -217,7 +212,8 @@ namespace clockManager {
|
|||||||
if (kMax == ~0u) {
|
if (kMax == ~0u) {
|
||||||
kMax = 0;
|
kMax = 0;
|
||||||
for (u32 i = 0; i < count; i++) {
|
for (u32 i = 0; i < count; i++) {
|
||||||
if (freqs[i] > kMax) kMax = freqs[i];
|
if (freqs[i] > kMax)
|
||||||
|
kMax = freqs[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,32 +260,19 @@ namespace clockManager {
|
|||||||
u32 hz;
|
u32 hz;
|
||||||
HocClkConfigValue kval;
|
HocClkConfigValue kval;
|
||||||
} eristaGpuVoltMap[] = {
|
} eristaGpuVoltMap[] = {
|
||||||
{ 76800000, KipConfigValue_g_volt_e_76800 },
|
{ 76800000, KipConfigValue_g_volt_e_76800 }, { 115200000, KipConfigValue_g_volt_e_115200 },
|
||||||
{ 115200000, KipConfigValue_g_volt_e_115200 },
|
{ 153600000, KipConfigValue_g_volt_e_153600 }, { 192000000, KipConfigValue_g_volt_e_192000 },
|
||||||
{ 153600000, KipConfigValue_g_volt_e_153600 },
|
{ 230400000, KipConfigValue_g_volt_e_230400 }, { 268800000, KipConfigValue_g_volt_e_268800 },
|
||||||
{ 192000000, KipConfigValue_g_volt_e_192000 },
|
{ 307200000, KipConfigValue_g_volt_e_307200 }, { 345600000, KipConfigValue_g_volt_e_345600 },
|
||||||
{ 230400000, KipConfigValue_g_volt_e_230400 },
|
{ 384000000, KipConfigValue_g_volt_e_384000 }, { 422400000, KipConfigValue_g_volt_e_422400 },
|
||||||
{ 268800000, KipConfigValue_g_volt_e_268800 },
|
{ 460800000, KipConfigValue_g_volt_e_460800 }, { 499200000, KipConfigValue_g_volt_e_499200 },
|
||||||
{ 307200000, KipConfigValue_g_volt_e_307200 },
|
{ 537600000, KipConfigValue_g_volt_e_537600 }, { 576000000, KipConfigValue_g_volt_e_576000 },
|
||||||
{ 345600000, KipConfigValue_g_volt_e_345600 },
|
{ 614400000, KipConfigValue_g_volt_e_614400 }, { 652800000, KipConfigValue_g_volt_e_652800 },
|
||||||
{ 384000000, KipConfigValue_g_volt_e_384000 },
|
{ 691200000, KipConfigValue_g_volt_e_691200 }, { 729600000, KipConfigValue_g_volt_e_729600 },
|
||||||
{ 422400000, KipConfigValue_g_volt_e_422400 },
|
{ 768000000, KipConfigValue_g_volt_e_768000 }, { 806400000, KipConfigValue_g_volt_e_806400 },
|
||||||
{ 460800000, KipConfigValue_g_volt_e_460800 },
|
{ 844800000, KipConfigValue_g_volt_e_844800 }, { 883200000, KipConfigValue_g_volt_e_883200 },
|
||||||
{ 499200000, KipConfigValue_g_volt_e_499200 },
|
{ 921600000, KipConfigValue_g_volt_e_921600 }, { 960000000, KipConfigValue_g_volt_e_960000 },
|
||||||
{ 537600000, KipConfigValue_g_volt_e_537600 },
|
{ 998400000, KipConfigValue_g_volt_e_998400 }, { 1036800000, KipConfigValue_g_volt_e_1036800 },
|
||||||
{ 576000000, KipConfigValue_g_volt_e_576000 },
|
|
||||||
{ 614400000, KipConfigValue_g_volt_e_614400 },
|
|
||||||
{ 652800000, KipConfigValue_g_volt_e_652800 },
|
|
||||||
{ 691200000, KipConfigValue_g_volt_e_691200 },
|
|
||||||
{ 729600000, KipConfigValue_g_volt_e_729600 },
|
|
||||||
{ 768000000, KipConfigValue_g_volt_e_768000 },
|
|
||||||
{ 806400000, KipConfigValue_g_volt_e_806400 },
|
|
||||||
{ 844800000, KipConfigValue_g_volt_e_844800 },
|
|
||||||
{ 883200000, KipConfigValue_g_volt_e_883200 },
|
|
||||||
{ 921600000, KipConfigValue_g_volt_e_921600 },
|
|
||||||
{ 960000000, KipConfigValue_g_volt_e_960000 },
|
|
||||||
{ 998400000, KipConfigValue_g_volt_e_998400 },
|
|
||||||
{1036800000, KipConfigValue_g_volt_e_1036800 },
|
|
||||||
{ 1075200000, KipConfigValue_g_volt_e_1075200 },
|
{ 1075200000, KipConfigValue_g_volt_e_1075200 },
|
||||||
};
|
};
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
@@ -301,7 +284,8 @@ namespace clockManager {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (skip) continue;
|
if (skip)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
*hz = freqs[i];
|
*hz = freqs[i];
|
||||||
@@ -314,14 +298,15 @@ namespace clockManager {
|
|||||||
fileUtils::LogLine("[mgr] count = %u", gFreqTable[module].count);
|
fileUtils::LogLine("[mgr] count = %u", gFreqTable[module].count);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleSafetyFeatures(bool isBoost)
|
bool HandleSafetyFeatures(bool isBoost) {
|
||||||
{
|
if (((tmp451TempSoc() / 1000) > (int)config::GetConfigValue(HocClkConfigValue_ThermalThrottleThreshold)) &&
|
||||||
if (((tmp451TempSoc() / 1000) > (int)config::GetConfigValue(HocClkConfigValue_ThermalThrottleThreshold)) && config::GetConfigValue(HocClkConfigValue_ThermalThrottle)) {
|
config::GetConfigValue(HocClkConfigValue_ThermalThrottle)) {
|
||||||
ResetToStockClocks();
|
ResetToStockClocks();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config::GetConfigValue(HocClkConfigValue_AutoRAMCPUOverclock) && !isBoost && !governor::isCpuGovernorEnabled && (board::GetSocType() == HocClkSocType_Mariko)) {
|
if (config::GetConfigValue(HocClkConfigValue_AutoRAMCPUOverclock) && !isBoost && !governor::isCpuGovernorEnabled &&
|
||||||
|
(board::GetSocType() == HocClkSocType_Mariko)) {
|
||||||
u32 ramHz = gContext.freqs[HocClkModule_MEM];
|
u32 ramHz = gContext.freqs[HocClkModule_MEM];
|
||||||
u32 threshold = (u32)config::GetConfigValue(HocClkConfigValue_AutoRamCpuRamOCThreshold) * 1000;
|
u32 threshold = (u32)config::GetConfigValue(HocClkConfigValue_AutoRamCpuRamOCThreshold) * 1000;
|
||||||
if (ramHz >= threshold) {
|
if (ramHz >= threshold) {
|
||||||
@@ -339,8 +324,7 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void HandleMiscFeatures()
|
void HandleMiscFeatures() {
|
||||||
{
|
|
||||||
|
|
||||||
// these dont need to run that often, so dont bother
|
// these dont need to run that often, so dont bother
|
||||||
static u32 tick = 0;
|
static u32 tick = 0;
|
||||||
@@ -394,9 +378,7 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DVFSReset() {
|
||||||
void DVFSReset()
|
|
||||||
{
|
|
||||||
if (config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
if (config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||||
board::PcvHijackGpuVolts(0); // Reset to vMin
|
board::PcvHijackGpuVolts(0); // Reset to vMin
|
||||||
|
|
||||||
@@ -416,8 +398,7 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleFreqReset(HocClkModule module, bool isBoost, bool didHijackPcv)
|
void HandleFreqReset(HocClkModule module, bool isBoost, bool didHijackPcv) {
|
||||||
{
|
|
||||||
switch (module) {
|
switch (module) {
|
||||||
case HocClkModule_CPU:
|
case HocClkModule_CPU:
|
||||||
if (!(isBoost || (config::GetConfigValue(HocClkConfigValue_OverwriteBoostMode) && isBoost)))
|
if (!(isBoost || (config::GetConfigValue(HocClkConfigValue_OverwriteBoostMode) && isBoost)))
|
||||||
@@ -426,7 +407,9 @@ namespace clockManager {
|
|||||||
if (board::GetSocType() == HocClkSocType_Erista)
|
if (board::GetSocType() == HocClkSocType_Erista)
|
||||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000);
|
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000);
|
||||||
else
|
else
|
||||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow),
|
||||||
|
config::GetConfigValue(KipConfigValue_marikoCpuUVHigh),
|
||||||
|
board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HocClkModule_GPU:
|
case HocClkModule_GPU:
|
||||||
@@ -449,8 +432,7 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetClocks(bool isBoost)
|
void SetClocks(bool isBoost) {
|
||||||
{
|
|
||||||
std::uint32_t targetHz = 0;
|
std::uint32_t targetHz = 0;
|
||||||
std::uint32_t maxHz = 0;
|
std::uint32_t maxHz = 0;
|
||||||
std::uint32_t nearestHz = 0;
|
std::uint32_t nearestHz = 0;
|
||||||
@@ -521,12 +503,9 @@ namespace clockManager {
|
|||||||
nearestHz = GetNearestHz((HocClkModule)module, targetHz, maxHz);
|
nearestHz = GetNearestHz((HocClkModule)module, targetHz, maxHz);
|
||||||
|
|
||||||
if (nearestHz != gContext.freqs[module]) {
|
if (nearestHz != gContext.freqs[module]) {
|
||||||
fileUtils::LogLine(
|
fileUtils::LogLine("[mgr] %s clock set : %u.%u MHz (target = %u.%u MHz)", board::GetModuleName((HocClkModule)module, true),
|
||||||
"[mgr] %s clock set : %u.%u MHz (target = %u.%u MHz)",
|
nearestHz / 1000000, nearestHz / 100000 - nearestHz / 1000000 * 10, targetHz / 1000000,
|
||||||
board::GetModuleName((HocClkModule)module, true),
|
targetHz / 100000 - targetHz / 1000000 * 10);
|
||||||
nearestHz / 1000000, nearestHz / 100000 - nearestHz / 1000000 * 10,
|
|
||||||
targetHz / 1000000, targetHz / 100000 - targetHz / 1000000 * 10
|
|
||||||
);
|
|
||||||
|
|
||||||
// The logic MUST be done in this order otherwise you WILL get crashes
|
// The logic MUST be done in this order otherwise you WILL get crashes
|
||||||
if (module == HocClkModule_MEM && targetHz > oldHz && config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
if (module == HocClkModule_MEM && targetHz > oldHz && config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||||
@@ -553,8 +532,7 @@ namespace clockManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RefreshContext()
|
bool RefreshContext() {
|
||||||
{
|
|
||||||
bool hasChanged = false;
|
bool hasChanged = false;
|
||||||
|
|
||||||
std::uint32_t mode = 0;
|
std::uint32_t mode = 0;
|
||||||
@@ -589,7 +567,8 @@ namespace clockManager {
|
|||||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||||
hz = board::GetHz((HocClkModule)module);
|
hz = board::GetHz((HocClkModule)module);
|
||||||
if (hz != 0 && hz != gContext.freqs[module]) {
|
if (hz != 0 && hz != gContext.freqs[module]) {
|
||||||
fileUtils::LogLine("[mgr] %s clock change: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), hz / 1000000, hz / 100000 - hz / 1000000 * 10);
|
fileUtils::LogLine("[mgr] %s clock change: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), hz / 1000000,
|
||||||
|
hz / 100000 - hz / 1000000 * 10);
|
||||||
gContext.freqs[module] = hz;
|
gContext.freqs[module] = hz;
|
||||||
|
|
||||||
if (module < HocClkModuleStable_EnumMax) {
|
if (module < HocClkModuleStable_EnumMax) {
|
||||||
@@ -601,7 +580,8 @@ namespace clockManager {
|
|||||||
hz = config::GetOverrideHz((HocClkModule)module);
|
hz = config::GetOverrideHz((HocClkModule)module);
|
||||||
if (hz != gContext.overrideFreqs[module]) {
|
if (hz != gContext.overrideFreqs[module]) {
|
||||||
if (hz) {
|
if (hz) {
|
||||||
fileUtils::LogLine("[mgr] %s override change: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), hz / 1000000, hz / 100000 - hz / 1000000 * 10);
|
fileUtils::LogLine("[mgr] %s override change: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), hz / 1000000,
|
||||||
|
hz / 100000 - hz / 1000000 * 10);
|
||||||
}
|
}
|
||||||
gContext.overrideFreqs[module] = hz;
|
gContext.overrideFreqs[module] = hz;
|
||||||
|
|
||||||
@@ -620,7 +600,8 @@ namespace clockManager {
|
|||||||
for (unsigned int sensor = 0; sensor < HocClkThermalSensor_EnumMax; sensor++) {
|
for (unsigned int sensor = 0; sensor < HocClkThermalSensor_EnumMax; sensor++) {
|
||||||
millis = board::GetTemperatureMilli((HocClkThermalSensor)sensor);
|
millis = board::GetTemperatureMilli((HocClkThermalSensor)sensor);
|
||||||
if (shouldLogTemp) {
|
if (shouldLogTemp) {
|
||||||
fileUtils::LogLine("[mgr] %s temp: %u.%u °C", board::GetThermalSensorName((HocClkThermalSensor)sensor, true), millis / 1000, (millis - millis / 1000 * 1000) / 100);
|
fileUtils::LogLine("[mgr] %s temp: %u.%u °C", board::GetThermalSensorName((HocClkThermalSensor)sensor, true), millis / 1000,
|
||||||
|
(millis - millis / 1000 * 1000) / 100);
|
||||||
}
|
}
|
||||||
gContext.temps[sensor] = millis;
|
gContext.temps[sensor] = millis;
|
||||||
|
|
||||||
@@ -650,7 +631,8 @@ namespace clockManager {
|
|||||||
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
for (unsigned int module = 0; module < HocClkModule_EnumMax; module++) {
|
||||||
realHz = board::GetRealHz((HocClkModule)module);
|
realHz = board::GetRealHz((HocClkModule)module);
|
||||||
if (shouldLogFreq) {
|
if (shouldLogFreq) {
|
||||||
fileUtils::LogLine("[mgr] %s real freq: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), realHz / 1000000, realHz / 100000 - realHz / 1000000 * 10);
|
fileUtils::LogLine("[mgr] %s real freq: %u.%u MHz", board::GetModuleName((HocClkModule)module, true), realHz / 1000000,
|
||||||
|
realHz / 100000 - realHz / 1000000 * 10);
|
||||||
}
|
}
|
||||||
gContext.realFreqs[module] = realHz;
|
gContext.realFreqs[module] = realHz;
|
||||||
|
|
||||||
@@ -704,8 +686,7 @@ namespace clockManager {
|
|||||||
return hasChanged;
|
return hasChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize()
|
void Initialize() {
|
||||||
{
|
|
||||||
gContext = {};
|
gContext = {};
|
||||||
gContext.applicationId = 0;
|
gContext.applicationId = 0;
|
||||||
gContext.profile = HocClkProfile_Handheld;
|
gContext.profile = HocClkProfile_Handheld;
|
||||||
@@ -744,7 +725,8 @@ namespace clockManager {
|
|||||||
gContext.isDram8GB = board::IsDram8GB();
|
gContext.isDram8GB = board::IsDram8GB();
|
||||||
gContext.consoleType = board::GetConsoleType();
|
gContext.consoleType = board::GetConsoleType();
|
||||||
|
|
||||||
board::SetGpuSchedulingMode((GpuSchedulingMode)config::GetConfigValue(HocClkConfigValue_GPUScheduling), (GpuSchedulingOverrideMethod)config::GetConfigValue(HocClkConfigValue_GPUSchedulingMethod));
|
board::SetGpuSchedulingMode((GpuSchedulingMode)config::GetConfigValue(HocClkConfigValue_GPUScheduling),
|
||||||
|
(GpuSchedulingOverrideMethod)config::GetConfigValue(HocClkConfigValue_GPUSchedulingMethod));
|
||||||
gContext.gpuSchedulingMode = (GpuSchedulingMode)config::GetConfigValue(HocClkConfigValue_GPUScheduling);
|
gContext.gpuSchedulingMode = (GpuSchedulingMode)config::GetConfigValue(HocClkConfigValue_GPUScheduling);
|
||||||
|
|
||||||
gContext.isSysDockInstalled = integrations::GetSysDockState();
|
gContext.isSysDockInstalled = integrations::GetSysDockState();
|
||||||
@@ -757,37 +739,31 @@ namespace clockManager {
|
|||||||
governor::startThreads();
|
governor::startThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Exit()
|
void Exit() {
|
||||||
{
|
|
||||||
governor::exitThreads();
|
governor::exitThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
HocClkContext GetCurrentContext()
|
HocClkContext GetCurrentContext() {
|
||||||
{
|
|
||||||
std::scoped_lock lock{ gContextMutex };
|
std::scoped_lock lock{ gContextMutex };
|
||||||
return gContext;
|
return gContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetRunning(bool running)
|
void SetRunning(bool running) {
|
||||||
{
|
|
||||||
gRunning = running;
|
gRunning = running;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Running()
|
bool Running() {
|
||||||
{
|
|
||||||
return gRunning;
|
return gRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetFreqList(HocClkModule module, std::uint32_t *list, std::uint32_t maxCount, std::uint32_t *outCount)
|
void GetFreqList(HocClkModule module, std::uint32_t *list, std::uint32_t maxCount, std::uint32_t *outCount) {
|
||||||
{
|
|
||||||
ASSERT_ENUM_VALID(HocClkModule, module);
|
ASSERT_ENUM_VALID(HocClkModule, module);
|
||||||
|
|
||||||
*outCount = std::min(maxCount, gFreqTable[module].count);
|
*outCount = std::min(maxCount, gFreqTable[module].count);
|
||||||
memcpy(list, &gFreqTable[module].list[0], *outCount * sizeof(gFreqTable[0].list[0]));
|
memcpy(list, &gFreqTable[module].list[0], *outCount * sizeof(gFreqTable[0].list[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tick()
|
void Tick() {
|
||||||
{
|
|
||||||
std::scoped_lock lock{ gContextMutex };
|
std::scoped_lock lock{ gContextMutex };
|
||||||
std::uint32_t mode = 0;
|
std::uint32_t mode = 0;
|
||||||
Result rc = apmExtGetCurrentPerformanceConfiguration(&mode);
|
Result rc = apmExtGetCurrentPerformanceConfiguration(&mode);
|
||||||
@@ -799,13 +775,13 @@ namespace clockManager {
|
|||||||
HandleMiscFeatures();
|
HandleMiscFeatures();
|
||||||
|
|
||||||
// GPU clock should always be the same unless PCV has overwriten our change, so reset it
|
// GPU clock should always be the same unless PCV has overwriten our change, so reset it
|
||||||
if ((RefreshContext() || config::Refresh() || (board::GetRealHz(HocClkModule_GPU) != gContext.freqs[HocClkModule_GPU])) && !shouldSkipClockSet) {
|
if ((RefreshContext() || config::Refresh() || (board::GetRealHz(HocClkModule_GPU) != gContext.freqs[HocClkModule_GPU])) &&
|
||||||
|
!shouldSkipClockSet) {
|
||||||
SetClocks(isBoost);
|
SetClocks(isBoost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitForNextTick()
|
void WaitForNextTick() {
|
||||||
{
|
|
||||||
if (board::GetHz(HocClkModule_MEM) > 665000000)
|
if (board::GetHz(HocClkModule_MEM) > 665000000)
|
||||||
svcSleepThread(config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL);
|
svcSleepThread(config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
#include "../util/lockable_mutex.h"
|
#include "../util/lockable_mutex.h"
|
||||||
|
|
||||||
namespace clockManager {
|
namespace clockManager {
|
||||||
@@ -37,7 +38,6 @@ namespace clockManager {
|
|||||||
std::uint32_t list[HOCCLK_FREQ_LIST_MAX];
|
std::uint32_t list[HOCCLK_FREQ_LIST_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern bool hasChanged;
|
extern bool hasChanged;
|
||||||
|
|
||||||
// instance variables
|
// instance variables
|
||||||
@@ -50,7 +50,6 @@ namespace clockManager {
|
|||||||
extern std::uint64_t gLastPowerLogNs;
|
extern std::uint64_t gLastPowerLogNs;
|
||||||
extern std::uint64_t gLastCsvWriteNs;
|
extern std::uint64_t gLastCsvWriteNs;
|
||||||
|
|
||||||
|
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void Exit();
|
void Exit();
|
||||||
|
|
||||||
@@ -66,4 +65,4 @@ namespace clockManager {
|
|||||||
|
|
||||||
void Tick();
|
void Tick();
|
||||||
void WaitForNextTick();
|
void WaitForNextTick();
|
||||||
}
|
} // namespace clockManager
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "governor.hpp"
|
|
||||||
#include "../hos/process_management.hpp"
|
#include "../hos/process_management.hpp"
|
||||||
|
#include "governor.hpp"
|
||||||
#include <hocclk/clock_manager.h>
|
#include <hocclk/clock_manager.h>
|
||||||
|
|
||||||
namespace governor {
|
namespace governor {
|
||||||
|
|
||||||
#define POLL_NS 5'000'000 // 5 ms – governor poll rate
|
#define POLL_NS 5'000'000 // 5 ms – governor poll rate
|
||||||
@@ -44,8 +45,10 @@ namespace governor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto resolve = [](u8 app, u8 temp) -> u8 {
|
auto resolve = [](u8 app, u8 temp) -> u8 {
|
||||||
if (temp == ComponentGovernor_Disabled) return ComponentGovernor_Disabled;
|
if (temp == ComponentGovernor_Disabled)
|
||||||
if (temp != ComponentGovernor_DoNotOverride) return temp;
|
return ComponentGovernor_Disabled;
|
||||||
|
if (temp != ComponentGovernor_DoNotOverride)
|
||||||
|
return temp;
|
||||||
return app;
|
return app;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,8 +71,10 @@ namespace governor {
|
|||||||
if (newVrrGovernorState == false && lastVrrGovernorState == true)
|
if (newVrrGovernorState == false && lastVrrGovernorState == true)
|
||||||
board::ResetToStockDisplay();
|
board::ResetToStockDisplay();
|
||||||
|
|
||||||
if (newCpuGovernorState != lastCpuGovernorState || newGpuGovernorState != lastGpuGovernorState || newVrrGovernorState != lastVrrGovernorState) {
|
if (newCpuGovernorState != lastCpuGovernorState || newGpuGovernorState != lastGpuGovernorState ||
|
||||||
fileUtils::LogLine("[mgr] Governor state changed: CPU %s, GPU %s, VRR %s", newCpuGovernorState ? "enabled" : "disabled", newGpuGovernorState ? "enabled" : "disabled", newVrrGovernorState ? "enabled" : "disabled");
|
newVrrGovernorState != lastVrrGovernorState) {
|
||||||
|
fileUtils::LogLine("[mgr] Governor state changed: CPU %s, GPU %s, VRR %s", newCpuGovernorState ? "enabled" : "disabled",
|
||||||
|
newGpuGovernorState ? "enabled" : "disabled", newVrrGovernorState ? "enabled" : "disabled");
|
||||||
lastCpuGovernorState = newCpuGovernorState;
|
lastCpuGovernorState = newCpuGovernorState;
|
||||||
lastGpuGovernorState = newGpuGovernorState;
|
lastGpuGovernorState = newGpuGovernorState;
|
||||||
lastVrrGovernorState = newVrrGovernorState;
|
lastVrrGovernorState = newVrrGovernorState;
|
||||||
@@ -91,13 +96,9 @@ namespace governor {
|
|||||||
u32 ResolveTargetHz(HocClkModule module) {
|
u32 ResolveTargetHz(HocClkModule module) {
|
||||||
u32 hz = clockManager::gContext.overrideFreqs[module];
|
u32 hz = clockManager::gContext.overrideFreqs[module];
|
||||||
if (!hz)
|
if (!hz)
|
||||||
hz = config::GetAutoClockHz(
|
hz = config::GetAutoClockHz(clockManager::gContext.applicationId, module, clockManager::gContext.profile, false);
|
||||||
clockManager::gContext.applicationId, module,
|
|
||||||
clockManager::gContext.profile, false);
|
|
||||||
if (!hz)
|
if (!hz)
|
||||||
hz = config::GetAutoClockHz(
|
hz = config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, module, clockManager::gContext.profile, false);
|
||||||
HOCCLK_GLOBAL_PROFILE_TID, module,
|
|
||||||
clockManager::gContext.profile, false);
|
|
||||||
return hz;
|
return hz;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,9 +249,11 @@ namespace governor {
|
|||||||
|
|
||||||
u32 targetHz = clockManager::gContext.overrideFreqs[HocClkModule_Display];
|
u32 targetHz = clockManager::gContext.overrideFreqs[HocClkModule_Display];
|
||||||
if (!targetHz) {
|
if (!targetHz) {
|
||||||
targetHz = config::GetAutoClockHz(clockManager::gContext.applicationId, HocClkModule_Display, clockManager::gContext.profile, false);
|
targetHz = config::GetAutoClockHz(clockManager::gContext.applicationId, HocClkModule_Display,
|
||||||
|
clockManager::gContext.profile, false);
|
||||||
if (!targetHz)
|
if (!targetHz)
|
||||||
targetHz = config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, HocClkModule_Display, clockManager::gContext.profile, false);
|
targetHz =
|
||||||
|
config::GetAutoClockHz(HOCCLK_GLOBAL_PROFILE_TID, HocClkModule_Display, clockManager::gContext.profile, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 maxDisplay = targetHz ? (u8)targetHz : 60;
|
u8 maxDisplay = targetHz ? (u8)targetHz : 60;
|
||||||
@@ -292,19 +295,11 @@ namespace governor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void startThreads() {
|
void startThreads() {
|
||||||
threadCreate(
|
threadCreate(&governorTHREAD, GovernorThread, nullptr, NULL, 0x2000, 0x3F, -2);
|
||||||
&governorTHREAD,
|
|
||||||
GovernorThread,
|
|
||||||
nullptr,
|
|
||||||
NULL,
|
|
||||||
0x2000,
|
|
||||||
0x3F,
|
|
||||||
-2
|
|
||||||
);
|
|
||||||
threadStart(&governorTHREAD);
|
threadStart(&governorTHREAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exitThreads() {
|
void exitThreads() {
|
||||||
threadClose(&governorTHREAD);
|
threadClose(&governorTHREAD);
|
||||||
}
|
}
|
||||||
}
|
} // namespace governor
|
||||||
|
|||||||
@@ -15,17 +15,18 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <hocclk.h>
|
|
||||||
#include "../board/board.hpp"
|
|
||||||
#include "clock_manager.hpp"
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "../file/file_utils.hpp"
|
#include <hocclk.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
#include "../board/board.hpp"
|
#include "../board/board.hpp"
|
||||||
#include "../file/errors.hpp"
|
|
||||||
#include "../file/config.hpp"
|
#include "../file/config.hpp"
|
||||||
|
#include "../file/errors.hpp"
|
||||||
|
#include "../file/file_utils.hpp"
|
||||||
#include "../hos/integrations.hpp"
|
#include "../hos/integrations.hpp"
|
||||||
#include "../util/lockable_mutex.h"
|
#include "../util/lockable_mutex.h"
|
||||||
|
#include "clock_manager.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace governor {
|
namespace governor {
|
||||||
extern bool isCpuGovernorInBoostMode;
|
extern bool isCpuGovernorInBoostMode;
|
||||||
@@ -38,4 +39,4 @@ namespace governor {
|
|||||||
void startThreads();
|
void startThreads();
|
||||||
void exitThreads();
|
void exitThreads();
|
||||||
void HandleGovernor(uint32_t targetHz);
|
void HandleGovernor(uint32_t targetHz);
|
||||||
}
|
} // namespace governor
|
||||||
@@ -15,8 +15,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
|
|
||||||
// Internal PSM service handle
|
// Internal PSM service handle
|
||||||
@@ -24,16 +25,7 @@ static Service g_psmService = {0};
|
|||||||
static bool g_batteryInfoInitialized = false;
|
static bool g_batteryInfoInitialized = false;
|
||||||
|
|
||||||
static const char *s_chargerTypeStrings[] = {
|
static const char *s_chargerTypeStrings[] = {
|
||||||
"None",
|
"None", "Power Delivery", "USB-C @ 1.5A", "USB-C @ 3.0A", "USB-DCP", "USB-CDP", "USB-SDP", "Apple @ 0.5A", "Apple @ 1.0A", "Apple @ 2.0A",
|
||||||
"Power Delivery",
|
|
||||||
"USB-C @ 1.5A",
|
|
||||||
"USB-C @ 3.0A",
|
|
||||||
"USB-DCP",
|
|
||||||
"USB-CDP",
|
|
||||||
"USB-SDP",
|
|
||||||
"Apple @ 0.5A",
|
|
||||||
"Apple @ 1.0A",
|
|
||||||
"Apple @ 2.0A",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *s_powerRoleStrings[] = {
|
static const char *s_powerRoleStrings[] = {
|
||||||
@@ -42,12 +34,7 @@ static const char* s_powerRoleStrings[] = {
|
|||||||
"Source",
|
"Source",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* s_pdStateStrings[] = {
|
static const char *s_pdStateStrings[] = { "Unknown", "New PDO Received", "No PD Source", "RDO Accepted" };
|
||||||
"Unknown",
|
|
||||||
"New PDO Received",
|
|
||||||
"No PD Source",
|
|
||||||
"RDO Accepted"
|
|
||||||
};
|
|
||||||
|
|
||||||
// Internal PSM command implementations
|
// Internal PSM command implementations
|
||||||
static Result psmGetBatteryChargeInfoFields(BatteryChargeInfo *out) {
|
static Result psmGetBatteryChargeInfoFields(BatteryChargeInfo *out) {
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <switch.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <switch.h>
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BatteryFlag_NoHub = BIT(0), // Hub is disconnected
|
BatteryFlag_NoHub = BIT(0), // Hub is disconnected
|
||||||
BatteryFlag_Rail = BIT(8), // At least one Joy-con is charging from rail
|
BatteryFlag_Rail = BIT(8), // At least one Joy-con is charging from rail
|
||||||
|
|||||||
@@ -297,18 +297,8 @@
|
|||||||
#define FUSE_ARRAY_WORDS_NUM 192
|
#define FUSE_ARRAY_WORDS_NUM 192
|
||||||
#define FUSE_ARRAY_WORDS_NUM_B01 256
|
#define FUSE_ARRAY_WORDS_NUM_B01 256
|
||||||
|
|
||||||
enum
|
enum { FUSE_NX_HW_TYPE_ICOSA, FUSE_NX_HW_TYPE_IOWA, FUSE_NX_HW_TYPE_HOAG, FUSE_NX_HW_TYPE_AULA };
|
||||||
{
|
|
||||||
FUSE_NX_HW_TYPE_ICOSA,
|
|
||||||
FUSE_NX_HW_TYPE_IOWA,
|
|
||||||
FUSE_NX_HW_TYPE_HOAG,
|
|
||||||
FUSE_NX_HW_TYPE_AULA
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
enum { FUSE_NX_HW_STATE_PROD, FUSE_NX_HW_STATE_DEV };
|
||||||
{
|
|
||||||
FUSE_NX_HW_STATE_PROD,
|
|
||||||
FUSE_NX_HW_STATE_DEV
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "gm20b.hpp"
|
|
||||||
#include "../mapping/mem_map.hpp"
|
#include "../mapping/mem_map.hpp"
|
||||||
|
#include "gm20b.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace gm20b {
|
namespace gm20b {
|
||||||
u64 gpu_base = 0;
|
u64 gpu_base = 0;
|
||||||
@@ -78,12 +78,8 @@ namespace gm20b {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void _clk_setup_slide() {
|
static void _clk_setup_slide() {
|
||||||
_gpu_mask(GPU_TRIM_SYS_GPCPLL_CFG2,
|
_gpu_mask(GPU_TRIM_SYS_GPCPLL_CFG2, GPCPLL_CFG2_STEPA_MASK, 0x04u << GPCPLL_CFG2_STEPA_SHIFT);
|
||||||
GPCPLL_CFG2_STEPA_MASK,
|
_gpu_mask(GPU_TRIM_SYS_GPCPLL_CFG3, GPCPLL_CFG3_STEPB_MASK, 0x05u << GPCPLL_CFG3_STEPB_SHIFT);
|
||||||
0x04u << GPCPLL_CFG2_STEPA_SHIFT);
|
|
||||||
_gpu_mask(GPU_TRIM_SYS_GPCPLL_CFG3,
|
|
||||||
GPCPLL_CFG3_STEPB_MASK,
|
|
||||||
0x05u << GPCPLL_CFG3_STEPB_SHIFT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _gpu_pllg_slide(u32 new_divn) {
|
static bool _gpu_pllg_slide(u32 new_divn) {
|
||||||
@@ -95,9 +91,7 @@ namespace gm20b {
|
|||||||
|
|
||||||
_clk_setup_slide();
|
_clk_setup_slide();
|
||||||
|
|
||||||
_gpu_mask(GPU_TRIM_SYS_GPCPLL_NDIV_SLOWDOWN,
|
_gpu_mask(GPU_TRIM_SYS_GPCPLL_NDIV_SLOWDOWN, NDIV_SLOWDOWN_SLOWDOWN_USING_PLL, NDIV_SLOWDOWN_SLOWDOWN_USING_PLL);
|
||||||
NDIV_SLOWDOWN_SLOWDOWN_USING_PLL,
|
|
||||||
NDIV_SLOWDOWN_SLOWDOWN_USING_PLL);
|
|
||||||
|
|
||||||
_gpu_mask(GPU_TRIM_SYS_GPCPLL_CFG2, GPCPLL_CFG2_SDM_DIN_NEW_MASK, 0);
|
_gpu_mask(GPU_TRIM_SYS_GPCPLL_CFG2, GPCPLL_CFG2_SDM_DIN_NEW_MASK, 0);
|
||||||
|
|
||||||
@@ -106,9 +100,7 @@ namespace gm20b {
|
|||||||
GPU_TRIM_SYS_GPCPLL(GPU_TRIM_SYS_GPCPLL_COEFF) = coeff;
|
GPU_TRIM_SYS_GPCPLL(GPU_TRIM_SYS_GPCPLL_COEFF) = coeff;
|
||||||
|
|
||||||
usleep(1);
|
usleep(1);
|
||||||
_gpu_mask(GPU_TRIM_SYS_GPCPLL_NDIV_SLOWDOWN,
|
_gpu_mask(GPU_TRIM_SYS_GPCPLL_NDIV_SLOWDOWN, NDIV_SLOWDOWN_EN_DYNRAMP, NDIV_SLOWDOWN_EN_DYNRAMP);
|
||||||
NDIV_SLOWDOWN_EN_DYNRAMP,
|
|
||||||
NDIV_SLOWDOWN_EN_DYNRAMP);
|
|
||||||
|
|
||||||
int ramp_timeout = RAMP_TIMEOUT_US;
|
int ramp_timeout = RAMP_TIMEOUT_US;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
@@ -125,9 +117,7 @@ namespace gm20b {
|
|||||||
_gpu_mask(GPU_TRIM_SYS_GPCPLL_CFG2, GPCPLL_CFG2_SDM_DIN_MASK, 0);
|
_gpu_mask(GPU_TRIM_SYS_GPCPLL_CFG2, GPCPLL_CFG2_SDM_DIN_MASK, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_gpu_mask(GPU_TRIM_SYS_GPCPLL_NDIV_SLOWDOWN,
|
_gpu_mask(GPU_TRIM_SYS_GPCPLL_NDIV_SLOWDOWN, NDIV_SLOWDOWN_SLOWDOWN_USING_PLL | NDIV_SLOWDOWN_EN_DYNRAMP, 0);
|
||||||
NDIV_SLOWDOWN_SLOWDOWN_USING_PLL | NDIV_SLOWDOWN_EN_DYNRAMP,
|
|
||||||
0);
|
|
||||||
(void)GPU_TRIM_SYS_GPCPLL(GPU_TRIM_SYS_GPCPLL_NDIV_SLOWDOWN);
|
(void)GPU_TRIM_SYS_GPCPLL(GPU_TRIM_SYS_GPCPLL_NDIV_SLOWDOWN);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
@@ -149,9 +139,11 @@ namespace gm20b {
|
|||||||
u32 new_divn = (u64)khz * divm * divp * 2 / osc_khz;
|
u32 new_divn = (u64)khz * divm * divp * 2 / osc_khz;
|
||||||
|
|
||||||
// L4T clamps the registers here for some reason, do that
|
// L4T clamps the registers here for some reason, do that
|
||||||
if (new_divn < 8) new_divn = 8;
|
if (new_divn < 8)
|
||||||
if (new_divn > 255) new_divn = 255;
|
new_divn = 8;
|
||||||
|
if (new_divn > 255)
|
||||||
|
new_divn = 255;
|
||||||
|
|
||||||
return _gpu_pllg_slide(new_divn);
|
return _gpu_pllg_slide(new_divn);
|
||||||
}
|
}
|
||||||
}
|
} // namespace gm20b
|
||||||
@@ -113,4 +113,4 @@ namespace pllmb {
|
|||||||
u32 pllm = ptoGetMHz(CLK_PLLM, 2, PLLM_MISC2, BIT(8));
|
u32 pllm = ptoGetMHz(CLK_PLLM, 2, PLLM_MISC2, BIT(8));
|
||||||
return pllmb == 0 ? pllm : pllmb; // pllmb is zeroed out at times, fallback to pllm
|
return pllmb == 0 ? pllm : pllmb; // pllmb is zeroed out at times, fallback to pllm
|
||||||
}
|
}
|
||||||
}
|
} // namespace pllmb
|
||||||
@@ -19,10 +19,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <switch.h>
|
|
||||||
#include <hocclk.h>
|
#include <hocclk.h>
|
||||||
#include "../board/board.hpp"
|
|
||||||
#include <registers.h>
|
#include <registers.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
|
#include "../board/board.hpp"
|
||||||
|
|
||||||
namespace pllmb {
|
namespace pllmb {
|
||||||
|
|
||||||
u64 getRamClockRatePLLMB();
|
u64 getRamClockRatePLLMB();
|
||||||
|
|||||||
@@ -80,8 +80,7 @@
|
|||||||
#define ACTMON_DEV_BASE (ACTMON_BASE + 0x80)
|
#define ACTMON_DEV_BASE (ACTMON_BASE + 0x80)
|
||||||
#define ACTMON(x) (*(volatile u32 *)(ACTMON_BASE + (x)))
|
#define ACTMON(x) (*(volatile u32 *)(ACTMON_BASE + (x)))
|
||||||
|
|
||||||
typedef enum _actmon_dev_t
|
typedef enum _actmon_dev_t {
|
||||||
{
|
|
||||||
ACTMON_DEV_CPU,
|
ACTMON_DEV_CPU,
|
||||||
ACTMON_DEV_BPMP,
|
ACTMON_DEV_BPMP,
|
||||||
ACTMON_DEV_AHB,
|
ACTMON_DEV_AHB,
|
||||||
@@ -93,8 +92,7 @@ typedef enum _actmon_dev_t
|
|||||||
ACTMON_DEV_NUM,
|
ACTMON_DEV_NUM,
|
||||||
} actmon_dev_t;
|
} actmon_dev_t;
|
||||||
|
|
||||||
typedef struct _actmon_dev_reg_t
|
typedef struct _actmon_dev_reg_t {
|
||||||
{
|
|
||||||
vu32 ctrl;
|
vu32 ctrl;
|
||||||
vu32 upper_wnark;
|
vu32 upper_wnark;
|
||||||
vu32 lower_wmark;
|
vu32 lower_wmark;
|
||||||
@@ -122,8 +120,7 @@ static u32 g_emc_bw_all = 0;
|
|||||||
static u32 g_emc_bw_cpu = 0;
|
static u32 g_emc_bw_cpu = 0;
|
||||||
static u32 g_emc_bw_gpu = 0;
|
static u32 g_emc_bw_gpu = 0;
|
||||||
|
|
||||||
static u32 _clock_get_dev_freq(u32 id, u32 multiplier)
|
static u32 _clock_get_dev_freq(u32 id, u32 multiplier) {
|
||||||
{
|
|
||||||
const u32 pto_win = 16;
|
const u32 pto_win = 16;
|
||||||
const u32 pto_osc = 32768;
|
const u32 pto_osc = 32768;
|
||||||
|
|
||||||
@@ -158,8 +155,7 @@ static u32 _clock_get_dev_freq(u32 id, u32 multiplier)
|
|||||||
return freq_khz;
|
return freq_khz;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _actmon_dev_enable(actmon_dev_t dev, u32 freq, u32 weight)
|
static void _actmon_dev_enable(actmon_dev_t dev, u32 freq, u32 weight) {
|
||||||
{
|
|
||||||
actmon_dev_reg_t *regs = (actmon_dev_reg_t *)(ACTMON_DEV_BASE + (dev * ACTMON_DEV_SIZE));
|
actmon_dev_reg_t *regs = (actmon_dev_reg_t *)(ACTMON_DEV_BASE + (dev * ACTMON_DEV_SIZE));
|
||||||
|
|
||||||
regs->init_avg = (u32)freq * ACTMON_PERIOD_MS / 2;
|
regs->init_avg = (u32)freq * ACTMON_PERIOD_MS / 2;
|
||||||
@@ -168,72 +164,58 @@ static void _actmon_dev_enable(actmon_dev_t dev, u32 freq, u32 weight)
|
|||||||
regs->ctrl = ACTMON_DEV_CTRL_ENB | ACTMON_DEV_CTRL_ENB_PERIODIC | ACTMON_DEV_CTRL_K_VAL(3); // 8 samples average.
|
regs->ctrl = ACTMON_DEV_CTRL_ENB | ACTMON_DEV_CTRL_ENB_PERIODIC | ACTMON_DEV_CTRL_K_VAL(3); // 8 samples average.
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 _actmon_dev_get_count_avg(actmon_dev_t dev)
|
static u32 _actmon_dev_get_count_avg(actmon_dev_t dev) {
|
||||||
{
|
|
||||||
actmon_dev_reg_t *regs = (actmon_dev_reg_t *)(ACTMON_DEV_BASE + (dev * ACTMON_DEV_SIZE));
|
actmon_dev_reg_t *regs = (actmon_dev_reg_t *)(ACTMON_DEV_BASE + (dev * ACTMON_DEV_SIZE));
|
||||||
|
|
||||||
return regs->avg_count;
|
return regs->avg_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Result _svcQueryMemoryMappingFallback(u64* virtaddr, u64 physaddr, u64 size)
|
static inline Result _svcQueryMemoryMappingFallback(u64 *virtaddr, u64 physaddr, u64 size) {
|
||||||
{
|
if (hosversionAtLeast(10, 0, 0)) {
|
||||||
if(hosversionAtLeast(10,0,0))
|
|
||||||
{
|
|
||||||
u64 out_size;
|
u64 out_size;
|
||||||
return svcQueryMemoryMapping(virtaddr, &out_size, physaddr, size);
|
return svcQueryMemoryMapping(virtaddr, &out_size, physaddr, size);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return svcLegacyQueryIoMapping(virtaddr, physaddr, size);
|
return svcLegacyQueryIoMapping(virtaddr, physaddr, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _clock_update_freqs(void)
|
static void _clock_update_freqs(void) {
|
||||||
{
|
|
||||||
u64 ticks = armGetSystemTick();
|
u64 ticks = armGetSystemTick();
|
||||||
if(armTicksToNs(ticks - g_update_ticks) <= WAIT_NS)
|
if (armTicksToNs(ticks - g_update_ticks) <= WAIT_NS) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_update_ticks = ticks;
|
g_update_ticks = ticks;
|
||||||
|
|
||||||
if (!g_clk_base)
|
if (!g_clk_base) {
|
||||||
{
|
|
||||||
_svcQueryMemoryMappingFallback(&g_clk_base, 0x60006000ul, 0x1000);
|
_svcQueryMemoryMappingFallback(&g_clk_base, 0x60006000ul, 0x1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!g_clk_base)
|
if (!g_clk_base) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mem_freq = _clock_get_dev_freq(CLK_PTO_EMC, 1);
|
g_mem_freq = _clock_get_dev_freq(CLK_PTO_EMC, 1);
|
||||||
g_cpu_freq = _clock_get_dev_freq(CLK_PTO_CCLK_G_DIV2, 2);
|
g_cpu_freq = _clock_get_dev_freq(CLK_PTO_CCLK_G_DIV2, 2);
|
||||||
|
|
||||||
if (!g_gpu_base)
|
if (!g_gpu_base) {
|
||||||
{
|
|
||||||
_svcQueryMemoryMappingFallback(&g_gpu_base, 0x57000000ul, 0x1000000);
|
_svcQueryMemoryMappingFallback(&g_gpu_base, 0x57000000ul, 0x1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_gpu_base)
|
if (!g_gpu_base) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gpu_enabled = (CLOCK(CLK_RST_CONTROLLER_CLK_OUT_ENB_X) & BIT(24)) && !(CLOCK(CLK_RST_CONTROLLER_RST_DEVICES_X) & BIT(24));
|
bool gpu_enabled = (CLOCK(CLK_RST_CONTROLLER_CLK_OUT_ENB_X) & BIT(24)) && !(CLOCK(CLK_RST_CONTROLLER_RST_DEVICES_X) & BIT(24));
|
||||||
if(!gpu_enabled)
|
if (!gpu_enabled) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_act_base)
|
if (!g_act_base) {
|
||||||
{
|
|
||||||
_svcQueryMemoryMappingFallback(&g_act_base, 0x6000C000ul, 0x1000);
|
_svcQueryMemoryMappingFallback(&g_act_base, 0x6000C000ul, 0x1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!g_act_base)
|
if (!g_act_base) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,8 +229,7 @@ static void _clock_update_freqs(void)
|
|||||||
u32 emc_freq = g_mem_freq / 1000;
|
u32 emc_freq = g_mem_freq / 1000;
|
||||||
|
|
||||||
// Check if actmon is disabled
|
// Check if actmon is disabled
|
||||||
if (!(ACTMON(ACTMON_GLB_STATUS) & ACTMON_MCALL_MON_ACT))
|
if (!(ACTMON(ACTMON_GLB_STATUS) & ACTMON_MCALL_MON_ACT)) {
|
||||||
{
|
|
||||||
ACTMON(ACTMON_GLB_PERIOD_CTRL) = ACTMON_GLB_PERIOD_SAMPLE(ACTMON_PERIOD_MS);
|
ACTMON(ACTMON_GLB_PERIOD_CTRL) = ACTMON_GLB_PERIOD_SAMPLE(ACTMON_PERIOD_MS);
|
||||||
_actmon_dev_enable(ACTMON_DEV_MC_ALL, emc_freq, 256 * 4);
|
_actmon_dev_enable(ACTMON_DEV_MC_ALL, emc_freq, 256 * 4);
|
||||||
}
|
}
|
||||||
@@ -270,57 +251,47 @@ static void _clock_update_freqs(void)
|
|||||||
g_emc_bw_gpu = g_emc_bw_all - g_emc_bw_cpu;
|
g_emc_bw_gpu = g_emc_bw_all - g_emc_bw_cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 t210ClkCpuFreq(void) {
|
||||||
u32 t210ClkCpuFreq(void)
|
|
||||||
{
|
|
||||||
_clock_update_freqs();
|
_clock_update_freqs();
|
||||||
return g_cpu_freq;
|
return g_cpu_freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 t210ClkMemFreq(void)
|
u32 t210ClkMemFreq(void) {
|
||||||
{
|
|
||||||
_clock_update_freqs();
|
_clock_update_freqs();
|
||||||
return g_mem_freq;
|
return g_mem_freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 t210ClkGpuFreq(void)
|
u32 t210ClkGpuFreq(void) {
|
||||||
{
|
|
||||||
_clock_update_freqs();
|
_clock_update_freqs();
|
||||||
return g_gpu_freq;
|
return g_gpu_freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 t210EmcLoadAll()
|
u32 t210EmcLoadAll() {
|
||||||
{
|
|
||||||
_clock_update_freqs();
|
_clock_update_freqs();
|
||||||
return g_emc_lall;
|
return g_emc_lall;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 t210EmcLoadCpu()
|
u32 t210EmcLoadCpu() {
|
||||||
{
|
|
||||||
_clock_update_freqs();
|
_clock_update_freqs();
|
||||||
return g_emc_lcpu;
|
return g_emc_lcpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 t210EmcBwAll()
|
u32 t210EmcBwAll() {
|
||||||
{
|
|
||||||
_clock_update_freqs();
|
_clock_update_freqs();
|
||||||
return g_emc_bw_all;
|
return g_emc_bw_all;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 t210EmcBwCpu()
|
u32 t210EmcBwCpu() {
|
||||||
{
|
|
||||||
_clock_update_freqs();
|
_clock_update_freqs();
|
||||||
return g_emc_bw_cpu;
|
return g_emc_bw_cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 t210EmcBwGpu()
|
u32 t210EmcBwGpu() {
|
||||||
{
|
|
||||||
_clock_update_freqs();
|
_clock_update_freqs();
|
||||||
return g_emc_bw_gpu;
|
return g_emc_bw_gpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 t210EmcBwPeak()
|
u32 t210EmcBwPeak() {
|
||||||
{
|
|
||||||
_clock_update_freqs();
|
_clock_update_freqs();
|
||||||
return ((u64)g_mem_freq * 16) / 1000000;
|
return ((u64)g_mem_freq * 16) / 1000000;
|
||||||
}
|
}
|
||||||
@@ -24,12 +24,10 @@
|
|||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user