xref: /haiku/src/system/boot/platform/amiga_m68k/video.cpp (revision a7dde370f552f5376edbf25046ec9cf2ba8bbd1a)
1 /*
2  * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "rom_calls.h"
8 #include "video.h"
9 //#include "mmu.h"
10 //#include "images.h"
11 
12 #include <arch/cpu.h>
13 #include <boot/stage2.h>
14 #include <boot/platform.h>
15 #include <boot/menu.h>
16 #include <boot/kernel_args.h>
17 #include <util/list.h>
18 #include <drivers/driver_settings.h>
19 #include <GraphicsDefs.h>
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 
25 
26 //#define TRACE_VIDEO
27 #ifdef TRACE_VIDEO
28 #	define TRACE(x) dprintf x
29 #else
30 #	define TRACE(x) ;
31 #endif
32 
33 
34 
35 
36 
37 //	#pragma mark -
38 
39 
40 bool
41 video_mode_hook(Menu *menu, MenuItem *item)
42 {
43 	// nothing yet
44 	return true;
45 }
46 
47 
48 Menu *
49 video_mode_menu()
50 {
51 	Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Video Mode");
52 	MenuItem *item;
53 
54 	menu->AddItem(item = new(nothrow) MenuItem("Default"));
55 	item->SetMarked(true);
56 	item->Select(true);
57 	item->SetHelpText("The Default video mode is the one currently configured "
58 		"in the system. If there is no mode configured yet, a viable mode will "
59 		"be chosen automatically.");
60 
61 /*
62 	video_mode *mode = NULL;
63 	while ((mode = (video_mode *)list_get_next_item(&sModeList, mode)) != NULL) {
64 		char label[64];
65 		sprintf(label, "%ux%u %u bit", mode->width, mode->height,
66 			mode->bits_per_pixel);
67 
68 		menu->AddItem(item = new(nothrow) MenuItem(label));
69 		item->SetData(mode);
70 	}
71 */
72 #if 1
73 	uint32 modeID = INVALID_ID;
74 	while ((modeID = NextDisplayInfo(modeID)) != INVALID_ID) {
75 		//DisplayInfoHandle handle = FindDisplayInfo(modeID);
76 		//if (handle == NULL)
77 		//	continue;
78 		struct DisplayInfo info;
79 		struct DimensionInfo dimension;
80 		struct NameInfo name;
81 		if (GetDisplayInfoData(NULL, (uint8 *)&info, sizeof(info),
82 			DTAG_DISP, modeID) < 48/*sizeof(struct DisplayInfo)*/)
83 			continue;
84 		if (GetDisplayInfoData(NULL, (uint8 *)&dimension, sizeof(dimension),
85 			DTAG_DIMS, modeID) < 66)
86 			continue;
87 		/*if (GetDisplayInfoData(NULL, (uint8 *)&name, sizeof(name),
88 			DTAG_NAME, modeID) < sizeof(name) - 8)
89 			continue;*/
90 		if (info.NotAvailable)
91 			continue;
92 		if (dimension.MaxDepth < 4)
93 			continue;
94 		//dprintf("name: %s\n", name.Name);
95 		/*
96 		dprintf("mode 0x%08lx: %dx%d flags: 0x%08lx bpp: %d\n",
97 			modeID, info.Resolution.x, info.Resolution.y, info.PropertyFlags,
98 			info.RedBits + info.GreenBits + info.BlueBits);
99 		dprintf("mode: %dx%d -> %dx%d\n",
100 			dimension.MinRasterWidth, dimension.MinRasterHeight,
101 			dimension.MaxRasterWidth, dimension.MaxRasterHeight);
102 		dprintf("mode: %dx%d %dbpp flags: 0x%08lx\n",
103 			dimension.Nominal.MaxX - dimension.Nominal.MinX + 1,
104 			dimension.Nominal.MaxY - dimension.Nominal.MinY + 1,
105 			dimension.MaxDepth, info.PropertyFlags);
106 		*/
107 		char label[128];
108 		sprintf(label, "%ux%u %u bit %08lx%s%s",
109 			dimension.Nominal.MaxX - dimension.Nominal.MinX + 1,
110 			dimension.Nominal.MaxY - dimension.Nominal.MinY + 1,
111 			dimension.MaxDepth, info.PropertyFlags,
112 			(info.PropertyFlags & DIPF_IS_LACE) ? "" : " i",
113 			(info.PropertyFlags & DIPF_IS_PAL) ? "" : " pal");
114 
115 		menu->AddItem(item = new(nothrow) MenuItem(label));
116 		item->SetData((void *)modeID);
117 	}
118 
119 #endif
120 	dprintf("done\n");
121 
122 	menu->AddSeparatorItem();
123 	menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
124 	item->SetType(MENU_ITEM_NO_CHOICE);
125 
126 	return menu;
127 }
128 
129 
130 //	#pragma mark -
131 
132 
133 extern "C" void
134 platform_switch_to_logo(void)
135 {
136 	// TODO: implement me
137 }
138 
139 
140 extern "C" void
141 platform_switch_to_text_mode(void)
142 {
143 	// TODO: implement me
144 }
145 
146 
147 extern "C" status_t
148 platform_init_video(void)
149 {
150 	// TODO: implement me
151 	return B_OK;
152 }
153 
154