summaryrefslogtreecommitdiff
path: root/kvmd/apps
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-03-30 23:37:10 +0300
committerMaxim Devaev <[email protected]>2022-03-30 23:37:10 +0300
commited93f1f4d30031b90c45469b2a6651fdce826f33 (patch)
tree0a53268a9ac10dcb1aed8609842984a45a112d9d /kvmd/apps
parent2d4aa93f06afe70b18e9f8e9e58151d5701fd1ac (diff)
improved otgbind
Diffstat (limited to 'kvmd/apps')
-rw-r--r--kvmd/apps/kvmd/__init__.py2
-rw-r--r--kvmd/apps/kvmd/ugpio.py4
-rw-r--r--kvmd/apps/otg/__init__.py10
3 files changed, 7 insertions, 9 deletions
diff --git a/kvmd/apps/kvmd/__init__.py b/kvmd/apps/kvmd/__init__.py
index afbe4493..633e3346 100644
--- a/kvmd/apps/kvmd/__init__.py
+++ b/kvmd/apps/kvmd/__init__.py
@@ -86,7 +86,7 @@ def main(argv: Optional[List[str]]=None) -> None:
),
info_manager=InfoManager(global_config),
log_reader=LogReader(),
- user_gpio=UserGpio(config.gpio, global_config.otg.udc),
+ user_gpio=UserGpio(config.gpio, global_config.otg.udc, global_config.otg.gadget),
ocr=TesseractOcr(**config.ocr._unpack()),
hid=hid,
diff --git a/kvmd/apps/kvmd/ugpio.py b/kvmd/apps/kvmd/ugpio.py
index 560503d8..04d72e28 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, udc: str) -> None:
+ def __init__(self, config: Section, udc: str, gadget: str) -> None:
self.__view = config.view
self.__notifier = aiotools.AioNotifier()
@@ -241,7 +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
+ **({"udc": udc, "gadget": gadget} 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 fb2254ad..11fa83a3 100644
--- a/kvmd/apps/otg/__init__.py
+++ b/kvmd/apps/otg/__init__.py
@@ -186,7 +186,7 @@ def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements
_check_config(config)
- (udc, usb_driver) = usb.find_udc(config.otg.udc)
+ udc = usb.find_udc(config.otg.udc)[0]
logger.info("Using UDC %s", udc)
logger.info("Creating gadget %r ...", config.otg.gadget)
@@ -258,10 +258,8 @@ def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements
_write(join(gadget_path, "UDC"), udc)
time.sleep(config.otg.init_delay)
- logger.info("Setting %s bind permissions ...", usb_driver)
- driver_path = f"{env.SYSFS_PREFIX}/sys/bus/platform/drivers/{usb_driver}"
- _chown(join(driver_path, "bind"), config.otg.user)
- _chown(join(driver_path, "unbind"), config.otg.user)
+ logger.info("Setting UDC permissions ...")
+ _chown(join(gadget_path, "UDC"), config.otg.user)
logger.info("Ready to work")
@@ -277,7 +275,7 @@ def _cmd_stop(config: Section) -> None:
gadget_path = join(f"{env.SYSFS_PREFIX}/sys/kernel/config/usb_gadget", config.otg.gadget)
logger.info("Disabling gadget %r ...", config.otg.gadget)
- _write(join(gadget_path, "UDC"), "")
+ _write(join(gadget_path, "UDC"), "\n")
_unlink(join(gadget_path, "os_desc/c.1"), True)