feat(pages): advanced config - mariko gpu undervolt

This commit is contained in:
hanabbi committed 2023-05-26 12:46:41 +09:00
1 parent 92829a1ca3
commit b44b47fb42
2 files changed
+95 -3

No files matched your search

+1 -1
View File
@@ -1 +1 @@
var __awaiter=this&&this.__awaiter||function(e,t,i,s){return new(i||(i=Promise))((function(a,l){function n(e){try{o(s.next(e))}catch(e){l(e)}}function r(e){try{o(s.throw(e))}catch(e){l(e)}}function o(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(n,r)}o((s=s.apply(e,t||[])).next())}))};const CUST_REV=4;var CustPlatform;!function(e){e[e.Undefined=0]="Undefined",e[e.Erista=1]="Erista",e[e.Mariko=2]="Mariko",e[e.All=3]="All"}(CustPlatform||(CustPlatform={}));class CustEntry{constructor(e,t,i,s,a,l,n=[0,1e6],r=1,o=!0){this.id=e,this.name=t,this.platform=i,this.size=s,this.desc=a,this.defval=l,this.step=r,this.zeroable=o,this.min=n[0],this.max=n[1]}validate(){let e=new ErrorToolTip(this.id).clear();return Number.isNaN(this.value)||void 0===this.value?(e.setMsg("Invalid value: Not a number").show(),!1):!(!this.zeroable||0!=this.value)||(this.value<this.min||this.value>this.max?(e.setMsg(`Expected range: [${this.min}, ${this.max}], got ${this.value}.`).show(),!1):this.value%this.step==0||(e.setMsg(`${this.value} % ${this.step} ≠ 0`).show(),!1))}getInputElement(){return document.getElementById(this.id)}updateValueFromElement(){var e;this.value=Number(null===(e=this.getInputElement())||void 0===e?void 0:e.value)}isAvailableFor(e){return e===CustPlatform.Undefined||this.platform===e||this.platform===CustPlatform.All}createElement(){let e=this.getInputElement();if(!e){let t=document.createElement("div");t.classList.add("grid","cust-element"),e=document.createElement("input"),e.min=String(this.zeroable?0:this.min),e.max=String(this.max),e.id=this.id,e.type="number",e.step=String(this.step);let i=document.createElement("label");i.setAttribute("for",this.id),i.innerHTML=this.name,i.appendChild(e),t.appendChild(i);let s=document.createElement("blockquote");s.innerHTML="<ul>"+this.desc.map((e=>`<li>${e}</li>`)).join("")+"</ul>",s.setAttribute("for",this.id),t.appendChild(s),document.getElementById("config-list-basic").appendChild(t),new ErrorToolTip(this.id).addChangeListener()}e.value=String(this.value)}setElementValue(){this.getInputElement().value=String(this.value)}setElementDefaultValue(){this.getInputElement().value=String(this.defval)}removeElement(){let e=this.getInputElement();e&&e.parentElement.parentElement.remove()}showElement(){let e=this.getInputElement();e&&e.parentElement.parentElement.style.removeProperty("display")}hideElement(){let e=this.getInputElement();e&&e.parentElement.parentElement.style.setProperty("display","none")}}var CustTable=[new CustEntry("mtcConf","DRAM Timing",CustPlatform.Mariko,4,["<b>0</b>: AUTO_ADJ_MARIKO_SAFE: Auto adjust timings for LPDDR4 ≤3733 Mbps specs, 8Gb density. (Default)","<b>1</b>: AUTO_ADJ_MARIKO_4266: Auto adjust timings for LPDDR4X 4266 Mbps specs, 8Gb density.","<b>2</b>: NO_ADJ_ALL: No timing adjustment for both Erista and Mariko. Might achieve better performance on Mariko but lower maximum frequency is expected."],0,[0,2],1),new CustEntry("commonCpuBoostClock","Boost Clock in kHz",CustPlatform.All,4,["System default: 1785000","Boost clock will be applied when applications request higher CPU frequency for quicker loading.","This will be set regardless of whether sys-clk is enabled."],1785e3,[102e4,3e6],1,!1),new CustEntry("commonEmcMemVolt","EMC Vddq (Erista Only) & RAM Vdd2 Voltage in uV",CustPlatform.All,4,["Acceptable range: 1100000 ≤ x ≤ 1250000, and it should be divided evenly by 12500.","Erista Default (HOS): 1125000 (bootloader: 1100000)","Mariko Default: 1100000 (It will not work without sys-clk-OC)","Not enabled by default"],0,[11e5,125e4],12500),new CustEntry("eristaCpuMaxVolt","Erista CPU Max Voltage in mV",CustPlatform.Erista,4,["Acceptable range: 1100 ≤ x ≤ 1300","L4T Default: 1235"],1235,[1100,1300],1),new CustEntry("eristaEmcMaxClock","Erista RAM Max Clock in kHz",CustPlatform.Erista,4,["Values should be ≥ 1600000, and divided evenly by 3200.","<b>WARNING:</b> RAM overclock could be UNSTABLE if timing parameters are not suitable for your DRAM"],1862400,[16e5,24e5],3200),new CustEntry("marikoCpuMaxVolt","Mariko CPU Max Voltage in mV",CustPlatform.Mariko,4,["System default: 1120","Acceptable range: 1100 ≤ x ≤ 1300"],1235,[1100,1300],5),new CustEntry("marikoEmcMaxClock","Mariko RAM Max Clock in kHz",CustPlatform.Mariko,4,["Values should be ≥ 1600000, and divided evenly by 3200.","<b>WARNING:</b> RAM overclock could be UNSTABLE if timing parameters are not suitable for your DRAM."],1996800,[16e5,24e5],3200),new CustEntry("marikoEmcVddqVolt","EMC Vddq (Mariko Only) Voltage in uV",CustPlatform.Mariko,4,["Acceptable range: 550000 ≤ x ≤ 650000","Value should be divided evenly by 5000","Default: 600000","Not enabled by default.","This will not work without sys-clk-OC."],0,[55e4,65e4],5e3)];class ErrorToolTip{constructor(e,t){this.id=e,this.msg=t,this.id=e,this.element=document.getElementById(e),t&&this.setMsg(t)}setMsg(e){return this.msg=e,this}show(){var e,t,i,s,a,l;return null===(e=this.elementLine truncated
var __awaiter=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))((function(s,l){function n(e){try{o(a.next(e))}catch(e){l(e)}}function r(e){try{o(a.throw(e))}catch(e){l(e)}}function o(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(n,r)}o((a=a.apply(e,t||[])).next())}))};const CUST_REV=4;var CustPlatform;!function(e){e[e.Undefined=0]="Undefined",e[e.Erista=1]="Erista",e[e.Mariko=2]="Mariko",e[e.All=3]="All"}(CustPlatform||(CustPlatform={}));class CustEntry{constructor(e,t,i,a,s,l,n=[0,1e6],r=1,o=!0){this.id=e,this.name=t,this.platform=i,this.size=a,this.desc=s,this.defval=l,this.step=r,this.zeroable=o,this.min=n[0],this.max=n[1]}validate(){let e=new ErrorToolTip(this.id).clear();return Number.isNaN(this.value)||void 0===this.value?(e.setMsg("Invalid value: Not a number").show(),!1):!(!this.zeroable||0!=this.value)||(this.value<this.min||this.value>this.max?(e.setMsg(`Expected range: [${this.min}, ${this.max}], got ${this.value}.`).show(),!1):this.value%this.step==0||(e.setMsg(`${this.value} % ${this.step} ≠ 0`).show(),!1))}getInputElement(){return document.getElementById(this.id)}updateValueFromElement(){var e;this.value=Number(null===(e=this.getInputElement())||void 0===e?void 0:e.value)}isAvailableFor(e){return e===CustPlatform.Undefined||this.platform===e||this.platform===CustPlatform.All}createElement(){let e=this.getInputElement();if(!e){let t=document.createElement("div");t.classList.add("grid","cust-element"),e=document.createElement("input"),e.min=String(this.zeroable?0:this.min),e.max=String(this.max),e.id=this.id,e.type="number",e.step=String(this.step);let i=document.createElement("label");i.setAttribute("for",this.id),i.innerHTML=this.name,i.appendChild(e),t.appendChild(i);let a=document.createElement("blockquote");a.innerHTML="<ul>"+this.desc.map((e=>`<li>${e}</li>`)).join("")+"</ul>",a.setAttribute("for",this.id),t.appendChild(a),document.getElementById("config-list-basic").appendChild(t),new ErrorToolTip(this.id).addChangeListener()}e.value=String(this.value)}setElementValue(){this.getInputElement().value=String(this.value)}setElementDefaultValue(){this.getInputElement().value=String(this.defval)}removeElement(){let e=this.getInputElement();e&&e.parentElement.parentElement.remove()}showElement(){let e=this.getInputElement();e&&e.parentElement.parentElement.style.removeProperty("display")}hideElement(){let e=this.getInputElement();e&&e.parentElement.parentElement.style.setProperty("display","none")}}class AdvEntry extends CustEntry{createElement(){let e=this.getInputElement();if(!e){let t=document.createElement("div");t.classList.add("grid","cust-element"),e=document.createElement("input"),e.min=String(this.zeroable?0:this.min),e.max=String(this.max),e.id=this.id,e.type="number",e.step=String(this.step);let i=document.createElement("label");i.setAttribute("for",this.id),i.innerHTML=this.name,i.appendChild(e),t.appendChild(i);let a=document.createElement("blockquote");a.innerHTML="<ul>"+this.desc.map((e=>`<li>${e}</li>`)).join("")+"</ul>",a.setAttribute("for",this.id),t.appendChild(a),document.getElementById("config-list-advanced").appendChild(t),new ErrorToolTip(this.id).addChangeListener()}e.value=String(this.value)}}var CustTable=[new CustEntry("mtcConf","DRAM Timing",CustPlatform.Mariko,4,["<b>0</b>: AUTO_ADJ_MARIKO_SAFE: Auto adjust timings for LPDDR4 ≤3733 Mbps specs, 8Gb density. (Default)","<b>1</b>: AUTO_ADJ_MARIKO_4266: Auto adjust timings for LPDDR4X 4266 Mbps specs, 8Gb density.","<b>2</b>: NO_ADJ_ALL: No timing adjustment for both Erista and Mariko. Might achieve better performance on Mariko but lower maximum frequency is expected."],0,[0,2],1),new CustEntry("commonCpuBoostClock","Boost Clock in kHz",CustPlatform.All,4,["System default: 1785000","Boost clock will be applied when applications request higher CPU frequency for quicker loading.","This will be set regardless of whether sys-clk is enabled."],1785e3,[102e4,3e6],1,!1),new CustEntry("commonEmcMemVolt","EMC Vddq (Erista Only) & RAM Vdd2 Voltage in uV",CustPlatform.All,4,["Acceptable range: 1100000 ≤ x ≤ 1250000, and it should be divided evenly by 12500.","Erista Default (HOS): 1125000 (bootloader: 1100000)","Mariko Default: 1100000 (It will not work without sys-clk-OC)","Not enabled by default"],0,[11e5,125e4],12500),new CustEntry("eristaCpuMaxVolt","Erista CPU Max Voltage in mV",CustPlatform.Erista,4,["Acceptable range: 1100 ≤ x ≤ 1300","L4T Default: 1235"],1235,[1100,1300],1),new CustEntry("eristaEmcMaxClock","Erista RAM Max Clock in kHz",CustPlatform.Erista,4,["Values should be ≥ 1600000, and divided evenly by 3200.","<b>WARNING:</b> RAM overclock could be UNSTABLE if timing parameters are not suitable for your DRAM"],1862400,[16e5,24e5],3200),new CustEntry("marikoCpuMaxVolt","Mariko CPU Max Voltage in mV",CustPlatform.Mariko,4,["System default: 1120","Acceptable range: 1100 ≤ x ≤ 1300"],1235,[1100,1300],5),new CustEntry("marikoEmcMaxClock","MarikoLine truncated
+94 -2
View File
@@ -121,6 +121,40 @@ class CustEntry {
}
}
class AdvEntry extends CustEntry {
createElement() {
let input = this.getInputElement();
if (!input) {
let grid = document.createElement("div");
grid.classList.add("grid", "cust-element");
// Label and input
input = document.createElement("input");
input.min = String(this.zeroable ? 0 : this.min);
input.max = String(this.max);
input.id = this.id;
input.type = "number";
input.step = String(this.step);
let label = document.createElement("label");
label.setAttribute("for", this.id);
label.innerHTML = this.name;
label.appendChild(input);
grid.appendChild(label);
// Description in blockquote style
let desc = document.createElement("blockquote");
desc.innerHTML = "<ul>" + this.desc.map(i => `<li>${i}</li>`).join('') + "</ul>";
desc.setAttribute("for", this.id);
grid.appendChild(desc);
document.getElementById("config-list-advanced")!.appendChild(grid);
new ErrorToolTip(this.id).addChangeListener();
}
input.value = String(this.value);
}
}
var CustTable: Array<CustEntry> = [
new CustEntry(
"mtcConf",
@@ -220,6 +254,21 @@ var CustTable: Array<CustEntry> = [
),
];
var AdvTable: Array<AdvEntry> = [
new AdvEntry(
"marikoGpuUV",
"Enable Mariko GPU Undervolt",
CustPlatform.Mariko,
4,
["Undervolt Mariko GPU",
"Your GPU might not withstand undervolt",
"Can hang your console, or crash games"],
0,
[0,1],
1,
),
];
class ErrorToolTip {
element: HTMLElement | null;
@@ -273,20 +322,33 @@ class CustStorage {
throw new Error(`Invalid ${i.name}`);
}
});
AdvTable.forEach(i => {
i.updateValueFromElement();
if (!i.validate()) {
i.getInputElement()?.focus();
throw new Error(`Invalid ${i.name}`);
}
});
this.storage = {};
let kv = Object.fromEntries(CustTable.map((i) => [i.id, i.value]));
Object.keys(kv)
.forEach(k => this.storage[k] = kv[k]);
kv = Object.fromEntries(AdvTable.map((i) => [i.id, i.value]));
Object.keys(kv)
.forEach(k => this.storage[k] = kv[k]);
}
setTable() {
let keys = Object.keys(this.storage);
keys.forEach(k => CustTable.filter(i => i.id == k)[0].value = this.storage[k]);
keys.forEach(k => AdvTable.filter(i => i.id == k)[0].value = this.storage[k]);
// Set default for missing values
CustTable.filter(i => !keys.includes(i.id))
.forEach(i => i.value = i.defval);
AdvTable.filter(i => !keys.includes(i.id))
.forEach(i => i.value = i.defval);
CustTable.forEach(i => {
if (!i.validate()) {
@@ -295,6 +357,13 @@ class CustStorage {
}
i.setElementValue();
});
AdvTable.forEach(i => {
if (!i.validate()) {
i.getInputElement()?.focus();
throw new Error(`Invalid ${i.name}`);
}
i.setElementValue();
});
}
save() {
@@ -312,6 +381,14 @@ class CustStorage {
if (ignoredKeys.length) {
console.log(`Ignored: ${ignoredKeys}`);
}
Object.keys(dict)
.filter(k => keys.includes(k))
.forEach(k => this.storage[k] = dict[k]);
keys = AdvTable.map(i => i.id);
ignoredKeys = Object.keys(dict).filter(k => !keys.includes(k));
if (ignoredKeys.length) {
console.log(`Ignored: ${ignoredKeys}`);
}
Object.keys(dict)
.filter(k => keys.includes(k))
.forEach(k => this.storage[k] = dict[k]);
@@ -350,7 +427,7 @@ class Cust {
save() {
this.storage.updateFromTable();
CustTable.forEach(i => {
var lambda = (i => {
if (!i.offset) {
i.getInputElement()?.focus();
throw new Error(`Failed to get offset for ${i.name}`);
@@ -362,6 +439,8 @@ class Cust {
}
mapper.set(i.offset, i.value!);
});
CustTable.forEach(lambda);
AdvTable.forEach(lambda);
this.storage.save();
let a = document.createElement("a");
@@ -395,9 +474,11 @@ class Cust {
CustTable.forEach(i => i.createElement());
let advanced = document.createElement("p");
advanced.innerHTML = "Advanced configuration: Coming soon...";
advanced.innerHTML = "Advanced configuration (Very Dangerous!!!)";
document.getElementById("config-list-advanced")?.appendChild(advanced);
AdvTable.forEach(i => i.createElement());
let default_btn = document.getElementById("load_default")!;
default_btn.removeAttribute("disabled");
default_btn.addEventListener('click', () => {
@@ -458,6 +539,17 @@ class Cust {
offset += i.size;
i.validate();
});
AdvTable.forEach(i => {
i.offset = offset;
let mapper = this.mapper[i.size];
if (!mapper) {
i.getInputElement()?.focus();
throw new Error(`Unknown size at ${i}`);
}
i.value = mapper.get(offset);
offset += i.size;
i.validate();
});
}
load(buffer: ArrayBuffer) {