mirror of
https://github.com/google/bumble.git
synced 2026-04-18 00:45:32 +00:00
allow custom driver factories
This commit is contained in:
@@ -61,7 +61,7 @@ async def get_driver_for_host(host):
|
||||
"""Probe all known diver classes until one returns a valid instance for a host,
|
||||
or none is found.
|
||||
"""
|
||||
if (driver := await rtk.Driver.for_host(host)):
|
||||
if driver := await rtk.Driver.for_host(host):
|
||||
logger.debug("Instantiated RTK driver")
|
||||
return driver
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ class Firmware:
|
||||
chip_id,
|
||||
firmware[patch_offset : patch_offset + patch_length - 4]
|
||||
+ struct.pack("<I", self.version),
|
||||
svn_version
|
||||
svn_version,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ class Host(AbortableEventEmitter):
|
||||
self.emit('flush')
|
||||
self.command_semaphore.release()
|
||||
|
||||
async def reset(self, raw=False):
|
||||
async def reset(self, driver_factory=drivers.get_driver_for_host):
|
||||
if self.ready:
|
||||
self.ready = False
|
||||
await self.flush()
|
||||
@@ -188,8 +188,8 @@ class Host(AbortableEventEmitter):
|
||||
# currently have a need for the driver later on. But if the driver interface
|
||||
# evolves, it may be required, then, to store a reference to the driver in
|
||||
# an object property.
|
||||
if not raw:
|
||||
if (driver := await drivers.get_driver_for_host(self)):
|
||||
if driver_factory is not None:
|
||||
if driver := await driver_factory(self):
|
||||
await driver.init_controller()
|
||||
|
||||
response = await self.send_command(
|
||||
|
||||
@@ -46,7 +46,7 @@ REALTEK_OPENSOURCE_SOURCE = (
|
||||
)
|
||||
LINUX_FROM_SCRATCH_SOURCE = (
|
||||
"https://anduin.linuxfromscratch.org/sources/linux-firmware/rtl_bt",
|
||||
False
|
||||
False,
|
||||
)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -92,7 +92,7 @@ def main(output_dir, source, single, force, parse):
|
||||
base_url, remove_suffix = {
|
||||
"linux-kernel": LINUX_KERNEL_GIT_SOURCE,
|
||||
"realtek-opensource": REALTEK_OPENSOURCE_SOURCE,
|
||||
"linux-from-scratch": LINUX_FROM_SCRATCH_SOURCE
|
||||
"linux-from-scratch": LINUX_FROM_SCRATCH_SOURCE,
|
||||
}[source]
|
||||
|
||||
print("Downloading")
|
||||
@@ -103,11 +103,7 @@ def main(output_dir, source, single, force, parse):
|
||||
images = [(f"{single}_fw.bin", f"{single}_config.bin", True)]
|
||||
else:
|
||||
images = [
|
||||
(
|
||||
driver_info.fw_name,
|
||||
driver_info.config_name,
|
||||
driver_info.config_needed
|
||||
)
|
||||
(driver_info.fw_name, driver_info.config_name, driver_info.config_needed)
|
||||
for driver_info in rtk.Driver.DRIVER_INFOS
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user