xref: /haiku/src/system/boot/platform/u-boot/video.cpp (revision 5f4f984a94d150153bcb00a2ed780d0437859543)
1 /*
2  * Copyright 2009, Johannes Wischert
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "video.h"
8 
9 #include <arch/cpu.h>
10 #include <boot/stage2.h>
11 #include <boot/platform.h>
12 #include <boot/menu.h>
13 #include <boot/kernel_args.h>
14 #include <boot/platform/generic/video.h>
15 #include <util/list.h>
16 #include <drivers/driver_settings.h>
17 
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 
22 #include "arch_framebuffer.h"
23 
24 
25 ArchFramebuffer *gFramebuffer = NULL;
26 
27 
28 //	#pragma mark -
29 
30 
31 bool
32 video_mode_hook(Menu *menu, MenuItem *item)
33 {
34 	return true;
35 }
36 
37 
38 Menu *
39 video_mode_menu()
40 {
41 	Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Video Mode");
42 	MenuItem *item;
43 
44 	menu->AddItem(item = new(nothrow) MenuItem("Default"));
45 	item->SetMarked(true);
46 	item->Select(true);
47 	item->SetHelpText("The Default video mode is the one currently configured "
48 		"in the system. If there is no mode configured yet, a viable mode will "
49 		"be chosen automatically.");
50 
51 
52 	menu->AddSeparatorItem();
53 	menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
54 	item->SetType(MENU_ITEM_NO_CHOICE);
55 
56 	return menu;
57 }
58 
59 
60 //	#pragma mark -
61 
62 
63 extern "C" void
64 platform_set_palette(const uint8 *palette)
65 {
66 }
67 
68 
69 extern "C" void
70 platform_blit4(addr_t frameBuffer, const uint8 *data, uint16 width,
71 	uint16 height, uint16 imageWidth, uint16 left, uint16 top)
72 {
73 }
74 
75 
76 extern "C" void
77 platform_switch_to_logo(void)
78 {
79 	// in debug mode, we'll never show the logo
80 	if ((platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT) != 0)
81 		return;
82 
83 	status_t err;
84 
85 	if (gFramebuffer != NULL) {
86 		err = gFramebuffer->SetDefaultMode();
87 		if (err < B_OK) {
88 			ERROR("Framebuffer SetDefaultMode failed!\n");
89 			return;
90 		}
91 
92 		err = video_display_splash(gFramebuffer->Base());
93 	}
94 }
95 
96 
97 extern "C" void
98 platform_switch_to_text_mode(void)
99 {
100 }
101 
102 
103 extern "C" status_t
104 platform_init_video(void)
105 {
106 
107 #warning TODO: Fix u-boot arm framebuffer location from fdt!
108 #ifdef __ARM__
109 	#if defined(BOARD_CPU_ARM920T)
110 		extern ArchFramebuffer *arch_get_fb_arm_920(addr_t base);
111 		gFramebuffer = arch_get_fb_arm_920(0x88000000);
112 	#elif defined(BOARD_CPU_BCM2835) || defined(BOARD_CPU_BCM2836)
113 		extern ArchFramebuffer *arch_get_fb_arm_bcm2835(addr_t base);
114 		// BCM2835/BCM2836 gets their framebuffer base from a Mailbox
115 		gFramebuffer = arch_get_fb_arm_bcm2835(0x0);
116 	#elif defined(BOARD_CPU_OMAP3)
117 		extern ArchFramebuffer *arch_get_fb_arm_omap3(addr_t base);
118 		gFramebuffer = arch_get_fb_arm_omap3(FB_BASE);
119 	#elif defined(BOARD_CPU_PXA270)
120 		ArchFramebuffer *arch_get_fb_arm_pxa270(addr_t base);
121 		gFramebuffer = arch_get_fb_arm_pxa270(0xA3000000);
122 	#endif
123 #endif
124 
125 	if (gFramebuffer == NULL) {
126 		ERROR("No framebuffer device found!\n");
127 		return B_ERROR;
128 	}
129 
130 	status_t result = gFramebuffer->Probe();
131 	if (result != B_OK)
132 		return result;
133 
134 	gFramebuffer->Init();
135 	if (result != B_OK)
136 		return result;
137 
138 	return B_OK;
139 }
140