From nobody Sat Dec 21 12:18:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1693589395974876.0975945835374; Fri, 1 Sep 2023 10:29:55 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 5872521722; Fri, 1 Sep 2023 17:29:50 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id D50C320FEF for ; Fri, 1 Sep 2023 17:29:30 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Fri, 01 Sep 2023 10:29:30 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id c17-20020adfe711000000b0031773a8e5c4sm5794787wrm.37.2023.09.01.10.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 10:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=obe-tv.20230601.gappssmtp.com; s=20230601; t=1693589370; x=1694194170; darn=seabios.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=I79wAd/eGcZklcpnXz4xpsEnGZPIPLl1XQw7O6yrzMk=; b=JtO+WRTn0ML1vCTmpbER8wcnAYMvQsP+5XAxZEE0OLblb8mal7+uZi1y9764PjVbee xSPWz+KO7/zsEamM/GyGBCwRnEUpE8+7dmEyI9XQ5Rjh8QOZXovqv83NV4C58QSE3Yxx o9wPfjMg3huaxmeeCYvIutfrBV8axynOiHA4bbV+O5/d1/tIkQCeAZaHEEv/6SlAxYWo z64RVpovxVaFPmpWSUKdcPOaReZAM0KZYuyVk/xHsOg351AnQydHovHDmiBoALVbtKZd S61gcl37nOrLYE+vQL+RLNu5j/KQ7JLwoUm3l++PibInRDNVyIc/ZBke7igLz1kiVhoi /DDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693589370; x=1694194170; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I79wAd/eGcZklcpnXz4xpsEnGZPIPLl1XQw7O6yrzMk=; b=UJ2DfHdZ/MIsv+sqhjCzGuSu/MThVYIixk2tkI8Eost/abGVk/gu9Xl8rMrZf/Trv8 oNi01iE0Bt5yGB2kEwfdthcBJQd6lMexfJVs555kOpn0gD9ktsVZJ6/mMVcm+j1yjBy/ ZdD5tr/fWfrHO6FxRQu6gGUfV4HQXmeQcrUmmX+ih7HAERbFEC2nH85HVSt/RAH01IJg 0xog3LUhfBlL2hivi+EPs3eKMsqA7hc4tEjCWkiw729EMbVQpDWqYagdJD/P6voI82fZ ePVNRzvbUVFDZgC4TyJEiDy34GJRnRxLLiBcmw8T4C9UXdXlfA2uiW7KcFQZ6pXCMPss SRpw== X-Gm-Message-State: AOJu0YzrgIPaOIsXDfOCTHrBcE6dHpiQgTsqniKf6k+/cRkdJipZAAKd sKkHIOFyueANoFDWHOAc/m3u12Q6yAqGcT+jJqIu3A== X-Google-Smtp-Source: AGHT+IFa5zjRC8zLn6GzSO1uWSinqqUJk80IfLg3WrGZCv2LIrlZXMj0gTuDxmlxQ11fCyRYF6x8+A== X-Received: by 2002:a5d:54c8:0:b0:317:dada:2417 with SMTP id x8-20020a5d54c8000000b00317dada2417mr2481383wrv.31.1693589369646; Fri, 01 Sep 2023 10:29:29 -0700 (PDT) From: Kieran Kunhya To: seabios@seabios.org Date: Fri, 1 Sep 2023 17:29:24 +0000 Message-Id: <20230901172924.2313317-1-kierank@obe.tv> MIME-Version: 1.0 X-Spam-Level: *** Message-ID-Hash: WYG2O2FPQ7M66F6LCZKFLTMBYDKIRRUC X-Message-ID-Hash: WYG2O2FPQ7M66F6LCZKFLTMBYDKIRRUC X-MailFrom: kierank@ob-encoder.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Kieran Kunhya X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] [PATCH] add multiple usb-hid support List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1693589396743100001 Content-Type: text/plain; charset="utf-8" Based on a patch from Stef van Os --- src/hw/usb-hid.c | 49 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/src/hw/usb-hid.c b/src/hw/usb-hid.c index dec198a..62c046a 100644 --- a/src/hw/usb-hid.c +++ b/src/hw/usb-hid.c @@ -11,8 +11,14 @@ #include "usb.h" // usb_ctrlrequest #include "usb-hid.h" // usb_keyboard_setup #include "util.h" // process_key +#include "malloc.h" // malloc_low =20 -struct usb_pipe *keyboard_pipe VARFSEG; +struct keyboard_list { + struct usb_pipe *keyboard_pipe; + struct keyboard_list *next; +}; + +struct keyboard_list *keyboard_list VARFSEG; struct usb_pipe *mouse_pipe VARFSEG; =20 =20 @@ -62,11 +68,13 @@ static int usb_kbd_setup(struct usbdevice_s *usbdev , struct usb_endpoint_descriptor *epdesc) { + int kbd_idx =3D 0; + struct usb_pipe *keyboard_pipe; + struct keyboard_list *prev; + struct keyboard_list *end; + if (! CONFIG_USB_KEYBOARD) return -1; - if (keyboard_pipe) - // XXX - this enables the first found keyboard (could be random) - return -1; =20 if (epdesc->wMaxPacketSize < sizeof(struct keyevent) || epdesc->wMaxPacketSize > MAX_KBD_EVENT) { @@ -91,7 +99,26 @@ usb_kbd_setup(struct usbdevice_s *usbdev if (!keyboard_pipe) return -1; =20 - dprintf(1, "USB keyboard initialized\n"); + prev =3D end =3D GET_GLOBAL(keyboard_list); + while (end) { + prev =3D end; + end =3D end->next; + kbd_idx++; + } + + end =3D malloc_low(sizeof(*end)); + if (!end) + return -1; + + end->keyboard_pipe =3D keyboard_pipe; + end->next =3D NULL; + + if (!prev) + keyboard_list =3D end; + else + prev->next =3D end; + + dprintf(1, "USB keyboard %d initialized\n", kbd_idx); return 0; } =20 @@ -321,13 +348,10 @@ handle_key(struct keyevent *data) =20 // Check if a USB keyboard event is pending and process it if so. static void -usb_check_key(void) +usb_check_key(struct usb_pipe *pipe) { if (! CONFIG_USB_KEYBOARD) return; - struct usb_pipe *pipe =3D GET_GLOBAL(keyboard_pipe); - if (!pipe) - return; =20 for (;;) { u8 data[MAX_KBD_EVENT]; @@ -344,7 +368,7 @@ usb_kbd_active(void) { if (! CONFIG_USB_KEYBOARD) return 0; - return GET_GLOBAL(keyboard_pipe) !=3D NULL; + return GET_GLOBAL(keyboard_list) !=3D NULL; } =20 // Handle a ps2 style keyboard command. @@ -451,6 +475,9 @@ usb_mouse_command(int command, u8 *param) void usb_check_event(void) { - usb_check_key(); + struct keyboard_list *kbd_list =3D GET_GLOBAL(keyboard_list); + + for(; kbd_list !=3D NULL; kbd_list =3D kbd_list->next) + usb_check_key(kbd_list->keyboard_pipe); usb_check_mouse(); } --=20 2.25.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org