lijuang | 45882c3 | 2019-06-18 13:46:55 +0800 | [diff] [blame] | 1 | /* Copyright (c) 2016, 2017, 2019, The Linux Foundation. All rights reserved. |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
| 4 | * modification, are permitted provided that the following conditions are |
| 5 | * met: |
| 6 | * * Redistributions of source code must retain the above copyright |
| 7 | * notice, this list of conditions and the following disclaimer. |
| 8 | * * Redistributions in binary form must reproduce the above |
| 9 | * copyright notice, this list of conditions and the following |
| 10 | * disclaimer in the documentation and/or other materials provided |
| 11 | * with the distribution. |
| 12 | * * Neither the name of The Linux Foundation nor the names of its |
| 13 | * contributors may be used to endorse or promote products derived |
| 14 | * from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 29 | #ifndef _DRAWUI_H_ |
| 30 | #define _DRAWUI_H_ |
| 31 | |
| 32 | #include <Uefi.h> |
| 33 | |
lijuang | 64679b7 | 2017-09-26 15:52:10 +0800 | [diff] [blame] | 34 | /* 45 characters per line for portrait orientation |
| 35 | * "720 (W) 1280(H)" : "sysfont2x" -- 720 /(8*2) = 45 |
| 36 | * "1080(W) 1920(H)" : "sysfont3x" -- 1080/(8*3) = 45 |
| 37 | * "1440(W) 2560(H)" : "sysfont4x" -- 1440/(8*4) = 45 |
| 38 | * "2160(W) 3840(H)" : "sysfont6x" -- 2160/(8*6) = 45 |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 39 | */ |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 40 | #define CHAR_NUM_PERROW_POR 45 |
lijuang | 64679b7 | 2017-09-26 15:52:10 +0800 | [diff] [blame] | 41 | |
| 42 | /* 80 characters per line for horizontal orientation |
lijuang | dac345c | 2017-10-19 14:25:09 +0800 | [diff] [blame] | 43 | * "480 (H) 640 (W)" : "" -- 640 / (8 * 1) = 80 |
lijuang | 64679b7 | 2017-09-26 15:52:10 +0800 | [diff] [blame] | 44 | * "720 (H) 1280(W)" : "sysfont2x" -- 1280/(8*2) = 80 |
| 45 | * "1080(H) 1920(W)" : "sysfont3x" -- 1920/(8*3) = 80 |
| 46 | * "1440(H) 2560(W)" : "sysfont4x" -- 2560/(8*4) = 80 |
| 47 | * "2160(H) 3840(W)" : "sysfont6x" -- 3840/(8*6) = 80 |
| 48 | */ |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 49 | #define CHAR_NUM_PERROW_HOR 80 |
lijuang | 64679b7 | 2017-09-26 15:52:10 +0800 | [diff] [blame] | 50 | |
lijuang | 45882c3 | 2019-06-18 13:46:55 +0800 | [diff] [blame] | 51 | /* Max row for portrait orientation |
| 52 | * "720 (W) 1280(H)" : "sysfont2x" -- 1280/(19*2) = 33 |
| 53 | * "1080(W) 1920(H)" : "sysfont3x" -- 1920/(19*3) = 33 |
| 54 | * "1440(W) 2560(H)" : "sysfont4x" -- 2560/(19*4) = 33 |
| 55 | * "2160(W) 3840(H)" : "sysfont6x" -- 3840/(19*6) = 33 |
| 56 | */ |
| 57 | #define MAX_ROW_FOR_POR 33 |
| 58 | |
| 59 | /* Max row for horizontal orientation |
| 60 | * "480 (H) 640 (W)" : "" -- 480/(19*1) = 25 |
| 61 | * "720 (H) 1280(W)" : "" -- 720/(19*1) = 37 |
| 62 | * "1080(H) 1920(W)" : "sysfont2" -- 1080/(19*2) = 28 |
| 63 | * "1440(H) 2560(W)" : "sysfont3" -- 1440/(19*3) = 25 |
| 64 | * "2160(H) 3840(W)" : "sysfont4" -- 2160/(19*4) = 28 |
| 65 | */ |
| 66 | #define MAX_ROW_FOR_HOR 25 |
| 67 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 68 | #define MAX_MSG_SIZE 256 |
| 69 | #define MAX_RSP_SIZE 64 |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 70 | |
| 71 | typedef enum { |
lijuang | 45882c3 | 2019-06-18 13:46:55 +0800 | [diff] [blame] | 72 | PORTRAIT_MODE = 0, |
| 73 | HORIZONTAL_MODE |
| 74 | } DISPLAY_MODE; |
| 75 | |
| 76 | typedef enum { |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 77 | DISPLAY_MENU_YELLOW = 0, |
| 78 | DISPLAY_MENU_ORANGE, |
| 79 | DISPLAY_MENU_RED, |
| 80 | DISPLAY_MENU_EIO, |
| 81 | DISPLAY_MENU_MORE_OPTION, |
| 82 | DISPLAY_MENU_UNLOCK, |
| 83 | DISPLAY_MENU_FASTBOOT, |
| 84 | DISPLAY_MENU_UNLOCK_CRITICAL, |
| 85 | DISPLAY_MENU_LOCK, |
| 86 | DISPLAY_MENU_LOCK_CRITICAL |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 87 | } DISPLAY_MENU_TYPE; |
| 88 | |
| 89 | typedef enum { |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 90 | BGR_WHITE, |
| 91 | BGR_BLACK, |
| 92 | BGR_ORANGE, |
| 93 | BGR_YELLOW, |
| 94 | BGR_RED, |
| 95 | BGR_GREEN, |
| 96 | BGR_BLUE, |
| 97 | BGR_CYAN, |
| 98 | BGR_SILVER, |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 99 | } COLOR_TYPE; |
| 100 | |
| 101 | typedef enum { |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 102 | COMMON_FACTOR = 1, |
| 103 | BIG_FACTOR, |
| 104 | MAX_FACTORTYPE = 2, |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 105 | } SCALE_FACTOR_TYPE; |
| 106 | |
| 107 | typedef enum { |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 108 | POWEROFF = 0, |
| 109 | RESTART, |
| 110 | RECOVER, |
| 111 | FASTBOOT, |
| 112 | BACK, |
| 113 | CONTINUE, |
| 114 | FFBM, |
| 115 | QMMI, |
| 116 | NOACTION, |
| 117 | OPTION_ACTION_MAX, |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 118 | } OPTION_ITEM_ACTION; |
| 119 | |
| 120 | typedef enum { |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 121 | COMMON = 0, |
| 122 | ALIGN_RIGHT, |
| 123 | ALIGN_LEFT, |
| 124 | OPTION_ITEM, |
| 125 | LINEATION, |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 126 | } MENU_STRING_TYPE; |
| 127 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 128 | typedef struct { |
| 129 | CHAR8 Msg[MAX_MSG_SIZE]; |
| 130 | UINT32 ScaleFactorType; |
| 131 | UINT32 FgColor; |
| 132 | UINT32 BgColor; |
| 133 | UINT32 Attribute; |
| 134 | UINT32 Location; |
| 135 | UINT32 Action; |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 136 | } MENU_MSG_INFO; |
| 137 | |
| 138 | typedef struct { |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 139 | MENU_MSG_INFO *MsgInfo; |
| 140 | UINT32 OptionItems[OPTION_ACTION_MAX]; |
| 141 | UINT32 OptionNum; |
| 142 | UINT32 OptionIndex; |
| 143 | UINT32 MenuType; |
| 144 | UINT32 TimeoutTime; |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 145 | } MENU_OPTION_ITEM_INFO; |
| 146 | |
| 147 | typedef struct { |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 148 | MENU_OPTION_ITEM_INFO Info; |
| 149 | UINT32 LastMenuType; |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 150 | } OPTION_MENU_INFO; |
| 151 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 152 | VOID |
| 153 | SetMenuMsgInfo (MENU_MSG_INFO *MenuMsgInfo, |
| 154 | CHAR8 *Msg, |
| 155 | UINT32 ScaleFactorType, |
| 156 | UINT32 FgColor, |
| 157 | UINT32 BgColor, |
| 158 | UINT32 Attribute, |
| 159 | UINT32 Location, |
| 160 | UINT32 Action); |
| 161 | EFI_STATUS |
| 162 | DrawMenu (MENU_MSG_INFO *TargetMenu, UINT32 *Height); |
| 163 | EFI_STATUS |
| 164 | UpdateMsgBackground (MENU_MSG_INFO *MenuMsgInfo, UINT32 NewBgColor); |
| 165 | EFI_STATUS BackUpBootLogoBltBuffer (VOID); |
lijuang | a4a9a65 | 2017-09-29 09:34:16 +0800 | [diff] [blame] | 166 | VOID RestoreBootLogoBitBuffer (VOID); |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 167 | VOID FreeBootLogoBltBuffer (VOID); |
| 168 | VOID DrawMenuInit (VOID); |
lijuang | c9d156e | 2016-07-27 18:31:00 +0800 | [diff] [blame] | 169 | #endif |