xref: /haiku/src/system/boot/platform/amiga_m68k/video.cpp (revision ee0c130257f0d547763676f50a8b50c69b5abfce)
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 
35b14f1607SFrançois Revol 
36b14f1607SFranç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 {
51b14f1607SFrançois Revol 	Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Video Mode");
52b14f1607SFrançois Revol 	MenuItem *item;
53b14f1607SFrançois Revol 
54b14f1607SFrançois Revol 	menu->AddItem(item = new(nothrow) MenuItem("Default"));
55b14f1607SFrançois Revol 	item->SetMarked(true);
56b14f1607SFrançois Revol 	item->Select(true);
57b14f1607SFrançois Revol 	item->SetHelpText("The Default video mode is the one currently configured "
58b14f1607SFrançois Revol 		"in the system. If there is no mode configured yet, a viable mode will "
59b14f1607SFrançois Revol 		"be chosen automatically.");
60b14f1607SFrançois Revol 
61b14f1607SFrançois Revol /*
62b14f1607SFrançois Revol 	video_mode *mode = NULL;
63b14f1607SFrançois Revol 	while ((mode = (video_mode *)list_get_next_item(&sModeList, mode)) != NULL) {
64b14f1607SFrançois Revol 		char label[64];
65b14f1607SFrançois Revol 		sprintf(label, "%ux%u %u bit", mode->width, mode->height,
66b14f1607SFrançois Revol 			mode->bits_per_pixel);
67b14f1607SFrançois Revol 
68b14f1607SFrançois Revol 		menu->AddItem(item = new(nothrow) MenuItem(label));
69b14f1607SFrançois Revol 		item->SetData(mode);
70b14f1607SFrançois Revol 	}
71b14f1607SFrançois Revol */
72b14f1607SFrançois Revol #if 1
73b14f1607SFrançois Revol 	uint32 modeID = INVALID_ID;
74b14f1607SFrançois Revol 	while ((modeID = NextDisplayInfo(modeID)) != INVALID_ID) {
75b14f1607SFrançois Revol 		//DisplayInfoHandle handle = FindDisplayInfo(modeID);
76b14f1607SFrançois Revol 		//if (handle == NULL)
77b14f1607SFrançois Revol 		//	continue;
78b14f1607SFrançois Revol 		struct DisplayInfo info;
79b14f1607SFrançois Revol 		struct DimensionInfo dimension;
80b14f1607SFrançois Revol 		struct NameInfo name;
81b14f1607SFrançois Revol 		if (GetDisplayInfoData(NULL, (uint8 *)&info, sizeof(info),
82b14f1607SFrançois Revol 			DTAG_DISP, modeID) < 48/*sizeof(struct DisplayInfo)*/)
83b14f1607SFrançois Revol 			continue;
84b14f1607SFrançois Revol 		if (GetDisplayInfoData(NULL, (uint8 *)&dimension, sizeof(dimension),
85b14f1607SFrançois Revol 			DTAG_DIMS, modeID) < 66)
86b14f1607SFrançois Revol 			continue;
87b14f1607SFrançois Revol 		/*if (GetDisplayInfoData(NULL, (uint8 *)&name, sizeof(name),
88b14f1607SFrançois Revol 			DTAG_NAME, modeID) < sizeof(name) - 8)
89b14f1607SFrançois Revol 			continue;*/
90b14f1607SFrançois Revol 		if (info.NotAvailable)
91b14f1607SFrançois Revol 			continue;
92b14f1607SFrançois Revol 		if (dimension.MaxDepth < 4)
93b14f1607SFrançois Revol 			continue;
94b14f1607SFrançois Revol 		//dprintf("name: %s\n", name.Name);
95b14f1607SFrançois Revol 		/*
96b14f1607SFrançois Revol 		dprintf("mode 0x%08lx: %dx%d flags: 0x%08lx bpp: %d\n",
97b14f1607SFrançois Revol 			modeID, info.Resolution.x, info.Resolution.y, info.PropertyFlags,
98b14f1607SFrançois Revol 			info.RedBits + info.GreenBits + info.BlueBits);
99b14f1607SFrançois Revol 		dprintf("mode: %dx%d -> %dx%d\n",
100b14f1607SFrançois Revol 			dimension.MinRasterWidth, dimension.MinRasterHeight,
101b14f1607SFrançois Revol 			dimension.MaxRasterWidth, dimension.MaxRasterHeight);
102b14f1607SFrançois Revol 		dprintf("mode: %dx%d %dbpp flags: 0x%08lx\n",
103b14f1607SFrançois Revol 			dimension.Nominal.MaxX - dimension.Nominal.MinX + 1,
104b14f1607SFrançois Revol 			dimension.Nominal.MaxY - dimension.Nominal.MinY + 1,
105b14f1607SFrançois Revol 			dimension.MaxDepth, info.PropertyFlags);
106b14f1607SFrançois Revol 		*/
107*ee0c1302SFrançois Revol 		char label[128];
108*ee0c1302SFrançois Revol 		sprintf(label, "%ux%u %u bit %08lx%s%s",
109b14f1607SFrançois Revol 			dimension.Nominal.MaxX - dimension.Nominal.MinX + 1,
110b14f1607SFrançois Revol 			dimension.Nominal.MaxY - dimension.Nominal.MinY + 1,
111*ee0c1302SFrançois Revol 			dimension.MaxDepth, info.PropertyFlags,
112*ee0c1302SFrançois Revol 			(info.PropertyFlags & DIPF_IS_LACE) ? "" : " i",
113*ee0c1302SFrançois Revol 			(info.PropertyFlags & DIPF_IS_PAL) ? "" : " pal");
114b14f1607SFrançois Revol 
115b14f1607SFrançois Revol 		menu->AddItem(item = new(nothrow) MenuItem(label));
116b14f1607SFrançois Revol 		item->SetData((void *)modeID);
117b14f1607SFrançois Revol 	}
118b14f1607SFrançois Revol 
119b14f1607SFrançois Revol #endif
120b14f1607SFrançois Revol 	dprintf("done\n");
121b14f1607SFrançois Revol 
122b14f1607SFrançois Revol 	menu->AddSeparatorItem();
123b14f1607SFrançois Revol 	menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
124b14f1607SFrançois Revol 	item->SetType(MENU_ITEM_NO_CHOICE);
125b14f1607SFrançois Revol 
126b14f1607SFrançois Revol 	return menu;
1274ae92968SFrançois Revol }
1284ae92968SFrançois Revol 
1294ae92968SFrançois Revol 
1304ae92968SFrançois Revol //	#pragma mark -
1314ae92968SFrançois Revol 
1324ae92968SFrançois Revol 
1334ae92968SFrançois Revol extern "C" void
1344ae92968SFrançois Revol platform_switch_to_logo(void)
1354ae92968SFrançois Revol {
1364ae92968SFrançois Revol 	// TODO: implement me
1374ae92968SFrançois Revol }
1384ae92968SFrançois Revol 
1394ae92968SFrançois Revol 
1404ae92968SFrançois Revol extern "C" void
1414ae92968SFrançois Revol platform_switch_to_text_mode(void)
1424ae92968SFrançois Revol {
1434ae92968SFrançois Revol 	// TODO: implement me
1444ae92968SFrançois Revol }
1454ae92968SFrançois Revol 
1464ae92968SFrançois Revol 
1474ae92968SFrançois Revol extern "C" status_t
1484ae92968SFrançois Revol platform_init_video(void)
1494ae92968SFrançois Revol {
1504ae92968SFrançois Revol 	// TODO: implement me
1514ae92968SFrançois Revol 	return B_OK;
1524ae92968SFrançois Revol }
1534ae92968SFrançois Revol 
154