Merge remote-tracking branch 'hpa/master'
[syslinux.git] / com32 / hdt / hdt-menu-vesa.c
blob0fe06ab9fbd91270b1abffa6bba885a75182b905
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2009 Erwan Velu - All Rights Reserved
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following
12 * conditions:
14 * The above copyright notice and this permission notice shall
15 * be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
26 * -----------------------------------------------------------------------
29 #include "hdt-menu.h"
31 /* Submenu for the vesa card */
32 static void compute_vesa_card(struct s_my_menu *menu,
33 struct s_hardware *hardware)
35 char buffer[SUBMENULEN + 1];
36 char statbuffer[STATLEN + 1];
38 menu->menu = add_menu(" VESA Bios ", -1);
39 menu->items_count = 0;
40 set_menu_pos(SUBMENU_Y, SUBMENU_X);
42 snprintf(buffer, sizeof buffer, "VESA Version: %d.%d",
43 hardware->vesa.major_version, hardware->vesa.minor_version);
44 snprintf(statbuffer, sizeof statbuffer, "Version: %d.%d",
45 hardware->vesa.major_version, hardware->vesa.minor_version);
46 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
47 menu->items_count++;
49 snprintf(buffer, sizeof buffer, "Vendor : %s", hardware->vesa.vendor);
50 snprintf(statbuffer, sizeof statbuffer, "Vendor Name: %s",
51 hardware->vesa.vendor);
52 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
53 menu->items_count++;
55 snprintf(buffer, sizeof buffer, "Product : %s", hardware->vesa.product);
56 snprintf(statbuffer, sizeof statbuffer, "Product Name: %s",
57 hardware->vesa.product);
58 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
59 menu->items_count++;
61 snprintf(buffer, sizeof buffer, "Product Rev.: %s",
62 hardware->vesa.product_revision);
63 snprintf(statbuffer, sizeof statbuffer, "Produt Revision: %s",
64 hardware->vesa.product_revision);
65 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
66 menu->items_count++;
68 snprintf(buffer, sizeof buffer, "Software Rev: %d",
69 hardware->vesa.software_rev);
70 snprintf(statbuffer, sizeof statbuffer, "Software Revision: %d",
71 hardware->vesa.software_rev);
72 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
73 menu->items_count++;
75 snprintf(buffer, sizeof buffer, "Memory (KB) : %d",
76 hardware->vesa.total_memory * 64);
77 snprintf(statbuffer, sizeof statbuffer, "Memory (KB): %d",
78 hardware->vesa.total_memory * 64);
79 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
80 menu->items_count++;
83 /* Submenu for the vesa card */
84 void compute_vesa_modes(struct s_my_menu *menu, struct s_hardware *hardware)
86 char buffer[56];
87 char statbuffer[STATLEN];
89 menu->menu = add_menu(" VESA Modes ", -1);
90 menu->items_count = 0;
91 set_menu_pos(SUBMENU_Y, SUBMENU_X);
92 for (int i = 0; i < hardware->vesa.vmi_count; i++) {
93 struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi;
94 /* Sometimes, vesa bios reports 0x0 modes
95 * We don't need to display that ones */
96 if ((mi->h_res == 0) || (mi->v_res == 0))
97 continue;
98 snprintf(buffer, sizeof buffer, "%4u x %4u x %2ubits vga=%3d",
99 mi->h_res, mi->v_res, mi->bpp,
100 hardware->vesa.vmi[i].mode + 0x200);
101 snprintf(statbuffer, sizeof statbuffer, "%4ux%4ux%2ubits vga=%3d",
102 mi->h_res, mi->v_res, mi->bpp,
103 hardware->vesa.vmi[i].mode + 0x200);
104 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
105 menu->items_count++;
109 /* Main VESA Menu*/
110 int compute_VESA(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
112 char buffer[15];
113 compute_vesa_card(&hdt_menu->vesa_card_menu, hardware);
114 compute_vesa_modes(&hdt_menu->vesa_modes_menu, hardware);
115 hdt_menu->vesa_menu.menu = add_menu(" VESA ", -1);
116 hdt_menu->vesa_menu.items_count = 0;
118 add_item("VESA Bios", "VESA Bios", OPT_SUBMENU, NULL,
119 hdt_menu->vesa_card_menu.menu);
120 hdt_menu->vesa_menu.items_count++;
121 snprintf(buffer, sizeof buffer, "%s (%d)", "Modes",
122 hardware->vesa.vmi_count);
123 add_item(buffer, "VESA Modes", OPT_SUBMENU, NULL,
124 hdt_menu->vesa_modes_menu.menu);
125 hdt_menu->vesa_menu.items_count++;
126 printf("MENU: VESA menu done (%d items)\n",
127 hdt_menu->vesa_menu.items_count);
128 return 0;