From patchwork Mon Aug 25 20:40:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 138 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154435; bh=lBmag95gO7q1KEy0BoKwgcfvPUmYMSjrIvNAuxwzovA=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ad208mw0xDqCQB90goypkiutgL2qISiervOWkBHiEpc9c4EKFH/ukNuwKnc3wTbey z5KVQ0ZFUDhJACxa90JxcHlkzmTzh1thjElhjkeAnRrh1xxX/Jl3zMMbWUOx3T0VIU A8s4f8AY03XtMkmhmtJJpJnFA++mf9DlqfHvB7A1AXFGnF1ROmi1VE4GL79QT2YTW3 jSdZQ+KsQDmA4pJ+vXJUDAmuuuyJNNMRhBAEx4J8+kC6iPYrJhSK/vHvEgn6Fvg9Ku 75ojeIaXq2mcSQSYox5EiBghVE6o4MWZIYTYmitOxU53r5GO3kryPVsao6F7XdFn+n Nm+25dxgdOpIA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DCDDA6779C for ; Mon, 25 Aug 2025 14:40:35 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 99NsG-VI-u-j for ; Mon, 25 Aug 2025 14:40:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154435; bh=lBmag95gO7q1KEy0BoKwgcfvPUmYMSjrIvNAuxwzovA=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ad208mw0xDqCQB90goypkiutgL2qISiervOWkBHiEpc9c4EKFH/ukNuwKnc3wTbey z5KVQ0ZFUDhJACxa90JxcHlkzmTzh1thjElhjkeAnRrh1xxX/Jl3zMMbWUOx3T0VIU A8s4f8AY03XtMkmhmtJJpJnFA++mf9DlqfHvB7A1AXFGnF1ROmi1VE4GL79QT2YTW3 jSdZQ+KsQDmA4pJ+vXJUDAmuuuyJNNMRhBAEx4J8+kC6iPYrJhSK/vHvEgn6Fvg9Ku 75ojeIaXq2mcSQSYox5EiBghVE6o4MWZIYTYmitOxU53r5GO3kryPVsao6F7XdFn+n Nm+25dxgdOpIA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CBDD767795 for ; Mon, 25 Aug 2025 14:40:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154433; bh=/m7c4rWEbaf9jA6scdItj1hGp+W9mJv1Vqm+NbvXTtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cffj/leKGpZC2AK6IVIq/DCXTGqwa/mGXa20mrcAGz18QF7hhKPB1KwaNNn6RIdVx 54QAkO0JX0jScAL5zhERpqKkCseiXcAMFOK/o//ti9a7XKIrKxKs3vcewzb6y6SYTE 0juLyd9GSjGDMnMQCrvOrCCw0gW+tWporkL6wWH5G8UKCFT4FEhB8qX7qJoWCpplOt 8qw/wIKKPAcK0dnSeg3UZmrxzHSKdWjOvwbODaZ4QmS4T45gm5Z3UgFgtmrw7e6VLn SGNZUJCZSGDCYjsfP/2jv+5t7VvdG3MkuPPRP1obSH3IgtnV1XNNwX4rscINvdqUdD zgq77frvKBU1g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C99EF67787; Mon, 25 Aug 2025 14:40:33 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id Abc-KtMZAM1X; Mon, 25 Aug 2025 14:40:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154433; bh=fJrUSo00xRSdyGkVgV2zwXYnWZJEEic5P187pJdj2RI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nTlZInMP19taI5fHs+1vUp5gncVeUTOkPIbOyeBfznq4wmdL5WbdiPz+9vVEwfKrd hJ8CXfUooszenWS+koPqut57RaXHfgv5ml2vGq+fJWdJ0OLokkosnBtvzivyabr57v h98n30z0zsi0e/dv2RZ12Umtq24TX2AR16GtBoYBl1cEMMsNSiccnem5erJvO2p+KS pfqJxGi9KKC6kH6r4Q0tzxcvBvsjoSmDHcJv/58NU6Ebs/MBnvsK0FyMjn2u8kNdho FDczv5ZLMyshToXiIq1K6unmJcrVLn4Ucu/R4wu5K7tt6zH6L1Phrx2q8XYe9w9ybT EaVCIlGXyVycw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1C53067709; Mon, 25 Aug 2025 14:40:33 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 25 Aug 2025 14:40:14 -0600 Message-ID: <20250825204022.3655799-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825204022.3655799-1-sjg@u-boot.org> References: <20250825204022.3655799-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2EYJMPM2I6UV2CICHZ4KZGGW4XC3QSKA X-Message-ID-Hash: 2EYJMPM2I6UV2CICHZ4KZGGW4XC3QSKA X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 1/6] Add a few floating-point routines List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass U-Boot does not normally make use of floating point and it is generally possible and desirable to avoid it within a bootloader. However there are libraries which need it. For example, U-Boot's Truetype font implementation needs floating point and some features such as the Nuklear GUI make use of it also. Enable this to compile in some basic library functions for floating point. Signed-off-by: Simon Glass --- include/vsprintf.h | 25 ++++++ lib/Kconfig | 13 +++ lib/Makefile | 1 + lib/strtof.c | 200 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 239 insertions(+) create mode 100644 lib/strtof.c diff --git a/include/vsprintf.h b/include/vsprintf.h index 9da6ce7cc4d..9e86f395331 100644 --- a/include/vsprintf.h +++ b/include/vsprintf.h @@ -364,4 +364,29 @@ int vsscanf(const char *inp, char const *fmt0, va_list ap); */ int sscanf(const char *buf, const char *fmt, ...); +/** + * strtod() - Convert text floating-point number to double + * + * @str: String to convert + * @entptr: If non-NULL, set to point to the character after the last one that + * was part of the floating-point number + * @return double-precision floating-point representation of the characters in + * @str. + */ +double strtod(const char *str, char **endptr); + +/** + * strtod() - Convert text floating-point number to double + * + * @str: decimal ASCII floating-point number, optionally preceded by whitespace. + * Must have form "-I.FE-X", where I is the integer part of the mantissa, F is + * the fractional part of the mantissa, and X is the exponent. Either of the + * signs may be "+", "-", or omitted. Either I or F may be omitted, or both. + * The decimal point isn't necessary unless F is present. The "E" may actually + * be an "e". E and X may both be omitted (but not just one). + * @return double-precision floating-point representation of the characters in + * @str. + */ +double atof(const char *str); + #endif diff --git a/lib/Kconfig b/lib/Kconfig index ed35c1f0b30..b9866619c5d 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1246,6 +1246,19 @@ config PHANDLE_CHECK_SEQ enable this config option to distinguish them using phandles in fdtdec_get_alias_seq() function. +config FLOAT + bool "Support floating-point functions" + help + U-Boot does not normally make use of floating point and it is + generally possible and desirable to avoid it within a bootloader. + + However there are libraries which need it. For example, U-Boot's + Truetype font implementation needs floating point and some features + such as the Nuklear GUI make use of it also. + + Enable this to compile in some basic library functions for floating + point. + endmenu source "lib/fwu_updates/Kconfig" diff --git a/lib/Makefile b/lib/Makefile index 84b94d78680..b9a5378e8aa 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -155,6 +155,7 @@ obj-y += vsprintf.o strto.o obj-$(CONFIG_SSCANF) += sscanf.o endif obj-$(CONFIG_$(PHASE_)OID_REGISTRY) += oid_registry.o +obj-$(CONFIG_FLOAT) += strtof.o obj-y += abuf.o obj-y += alist.o diff --git a/lib/strtof.c b/lib/strtof.c new file mode 100644 index 00000000000..f26eca5ab79 --- /dev/null +++ b/lib/strtof.c @@ -0,0 +1,200 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 1988-1993 The Regents of the University of California. + * Copyright (c) 1994 Sun Microsystems, Inc. + * Copyright 2020 Google LLC + * Relicensed as GPL-2.0+ for U-Boot + * + * Modified from commit fae05bc at:: + * github.com/embeddedartistry/embedded-resources/tree/master/examples/libc/stdlib + */ + +#include +#include +#include + +/* + * Largest possible base--10 exponent. Any exponent larger than this will + * already produce underflow or overflow, so there's no need to worry about + * additional digits. + */ +static int maxExponent = 511; + +/* + * Table giving binary powers of 10. Entry is 10^2^i. Used to convert decimal + * exponents into floating-point numbers + */ +static double powersOf10[] = { + 1.0e4, + 1.0e8, + 1.0e16, + 1.0e32, + 1.0e64, + 1.0e128, + 1.0e256 +}; + +/* + * Details on @str: + */ +double strtod(const char *string, char **endptr) +{ + int sign, expsign = false; + double fraction, dblexp, *d; + const char *p; + int c; + int exp = 0; /* Exponent read from "EX" field */ + /* + * Exponent that derives from the fractional part. Under normal + * circumstatnces, it is the negative of the number of digits in F. + * However if I is very long, the last digits of I get dropped + * (otherwise a long I with a large negative exponent could cause an + * unnecessary overflow on I alone). In this case, fracexp is + * incremented one for each dropped digit. + */ + int fracexp = 0; + int mantsize; /* Number of digits in mantissa */ + int decpt; /* Number of mantissa digits BEFORE decimal point */ + /* Temporarily holds location of exponent in string */ + const char *pexp; + + /* Strip off leading blanks and check for a sign */ + p = string; + while (isspace(*p)) + p += 1; + if (*p == '-') { + sign = true; + p += 1; + } else { + if (*p == '+') + p += 1; + sign = false; + } + + /* + * Count the number of digits in the mantissa (including the decimal + * point), and also locate the decimal point. + */ + decpt = -1; + for (mantsize = 0;; mantsize += 1) { + c = *p; + if (!isdigit(c)) { + if (c != '.' || decpt >= 0) + break; + decpt = mantsize; + } + p += 1; + } + + /* + * Now suck up the digits in the mantissa. Use two integers to + * collect 9 digits each (this is faster than using floating-point). + * If the mantissa has more than 18 digits, ignore the extras, since + * they can't affect the value anyway. + */ + pexp = p; + p -= mantsize; + if (decpt < 0) + decpt = mantsize; + else + mantsize -= 1; /* One of the digits was the point */ + if (mantsize > 18) { + fracexp = decpt - 18; + mantsize = 18; + } else { + fracexp = decpt - mantsize; + } + if (!mantsize) { + fraction = 0.0; + p = string; + goto done; + } else { + int frac1, frac2; + + frac1 = 0; + for (; mantsize > 9; mantsize -= 1) { + c = *p; + p += 1; + if (c == '.') { + c = *p; + p += 1; + } + frac1 = 10 * frac1 + (c - '0'); + } + frac2 = 0; + for (; mantsize > 0; mantsize -= 1) { + c = *p; + p += 1; + if (c == '.') { + c = *p; + p += 1; + } + frac2 = 10 * frac2 + (c - '0'); + } + fraction = (1.0e9 * frac1) + frac2; + } + + /* Skim off the exponent */ + p = pexp; + if (*p == 'E' || *p == 'e') { + p += 1; + if (*p == '-') { + expsign = true; + p += 1; + } else { + if (*p == '+') + p += 1; + expsign = false; + } + if (!isdigit(*p)) { + p = pexp; + goto done; + } + while (isdigit(*p)) { + exp = exp * 10 + (*p - '0'); + p += 1; + } + } + if (expsign) + exp = fracexp - exp; + else + exp = fracexp + exp; + + /* + * Generate a floating-point number that represents the exponent. + * Do this by processing the exponent one bit at a time to combine + * many powers of 2 of 10. Then combine the exponent with the + * fraction. + */ + if (exp < 0) { + expsign = true; + exp = -exp; + } else { + expsign = false; + } + if (exp > maxExponent) + exp = maxExponent; /* errno = ERANGE; */ + dblexp = 1.0; + for (d = powersOf10; exp != 0; exp >>= 1, d += 1) { + if (exp & 01) + dblexp *= *d; + } + if (expsign) + fraction /= dblexp; + else + fraction *= dblexp; + +done: + if (endptr) + *endptr = (char *)p; + + if (sign) + return -fraction; + + return fraction; +} + +double atof(const char *str) +{ + return strtod(str, NULL); +} From patchwork Mon Aug 25 20:40:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 139 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154438; bh=Z0OHH0aDIJaB3o91yfJtyaznWynjWu1pgtdDjRI9Odc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=SnFx5kCS3JEpWPdjfTtZWjGbBOElMYjkNHr0z95e7MX40o4YhptX9fluvcBWdPdXI oVeZY+1SCc+KXdxkftXufUb3o+i035c2zHqNqzJVfSB+4eyoozkGUb+4ay0AsQPPeo AlT2tFbfMAgm4oOIbDZJeXFkhNfM1RlTFF9IWqR83T4ZdIFALyaebkwYyVzTIhi10y 7DcPqGwSNmJJKpbkwKhw3pOKE0MzpJdW3tW3dIR1ImPLMzwDG5hoHs06/7s2npI8Lq 3ZcHA0nL5L93gNnjkR2TLVMl8vhlC+3TLs50nUHtzZPcn7UzA+lT6yXnHOu3JjtXKV mAfSL2/zQd9cA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 46FAD67787 for ; Mon, 25 Aug 2025 14:40:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id yfXVIVE4_PX5 for ; Mon, 25 Aug 2025 14:40:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154437; bh=Z0OHH0aDIJaB3o91yfJtyaznWynjWu1pgtdDjRI9Odc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ZOTEnqpvY4f/WKZIzpzsH4L8iDIYKbHg4CR9uScxC1QgKcxJle7Wr4h1j9Yyuaop0 q264VpcK9l3N4fGYBip5NkDD69ASXZlelY7dBjGACG2AUYcCWu1Aq7TQpcj0DtHqbe BbhDbHbMilhPyW6QYa7LZOTTl1ikTdHhKqV17rOL7wjEX3GAUW/itJW974pi4Tsoiv hhB+iUZOaST52nIAa7hTdO5ZopHtHqnXlFEgZqXf40R4oMBx93AS15ZkuBhqMqrLrq yT6TEZtEUXYtjJzt8B4vrLKKRp5FZSnhsdUo/k8hcD0bVpTW3riR4sp391e/XHM5XX iz0AG/W782/fA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 543276778C for ; Mon, 25 Aug 2025 14:40:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154434; bh=GIkUNmy8fnjEDFSZwu5JJNFjyHFbOm9rBJ4gFeJe+QI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hioH9RkK+Zes5JOlLw0FKzeExtHfG3xJOoDpw1Oxp0OaSs3329CJEmz5Gjd6D8DpN /+29yTHBJ9N6GGwBPXFQ2sQRs7eqq+rnQBbgjOVxactI3Ne48aFlNt1tBjvP64pgpP /bssq7XiZBSo3dcm6I0kaV9hfbkAQFZDB8D8lI9m6o6qSWIkuKf4jAmM4GAGMx9N4z x/nnl9gQ16ix6yUJxngF8nWNFp7OS0rqmjZVvhI+GKagXARMvR54OuwK2ZGCGzpm4e RTWeF3HU5PQBYF2qScn62Msn+ilVhaY3QvxneRb8csw/Qzc8OQsi30hWnCDaZIhwR1 bZrVRk2SEwfLA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AE4AF6778C; Mon, 25 Aug 2025 14:40:34 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id FYvsF9z1uDgo; Mon, 25 Aug 2025 14:40:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154434; bh=45WMtjCNaIYP2pNmovsU8gSeSBPXmr+88tZuiQtNoPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=btjr+2Q5T1r1LMuJeu8Bdmis4yMMZnDrOh3mdOEEf16W75x+zv8/o0UiZVS3r1h/r mhdxHF1nhuvWlnCj4HKEMHFMM2Jwf97UpVWT2v2jn1VdwFNMqQAgibfN/bW5aM8r01 DT2DbAwtMsRdymDvudNXFwXCsJZCu41w74yWZ625dMMqtsz56LmE0+4EfvrYuIPaJ6 SHcjQGU9WtwTvMhqoUT9xBNYtydllJ4uxdkeje5mcJq99O5VM+HJkb8XLaCjC+EV1C xEeM5yALS4uytvVa4B3TIn7Hp6VWJ1Pz3yxYOU0EuiCrSRZUNzAWj2V8ij1HFlUfPS DQFmpn7zvNSkA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 17C4867709; Mon, 25 Aug 2025 14:40:34 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 25 Aug 2025 14:40:15 -0600 Message-ID: <20250825204022.3655799-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825204022.3655799-1-sjg@u-boot.org> References: <20250825204022.3655799-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: MKKE4GFPL2VWAPPQF33CYT5LBH2WWPUQ X-Message-ID-Hash: MKKE4GFPL2VWAPPQF33CYT5LBH2WWPUQ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 2/6] input: Add mouse support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass When running a simple GUI it is useful to support a mouse. This is similar to what is provided in UEFI's boot menu. Add a simple uclass and a way to read the mouse position. For sandbox add a driver that reads the position from SDL. Signed-off-by: Simon Glass --- drivers/input/Kconfig | 9 ++++ drivers/input/Makefile | 3 ++ drivers/input/mouse-uclass.c | 28 +++++++++++++ drivers/input/sandbox_mouse.c | 35 ++++++++++++++++ include/dm/uclass-id.h | 1 + include/mouse.h | 78 +++++++++++++++++++++++++++++++++++ 6 files changed, 154 insertions(+) create mode 100644 drivers/input/mouse-uclass.c create mode 100644 drivers/input/sandbox_mouse.c create mode 100644 include/mouse.h diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index c2b365af11d..6bfee40ccac 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig @@ -100,3 +100,12 @@ config TWL4030_INPUT bool "Enable TWL4030 Input controller" help Enable TWL4030 Input controller + +config MOUSE + bool "Support for mice and other pointing devices" + default y if SANDBOX + help + This allows U-Boot to access mouse input, typically needed for + graphics boot menus and the like. The driver can provide mouse + events based on user interaction and these can be used to control + U-Boot's operation. diff --git a/drivers/input/Makefile b/drivers/input/Makefile index 8d4107b8848..a4938d19903 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile @@ -15,3 +15,6 @@ obj-$(CONFIG_I8042_KEYB) += i8042.o obj-$(CONFIG_TEGRA_KEYBOARD) += input.o tegra-kbc.o obj-$(CONFIG_TWL4030_INPUT) += twl4030.o endif + +obj-$(CONFIG_MOUSE) += mouse-uclass.o +obj-$(CONFIG_SANDBOX) += sandbox_mouse.o diff --git a/drivers/input/mouse-uclass.c b/drivers/input/mouse-uclass.c new file mode 100644 index 00000000000..ddf948f7e78 --- /dev/null +++ b/drivers/input/mouse-uclass.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019 Google LLC + * Written by Simon Glass + */ + +#include +#include + +int mouse_get_event(struct udevice *dev, struct mouse_event *evt) +{ + struct mouse_ops *ops = mouse_get_ops(dev); + int ret; + + if (!ops->get_event) + return -ENOSYS; + + ret = ops->get_event(dev, evt); + if (ret) + return ret; + + return 0; +} + +UCLASS_DRIVER(mouse) = { + .id = UCLASS_MOUSE, + .name = "mouse", +}; diff --git a/drivers/input/sandbox_mouse.c b/drivers/input/sandbox_mouse.c new file mode 100644 index 00000000000..4aedf0fdf2d --- /dev/null +++ b/drivers/input/sandbox_mouse.c @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2020 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include + +static int mouse_sandbox_get_event(struct udevice *dev, + struct mouse_event *event) +{ + int ret; + + ret = sandbox_sdl_get_mouse_event(event); + + return ret; +} + +const struct mouse_ops mouse_sandbox_ops = { + .get_event = mouse_sandbox_get_event, +}; + +static const struct udevice_id mouse_sandbox_ids[] = { + { .compatible = "sandbox,mouse" }, + { } +}; + +U_BOOT_DRIVER(mouse_sandbox) = { + .name = "mouse_sandbox", + .id = UCLASS_MOUSE, + .of_match = mouse_sandbox_ids, + .ops = &mouse_sandbox_ops, +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index c558c95f465..a424ef00fc9 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -97,6 +97,7 @@ enum uclass_id { UCLASS_MISC, /* Miscellaneous device */ UCLASS_MMC, /* SD / MMC card or chip */ UCLASS_MOD_EXP, /* RSA Mod Exp device */ + UCLASS_MOUSE, /* Mouse, trackpad or other pointing device */ UCLASS_MTD, /* Memory Technology Device (MTD) device */ UCLASS_MUX, /* Multiplexer device */ UCLASS_NOP, /* No-op devices */ diff --git a/include/mouse.h b/include/mouse.h new file mode 100644 index 00000000000..81704047f5d --- /dev/null +++ b/include/mouse.h @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Mouse/trackpad/touchscreen input uclass + * + * Copyright 2020 Google LLC + */ + +#ifndef _MOUSE_H +#define _MOUSE_H + +enum mouse_ev_t { + MOUSE_EV_NULL, + MOUSE_EV_MOTION, + MOUSE_EV_BUTTON, +}; + +enum mouse_state_t { + BUTTON_LEFT = 1 << 0, + BUTTON_MIDDLE = 1 << 1, + BUTTON_RIGHT = 1 << 2, + BUTTON_SCROLL_PLUS = 1 << 3, + BUTTON_SCROLL_MINUS = 1 << 4, +}; + +enum mouse_press_state_t { + BUTTON_RELEASED = 0, + BUTTON_PRESSED, +}; + +/** + * struct mouse_event - information about a mouse event + * + * @type: Mouse event ype + */ +struct mouse_event { + enum mouse_ev_t type; + union { + /** + * @state: Mouse state (enum mouse_state_t bitmask) + * @x: X position of mouse + * @y: Y position of mouse + * @xrel: Relative motion in X direction + * @yrel: Relative motion in Y direction + */ + struct mouse_motion { + unsigned char state; + unsigned short x; + unsigned short y; + short xrel; + short yrel; + } motion; + + /** + * @button: Button number that was pressed/released (BUTTON_...) + * @state: BUTTON_PRESSED / BUTTON_RELEASED + * @clicks: number of clicks (normally 1; 2 = double-click) + * @x: X position of mouse + * @y: Y position of mouse + */ + struct mouse_button { + unsigned char button; + unsigned char press_state; + unsigned char clicks; + unsigned short x; + unsigned short y; + } button; + }; +}; + +struct mouse_ops { + int (*get_event)(struct udevice *dev, struct mouse_event *event); +}; + +#define mouse_get_ops(dev) ((struct mouse_ops *)(dev)->driver->ops) + +int mouse_get_event(struct udevice *dev, struct mouse_event *event); + +#endif From patchwork Mon Aug 25 20:40:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 140 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154438; bh=wRDT9DdHK/PHOlJGNt9XL1HergSUOgWy6ATcxw5+aMI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=kNNpIZjTsJJ1cyKm+3rorMMtf9RNWDSIaSrHKh/aCya6gL3RhkLPbgWfWYDsiO203 n53n9Dkxrl0Y4DQcLpPlzWOSRPwO45Jt7nt40lyyrrZb5E2My/gJGPzEyXJCK+yqPt vYbZyu6NC3T4/1RguAiYT/8DCGiYP6CbqLwLes14aQT1QTIN6gZDdaREz0ei07YDNV gGSMs7IMZHzEbnacXyufOKLSW0NxVSHT2D3ujNBQ/oDS4KDec0siZ2cHusoU5ZHAen 3LlvIuqW+7riFBWygxisNtCokBtO6CC92++WAc+LZTrSuFt3yAqnvpqY131k5uH3b5 IzwXFmlbEus2g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8CA8C67797 for ; Mon, 25 Aug 2025 14:40:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id zaXC7vTLNjX6 for ; Mon, 25 Aug 2025 14:40:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154437; bh=wRDT9DdHK/PHOlJGNt9XL1HergSUOgWy6ATcxw5+aMI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Sw+tUdhIxpBMEu4upobKb45dF5/0TcU4pbxDnewz+gojZNVLcn2ynxIpR6M+yAeOR /ODIaI81LAvShBUPETrxDS7uRUvtFhpGNBFYzMBjmdAWVDZ5BEpBw9mJEI1sWIwVMK BohtEuVJrb+/PHOS5yKWxJbWmM3v7J9DFo6TGFhKJbv0FZ0fWWiKkG+5XktRqzL97G xP788xqxaWocBg7ks+FAFpM0Te7Vcb+HiFQ0oPLDCqaYly5ZJ0d4bdfj2TytfbKyKI H+DYOmGbhn9ttERPx1D2tz9AGbtTAYA7fuICtLKyrmEyVXD2ipBZm/gS14rqKz1rtJ Ur0w1CAne82MQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A7F3D6779F for ; Mon, 25 Aug 2025 14:40:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154435; bh=AD3u+9LBYQqAFD8yDCYyRZ0+GwL26HhNiYW8Jy3dR5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uU+UQMHA4Usm3VtK99kRcEQRPE2keU5l37RpX22lqgZluirYEPlfEg1TmAN/D9Aqg 0/cnhuxzrJBzTUBVxF1mRpPG2r2mmpjJQ2qkSMLj8JfVUqKQK+whaGwZERMzzlJWJ2 L+Y85PIo/BDmS8nU0cPLn6qjldw4PRrj/NRDxN++JRKLLqS6slsK05k5MKuDavIpCG PuowJJgpKiW2xBzUL5wzkHuxewRDGhk+LaWfMNhHvguI/YQfuXb7xC6DkrN9Fow9XT 7AuJ4izPGnrwBbTWLdeQr7ogCUndWzT6/wNg4BYE5prK/kxRIWo1gJX0vdRk7ep0JJ x5vR/2a+VRpVA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7F8BB67787; Mon, 25 Aug 2025 14:40:35 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 0eOf5kWyabRH; Mon, 25 Aug 2025 14:40:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154435; bh=PmFeBTMsS5rbWNqITKAeMhNI90ZFXbEixXv8sXQA8I4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a+QUmRd4OVoquPVZHOFfOgRjStyUQ8BtHAGbjx/E9LWsbemY+boPgKrP5R/PuY1Nw eHmq0OlMBEWSbEpZF28qj4rEo7QIN5AsGGDnL8+xUR+s5mkDLQsGnRf5mr1NhPSfW4 g9jwf0qp9KKJ1pfnjWfqmRs9+3jelcmgHKoxq4y+bxSl6aB1VNj0Slgqlgvq75S9oW 7OHnwNSjwXyQG+LZEWOpl4lLAbcI2y5PycPlLFV/UuJgSnLt4i3HBZTdkGTiYCw0FS Cj0pZm3QXWFKX0laN/MGGvuy9X06rp+l6JzAwYMhhrR73zaVDDFAggOeULGmfDv+Ug mcriq51HXobQA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F008067709; Mon, 25 Aug 2025 14:40:34 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 25 Aug 2025 14:40:16 -0600 Message-ID: <20250825204022.3655799-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825204022.3655799-1-sjg@u-boot.org> References: <20250825204022.3655799-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6XHEJEIIBJCG7LRZENJ2VZMI7NNBONTY X-Message-ID-Hash: 6XHEJEIIBJCG7LRZENJ2VZMI7NNBONTY X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 3/6] sandbox: sdl: Add support for mouse input List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Allow mouse input to be reported from sandbox using SDL. Signed-off-by: Simon Glass --- arch/sandbox/cpu/sdl.c | 48 ++++++++++++++++++++++++++++++---- arch/sandbox/include/asm/sdl.h | 4 +++ 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index ed84646bdab..b705e15cf9c 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -67,15 +68,11 @@ static struct sdl_info { SDL_Renderer *renderer; SDL_Window *screen; int src_depth; + struct mouse_event mouse; } sdl; static void sandbox_sdl_poll_events(void) { - /* - * We don't want to include cpu_func.h in this file since it uses - * system headers. So add a declation here. - */ - extern void reset_cpu(void); SDL_Event event; while (SDL_PollEvent(&event)) { @@ -84,10 +81,50 @@ static void sandbox_sdl_poll_events(void) puts("LCD window closed - quitting\n"); sysreset_walk(SYSRESET_POWER_OFF); break; + case SDL_MOUSEMOTION: { + struct mouse_event *m = &sdl.mouse; + + m->type = MOUSE_EV_MOTION; + m->motion.state = 0; + m->motion.x = event.motion.x; + m->motion.y = event.motion.y; + m->motion.xrel = event.motion.xrel; + m->motion.yrel = event.motion.yrel; + break; + } + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEBUTTONUP: { + struct mouse_event *m = &sdl.mouse; + + m->type = MOUSE_EV_BUTTON; + if (event.button.button == SDL_BUTTON_LEFT) + m->button.button = BUTTON_LEFT; + else if (event.button.button == SDL_BUTTON_MIDDLE) + m->button.button = BUTTON_MIDDLE; + else if (event.button.button == SDL_BUTTON_RIGHT) + m->button.button = BUTTON_RIGHT; + m->button.press_state = event.type == + SDL_MOUSEBUTTONDOWN ? + BUTTON_PRESSED : BUTTON_RELEASED; + m->button.x = event.button.x; + m->button.y = event.motion.y; + break; + } } } } +int sandbox_sdl_get_mouse_event(struct mouse_event *evt) +{ + if (sdl.mouse.type == MOUSE_EV_NULL) + return -EAGAIN; + + *evt = sdl.mouse; + sdl.mouse.type = MOUSE_EV_NULL; + + return 0; +} + static int sandbox_sdl_ensure_init(void) { if (!sdl.inited) { @@ -521,6 +558,7 @@ int sandbox_sdl_sound_init(int rate, int channels) sdl.sample_rate = wanted.freq; sdl.cur_buf = 0; sdl.running = false; + sdl.mouse.type = MOUSE_EV_NULL; return 0; diff --git a/arch/sandbox/include/asm/sdl.h b/arch/sandbox/include/asm/sdl.h index ee4991f7c24..190b52bd407 100644 --- a/arch/sandbox/include/asm/sdl.h +++ b/arch/sandbox/include/asm/sdl.h @@ -9,6 +9,8 @@ #include #include +struct mouse_event; + #ifdef CONFIG_SANDBOX_SDL /** @@ -104,6 +106,8 @@ int sandbox_sdl_sound_init(int rate, int channels); */ int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp); +int sandbox_sdl_get_mouse_event(struct mouse_event *evt); + #else static inline int sandbox_sdl_init_display(int width, int height, int log2_bpp, bool double_size) From patchwork Mon Aug 25 20:40:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 141 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154440; bh=L+ANy7i2jt+BwDI1PccMQ00alG9EICr8F4VGIrbtey0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=DlWy8HrpumMCgp52IrAMQvg5+H1r8eNEecU+DWykBUP9NomfoG4Z/tfoEZ/9XyH1Q As1XiWNiEwSfyBLI9a5Y1HOkl5vfng0hM2uMikLtMfYaATZmhNPDaWRr8hftbKIbV0 klaqFLoejkDRHiBtahfxFHBdYG7X0Ryr3nF6nBi0lQF3i9FnLw/YvC3LnmwG1tEUxX W/cOFLKe29YockPAqC3Cg5m03lNMMXsUgUmYr2uVOIijJE9k1Sx7v3KppLufrNgk9+ 6nCa/uuny9dRKVOheBfVS1ksCY7DdMzQ08dOYckIUtw9gchjPihx1YMXytXFIYQ5qB MZNrY4YX1j5zQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1A36D6778B for ; Mon, 25 Aug 2025 14:40:40 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 4V3obVPJr_2R for ; Mon, 25 Aug 2025 14:40:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154440; bh=L+ANy7i2jt+BwDI1PccMQ00alG9EICr8F4VGIrbtey0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=DlWy8HrpumMCgp52IrAMQvg5+H1r8eNEecU+DWykBUP9NomfoG4Z/tfoEZ/9XyH1Q As1XiWNiEwSfyBLI9a5Y1HOkl5vfng0hM2uMikLtMfYaATZmhNPDaWRr8hftbKIbV0 klaqFLoejkDRHiBtahfxFHBdYG7X0Ryr3nF6nBi0lQF3i9FnLw/YvC3LnmwG1tEUxX W/cOFLKe29YockPAqC3Cg5m03lNMMXsUgUmYr2uVOIijJE9k1Sx7v3KppLufrNgk9+ 6nCa/uuny9dRKVOheBfVS1ksCY7DdMzQ08dOYckIUtw9gchjPihx1YMXytXFIYQ5qB MZNrY4YX1j5zQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 01BCF67787 for ; Mon, 25 Aug 2025 14:40:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154438; bh=wPDCUyXpN5jH6FEBwX2KfCPjj3WDSqA0gwRAL+9wNJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PAINty7/Jtd6RUTc5oLnC8ZrtjpHDsw/4p/DeONSvTIXEERp3362KHrUPUUj874OL WznpHKrfl+OHNgyuZAZt+tOBEyC0ifAFkAtTzFxkw4KIN3amW+BP31bl/enpZYifpu uE/q6CQX4b7hAqRdq/Y/tRX0BCuHEzb5TFlcZVkqXMZOTsES5P9VqDfjeiCPl6iQKN 2Yoc5hQ2oVW/dH+XW/Va8Q3LxD5QUAiVlKYSxgBN1NBRnoVzUAoWja4ZHmSL4Pz713 eVBxkKdLRwo7+P6FrJSq0qUD05YZ26dc9hBsI0Be7/L2FIZTR8PD8hAprmjxvGYppQ uW2x92Kca93oQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 344E567789; Mon, 25 Aug 2025 14:40:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id pewmvhwjEjSF; Mon, 25 Aug 2025 14:40:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154436; bh=yi0n6qaZuTRoZhGavy8Gq0MnBfHqlQv9i0+6TCAlkUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FUwiZCymTNZFj9Mgsn2iK7adk3b4jnv5DxOru/kIU6JzOyQWun405SU+oto230kzP 4j3LB7Xm3GfKonKqDxnSb5nMbtjxKPIExUkDgZrfJFcmJVqYgQeqCr9FSI0+SYJLZt Ef/XF4BO8YFZ93ZaS2y0Lb6XGqUmppWarxMy8VNjv7BkYL3NYpad7B4Ea3XPTw4wSI Qoj5W7U4zwwUMCzLKxEEqwJgLvxI7wJte64aOaHBGSZZ4Q0oXz08TDInzo3mjR7hwt r0KSh0aVEWH1qQOalDzK/HzMOQrgH3JYDu1Q8gnERrLkIZeOybzqOekxc3Ma0ZyWd0 Eo0BQoU8r+mvw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C06326778D; Mon, 25 Aug 2025 14:40:35 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 25 Aug 2025 14:40:17 -0600 Message-ID: <20250825144018.4.I74dbe55eb065be1782737c8b2b86558e53e0292a@changeid> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825204022.3655799-1-sjg@u-boot.org> References: <20250825204022.3655799-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BR5S53QAPUGV7MAXRVB53LKHNRG26CXY X-Message-ID-Hash: BR5S53QAPUGV7MAXRVB53LKHNRG26CXY X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 4/6] usb: Add a USB mouse driver List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a basic mouse driver for USB mice. It only handles very basic mice so assumes that the reports are in the basic format described by the USB HID specification 1.11. Signed-off-by: Simon Glass --- drivers/input/Kconfig | 8 + drivers/input/Makefile | 1 + drivers/input/usb_mouse.c | 325 ++++++++++++++++++++++++++++++++++++++ include/usb.h | 1 + 4 files changed, 335 insertions(+) create mode 100644 drivers/input/usb_mouse.c diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index 6bfee40ccac..bcab0408d70 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig @@ -109,3 +109,11 @@ config MOUSE graphics boot menus and the like. The driver can provide mouse events based on user interaction and these can be used to control U-Boot's operation. + +config USB_MOUSE + bool "USB mouse support" + help + This enables using a USB mouse to control a feature in U-Boot, + typically a boot menu. The driver uses the USB boot interface of + the mouse and attempts to auto-configure itself for normal + operation. diff --git a/drivers/input/Makefile b/drivers/input/Makefile index a4938d19903..f1c136b214c 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile @@ -18,3 +18,4 @@ endif obj-$(CONFIG_MOUSE) += mouse-uclass.o obj-$(CONFIG_SANDBOX) += sandbox_mouse.o +obj-$(CONFIG_USB_MOUSE) += usb_mouse.o diff --git a/drivers/input/usb_mouse.c b/drivers/input/usb_mouse.c new file mode 100644 index 00000000000..b5b5ba2f894 --- /dev/null +++ b/drivers/input/usb_mouse.c @@ -0,0 +1,325 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * USB mouse driver (parts taken from usb_kbd.c) + * + * (C) Copyright 2001 + * Denis Peter, MPL AG Switzerland + * + * Part of this source has been derived from the Linux USB + * project. + * + * Copyright 2020 Google LLC + */ + +#define LOG_CATEGORY UCLASS_MOUSE + +#include +#include +#include +#include +#include +#include + +enum { + RPT_BUTTON, + RPT_XREL, + RPT_YREL, + RPT_SCROLLY, +}; + +struct usb_mouse_priv { + ulong intpipe; + int intpktsize; + int intinterval; + ulong last_report; + struct int_queue *intq; + u32 repeat_delay; + int xrel; + int yrel; + int x; + int y; + int buttons; + int old_buttons; + int yscroll; + /* + * TODO(sjg@chromium.org): Use an array instead, with the + * DM_FLAG_ALLOC_PRIV_DMA flag + */ + s8 *buf; + u8 flags; +}; + +/* Interrupt service routine */ +static int usb_mouse_irq_worker(struct udevice *dev) +{ + struct usb_mouse_priv *priv = dev_get_priv(dev); + s8 *buf = priv->buf; + + priv->buttons = buf[RPT_BUTTON]; + priv->xrel = buf[RPT_XREL]; + if (priv->xrel < -127) + priv->xrel = 0; + priv->yrel = buf[RPT_YREL]; + if (priv->yrel < -127) + priv->yrel = 0; + priv->yscroll = buf[RPT_SCROLLY]; + + return 1; +} + +/* Mouse interrupt handler */ +static int usb_mouse_irq(struct usb_device *udev) +{ + struct udevice *dev = udev->dev; + + if (udev->irq_status || udev->irq_act_len != USB_MOUSE_BOOT_REPORT_SIZE) { + log_warning("Error %lx, len %d\n", udev->irq_status, + udev->irq_act_len); + return 1; + } + + return usb_mouse_irq_worker(dev); +} + +/* Interrupt polling */ +static void usb_mouse_poll_for_event(struct udevice *dev) +{ + struct usb_device *udev = dev_get_parent_priv(dev); + struct usb_mouse_priv *priv = dev_get_priv(dev); + int ret; + + if (IS_ENABLED(CONFIG_SYS_USB_EVENT_POLL)) { + /* Submit an interrupt transfer request */ + if (usb_int_msg(udev, priv->intpipe, priv->buf, + priv->intpktsize, priv->intinterval, true) >= 0) + usb_mouse_irq_worker(dev); + } else if (IS_ENABLED(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP) || + IS_ENABLED(CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE)) { + bool got_report = false; + + if (IS_ENABLED(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP)) { + struct usb_interface *iface; + + iface = &udev->config.if_desc[0]; + ret = usb_get_report(udev, iface->desc.bInterfaceNumber, + 1, 0, priv->buf, + USB_MOUSE_BOOT_REPORT_SIZE); + printf("control ret=%d\b", ret); + } else { + if (poll_int_queue(udev, priv->intq)) { + usb_mouse_irq_worker(dev); + /* We've consumed all queued int packets, create new */ + destroy_int_queue(udev, priv->intq); + priv->intq = create_int_queue(udev, + priv->intpipe, 1, + USB_MOUSE_BOOT_REPORT_SIZE, priv->buf, + priv->intinterval); + got_report = true; + } + } + if (got_report) + priv->last_report = get_timer(0); + } +} + +static int usb_mouse_get_event(struct udevice *dev, struct mouse_event *event) +{ + struct usb_mouse_priv *priv = dev_get_priv(dev); + + if (priv->buttons != priv->old_buttons) { + struct mouse_button *but = &event->button; + u8 diff; + int i; + + event->type = MOUSE_EV_BUTTON; + diff = priv->buttons ^ priv->old_buttons; + log_debug("buttons=%d, old=%d, diff=%d\n", priv->buttons, + priv->old_buttons, diff); + for (i = 0; i < 3; i++) { + u8 mask = 1 << i; + + if (diff && mask) { + but->button = i; + but->press_state = priv->buttons & mask; + but->clicks = 1; + but->x = priv->x; + but->y = priv->y; + priv->old_buttons ^= mask; + break; + } + } + log_debug(" end: buttons=%d, old=%d, diff=%d\n", priv->buttons, + priv->old_buttons, diff); + } else if (priv->xrel || priv->yrel) { + struct mouse_motion *motion = &event->motion; + + priv->x += priv->xrel; + priv->x = max(priv->x, 0); + priv->x = min(priv->x, 0xffff); + + priv->y += priv->yrel; + priv->y = max(priv->y, 0); + priv->y = min(priv->y, 0xffff); + + event->type = MOUSE_EV_MOTION; + motion->state = priv->buttons; + motion->x = priv->x; + motion->y = priv->y; + motion->xrel = priv->xrel; + motion->yrel = priv->yrel; + priv->xrel = 0; + priv->yrel = 0; + } else { + usb_mouse_poll_for_event(dev); + return -EAGAIN; + } + + return 0; +} + +static int check_mouse(struct usb_device *udev, int ifnum) +{ + struct usb_endpoint_descriptor *ep; + struct usb_interface *iface; + + if (udev->descriptor.bNumConfigurations != 1) + return log_msg_ret("numcfg", -EINVAL); + + iface = &udev->config.if_desc[ifnum]; + + if (iface->desc.bInterfaceClass != USB_CLASS_HID) + return log_msg_ret("if class", -EINVAL); + + if (iface->desc.bInterfaceSubClass != USB_SUB_HID_BOOT) + return log_msg_ret("if subclass", -EINVAL); + + if (iface->desc.bInterfaceProtocol != USB_PROT_HID_MOUSE) + return log_msg_ret("if protocol", -EINVAL); + + if (iface->desc.bNumEndpoints != 1) + return log_msg_ret("num endpoints", -EINVAL); + + ep = &iface->ep_desc[0]; + + /* Check if endpoint 1 is interrupt endpoint */ + if (!(ep->bEndpointAddress & 0x80)) + return log_msg_ret("ep not irq", -EINVAL); + + if ((ep->bmAttributes & 3) != 3) + return log_msg_ret("ep attr", -EINVAL); + + return 0; +} + +/* probes the USB device dev for mouse type */ +static int usb_mouse_probe(struct udevice *dev) +{ + struct usb_device *udev = dev_get_parent_priv(dev); + struct usb_mouse_priv *priv = dev_get_priv(dev); + struct usb_endpoint_descriptor *ep; + struct usb_interface *iface; + const int ifnum = 0; + int ret; + + ret = check_mouse(udev, ifnum); + if (ret) { + log_warning("Mouse detect fail (err=%d)\n", ret); + return log_msg_ret("probe", ret); + } + log_debug("USB mouse: found set protocol...\n"); + + /* allocate input buffer aligned and sized to USB DMA alignment */ + priv->buf = memalign(USB_DMA_MINALIGN, + roundup(USB_MOUSE_BOOT_REPORT_SIZE, USB_DMA_MINALIGN)); + + /* Insert private data into USB device structure */ + udev->privptr = priv; + + /* Set IRQ handler */ + udev->irq_handle = usb_mouse_irq; + + iface = &udev->config.if_desc[ifnum]; + ep = &iface->ep_desc[0]; + priv->intpipe = usb_rcvintpipe(udev, ep->bEndpointAddress); + priv->intpktsize = min(usb_maxpacket(udev, priv->intpipe), + USB_MOUSE_BOOT_REPORT_SIZE); + priv->intinterval = ep->bInterval; + priv->last_report = -1; + + /* We found a USB Keyboard, install it. */ + usb_set_protocol(udev, iface->desc.bInterfaceNumber, 0); + + log_debug("Found set idle...\n"); + usb_set_idle(udev, iface->desc.bInterfaceNumber, 0, 0); + + log_debug("Enable interrupt pipe...\n"); + if (IS_ENABLED(CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE)) { + priv->intq = create_int_queue(udev, priv->intpipe, 1, + USB_MOUSE_BOOT_REPORT_SIZE, + priv->buf, priv->intinterval); + printf("priv->intq %p\n", priv->intq); + ret = priv->intq ? 0 : -EBUSY; + } else if (IS_ENABLED(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP)) { + ret = usb_get_report(udev, iface->desc.bInterfaceNumber, 1, 0, + priv->buf, USB_MOUSE_BOOT_REPORT_SIZE); + } else { + ret = usb_int_msg(udev, priv->intpipe, priv->buf, + priv->intpktsize, priv->intinterval, false); + } + if (ret < 0) { + log_warning("Failed to get mouse state from device %04x:%04x (err=%d)\n", + udev->descriptor.idVendor, + udev->descriptor.idProduct, ret); + /* Abort, we don't want to use that non-functional keyboard */ + return ret; + } + log_info("USB mouse OK\n"); + + /* Success */ + return 0; +} + +static int usb_mouse_remove(struct udevice *dev) +{ + struct usb_device *udev = dev_get_parent_priv(dev); + struct usb_mouse_priv *priv = dev_get_priv(dev); + + if (IS_ENABLED(CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE)) + destroy_int_queue(udev, priv->intq); + free(priv->buf); + + return 0; +} + +const struct mouse_ops usb_mouse_ops = { + .get_event = usb_mouse_get_event, +}; + +static const struct udevice_id usb_mouse_ids[] = { + { .compatible = "usb-mouse" }, + { } +}; + +U_BOOT_DRIVER(usb_mouse) = { + .name = "usb_mouse", + .id = UCLASS_MOUSE, + .of_match = usb_mouse_ids, + .ops = &usb_mouse_ops, + .probe = usb_mouse_probe, + .remove = usb_mouse_remove, + .priv_auto = sizeof(struct usb_mouse_priv), +}; + +static const struct usb_device_id mouse_id_table[] = { + { + .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | + USB_DEVICE_ID_MATCH_INT_SUBCLASS | + USB_DEVICE_ID_MATCH_INT_PROTOCOL, + .bInterfaceClass = USB_CLASS_HID, + .bInterfaceSubClass = USB_SUB_HID_BOOT, + .bInterfaceProtocol = USB_PROT_HID_MOUSE, + }, + { } /* Terminating entry */ +}; + +U_BOOT_USB_DEVICE(usb_mouse, mouse_id_table); diff --git a/include/usb.h b/include/usb.h index be37ed272e1..7e05ef26d6b 100644 --- a/include/usb.h +++ b/include/usb.h @@ -255,6 +255,7 @@ int usb_host_eth_scan(int mode); * Appendix B of HID Device Class Definition 1.11 */ #define USB_KBD_BOOT_REPORT_SIZE 8 +#define USB_MOUSE_BOOT_REPORT_SIZE 8 /* * usb_init() - initialize the USB Controllers From patchwork Mon Aug 25 20:40:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 142 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154442; bh=zp0B9EYopsMDRoS+2H1yrkl7v05mWMi2yt745GFxztE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=kE9IH/kgPrLlHWwPYDTdIWUdX5IWIpLNyruLedkEo1d/iF5kBiNj0cBDKL0v4BEQA g2YwKECbwICJq59IE7RG+b32KZb148/EkpLGrI8rLpM0fJdNBjadqm9TYPlBR4J5RK d1HFCX3UfrgCmRkj7+eouHRGWxDtJLrGe/rXWNcaYaLQRa2SQFV4tl99te7pCyrJaO zE+zUM5jckpdgk4M0v1E4E5EyRh2Gwv0ozS+2C23faBCVKYN3dHUE3jnyp56imsIFk d6n+FChSBg7+tPYhu8retueG8dEdHMejTHSw1ufLgTay5mTpEXcZak2sLuEN0TmAbP +6PhndVSfiTLQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6CA316771F for ; Mon, 25 Aug 2025 14:40:42 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id YkykObcr93Jl for ; Mon, 25 Aug 2025 14:40:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154440; bh=zp0B9EYopsMDRoS+2H1yrkl7v05mWMi2yt745GFxztE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=sdgpLu1XBc5RPYapyaFh7vltUiBuLi2A2+oeESRaPw0ttpvgPwsSXIeyaAFIZtQau r68w63pLcpuxXBw6UqCil3cxf1Ss8FpcDnj1nFeRY+zpmPiF9admwP252t4RScD358 67a5wvDwZqQoxP9PElQkCOEXRaXp/ovRUjd0Tdt4Br8iQkLQ6w47tFj8mVUomXMfjP procFcIjc0YqXcDldl+j8zYYFg45N6cr1BilWZXKy100OSXYKnXUaklkmephcOYTEi Ee4XNmDmhZ4GIBK1LPdxVMyFnDlRgcjSOsVwX69XS7vX6OF067DP+Cp1pVR65xaopD TdkO326Lwj55Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8414867719 for ; Mon, 25 Aug 2025 14:40:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154438; bh=11RyFqxk4SAmnJuvfjXtImB26gPzfqIaHKdMG/xEJXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JbDSioCa8ZHScnsHlb9M8JRMyU+Fu9yhhS/g8EkeAuZ0S+glF1ewPZKOSvz4Pln+N WnvQTA/IqhQt+hoeNnpMU13BZHz25g6TyLoeUdLOoSpKc/4gsz2VdY3mH6Ae8XydCY AtFR/zg8u4LSz/UH0UNwho4kSUjh/LDf7jxTpWUZ90IGSDXCBZFAcM5aVgCoeDriQR DL7H8YFiaOWltuSvxxUh/XxPGM8M056jFmz07mYXQJzePhD/GWNZ5xmNwqk2T42XF5 XAA70O4P8NK0DXqtNxQUBn1AE8i07StYbINIfWoOcQuo4DUKuSOXMBQo0vDtW/UdAw hVbH5FS2ixe4w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4E2376778C; Mon, 25 Aug 2025 14:40:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id oGn8EXcEakNz; Mon, 25 Aug 2025 14:40:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154437; bh=bXp00nolNzDkWHF5QYpAPMi8oMPGz5t1WUaYtLGF13M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ArIkm3qV7AXudhkWfpxDQxiOnbJC9Fk7flI57OcdCooWiuCJeBpvegVAgAwGc5GQv OkRWXJIKrKr1HyBMO7JQg1daZenVWCQoImB4Otkk6bHO1L6pBre6wY3TMTUclivMjO EhzjGvs6VMhQRvNt16gajYXdvxLXefZ4M7VpWE7tG7QEmNRWQj9eXK4woL7pvISr3M Ns8USmRdO1UuPxdVyrdN7oXGY6hzrwA5g0tbXlZGiDaTLFwvrOKU011zrJ+o0UU1ey gWS7kMboWCqkXnCbnbX+TmpGZHXaF+WU/QZ5pgIWp5Qju1YfC1H457MOlfSKuATewW mo80q28VmZeNw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C9F4567709; Mon, 25 Aug 2025 14:40:36 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 25 Aug 2025 14:40:18 -0600 Message-ID: <20250825144018.5.Ifebe6452f38904689e3e2142fc08a623131ed0de@changeid> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825204022.3655799-1-sjg@u-boot.org> References: <20250825204022.3655799-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2W7DPVQBYQQYHCSWRVE5SJR46MCYUZPL X-Message-ID-Hash: 2W7DPVQBYQQYHCSWRVE5SJR46MCYUZPL X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 5/6] input: Add a command to show mouse input List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass This reads mouse input and shows it on the terminal. It is useful for testing mice. Signed-off-by: Simon Glass --- cmd/Kconfig | 9 +++++++ cmd/Makefile | 1 + cmd/mouse.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 cmd/mouse.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 882a4ee02e3..1a879d1fe90 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2934,6 +2934,15 @@ config CMD_LOG maximum log level for emitting of records). It also provides access to a command used for testing the log system. +config CMD_MOUSE + bool "mouse - Show mouse input" + default y if MOUSE + help + This shows the data produced by a mouse. If a mouse device is + available records are printed when the mouse is moved. This can be + useful for checking that a mouse is working correctly within + U-Boot. + config CMD_TRACE bool "trace - Support tracing of function calls and timing" depends on TRACE diff --git a/cmd/Makefile b/cmd/Makefile index 407056b778b..2a9c39f18e2 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -128,6 +128,7 @@ obj-$(CONFIG_CMD_CLONE) += clone.o ifneq ($(CONFIG_CMD_NAND)$(CONFIG_CMD_SF),) obj-y += legacy-mtd-utils.o endif +obj-$(CONFIG_CMD_MOUSE) += mouse.o obj-$(CONFIG_CMD_MUX) += mux.o obj-$(CONFIG_CMD_NAND) += nand.o ifdef CONFIG_NET diff --git a/cmd/mouse.c b/cmd/mouse.c new file mode 100644 index 00000000000..94434afa0c4 --- /dev/null +++ b/cmd/mouse.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Mouse testing + * + * Copyright 2020 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include + +static int do_mouse_dump(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct udevice *dev; + bool running; + int count; + int ret; + + ret = uclass_first_device_err(UCLASS_MOUSE, &dev); + if (ret) { + printf("Mouse not found (err=%d)\n", ret); + return CMD_RET_FAILURE; + } + for (running = true, count = 0; running;) { + struct mouse_event evt; + + ret = mouse_get_event(dev, &evt); + if (!ret) { + switch (evt.type) { + case MOUSE_EV_BUTTON: { + struct mouse_button *but = &evt.button; + + printf("button: button==%d, press=%d, clicks=%d, X=%d, Y=%d\n", + but->button, but->press_state, + but->clicks, but->x, but->y); + break; + } + case MOUSE_EV_MOTION: { + struct mouse_motion *motion = &evt.motion; + + printf("motion: Xrel=%d, Yrel=%d, X=%d, Y=%d, but=%d\n", + motion->xrel, motion->yrel, motion->x, + motion->y, motion->state); + break; + } + case MOUSE_EV_NULL: + break; + } + count++; + } else if (ret != -EAGAIN) { + return log_msg_ret("get_event", ret); + } + schedule(); + if (ctrlc()) + running = false; + } + printf("%d events received\n", count); + + return 0; +} + +static char mouse_help_text[] = + "dump - Dump input from a mouse"; + +U_BOOT_CMD_WITH_SUBCMDS(mouse, "Mouse input", mouse_help_text, + U_BOOT_SUBCMD_MKENT(dump, 1, 1, do_mouse_dump)); From patchwork Mon Aug 25 20:40:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 143 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154442; bh=bbplL+SJlCiA1KVZJC3RKCNACbQlqWwxKNdwnaaa8OE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=bR9IL8L/fpCnn+IT5kkJQdigDjowk7CSMCUnXEnd11tUzL8XOBCfK+kTmLAGc1NCw iKJZihNOO7/bVV0tkBooEdEVIakjGbWwshjovG8jN8eOcHC4pS+45ZdbHFbgWlT4hF GLlVvN4BEYbwmP1UdD2MCoKvz+xd8fmDbAiDRcLKfmlzKL1nkgrOelI8YD+bnwMWof jZr8l8uFl5gybqo3rz8MCjboXnz0bFsvK4u3ZgvilOemA8LQ1fKp9IvqXNjyDDudVM pVc8ciBYYmcvD9XF7KQVkxJCci91+F3sUOrH+NJ2cXVDEGDnjNkh2wNukRRq5XVoIq ETCjbsZy2x38Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B2BFC67789 for ; Mon, 25 Aug 2025 14:40:42 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id O486Anr31SRZ for ; Mon, 25 Aug 2025 14:40:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154441; bh=bbplL+SJlCiA1KVZJC3RKCNACbQlqWwxKNdwnaaa8OE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=nLsq3P0WIYix43kFnTTVCRYf2ABhu13SSuCE8QroPilRyknOFIYbaO/kqE04nSWhy xg7G+ftzZLEgHT/5F7fP20IvXZTCIyzircLTzpOQi/GjJtsI337tKXXWV9L8U1WIYe mLi00Zy/hAhrY3aEUDtefYrnZ0o4EVgdJuq5RAt1JaEWjPZPgIJGmTkEwZg8a4yqmy eAXLWgpZ7YoISuverzHkCXSul9Gea/jwDkHAfJF/O8nysKeZdnYAHNYNXu3ltDXFRh y0n1VN7bDbZvF4mP7s3KwtK/VHdxAMGcEXBQEA/Wo8A36kC4QE1Q9y1g0U78Z1Fs+i Gsn4IjhixEUgQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 51EDC6778D for ; Mon, 25 Aug 2025 14:40:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154438; bh=YC8B2iot+hAmB3p2ogTdamqLKNa2a9iPxdpf5dWMRMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bTerJrDVPavnzXnzcjI5CCZ3OfizSWhyDhdgcIIu9puZJEP+aXmypz36cmdrm+xSp Ypf4djARn6ACqWZhc6jKiiZCGq3SaSbqNX4aF1kbwQEkAY3NKhb12u/MdJlO566Nzl LCFAlPgwEc3cOhblnIfF+yWaEyBHb2WaWmULGeGZlUcZxuly2A7GVmQjDMQf48WaNN QEW//XgrPMHvAxTcbedjMjNggV47Z9s1tE6RK2md8qcN1Lz1b9y5Vcqd+xpLhELrwB 2EjVbM8OSjawZcfnYi7RYu0QzOTZNujuegK0f8PhPgIRU/SBb4IjopG93hIQFr3KQc kYg+RXmiNuAZQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D50796779F; Mon, 25 Aug 2025 14:40:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id fFXuoptEa3Qc; Mon, 25 Aug 2025 14:40:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756154438; bh=fLOvVah1+kWUdIQ2+bhezGgKlaocDE9l7EjrrlUNxC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bUPg66kxhgVNFUvolEB6qJJAey75UHzC8cAr60oYzyftxC5NRVwPx0+Fv9JqNM3qA C1KQyPVzWBixAxOpIwjvkru4Ub58u3SS6bI1f7IPkda43Cyp+0yLIAeElI5Y/HFGQq K269xE/Bel9uZVLNyz4BuXUKZQIg2PRrpzBeZUrEUKik4P/Dkiiip6m8ht/1QsztRA IvAuM5lJdVKUHTVKFNTkp1TBaPohknN3kEn83YGmDDDBy+PCC2Ekt9RTB2IaJFpOHu F3cFZ35pEBVluNBVrB+tCOx/qHcCwErKY/u62LBtMuF85sexqTTGxvzBtQk4cTp/7P G/gnfgBYTtRkA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AEDCD677A0; Mon, 25 Aug 2025 14:40:37 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 25 Aug 2025 14:40:19 -0600 Message-ID: <20250825204022.3655799-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825204022.3655799-1-sjg@u-boot.org> References: <20250825204022.3655799-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PQ4FB733NAF5PN5X6DV4WMA3FKVSVHUA X-Message-ID-Hash: PQ4FB733NAF5PN5X6DV4WMA3FKVSVHUA X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 6/6] sandbox: Enable the mouse List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Enable support for an mouse in sandbox, implemented by SDL. Signed-off-by: Simon Glass --- arch/sandbox/dts/sandbox.dtsi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi index dd18bd26352..48e34a7aee5 100644 --- a/arch/sandbox/dts/sandbox.dtsi +++ b/arch/sandbox/dts/sandbox.dtsi @@ -203,6 +203,10 @@ }; }; + mouse { + compatible = "sandbox,mouse"; + }; + pci@0 { pci@1e,0 { compatible = "sandbox,pmc";