fuente:
Linux device driver for xbox 360 audio released
Posted on Monday, October 05, 2009 @ 04:21:22 GMT
xbox360 [source: jc4360 @ xboxhacker.net] I am releasing the first version of linux device driver for xbox 360 audio. you can get source from here. The device driver is alsa compitable, so basically you can compile mplayer and then it should play various music formats for you easily. It supports both analog stereo and digital spdif (only dobly digital by now). Thanks for tmbinc for his finding on 360 audio hardware details and his help on debuging the code. The license for the code is GPL.
In order to compile it, you will need to properly edit sound/pci/Makefile with the following statements, and also change Kconfig if needed. do not forget to enable ALSA support in your kernel.
snd-xenon-objs := xenon_snd.o
obj-$(CONFIG_SND_XENON) += snd-xenon.o
To compile mplayer, download MPlayer-1.0rc2.tar.bz2 and edit libmpcodecs/ad_hwac3.c by applying the following patch:
--- ad_hwac3.c 1969-12-31 19:15:52.000000000 -0500
+++ ad_hwac3.c.org 1969-12-31 19:15:17.000000000 -0500
@@ -144,4 +144,17 @@
}
+static inline unsigned short bswap16(unsigned short a)
+{
+ return ((a&0xff)<<8) | ((a&0xff00)>>8);
+}
+
+static inline void mem_swap16(void *buf, int line)
+{
+ int i=0;
+ uint16_t *buf16 = (uint16_t *)buf;
+ for (i=0; i<line/2; i++)
+ buf16[i]=bswap16(buf16[i]);
+}
+
static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
{
@@ -177,4 +190,6 @@
memset(buf + 8 + len, 0, 6144 - 8 - len);
+ mem_swap16(buf, 6144);
+
return 6144;
}
@@ -375,4 +390,6 @@
memset(&buf[fsize + 8], 0, nr_samples * 2 * 2 - (fsize + 8));
+ mem_swap16(buf, nr_samples * 2 * 2);
+
return nr_samples * 2 * 2;
}
To test:
-bash-3.2# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: AudioPCI [Xenon AudioPCI], device 0: Xenon Audio [Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 0: AudioPCI [Xenon AudioPCI], device 1: Xenon Audio [Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
stereo music:
./mplayer -ao alsa:device=hw=0.0 music.mp3/ape/flac/wav
digital music:
./mplayer -ao alsa:device=hw=0.1 -ac hwac3 music.ac3
./mplayer -ao alsa:device=hw=0.1 -ac hwdts music.dts
Please feel free to improve this driver for the following things:
1) Interrupt: I could not get pci interrupt to work. This driver currently uses a timer interrupt.
2) DTS passthrough: my receiver could not decode the raw dts bit stream sent by mplayer, I guess one register was not set correctly for dts passthrough. If you have a jtag setup on xbox 360 motherboard, you could help on this: put a dvd movie with dts track into 360 drive and play(check if your receiver receive dts signal), read 64 bytes from address 0xea001600 with your jtag device and then post the result here.
3) Mixer such as volumn setting etc.
The driver may not be bug free. I am not responsible for any damge that the driver may cause to your hardware, so use it at your own risk.