hdt: fix conflict
[profile/ivi/syslinux.git] / com32 / hdt / hdt-menu-vesa.c
1 /* ----------------------------------------------------------------------- *
2  *
3  *   Copyright 2009 Erwan Velu - All Rights Reserved
4  *
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:
13  *
14  *   The above copyright notice and this permission notice shall
15  *   be included in all copies or substantial portions of the Software.
16  *
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.
25  *
26  * -----------------------------------------------------------------------
27 */
28
29 #include "hdt-menu.h"
30
31
32 /* Submenu for the vesa card */
33 static void compute_vesa_card(struct s_my_menu *menu, struct s_hardware *hardware) {
34   char buffer[SUBMENULEN+1];
35   char statbuffer[STATLEN+1];
36
37    menu->menu = add_menu(" VESA Bios ",-1);
38    menu->items_count=0;
39    set_menu_pos(SUBMENU_Y,SUBMENU_X);
40
41    snprintf(buffer,sizeof buffer,"VESA Version: %d.%d",hardware->vesa.major_version,hardware->vesa.minor_version);
42    snprintf(statbuffer,sizeof statbuffer,"Version: %d.%d",hardware->vesa.major_version,hardware->vesa.minor_version);
43    add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
44    menu->items_count++;
45
46    snprintf(buffer,sizeof buffer,"Vendor      : %s",hardware->vesa.vendor);
47    snprintf(statbuffer,sizeof statbuffer,"Vendor Name: %s",hardware->vesa.vendor);
48    add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
49    menu->items_count++;
50
51    snprintf(buffer,sizeof buffer,"Product     : %s",hardware->vesa.product);
52    snprintf(statbuffer,sizeof statbuffer,"Product Name: %s",hardware->vesa.product);
53    add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
54    menu->items_count++;
55
56    snprintf(buffer,sizeof buffer,"Product Rev.: %s",hardware->vesa.product_revision);
57    snprintf(statbuffer,sizeof statbuffer,"Produt Revision: %s",hardware->vesa.product_revision);
58    add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
59    menu->items_count++;
60
61    snprintf(buffer,sizeof buffer,"Software Rev: %d",hardware->vesa.software_rev);
62    snprintf(statbuffer,sizeof statbuffer,"Software Revision: %d",hardware->vesa.software_rev);
63    add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
64    menu->items_count++;
65
66    snprintf(buffer,sizeof buffer,"Memory (KB) : %d",hardware->vesa.total_memory*64);
67    snprintf(statbuffer,sizeof statbuffer,"Memory (KB): %d",hardware->vesa.total_memory*64);
68    add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
69    menu->items_count++;
70 }
71
72 /* Submenu for the vesa card */
73 void compute_vesa_modes(struct s_my_menu *menu, struct s_hardware *hardware) {
74   char buffer[56];
75   char statbuffer[STATLEN];
76
77    menu->menu = add_menu(" VESA Modes ",-1);
78    menu->items_count=0;
79    set_menu_pos(SUBMENU_Y,SUBMENU_X);
80    for (int i=0;i<hardware->vesa.vmi_count;i++) {
81     struct vesa_mode_info *mi=&hardware->vesa.vmi[i].mi;
82     /* Sometimes, vesa bios reports 0x0 modes
83      * We don't need to display that ones */
84     if ((mi->h_res==0) || (mi->v_res==0)) continue;
85     snprintf(buffer,sizeof buffer,"%4u x %4u x %2ubits vga=%3d",
86                  mi->h_res, mi->v_res, mi->bpp, hardware->vesa.vmi[i].mode+0x200);
87     snprintf(statbuffer,sizeof statbuffer,"%4ux%4ux%2ubits vga=%3d",
88                  mi->h_res, mi->v_res, mi->bpp, hardware->vesa.vmi[i].mode+0x200);
89     add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
90     menu->items_count++;
91    }
92 }
93
94 /* Main VESA Menu*/
95 int compute_VESA(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware) {
96  char buffer[15];
97  compute_vesa_card(&hdt_menu->vesa_card_menu,hardware);
98  compute_vesa_modes(&hdt_menu->vesa_modes_menu,hardware);
99  hdt_menu->vesa_menu.menu = add_menu(" VESA ",-1);
100  hdt_menu->vesa_menu.items_count=0;
101
102  add_item("VESA Bios","VESA Bios",OPT_SUBMENU,NULL,hdt_menu->vesa_card_menu.menu);
103  hdt_menu->vesa_menu.items_count++;
104  snprintf(buffer,sizeof buffer,"%s (%d)","Modes",hardware->vesa.vmi_count);
105  add_item(buffer,"VESA Modes",OPT_SUBMENU,NULL,hdt_menu->vesa_modes_menu.menu);
106  hdt_menu->vesa_menu.items_count++;
107  printf("MENU: VESA menu done (%d items)\n",hdt_menu->vesa_menu.items_count);
108  return 0;
109 }