SPU2

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
blueshogun96
Posts: 19
Joined: Thu Jun 09, 2005 3:18 am

SPU2

Post by blueshogun96 »

I was just wondering what would be the best way to obtain technical information on the PS2's SPU2. I never got a chance to order a linux dev kit, so would it be there or are there other docs out there? thanks.
User avatar
jbit
Site Admin
Posts: 293
Joined: Sat May 28, 2005 3:11 am
Location: København, Danmark
Contact:

Post by jbit »

There isn't much info about the SPU2 floating around unfortuantly.
However in essence it's two PlayStation1 SPUs stuck together with some core selection logic and capable of 48KHz output (and some other stuff).
Programming the SPU2 is pretty much the same as programming a PlayStation1 SPU.

I wrote the ps2snd module/library in ps2sdk (some day I'll update freesd so ps2snd works with it, I swear!) which should give an EE program access to all the interesting SPU2 features, and an easy way to stream stereo ADPCM music.

If you want I can whip up a few examples on how to use libps2snd for uploading samples, playing voices and doing some basic effects on the output.

Oh, and the PS2 Linux kit didn't include any documentation about the SPU2.

Hope this helps
blueshogun96
Posts: 19
Joined: Thu Jun 09, 2005 3:18 am

Post by blueshogun96 »

thanks, i really appreciate it
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Me too. I'd love some examples on using the voices. That would be handy for a variety of programs. As it is right now, everything just adds whatever sounds they need together into a single stereo stream using the CPU.
User avatar
jbit
Site Admin
Posts: 293
Joined: Sat May 28, 2005 3:11 am
Location: København, Danmark
Contact:

Post by jbit »

Okay, over the weekend I'll write some sample code for using ps2snd (libsd) for doing sound effects and stuff using voices while streaming ADPCM music from somewhere.
I'll also write some basic docs about how libSD does stuff, since it may not be completly obvious in some cases.
Keep in mind that ps2snd requries a relativly recent SCE libSD at the moment, since freeSD and old libSD's have problems with interrupts amungst other things, and I havn't got round to finding and fixing exactly what's up yet.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Great! Thanks.
blueshogun96
Posts: 19
Joined: Thu Jun 09, 2005 3:18 am

Post by blueshogun96 »

jbit wrote:Okay, over the weekend I'll write some sample code for using ps2snd (libsd) for doing sound effects and stuff using voices while streaming ADPCM music from somewhere.
I'll also write some basic docs about how libSD does stuff, since it may not be completly obvious in some cases.
Keep in mind that ps2snd requries a relativly recent SCE libSD at the moment, since freeSD and old libSD's have problems with interrupts amungst other things, and I havn't got round to finding and fixing exactly what's up yet.
Thanks jbit, I can't thank you enough :)
User avatar
jbit
Site Admin
Posts: 293
Joined: Sat May 28, 2005 3:11 am
Location: København, Danmark
Contact:

Post by jbit »

Gah, sorry, I forgot about doing this, had other things to do.
I'll start work on it tonight.. ;)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

No rush... we all understand how it is. Besides, I think the saying "beggars can't be choosers" applies here. :)
dreamtime
Posts: 14
Joined: Mon Feb 02, 2004 10:12 pm
Location: Melbourne, Australia
Contact:

Post by dreamtime »

@shogun: i remember from a LONG time ago I came across a ps1 SPU library with nice code and a technical doc. A bit of googling and I found this:

http://www.geocities.com/james7780/PSX/psxprog.html

I'm pretty sure it's the same lib that I remember, but can't see the doc in there. It should be easy to find anyway if you search for old ps1 spu info.

cheers,
Tony
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

While the PSX SPU docs are helpful in understanding the SPU2, it doesn't help with libsd very much.
dreamtime
Posts: 14
Joined: Mon Feb 02, 2004 10:12 pm
Location: Melbourne, Australia
Contact:

Post by dreamtime »

J.F. wrote:While the PSX SPU docs are helpful in understanding the SPU2, it doesn't help with libsd very much.
... but if you look at shogun's original post, he's after technical info about spu2, not libsd :-)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Yep! Just noticed. :) Jbit had offered info on using libsd to take advantage of the more technical aspects of the SPU2. While a few people could use technical info on the SPU2, more people could use info on libsd. Plus, like I said, the SPU isn't exactly a SPU2, so it would still take more work to go from SPU info to working directly on the SPU2.
blueshogun96
Posts: 19
Joined: Thu Jun 09, 2005 3:18 am

Post by blueshogun96 »

@dreamtime: first of all, thanks for your great ps2dev tutorials. second of all, thanks for the link. this is a start to understanding how the SPU2 works :)

so far, all I was able to find on SPU2 was a set of registers. These were copied and pasted from the PS2E plugin SPU2null 0.4 by the pcsx2 team:

