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.web11.1575.1578283941264246197 for ; Sun, 05 Jan 2020 20:12:21 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G+tUg8Qb; 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 p8so33472186oth.10 for ; Sun, 05 Jan 2020 20:12:21 -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=G+tUg8Qbl9m3aG67IUt9gfDVJpE1rakJNr5bdRbFtMFgRBDOBUtGNj3mPTrM/CXs7v r5qKp9eWltJoIGwdIxp/j0FPcbmrvKXkISEPE4fNYGm4zswZzVfTFAh0hD3TX9xl00do Z8crgBBTWQC//hUbdB4BbpmLN0tIbcoaeo1av51fINBEPxKVynXTGlRhW9PZ7XNblEfg 1v7gM6b5X66JlRwcvbHO03MYVpHOCBOFY6o5ZzjSVF5Lt0wrrdLQqQN2KzGtbKFkOZiv +C8GopqnPj5DWzy1u0VgnZIpMjT4L+zjW9ZXfSLlDexiMghJ9/ubGFUWj7Ub5Lb4sLlJ IRXg== 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=lYMY3PNUOQ1oRSAhcddqucdknHiItQ1ktTNzKl3oFjp71LZbkb2qu626P7vA5afPQX Wrp46BOOGs9VqGsjUHrfVBoiYW113EvK2nhRjFbJYSLHhwBVRsPXhSMZ6rLn+j+Avmu2 gLvheumlKHaygQQz2NbVeYdRikoNgVkPCyM74po/yXnPD08g4PMnMQ1UpVJbVJqT+FuC uaUB5sAW5rY9zYQ6S0AQfq3391gjRQuLKbKglQHw4so1TLWXaoPaJ4VWdG7oZ51BzeoG PriYS20eJ0eS6/yv8Czd85tdN/nh/TVZp+bQWb3jloNTQ5Pzko+krAEr2gj+khCS2JUi Qe9A== X-Gm-Message-State: APjAAAXlINOsSOSrbThNo6GKkxrAXjd+WpDfCCRanr9vh1uzQBv5xZhj pyPuOa4vaHX66ozLDtVh82c4NiXMMbc= X-Google-Smtp-Source: APXvYqwD2/BMN2MJowI+Xkuz/D389TLuJ5c1w3oD0F/SDSXJXuDhC/itzqv6CN2rwxG6Rj9iP1Rt9w== X-Received: by 2002:a9d:6c06:: with SMTP id f6mr115706315otq.318.1578283940390; Sun, 05 Jan 2020 20:12:20 -0800 (PST) Return-Path: Received: from localhost.localdomain ([69.212.114.66]) by smtp.gmail.com with ESMTPSA id w72sm21039214oie.49.2020.01.05.20.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 20:12:19 -0800 (PST) From: "MrChromebox" To: devel@edk2.groups.io Cc: Matt DeVillier Subject: [PATCH v3 1/3] MdeModulePkg/Usb/EfiKey: Fix endpoint selection Date: Sun, 5 Jan 2020 22:12:05 -0600 Message-Id: <20200106041207.29728-2-matt.devillier@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200106041207.29728-1-matt.devillier@gmail.com> References: <20200106041207.29728-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