Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pbkit quits if the nvclk freq is not default #536

Open
GXTX opened this issue Feb 3, 2022 · 1 comment
Open

pbkit quits if the nvclk freq is not default #536

GXTX opened this issue Feb 3, 2022 · 1 comment

Comments

@GXTX
Copy link
Contributor

GXTX commented Feb 3, 2022

It shouldn't do this.

https://github.com/XboxDev/nxdk/blob/master/lib/pbkit/pbkit.c#L2815

@GXTX
Copy link
Contributor Author

GXTX commented Feb 27, 2022

I think something like this would work? Tested on hardware with mesh and triangle sample and appears not to break anything. Someone else can PR.

    DWORD nv_base = 16667; //hz
    DWORD nv_clk = ((nv_base * ndiv) / (odiv << pdiv)) / mdiv;
    DWORD nv = nv_clk;
    DWORD d = 1000000 / 32;

    // taken from linux nv04.c
    while (((nv % 5) == 0) && ((d % 5) == 0)) {
        nv /= 5;
        d /= 5;
    }

    while (((nv % 2) == 0) && ((d % 2) == 0)) {
        nv /= 2;
        d /= 2;
    }

    while (nv > 0xFFFF || d > 0xFFFF) {
        nv >>= 1;
        d >>= 1;
    }

#if DBG
    debugPrint("input freq : %dHz\n", nv_clk);
    debugPrint("num        : %d\n", nv);
    debugPrint("den        : %d\n", d);
    debugPrint("timer freq : %dHz\n", (nv_clk * d) / nv);
#endif

    VIDEOREG(NV_PTIMER_NUMERATOR) = nv;
    VIDEOREG(NV_PTIMER_DENOMINATOR) = d;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant