diff options
author | Devaev Maxim <[email protected]> | 2020-12-26 04:55:40 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-12-26 04:55:40 +0300 |
commit | 570dd04e29f5c597cf1fdcf9eca8f9f9877d243d (patch) | |
tree | 3f0f495728ac110a80c1232aa6e79300473aeb14 /kvmd/apps | |
parent | 77771bea55dad3c22694438e584b79d2ce6f7d48 (diff) |
otgbind pseudo-gpio plugin
Diffstat (limited to 'kvmd/apps')
-rw-r--r-- | kvmd/apps/__init__.py | 3 | ||||
-rw-r--r-- | kvmd/apps/kvmd/__init__.py | 2 | ||||
-rw-r--r-- | kvmd/apps/kvmd/ugpio.py | 3 | ||||
-rw-r--r-- | kvmd/apps/otg/__init__.py | 7 |
4 files changed, 11 insertions, 4 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py index 008f9e08..7e4f6a81 100644 --- a/kvmd/apps/__init__.py +++ b/kvmd/apps/__init__.py @@ -409,9 +409,10 @@ def _get_config_scheme() -> Dict: "udc": Option("", type=valid_stripped_string), "init_delay": Option(3.0, type=valid_float_f01), + "user": Option("kvmd", type=valid_user), + "devices": { "msd": { - "user": Option("kvmd", type=valid_user), "default": { "stall": Option(False, type=valid_bool), "cdrom": Option(True, type=valid_bool), diff --git a/kvmd/apps/kvmd/__init__.py b/kvmd/apps/kvmd/__init__.py index d11512b1..ac11945f 100644 --- a/kvmd/apps/kvmd/__init__.py +++ b/kvmd/apps/kvmd/__init__.py @@ -81,7 +81,7 @@ def main(argv: Optional[List[str]]=None) -> None: info_manager=InfoManager(global_config), log_reader=LogReader(), wol=WakeOnLan(**config.wol._unpack()), - user_gpio=UserGpio(config.gpio), + user_gpio=UserGpio(config.gpio, global_config.otg.udc), hid=hid, atx=get_atx_class(config.atx.type)(**config.atx._unpack(ignore=["type"])), diff --git a/kvmd/apps/kvmd/ugpio.py b/kvmd/apps/kvmd/ugpio.py index d4e9d0af..b3e01cb3 100644 --- a/kvmd/apps/kvmd/ugpio.py +++ b/kvmd/apps/kvmd/ugpio.py @@ -231,7 +231,7 @@ class _GpioOutput: # pylint: disable=too-many-instance-attributes # ===== class UserGpio: - def __init__(self, config: Section) -> None: + def __init__(self, config: Section, udc: str) -> None: self.__view = config.view self.__notifier = aiotools.AioNotifier() @@ -241,6 +241,7 @@ class UserGpio: instance_name=driver, notifier=self.__notifier, **drv_config._unpack(ignore=["instance_name", "notifier", "type"]), + **({"udc": udc} if drv_config.type == "otgbind" else {}), # Hack ) for (driver, drv_config) in tools.sorted_kvs(config.drivers) } diff --git a/kvmd/apps/otg/__init__.py b/kvmd/apps/otg/__init__.py index 2750549a..b8f93c6d 100644 --- a/kvmd/apps/otg/__init__.py +++ b/kvmd/apps/otg/__init__.py @@ -210,7 +210,7 @@ def _cmd_start(config: Section) -> None: if config.kvmd.msd.type == "otg": logger.info("===== Required MSD =====") - _create_msd(gadget_path, config_path, 0, config.otg.devices.msd.user, **config.otg.devices.msd.default._unpack()) + _create_msd(gadget_path, config_path, 0, config.otg.user, **config.otg.devices.msd.default._unpack()) if config.otg.devices.drives.enabled: logger.info("===== Required MSD extra drives: %d =====", config.otg.devices.drives.count) for instance in range(config.otg.devices.drives.count): @@ -222,6 +222,11 @@ def _cmd_start(config: Section) -> None: _write(join(gadget_path, "UDC"), udc) time.sleep(config.otg.init_delay) + logger.info("Setting DWC2 bind permissions ...") + driver_path = f"{env.SYSFS_PREFIX}/sys/bus/platform/drivers/dwc2" + _chown(join(driver_path, "bind"), config.otg.user) + _chown(join(driver_path, "unbind"), config.otg.user) + logger.info("Ready to work") |