Skip to content

camera: Print firmware version of camera #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions framework_lib/src/camera.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pub const FRAMEWORK_VID: u16 = 0x32AC;
pub const FRAMEWORK13_16_2ND_GEN_PID: u16 = 0x001C;
pub const FRAMEWORK12_PID: u16 = 0x001D;

/// Get and print the firmware version of the camera
pub fn check_camera_version() {
for dev in rusb::devices().unwrap().iter() {
let dev_descriptor = dev.device_descriptor().unwrap();
if dev_descriptor.vendor_id() != FRAMEWORK_VID
|| (dev_descriptor.product_id() != FRAMEWORK13_16_2ND_GEN_PID
&& dev_descriptor.product_id() != FRAMEWORK12_PID)
{
debug!(
"Skipping {:04X}:{:04X}",
dev_descriptor.vendor_id(),
dev_descriptor.product_id()
);
continue;
}
let handle = dev.open().unwrap();

let dev_descriptor = dev.device_descriptor().unwrap();
let i_product = dev_descriptor
.product_string_index()
.and_then(|x| handle.read_string_descriptor_ascii(x).ok());
println!("{}", i_product.unwrap_or_default());
println!(" Firmware Version: {}", dev_descriptor.device_version());
}
}
4 changes: 4 additions & 0 deletions framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use std::io::prelude::*;
#[cfg(feature = "rusb")]
use crate::audio_card::check_synaptics_fw_version;
use crate::built_info;
#[cfg(feature = "rusb")]
use crate::camera::check_camera_version;
use crate::capsule;
use crate::capsule_content::{
find_bios_version, find_ec_in_bios_cap, find_pd_in_bios_cap, find_retimer_version,
Expand Down Expand Up @@ -470,6 +472,8 @@ fn print_versions(ec: &CrosEc) {
println!(" Unknown");
}
}
#[cfg(feature = "rusb")]
check_camera_version();
}

fn print_esrt() {
Expand Down
2 changes: 2 additions & 0 deletions framework_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ extern crate log;

#[cfg(feature = "rusb")]
pub mod audio_card;
#[cfg(feature = "rusb")]
pub mod camera;

#[cfg(feature = "uefi")]
#[macro_use]
Expand Down