#define REG_VP_VOLL 0x1F900000
#define REG_VP_VOLR 0x1F900002
#define REG_VP_PITCH 0x1F900004
#define REG_VP_ADSR1 0x1F900006
#define REG_VP_ADSR2 0x1F900008
#define REG_VP_ENVX 0x1F90000A
#define REG_VP_VOLXL 0x1F90000C
#define REG_VP_VOLXR 0x1F90000E
#define REG_S_PMON 0x1F900180
#define REG_S_NON 0x1F900184
#define REG_S_VMIXL 0x1F900188
#define REG_S_VMIXEL 0x1F90018C
#define REG_S_VMIXR 0x1F900190
#define REG_S_VMIXER 0x1F900194
#define REG_P_MMIX 0x1F900198
#define CORE0_ATTR 0x1F90019A
#define REG_A_IRQA 0x1F90019C
#define REG_S_KON 0x1F9001A0
#define REG_S_KOFF 0x1F9001A4
#define REG_A_TSA 0x1F9001A8
#define REG__1AC 0x1F9001AC
#define REG__1AE 0x1F9001AE
#define REG__1B0 0x1F9001B0
#define REG_VA_SSA 0x1F9001C0
#define REG_VA_LSAX 0x1F9001C4
#define REG_VA_NAX 0x1F9001C8
#define REG_A_ESA 0x1F9002E0
#define REG_A_EEA 0x1F90033C
#define REG_S_ENDX 0x1F900340
#define SPU2_STATX_WRDY_M 0x1F900344 //not sure!
#define CORE1_ATTR 0x1F90059A
#define REG__5B0 0x1F9001B0
#define SPU2_STATX_DREQ 0x1F900744 //not sure!
#define REG_P_MVOLL 0x1F900760
#define REG_P_MVOLR 0x1F900762
#define REG_P_EVOLL 0x1F900764
#define REG_P_EVOLR 0x1F900766
#define REG_P_AVOLL 0x1F900768
#define REG_P_AVOLR 0x1F90076A
#define REG_P_BVOLL 0x1F90076C
#define REG_P_BVOLR 0x1F90076E
#define REG_P_MVOLXL 0x1F900770
#define REG_P_MVOLXR 0x1F900772
#define SPDIF_OUT 0x1F9007C0
#define IRQINFO 0x1F9007C2
#define SPDIF_MODE 0x1F9007C6
#define SPDIF_MEDIA 0x1F9007C8

No idea what they do or how they work yet. I tried to do a google search on the registers, but no results :(
dreamtime
Posts: 14
Joined: Mon Feb 02, 2004 10:12 pm
Location: Melbourne, Australia
Contact:

Post by dreamtime »

Check out SPU.TXT at http://psx.rules.org/psxrul2.shtml
It should help explain some of the registers...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

jbit wrote:Okay, over the weekend I'll write some sample code for using ps2snd (libsd) for doing sound effects and stuff using voices while streaming ADPCM music from somewhere.
I'll also write some basic docs about how libSD does stuff, since it may not be completly obvious in some cases.
Keep in mind that ps2snd requries a relativly recent SCE libSD at the moment, since freeSD and old libSD's have problems with interrupts amungst other things, and I havn't got round to finding and fixing exactly what's up yet.
Just a reminder... some of us would still be interested in this. :)
EEUG
Posts: 136
Joined: Fri May 13, 2005 4:49 am
Location: The Netherlands

Post by EEUG »

@J.F.: check the latest SMS sources out. There're working S/PDIF passthrough thingy there...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

EEUG wrote:@J.F.: check the latest SMS sources out. There're working S/PDIF passthrough thingy there...
Cool! I'll check it out right away.

EDIT: one quick note - you have a problem with an include file.

Code: Select all

ee-gcc -DVB_SYNC -D_EE -O2 -G8192 -mgpopt -Wall -mno-check-zero-division -Iinclude/ -I/usr/local/ps2dev/ps2sdk/ee/include -I/usr/local/ps2dev/ps2sdk/common/include -I/usr/local/ps2dev/ps2sdk/sbv/include -c src/SMS_PlayerMenu.c -o obj/SMS_PlayerMenu.o
src/SMS_PlayerMenu.c:19:25: SMS_GUICons.h: No such file or directory
The filename is "SMS_GUIcons.h" instead of "SMS_GUICons.h". You should change the #include, or the filename. I just copied the file to the other filename temporarily to get it compiling.
EEUG
Posts: 136
Joined: Fri May 13, 2005 4:49 am
Location: The Netherlands

Post by EEUG »

@J.F. ...yes, I'm a Win32 bound :D, thanks for the remark...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

It's easy to miss those as Windows isn't case sensitive by default, although you can set it to be if you want. I'm using linux Fedora Core 4 as my PS2 dev system, so it's case sensitive by default.

I checked a few things... I have to say, the player is REALLY nice. As long as it's avi, mpeg4 video, and mp3 or ac3 audio, it plays nice. Now if I can ever make the time to add some support for other containers... :)

I switched on the SPDIF pass-through in the settings. With regular stereo audio, it's the same as when it's not switched to SPDIF (which you would expect since the PS2 echos normal stereo out to the SPDIF by default as I understand it). The difference now came with AC3 - my digital stereo switched to surround and I got nice Dolby 5.1 surround. I need to find some more samples to try, but so far it appears the SPDIF pass-through with AC3 is a success. Great work there!
florinsasu
Posts: 47
Joined: Wed Dec 15, 2004 4:23 am

Post by florinsasu »

blueshogun96 wrote: so far, all I was able to find on SPU2 was a set of registers. These were copied and pasted from the PS2E plugin SPU2null 0.4 by the pcsx2 team:
at 0x1F9007C4 it seems to be the revision of the SPU2 chip
Post Reply