use the locations specified in the bcm2708_boot header
[AROS.git] / arch / arm-raspi / boot / vc_fb.c
blobf798092750dc152436cd2133742861bd99fcc196
1 /*
2 Copyright � 2013-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: VideoCore framebuffer routines
6 Lang: english
7 */
9 #include <hardware/bcm2708.h>
10 #include <hardware/bcm2708_boot.h>
11 #undef ARM_PERIIOBASE
13 #include <hardware/videocore.h>
15 #include "bootconsole.h"
16 #include "vc_mb.h"
17 #include "vc_fb.h"
19 #undef ARM_PERIIOBASE
20 #define ARM_PERIIOBASE (__arm_periiobase)
21 extern uint32_t __arm_periiobase;
23 int vcfb_init(void)
25 unsigned int fb_width, fb_height, fb_depth, fb_pitch;
26 unsigned int count;
27 volatile unsigned int *vcmb_msg = (unsigned int *)BOOTMEMADDR(bm_mboxmsg);
29 scr_Type = SCR_UNKNOWN;
31 /* query the display dimensions */
33 vcmb_msg[0] = 8 * 4;
34 vcmb_msg[1] = VCTAG_REQ;
35 vcmb_msg[2] = VCTAG_GETRES;
36 vcmb_msg[3] = 8;
37 vcmb_msg[4] = 0;
38 vcmb_msg[5] = 0;
39 vcmb_msg[6] = 0;
40 vcmb_msg[7] = 0; // terminate tag
42 vcmb_write((void *)VCMB_BASE, VCMB_PROPCHAN, (void *)vcmb_msg);
43 vcmb_msg = vcmb_read((void *)VCMB_BASE, VCMB_PROPCHAN);
45 if (!vcmb_msg || (vcmb_msg[1] != VCTAG_RESP))
46 return 0;
48 if (((fb_width = vcmb_msg[5]) == 0) || ((fb_height = vcmb_msg[6]) == 0))
50 fb_width = 1024;
51 fb_height = 768;
55 /* fill in our framebuffer configuration/allocation request */
57 unsigned int c = 1;
58 vcmb_msg[c++] = VCTAG_REQ;
60 vcmb_msg[c++] = VCTAG_SETRES;
61 vcmb_msg[c++] = 8;
62 vcmb_msg[c++] = 8;
63 vcmb_msg[c++] = fb_width;
64 vcmb_msg[c++] = fb_height;
66 vcmb_msg[c++] = VCTAG_SETVRES; // duplicate physical size...
67 vcmb_msg[c++] = 8;
68 vcmb_msg[c++] = 8;
69 vcmb_msg[c++] = fb_width;
70 vcmb_msg[c++] = fb_height;
72 vcmb_msg[c++] = VCTAG_SETDEPTH;
73 vcmb_msg[c++] = 4;
74 vcmb_msg[c++] = 4;
76 fb_depth = 16;
78 vcmb_msg[c++] = fb_depth;
80 vcmb_msg[c++] = VCTAG_FBALLOC;
81 vcmb_msg[c++] = 8;
82 vcmb_msg[c++] = 4;
83 vcmb_msg[c++] = 16;
84 vcmb_msg[c++] = 0;
86 vcmb_msg[c++] = 0; // terminate tags
88 vcmb_msg[0] = (c << 2); // fill in request size
90 vcmb_write((void *)VCMB_BASE, VCMB_PROPCHAN, (void *)vcmb_msg);
91 vcmb_msg = vcmb_read((void *)VCMB_BASE, VCMB_PROPCHAN);
93 if (!vcmb_msg || (vcmb_msg[1] != VCTAG_RESP))
94 return 0;
96 count = 2; // locate the allocation request
97 while((vcmb_msg[count]))
99 if (vcmb_msg[count] == VCTAG_FBALLOC)
100 break;
102 count += 3 + (vcmb_msg[count + 1] >> 2);
104 if (count > c)
105 return 0;
108 if (vcmb_msg[count + 2] != (VCTAG_RESP + 8))
109 return 0;
111 if (((scr_FrameBuffer = (void *)vcmb_msg[count + 3]) == 0) || (vcmb_msg[count + 4] == 0))
112 return 0;
115 /* query the framebuffer pitch */
117 vcmb_msg[0] = 7 * 4;
118 vcmb_msg[1] = VCTAG_REQ;
119 vcmb_msg[2] = VCTAG_GETPITCH;
120 vcmb_msg[3] = 4;
121 vcmb_msg[4] = 0;
122 vcmb_msg[5] = 0;
123 vcmb_msg[6] = 0; // terminate tag
125 vcmb_write((void *)VCMB_BASE, VCMB_PROPCHAN, (void *)vcmb_msg);
126 vcmb_msg = vcmb_read((void *)VCMB_BASE, VCMB_PROPCHAN);
128 if (!vcmb_msg || (vcmb_msg[4] != (VCTAG_RESP + 4)))
129 return 0;
131 if ((fb_pitch = vcmb_msg[5]) == 0)
132 return 0;
135 scr_Type = SCR_GFX;
137 fb_Init(fb_width, fb_height, fb_depth, fb_pitch);
139 return 1;