From: shingil.kang Date: Thu, 12 Mar 2015 03:33:20 +0000 (+0900) Subject: SDB: separated android, tizen device when being detected X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7dbd15372b64e5b58a049fdf89c4f7617f21fe9b;p=sdk%2Ftools%2Fsdb.git SDB: separated android, tizen device when being detected Change-Id: I40ffb298efd9121a0ffc33748e4802643bc4a962 Signed-off-by: shingil.kang --- diff --git a/src/transport_usb.c b/src/transport_usb.c index c20943b..4c8b064 100755 --- a/src/transport_usb.c +++ b/src/transport_usb.c @@ -132,6 +132,8 @@ void register_usb_transport(usb_handle *usb, const char *serial) t->device_name = strdup(device_name); } +// check if device is tizen or android device. +// return 1 if tizen device, return 2 if android device int is_sdb_interface(int vendor_id, int usb_class, int usb_subclass, int usb_protocol) { /** @@ -141,11 +143,12 @@ int is_sdb_interface(int vendor_id, int usb_class, int usb_subclass, int usb_pro // && usb_protocol == SDB_INTERFACE_PROTOCOL) { // return 1; // } - - if ( usb_class == SDB_INTERFACE_CLASS && (usb_protocol == ADB_INTERFACE_PROTOCOL || usb_protocol == SDB_INTERFACE_PROTOCOL)) { + if ( usb_class == SDB_INTERFACE_CLASS ) { + if ( usb_subclass == SDB_INTERFACE_SUBCLASS && usb_protocol == SDB_INTERFACE_PROTOCOL ) return 1; - } - + else if ( usb_subclass == ADB_INTERFACE_SUBCLASS && usb_protocol == ADB_INTERFACE_PROTOCOL) + return 2; + } return 0; } diff --git a/src/usb_linux.c b/src/usb_linux.c index c692732..25f1bb6 100644 --- a/src/usb_linux.c +++ b/src/usb_linux.c @@ -185,10 +185,11 @@ int register_device(const char* node, const char* serial) { struct usb_interface_descriptor* usb_interface = (struct usb_interface_descriptor *) desc_current_ptr; - if (is_sdb_interface(usb_dev->idVendor, + int device_type; + if ((device_type = is_sdb_interface(usb_dev->idVendor, usb_interface->bInterfaceClass, usb_interface->bInterfaceSubClass, - usb_interface->bInterfaceProtocol) + usb_interface->bInterfaceProtocol)) && (USB_DT_INTERFACE_SIZE == bLength && USB_DT_INTERFACE == bType && 2 == usb_interface->bNumEndpoints)) { @@ -204,15 +205,14 @@ int register_device(const char* node, const char* serial) { unsigned char endpoint_out; unsigned char interface = usb_interface->bInterfaceNumber; - int bConfigurationValue = 2; - int n = ioctl(fd, USBDEVFS_SETCONFIGURATION, - &bConfigurationValue); - if (n != 0) { - LOG_DEBUG("check kernel is supporting %dth configuration\n", bConfigurationValue); - } - /* - // TODO: removed! - { + if(device_type == 2) { + int bConfigurationValue = 2; + int n = ioctl(fd, USBDEVFS_SETCONFIGURATION, + &bConfigurationValue); + if (n != 0) { + LOG_DEBUG("check kernel is supporting %dth configuration\n", bConfigurationValue); + } + } else { int bConfigurationValue = 2; int n = ioctl(fd, USBDEVFS_RESET); if (n != 0) { @@ -229,7 +229,6 @@ int register_device(const char* node, const char* serial) { LOG_DEBUG("usb claim failed\n"); } } - */ // find in/out endpoint address if ((endpoint1->bEndpointAddress & USB_ENDPOINT_DIR_MASK)