@@ -27,6 +27,8 @@ static struct {
27
27
u32 mode ;
28
28
struct {
29
29
u32 width , height ;
30
+ int format ;
31
+ u8 depth ;
30
32
} res ;
31
33
};
32
34
} cmdline __efistub_global = { .option = EFI_CMDLINE_NONE };
@@ -50,19 +52,35 @@ static bool parse_modenum(char *option, char **next)
50
52
51
53
static bool parse_res (char * option , char * * next )
52
54
{
53
- u32 w , h ;
55
+ u32 w , h , d = 0 ;
56
+ int pf = -1 ;
54
57
55
58
if (!isdigit (* option ))
56
59
return false;
57
60
w = simple_strtoull (option , & option , 10 );
58
61
if (* option ++ != 'x' || !isdigit (* option ))
59
62
return false;
60
63
h = simple_strtoull (option , & option , 10 );
64
+ if (* option == '-' ) {
65
+ option ++ ;
66
+ if (strstarts (option , "rgb" )) {
67
+ option += strlen ("rgb" );
68
+ pf = PIXEL_RGB_RESERVED_8BIT_PER_COLOR ;
69
+ } else if (strstarts (option , "bgr" )) {
70
+ option += strlen ("bgr" );
71
+ pf = PIXEL_BGR_RESERVED_8BIT_PER_COLOR ;
72
+ } else if (isdigit (* option ))
73
+ d = simple_strtoull (option , & option , 10 );
74
+ else
75
+ return false;
76
+ }
61
77
if (* option && * option ++ != ',' )
62
78
return false;
63
79
cmdline .option = EFI_CMDLINE_RES ;
64
80
cmdline .res .width = w ;
65
81
cmdline .res .height = h ;
82
+ cmdline .res .format = pf ;
83
+ cmdline .res .depth = d ;
66
84
67
85
* next = option ;
68
86
return true;
@@ -123,6 +141,18 @@ static u32 choose_mode_modenum(efi_graphics_output_protocol_t *gop)
123
141
return cmdline .mode ;
124
142
}
125
143
144
+ static u8 pixel_bpp (int pixel_format , efi_pixel_bitmask_t pixel_info )
145
+ {
146
+ if (pixel_format == PIXEL_BIT_MASK ) {
147
+ u32 mask = pixel_info .red_mask | pixel_info .green_mask |
148
+ pixel_info .blue_mask | pixel_info .reserved_mask ;
149
+ if (!mask )
150
+ return 0 ;
151
+ return __fls (mask ) - __ffs (mask ) + 1 ;
152
+ } else
153
+ return 32 ;
154
+ }
155
+
126
156
static u32 choose_mode_res (efi_graphics_output_protocol_t * gop )
127
157
{
128
158
efi_status_t status ;
@@ -133,16 +163,21 @@ static u32 choose_mode_res(efi_graphics_output_protocol_t *gop)
133
163
134
164
u32 max_mode , cur_mode ;
135
165
int pf ;
166
+ efi_pixel_bitmask_t pi ;
136
167
u32 m , w , h ;
137
168
138
169
mode = efi_table_attr (gop , mode );
139
170
140
171
cur_mode = efi_table_attr (mode , mode );
141
172
info = efi_table_attr (mode , info );
142
- w = info -> horizontal_resolution ;
143
- h = info -> vertical_resolution ;
173
+ pf = info -> pixel_format ;
174
+ pi = info -> pixel_information ;
175
+ w = info -> horizontal_resolution ;
176
+ h = info -> vertical_resolution ;
144
177
145
- if (w == cmdline .res .width && h == cmdline .res .height )
178
+ if (w == cmdline .res .width && h == cmdline .res .height &&
179
+ (cmdline .res .format < 0 || cmdline .res .format == pf ) &&
180
+ (!cmdline .res .depth || cmdline .res .depth == pixel_bpp (pf , pi )))
146
181
return cur_mode ;
147
182
148
183
max_mode = efi_table_attr (mode , max_mode );
@@ -157,14 +192,17 @@ static u32 choose_mode_res(efi_graphics_output_protocol_t *gop)
157
192
continue ;
158
193
159
194
pf = info -> pixel_format ;
195
+ pi = info -> pixel_information ;
160
196
w = info -> horizontal_resolution ;
161
197
h = info -> vertical_resolution ;
162
198
163
199
efi_bs_call (free_pool , info );
164
200
165
201
if (pf == PIXEL_BLT_ONLY || pf >= PIXEL_FORMAT_MAX )
166
202
continue ;
167
- if (w == cmdline .res .width && h == cmdline .res .height )
203
+ if (w == cmdline .res .width && h == cmdline .res .height &&
204
+ (cmdline .res .format < 0 || cmdline .res .format == pf ) &&
205
+ (!cmdline .res .depth || cmdline .res .depth == pixel_bpp (pf , pi )))
168
206
return m ;
169
207
}
170
208
0 commit comments