private void applyButton_Click(object sender, EventArgs e) { var key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"Software\BrazosTweaker"); key.SetValue("EnableCustomPStates", (makePermanentCheckBox.Checked ? 1 : 0)); if (makePermanentCheckBox.Checked) { for (int i = 0; i < (K10Manager.GetHighestPState() + 1); i++) //this is the part, where the CPU PStates are handled { string valueName = "P" + i; if (_pStates[i] != null) { key.SetValue(valueName, _pStates[i].Encode(i)); } else { key.DeleteValue(valueName, false); } } for (int i = 3; i < 5; i++) //this is the part for the NB PStates { string valueName = "P" + i; if (_pStates[i] != null) { key.SetValue(valueName, _pStates[i].Encode(i)); } else { key.DeleteValue(valueName, false); } } } key.SetValue("EnableCustomCnQ", (enableCustomCnQCheckBox.Checked ? 1 : 0)); key.Close(); if (enableCustomCnQCheckBox.Checked) { balancedProfileControl.Save(); highPerformanceProfileControl.Save(); powerSaverProfileControl.Save(); } try { serviceController1.Refresh(); var status = serviceController1.Status; if (status != ServiceControllerStatus.Stopped && status != ServiceControllerStatus.StopPending) { serviceController1.Stop(); } Cursor = Cursors.WaitCursor; serviceController1.WaitForStatus(ServiceControllerStatus.Stopped); serviceController1.Start(); Cursor = Cursors.Default; Applied = true; } catch (Exception exception) { Cursor = Cursors.Default; MessageBox.Show("The service could not be (re)started:\n\n" + exception.Message, "BrazosTweaker", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Constructor. /// </summary> public PStateControl() { InitializeComponent(); // check if the CPU's maximum multi is limited (non Black Edition CPUs) if (_maxCOF < 0) { // in DesignMode, Program.Ols is null if (Program.Ols == null) { _maxCOF = 31.5; _minVid = 0.0125; _maxVid = 1.55; _maxPstate = -1; } else { _maxCOF = K10Manager.MaxCOF(); _maxPstate = K10Manager.GetHighestPState(); //double _curDiv = K10Manager.CurrCOF(); //uint MainDivEn = K10Manager.MainCofEn(); K10Manager.GetVidLimits(out _minVid, out _maxVid); } } VidNumericUpDown.Minimum = (decimal)_minVid; CLKNumericUpDown.Minimum = 0; VidNumericUpDown.Maximum = (decimal)_maxVid; CLKNumericUpDown.Maximum = 200; // add as many NumericUpDown controls as there are CPU cores for the multis for (int i = 0; i < _numCores; i++) { var control = new NumericUpDown() { AutoSize = true, DecimalPlaces = 2, Increment = (decimal)0.25, Maximum = (decimal)_maxCOF, Minimum = 1, TabIndex = i, TextAlign = HorizontalAlignment.Center, Value = 4, }; toolTip1.SetToolTip(control, "Divider for core " + (i + 1) + ".\r\nReference clock (default: 100 MHz) times " + (_maxCOF + 16) + " divided by the chosen value yields the core speed."); control.ValueChanged += (s, e) => _modified = true; if (i == 0) { control.ValueChanged += (s, e) => { for (int j = 1; j < _numCores; j++) { var otherControl = (NumericUpDown)flowLayoutPanel1.Controls[j]; otherControl.Value = control.Value; } }; } flowLayoutPanel1.Controls.Add(control); } VidNumericUpDown.ValueChanged += (s, e) => _modified = true; CLKNumericUpDown.ValueChanged += (s, e) => _modified = true; // set the tab order VidNumericUpDown.TabIndex = 3 + _numCores; CLKNumericUpDown.TabIndex = VidNumericUpDown.TabIndex + 1; refreshButton.TabIndex = CLKNumericUpDown.TabIndex + 1; // compute the optimal width, based on the number of cores _optimalWidth = Cofstate.Width + Cofstate.Margin.Horizontal + flowLayoutPanel1.Controls.Count * (flowLayoutPanel1.Controls[0].Width + flowLayoutPanel1.Controls[0].Margin.Horizontal) + 70; refreshButton.Click += (s, e) => LoadFromHardware(_index); }
public static PStateMsr Decode(uint value, int pstate) { //uint maxDiv = (uint)K10Manager.MaxCOF(); uint maxDiv = (uint)K10Manager.CurrCOF(); uint clk = (uint)K10Manager.GetBIOSBusSpeed(); bool turbo = K10Manager.IsTurboSupported(); if (pstate < 3) { if (pstate <= K10Manager.GetHighestPState()) { uint cpuDidLSD = (value >> 0) & 0x0F; uint cpuDidMSD = (value >> 4) & 0x1F; uint cpuVid = (value >> 9) & 0x7F; double Div = cpuDidMSD + (cpuDidLSD * 0.25) + 1; double DivPLL = cpuDidMSD + (cpuDidLSD * 0.25) + 1; if (maxDiv == 16 && Div < 2) //E-350 seems to restrict PLL frequencies higher than 1.6GHz { DivPLL = 2; } else if (maxDiv == 24 && Div < 4 && !turbo) //C-50 seems to restrict PLL frequencies higher than 1.0GHz { DivPLL = 4; } else if (maxDiv == 24 && Div < 3 && turbo) //C-60 (with turbo seems to restrict PLL frequencies higher than 1.33GHz { DivPLL = 3; } var msr = new PStateMsr() { Divider = Div, Vid = 1.55 - 0.0125 * cpuVid, CLK = clk, PLL = (16 + maxDiv) / DivPLL * clk }; return(msr); } else { var msr = new PStateMsr() { Divider = 10, Vid = 0.4, CLK = 100, PLL = 1000 }; return(msr); } } else if (pstate == 3) { uint nclk = ((value >> 20) & 0x7F); uint nbVid = ((value >> 12) & 0x7F); double nclkdiv = 1; //NCLK Div 2-16 ind 0.25 steps / Div 16-32 in 0.5 steps / Div 32-63 in 1.0 steps if (nclk >= 8 && nclk <= 63) { nclkdiv = nclk * 0.25; } else if (nclk >= 64 && nclk <= 95) { nclkdiv = (nclk - 64) * 0.5 - 16; } else if (nclk >= 96 && nclk <= 127) { nclkdiv = nclk - 64; } else { nclkdiv = 1; } var msr = new PStateMsr() { Divider = nclkdiv, Vid = 1.55 - 0.0125 * nbVid, CLK = clk, PLL = (16 + maxDiv) / nclkdiv * clk }; return(msr); } else if (pstate == 4) { uint nclk = ((value >> 0) & 0x7F); uint nbVid = ((value >> 8) & 0x7F); double nclkdiv = 1; //NCLK Div 2-16 ind 0.25 steps / Div 16-32 in 0.5 steps / Div 32-63 in 1.0 steps if (nclk >= 8 && nclk <= 63) { nclkdiv = nclk * 0.25; } else if (nclk >= 64 && nclk <= 95) { nclkdiv = (nclk - 64) * 0.5 - 16; } else if (nclk >= 96 && nclk <= 127) { nclkdiv = nclk - 64; } else { nclkdiv = 1; } var msr = new PStateMsr() { Divider = nclkdiv, Vid = 1.55 - 0.0125 * nbVid, CLK = clk, PLL = (16 + maxDiv) / nclkdiv * clk }; return(msr); } else { var msr = new PStateMsr() { Divider = 10, Vid = 0.4, CLK = 100, PLL = 1000 }; return(msr); } }