xref: /haiku/src/system/boot/platform/amiga_m68k/video.cpp (revision b14f16077c3bc7938bc8278950915051965c1327)
14ae92968SFrançois Revol /*
24ae92968SFrançois Revol  * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de.
34ae92968SFrançois Revol  * Distributed under the terms of the MIT License.
44ae92968SFrançois Revol  */
54ae92968SFrançois Revol 
64ae92968SFrançois Revol 
77ddba3d2SFrançois Revol #include "rom_calls.h"
84ae92968SFrançois Revol #include "video.h"
94ae92968SFrançois Revol //#include "mmu.h"
104ae92968SFrançois Revol //#include "images.h"
114ae92968SFrançois Revol 
124ae92968SFrançois Revol #include <arch/cpu.h>
134ae92968SFrançois Revol #include <boot/stage2.h>
144ae92968SFrançois Revol #include <boot/platform.h>
154ae92968SFrançois Revol #include <boot/menu.h>
164ae92968SFrançois Revol #include <boot/kernel_args.h>
174ae92968SFrançois Revol #include <util/list.h>
184ae92968SFrançois Revol #include <drivers/driver_settings.h>
194ae92968SFrançois Revol #include <GraphicsDefs.h>
204ae92968SFrançois Revol 
214ae92968SFrançois Revol #include <stdio.h>
224ae92968SFrançois Revol #include <stdlib.h>
234ae92968SFrançois Revol #include <string.h>
244ae92968SFrançois Revol 
254ae92968SFrançois Revol 
264ae92968SFrançois Revol //#define TRACE_VIDEO
274ae92968SFrançois Revol #ifdef TRACE_VIDEO
284ae92968SFrançois Revol #	define TRACE(x) dprintf x
294ae92968SFrançois Revol #else
304ae92968SFrançois Revol #	define TRACE(x) ;
314ae92968SFrançois Revol #endif
324ae92968SFrançois Revol 
334ae92968SFrançois Revol 
344ae92968SFrançois Revol 
35*b14f1607SFrançois Revol 
36*b14f1607SFrançois Revol 
374ae92968SFrançois Revol //	#pragma mark -
384ae92968SFrançois Revol 
394ae92968SFrançois Revol 
404ae92968SFrançois Revol bool
414ae92968SFrançois Revol video_mode_hook(Menu *menu, MenuItem *item)
424ae92968SFrançois Revol {
434ae92968SFrançois Revol 	// nothing yet
444ae92968SFrançois Revol 	return true;
454ae92968SFrançois Revol }
464ae92968SFrançois Revol 
474ae92968SFrançois Revol 
484ae92968SFrançois Revol Menu *
494ae92968SFrançois Revol video_mode_menu()
504ae92968SFrançois Revol {
51*b14f1607SFrançois Revol 	Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Video Mode");
52*b14f1607SFrançois Revol 	MenuItem *item;
53*b14f1607SFrançois Revol 
54*b14f1607SFrançois Revol 	menu->AddItem(item = new(nothrow) MenuItem("Default"));
55*b14f1607SFrançois Revol 	item->SetMarked(true);
56*b14f1607SFrançois Revol 	item->Select(true);
57*b14f1607SFrançois Revol 	item->SetHelpText("The Default video mode is the one currently configured "
58*b14f1607SFrançois Revol 		"in the system. If there is no mode configured yet, a viable mode will "
59*b14f1607SFrançois Revol 		"be chosen automatically.");
60*b14f1607SFrançois Revol 
61*b14f1607SFrançois Revol /*
62*b14f1607SFrançois Revol 	video_mode *mode = NULL;
63*b14f1607SFrançois Revol 	while ((mode = (video_mode *)list_get_next_item(&sModeList, mode)) != NULL) {
64*b14f1607SFrançois Revol 		char label[64];
65*b14f1607SFrançois Revol 		sprintf(label, "%ux%u %u bit", mode->width, mode->height,
66*b14f1607SFrançois Revol 			mode->bits_per_pixel);
67*b14f1607SFrançois Revol 
68*b14f1607SFrançois Revol 		menu->AddItem(item = new(nothrow) MenuItem(label));
69*b14f1607SFrançois Revol 		item->SetData(mode);
70*b14f1607SFrançois Revol 	}
71*b14f1607SFrançois Revol */
72*b14f1607SFrançois Revol #if 1
73*b14f1607SFrançois Revol 	uint32 modeID = INVALID_ID;
74*b14f1607SFrançois Revol 	while ((modeID = NextDisplayInfo(modeID)) != INVALID_ID) {
75*b14f1607SFrançois Revol 		//DisplayInfoHandle handle = FindDisplayInfo(modeID);
76*b14f1607SFrançois Revol 		//if (handle == NULL)
77*b14f1607SFrançois Revol 		//	continue;
78*b14f1607SFrançois Revol 		struct DisplayInfo info;
79*b14f1607SFrançois Revol 		struct DimensionInfo dimension;
80*b14f1607SFrançois Revol 		struct NameInfo name;
81*b14f1607SFrançois Revol 		if (GetDisplayInfoData(NULL, (uint8 *)&info, sizeof(info),
82*b14f1607SFrançois Revol 			DTAG_DISP, modeID) < 48/*sizeof(struct DisplayInfo)*/)
83*b14f1607SFrançois Revol 			continue;
84*b14f1607SFrançois Revol 		if (GetDisplayInfoData(NULL, (uint8 *)&dimension, sizeof(dimension),
85*b14f1607SFrançois Revol 			DTAG_DIMS, modeID) < 66)
86*b14f1607SFrançois Revol 			continue;
87*b14f1607SFrançois Revol 		/*if (GetDisplayInfoData(NULL, (uint8 *)&name, sizeof(name),
88*b14f1607SFrançois Revol 			DTAG_NAME, modeID) < sizeof(name) - 8)
89*b14f1607SFrançois Revol 			continue;*/
90*b14f1607SFrançois Revol 		if (info.NotAvailable)
91*b14f1607SFrançois Revol 			continue;
92*b14f1607SFrançois Revol 		if (dimension.MaxDepth < 4)
93*b14f1607SFrançois Revol 			continue;
94*b14f1607SFrançois Revol 		//dprintf("name: %s\n", name.Name);
95*b14f1607SFrançois Revol 		/*
96*b14f1607SFrançois Revol 		dprintf("mode 0x%08lx: %dx%d flags: 0x%08lx bpp: %d\n",
97*b14f1607SFrançois Revol 			modeID, info.Resolution.x, info.Resolution.y, info.PropertyFlags,
98*b14f1607SFrançois Revol 			info.RedBits + info.GreenBits + info.BlueBits);
99*b14f1607SFrançois Revol 		dprintf("mode: %dx%d -> %dx%d\n",
100*b14f1607SFrançois Revol 			dimension.MinRasterWidth, dimension.MinRasterHeight,
101*b14f1607SFrançois Revol 			dimension.MaxRasterWidth, dimension.MaxRasterHeight);
102*b14f1607SFrançois Revol 		dprintf("mode: %dx%d %dbpp flags: 0x%08lx\n",
103*b14f1607SFrançois Revol 			dimension.Nominal.MaxX - dimension.Nominal.MinX + 1,
104*b14f1607SFrançois Revol 			dimension.Nominal.MaxY - dimension.Nominal.MinY + 1,
105*b14f1607SFrançois Revol 			dimension.MaxDepth, info.PropertyFlags);
106*b14f1607SFrançois Revol 		*/
107*b14f1607SFrançois Revol 		char label[64];
108*b14f1607SFrançois Revol 		sprintf(label, "%ux%u %u bit",
109*b14f1607SFrançois Revol 			dimension.Nominal.MaxX - dimension.Nominal.MinX + 1,
110*b14f1607SFrançois Revol 			dimension.Nominal.MaxY - dimension.Nominal.MinY + 1,
111*b14f1607SFrançois Revol 			dimension.MaxDepth);
112*b14f1607SFrançois Revol 
113*b14f1607SFrançois Revol 		menu->AddItem(item = new(nothrow) MenuItem(label));
114*b14f1607SFrançois Revol 		item->SetData((void *)modeID);
115*b14f1607SFrançois Revol 	}
116*b14f1607SFrançois Revol 
117*b14f1607SFrançois Revol #endif
118*b14f1607SFrançois Revol 	dprintf("done\n");
119*b14f1607SFrançois Revol 
120*b14f1607SFrançois Revol 	menu->AddSeparatorItem();
121*b14f1607SFrançois Revol 	menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
122*b14f1607SFrançois Revol 	item->SetType(MENU_ITEM_NO_CHOICE);
123*b14f1607SFrançois Revol 
124*b14f1607SFrançois Revol 	return menu;
1254ae92968SFrançois Revol }
1264ae92968SFrançois Revol 
1274ae92968SFrançois Revol 
1284ae92968SFrançois Revol //	#pragma mark -
1294ae92968SFrançois Revol 
1304ae92968SFrançois Revol 
1314ae92968SFrançois Revol extern "C" void
1324ae92968SFrançois Revol platform_switch_to_logo(void)
1334ae92968SFrançois Revol {
1344ae92968SFrançois Revol 	// TODO: implement me
1354ae92968SFrançois Revol }
1364ae92968SFrançois Revol 
1374ae92968SFrançois Revol 
1384ae92968SFrançois Revol extern "C" void
1394ae92968SFrançois Revol platform_switch_to_text_mode(void)
1404ae92968SFrançois Revol {
1414ae92968SFrançois Revol 	// TODO: implement me
1424ae92968SFrançois Revol }
1434ae92968SFrançois Revol 
1444ae92968SFrançois Revol 
1454ae92968SFrançois Revol extern "C" status_t
1464ae92968SFrançois Revol platform_init_video(void)
1474ae92968SFrançois Revol {
1484ae92968SFrançois Revol 	// TODO: implement me
1494ae92968SFrançois Revol 	return B_OK;
1504ae92968SFrançois Revol }
1514ae92968SFrançois Revol 
152