openvortex-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Openvortex-dev] SPDIF first mile stone.


From: Manuel Jander
Subject: [Openvortex-dev] SPDIF first mile stone.
Date: Wed, 10 Sep 2003 00:53:37 -0400

Hi everyone,

I think i got something SPDIF'ish out of my MX300. There was some more
work to be done, i didn't expected, but finally, i got a digital (TTL)
signal that changes according to the audio output.

Below is the function i hacked to bring the SPDIF port to life. After
that (hooked into vortex_hw_init), all that is needed to be done is to
route audio to ADB addresses 0x92 and 0x93.

I'll try to integrate SPDIF as a separate ALSA PCM device for easier
usage. Stay tuned :)

void vortex_spdif_init(vortex_t *vortex) {
        int i, spdif_sr=48000, spdif_mode=1, this_38 = 0, this_04=0, this_08=0,
this_0c=0;
        
        /* CAsp4Spdif::InitializeSpdifHardware(void) */
        hwwrite(vortex->mmio, 0x2205c, hwread(vortex->mmio, 0x2205c) &
0xfff3fffd);
        for (i=0x291D4; i<0x29200; i+=4)
                hwwrite(vortex->mmio, i, 0);
        hwwrite(vortex->mmio, 0x29190, hwread(vortex->mmio, 0x29190) |
0xc0000);
        //hwwrite(vortex->mmio, 0x29190, hwread(vortex->mmio, 0x29190) |
EN_SPDIF);
                
        /* CAsp4Spdif::ProgramSRCInHardware(enum  SPDIF_SR,enum  SPDIFMODE) */
        if (this_04 && this_08) {
                int edi;
                
                i = (((0x5DC00000 / spdif_sr) + 1) >> 1);
                if (i > 0x800) {
                        if (i < 0x1ffff)
                                edi = (i >> 1);
                        else 
                                edi = 0x1ffff;
                } else {
                        i = edi = 0x800;
                }
                /* this_04 and this_08 are the CASp4Src's (samplerate 
converters) */
                vortex_src_setupchannel(vortex, this_04, edi, 0, 1, this_0c, 1, 
0,
edi, 1);
                vortex_src_setupchannel(vortex, this_08, edi, 0, 1, this_0c, 1, 
0,
edi, 1);
        }
        i = spdif_sr;
        spdif_sr |= 0x8c;
        switch (i) {
                case 32000:
                        this_38 &= 0xFFFFFFFE;
                        this_38 &= 0xFFFFFFFD;
                        this_38 &= 0xF3FFFFFF;
                        this_38 |= 0x03000000;
                        this_38 &= 0xFFFFFF3F;
                        spdif_sr &= 0xFFFFFFFD;
                        spdif_sr |= 1;
                        break;
                case 44100:
                        this_38 &= 0xFFFFFFFE;
                        this_38 &= 0xFFFFFFFD;
                        this_38 &= 0xF0FFFFFF;
                        this_38 |= 0x03000000;
                        this_38 &= 0xFFFFFF3F;
                        spdif_sr &= 0xFFFFFFFC;
                        break;
                case 48000:
                        if (spdif_mode == 1) {
                                this_38 &= 0xFFFFFFFE;
                                this_38 &= 0xFFFFFFFD;
                                this_38 &= 0xF2FFFFFF;
                                this_38 |= 0x02000000;
                                this_38 &= 0xFFFFFF3F;
                        } else {
                                this_38 |= 0x00000003;
                                this_38 &= 0xFFFFFFBF;
                                this_38 |= 0x80;
                        }
                        spdif_sr |= 2;
                        spdif_sr &= 0xFFFFFFFE;
                        break;
                
        }
        hwwrite(vortex->mmio, 0x291D0, this_38 & 0xffff);
        hwwrite(vortex->mmio, 0x291D4, this_38 >> 0x10);
        hwwrite(vortex->mmio, 0x29194, spdif_sr);
}






reply via email to

[Prev in Thread] Current Thread [Next in Thread]