Yellow Dog Linux 5.01 Kernel patch to add 3D support

Investigation into how Linux on the PS3 might lead to homebrew development.

Moderators: cheriff, emoon

Post Reply
hermes
Posts: 25
Joined: Tue Mar 30, 2004 5:22 am
Location: Spain

Yellow Dog Linux 5.01 Kernel patch to add 3D support

Post by hermes »

Hi

I have done a script to install, patch and compile a custom kernel for the YDL 5.01 to add the devices to use libps3rsx , UDF 2.50, to resolve a problem with the Bluray unit when Linux start without one disc, etc.

It is very easy to use:

Code: Select all

- Enter in Linux as root user

- Extract all files in a directory 

- Copy the file kernel-source-2.6.16-20070425.ydl.3.ppc64.rpm in the same directory from
Yellow Dog Linux 5.01 DVD (from /YellowDog/RPMS directory)

- Run the install script from the console using: ./install_kernel

- Wait a time to finish

- When it finish, you have a new 2.6.16-20070425.ydl.3custom kernel

- Edit kboot.conf file from /etc/ directory

- Add this lines to the end of file:

ydlcustom='/dev/sda1:/vmlinux-2.6.16-20070425.ydl.3custom initrd=/dev/sda1:/initrd-2.6.16-20070425.ydl.3custom.img root=/dev/sda2 init=/sbin/init video=ps3fb:mode:3 rhgb'

- Remember to change ps3fb:mode:3 to your custom video mode (3 is for 1280x720P 60 Hz non fullscreen)

- If you want, change the string 'default=ydl' to 'default=ydlcustom' to autorun this kernel from kboot:

- You can run too this kernel writing 'ydlcustom' from kboot console

- You can run the old kernel writing 'ydl' (you can use this method to safe if the new kernel fail)

- When restart Linux, on root mode,  you can see in the /dev/ directory 3 news devices: ps3gpu_vram, ps3gpu_fifo and ps3gpu_ctrl. This devices requires root perms, so you need to change it to use in user mode.

For example, edit /etc/rc.local and put this lines:

chmod 766 /dev/ps3gpu_vram
chmod 766 /dev/ps3gpu_fifo
chmod 766 /dev/ps3gpu_ctrl

Also is possible to use an alternative method using /dev/fb0 to map the memory (see demo3d_alternative code, files util.c, line 112 and util.l line 62). It is valid for user mode too.

It is based in part of the work of Glaurung and IronPeter to do a ps3fb driver for the 2.6.16 kernel using some partially patch information and the libps3rsx method.

i have included a little 3D example with libps3rsx too, slightly modified to include some info and one alternative form to get the memory areas form /dev/fb0

Also i include two ioctl functions, one to call lv1_gpu_context_attribute function (same method i see in a patch of Glaurung), and other to flip the screen (to use double buffer)

For example, to 'reset' the FIFO position i use this method:

Code: Select all

uint32_t *ctrl = gpu->ctrl.virt;
uint32_t fifo_base;
struct ps3fb_ioctl_gpu_attr a;
fifo_base =ctrl[0x10] & ~(gpu->fifo.len - 1);

a.attr=1;
a.p0=fifo_base;
a.p1=fifo_base;
a.p2=0;
a.p3=0;
ioctl(fb_fd, PS3FB_IOCTL_GPU_ATTR, &a);
So, i put always the FIFO datas from offset 0


To flip the screen, you send a param with the VRAM offset :

Code: Select all

#define PS3FB_IOCTL_GPU_FLIP      _IOW&#40;'r', 10, int&#41;   /* flip the buffers */ <- defined in util.h

if&#40;!val&#41; offset=width*height*4; else offset=0; 
ioctl&#40;fb_fd, PS3FB_IOCTL_GPU_FLIP, &offset&#41;; // flip the screen

It can use ps3gpu_vram, ps3gpu_fifo and ps3gpu_ctrl devices to asign the memory areas on libps3rsx, but i have an alternative method to use only a device too:

Code: Select all

from /dev/fb0 

 mem=mmap&#40;0, res->len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset&#41;;

offset =          0 -> mem= XRAM
offset = 0x10000000 -> mem= VRAM
offset = 0x20000000 -> mem= FIFO
offset = 0x30000000 -> mem= CTRL
I think it is an easy method to map the memory, without problems with the user perms under Linux.

To compile the kernel maybe you need to disable the PS3 screen saver to avoid the hang of the system, but i don't remember any problem compiling it from a virtual console under Gnome.

In any way, if you are using YDL 5.01 and you use the same .rpm file, it compile without problems (except if you need free space in your hdd)

i hope you understand my post (i am spanish and the English language is a little problem for me :) )

The download link:

http://mods.elotrolado.net/~hermes/ps3/ ... ort.tar.gz
billb
Posts: 32
Joined: Wed Dec 12, 2007 5:52 am

Post by billb »

Works great! Thanks.
MeeM
Posts: 1
Joined: Thu Dec 13, 2007 4:16 am

Isn't working

Post by MeeM »

Hey guys can you help me, this isn't working on my PS3
Here is that what happens, when i Run it:

Code: Select all

