summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kvmd/apps/__init__.py2
-rw-r--r--kvmd/apps/otg/__init__.py20
2 files changed, 14 insertions, 8 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py
index ef277839..afabd560 100644
--- a/kvmd/apps/__init__.py
+++ b/kvmd/apps/__init__.py
@@ -491,7 +491,9 @@ def _get_config_scheme() -> Dict:
"manufacturer": Option("PiKVM"),
"product": Option("Composite KVM Device"),
"serial": Option("CAFEBABE"),
+ "device_version": Option(-1, type=functools.partial(valid_number, min=-1, max=0xFFFF)),
"usb_version": Option(0x0200, type=valid_otg_id),
+ "max_power": Option(250, type=functools.partial(valid_number, min=50, max=500)),
"remote_wakeup": Option(False, type=valid_bool),
"gadget": Option("kvmd", type=valid_otg_gadget),
diff --git a/kvmd/apps/otg/__init__.py b/kvmd/apps/otg/__init__.py
index e84a7f00..11058a7b 100644
--- a/kvmd/apps/otg/__init__.py
+++ b/kvmd/apps/otg/__init__.py
@@ -212,16 +212,20 @@ def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements
_write(join(gadget_path, "idVendor"), f"0x{config.otg.vendor_id:04X}")
_write(join(gadget_path, "idProduct"), f"0x{config.otg.product_id:04X}")
+ _write(join(gadget_path, "bcdUSB"), f"0x{config.otg.usb_version:04X}")
+
# bcdDevice should be incremented any time there are breaking changes
# to this script so that the host OS sees it as a new device
# and re-enumerates everything rather than relying on cached values.
- if config.otg.devices.ethernet.enabled and config.otg.devices.ethernet.driver == "ncm":
- _write(join(gadget_path, "bcdDevice"), "0x0102")
- elif config.otg.devices.ethernet.enabled and config.otg.devices.ethernet.driver == "rndis":
- _write(join(gadget_path, "bcdDevice"), "0x0101")
- else:
- _write(join(gadget_path, "bcdDevice"), "0x0100")
- _write(join(gadget_path, "bcdUSB"), f"0x{config.otg.usb_version:04X}")
+ device_version = config.otg.device_version
+ if device_version < 0:
+ device_version = 0x0100
+ if config.otg.devices.ethernet.enabled:
+ if config.otg.devices.ethernet.driver == "ncm":
+ device_version = 0x0102
+ elif config.otg.devices.ethernet.driver == "rndis":
+ device_version = 0x0101
+ _write(join(gadget_path, "bcdDevice"), f"0x{device_version:04X}")
lang_path = join(gadget_path, "strings/0x409")
_mkdir(lang_path)
@@ -233,7 +237,7 @@ def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements
_mkdir(profile_path)
_mkdir(join(profile_path, "strings/0x409"))
_write(join(profile_path, "strings/0x409/configuration"), f"Config 1: {config.otg.config}")
- _write(join(profile_path, "MaxPower"), "250")
+ _write(join(profile_path, "MaxPower"), str(config.otg.max_power))
if config.otg.remote_wakeup:
# XXX: Should we use MaxPower=100 with Remote Wakeup?
_write(join(profile_path, "bmAttributes"), "0xA0")