pnozz_write_dac_ctl_reg(pPnozz, DAC_32BIT_CTRL, 3);
pnozz_write_dac_ctl_reg(pPnozz, DAC_32BIT_CTRL, 0 );  pnozz_write_dac_ctl_reg(pPnozz, 0x10, 2); pnozz_write_dac_ctl_reg(pPnozz, 0x11, 0); pnozz_write_dac_ctl_reg(pPnozz, 0x14, 5); pnozz_write_dac_ctl_reg(pPnozz, 0x08, 1); pnozz_write_dac_ctl_reg(pPnozz, 0x15, 5); pnozz_write_dac_ctl_reg(pPnozz, 0x16, 0x63);
PnozzSetDepth(PnozzPtr pPnozz, int depth){    int new_sls;    unsigned int bits, scr, sscr;    int s0, s1, s2, s3, ps;    unsigned char mcr, pf, mc3, es, pll0, vco;        DumpDAC(pPnozz);    DumpCRTC(pPnozz);        switch (depth) {	case 8:	    pPnozz->depthshift = 0;	    ps = 2;	    mcr = 1;	/* the 3GX manual says 7 here */	    pf = 3;	    mc3 = 0;	    es = 0;	    pll0 = 0x47;	    vco = 0x63;	    break;	case 16:	    pPnozz->depthshift = 1;	    ps = 3;	    mcr = 3;	/* the 3GX manual says 5 */	    pf = 4;	    mc3 = 0;	    es = 2;	    pll0 = 0x87;	    vco = 0xa3;	    break;	case 24:	    /* boo */	    xf86Msg(X_ERROR, "We don't DO 24bit pixels dammit!\n");	    return 0;	case 32:	    pPnozz->depthshift = 2;	    ps = 5;	    mcr = 5;	/* the 3GX manual says 3 */	    pf = 6;	    mc3 = 0x80;	    es = 6;	    pll0 = 0xc7;	    vco = 0xe3;	    break;    }    /*     * this could be done a lot shorter and faster but then nobody would      * understand what the hell we're doing here without getting a major      * headache. Scanline size is encoded as 4 shift values, 3 of them 3 bits      * wide, 16 << n for n>0, one 2 bits, 512 << n for n>0. n==0 means 0     */    new_sls = pPnozz->width << pPnozz->depthshift;    pPnozz->scanlinesize = new_sls;    bits = /*800/*/new_sls;    s3 = upper_bit(bits);    if (s3 > 9) {	bits &= ~(1 << s3);	s3 -= 9;    } else s3 = 0;    s2 = upper_bit(bits);    if (s2 > 0) {	bits &= ~(1 << s2);	s2 -= 4;    } else s2 = 0;    s1 = upper_bit(bits);    if (s1 > 0) {        bits &= ~(1 << s1);        s1 -= 4;    } else s1 = 0;    s0 = upper_bit(bits);    if (s0 > 0) {        bits &= ~(1 << s0);        s0 -= 4;    } else s0 = 0;    xf86Msg(X_ERROR, "sls: %x sh: %d %d %d %d leftover: %x\n", new_sls, s0, s1,         s2, s3, bits);    /*      * now let's put these values into the System Config Register. No need to      * read it here since we (hopefully) just saved the content      */    scr = pPnozz->SvSysConf & ~((7<<SHIFT_0) | (7<<SHIFT_1) | (7<<SHIFT_2) |         (3 << SHIFT_3) | (7 << PIXEL_SHIFT) | (7 << SWAP_SHIFT));    scr = (s0 << SHIFT_0) | (s1 << SHIFT_1) | (s2 << SHIFT_2) |         (s3 << SHIFT_3) | (ps << PIXEL_SHIFT) | (es << SWAP_SHIFT);    xf86Msg(X_ERROR, "new scr: %x DAC %x %x %x\n", scr, mcr, pf, mc3);    DumpSCR(scr);        /* whack the engine... */    pnozz_write_4(pPnozz, SYS_CONF, scr);        /* ok, whack the DAC */    pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_1, 0x11);    pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_2, 0x45);    pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_3, mc3);    /*      * despite the 3GX manual saying otherwise we don't need to mess with any     * clock dividers here     */    pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_CLK, 1/*/mcr*/);    pnozz_write_dac_ctl_reg(pPnozz, DAC_POWER_MGT, 0);    pnozz_write_dac_ctl_reg(pPnozz, DAC_PIXEL_FMT, pf);    pnozz_write_dac_ctl_reg(pPnozz, DAC_8BIT_CTRL, 0);    pnozz_write_dac_ctl_reg(pPnozz, DAC_16BIT_CTRL, 0xc6);    pnozz_write_dac_ctl_reg(pPnozz, DAC_32BIT_CTRL, 3);    /*     * we feed data to the DAC in 64bit chunks, so if we want a higher colour      * depth we need to feed it faster. In theory we'd just need to program a      * higher pixel clock but for some reason this doesn't quite work     *///    pnozz_write_dac_ctl_reg(pPnozz, DAC_PLL0, pll0);//    pnozz_write_dac_ctl_reg(pPnozz, DAC_VCO_DIV, vco);    /* whack the CRTC. Not sure if we need to */#if 0    pnozz_write_4(pPnozz, VID_HTOTAL, 24 + (100 << pPnozz->depthshift));    pnozz_write_4(pPnozz, VID_HSRE, 8 /*<< pPnozz->depthshift*/);    pnozz_write_4(pPnozz, VID_HBRE, 18 /*<< pPnozz->depthshift*/);    pnozz_write_4(pPnozz, VID_HBFE, 18 + (100 << pPnozz->depthshift));#endif    sscr = pnozz_read_4(pPnozz, SYS_CONF);    xf86Msg(X_ERROR, "scr: %x\n", sscr);    return TRUE;}