mirror of
https://github.com/Lekensteyn/lglaf.git
synced 2025-02-19 19:14:53 -05:00
Attempt to LG G4 compatibility
lsusb from @invisiblek, unfortunately it seems to hang when used in VirtualBox (USB passthrough from Windows to Linux). The second CD of exposes the endpoints over bInterfaceNumber 2, so this patch simply activates the second CD. LG G4 (1004:6298) has this device descriptor: ... idVendor 0x1004 LG Electronics, Inc. idProduct 0x6298 bcdDevice 3.10 iManufacturer 1 LG Electronics Inc. iProduct 2 LGE Android Phone iSerial 3 VS986xxxxxxxx bNumConfigurations 2 Configuration Descriptor: ... bNumInterfaces 1 bConfigurationValue 1 ... Interface Descriptor: ... bNumEndpoints 3 bInterfaceClass 6 Imaging bInterfaceSubClass 1 Still Image Capture bInterfaceProtocol 1 Picture Transfer Protocol (PIMA 15470) iInterface 5 MTP ... (EP 1 IN Bulk) (EP 1 OUT Bulk) (EP 2 IN Intr) ... Configuration Descriptor: ... bNumInterfaces 4 bConfigurationValue 2 ... Interface Descriptor: ... bNumEndpoints 3 bInterfaceClass 6 Imaging bInterfaceSubClass 1 Still Image Capture bInterfaceProtocol 1 Picture Transfer Protocol (PIMA 15470) iInterface 6 MTP ... (EP 1 IN Bulk) (EP 1 OUT Bulk) (EP 2 IN Intr) ... Interface Association: bLength 8 bDescriptorType 11 bFirstInterface 1 bInterfaceCount 2 bFunctionClass 2 Communications bFunctionSubClass 2 Abstract (modem) bFunctionProtocol 1 AT-commands (v.25ter) iFunction 9 CDC Serial Interface Descriptor: ... bNumEndpoints 1 bInterfaceClass 2 Communications bInterfaceSubClass 2 Abstract (modem) bInterfaceProtocol 1 AT-commands (v.25ter) iInterface 7 CDC Abstract Control Model (ACM) ... (EP 4 IN Intr) Interface Descriptor: ... bNumEndpoints 2 bInterfaceClass 10 CDC Data bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 8 CDC ACM Data (EP 3 IN Bulk) (EP 2 Out Bulk) Interface Descriptor: ... bInterfaceNumber 2 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass 255 Vendor Specific Subclass bInterfaceProtocol 255 Vendor Specific Protocol iInterface 0 (EP 5 IN Bulk) (EP 3 OUT Bulk) ...
This commit is contained in:
parent
e71375d6cc
commit
2d79e1565e
1 changed files with 13 additions and 0 deletions
13
lglaf.py
13
lglaf.py
|
@ -203,6 +203,16 @@ class USBCommunication(Communication):
|
|||
custom_match = self._match_device)
|
||||
if self.usbdev is None:
|
||||
raise RuntimeError("USB device not found")
|
||||
cfg = usb.util.find_descriptor(self.usbdev,
|
||||
custom_match=self._match_configuration)
|
||||
current_cfg = self.usbdev.get_active_configuration()
|
||||
if cfg.bConfigurationValue != current_cfg.bConfigurationValue:
|
||||
try:
|
||||
cfg.set()
|
||||
except usb.core.USBError as e:
|
||||
_logger.warning("Failed to set configuration, "
|
||||
"has a kernel driver claimed the interface?")
|
||||
raise e
|
||||
def _match_device(self, device):
|
||||
return any(
|
||||
usb.util.find_descriptor(cfg, bInterfaceClass=255,
|
||||
|
@ -217,6 +227,9 @@ class USBCommunication(Communication):
|
|||
usb.util.ENDPOINT_TYPE_BULK
|
||||
for ep in intf
|
||||
)
|
||||
def _match_configuration(self, config):
|
||||
return usb.util.find_descriptor(config,
|
||||
custom_match=self._match_interface)
|
||||
def _read(self, n, timeout=READ_TIMEOUT_MS):
|
||||
# device seems to use 16 KiB buffers.
|
||||
array = self.usbdev.read(self.EP_IN, 2**14, timeout=timeout)
|
||||
|
|
Loading…
Reference in a new issue