public Form1() { InitializeComponent(); family = K10Manager.GetFamily(); numPstates = K10Manager.GetHighestPState(); clock = K10Manager.GetBIOSBusSpeed(); //Brazos merge next line removed in BT //numBoostedPstates = K10Manager.GetNumBoostedStates(); numBoostedPstates = 0; processBarSteps = numPstates + numBoostedPstates + 1; processBarPerc = 100 / processBarSteps; if ((family != 12) && (family != 14) && (family != 16)) { MessageBox.Show("Your CPU/APU from AMD family: " + family + "h is not supported!"); } //needed to reduces flickering SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); if (numCores == 3) { this.Controls.Remove(this.pstateLabel4); this.Controls.Remove(this.core4label); this.Controls.Remove(this.cpu4Bar); ShiftTable(-15); } else if (numCores == 2) { this.Controls.Remove(this.pstateLabel4); this.Controls.Remove(this.core4label); this.Controls.Remove(this.cpu4Bar); this.Controls.Remove(this.pstateLabel3); this.Controls.Remove(this.core3label); this.Controls.Remove(this.cpu3Bar); ShiftTable(-30); } else if (numCores == 1) { this.Controls.Remove(this.pstateLabel4); this.Controls.Remove(this.core4label); this.Controls.Remove(this.cpu4Bar); this.Controls.Remove(this.pstateLabel3); this.Controls.Remove(this.core3label); this.Controls.Remove(this.cpu3Bar); this.Controls.Remove(this.pstateLabel2); this.Controls.Remove(this.core2label); this.Controls.Remove(this.cpu2Bar); ShiftTable(-50); } notifyIcon.Icon = this.Icon; notifyIcon.ContextMenuStrip = new ContextMenuStrip(); notifyIcon.Visible = true; if (family == 16) { //MessageBox.Show("Jetzt wird ein Log für den Editor erstellt!"); //log_now(); } //Brazos merge next line was active in BT //this.Width += p0StateControl.GetDeltaOptimalWidth(); //Brazos merge p3 trough p7 inactive in BT //BT also provides integer value to Load for PState, which shouldn't be needed //MessageBox.Show("Jetzt werden die Register der GPU gelesen!"); nbp0StateControl.LoadFromHardware(); nbp1StateControl.LoadFromHardware(); //MessageBox.Show("Jetzt werden zusätzliche Register gelesen!"); statusinfo.LoadFromHardware(); //MessageBox.Show("Jetzt werden die Register der CPU gelesen!"); p0StateControl.LoadFromHardware(); p1StateControl.LoadFromHardware(); p2StateControl.LoadFromHardware(); p3StateControl.LoadFromHardware(); p4StateControl.LoadFromHardware(); p5StateControl.LoadFromHardware(); p6StateControl.LoadFromHardware(); p7StateControl.LoadFromHardware(); //MessageBox.Show("Alle Register gelesen!"); if (!_useWindowsPowerSchemes) { // use FusionTweaker's power schemes (via the registry) powerSchemesComboBox.Items.Add(new PowerScheme() { Name = "Balanced" }); powerSchemesComboBox.Items.Add(new PowerScheme() { Name = "High performance" }); powerSchemesComboBox.Items.Add(new PowerScheme() { Name = "Power saver" }); var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Software\FusionTweaker"); if (key == null) { powerSchemesComboBox.SelectedIndex = 0; } else { powerSchemesComboBox.SelectedIndex = (int)key.GetValue("PowerScheme", 0); key.Close(); } InitializeNotifyIconContextMenu(); powerSchemesComboBox.SelectedIndexChanged += (s, e) => { var k = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"Software\FusionTweaker"); k.SetValue("PowerScheme", powerSchemesComboBox.SelectedIndex); k.Close(); SynchronizeNotifyIconContextMenu(); }; return; } int guidSize = 16; IntPtr guid = Marshal.AllocHGlobal(guidSize); // get the GUID of the current power scheme IntPtr activeGuidPointer; if (PowerGetActiveScheme(IntPtr.Zero, out activeGuidPointer) != 0) { throw new Exception("PowerGetActiveScheme()"); } Guid activeGuid = (Guid)Marshal.PtrToStructure(activeGuidPointer, typeof(Guid)); LocalFree(activeGuidPointer); // iterate over all power schemes for (int i = 0; true; i++) { if (PowerEnumerate(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, 0x10, i, guid, ref guidSize) != 0) { break; } // get the required buffer size int size = 0; if (PowerReadFriendlyName(IntPtr.Zero, guid, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, ref size) != 0) { break;//throw new Exception("PowerReadFriendlyName()"); } IntPtr stringBuffer = Marshal.AllocHGlobal(size); // get the scheme name if (PowerReadFriendlyName(IntPtr.Zero, guid, IntPtr.Zero, IntPtr.Zero, stringBuffer, ref size) != 0) { throw new Exception("PowerReadFriendlyName()"); } var item = new PowerScheme() { Guid = (Guid)Marshal.PtrToStructure(guid, typeof(Guid)), Name = Marshal.PtrToStringUni(stringBuffer) }; Marshal.FreeHGlobal(stringBuffer); powerSchemesComboBox.Items.Add(item); if (item.Guid == activeGuid) { powerSchemesComboBox.SelectedIndex = i; } } Marshal.FreeHGlobal(guid); InitializeNotifyIconContextMenu(); powerSchemesComboBox.SelectedIndexChanged += (s, e) => { var item = (PowerScheme)powerSchemesComboBox.SelectedItem; if (PowerSetActiveScheme(IntPtr.Zero, ref item.Guid) != 0) { throw new Exception("PowerSetActiveScheme()"); } SynchronizeNotifyIconContextMenu(); }; }
/// <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 = 48; _minVid = 0.0125; _maxVid = 1.55; //Brazos merge next line added from BT _maxPstate = -1; } else { //Brazos merge next line added from BT _maxPstate = K10Manager.GetHighestPState(); _family = K10Manager.GetFamily(); if (_family == 14) { _maxCOF = K10Manager.MaxCOF() + 16; } else { _maxCOF = K10Manager.MaxCOF(); } K10Manager.GetVidLimits(out _minVid, out _maxVid); } } VidNumericUpDown.Minimum = (decimal)_minVid; VidNumericUpDown.Maximum = (decimal)_maxVid; // add as many NumericUpDown controls as there are CPU cores for the multis for (int i = 0; i < _numCores; i++) { double _incr = 0.25; int _min = 1; if (_family == 12) //Llano { _incr = 1; _min = 4; } else if (_family == 14) //Brazos { _incr = 0.25; _min = 1; } else if (_family == 16) //Kabini { _incr = 0.5; _min = 4; } var control = new NumericUpDown() { AutoSize = true, DecimalPlaces = 2, Increment = (decimal)_incr, Maximum = (decimal)_maxCOF, Minimum = _min, TabIndex = i, TextAlign = HorizontalAlignment.Center, Value = 4, }; toolTip1.SetToolTip(control, "CPUMultNBDivider for core " + (i + 1) + ".\r\nReference clock (default: 100 MHz) times " + _maxCOF + " 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; // set the tab order VidNumericUpDown.TabIndex = 3 + _numCores; refreshButton.TabIndex = VidNumericUpDown.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) + 270; //Brazos merge next line from BT //refreshButton.Click += (s, e) => LoadFromHardware(_index); refreshButton.Click += (s, e) => LoadFromHardware(); }