- Fix a bug in the speedstep driver, now the cookie is initialized in open so multiple watching clients don't interfere any more.
- Cleanup and smaller issues in the preferences app. - Add driver and preferences to the image. The driver supports some Pentium M and VIA Centaur CPUs (1000 to 2100 Mhz) and need acpi to detect the cpu device, so you have to enable acpi in the kernel setting file to test it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30234 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -54,7 +54,7 @@ SYSTEM_APPS = AboutSystem ActivityMonitor CharacterMap CodyCam DeskCalc DiskProb
|
||||
PoorMan PowerStatus ProcessController Screenshot ShowImage SoundRecorder
|
||||
StyledEdit Terminal TextSearch TV Workspaces
|
||||
;
|
||||
SYSTEM_PREFERENCES = Appearance Backgrounds DataTranslations E-mail
|
||||
SYSTEM_PREFERENCES = Appearance Backgrounds CPUFrequency DataTranslations E-mail
|
||||
FileTypes Fonts Keyboard Keymap Media Menu Mouse Network Printers Screen
|
||||
ScreenSaver Sounds Time Touchpad <preference>Tracker VirtualMemory
|
||||
;
|
||||
@@ -180,6 +180,7 @@ if $(TARGET_ARCH) = x86 {
|
||||
|
||||
# drivers
|
||||
AddNewDriversToHaikuImage disk scsi : scsi_cd scsi_disk ;
|
||||
AddNewDriversToHaikuImage power : enhanced_speedstep ;
|
||||
|
||||
# legacy drivers
|
||||
AddDriversToHaikuImage : console dprintf $(X86_ONLY)keyboard null
|
||||
@@ -269,9 +270,9 @@ for linkTarget in $(DESKBAR_DESKTOP_APPLETS) {
|
||||
AddDirectoryToHaikuImage home config be Preferences ;
|
||||
# TODO/NOTE: Cannot use $(SYSTEM_PREFERENCES) here since there is
|
||||
# "<preferences>Tracker"...
|
||||
DESKBAR_PREFERENCES = Appearance Backgrounds DataTranslations E-mail
|
||||
FileTypes Fonts Keyboard Keymap Media Menu Mouse Network Printers Screen
|
||||
ScreenSaver Sounds Time Touchpad Tracker VirtualMemory
|
||||
DESKBAR_PREFERENCES = Appearance Backgrounds CPUFrequency DataTranslations
|
||||
E-mail FileTypes Fonts Keyboard Keymap Media Menu Mouse Network Printers
|
||||
Screen ScreenSaver Sounds Time Touchpad Tracker VirtualMemory
|
||||
;
|
||||
for linkTarget in $(DESKBAR_PREFERENCES) {
|
||||
AddSymlinkToHaikuImage home config be Preferences
|
||||
|
||||
@@ -31,66 +31,16 @@
|
||||
#define EST_BASENAME "power/enhanced_speedstep/%d"
|
||||
|
||||
// name of pnp generator of path ids
|
||||
#define EST_PATHID_GENERATOR "est/path_id"
|
||||
#define EST_PATHID_GENERATOR "enhanced_speedstep/path_id"
|
||||
|
||||
static device_manager_info *sDeviceManager;
|
||||
static ConditionVariable sFrequencyCondition;
|
||||
static vint32 sCurrentID;
|
||||
|
||||
|
||||
static status_t
|
||||
est_open(void *initCookie, const char *path, int flags, void** cookie)
|
||||
{
|
||||
TRACE("est: open\n");
|
||||
est_cookie *device = (est_cookie*)initCookie;
|
||||
*cookie = device;
|
||||
device->stop_watching = 0;
|
||||
|
||||
// enable enhanced speedstep
|
||||
TRACE("est: check if enhanced speedstep is enabled\n");
|
||||
uint64 msrMisc = x86_read_msr(MSR_MISC);
|
||||
if ((msrMisc & MSR_EST_ENABLED) == 0) {
|
||||
TRACE("est: enable enhanced speedstep\n");
|
||||
x86_write_msr(MSR_MISC, msrMisc | MSR_EST_ENABLED);
|
||||
|
||||
uint64 msrMisc = x86_read_msr(MSR_MISC);
|
||||
if ((msrMisc & MSR_EST_ENABLED) == 0) {
|
||||
TRACE("est: enable enhanced speedstep failed\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// get freq_info
|
||||
if (est_get_info(&(device->available_states)) != B_OK)
|
||||
return B_ERROR;
|
||||
freq_info *freqsInfo = device->available_states;
|
||||
|
||||
// count number of states
|
||||
TRACE("est: frequency info:\n");
|
||||
freq_info *f;
|
||||
device->number_states = 0;
|
||||
for (f = freqsInfo; f->frequency != 0; f++) {
|
||||
TRACE("est: Frequency %u, Volts %u, Power %i, Latency %u, id %u\n",
|
||||
f->frequency, f->volts, f->power, f->id, EST_TRANS_LAT);
|
||||
device->number_states++;
|
||||
}
|
||||
|
||||
// print current frequency
|
||||
freq_info *f2 = est_get_current(freqsInfo);
|
||||
if (f2) {
|
||||
TRACE("est: Current Frequency %u, Volts %u, Power %i, Latency %u\n",
|
||||
f2->frequency, f2->volts, f2->power, EST_TRANS_LAT);
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
est_read(void* _cookie, off_t position, void *buffer, size_t* numBytes)
|
||||
{
|
||||
TRACE("est: est_read\n");
|
||||
|
||||
if (*numBytes < 1)
|
||||
return B_IO_ERROR;
|
||||
|
||||
@@ -140,7 +90,6 @@ est_write(void* cookie, off_t position, const void* buffer, size_t* numBytes)
|
||||
status_t
|
||||
est_control(void* _cookie, uint32 op, void* arg, size_t len)
|
||||
{
|
||||
TRACE("est: est_control op %u\n", int(op));
|
||||
est_cookie* device = (est_cookie*)_cookie;
|
||||
status_t err = B_ERROR;
|
||||
|
||||
@@ -210,9 +159,72 @@ est_control(void* _cookie, uint32 op, void* arg, size_t len)
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
est_open(void *initCookie, const char *path, int flags, void** cookie)
|
||||
{
|
||||
TRACE("est: open\n");
|
||||
est_cookie *device;
|
||||
device = (est_cookie *)calloc(1, sizeof(est_cookie));
|
||||
if (device == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
*cookie = device;
|
||||
|
||||
device_node *node = (device_node *)initCookie;
|
||||
device->node = node;
|
||||
|
||||
device_node *parent;
|
||||
parent = sDeviceManager->get_parent_node(node);
|
||||
sDeviceManager->get_driver(parent, (driver_module_info **)&device->acpi,
|
||||
(void **)&device->acpi_cookie);
|
||||
sDeviceManager->put_node(parent);
|
||||
|
||||
device->stop_watching = 0;
|
||||
|
||||
// enable enhanced speedstep
|
||||
uint64 msrMisc = x86_read_msr(MSR_MISC);
|
||||
if ((msrMisc & MSR_EST_ENABLED) == 0) {
|
||||
TRACE("est: enable enhanced speedstep\n");
|
||||
x86_write_msr(MSR_MISC, msrMisc | MSR_EST_ENABLED);
|
||||
|
||||
uint64 msrMisc = x86_read_msr(MSR_MISC);
|
||||
if ((msrMisc & MSR_EST_ENABLED) == 0) {
|
||||
TRACE("est: enable enhanced speedstep failed\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// get freq_info
|
||||
if (est_get_info(&(device->available_states)) != B_OK)
|
||||
return B_ERROR;
|
||||
freq_info *freqsInfo = device->available_states;
|
||||
|
||||
// count number of states
|
||||
TRACE("est: frequency info:\n");
|
||||
freq_info *f;
|
||||
device->number_states = 0;
|
||||
for (f = freqsInfo; f->frequency != 0; f++) {
|
||||
TRACE("est: Frequency %u, Volts %u, Power %i, Latency %u, id %u\n",
|
||||
f->frequency, f->volts, f->power, f->id, EST_TRANS_LAT);
|
||||
device->number_states++;
|
||||
}
|
||||
|
||||
// print current frequency
|
||||
freq_info *f2 = est_get_current(freqsInfo);
|
||||
if (f2) {
|
||||
TRACE("est: Current Frequency %u, Volts %u, Power %i, Latency %u\n",
|
||||
f2->frequency, f2->volts, f2->power, EST_TRANS_LAT);
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
est_close(void* cookie)
|
||||
{
|
||||
est_cookie *device = (est_cookie*)cookie;
|
||||
free(device);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -245,30 +257,28 @@ est_support(device_node *parent)
|
||||
|| deviceType != ACPI_TYPE_PROCESSOR) {
|
||||
return 0.0;
|
||||
}
|
||||
TRACE("est_support: supported\n");
|
||||
|
||||
// check if cpu support est
|
||||
uint32 cpuNum = 0;
|
||||
system_info sysInfo;
|
||||
if (get_system_info(&sysInfo) != B_OK)
|
||||
return 0.0;
|
||||
TRACE("cpu_type: %u vendor %u model %u\n", sysInfo.cpu_type,
|
||||
TRACE("est: cpu_type: %u vendor %u model %u\n", sysInfo.cpu_type,
|
||||
sysInfo.cpu_type & B_CPU_x86_VENDOR_MASK, sysInfo.cpu_type & 0x00FF);
|
||||
if ((sysInfo.cpu_type & B_CPU_x86_VENDOR_MASK) != B_CPU_INTEL_x86)
|
||||
return 0.0;
|
||||
|
||||
TRACE("ext\n");
|
||||
cpuid_info info;
|
||||
if (get_cpuid(&info, 1, cpuNum) != B_OK)
|
||||
return 0.0;
|
||||
|
||||
TRACE("extended_features: %i\n", int(info.eax_1.extended_features));
|
||||
TRACE("est: extended_features: %i\n", int(info.eax_1.extended_features));
|
||||
|
||||
// check for enhanced speedstep
|
||||
if ((info.eax_1.extended_features & IA32_FEATURE_EXT_EST) == 0)
|
||||
return 0.0;
|
||||
|
||||
TRACE("supports est\n");
|
||||
TRACE("est: supported\n");
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
@@ -326,22 +336,8 @@ est_register_child_devices(void *_cookie)
|
||||
static status_t
|
||||
est_init_device(void *driverCookie, void **cookie)
|
||||
{
|
||||
est_cookie *device;
|
||||
device = (est_cookie *)calloc(1, sizeof(est_cookie));
|
||||
if (device == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
*cookie = device;
|
||||
|
||||
device_node *node = (device_node *)driverCookie;
|
||||
device->node = node;
|
||||
|
||||
device_node *parent;
|
||||
parent = sDeviceManager->get_parent_node(node);
|
||||
sDeviceManager->get_driver(parent, (driver_module_info **)&device->acpi,
|
||||
(void **)&device->acpi_cookie);
|
||||
sDeviceManager->put_node(parent);
|
||||
|
||||
// driverCookie is the device node
|
||||
*cookie = driverCookie;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -349,9 +345,7 @@ est_init_device(void *driverCookie, void **cookie)
|
||||
static void
|
||||
est_uninit_device(void *_cookie)
|
||||
{
|
||||
TRACE("est: est_uninit_device\n");
|
||||
est_cookie *device = (est_cookie*)_cookie;
|
||||
free(device);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "ColorStepView.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "DriverInterface.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <FindDirectory.h>
|
||||
@@ -43,6 +45,7 @@ CPUFreqDriverInterface::CPUFreqDriverInterface()
|
||||
|
||||
CPUFreqDriverInterface::~CPUFreqDriverInterface()
|
||||
{
|
||||
StopWatching();
|
||||
delete fFrequencyStates;
|
||||
|
||||
if (InitCheck() == B_OK)
|
||||
@@ -139,12 +142,13 @@ CPUFreqDriverInterface::StopWatching()
|
||||
if (fIsWatching &&
|
||||
ioctl(fDriverHandler, STOP_WATCHING_CPU_FREQ) == B_OK)
|
||||
{
|
||||
status_t status;
|
||||
status = wait_for_thread(fThreadId, &status);
|
||||
|
||||
delete fWatchingMessenger;
|
||||
fWatchingMessenger = NULL;
|
||||
|
||||
fIsWatching = false;
|
||||
|
||||
status_t status;
|
||||
return wait_for_thread(fThreadId, &status);
|
||||
}
|
||||
|
||||
return B_ERROR;
|
||||
@@ -200,7 +204,6 @@ CPUFreqDriverInterface::_FindSpeedStepDriver(const char* path)
|
||||
return B_OK;
|
||||
}
|
||||
else {
|
||||
printf("path %s\n", path.Path());
|
||||
fDriverHandler = open(path.Path(), O_RDWR);
|
||||
if (fDriverHandler >= 0) {
|
||||
uint32 magicId = 0;
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
extern "C" _EXPORT BView *instantiate_deskbar_item(void);
|
||||
|
||||
#define MAX_FREQ_STRING "9999MHz"
|
||||
|
||||
// messages FrequencySwitcher
|
||||
const uint32 kMsgDynamicPolicyPuls = '&dpp';
|
||||
|
||||
@@ -142,8 +144,7 @@ FrequencySwitcher::_CalculateDynamicState()
|
||||
for (int i = 0; i < numberOfStates; i++) {
|
||||
float usageOfStep = ColorStepView::UsageOfStep(i, numberOfStates,
|
||||
fSteppingThreshold);
|
||||
LOG("usage %f, step %f\n", usage, usageOfStep);
|
||||
|
||||
|
||||
if (usage < usageOfStep)
|
||||
{
|
||||
StateList* list = fDriverInterface->GetCpuFrequencyStates();
|
||||
@@ -554,8 +555,6 @@ StatusView::FrameResized(float width, float height)
|
||||
void
|
||||
StatusView::Draw(BRect updateRect)
|
||||
{
|
||||
|
||||
|
||||
font_height fontHeight;
|
||||
GetFontHeight(&fontHeight);
|
||||
float height = fontHeight.ascent + fontHeight.descent;
|
||||
@@ -586,8 +585,8 @@ StatusView::GetPreferredSize(float *width, float *height)
|
||||
*height = fontHeight.ascent + fontHeight.descent;
|
||||
if (!fInDeskbar)
|
||||
*height += 7;
|
||||
|
||||
*width = StringWidth(fFreqString.String());
|
||||
|
||||
*width = StringWidth(MAX_FREQ_STRING);
|
||||
}
|
||||
|
||||
|
||||
@@ -629,15 +628,15 @@ StatusView::_SetupNewFreqString()
|
||||
{
|
||||
if (fCurrentFrequency)
|
||||
fFreqString = ColorStepView::CreateFrequencyString(
|
||||
fCurrentFrequency->frequency);
|
||||
fCurrentFrequency->frequency);
|
||||
else
|
||||
fFreqString = "? MHz";
|
||||
|
||||
|
||||
ResizeToPreferred();
|
||||
|
||||
|
||||
if (fDragger) {
|
||||
BRect frame = Frame();
|
||||
fDragger->MoveTo(frame.right - 7, frame.bottom - 7);
|
||||
BRect bounds = Bounds();
|
||||
fDragger->MoveTo(bounds.right - 7, bounds.bottom - 7);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,6 +644,12 @@ void
|
||||
StatusView::_OpenPreferences()
|
||||
{
|
||||
status_t ret = be_roster->Launch(kPrefSignature);
|
||||
if (ret == B_ALREADY_RUNNING) {
|
||||
app_info info;
|
||||
ret = be_roster->GetAppInfo(kPrefSignature, &info);
|
||||
if (ret == B_OK)
|
||||
ret = be_roster->ActivateApp(info.team);
|
||||
}
|
||||
if (ret < B_OK) {
|
||||
BString errorMessage("Launching the CPU Frequency preflet failed.\n\n"
|
||||
"Error: ");
|
||||
@@ -655,7 +660,6 @@ StatusView::_OpenPreferences()
|
||||
// application
|
||||
alert->Go(NULL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user