Fan control for Windows in Bootcamp?

Discussion in 'Windows, Linux & Others on the Mac' started by cdavi060, Apr 29, 2008.

  1. macrumors regular

    Joined:
    Oct 3, 2007
    #1
    Im running Vista in bootcamp on my MacBook Pro and the temp at idle is around 165 and if I do anything else on it like games or such its around 180+. The thing is I bearly hear the fans, unlike in OSX they kick on when needed. Can someone let me in on a program like fan control but for windows that will allow me to control my macbook fans while in vista? I dont like this temp issue!!!
     
  2. macrumors G3

    clevin

    Joined:
    Aug 6, 2006
    #2
    its more or less hardware related, not that windows can 100% control. but you can always search google for "fan control windows".

    The best thing can happen, is apple releasing better bootcamp drivers, apple pulled together the hardwares, and did the internal design, they are the best candidate to develop good drivers for windows.
     
  3. macrumors 68040

    Neil321

    Joined:
    Nov 6, 2007
    Location:
    Britain, Avatar Created By Bartelby
  4. thread starter macrumors regular

    Joined:
    Oct 3, 2007
    #4
    yeah i thought of that program, tried it, but doesnt know the apple hardware so only can monitor temp, no fan control.
     
  5. thread starter macrumors regular

    Joined:
    Oct 3, 2007
    #5
  6. macrumors 68040

    Neil321

    Joined:
    Nov 6, 2007
    Location:
    Britain, Avatar Created By Bartelby
    #6
    That's odd as it recognizes mine
     
  7. thread starter macrumors regular

    Joined:
    Oct 3, 2007
    #7
    not too sure but it doesnt

    i got the remapper to work so thats all i needed. wanted to keep the temps down on my macbook while playing games
     
  8. macrumors 68040

    Neil321

    Joined:
    Nov 6, 2007
    Location:
    Britain, Avatar Created By Bartelby
    #8
    Ah Ok but looking at that remapper,is there a way to just use it to just to control fan speed & not all the bumff that goes with it, ie disable the remapper??
     
  9. thread starter macrumors regular

    Joined:
    Oct 3, 2007
    #9
    yeah i think so im not sure. I didnt try because the things it remaps i dont really use anyway so guess it doesnt really bother me.

    but yes i see you can enable and disable the remapper
     
  10. macrumors 68040

    Neil321

    Joined:
    Nov 6, 2007
    Location:
    Britain, Avatar Created By Bartelby
    #10
    Ok cheers,i might try downloading it & give it a try out
     
  11. macrumors regular

    Joined:
    Jun 9, 2007
    #11
    I want to do the same thing as the original poster, but I am using Windows XP (32-bit). My OS X is 10.5.3 and Boot Camp is 2.1, on a Santa Rosa MBP.

    I have read many, many posts saying how Input Remapper (which has not been updated since Fall 2007) causes tons of problems with Boot Camp 2.1. I do not wish to use Input Remapper.

    Has anyone found an alternative? Perhaps smcfancontrol via OS X? Does that work perfectly in 10.5.3? It hasn't been updated in forever.
     
  12. aki
    macrumors 6502a

    Joined:
    Mar 2, 2004
    Location:
    Japan
    #12
    i use smbfancontrol and it works well until there is a windows app....basically i have a hifanspeed setting for windows and u can set the speeds then reboot - not shutdown and startup - and the same fan settings will last for the windows

    for everyday apps its not important i think but for games my hd gets too hot after some playing so i think its good to use
     
  13. macrumors regular

    Joined:
    Jun 9, 2007
    #13

    I used smcfancontrol in Tiger, so I guess I will try in in Leopard.

    Nobody has a report of a bad experience with it in Leopard, right?
     
  14. aki
    macrumors 6502a

    Joined:
    Mar 2, 2004
    Location:
    Japan
    #14
    i havent read of any problem.....it works for me on 10.5.3
     
  15. macrumors 601

    MagnusVonMagnum

    Joined:
    Jun 18, 2007
    #15
    I just tried Input Remapper on my September '08 era MBP (pre-current) runnnig XP Pro in Boot Camp and when I go to the Mac book settings page, it just starts going nuts (keyboard brightness settings start changing and when the fan speeds come up, the whole system locks for like 10 seconds and then continues but the fan speeds reported are totally erratic and then it locks up again and the whole thing repeats until I can hit "OK" and then everything seems OK except I have NO IDEA what the current fan speeds actually are or how to set them when the config screen is so messed up. When I tried to configure "presets", it did nothing. Basically, the program seems downright awful to me. There's got to be a better solution for fan control in XP. Having to boot up OS X just to set the fan is ludicrous. I don't know how some of you can call that a decent solution. It seems ridiculous that Apple couldn't provide some kind of fan control in Boot Camp. But then I've got SMCFan Control in OS X precisely because Apple's defaults are too low (I set it to 4000 RPM while docked and the temperature rarely goes above 110F and often hovers near 98. But I don't need the Nvidia chips to get screwed up because I'm playing a game in XP.

    Update:

    I installed Speed Fan, which can't control the MBP's fan speed, but it did tell me the GPU and two core CPU temperatures which were pretty hot compared to OS X. So I reinstalled input remapper and tried it again. The configuration screen is still acting up, but I was able to adjust the minimum fan speed to increase and while it was hard to read the intermittent displays to see what it was set to, I eventually found a 4500RPM, which keeps the cores during basic apps around 100F and the GPU around 120F. Once I hit OK, it Input Remapper seems to stabilize and the MBP's keyboard lighting buttons, volume settings, etc. all seem to function. It's just unstable in configure mode for some reason, although until I do more long term testing I won't know for certain in that regard, but at least it did bump up the fans without having to boot into OS X each time. If it can control the fans, I see no reason why someone couldn't make a fan + temperature monitor app combo without the key remapping aspects.
     
  16. macrumors newbie

    Joined:
    Apr 30, 2009
    #16
    Dedicate Fan Controller Program under Boot Camp (Open Source)

    Hi, friends:

    I got my own program which a dedicated fan controller. It been tested on my new Mac Mini early 2009 (Windows XP). And my source code is open. Everybody should use this to build up a nice GUI program.

    NOTE: The program is only a proof of concept. So it only works but lack of functionalities.

    1. The program need GIVEIO device driver support. You can get it by install speedfan. Or you can download the standalone package from anywhere.
    2. It is a console command line program. Not easy to use, but easy for script. You can add temperature sensor detect function in it.
    3. How to get the 'key' definitions of Apple SMC. Please install smcFanControl under OSX. There is a console program in /Application/smcFanControl.app/Contents/Resource/Source. It named 'smc'. Use the command line 'smc -l' to get all 'Key' definitions.
    4. For the Apple SMC programming, please refer to Linux Kernel applesmc.c which a kernel extension. It is nice program to communicate with SMC under Linux. The code should help you and me.

    BTW: Sorry for my poor English. I am from China. If you got better idea, please email me: iam.liuzhong@gmail.com

    [codebox]
    #include "stdlib.h"
    #include "windows.h"
    //Console inp and out functions
    #include "conio.h"

    #define APPLESMC_DATA_PORT 0x300
    /* command/status port used by Apple SMC */
    #define APPLESMC_CMD_PORT 0x304

    #define APPLESMC_STATUS_MASK 0x0f
    #define APPLESMC_READ_CMD 0x10
    #define APPLESMC_WRITE_CMD 0x11
    #define APPLESMC_GET_KEY_BY_INDEX_CMD 0x12
    #define APPLESMC_GET_KEY_TYPE_CMD 0x13

    SC_HANDLE hSCMan = NULL;
    BOOL IsWinNT = FALSE;
    BOOL IsDriverLoaded = FALSE;

    // Return Value // Meaning
    enum { DRIVER_ALREADY_INSTALLED=100, //100 Driver is already Installed
    DRIVER_INSTALL_SUCCESS, //101
    DRIVER_INSTALL_FAILURE, //102
    DRIVER_ALREADY_UNINSTALLED, //103
    DRIVER_UNINSTALL_SUCCESS, //104
    DRIVER_UNINSTALL_FAILURE, //105
    DRIVER_NOT_INSTALLED, //106
    DRIVER_ALREADY_STARTED, //107
    DRIVER_IN_USE
    };

    // SCM & GIVEIO control
    BOOL InitSCM()
    {
    if ((hSCMan = OpenSCManager(NULL, NULL,SC_MANAGER_ALL_ACCESS)) == NULL)
    {
    printf("ERROR: Can't connect to Service Control Manager.\n");
    return FALSE;
    }
    return TRUE;
    }

    BOOL ShutDownSCM(SC_HANDLE hSCMan)
    {
    return CloseServiceHandle(hSCMan);
    }

    DWORD DriverInstall(LPSTR lpPath, LPSTR lpDriver)
    {
    BOOL dwStatus = 0;
    SC_HANDLE hService = NULL;

    // add to service control manager's database
    if ((hService = CreateService(hSCMan,
    lpDriver,
    lpDriver,
    SERVICE_ALL_ACCESS,
    SERVICE_KERNEL_DRIVER,
    SERVICE_DEMAND_START,
    SERVICE_ERROR_NORMAL,
    lpPath, NULL, NULL, NULL, NULL, NULL)) == NULL)
    dwStatus = GetLastError();
    else
    CloseServiceHandle(hService);

    return dwStatus;
    }

    DWORD DriverRemove(LPSTR lpDriver)
    {
    BOOL dwStatus = 0;
    SC_HANDLE hService = NULL;

    // get a handle to the service
    if ((hService = OpenService(hSCMan, lpDriver, SERVICE_ALL_ACCESS)) != NULL)
    {
    // remove the driver
    if (!DeleteService(hService)) dwStatus = GetLastError();
    }
    else dwStatus = GetLastError();

    if (hService != NULL) CloseServiceHandle(hService);

    return dwStatus;
    }

    ///////////////////////////////////////////////////////////////
    // FUNC: GetDriverStatus
    // DESC: Returns a Bool; 0 -> GiveIO Driver NOT loaded
    // 1 -> GiveIO Driver LOADED
    ///////////////////////////////////////////////////////////////

    int GetDriverStatus()
    {
    return IsDriverLoaded;
    }

    BOOL AttachDrv()
    {
    HANDLE h;

    h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL);
    if(h == INVALID_HANDLE_VALUE)
    {
    printf("ERROR: Couldn't access giveio device.\n");
    return FALSE;
    }
    CloseHandle(h);
    return TRUE;
    }

    BOOL AttachDIO()
    {
    OSVERSIONINFO osvi;
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    GetVersionEx(&osvi);

    IsWinNT = osvi.dwMajorVersion == 3 || osvi.dwMajorVersion == 4 || osvi.dwMajorVersion == 5 || osvi.dwMajorVersion == 6;

    if(IsWinNT)
    {
    //Load the DirectIO Driver and attach it to this process

    //try opening SCM ; if failed Bail out
    if(!InitSCM()) return FALSE;

    //Install the Driver
    char szDrvPath[MAX_PATH];
    GetSystemDirectory(szDrvPath,MAX_PATH);
    lstrcat(szDrvPath,"\\Drivers\\GiveIO.sys");
    DWORD dwRet = DriverInstall(szDrvPath,"giveio");

    if(dwRet != 0 && dwRet != 0x00000431) //Success or already installed
    {
    printf("ERROR: Could not initialize GiveIO.sys Driver.\n");
    return FALSE;
    }

    if(AttachDrv())
    {
    IsDriverLoaded = TRUE ;
    return TRUE ; // Successful PROCESS_ATTACH
    }
    else
    {
    DriverRemove("giveio");
    return FALSE;
    }
    }

    return TRUE;
    }

    BOOL DetachDIO()
    {
    // Perform any necessary cleanup.

    //if it is WinNT unload the giveIO driver
    if(IsWinNT)
    {
    DriverRemove("giveio");
    IsDriverLoaded = FALSE ;
    return ShutDownSCM(hSCMan); //No Error Check :p
    }
    return FALSE;
    }

    short OutPort( int PortAddress, int PortData )
    {
    short Dummy;

    Dummy = (short)(_outp( PortAddress, PortData ));
    return(Dummy);

    }

    short InPort( int PortAddress )
    {
    short PortData;

    PortData = (short)(_inp( PortAddress ));
    return( PortData );

    }

    int wait_status(short val)
    {
    unsigned int i;

    val = val & APPLESMC_STATUS_MASK;

    for (i = 0; i < 200; i++) {
    if ((InPort(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val) return 0;
    Sleep(10);
    }

    return -1;
    }

    static int applesmc_read_key(const char* key, short* buffer, short len)
    {
    int i;

    OutPort(APPLESMC_CMD_PORT, APPLESMC_READ_CMD);
    if (wait_status(0x0c)) return -1;

    for (i = 0; i < 4; i++) {
    OutPort(APPLESMC_DATA_PORT, key);
    if (wait_status(0x04)) return -1;
    }

    OutPort(APPLESMC_DATA_PORT, len);

    for (i = 0; i < len; i++) {
    if (wait_status(0x05)) return -1;
    buffer = InPort(APPLESMC_DATA_PORT);
    }

    return 0;
    }

    static int applesmc_write_key(const char* key, short* buffer, short len)
    {
    int i;

    OutPort(APPLESMC_CMD_PORT, APPLESMC_WRITE_CMD);
    if (wait_status(0x0c)) return -1;

    for (i = 0; i < 4; i++) {
    OutPort(APPLESMC_DATA_PORT, key);
    if (wait_status(0x04)) return -1;
    }

    OutPort(APPLESMC_DATA_PORT, len);

    for (i = 0; i < len; i++) {
    if (wait_status(0x04)) return -1;
    OutPort(APPLESMC_DATA_PORT, buffer);
    }

    return 0;
    }



    int main(int argc, char* argv[])
    {
    short speed[2];
    char MINSPEED[5] = "F0Mn";
    int st = 0;
    AttachDIO();
    st = GetDriverStatus();
    printf("Driver Status: %d\n", st);
    if (st != 1) return 1;

    if (argc == 2) {
    printf("Set the Minimal speed: %s\n", argv[1]);
    st = atoi(argv[1]);
    st = st * 4;
    speed[0] = st >> 8;
    speed[1] = st & 0x00FF;
    for (int i = 0; i < 120; i++)
    {
    if (applesmc_write_key(MINSPEED, speed, 2) == 0) break;
    Sleep(1000);
    }
    if (i == 120) {
    printf("Failed, retry again!\n");
    return 1;
    }
    printf("Update Successful\n");
    }

    for (int i = 0; i < 120; i++)
    {
    memset(speed, 0, sizeof(speed));
    if (applesmc_read_key(MINSPEED, speed, 2) == 0) break;
    Sleep(1000);
    }
    if (i == 120) {
    printf("Failed, retry again!\n");
    return 1;
    }
    st = (speed[0] * 0xFF + speed[1]) / 4;
    printf("Current Minimal speed: %d\n", st);
    printf("All OK!\n");
    return 0;
    }

    [/codebox]

    Usage: smc [Target minimal fan speed you like]


    Two more points:
    1. Speedfan lack of support to Apple SMC device driver. Speedfan just only find the SMBus devices on Motherboard. For ex. my Mac Mini has a nvidia nForce motherboard. Speedfan find the I/O Port 2140 & 2100 which all are nvidia SMBus devices. And nvidia did not provide any control method from OS to control fan or something. At least the symptom apply for my Macmini.

    2. InputRemapper. A greate tool, It can work well with Apple SMC interfaces. But the fan control did not work for some sort of Mac. And the code not updated for a long time. By my test, Inputremapper may add some retry mechanism. Because I try to update the SMC chip which failed time to time. So my program will retry 120 times untill success.
     

    Attached Files:

    • smc.zip
      File size:
      32 KB
      Views:
      2,266
  17. macrumors newbie

    Joined:
    Nov 3, 2008
    #17
    just to confirm, SMCfancontrol is a great alternative - when i'm running 3D rendering software I like to whack the fans up to 6200 (while in leopard), then reboot into windows without powering off, and the speed stays up - nice and cool! Mind, when I used vista on bootcamp it still overheated way too much for my tastes, even with fans blaring away.
     
  18. aki
    macrumors 6502a

    Joined:
    Mar 2, 2004
    Location:
    Japan
    #18
    i also use smcfancontrol on 3.06 imac and it works great for windows use using the reboot trick
     
  19. macrumors newbie

    Joined:
    May 27, 2009
    #19
    Does it set both fans

    Thanks campliu,

    This solution works great. A nice Fan only control for bootcamp running windows xp.

    Only question I have is when I type "smc 3000" - does this set both fans to 3000 rpm?

    Lk
     
  20. macrumors newbie

    Joined:
    Jun 15, 2009
    #20
    SMC - Enhanced version

    Hi all,

    I'm working on campliu project and I've modified his code, following his suggestions, to add some other features.
    Actually I've also merged some code from the "Extended Fan Control" OSx program to implement these features:

    1) Speed setting for 2 MBP unibody fans (CPU and GPU)
    2) Speeds fans dinamically updated on the basis of the CPU and GPU temperatures independently.
    3) Three working modality:
    (a) Only system information retrieval (fans speeds and temperatures, nothing is set)
    (b) Only minimum speeds fans settings (one shot)
    (c) Fans speeds updated every 3,5 seconds on the basis of CPU and GPU temperature (linear calculation specifying min and max temp and min fan speed. Like Extended Fan Control program.)

    The program is in a very draft state, it works (WinXP prof 32bit) but there are some problems with temperatures calculations (not aligned with SpeedFan results) and it haven't a GUI to control settings (but I'm working on).

    The big problem is still present: it is incompatible with BootCamp driver, KbdMgr.exe process must be killed before running this program.
    It seems that BootCamp driver polls temperatures and fans speeds causing something like hardware deadlocks that freeze the PC for 1 or 2 seconds.
    The workaround is to kill the KbdMgr.exe setup minumum fan speed and restart KbdMgr.exe (the command from console to kill the process is "TASKKILL /F /IM Kbdmgr.exe").
    But dinamically adjusted fans speeds requires the KbdMgr.exe not running at all: so no keyboard special keys mapping :-(
    Unfortunately InputRemapper doesn't work on my MBP Unibody (April 2009) so I can't use it for keyboard special keys mapping.

    My main objective is gaming ... so special keys are not necessary, but I desire the perfection ... ;-)

    I need some help on this issues:

    1) Correctly decode CPU and GPU temps
    2) Adding keyboard special key mapping to cover BootCamp functionalities
    3) GUI making
    4) Hardware port timeout settings (probably could be a way to making BootCamp working at the same time)

    Any suggestion will be very appreciated.

    Thanks campliu!

    Source code and executable in attachment.

    USAGE:
    FAN <MinTemp> <MaxTemp> <CPU_RPM> <GPU_RPM> <Debug=0/1/2>
    or
    FAN <CPU_RPM> <GPU_RPM>
    or
    FAN -i

    P.S. Damned Visual Studio Express 2008 (more than 1Gb to build a piece of code) ... use MingW gcc instead it works and it's very light (some changes to "conio.h" are required ... if someone needs help I'm here).
     

    Attached Files:

  21. macrumors newbie

    Joined:
    Jun 16, 2009
    #21
    Works on MBP 17"

    Just thought I would say thanks for the code. While it works it takes forever to change the fan speed, and gives an error message "Read RPM F1AC Error ...OK!" which seems weird.

    Any way, a GUI would be very nice. I can diffidently say that this is important to those of us who want to work on windows for extended periods of time or just want to run a game or two.

    What is the upper limit of the fans? I had them set to 8000 RPM and it was very very loud but kept the book cool, although I think that there is not much benefit to very fast RPM there must be a sweet spot.


    EDIT!

    OK for some reason the program stopped working altogether when I removed speedfan. I just get the Driver Status = 0! So I guss it cant find the driver to control the fan? What driver is speedfan using that we need for Fancontrol to work?

    -Gagi
     
  22. macrumors 68000

    -tWv-

    Joined:
    May 11, 2009
    Location:
    Ohio
    #22
    Install SMC fan control in osx. Then when you want to boot into windows, set the fan speed up higher. If you restart, not shutdown and reboot, the fan speed will stay the same and it will stay cooler in windows with the fans up higher.
     
  23. macrumors newbie

    Joined:
    Jun 16, 2009
    #23
    While this works I would rather not have to boot into OSX to get into windows. I would like the fans to work just as well through windows as they do through OSX. Besides I use rEFit to boot OSX Ubuntu and Windows, it would be nice to have some code that can control fan speed across platform.

    -Gagi

     
  24. macrumors 68000

    -tWv-

    Joined:
    May 11, 2009
    Location:
    Ohio
    #24
    I also use refit to boot ubuntu, osx, and windows but i guess try to use the code that is posted in one of the above posts. I don't know of any easy way to do this besides using smc fan control.
     
  25. macrumors 601

    MagnusVonMagnum

    Joined:
    Jun 18, 2007
    #25
    Input Remapper works OK for me, albeit the issues mentioned earlier in the thread (i.e. the preference settings causes it to slow the computer and act weird, but once it's set it runs fine in the background). It starts with Windows. No OS X boot to engage the fan is needed. Really, I can't believe no one has made an SMC like program for Windows considering all the Macbook and Macbook Pro owners out there that would be interested in it. I'd even pay a few bucks for a good program that didn't act funny in Windows.
     

Share This Page