120cbef82SFrançois Revol/*
220cbef82SFrançois Revol * Copyright 2009, Johannes Wischert
320cbef82SFrançois Revol * Distributed under the terms of the MIT License.
420cbef82SFrançois Revol */
520cbef82SFrançois Revol
620cbef82SFrançois Revol
720cbef82SFrançois Revol#include "video.h"
820cbef82SFrançois Revol
920cbef82SFrançois Revol#include <arch/cpu.h>
1020cbef82SFrançois Revol#include <boot/stage2.h>
1120cbef82SFrançois Revol#include <boot/platform.h>
1220cbef82SFrançois Revol#include <boot/menu.h>
1320cbef82SFrançois Revol#include <boot/kernel_args.h>
1498a35452SFrançois Revol#include <boot/platform/generic/video.h>
1520cbef82SFrançois Revol#include <util/list.h>
1620cbef82SFrançois Revol#include <drivers/driver_settings.h>
1720cbef82SFrançois Revol
1820cbef82SFrançois Revol#include <stdio.h>
1920cbef82SFrançois Revol#include <stdlib.h>
2020cbef82SFrançois Revol#include <string.h>
2120cbef82SFrançois Revol
228eeafbceSAlexander von Gluck IV#include "arch_framebuffer.h"
2320cbef82SFrançois Revol
2420cbef82SFrançois Revol
258eeafbceSAlexander von Gluck IVArchFramebuffer *gFramebuffer = NULL;
2620cbef82SFrançois Revol
2720cbef82SFrançois Revol
2820cbef82SFrançois Revol//	#pragma mark -
2920cbef82SFrançois Revol
3020cbef82SFrançois Revol
3120cbef82SFrançois Revolbool
3220cbef82SFrançois Revolvideo_mode_hook(Menu *menu, MenuItem *item)
3320cbef82SFrançois Revol{
3420cbef82SFrançois Revol	return true;
3520cbef82SFrançois Revol}
3620cbef82SFrançois Revol
3720cbef82SFrançois Revol
3820cbef82SFrançois RevolMenu *
3920cbef82SFrançois Revolvideo_mode_menu()
4020cbef82SFrançois Revol{
4120cbef82SFrançois Revol	Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Video Mode");
4220cbef82SFrançois Revol	MenuItem *item;
4320cbef82SFrançois Revol
4420cbef82SFrançois Revol	menu->AddItem(item = new(nothrow) MenuItem("Default"));
4520cbef82SFrançois Revol	item->SetMarked(true);
4620cbef82SFrançois Revol	item->Select(true);
4720cbef82SFrançois Revol	item->SetHelpText("The Default video mode is the one currently configured "
4820cbef82SFrançois Revol		"in the system. If there is no mode configured yet, a viable mode will "
4920cbef82SFrançois Revol		"be chosen automatically.");
5020cbef82SFrançois Revol
5120cbef82SFrançois Revol
5220cbef82SFrançois Revol	menu->AddSeparatorItem();
5320cbef82SFrançois Revol	menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
5420cbef82SFrançois Revol	item->SetType(MENU_ITEM_NO_CHOICE);
5520cbef82SFrançois Revol
5620cbef82SFrançois Revol	return menu;
5720cbef82SFrançois Revol}
5820cbef82SFrançois Revol
5920cbef82SFrançois Revol
6020cbef82SFrançois Revol//	#pragma mark -
6120cbef82SFrançois Revol
6298a35452SFrançois Revol
6398a35452SFrançois Revolextern "C" void
6498a35452SFrançois Revolplatform_set_palette(const uint8 *palette)
6598a35452SFrançois Revol{
6698a35452SFrançois Revol}
6798a35452SFrançois Revol
6898a35452SFrançois Revol
6998a35452SFrançois Revolextern "C" void
708eeafbceSAlexander von Gluck IVplatform_blit4(addr_t frameBuffer, const uint8 *data, uint16 width,
718eeafbceSAlexander von Gluck IV	uint16 height, uint16 imageWidth, uint16 left, uint16 top)
7298a35452SFrançois Revol{
7398a35452SFrançois Revol}
7498a35452SFrançois Revol
758eeafbceSAlexander von Gluck IV
7620cbef82SFrançois Revolextern "C" void
7720cbef82SFrançois Revolplatform_switch_to_logo(void)
7820cbef82SFrançois Revol{
7920cbef82SFrançois Revol	// in debug mode, we'll never show the logo
8020cbef82SFrançois Revol	if ((platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT) != 0)
8120cbef82SFrançois Revol		return;
8298a35452SFrançois Revol
8398a35452SFrançois Revol	status_t err;
8498a35452SFrançois Revol
858eeafbceSAlexander von Gluck IV	if (gFramebuffer != NULL) {
868eeafbceSAlexander von Gluck IV		err = gFramebuffer->SetDefaultMode();
878eeafbceSAlexander von Gluck IV		if (err < B_OK) {
888eeafbceSAlexander von Gluck IV			ERROR("Framebuffer SetDefaultMode failed!\n");
898eeafbceSAlexander von Gluck IV			return;
908eeafbceSAlexander von Gluck IV		}
9198a35452SFrançois Revol
9204cbc258SFredrik Holmqvist		err = video_display_splash(gFramebuffer->Base());
938eeafbceSAlexander von Gluck IV	}
9420cbef82SFrançois Revol}
9520cbef82SFrançois Revol
9620cbef82SFrançois Revol
9720cbef82SFrançois Revolextern "C" void
9820cbef82SFrançois Revolplatform_switch_to_text_mode(void)
9920cbef82SFrançois Revol{
10020cbef82SFrançois Revol}
10120cbef82SFrançois Revol
10220cbef82SFrançois Revol
10320cbef82SFrançois Revolextern "C" status_t
10420cbef82SFrançois Revolplatform_init_video(void)
10520cbef82SFrançois Revol{
106e40cea64SAlexander von Gluck IV
107e40cea64SAlexander von Gluck IV#warning TODO: Fix u-boot arm framebuffer location from fdt!
1089642f770SAlexander von Gluck IV#if defined(__arm__)
1098eeafbceSAlexander von Gluck IV	#if defined(BOARD_CPU_ARM920T)
11003e2e071SIthamar R. Adema		extern ArchFramebuffer *arch_get_fb_arm_920(addr_t base);
1118eeafbceSAlexander von Gluck IV		gFramebuffer = arch_get_fb_arm_920(0x88000000);
112f8e19d47SAlexander von Gluck IV	#elif defined(BOARD_CPU_BCM2835) || defined(BOARD_CPU_BCM2836)
113f8e19d47SAlexander von Gluck IV		extern ArchFramebuffer *arch_get_fb_arm_bcm2835(addr_t base);
114f8e19d47SAlexander von Gluck IV		// BCM2835/BCM2836 gets their framebuffer base from a Mailbox
115523c77e0SAlexander von Gluck IV		gFramebuffer = arch_get_fb_arm_bcm2835(0x0);
1168eeafbceSAlexander von Gluck IV	#elif defined(BOARD_CPU_OMAP3)
11703e2e071SIthamar R. Adema		extern ArchFramebuffer *arch_get_fb_arm_omap3(addr_t base);
1189c71c671SIthamar R. Adema		gFramebuffer = arch_get_fb_arm_omap3(FB_BASE);
1198eeafbceSAlexander von Gluck IV	#elif defined(BOARD_CPU_PXA270)
12003e2e071SIthamar R. Adema		ArchFramebuffer *arch_get_fb_arm_pxa270(addr_t base);
12103e2e071SIthamar R. Adema		gFramebuffer = arch_get_fb_arm_pxa270(0xA3000000);
1228eeafbceSAlexander von Gluck IV	#endif
123386671b4SFrançois Revol#endif
1248eeafbceSAlexander von Gluck IV
12591c87884SAlexander von Gluck IV	if (gFramebuffer == NULL) {
12691c87884SAlexander von Gluck IV		ERROR("No framebuffer device found!\n");
12791c87884SAlexander von Gluck IV		return B_ERROR;
1288eeafbceSAlexander von Gluck IV	}
1298eeafbceSAlexander von Gluck IV
13091c87884SAlexander von Gluck IV	status_t result = gFramebuffer->Probe();
13191c87884SAlexander von Gluck IV	if (result != B_OK)
13291c87884SAlexander von Gluck IV		return result;
13391c87884SAlexander von Gluck IV
13491c87884SAlexander von Gluck IV	gFramebuffer->Init();
13591c87884SAlexander von Gluck IV	if (result != B_OK)
13691c87884SAlexander von Gluck IV		return result;
13791c87884SAlexander von Gluck IV
1388eeafbceSAlexander von Gluck IV	return B_OK;
1398eeafbceSAlexander von Gluck IV}