/// <summary> /// Decodes a P-state from its string representation. /// </summary> /// <returns></returns> public static PState Decode(string text, int pstate) { if (string.IsNullOrEmpty(text)) { return(null); } string[] tokens = text.Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (tokens == null || tokens.Length != _numCores) { return(null); } var r = new PState(); for (int i = 0; i < _numCores; i++) { uint value = uint.Parse(tokens[i], System.Globalization.NumberStyles.HexNumber); r._msrs[i] = PStateMsr.Decode(value, pstate); } return(r); }
public ServiceDialog(System.Drawing.Icon icon) { InitializeComponent(); this.Icon = icon; makePermanentCheckBox.CheckedChanged += (s, e) => updateButton.Enabled = makePermanentCheckBox.Checked; turboCheckBox.CheckedChanged += (s, e) => { if (turboCheckBox.Checked) { enableCustomCnQCheckBox.Checked = false; enableCustomCnQCheckBox.Enabled = false; } else { enableCustomCnQCheckBox.Enabled = true; } }; enableCustomCnQCheckBox.CheckedChanged += (s, e) => tabControl1.Enabled = enableCustomCnQCheckBox.Checked; // select the current P-state settings as default settings updateButton_Click(updateButton, EventArgs.Empty); turboCheckBox.Enabled = K10Manager.IsTurboSupported(); turboCheckBox.Checked = K10Manager.IsTurboSupported(); balancedProfileControl.LoadFromRegistry(); highPerformanceProfileControl.LoadFromRegistry(); powerSaverProfileControl.LoadFromRegistry(); var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Software\BrazosTweaker"); if (key == null) { return; } for (int i = 0; i < (_maxPstate + 1); i++) { string text = (string)key.GetValue("P" + i); _pStates[i] = PState.Decode(text, i); } for (int i = 3; i < 5; i++) { string text = (string)key.GetValue("P" + i); _pStates[i] = PState.Decode(text, i); } RefreshPStatesLabel(); makePermanentCheckBox.Checked = ((int)key.GetValue("EnableCustomPStates", 0) != 0); enableCustomCnQCheckBox.Checked = ((int)key.GetValue("EnableCustomCnQ", 0) != 0); key.Close(); }
/// <summary> /// Loads the specified P-state from the cores' MSRs. /// </summary> /// <param name="index">Index of the hardware P-state (0-4) to be loaded.</param> public static PState Load(int index) { if (index < 0 || index > 4) throw new ArgumentOutOfRangeException("index"); var r = new PState(); for (int i = 0; i < _numCores; i++) r._msrs[i] = PStateMsr.Load(index, i); return r; }
/// <summary> /// Loads the specified P-state from the cores' MSRs. /// </summary> /// <param name="index">Index of the hardware P-state (0-4) to be loaded.</param> public static PState Load(int index) { if (index < 0 || index > 4) { throw new ArgumentOutOfRangeException("index"); } var r = new PState(); for (int i = 0; i < _numCores; i++) { r._msrs[i] = PStateMsr.Load(index, i); } return(r); }
private void updateButton_Click(object sender, EventArgs e) { for (int i = 0; i < 5; i++) { _pStates[i] = PState.Load(i); // disable the current P-state and all following ones in case the // first core's CPU VID is > than the previous P-state's if ((i > 0 && _pStates[i].Msrs[0].Vid > _pStates[i - 1].Msrs[0].Vid) && (i < 3)) //ignore Vids from NB in comprison { for (int j = i; j < 5; j++) { _pStates[j] = null; } break; } } RefreshPStatesLabel(); }
/// <summary> /// Loads the P-state settings from each core's MSR. /// </summary> public void LoadFromHardware(int pstatetab) { if (_index < 0) { throw new InvalidOperationException("The PStateIndex property needs to be initialized first."); } if (pstatetab < 3) //hardware loads for CPU { if (_index <= _maxPstate) //skip, in case just 2 CPU PStates are initialized { _pState = PState.Load(_index); double maxCpuVid = 0; for (int i = 0; i < _pState.Msrs.Length; i++) { var msr = _pState.Msrs[i]; var control = (NumericUpDown)flowLayoutPanel1.Controls[i]; control.Value = (decimal)msr.Divider; maxCpuVid = Math.Max(maxCpuVid, msr.Vid); } VidNumericUpDown.Value = Math.Min(VidNumericUpDown.Maximum, (decimal)maxCpuVid); //int check = K10Manager.SetBIOSBusSpeed(80); CLKNumericUpDown.Value = (decimal)K10Manager.GetBIOSBusSpeed(); pllfreq.Text = "P" + _index + " Freq (CPU): " + (int)_pState.Msrs[0].PLL + "MHz"; Cofstate.Text = "Mult = " + (K10Manager.CurrCOF() + 16) + " divided by ->"; Form1.freq[pstatetab] = (int)_pState.Msrs[0].PLL; } else { VidNumericUpDown.Value = (decimal)0.4; CLKNumericUpDown.Value = 100; } } else if (pstatetab == 3) { //hardware loads for NB P0 _pState = PState.Load(_index); var control = (NumericUpDown)flowLayoutPanel1.Controls[0]; control.Value = (decimal)K10Manager.GetNbDivPState0(); VidNumericUpDown.Value = (decimal)(1.55 - 0.0125 * K10Manager.GetNbVidPState0()); CLKNumericUpDown.Value = (decimal)K10Manager.GetBIOSBusSpeed(); pllfreq.Text = "P" + (_index - 3) + " Freq (GPU): " + (int)_pState.Msrs[0].PLL + "MHz"; Cofstate.Text = "Mult = " + (K10Manager.CurrCOF() + 16) + " divided by ->"; Form1.freq[pstatetab] = (int)_pState.Msrs[0].PLL; } else if (pstatetab == 4) { //hardware loads for NB P0 _pState = PState.Load(_index); var control = (NumericUpDown)flowLayoutPanel1.Controls[0]; control.Value = (decimal)K10Manager.GetNbDivPState1(); VidNumericUpDown.Value = (decimal)(1.55 - 0.0125 * K10Manager.GetNbVidPState1()); CLKNumericUpDown.Value = (decimal)K10Manager.GetBIOSBusSpeed(); pllfreq.Text = "P" + (_index - 3) + " Freq (GPU): " + (int)_pState.Msrs[0].PLL + "MHz"; Cofstate.Text = "Mult = " + (K10Manager.CurrCOF() + 16) + " divided by ->"; Form1.freq[pstatetab] = (int)_pState.Msrs[0].PLL; } else if (pstatetab == 5) //settings for displaying registers { VidNumericUpDown.Value = 1; CLKNumericUpDown.Value = 100; } _modified = false; }
/// <summary> /// Loads the P-state settings from each core's MSR. /// </summary> public void LoadFromHardware(int pstatetab) { if (_index < 0) throw new InvalidOperationException("The PStateIndex property needs to be initialized first."); if (pstatetab < 3) //hardware loads for CPU { if (_index <= _maxPstate) //skip, in case just 2 CPU PStates are initialized { _pState = PState.Load(_index); double maxCpuVid = 0; for (int i = 0; i < _pState.Msrs.Length; i++) { var msr = _pState.Msrs[i]; var control = (NumericUpDown)flowLayoutPanel1.Controls[i]; control.Value = (decimal)msr.Divider; maxCpuVid = Math.Max(maxCpuVid, msr.Vid); } VidNumericUpDown.Value = Math.Min(VidNumericUpDown.Maximum, (decimal)maxCpuVid); //int check = K10Manager.SetBIOSBusSpeed(80); CLKNumericUpDown.Value = (decimal)K10Manager.GetBIOSBusSpeed(); pllfreq.Text = "P" + _index + " Freq (CPU): " + (int)_pState.Msrs[0].PLL + "MHz"; Cofstate.Text = "Mult = " + (K10Manager.CurrCOF() + 16) + " divided by ->"; Form1.freq[pstatetab] = (int)_pState.Msrs[0].PLL; } else { VidNumericUpDown.Value = (decimal)0.4; CLKNumericUpDown.Value = 100; } } else if (pstatetab == 3) { //hardware loads for NB P0 _pState = PState.Load(_index); var control = (NumericUpDown)flowLayoutPanel1.Controls[0]; control.Value = (decimal)K10Manager.GetNbDivPState0(); VidNumericUpDown.Value = (decimal)(1.55 - 0.0125 * K10Manager.GetNbVidPState0()); CLKNumericUpDown.Value = (decimal)K10Manager.GetBIOSBusSpeed(); pllfreq.Text = "P" + (_index - 3) + " Freq (GPU): " + (int)_pState.Msrs[0].PLL + "MHz"; Cofstate.Text = "Mult = " + (K10Manager.CurrCOF() + 16) + " divided by ->"; Form1.freq[pstatetab] = (int)_pState.Msrs[0].PLL; } else if (pstatetab == 4) { //hardware loads for NB P0 _pState = PState.Load(_index); var control = (NumericUpDown)flowLayoutPanel1.Controls[0]; control.Value = (decimal)K10Manager.GetNbDivPState1(); VidNumericUpDown.Value = (decimal)(1.55 - 0.0125 * K10Manager.GetNbVidPState1()); CLKNumericUpDown.Value = (decimal)K10Manager.GetBIOSBusSpeed(); pllfreq.Text = "P" + (_index - 3) + " Freq (GPU): " + (int)_pState.Msrs[0].PLL + "MHz"; Cofstate.Text = "Mult = " + (K10Manager.CurrCOF() + 16) + " divided by ->"; Form1.freq[pstatetab] = (int)_pState.Msrs[0].PLL; } else if (pstatetab == 5) //settings for displaying registers { VidNumericUpDown.Value = 1; CLKNumericUpDown.Value = 100; } _modified = false; }
/// <summary> /// Decodes a P-state from its string representation. /// </summary> /// <returns></returns> public static PState Decode(string text,int pstate) { if (string.IsNullOrEmpty(text)) return null; string[] tokens = text.Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (tokens == null || tokens.Length != _numCores) return null; var r = new PState(); for (int i = 0; i < _numCores; i++) { uint value = uint.Parse(tokens[i], System.Globalization.NumberStyles.HexNumber); r._msrs[i] = PStateMsr.Decode(value,pstate); } return r; }