xref: /haiku/src/system/boot/platform/amiga_m68k/video.cpp (revision b14f16077c3bc7938bc8278950915051965c1327)
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[64];
108 		sprintf(label, "%ux%u %u bit",
109 			dimension.Nominal.MaxX - dimension.Nominal.MinX + 1,
110 			dimension.Nominal.MaxY - dimension.Nominal.MinY + 1,
111 			dimension.MaxDepth);
112 
113 		menu->AddItem(item = new(nothrow) MenuItem(label));
114 		item->SetData((void *)modeID);
115 	}
116 
117 #endif
118 	dprintf("done\n");
119 
120 	menu->AddSeparatorItem();
121 	menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
122 	item->SetType(MENU_ITEM_NO_CHOICE);
123 
124 	return menu;
125 }
126 
127 
128 //	#pragma mark -
129 
130 
131 extern "C" void
132 platform_switch_to_logo(void)
133 {
134 	// TODO: implement me
135 }
136 
137 
138 extern "C" void
139 platform_switch_to_text_mode(void)
140 {
141 	// TODO: implement me
142 }
143 
144 
145 extern "C" status_t
146 platform_init_video(void)
147 {
148 	// TODO: implement me
149 	return B_OK;
150 }
151 
152