Skip to content

ccgx: Format PD version as decimal on 11th Gen #75

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
Feb 12, 2025
Merged
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
12 changes: 11 additions & 1 deletion framework_lib/src/ccgx/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Interact with Infineon (formerly Cypress) PD controllers (their firmware binaries) in the CCGx series

use alloc::format;
use alloc::string::String;
use alloc::string::ToString;
#[cfg(feature = "uefi")]
Expand Down Expand Up @@ -117,6 +118,14 @@ pub struct BaseVersion {
/// Build Number part of the version. PP of X.Y.Z.BB
pub build_number: u16,
}
impl BaseVersion {
pub fn to_dec_string(&self) -> String {
format!(
"{}.{}.{}.{:0>3}",
self.major, self.minor, self.patch, self.build_number
)
}
}
impl fmt::Display for BaseVersion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
Expand Down Expand Up @@ -215,8 +224,9 @@ impl ControllerFirmwares {
pub fn active_fw_ver(&self) -> String {
let active = self.active_fw();
// On 11th Gen we modified base version instead of app version
// And it's formatted as decimal instead of hex
if let Some(Platform::IntelGen11) = smbios::get_platform() {
active.base.to_string()
active.base.to_dec_string()
} else {
active.app.to_string()
}
Expand Down