Skip to content

Commit 27ef35f

Browse files
committed
laptop12: Add GOP debugging
Example: fs0:> inputmodule.efi gop GOP Info Available resolutions: 1920x1080 1600x1200 1280x1024 1280x720 1024x768 800x600 640x480 Current Resolution: 1920x1080 Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 8840918 commit 27ef35f

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

SUNFLOWER.README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ Presence/Status detection
172172
- Changes
173173
- Skip resolution update if already native
174174
- Add current resolution to ? debug info
175+
- Add commandline flag `inputmodules.efi gop` to print GOP modes for debugging
175176

176177
### Version 0.4.6
177178

src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@ fn main(image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
5656
if let Ok(ShellAction::Info) = arg {
5757
println!("Provide Parameter: 'gui' to launch UI and show issues");
5858
println!("Provide Parameter: 'force' to launch UI even if everything is ok");
59+
println!("Provide Parameter: 'gop' to print GOP debugging info");
5960
println!();
6061
#[cfg(not(feature = "12in"))]
6162
print_module_status();
6263
#[cfg(feature = "12in")]
6364
print_12in_status();
65+
} else if let Ok(ShellAction::GopInfo) = arg {
66+
println!("GOP Info");
67+
util::print_gop_info(boot_services);
6468
} else {
6569
info!("No shell arg, launching GUI");
6670

@@ -103,6 +107,7 @@ enum ShellAction {
103107
Gui,
104108
Force,
105109
Info,
110+
GopInfo,
106111
}
107112

108113
fn get_shell_action(boot_services: &BootServices) -> uefi::Result<ShellAction> {
@@ -134,6 +139,8 @@ fn get_shell_action(boot_services: &BootServices) -> uefi::Result<ShellAction> {
134139
ShellAction::Gui
135140
} else if args.len() == 2 && args[1] == "force" {
136141
ShellAction::Force
142+
} else if args.len() == 2 && args[1] == "gop" {
143+
ShellAction::GopInfo
137144
} else if args.len() == 1 {
138145
ShellAction::Gui
139146
} else {

src/util.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,46 @@ use crate::buffer::Buffer;
1616
const EFI_OS_INDICATIONS_BOOT_TO_FW_UI: u64 = 0x0000000000000001;
1717
const EFI_GLOBAL_VARIABLE_GUID: uefi::Guid = guid!("8be4df61-93ca-11d2-aa0d-00e098032b8c");
1818

19+
pub fn print_gop_info(bs: &BootServices) -> Option<()> {
20+
let gop_handles = if let Ok(gop_handles) =
21+
bs.locate_handle_buffer(SearchType::ByProtocol(&GraphicsOutput::GUID))
22+
{
23+
gop_handles
24+
} else {
25+
error!("GraphicsOutput protocol is missing");
26+
return None;
27+
};
28+
29+
let gop = if let Some(handle) = gop_handles.iter().next() {
30+
unsafe {
31+
bs.open_protocol::<GraphicsOutput>(
32+
OpenProtocolParams {
33+
handle: *handle,
34+
agent: bs.image_handle(),
35+
controller: None,
36+
},
37+
OpenProtocolAttributes::GetProtocol,
38+
)
39+
.expect("Failed to open GraphicsOutput handle")
40+
}
41+
} else {
42+
error!("No GOP handles found");
43+
return None;
44+
};
45+
46+
println!("Available resolutions:");
47+
for mode in gop.modes() {
48+
let (width, height) = mode.info().resolution();
49+
println!(" {}x{}", width, height);
50+
}
51+
52+
let mode = gop.current_mode_info();
53+
let (width, height) = mode.resolution();
54+
println!("Current Resolution: {}x{}", width, height);
55+
56+
Some(())
57+
}
58+
1959
pub fn get_gop_buffer(
2060
bs: &BootServices,
2161
) -> Option<(ScopedProtocol<GraphicsOutput>, Buffer, Option<Mode>)> {

0 commit comments

Comments
 (0)