diff options
Diffstat (limited to 'src/ppu.c')
-rw-r--r-- | src/ppu.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/ppu.c b/src/ppu.c new file mode 100644 index 0000000..99574d7 --- /dev/null +++ b/src/ppu.c | |||
@@ -0,0 +1,54 @@ | |||
1 | #include "common.h" | ||
2 | |||
3 | static u32 *framebuffer = 0; | ||
4 | |||
5 | void | ||
6 | ppu_init(void) { | ||
7 | static MboxFramebufferRequest fb_request = { | ||
8 | .buf_size = 96, | ||
9 | .code = MBOX_REQUEST, | ||
10 | .screen_tag = { | ||
11 | .header = { | ||
12 | .id = 0x48003, | ||
13 | .buf_size = 8, | ||
14 | }, | ||
15 | .width = 1024, | ||
16 | .height = 1024, | ||
17 | }, | ||
18 | .virtual_screen_tag = { | ||
19 | .header = { | ||
20 | .id = 0x48004, | ||
21 | .buf_size = 8, | ||
22 | }, | ||
23 | .width = 1024, | ||
24 | .height = 1024, | ||
25 | }, | ||
26 | .depth_tag = { | ||
27 | .header = { | ||
28 | .id = 0x48005, | ||
29 | .buf_size = 4, | ||
30 | }, | ||
31 | .depth = 32, | ||
32 | }, | ||
33 | .framebuffer_tag = { | ||
34 | .header = { | ||
35 | .id = 0x40001, | ||
36 | .buf_size = 8, | ||
37 | }, | ||
38 | .fb_addr = 0, | ||
39 | .fb_size = 0, | ||
40 | } | ||
41 | }; | ||
42 | |||
43 | if (mb_call(MBOX_CH_PROP, &fb_request) | ||
44 | && fb_request.depth_tag.depth == 32 | ||
45 | && fb_request.framebuffer_tag.fb_addr != 0) { | ||
46 | fb_request.framebuffer_tag.fb_addr &= 0x3FFFFFFF; | ||
47 | framebuffer = (u32*)((uintptr_t)fb_request.framebuffer_tag.fb_addr); | ||
48 | for (size_t i = 0; i < 1024 * 100; i++) { | ||
49 | framebuffer[i] = 0xffaa22; // 0xBBGGRR | ||
50 | } | ||
51 | } else { | ||
52 | uart_puts("Unable initialize framebuffer\n"); | ||
53 | } | ||
54 | } | ||