Starting ...
find&#58; /usr/src/linux-2.6.16-20070425.ydl.3&#58; Datei oder Verzeichnis nicht gefunden
Kernel Source Install ...
Warnung&#58; kernel-source-2.6.16-20070425.ydl.3.ppc64.rpm&#58; Header V3 DSA-Signatur&#58; NOKEY, key ID aeb6b9c4
Vorbereiten...              ########################################### &#91;100%&#93;
   1&#58;kernel-source          ########################################### &#91;100%&#93;
Copying ps3fb.c ...
cp&#58; reguläre Datei „/usr/src/linux-2.6.16-20070425.ydl.3/drivers/video/ps3fb.c“ kann nicht angelegt werden&#58; Datei oder Verzeichnis nicht gefunden
Error copying ps3fb.c
&#91;root@localhost kernel_custom&#93;#

Any idea?
myke666
Posts: 1
Joined: Thu Dec 13, 2007 9:49 am

yo

Post by myke666 »

i ve got the same bug because i canfnd the good rpm source : 2.6.22 instead of 2.6.16 ...
Partial solution :
go to /usr/src/
you'll find this folder : linux-2.6.22-0.ydl.rc4
make a copy and rename it : linux-2.6.16-20070425.ydl.3
launch again and it will work...
But it will ask you 46406466416.97+5 questions to compile the kernel, and for the moment, i haven't found the good combinaison to compile correctly the kernel with the last sources....

The rpm sources of 2.6.16 is only available on old ydl dvd isos...
So .... WE'RE DOOMED !!!!!
WE'LL NEVER SEE SOMETHING WORKING IN 3D ON OUR PS3 ... !!!?!
Or it's because i'm a french noob on linux for ps3?! ...

hum well ... hermes .... please ...
can you put the rpm somewhere ?
thanks by advance...

MyKe
hermes
Posts: 25
Joined: Tue Mar 30, 2004 5:22 am
Location: Spain

Post by hermes »

Hi.

You can download the old ISO and extract it... but I include the ps3fb.c file (instead of a patch) to do easy the portability to others kernels (2.6.16 kernel is very different and because it , i have done this patch).

I think if you compile the old kernel it don't work well
billb
Posts: 32
Joined: Wed Dec 12, 2007 5:52 am

Post by billb »

I'm running on the custom kernel:

Code: Select all

#  uname -a
#  Linux localhost.localdomain 2.6.16-20070425.ydl.3custom #1 SMP Tue Dec 11 19&#58;34&#58;45 MST 2007 ppc64 ppc64 ppc64 GNU/Linux
And I'm able to run the demo as root:

Code: Select all

&#91;root@localhost demo3d&#93;# ./demo3d.elf
video mode 3
vram 264241152 fifo 65536 ctrl 4096
mmap&#58; /dev/fb0 len 16777216
mmap&#58; /dev/ps3gpu_vram len 264241152
mmap&#58; /dev/ps3gpu_fifo len 65536
mmap&#58; /dev/ps3gpu_ctrl len 4096
But should I be installing the ps3rsx and x driver as described here?

I can make and load the ps3rsx module:

Code: Select all

#  dmesg
...
ps3rsx&#58; PS3 RSX access module, 1.0.0
ps3rsx&#58; reserved XDR memory is @c000000000500000, len 18874368
ps3rsx&#58; 254MB of DDR video ram at 0x7001e0000000 mapped at d0000800900af000 handle 5a5a5a5b
ps3rsx&#58; context 0x55555554 dma=440000421000 driver=4000001f4000 reports=480000810000 reports_size=10000
ps3rsx&#58; ctrl=d00008009feaf000 drv=d00008009feb0000 reports=d00008009fed0000
ps3rsx&#58; version 2.11 RSX rev12 0MB RAM channel 1 core 500MHz mem 650MHz
ps3rsx&#58; remapped XDR apperture at c000000000500000 size 18432kB to RSX
And I can build xf86-video-ps3 after updating xorg-x11-server-sdk using a package from FC6: xorg-x11-server-sdk-1.1.1-47.8.fc6.ppc.rpm.

But when I tried to use the driver in /etc/X11/xorg.conf, my Xorg.0.log said:

Code: Select all

&#40;II&#41; LoadModule&#58; "ps3"
&#40;II&#41; Loading /usr/lib/xorg/modules/drivers/ps3_drv.so
&#40;II&#41; Module ps3&#58; vendor="X.Org Foundation"
        compiled for 7.1.1, module version = 0.3.1
        ABI class&#58; X.Org Video Driver, version 1.0
&#40;EE&#41; module ABI major version &#40;1&#41; doesn't match the server's version &#40;0&#41;
&#40;II&#41; UnloadModule&#58; "ps3"
&#40;II&#41; Unloading /usr/lib/xorg/modules/drivers/ps3_drv.so
&#40;EE&#41; Failed to load module "ps3" &#40;module requirement mismatch, 0&#41;
Err... help?
hermes
Posts: 25
Joined: Tue Mar 30, 2004 5:22 am
Location: Spain

Post by hermes »

It is easy: you are using a Xorg-server with version different to the ps3 driver and it fail.

you need to compile and older xf86 code merged with the ps3 code to work or you need to compile a new xorg-server code with the correct version for the xf86 code (but i don´t have any idea about the steps to do it)
Post Reply