From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by mx.groups.io with SMTP id smtpd.web10.4018.1578023016163484101 for ; Thu, 02 Jan 2020 19:43:36 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QE/sKzAG; spf=pass (domain: gmail.com, ip: 209.85.210.66, mailfrom: matt.devillier@gmail.com) Received: by mail-ot1-f66.google.com with SMTP id p8so23092378oth.10 for ; Thu, 02 Jan 2020 19:43:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i0y8Nf00ugZLV3fwULqXJ3WyLElM82TNubQJy3i1iCs=; b=QE/sKzAGKFn6DMRtU7ZmbLzTOeHxHY6iT/TgmVfxcLCibjhSReDJWg+abGmK0jErJQ zaWkJcR14i/rh4tcKzX4qMiQST5+hIrteca21xCWBRxScM4xsA/S3ZfG6XWB8Hm18mDl B1F+Vi6IfRHRE9aPLXQ5d1ifpxR0dX+5pfZY3PT0ejKsW3F/j/PgRyfJA3gCEMzCPGJF Vqxdtuu1W5thALX7pNA+d9aQK1HDpSHb1l6iFVRDOb3MFn556kGu3Eg2CZ4gABLgAfTp c/xmLHcL3/GPjzXfIetc5pkUAPw4i44UjNVTLt6dN1cjMf0yj1xp0jwsgJgvkmbDVEV3 wghw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i0y8Nf00ugZLV3fwULqXJ3WyLElM82TNubQJy3i1iCs=; b=GdeQ2PVsHC07BqH6CHz8VgS2FQmONInabmq5nFkj5AWorkHEdVFNMI1xOv7z9HBw3V NgYqmzV/IZYWk6IWWc5BrJDjMpkzCgv0zTxIJWB7pNmmXCxktkIcGQ57rH3CMl8LyE6w UjjM019j7DFn2f84kr49lkSfa9dRlAZwEZIRaZHbr46Vtlg+B60Vo2pqnKmYAhAkPQwl YjLFaEaXlIZL98oY3hy9s2yjt94Yg+guNEZnvo8v3FQRXhNdaDZnTwwIdTAtD7JOovv8 zI8UcJnAylXasnYDH6dU1d8Kdf/CbIevueNm20dubylrXACm50dKxQ9DYu7DiPUjYhQl A4XA== X-Gm-Message-State: APjAAAVHrefGCeKl8NH6ojueO4O2tlU9MP5ODzNW/211O+V49tJPMb79 mS9aD79zQYoXP6pgOGpaUGDmpfU9SH4= X-Google-Smtp-Source: APXvYqz9SbfftX9azsYwhjV6HIOKOleL/a7LSuUhRDNByyj0QPnzI/5MZ+Nn3cCHL0E/59/qf8i2ng== X-Received: by 2002:a9d:7d09:: with SMTP id v9mr78934718otn.338.1578023015322; Thu, 02 Jan 2020 19:43:35 -0800 (PST) Return-Path: Received: from localhost.localdomain ([69.212.114.66]) by smtp.gmail.com with ESMTPSA id i2sm20028661oth.39.2020.01.02.19.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2020 19:43:34 -0800 (PST) From: "MrChromebox" To: devel@edk2.groups.io Cc: Matt DeVillier Subject: [PATCH v2 1/1] MdeModulePkg/Usb/EfiKey: Fix endpoint selection Date: Thu, 2 Jan 2020 21:43:10 -0600 Message-Id: <20200103034310.23428-2-matt.devillier@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200103034310.23428-1-matt.devillier@gmail.com> References: <20200103034310.23428-1-matt.devillier@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The endpoint selected by the driver needs to not only be an interrupt type, but have direction IN as required to set up an asynchronous interrupt transfer. Currently, the driver assumes that the first INT endpoint will be of type IN, but that is not true of all devices, and will silently fail on devices which have the OUT endpoint before the IN. Adjust the endpoint selection loop to explictly check for direction IN. Test: detachable keyboard on Google Pixel Slate now works. Signed-off-by: Matt DeVillier --- MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c index 27685995c2..ccb389067a 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c @@ -215,7 +215,7 @@ USBKeyboardDriverBindingStart ( EndpointNumber = UsbKeyboardDevice->InterfaceDescriptor.NumEndpoints; // - // Traverse endpoints to find interrupt endpoint + // Traverse endpoints to find interrupt endpoint IN // Found = FALSE; for (Index = 0; Index < EndpointNumber; Index++) { @@ -226,7 +226,8 @@ USBKeyboardDriverBindingStart ( &EndpointDescriptor ); - if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) { + if (((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) && + ((EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) != 0)) { // // We only care interrupt endpoint here // -- 2.20.1