From nobody Sat May 4 04:37:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52866+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52866+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1578283941; cv=none; d=zohomail.com; s=zohoarc; b=G7FbRkm8Rag4jPSnrbTA4wL6h8/ICxsQzs/KFINQoKiei3qzbiaYvlhewrq39RfW/wMHbaOptVHW80/ihGnOpw9KST43CB+IomfbadK0PiNoeGvPDPX3A+t0P10VI4/8E+wovkukwHIFCn2g6jeMUgeaTjD5FHsaIX+jPGZtvaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578283941; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=PSEwNgAgUAkLwmsz/AIUgNMYeR3Krqk4CvUHqPcB+Z8=; b=B+Z11Mtr83bV/9tX/5yaUP/qNrw8quLlOtBujEKHmz1IkMQLrma7+UW/7VIO1gwau/CHhWcqCPtxhuCy2rubp31+gLhDtyC8HtlmyunPZSr3OhnRHX3w/nYft/dlFiI+mH+Ld0OlJzrt4/RSy0fOpNc4ufwsH2RzIGqipTY/dUw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52866+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 157828394174763.81559753719546; Sun, 5 Jan 2020 20:12:21 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id tNitYY1788612xjkwh6C6ZrI; Sun, 05 Jan 2020 20:12:21 -0800 X-Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by mx.groups.io with SMTP id smtpd.web12.1558.1578283940485831311 for ; Sun, 05 Jan 2020 20:12:20 -0800 X-Received: by mail-ot1-f66.google.com with SMTP id a15so69894226otf.1 for ; Sun, 05 Jan 2020 20:12:20 -0800 (PST) X-Gm-Message-State: Y6Dzv37isya63vB1OSkSiyWTx1787277AA= X-Google-Smtp-Source: APXvYqxu2M+C4C/pQNaIdHZY6atyMydZff4TKhkL00GEJQTc1yEJ97u/JDt77zx4xtlfaVa+0DAJ7g== X-Received: by 2002:a9d:70cb:: with SMTP id w11mr97948153otj.230.1578283939552; Sun, 05 Jan 2020 20:12:19 -0800 (PST) X-Received: from localhost.localdomain ([69.212.114.66]) by smtp.gmail.com with ESMTPSA id w72sm21039214oie.49.2020.01.05.20.12.18 (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: [edk2-devel] [PATCH] debug Date: Sun, 5 Jan 2020 22:12:04 -0600 Message-Id: <20200106041207.29728-1-matt.devillier@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,matt.devillier@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1578283941; bh=YTN2IIER3/yHZDiU2L54QGtaI23AGo4wq9pizipCPnw=; h=Cc:Date:From:Reply-To:Subject:To; b=X/W9Qee63x+o72MVpIC/BstCbA6aeUJiUZGE+97hDOVt1dEPyaRRp6cAGCm7j/uvh7m NPYVkiQapjzkP4i4vhZrbeyqg4C2v7Qz9h+7bkKec4X/nbBK8Z7iGA+a7xJI+D8ah9RGC Hd/Csnq2kxUBJcdu9kpaykwKkB4NANxzmJc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" --- MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c | 90 +++++++++++++----------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Us= b/UsbKbDxe/KeyBoard.c index 7505951c82..37c9388161 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c @@ -792,6 +792,19 @@ InitKeyboardLayout ( return EFI_SUCCESS; } =20 +static +BOOLEAN +UsbQuirkRequireSetIdle ( + IN EFI_USB_DEVICE_DESCRIPTOR DevDesc + ) +{ + switch (DevDesc.IdVendor) { + case 0x0557: + return DevDesc.IdProduct =3D=3D 0x2419; + default: + return FALSE; + } +} =20 /** Initialize USB keyboard device and all private data structures. @@ -807,10 +820,8 @@ InitUSBKeyboard ( IN OUT USB_KB_DEV *UsbKeyboardDevice ) { - UINT16 ConfigValue; - UINT8 Protocol; - EFI_STATUS Status; - UINT32 TransferResult; + EFI_STATUS Status; + EFI_USB_DEVICE_DESCRIPTOR DevDesc; =20 REPORT_STATUS_CODE_WITH_DEVICE_PATH ( EFI_PROGRESS_CODE, @@ -823,55 +834,38 @@ InitUSBKeyboard ( InitQueue (&UsbKeyboardDevice->EfiKeyQueueForNotify, sizeof (EFI_KEY_DAT= A)); =20 // - // Use the config out of the descriptor - // Assumed the first config is the correct one and this is not always th= e case + // Get device descriptor so vendor/device IDs available + // for quirk handling // - Status =3D UsbGetConfiguration ( + Status =3D UsbKeyboardDevice->UsbIo->UsbGetDeviceDescriptor ( UsbKeyboardDevice->UsbIo, - &ConfigValue, - &TransferResult - ); + &DevDesc); if (EFI_ERROR (Status)) { - ConfigValue =3D 0x01; - // - // Uses default configuration to configure the USB Keyboard device. - // - Status =3D UsbSetConfiguration ( - UsbKeyboardDevice->UsbIo, - ConfigValue, - &TransferResult - ); - if (EFI_ERROR (Status)) { - // - // If configuration could not be set here, it means - // the keyboard interface has some errors and could - // not be initialized - // - REPORT_STATUS_CODE_WITH_DEVICE_PATH ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, - (EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_INTERFACE_ERROR), - UsbKeyboardDevice->DevicePath - ); - - return EFI_DEVICE_ERROR; - } + return EFI_DEVICE_ERROR; } =20 - UsbGetProtocolRequest ( - UsbKeyboardDevice->UsbIo, - UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber, - &Protocol - ); // // Set boot protocol for the USB Keyboard. // This driver only supports boot protocol. // - if (Protocol !=3D BOOT_PROTOCOL) { - UsbSetProtocolRequest ( - UsbKeyboardDevice->UsbIo, - UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber, - BOOT_PROTOCOL + Status =3D UsbSetProtocolRequest ( + UsbKeyboardDevice->UsbIo, + UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber, + BOOT_PROTOCOL + ); + if (EFI_ERROR (Status)) { + // + // If protocol could not be set here, it means + // the keyboard interface has some errors and could + // not be initialized + // + REPORT_STATUS_CODE_WITH_DEVICE_PATH ( + EFI_ERROR_CODE | EFI_ERROR_MINOR, + (EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_INTERFACE_ERROR), + UsbKeyboardDevice->DevicePath ); + + return EFI_DEVICE_ERROR; } =20 UsbKeyboardDevice->CtrlOn =3D FALSE; @@ -896,6 +890,16 @@ InitUSBKeyboard ( =20 UsbKeyboardDevice->CurrentNsKey =3D NULL; =20 + // + // Some keyboards don't send interrupt transfers until SetIdle is called + // + if (UsbQuirkRequireSetIdle(DevDesc)) { + UsbSetIdleRequest(UsbKeyboardDevice->UsbIo, + UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber, + 0, + 0); + } + // // Sync the initial state of lights on keyboard. // --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#52866): https://edk2.groups.io/g/devel/message/52866 Mute This Topic: https://groups.io/mt/69457407/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-