VFIO mode enabled

This commit is contained in:
Luke D Jones
2021-03-20 23:26:03 +13:00
parent 45ab568f7a
commit 538e111e78
15 changed files with 240 additions and 179 deletions

View File

@@ -4,8 +4,8 @@
// static LED_INIT4: &str = "^ASUS Tech.Inc."; // ^ == 0x5e
// static LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08];
use crate::LED_MSG_LEN;
use crate::error::AuraError;
use crate::LED_MSG_LEN;
use serde_derive::{Deserialize, Serialize};
use std::str::FromStr;
use zvariant_derive::Type;

View File

@@ -1,6 +1,4 @@
use crate::{
error::AuraError,
};
use crate::error::AuraError;
use gumdrop::Options;
use std::str::FromStr;

View File

@@ -1,12 +1,14 @@
use crate::error::GraphicsError;
use serde_derive::{Deserialize, Serialize};
use std::str::FromStr;
use zvariant_derive::Type;
#[derive(Debug, PartialEq, Copy, Clone, Deserialize, Serialize)]
#[derive(Debug, Type, PartialEq, Copy, Clone, Deserialize, Serialize)]
pub enum GfxVendors {
Nvidia,
Integrated,
Compute,
Vfio,
Hybrid,
}
@@ -18,10 +20,12 @@ impl FromStr for GfxVendors {
"nvidia" => Ok(GfxVendors::Nvidia),
"hybrid" => Ok(GfxVendors::Hybrid),
"compute" => Ok(GfxVendors::Compute),
"vfio" => Ok(GfxVendors::Vfio),
"integrated" => Ok(GfxVendors::Integrated),
"nvidia\n" => Ok(GfxVendors::Nvidia),
"hybrid\n" => Ok(GfxVendors::Hybrid),
"compute\n" => Ok(GfxVendors::Compute),
"vfio\n" => Ok(GfxVendors::Vfio),
"integrated\n" => Ok(GfxVendors::Integrated),
_ => Err(GraphicsError::ParseVendor),
}
@@ -34,6 +38,7 @@ impl From<&GfxVendors> for &str {
GfxVendors::Nvidia => "nvidia",
GfxVendors::Hybrid => "hybrid",
GfxVendors::Compute => "compute",
GfxVendors::Vfio => "vfio",
GfxVendors::Integrated => "integrated",
}
}
@@ -45,38 +50,19 @@ impl From<GfxVendors> for &str {
}
}
#[derive(Debug)]
pub enum GfxCtrlAction {
#[derive(Debug, Type, PartialEq, Copy, Clone, Deserialize, Serialize)]
pub enum GfxRequiredUserAction {
Logout,
Reboot,
RestartX,
None,
}
impl FromStr for GfxCtrlAction {
type Err = GraphicsError;
fn from_str(s: &str) -> Result<Self, GraphicsError> {
match s.to_lowercase().as_str() {
"reboot" => Ok(GfxCtrlAction::Reboot),
"restartx" => Ok(GfxCtrlAction::RestartX),
"none" => Ok(GfxCtrlAction::None),
_ => Err(GraphicsError::ParseVendor),
impl From<&GfxRequiredUserAction> for &str {
fn from(gfx: &GfxRequiredUserAction) -> &'static str {
match gfx {
GfxRequiredUserAction::Logout => "logout",
GfxRequiredUserAction::Reboot => "reboot",
GfxRequiredUserAction::None => "no action",
}
}
}
impl From<&GfxCtrlAction> for &str {
fn from(mode: &GfxCtrlAction) -> Self {
match mode {
GfxCtrlAction::Reboot => "reboot",
GfxCtrlAction::RestartX => "restartx",
GfxCtrlAction::None => "none",
}
}
}
impl From<GfxCtrlAction> for &str {
fn from(mode: GfxCtrlAction) -> Self {
(&mode).into()
}
}