1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
| #include "mbox.h"
#include "peripherals/mbox.h"
#include "uart0.h"
unsigned int width, height, pitch, isrgb; /* dimensions and channel order */
unsigned char *fb; /* raw frame buffer address */
void fb_init() {
unsigned int __attribute__((aligned(16))) mbox[35];
mbox[0] = 35 * 4;
mbox[1] = MBOX_CODE_BUF_REQ;
// set physical width / height
mbox[2] = MBOX_TAG_SET_PHY_WIDTH_HEIGHT;
mbox[3] = 8;
mbox[4] = MBOX_CODE_TAG_REQ;
mbox[5] = 960; // width in pixels
mbox[6] = 720; // height in pixels
// set virtual width / height
mbox[7] = MBOX_TAG_SET_VTL_WIDTH_HEIGHT;
mbox[8] = 8;
mbox[9] = MBOX_CODE_TAG_REQ;
mbox[10] = 920; // width in pixels
mbox[11] = 720; // height in pixels
// set virtual offset
mbox[12] = MBOX_TAG_SET_VTL_OFFSET;
mbox[13] = 8;
mbox[14] = MBOX_CODE_TAG_REQ;
mbox[15] = 0; // X in pixels
mbox[16] = 0; // Y in pixels
// set depth
mbox[17] = MBOX_TAG_SET_DEPTH;
mbox[18] = 4;
mbox[19] = MBOX_CODE_TAG_REQ;
mbox[20] = 32; // bits per pixel
// set pixel order
mbox[21] = MBOX_TAG_SET_PIXEL_ORDER;
mbox[22] = 4;
mbox[23] = MBOX_CODE_TAG_REQ;
mbox[24] = 1; // 0x0: BGR, 0x1: RGB
// allocate buffer
mbox[25] = MBOX_TAG_ALLOCATE_BUFFER;
mbox[26] = 8;
mbox[27] = MBOX_CODE_TAG_REQ;
mbox[28] = 4096; // req: alignment in bytes / res: frame buffer base address in bytes
mbox[29] = 0; // frame buffer size in bytes
// get pitch
mbox[30] = MBOX_TAG_GET_PITCH;
mbox[31] = 4;
mbox[32] = MBOX_CODE_TAG_REQ;
mbox[33] = 0; // res: bytes per line
mbox[34] = 0x0;
mbox_call(mbox, 8);
if (mbox[20] == 32 && mbox[28] != 0) {
mbox[28] &= 0x3FFFFFFF; // convert GPU address to ARM address
width = mbox[5]; // get actual physical width
height = mbox[6]; // get actual physical height
pitch = mbox[33]; // get number of bytes per line
isrgb = mbox[24]; // get the actual channel order
fb = (void *)((unsigned long)mbox[28]);
}
else {
uart_printf("Unable to set screen resolution to 1024x768x32\n");
}
}
|