From patchwork Mon Sep 15 10:46:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 300 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=1757933246; bh=Uc846H2gbHnzUMGzRafujeWvJc2hA7mJeqvciySc+aA=; 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=jOYUcuUGSmTnR4sur3CO84OYzSlyiJNCEuzQnpoTkWGKjDiFGnpk9oD1xBODM0shO ixtbBaItrFE/knZ5n8szjKJ5Klh4gOYXXiaFH18/U+yIUxmc+EgMO77a7pwFQ+QA9F /fY1RqmVK3ky5ExtFlIxMzeRQ1PTAncw9Ax2rs6301kilHY+hBG2Xtp6pA/plXMZYw XTr18XgRZ0C/6WVGSsI04ID25CjJSOV1/VwlvErGRGNxjDOqCNsGWlZHyK9rSKxnxm Jv/XvFHSCCoeLpuoQV4rQ32CZj6Enra12F9SNqHHtfq5YLNUBCdFla/Nvivdv2gPtO /yFcCuW0ktzcw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 41CE867B34 for ; Mon, 15 Sep 2025 04:47:26 -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 Uem5hcbb5dri for ; Mon, 15 Sep 2025 04:47:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933246; bh=Uc846H2gbHnzUMGzRafujeWvJc2hA7mJeqvciySc+aA=; 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=jOYUcuUGSmTnR4sur3CO84OYzSlyiJNCEuzQnpoTkWGKjDiFGnpk9oD1xBODM0shO ixtbBaItrFE/knZ5n8szjKJ5Klh4gOYXXiaFH18/U+yIUxmc+EgMO77a7pwFQ+QA9F /fY1RqmVK3ky5ExtFlIxMzeRQ1PTAncw9Ax2rs6301kilHY+hBG2Xtp6pA/plXMZYw XTr18XgRZ0C/6WVGSsI04ID25CjJSOV1/VwlvErGRGNxjDOqCNsGWlZHyK9rSKxnxm Jv/XvFHSCCoeLpuoQV4rQ32CZj6Enra12F9SNqHHtfq5YLNUBCdFla/Nvivdv2gPtO /yFcCuW0ktzcw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2F9915F92B for ; Mon, 15 Sep 2025 04:47:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933242; bh=OdpyaDYzSuBwSaFO77zweINJ8CA4ShTPzfPsksmq+EI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djys5jpdf2dtQZaR598guBwwwNHyeqsJr3lFjmJXwHOKpnzXqrTAWlE9wult+dRO6 0vKT8P5aihJuI7WOMeu0zB1jxHbegq4w80v4PjzKiQYQcwqOT3gpHS8CIhK/hQUAcO U+tX5IzHQIYPGxQrX1Yxgr5CY75wn/XC4f8aV2GGrJYGqj3NTxozsdCKz22edSJE6v L8MQXexl1eY3sdMlsxq5RM4T1axSnX8L5z8pXdgokajwbchSQxkfn+uK2yBSCEY5iX XxUZWM0O7GSFeT8A5pxREaykvhYtuDnRFlvd9qsaElYRE9PhQn8+Wf4iwQWwBQ6Tkq Sa6ZFgJ0sZmqw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3FFFE67B4F; Mon, 15 Sep 2025 04:47:22 -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 w3yucbPOAJUj; Mon, 15 Sep 2025 04:47:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933242; bh=JsSHqRxvN9XJSJzIBoScVNZZap/6f75qefEiHd5llNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qYC41OLbHVZcA0AiIE32fyhlTCn4ezBtQS258SFi7wBYiSzw8IEtrCWFOKFHDxyWj d6xwbqlDvWqUfOmlOMBeepjD6UcGCAN8MurB/u/+a44ZQuYj7eSD4oIjYmsTLqIaYc bbxJVRI/pAg8OSE3/Z79bFpno9y4RQJeOv2LTs/qeC+SIWq6o4XbmwuSVyAiAdi+R5 lDjn0fhHRDxpMygsi8eSDZRxZ9dOx9L8rd9jcFekgYm90Mc3umr2PVzN5AnYjedh6G ZSAPlfg42Z9YozctfSVUc3h1f+Z92FCz4jv3Lrzha5hX9ZJEKihuMDbDA2tGAjIVrf aK/bxu50s9p7A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B0D4F67A99; Mon, 15 Sep 2025 04:47:21 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:42 -0600 Message-ID: <20250915104705.937780-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: MCPZY2S6CUXYHS5ECYXMTFLPCDMISJBZ X-Message-ID-Hash: MCPZY2S6CUXYHS5ECYXMTFLPCDMISJBZ 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 01/17] membuf: Add a function to set up a static membuf 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 way to set up a membuf with some pre-loaded data, so it is possible to read it out using membuf_readline(), etc. Signed-off-by: Simon Glass --- include/membuf.h | 17 ++++++++++++++++- lib/membuf.c | 8 ++++++++ test/lib/membuf.c | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/include/membuf.h b/include/membuf.h index b495a72652b..3352faa0606 100644 --- a/include/membuf.h +++ b/include/membuf.h @@ -222,7 +222,9 @@ int membuf_readline(struct membuf *mb, char *str, int maxlen, int minch, int membuf_extend_by(struct membuf *mb, int by, int max); /** - * membuf_init() - set up a new membuff using an existing membuff + * membuf_init() - set up a new membuff using an existing buffer + * + * The buffer is initially empty * * @mb: membuff to set up * @buff: Address of buffer @@ -230,6 +232,19 @@ int membuf_extend_by(struct membuf *mb, int by, int max); */ void membuf_init(struct membuf *mb, char *buff, int size); +/** + * membuf_init_with_data() - set up a new membuff using existing data + * + * The buffer is set up to contain the provided data. with its size set to + * @size + 1 (less MEMBUF_FULL), so that there is enough space for the head/tail + * differece. + * + * @mb: membuff to set up + * @buff: Address of buffer + * @size: Number of bytes to put into the membuf + */ +void membuf_init_with_data(struct membuf *mb, char *buff, int size); + /** * membuf_uninit() - clear a membuff so it can no longer be used * diff --git a/lib/membuf.c b/lib/membuf.c index 016430ae988..47a1b06664a 100644 --- a/lib/membuf.c +++ b/lib/membuf.c @@ -405,6 +405,14 @@ void membuf_init(struct membuf *mb, char *buff, int size) membuf_purge(mb); } +void membuf_init_with_data(struct membuf *mb, char *buff, int size) +{ + char *data; + + membuf_init(mb, buff, size + !MEMBUF_FULL); + membuf_putraw(mb, size, true, &data); +} + int membuf_new(struct membuf *mb, int size) { mb->start = malloc(size); diff --git a/test/lib/membuf.c b/test/lib/membuf.c index f36332ff7b6..2e7de9cdc57 100644 --- a/test/lib/membuf.c +++ b/test/lib/membuf.c @@ -242,3 +242,22 @@ static int lib_test_membuf_readline(struct unit_test_state *uts) return 0; } LIB_TEST(lib_test_membuf_readline, 0); + +/* test membuf_readline() with generated data */ +static int lib_test_membuf_init(struct unit_test_state *uts) +{ + struct membuf mb; + char buf[10], out[10]; + int len; + + strcpy(buf, "hello"); + len = strlen(buf); + membuf_init_with_data(&mb, buf, len); + ut_asserteq_ptr(buf, mb.start); + ut_asserteq(len, membuf_avail(&mb)); + ut_asserteq(len, membuf_readline(&mb, out, sizeof(out), 0, false)); + ut_asserteq_str("hello", out); + + return 0; +} +LIB_TEST(lib_test_membuf_init, 0); From patchwork Mon Sep 15 10:46:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 301 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=1757933248; bh=Qite6YOki3f8ZX+dHFeCzW1Ar62vEfll/eXvqLyFPp8=; 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=I3nUGrFf9IihyADlqPFGJLa5EdzLYxHG5okgcAXLisafvp2HcTKiJPjh8FjerMu/g yg8R3x8S0UnueqtLAz4AqyJCDiFhKdPwGyGNJIK9FF4x4lCOPvQxS+kKfIwOqOOipJ Md6LzipPOt5NDxZF8NwG3/aXgOFJrJHNtUMxSgYUJ/l+JtIu2zpkzKYAX5B8G3rVy0 jmuoU1qtZuZxb0Ci+bXO9mfNyUEa1A7dYdYo68BEdrylFCVPpyqamcX5TSfu70NUUC 9kG0k4ZHPBfXMHLZxp9HSjJ2Mj/LhR+1Q+LjTCmWwHBuE1s6jV1dpdi05dFZzrrV7M 1DlyTZ72rgiKg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A15DC67B65 for ; Mon, 15 Sep 2025 04:47:28 -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 vvEUfQOo9cjk for ; Mon, 15 Sep 2025 04:47:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933246; bh=Qite6YOki3f8ZX+dHFeCzW1Ar62vEfll/eXvqLyFPp8=; 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=RAoFnnue/aPJQxCk6l4i/5PJ2vsdNT3jccuxOQyrOMT6kkOcLOaSsxfiwwBYOcyxq Bm3Z0o4Ml/AO9vwDboopTb7VX/mF9tnbSTgsdE+atsfecJ6pE8CtRI0t+kiKDAJTm2 95DtM++7AHZoJHg0W1i39Vdb6Cg1NEW4r7MVbhT8nSRFqSADd7OYQfOHD4yjwbk/4I uLE906Dwkqyt7K/5Pzf26EazaW1ZyWv5fXFUS54Ouf9kVgO5sHjV9JXRfxmY4hS0Vv t4yYYW3/dsiGXkHjaPeSKSjsK31B5lokpdjUCSOi10jHBTwhRWu0nAON1NQo7Hucqo kDr0GBvWkHHeQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A780B67BB7 for ; Mon, 15 Sep 2025 04:47:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933243; bh=QK7StbXPbhH7ZCofaV77xXP4sx/0AzkE12vCxoAOGrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HumhDzp8fLYipeZzZct/1wV101DzWab7cJoW/HO8Zoeej4cFih2hbCxZ4xHqqwuix TPGCjoeAJvfYtbc/Y5LbuJYyqPKKWC0W6cplBI+uLYuN7MHHyHVGgkhu9+hOLdm/lD kbO8a58jmGA5LEKdaz4qRD7j9z0QjmcOKxDMXQh+M1fYyLweA72KTbmNwf9Geux6CA tDrUkmDORFSY1ll71yWnZ2ny/r4nPLZvUCLOIpfX1fMhPZ2XksmNLqloxsEYVj0uRS dP61wzKqibUqyeTIpr+5CE/F8J/h1cxdYeHHPhQgt3UPF1OMZAcEXpfbHasaA1dGmh Y9rjWWlBIon+Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 267C65F92B; Mon, 15 Sep 2025 04:47:23 -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 Oc6aTh5hLw2u; Mon, 15 Sep 2025 04:47:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933242; bh=hgqzAJyFZkNQk9QR1t2L7zyWDkGeZnWa7KbS0SjaXb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SSmyiv0bD9f0mmwtIxteKX2FPHVEs0EmrIzvfuDyBe3uBFdtJN8o0oPbJt70rlrmz hR0b/aVRtpH+Sl+gH0xvg1kE35VIMjHC4qR5Ij/kXRnNNHPaQeYtZ3soUzmhAJliVP gO+euq8OgD7NZ1cJBHX2M+pAvYjI9fMuXx64Ep65S78O1unCZ9/iKj6EqPZHzNqWmW zy3H8ay8xa400m/xUfKEi8oN4wp/UmKpbInVinIU+Lp5BbsapDXeuHAqYiWbL7mdEw JWvFm7I/r4rRHyToMwJ/AjhPA9HH1aSyrcxrQubby2BBEtFND2NG1g1XUXOXtqNUKm mXB362AtMNNYQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 839B367A99; Mon, 15 Sep 2025 04:47:22 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:43 -0600 Message-ID: <20250915104705.937780-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: NTPMIDYDOZC467DLAQNDZ3Z4FRQF3NCB X-Message-ID-Hash: NTPMIDYDOZC467DLAQNDZ3Z4FRQF3NCB 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 02/17] sandbox: Add a way to set the window title 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 new option to set the window title for U-Boot sandbox. This is helpful when different sandbox instances are used for different purposes at the same time. Signed-off-by: Simon Glass --- arch/sandbox/cpu/sdl.c | 3 ++- arch/sandbox/cpu/start.c | 9 +++++++++ arch/sandbox/include/asm/state.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index ed84646bdab..5a323a607f1 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -157,7 +157,8 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp, log2_bpp = 5; sdl.depth = 1 << log2_bpp; sdl.pitch = sdl.width * sdl.depth / 8; - sdl.screen = SDL_CreateWindow("U-Boot", SDL_WINDOWPOS_UNDEFINED, + sdl.screen = SDL_CreateWindow(state->window_title ? : "U-Boot", + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, sdl.vis_width, sdl.vis_height, SDL_WINDOW_RESIZABLE); if (!sdl.screen) { diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 556d1985ccc..43adc4cdb4f 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -187,6 +187,15 @@ static int sandbox_cmdline_cb_fdt(struct sandbox_state *state, const char *arg) } SANDBOX_CMDLINE_OPT_SHORT(fdt, 'd', 1, "Specify U-Boot's control FDT"); +static int sandbox_cmdline_cb_title(struct sandbox_state *state, + const char *arg) +{ + state->window_title = arg; + + return 0; +} +SANDBOX_CMDLINE_OPT_SHORT(title, 'W', 1, "Set the window title to display"); + static int sandbox_cmdline_cb_default_fdt(struct sandbox_state *state, const char *arg) { diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 1c9f45d18eb..af92f4e6fcd 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -189,6 +189,8 @@ struct sandbox_state { struct list_head mapmem_head; /* struct sandbox_mapmem_entry */ bool hwspinlock; /* Hardware Spinlock status */ bool allow_memio; /* Allow readl() etc. to work */ + /* Title to use for LCD window, NULL for default */ + const char *window_title; void *other_fdt_buf; /* 'other' FDT blob used by tests */ int other_size; /* size of other FDT blob */ From patchwork Mon Sep 15 10:46:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 302 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=1757933253; bh=LNGpMRo/PIb8+gM1LH+QZCFrDAxTr7pr+M5yQM+gWPY=; 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=fHFWGgovtkdnkFxBtsr1bjePoMipvIAFoE7FXgO1JOKbjCK1E0Rd5qtnDztqOLQMG Id9orOboHochlTy6Yxpe1q5NziMyREE57jr5Fj0I9O9gFqObitgTzL1rwt569yQ8jj zvd8/qcDwb9JMvqmvyAptXIchTWOTGLR4PWXCWaA+21xTptrsDihLiPf2+6rmHOv28 D6D6B7pyy0iWgfidF6H/K8d+1B0u8WiG40FDCEq0+4IDLiziLkgUCCsb29mAn+VlMD xq55mhVIVfK4a+ja9ocXpFxfUxTFDyL06ZFDxedQz+MJIuClrwZh8XH7wzmavqBfLB NBaPvcHRm71pA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 18A2267BAF for ; Mon, 15 Sep 2025 04:47: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 10024) with ESMTP id TDgST-t0q0Zw for ; Mon, 15 Sep 2025 04:47:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933253; bh=LNGpMRo/PIb8+gM1LH+QZCFrDAxTr7pr+M5yQM+gWPY=; 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=fHFWGgovtkdnkFxBtsr1bjePoMipvIAFoE7FXgO1JOKbjCK1E0Rd5qtnDztqOLQMG Id9orOboHochlTy6Yxpe1q5NziMyREE57jr5Fj0I9O9gFqObitgTzL1rwt569yQ8jj zvd8/qcDwb9JMvqmvyAptXIchTWOTGLR4PWXCWaA+21xTptrsDihLiPf2+6rmHOv28 D6D6B7pyy0iWgfidF6H/K8d+1B0u8WiG40FDCEq0+4IDLiziLkgUCCsb29mAn+VlMD xq55mhVIVfK4a+ja9ocXpFxfUxTFDyL06ZFDxedQz+MJIuClrwZh8XH7wzmavqBfLB NBaPvcHRm71pA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 07EED67B65 for ; Mon, 15 Sep 2025 04:47:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933250; bh=/AKWSJ8K1QYzXDNnZG4tN03yyyIVBn4DvrQYBtwRmj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cpti4CboaLBFlerN4Rd2PZyA0X6Aq3Ua3RIlUjkkU8BURVk8eYDkoU9aOChT/zqvH c4g8y4c4t65hz4YoZgSc6ZNcykS4D07dqnf/or+FNGZoCiXp+mXNP9eoFy+QZ4PNlE LqnbhEZzMLMlg8P7i7RnTrnHCBMWrVZQkg31eovnE8j7t9J77CfBgGrb6dy40cOeDl QsTk/c3KnlipLGbcHpwJDK3/Rtvubg52/dtca5Oe72bpipA0F59LYutCap7tMA2iql WV5fOvFtbeUTf6pyCAYUd98S1Gy8bvt2M8BZ+LCt0P/f0eeeKpzFlfSSxjTbtGghHz TDecZ8AC/W91Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D8E7867B04; Mon, 15 Sep 2025 04:47:30 -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 K77bfeNRHqnI; Mon, 15 Sep 2025 04:47:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933243; bh=sznoyxPpcJsZu0NPX1eDUN7Fg2/x2H9J9LLrv673O/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gf/bTnKfTwEA2xyyIJTrdEWVOKyCGJzAeE0l422l1/Uxn6Ij2/NXtCwk8Z97lAwwB EVgDnmbwm7+YmmaLm/q2Dl6vyA4AhITYF4XIWMOWwUwGXfT8M+dO9tbZJXdyo9rywz bHdPOclkKj8bbIimo3SAHwsAueXu97JU+OE1oKDYcUHVlW4I6aTIleMOMCv+Ymmxhl JqMYxiUmt3pCBds1/NJblFKqxL7ryQnLfAMry/Wp6TFlj0ZtIX1In2UWargKnvjO40 AeQwhrWvkEXkRZjQQnjh7TlPpnHCIXz7/xa0VWTo8BS+CEiGdgcTj80y1WsIWzGI9+ s2QUQbGqpirLw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6626E67A99; Mon, 15 Sep 2025 04:47:23 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:44 -0600 Message-ID: <20250915104705.937780-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: IEWJJXFY5LDF4E6ADJPVPETIPFWO3IKW X-Message-ID-Hash: IEWJJXFY5LDF4E6ADJPVPETIPFWO3IKW 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 03/17] test: Add newlines at the end of the img functions 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 The functions which create images lack a newline at the end of the file. Add one, for consistency. Signed-off-by: Simon Glass --- test/py/img/android.py | 2 +- test/py/img/armbian.py | 2 +- test/py/img/cedit.py | 2 +- test/py/img/chromeos.py | 2 +- test/py/img/common.py | 2 +- test/py/img/efi.py | 2 +- test/py/img/fedora.py | 2 +- test/py/img/localboot.py | 2 +- test/py/img/ubuntu.py | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/py/img/android.py b/test/py/img/android.py index 44d15fe35a7..a703a68f790 100644 --- a/test/py/img/android.py +++ b/test/py/img/android.py @@ -143,4 +143,4 @@ def setup_android_image(config, log): print(f'wrote to {fname}') - return fname \ No newline at end of file + return fname diff --git a/test/py/img/armbian.py b/test/py/img/armbian.py index 4db40fd5070..e1ae9b0aae9 100644 --- a/test/py/img/armbian.py +++ b/test/py/img/armbian.py @@ -129,4 +129,4 @@ booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} img = DiskHelper(config, mmc_dev, 'mmc', True) img.add_fs(fsh, DiskHelper.EXT4) img.create() - fsh.cleanup() \ No newline at end of file + fsh.cleanup() diff --git a/test/py/img/cedit.py b/test/py/img/cedit.py index dd6c5de44bb..564cb985dc1 100644 --- a/test/py/img/cedit.py +++ b/test/py/img/cedit.py @@ -22,4 +22,4 @@ def setup_cedit_file(config, log): expo_tool = os.path.join(config.source_dir, 'tools/expo.py') outfname = 'cedit.dtb' utils.run_and_log_no_ubman( - log, f'{expo_tool} -e {inhname} -l {infname} -o {outfname}') \ No newline at end of file + log, f'{expo_tool} -e {inhname} -l {infname} -o {outfname}') diff --git a/test/py/img/chromeos.py b/test/py/img/chromeos.py index 6217b5310f1..24884402c92 100644 --- a/test/py/img/chromeos.py +++ b/test/py/img/chromeos.py @@ -151,4 +151,4 @@ def setup_cros_image(config, log): with open(fname, 'wb') as outf: outf.write(disk_data) - return fname \ No newline at end of file + return fname diff --git a/test/py/img/common.py b/test/py/img/common.py index 80f9c124fc8..c9be6a22362 100644 --- a/test/py/img/common.py +++ b/test/py/img/common.py @@ -85,4 +85,4 @@ def setup_extlinux_image(config, log, devnum, basename, vmlinux, initrd, dtbdir, img.add_fs(ext4, DiskHelper.EXT4) img.create() - fsh.cleanup() \ No newline at end of file + fsh.cleanup() diff --git a/test/py/img/efi.py b/test/py/img/efi.py index fbb39c24063..8239b4c247f 100644 --- a/test/py/img/efi.py +++ b/test/py/img/efi.py @@ -34,4 +34,4 @@ def setup_efi_image(config): img = DiskHelper(config, devnum, 'flash', True) img.add_fs(fsh, DiskHelper.VFAT) img.create() - fsh.cleanup() \ No newline at end of file + fsh.cleanup() diff --git a/test/py/img/fedora.py b/test/py/img/fedora.py index ffa546d1cfe..8d3407d065e 100644 --- a/test/py/img/fedora.py +++ b/test/py/img/fedora.py @@ -32,4 +32,4 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl) fdtdir /%s/ initrd /%s''' % (vmlinux, dtbdir, initrd) setup_extlinux_image(config, log, devnum, basename, vmlinux, - initrd, dtbdir, script) \ No newline at end of file + initrd, dtbdir, script) diff --git a/test/py/img/localboot.py b/test/py/img/localboot.py index 62a65f33cf0..e83a0cbaa82 100644 --- a/test/py/img/localboot.py +++ b/test/py/img/localboot.py @@ -24,4 +24,4 @@ LABEL local vmlinux = 'vmlinuz' initrd = 'initrd.img' setup_extlinux_image(config, log, mmc_dev, 'mmc', vmlinux, initrd, None, - script) \ No newline at end of file + script) diff --git a/test/py/img/ubuntu.py b/test/py/img/ubuntu.py index 4fe54cb679b..06e8251c05b 100644 --- a/test/py/img/ubuntu.py +++ b/test/py/img/ubuntu.py @@ -44,4 +44,4 @@ label l0r initrd /boot/%s ''' % (vmlinux, initrd, vmlinux, initrd) setup_extlinux_image(config, log, devnum, basename, vmlinux, initrd, dtbdir, - script) \ No newline at end of file + script) From patchwork Mon Sep 15 10:46:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 303 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=1757933255; bh=GD0TEqodCBFZj6y7PyMQChY5jcPiOCTMBSQYUf5ks44=; 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=D6I8WmnhGseC+syjqyL+J4at8uEdYzkbYTk+pw0yeUdU+t8TS6m5uSa430abcSRFO deM68ZeI5bKCj7EB8O53mziRTgZwl8K2NRPksSaruvtot3ghEanPlKnB9kxV0f0vO+ wdcr7TXAqNGkd4lEUEIsjNwgyveaP9pVgJHlp15umY0+W2pRNGukVLAFfZytk/moHj dcSftkLX07ti0B7S1Nb1JK4h5Ma5Hs+XPZmyvgk1gZHM4r0Eq30eZOf5dkL1Yulh70 18yVP96yYS9C4KMsykQfTcw3LUUX6bXAc9VhjCU7nZqhN7K6BEvxuZ8NvA2ChaddyE QGJNPP0lnHPSw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6EDCC67A99 for ; Mon, 15 Sep 2025 04:47: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 i69JpYATyiki for ; Mon, 15 Sep 2025 04:47:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933254; bh=GD0TEqodCBFZj6y7PyMQChY5jcPiOCTMBSQYUf5ks44=; 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=Jx38O9Dyxx9JV9x3nxeYSUGIFgC01YOADesk2wqKB9+l2i4ceRz+WGa0dxUyg/5n/ si5gVo2kjukS4AYFS1sZv9vwGiuQfXx83BgBXtiWjZdoIzyjP1O53OAAvzqE7yQloS 0oFQjwwu0Bim42Kc9u3XODU6tlDCDgi9CK4AWfWsho7DXjP1rfoVl/cjrBr2xzkpOT gKVFAsqqyx8UP7Ni1M2DECs/7M3DC10lRZCXGnHSquTfS4Tg7w2k6tzeY+b3BlaSdV K1YT2shiFEiwZPu0kRl8rh5ZPxirYpGGJv2+0bUE/561zbtdHaNJcQYQOUmtHfMv9l 9WfQp6oBHClRg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DD30A67B44 for ; Mon, 15 Sep 2025 04:47:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933252; bh=HcjFKArwUt7N1cVSggotzVo10hGKIjhDo1GrLaEeDzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r0ZjTUw+7F8T5WSIEgfCwmcp/666lDR06XDaM+6GjQvgOJRu4a5g0aQXYar8chGo2 EOKBdFt3K3C/C/1GF5/97lqOZLLqHRkmxR+z/QQsh3BcLWl67pmKhRrt5CKifue/K1 pP+HJFa9cnHrA0hMEsc1VhMo5KN85cnjnOc4RFQJ3r4L9AMgcMDr6eNQOiEOqL2aoe KepSbbhH23GggFUqHEiXJDxXZRZaVHPAUf3YjEo/NSb9PSgkmWkR99ilwUBuK+3wom 0J8QnDG8RfUsZIMmjv5hC5CQEuntoXWPEjaTAAkz9UedUe+xg6sAOnuI7Tkk0XKV8D HD4xrNRrBqTTA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9E85D67A99; Mon, 15 Sep 2025 04:47:32 -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 XyGpPTfkOJiP; Mon, 15 Sep 2025 04:47:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933248; bh=HRngLDD2DdoybvKKUyAqfy8BcU2zq5s4sMdcBVttHhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LwKwqVNWKcNgoKCplcGqUnVXhLHwgCNXALQRqy3ju/VBgrXwDMtd+LkiPoTSndiTI 6N86hc+1Igxs/uAfxG3Pze068e5UhhD/nPHZmweTWvrtuh4PG1O5/GVoDtAr2PuNn4 2ZOGj645zFrkaGEEs+1qSObInvZe2H7tAIfL85SE2z82g2WRnqYfJQOpSTXvV6F7r0 iiirzJCQ+dnR+EkLO8kYPl0DufNCo6ufPM2W8IGhozZHR3xT78w3L/RDLXotw6jitT c0cXXUi9U1PsvgjaXutAQyBBJaqQyuRO4UT+zeZiFccCb//PmSk1Z5drw4UzPNGMyM 9xorNIpG5NBTA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2336367B44; Mon, 15 Sep 2025 04:47:28 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:45 -0600 Message-ID: <20250915104705.937780-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HUZGM4ZB3O7MDSKKLNWED6UQL2ZCWXFS X-Message-ID-Hash: HUZGM4ZB3O7MDSKKLNWED6UQL2ZCWXFS 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 04/17] 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. Disable input for the tools-only build, since it is of no use there and causes build failures. Signed-off-by: Simon Glass --- MAINTAINERS | 7 ++++ configs/tools-only_defconfig | 2 +- drivers/input/Kconfig | 9 ++++ drivers/input/Makefile | 2 + drivers/input/mouse-uclass.c | 29 +++++++++++++ include/dm/uclass-id.h | 1 + include/mouse.h | 80 ++++++++++++++++++++++++++++++++++++ 7 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 drivers/input/mouse-uclass.c create mode 100644 include/mouse.h -- 2.43.0 diff --git a/MAINTAINERS b/MAINTAINERS index 5d05281633d..e858331455c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1251,6 +1251,13 @@ S: Maintained T: git https://source.denx.de/u-boot/custodians/u-boot-i2c.git F: drivers/i2c/ +INPUT +M: Simon Glass +S: Maintained +T: git https://concept.u-boot.org/u-boot/u-boot.git +F: drivers/input +F: include/mouse.h + KWBIMAGE / KWBOOT TOOLS M: Pali Rohár M: Marek Behún diff --git a/configs/tools-only_defconfig b/configs/tools-only_defconfig index 9e4866b494c..f3c35e1a8bb 100644 --- a/configs/tools-only_defconfig +++ b/configs/tools-only_defconfig @@ -5,7 +5,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sandbox" CONFIG_SYS_LOAD_ADDR=0x0 CONFIG_PCI=y # CONFIG_SANDBOX_SDL is not set -# CONFIG_ULIB is not set # CONFIG_EFI_LOADER is not set CONFIG_ANDROID_BOOT_IMAGE=y CONFIG_TIMESTAMP=y @@ -30,6 +29,7 @@ CONFIG_NO_NET=y CONFIG_AXI=y CONFIG_AXI_SANDBOX=y CONFIG_SANDBOX_GPIO=y +# CONFIG_INPUT is not set CONFIG_PCI_SANDBOX=y CONFIG_DM_RTC=y CONFIG_SOUND=y 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..7ed7eba3e8c 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile @@ -15,3 +15,5 @@ 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 diff --git a/drivers/input/mouse-uclass.c b/drivers/input/mouse-uclass.c new file mode 100644 index 00000000000..f42ef346c5c --- /dev/null +++ b/drivers/input/mouse-uclass.c @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019 Google LLC + * Written by Simon Glass + */ + +#include +#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/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..c96c63918ea --- /dev/null +++ b/include/mouse.h @@ -0,0 +1,80 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Mouse/trackpad/touchscreen input uclass + * + * Copyright 2020 Google LLC + */ + +#ifndef _MOUSE_H +#define _MOUSE_H + +struct udevice; + +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 Sep 15 10:46:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 304 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=1757933257; bh=YHfiYQ3vfrqdjEFAZR6fD+BBRlnRg16s7w5NbZMhYPU=; 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=mRSdkOWU5VyX2IRLSuPUCA4HLW84/34EEeygK72Dox37/tB9+R/5/JFyEIP93qgRp QhPSUG1tmJRw89G7EB2hFd1sOoonGfShx1Dh4Uk3Hr/sF1yNNJKzpdG1TmzTvmxb5N du1b4GI5tPTX29O3mGtXVxViDwnLtnpFKZ+beCQmEmIW/Ju7inCo6iE1qtwlelvvg5 kjm2bTUzoui5dETOhk/xxHCdpXtkvA0eaEUeJHF6aEHRUVjskU0f66nlI7uSX0lTHz hwAM3ZwGT4PZDU1l1zioBZBp717WHlhFm/R5byzaRcDETYDPzjHnlo0kwoKcaY+8Mw uz+IR5s4qzC9Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A834A67BB5 for ; Mon, 15 Sep 2025 04:47:37 -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 SnP23wWB_yFT for ; Mon, 15 Sep 2025 04:47:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933257; bh=YHfiYQ3vfrqdjEFAZR6fD+BBRlnRg16s7w5NbZMhYPU=; 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=mRSdkOWU5VyX2IRLSuPUCA4HLW84/34EEeygK72Dox37/tB9+R/5/JFyEIP93qgRp QhPSUG1tmJRw89G7EB2hFd1sOoonGfShx1Dh4Uk3Hr/sF1yNNJKzpdG1TmzTvmxb5N du1b4GI5tPTX29O3mGtXVxViDwnLtnpFKZ+beCQmEmIW/Ju7inCo6iE1qtwlelvvg5 kjm2bTUzoui5dETOhk/xxHCdpXtkvA0eaEUeJHF6aEHRUVjskU0f66nlI7uSX0lTHz hwAM3ZwGT4PZDU1l1zioBZBp717WHlhFm/R5byzaRcDETYDPzjHnlo0kwoKcaY+8Mw uz+IR5s4qzC9Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 49C5167B04 for ; Mon, 15 Sep 2025 04:47:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933255; bh=gAF92bNdTK9cHr2lfOshluGkMNeQg0r8s1w8Qw+HaPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Na9SgGEUrqPzJ/IYbH4D636puDtAEGYRsPR89IR0Wsk5XUrvdsGa1B3BXU/BmFi7r 5oJ4+vmIG7AZI9MD8f2k1TVlH2XzMsFZid6Wexq4D0Vn7dQp0KyCYvxtywYaLfyTjx ChS3QqlXX5zWxhDTxtIwabOa9hHsEsKwQGGkXDHZxbe4MFwziUxie4wqkEXeleK1+X 1C5WHzEPoM/CU7sFFLalj2Oq2t24YgqD443vY9D8wGyF5gN/1yjKo2suVnjADMjtMB A07mmVyNeZn8z4b6GgSCF2LTQ5uD/Taxp0QnBjFxpP5fTEfLBmcpY4vNpQAfUcMz0h 8zxQNwmFZNofw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4FEE867BBC; Mon, 15 Sep 2025 04:47: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 m8Tkv8GCaWsi; Mon, 15 Sep 2025 04:47:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933253; bh=KeTD5IUtLk5S2xsqsUALndGUCzSL9EAGdbS7Sb5/w00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jc1ajGggUpSwQgzIHuKyfF1a8F79ukqP9MKKbokJzdkKZp4zPbJCC/dwJiF0iAyZj Pk5+9DcOWgNjIGPLXn0WJMTVEP362WYLXlhXkhojlRgPcUhwoyn6dGGOTumsaPjQ3B JLKXsIZqfcTbMfIUgaCIOi2Yvhtl2lwC3aVjKxJSiam+74lnV8vzCHwiADgVp5VFO7 nPsAKy8b8nZq7Z2WccKRR/t780gB3fSrqpJZyYZ1usQeFBM5MdmT/DU3TpC7+rxiO6 B4ymVuVMdElZX9eEWubAYBUcPx/XNItuAwxv55EZXKWs1z+ZpO+5cb35IMZmh6GvHu 4MFE1d0Ne0rNw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E128867B04; Mon, 15 Sep 2025 04:47:32 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:46 -0600 Message-ID: <20250915104705.937780-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CXF6IAUNEEDIZIMUZIUZMTABV7ULG5X4 X-Message-ID-Hash: CXF6IAUNEEDIZIMUZIUZMTABV7ULG5X4 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 05/17] 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 | 43 ++++++++++++++++++++++++++++++++++ arch/sandbox/include/asm/sdl.h | 9 +++++++ 2 files changed, 52 insertions(+) diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index 5a323a607f1..fa431010b11 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -67,6 +68,7 @@ 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) @@ -84,10 +86,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) { @@ -522,6 +564,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..86368c8a0a6 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) @@ -157,6 +161,11 @@ static inline int sandbox_sdl_set_bpp(struct udevice *dev, return -ENOSYS; } +static inline int sandbox_sdl_get_mouse_event(struct mouse_event *evt) +{ + return -ENODEV; +} + #endif #endif From patchwork Mon Sep 15 10:46:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 305 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=1757933261; bh=0AWAX+ZEIHtc6n45NAyYkg7PdX08XY1nvjQCaS0j4I0=; 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=nHSpRO/es6Qucu/8VfxpblHRiAM6yYzkuRICTtKNQC+ZYbLcbj2bfrbXbBeT04ej0 vVjWgQxxX7f062KWQefU0690wS0MTZEUKjJ5AMk/pfU+fUghprEYaKi54VRGChO1sR 9lg/bNb/6GhZOfPVOQaBSNWwq4DpXCq7C6VffRnAbLRlGRMaB8jM/rJvSOcTJcOIwC NIRaloy62V2EQnTemzG/mTqD7zv+1xT+oybRofDrBMaY63R1QT1O9lc4Qv8QZz9CqR tNFMrEPx6hHMK29UCuqa1581lqyEGjy1d70QeihijdpqsBGEz8ocMkR7R2t1JOqTi0 3t7N2jQ0fAr/w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B3E2967A99 for ; Mon, 15 Sep 2025 04:47:41 -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 DHtB3IytF1Fr for ; Mon, 15 Sep 2025 04:47:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933261; bh=0AWAX+ZEIHtc6n45NAyYkg7PdX08XY1nvjQCaS0j4I0=; 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=nHSpRO/es6Qucu/8VfxpblHRiAM6yYzkuRICTtKNQC+ZYbLcbj2bfrbXbBeT04ej0 vVjWgQxxX7f062KWQefU0690wS0MTZEUKjJ5AMk/pfU+fUghprEYaKi54VRGChO1sR 9lg/bNb/6GhZOfPVOQaBSNWwq4DpXCq7C6VffRnAbLRlGRMaB8jM/rJvSOcTJcOIwC NIRaloy62V2EQnTemzG/mTqD7zv+1xT+oybRofDrBMaY63R1QT1O9lc4Qv8QZz9CqR tNFMrEPx6hHMK29UCuqa1581lqyEGjy1d70QeihijdpqsBGEz8ocMkR7R2t1JOqTi0 3t7N2jQ0fAr/w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A0DB167B22 for ; Mon, 15 Sep 2025 04:47:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933259; bh=k/p1EIyY5J5+U8o52M0p/G0CaWbhr/2sJzndivUCOW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IP5hBDIJGY9KBUwRxGyiMzHqJq0VpErSW4PmwbEikp5Ha3zdNZkprtxEXzHhtQP5a aIHdO+6JOSYU40i2bXfTGFFWg5dhDDNsiRVt5DS6MK8zHi1gPyqmg1jmvDP54pxjHu kEijljy5FZENaXVOY6qK2AM7cgmDSu3G4AH6rHHV0zubN7UtQ1UQr7rSvZLxgWaGPJ 6cZuWI2Buoaj3dQaBcILx+/6+Ija1+jzgABk2wQkb5r2K1mRAcLToINIoWtcZ5fHqZ 3itTlcFoumoKbZO9/1mFa0IMyb/L0M6lNyilVlHn7aoZPRtP0pMkv43kABUrNIGYLu IoPoOzr8pr9Xg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E442467B22; Mon, 15 Sep 2025 04:47:39 -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 tu2cSCNuN623; Mon, 15 Sep 2025 04:47:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933254; bh=mFk8lnFf6xamZ62rXEoLm6ZuQHsWxuRpcXer8UxXfWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dW32LYBBTVwlrEZzSAbPumqrKsbzLmrQXz4cOGboZqny3B2LoM9izOTmy2L7Ol6Fo LK5KETbZrQ6/ugbtaGbi78aGeY+YqPRzcGl/pTGsOKMm0NdqnS/pstRV2hCRqguMrM VfGXTzttkcrHx+cWqJLcgdcuBdLS/QDrWCPi3ABW67mOR1Gg3v907b13piIRfqeuqP pwUHJIlw5qqNj8YLsnlBKSm/o27CMdgTkFCR5vzEso3QQAMcbRvr4WhbAxCLGbTikM WuG8wag5EkEO2bmRDg7+oiXPMi/++mAc8PFe2gFpOFx5aNMxp63RNWs/sax+eBTsnA fBdqS+/7jfdkQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C6C5E67BAC; Mon, 15 Sep 2025 04:47:33 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:47 -0600 Message-ID: <20250915104705.937780-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5KKLGPUZZPR7SG22QZL6KU5ZCMZKW4CD X-Message-ID-Hash: 5KKLGPUZZPR7SG22QZL6KU5ZCMZKW4CD 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 06/17] input: sandbox: Provide a 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 sandbox driver for the mouse, so it can be used as an input device. Signed-off-by: Simon Glass --- drivers/input/Kconfig | 1 + drivers/input/Makefile | 3 +++ drivers/input/sandbox_mouse.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 drivers/input/sandbox_mouse.c diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index 6bfee40ccac..101257f9767 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig @@ -103,6 +103,7 @@ config TWL4030_INPUT config MOUSE bool "Support for mice and other pointing devices" + depends on INPUT default y if SANDBOX help This allows U-Boot to access mouse input, typically needed for diff --git a/drivers/input/Makefile b/drivers/input/Makefile index 7ed7eba3e8c..8c5a395a540 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile @@ -17,3 +17,6 @@ obj-$(CONFIG_TWL4030_INPUT) += twl4030.o endif obj-$(CONFIG_MOUSE) += mouse-uclass.o +ifdef CONFIG_MOUSE +obj-$(CONFIG_SANDBOX) += sandbox_mouse.o +endif 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, +}; From patchwork Mon Sep 15 10:46:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 306 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=1757933263; bh=wnImVK8vmyAo5avOV6rn4L0+iCj3j8NlxKnXNtrG02g=; 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=ouOS8dt5genR8MUg34TaG9YbOY8pI1jpDYTNwviiSqx2g0eOBP7uN5VZ3NAo3ajt7 bSFXkRgob2jXV2R7RHPoATlnZMU25hIHi72uuPrT3fSiQV5oBK/s+gNbItttR/OIfB C0IRkamrU+Q16nOkROkzakSMGETIxzeyamQ+mS/K2GPP0fisuXep3g6kxBv+fh9Hf8 fLoVwdUL9B5nBhgltOYyUIwgG4KH5Xmh9W6vw0hNGjddE/AO2OJf6Q3p4JDBH/K1tt NWCc5qatCIXc38pQQeao/M0G24e7yNaZYR519jfaYFkl4ETH+6LvxBbLPtct75vu9N AP/mvYtQ6Mi2A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2AC3967BBC for ; Mon, 15 Sep 2025 04:47:43 -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 TA1JeELSGZH2 for ; Mon, 15 Sep 2025 04:47:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933262; bh=wnImVK8vmyAo5avOV6rn4L0+iCj3j8NlxKnXNtrG02g=; 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=Kbf7igiJteKdDLtbdKMDtLc1xupFSxzIn+ve5bOG5WR1M7Iv6CCARF/EjbK8WQvmg +vAGjkcBZwoKaA2t8Jw6GuAHfbOzJ1R8Oivw3vxKnZQSG4Yrkb8dnCMQ99wzlM8WWb /7pz2JpENt/5QPlgvsl7Udq0KszoeGOPPjARiy5ugMHbIXyO018tNEr578i6Ty5yhq krcIxboUhhY7ZMEeRs6FaCbxX8NkWdIBVZvL3BpDjP/MkJ6/gVFtaAhhkLZJCbzOPr hCnOyOaGBnXpO+f6F9Uspojpm+K2jQ/y9yqmpwpue5/FgE1D9+D0aeV0jsLZ8N/ykP 4hAfdyx617SVg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 17F4067B44 for ; Mon, 15 Sep 2025 04:47:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933259; bh=2/H0mYbwwyx7MCjnqjRGVLNlGnCswU9CtrZrVYy+0HE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ahl7lt01wrO8pB9VBXX7+wrW15Ff6QRpFr5nfnghjA8XfuVNFElGTyfe86C2UOitr A4+CIiEHeTAZ3GamoXkpORkpIMLy+BL6Cwlnhf7Q4+PSQagQimvKqL9jdXYEX4fyb6 yViGV9ZKfY++FAjtZrv6YToBKTFIenEiWKtPyzkQJBUe6pypdjPBriknNqVJCOrGXG +C0ShOTBLzlHKJrGa8XCD8SYTF0XWJnlUgCCGF0Cw4pyigjLsw6CeEyrtNtp5bfTV0 uJLUPgKKVGbePHr/giz/Z6ORcUvd08Pe3SHEBT/PQsZO52JHU48AkUG0Hjyt1jT0Kx CUq11GVxoB4YA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E512E67B3C; Mon, 15 Sep 2025 04:47:39 -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 HCGAwPu57Q6j; Mon, 15 Sep 2025 04:47:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933258; bh=4m9PtwHSHLdCXo46f9HIA5z6gpiSkgLZdGFgFdFJAao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CQ0Zo5P+XJRSpRwGS7A2m/6CXp44VcRmaH+2SSvenupjaFcoRL22f2+cj6URrxUvh Rmklz46eLSsaAhwP7Q8iyggrV00HS9Mcbp923voEgyaP1Ppv3W5EqsSOzu6w9axvzu YXYR9wJjh6LhsMD9QdlhxSlrRvwV9mQCDKQ05ix0ZVS8B5DvWeWzFIUee5jB9ELHNB e27hSVRp999UwA+BVfLQY3UV2ILXBAgpv+OWINJqagRvsgQDGlutGM6BIyjjbXsk0c NdghURY9ShlhIMwx3/0Q3hOi5Y/WPk/a/qYZ97VY/lg1cod/8NfYhHrq8r/WGrxfDt MeBhLBlyQBGbg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5E4B767A99; Mon, 15 Sep 2025 04:47:38 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:48 -0600 Message-ID: <20250915044657.7.Ifebe6452f38904689e3e2142fc08a623131ed0de@changeid> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZCBBKAHMORSZ5OMCCWVV4H75BC6UMVLI X-Message-ID-Hash: ZCBBKAHMORSZ5OMCCWVV4H75BC6UMVLI 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 07/17] 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 | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 cmd/mouse.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 8037827930b..af79770b4c6 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2971,6 +2971,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 75ef9fab922..1d65703b625 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -129,6 +129,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..60210b9f868 --- /dev/null +++ b/cmd/mouse.c @@ -0,0 +1,69 @@ +// 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 Sep 15 10:46:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 307 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=1757933267; bh=XXNBh8Ln3BmGTcNpVJTFqzARRgCLxBzzEVTj3K8LYh8=; 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=te4tBKi9yA5wjdfRWhBubj3XK7DW4P57+LC3yM+HP/dGgBCtlpaT1IgqrNEmai2oj 97307JNEcVkhLS+Bk8hDSr5pHtkk5c8z8aK4MsSkfHMAYAqGq+E0Ok2jKOiZt0fZSe uN/I7+YyokufBi9yJyD6XQ2zzPd0MRNxxWTb7DoOsZHfFgV+1RnzyPfVaU+wMKocAA D0p1KYMHZKInyvlL8WlsLcpXi+vdSpbwaC5vEW4919wpHrtB95W3MAbLr62h16ejpk 8zM7p6L4HckBiS4yVQBND9zDCfHDrfZ5YyX+RNEfi73cAAERVaMn8WxvS1D0ETSl4x Zomqh2Y7AIcxQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 812B767B44 for ; Mon, 15 Sep 2025 04:47:47 -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 X3Qkc8QKxVAH for ; Mon, 15 Sep 2025 04:47:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933267; bh=XXNBh8Ln3BmGTcNpVJTFqzARRgCLxBzzEVTj3K8LYh8=; 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=te4tBKi9yA5wjdfRWhBubj3XK7DW4P57+LC3yM+HP/dGgBCtlpaT1IgqrNEmai2oj 97307JNEcVkhLS+Bk8hDSr5pHtkk5c8z8aK4MsSkfHMAYAqGq+E0Ok2jKOiZt0fZSe uN/I7+YyokufBi9yJyD6XQ2zzPd0MRNxxWTb7DoOsZHfFgV+1RnzyPfVaU+wMKocAA D0p1KYMHZKInyvlL8WlsLcpXi+vdSpbwaC5vEW4919wpHrtB95W3MAbLr62h16ejpk 8zM7p6L4HckBiS4yVQBND9zDCfHDrfZ5YyX+RNEfi73cAAERVaMn8WxvS1D0ETSl4x Zomqh2Y7AIcxQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 70AF567B22 for ; Mon, 15 Sep 2025 04:47:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933265; bh=qxI5e2VHSK3jf1nwU/bPZKJiuaDQJxVf4i8tDolP18g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qVrKEjx1BAYf15tTGGpQOQMcL9LTsEfOId34uZkohKl2oGXl8gUhjpOK7QI1CxIn1 /+aEkYTUJnIDfEWoQQ6wyzTPKYJgv2qUcYRM8Wy6uHDIMkHisNK0zAoLOjGMgWqqu/ dhoZv34c9R8WQjcPA1k2hKt+7Nkb4pj8Ruk7a2lArq2WSQQ6Egw0GmCoWZzEoFXi1D 8nMg5GIrtvnu9I38ar4auv481oNYhVXkaRsYoVGhJdUybnIfZRLwIBUKhcyguFwHyN kO4GOImWQQx7gq6xL1NV3c0ThkhD3tVSIzWgilvSXqcutxT0c3qA+kMjfKxhDKiNZo mLOudVd67NYgQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6268367B22; Mon, 15 Sep 2025 04:47:45 -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 AUnf581b9oA6; Mon, 15 Sep 2025 04:47:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933259; bh=dw/xdNzqcxdeRbxI9Ha5lX4pwJIWzYZCgmXuF9Uq4To=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FpfLymd7ImyOWFGi3r9kOn6TBptjKN5+abYb1zzSlrDXZOqFzZDo+A1Cd2AqXmMmi 5G1fIdrgK08dw9B1I/RzHnCklRhggvqmw3SrkbR4SXE5l43ilCRvRzgWZ5jke0xBPu Enu++NhzQfTy7EIylslG0+yMk/+ExUu/r736j1pwiW+I6WN2C5dYhckaAFmLDamzKm g2VUGgnDRLFgVAR2ILDZlHssB2ob1t2SPL3F0jxxhZTW9/PCcVaV7SXJ1FuKSaZiUQ OiqAbyHtVoGmI91DKCT1vWOQr0z+fQaCbBbddxaQZHQFvb2n7R42jEQ0yqg8jjxLcw dMx51GyvfrNWg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 335A367B04; Mon, 15 Sep 2025 04:47:39 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:49 -0600 Message-ID: <20250915104705.937780-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: DNCOIC6M6S5U7VCEMPW3KE42LQAZF4CQ X-Message-ID-Hash: DNCOIC6M6S5U7VCEMPW3KE42LQAZF4CQ 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 08/17] 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 Provide a devicetree fragment to enable a mouse for sandbox. Signed-off-by: Simon Glass --- arch/sandbox/dts/sandbox.dtsi | 4 ++++ arch/sandbox/dts/test.dts | 4 ++++ 2 files changed, 8 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"; diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index b79f06ce0fe..6a199965d36 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -591,6 +591,10 @@ test5-gpios = <&gpio_a 19>; }; + mouse { + compatible = "sandbox,mouse"; + }; + mmio-bus@0 { #address-cells = <1>; #size-cells = <1>; From patchwork Mon Sep 15 10:46:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 308 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=1757933269; bh=OJfb1VnkQJgWyl+X8EkTOYlizx53+astXtsOXvZvSa0=; 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=QKKyu/2pEzLqyiBXrqqiuDaFU7+Dx5C7Z2YTqElt5ZEoHSi8kDKxArMvk+8SIQwW9 vLo3auHo3JuJbA3U5Gn5Uqx/QQkeaQxjz8qH6weygqRNHr1Hy9U40sjM3GUqWIoFBT xIX/G2KjnanBkKrZAHlik7f+OT21+GPYejyCJXXasRLusQh7znSVdVt9BtG+xmcd04 HMfP59eWtd6O3SdBgJxa7DGqLqkOGjdkff3tr3isMXEX0xLmpnd6Nlb3WioY8mP52l 7qxZaYNI+tFzuPkOR255zc5ajQtY4Y+xZdzlTxq9NTuXdCPORNwwhMkHFr5umX6l3e s2FzK/CWCyB7g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CDAE267BBB for ; Mon, 15 Sep 2025 04:47:49 -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 4aqmqp1HPxqC for ; Mon, 15 Sep 2025 04:47:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933268; bh=OJfb1VnkQJgWyl+X8EkTOYlizx53+astXtsOXvZvSa0=; 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=gzWqeqGFR44k8VLBOjSA+M8xXtkyBkReqhxWmLBDvJV75qjbRenkAjTxC+fRuVW30 fa5qQ6jQYUtD+g/gUcgmE4fFkUrGxqVsr0wmLrF/KL1mblMGwtMKFu+5/38AuUZbqH pCdKiX0U9dVNUlHirDyfVDW5UKz23ox4nWC3ZT+xVkBDu6zEr7foKHTEHccWWfT5TV Cw2Vl5lEsjwb90x2zSa8ypCJBBqF4sb8KW6iaQ2144HCtDtDrVqGXRxSO+BSnahL6B wdLtSLeAIrEA/N10kY2Y0sakOpnrnyZ3pAQwZ7iw9e89GZE5gd5S1Ijmd0oH+p0uRK aX4Hx6Hod6yJg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7C2A967B44 for ; Mon, 15 Sep 2025 04:47:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933265; bh=BwVJ6hSqTsoPbNUJLWZ5UwuGhPT+6fWDU1nzz8XZCmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QfFzn5IIM6WzPEDqmzeCbCTiyrTVKc0ch+lpeYMYKE/jrrgWQXtGVZZcjygp0xQ8w v1zWKbML03UY3UsY8aPtb+9q6cf/wnRRgJ0gjSUNZQSFxEOsZW4Sy1rmS1wmvlksBW iqHP5v8jsIKeaeVCR0ISK4aNXAU7uM9LaLt3fdxpko4tT3sTWxBj8Llbvcuwr5Iv/Y OQhelqWr6fblxVO0b2Zlm3oTUrVQWQTlwdUe0FeBjQY1aAsS5GkzbRyE9yJsTch7xG zkTT/nNgYnTD9VBxAIHCa9pUt/lzfgBo4lfcG8lKjoGGKtf6aYM7zMppVhRSLP2Ypa iMz6NE+iWoSVQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8E53467B04; Mon, 15 Sep 2025 04:47:45 -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 x_B6QIyrpzkU; Mon, 15 Sep 2025 04:47:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933264; bh=ceEBMVUibKm/cuUv0wFH2n58GZf/8/JS4nNA2dl7U84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kdo12FsKIQmIcpo7wVrE96FS4o3ytx7YvKbOVgO+tLFhxrt+BUNW3ydL2lqDE2IK1 GAWZkiZpZ+gJ1RFFl9UQdG12Y7at+jBotVuVrDvVZL6Py+U5T0pr12GONbWbliC4bs BBaTF/JpRL2O5h91TRThj2yM3vYHJA+V618qWFtNMQuUxuHAWQnYjMe1eyfYcKMRGS 10zOJed+cJLpjodvuw3h/xbBQATmB6/pj8iteeUPzb7k1HGeT7WA/oFu71u0ivLoLX y+YwLyTbuE2q/V1Asww7aWaYDAaWwCUR6WKM+zRwptBo6OSFWzfwpy0xLIkfxxdvLJ UFCIpL3xqExyg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B9E8667A99; Mon, 15 Sep 2025 04:47:43 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:50 -0600 Message-ID: <20250915104705.937780-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KOUEGV6WKTHZDGUXQGU7M7PNOU7454RT X-Message-ID-Hash: KOUEGV6WKTHZDGUXQGU7M7PNOU7454RT 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 09/17] sandbox: Provide a test for the mouse uclass 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 Provide a few simple tests for two methods available in the mouse uclass. Signed-off-by: Simon Glass --- arch/sandbox/include/asm/test.h | 17 ++++++ drivers/input/sandbox_mouse.c | 49 +++++++++++++++++ test/dm/Makefile | 1 + test/dm/mouse.c | 96 +++++++++++++++++++++++++++++++++ 4 files changed, 163 insertions(+) create mode 100644 test/dm/mouse.c diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index 4df39fac1da..499db42804c 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -11,6 +11,7 @@ #include struct unit_test_state; +struct mouse_event; /* The sandbox driver always permits an I2C device with this address */ #define SANDBOX_I2C_TEST_ADDR 0x59 @@ -361,4 +362,20 @@ bool sandbox_sf_bootdev_enabled(void); */ void sandbox_sf_set_enable_bootdevs(bool enable); +/** + * sandbox_mouse_set_test_mode() - Enable/disable test mode for sandbox mouse + * + * @dev: Mouse device + * @test_mode: true to enable test mode, false to use SDL + */ +void sandbox_mouse_set_test_mode(struct udevice *dev, bool test_mode); + +/** + * sandbox_mouse_inject() - Inject a mouse event for testing + * + * @dev: Mouse device (must be in test mode) + * @event: Event to inject + */ +void sandbox_mouse_inject(struct udevice *dev, struct mouse_event *event); + #endif diff --git a/drivers/input/sandbox_mouse.c b/drivers/input/sandbox_mouse.c index 4aedf0fdf2d..ba271242b1a 100644 --- a/drivers/input/sandbox_mouse.c +++ b/drivers/input/sandbox_mouse.c @@ -8,11 +8,29 @@ #include #include +struct sandbox_mouse_priv { + bool test_mode; + struct mouse_event test_event; + bool test_event_pending; +}; + static int mouse_sandbox_get_event(struct udevice *dev, struct mouse_event *event) { + struct sandbox_mouse_priv *priv = dev_get_priv(dev); int ret; + /* If in test mode, return test event if pending */ + if (priv->test_mode) { + if (priv->test_event_pending) { + *event = priv->test_event; + priv->test_event_pending = false; + return 0; + } else { + return -EAGAIN; + } + } + ret = sandbox_sdl_get_mouse_event(event); return ret; @@ -27,9 +45,40 @@ static const struct udevice_id mouse_sandbox_ids[] = { { } }; +/** + * sandbox_mouse_set_test_mode() - Enable/disable test mode + * + * @dev: Mouse device + * @test_mode: true to enable test mode, false to use SDL + */ +void sandbox_mouse_set_test_mode(struct udevice *dev, bool test_mode) +{ + struct sandbox_mouse_priv *priv = dev_get_priv(dev); + + priv->test_mode = test_mode; + priv->test_event_pending = false; +} + +/** + * sandbox_mouse_inject() - Inject a mouse event for testing + * + * @dev: Mouse device (must be in test mode) + * @event: Event to inject + */ +void sandbox_mouse_inject(struct udevice *dev, struct mouse_event *event) +{ + struct sandbox_mouse_priv *priv = dev_get_priv(dev); + + if (priv->test_mode) { + priv->test_event = *event; + priv->test_event_pending = true; + } +} + U_BOOT_DRIVER(mouse_sandbox) = { .name = "mouse_sandbox", .id = UCLASS_MOUSE, .of_match = mouse_sandbox_ids, .ops = &mouse_sandbox_ops, + .priv_auto = sizeof(struct sandbox_mouse_priv), }; diff --git a/test/dm/Makefile b/test/dm/Makefile index eab78d3ac4a..b38de3e12d0 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -68,6 +68,7 @@ obj-$(CONFIG_DM_MDIO_MUX) += mdio_mux.o obj-$(CONFIG_MEMORY) += memory.o obj-$(CONFIG_MISC) += misc.o obj-$(CONFIG_DM_MMC) += mmc.o +obj-$(CONFIG_MOUSE) += mouse.o obj-$(CONFIG_CMD_MUX) += mux-cmd.o obj-$(CONFIG_MULTIPLEXER) += mux-emul.o obj-$(CONFIG_MUX_MMIO) += mux-mmio.o diff --git a/test/dm/mouse.c b/test/dm/mouse.c new file mode 100644 index 00000000000..f9c2e88c43a --- /dev/null +++ b/test/dm/mouse.c @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Tests for the driver model mouse API + * + * Copyright 2025 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include + +static int dm_test_mouse_basic(struct unit_test_state *uts) +{ + struct udevice *dev; + + ut_assertok(uclass_first_device_err(UCLASS_MOUSE, &dev)); + + /* put mouse in test mode */ + sandbox_mouse_set_test_mode(dev, true); + + return 0; +} +DM_TEST(dm_test_mouse_basic, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +static int dm_test_mouse_motion(struct unit_test_state *uts) +{ + struct udevice *dev; + struct mouse_event event, inject; + + ut_assertok(uclass_first_device_err(UCLASS_MOUSE, &dev)); + + /* put mouse in test mode */ + sandbox_mouse_set_test_mode(dev, true); + + /* inject a motion event */ + inject.type = MOUSE_EV_MOTION; + inject.motion.state = 0; + inject.motion.x = 100; + inject.motion.y = 200; + inject.motion.xrel = 10; + inject.motion.yrel = 20; + + sandbox_mouse_inject(dev, &inject); + + /* get and verify the event */ + ut_assertok(mouse_get_event(dev, &event)); + ut_asserteq(MOUSE_EV_MOTION, event.type); + ut_asserteq(0, event.motion.state); + ut_asserteq(100, event.motion.x); + ut_asserteq(200, event.motion.y); + ut_asserteq(10, event.motion.xrel); + ut_asserteq(20, event.motion.yrel); + + /* verify no more events are pending */ + ut_asserteq(-EAGAIN, mouse_get_event(dev, &event)); + + return 0; +} +DM_TEST(dm_test_mouse_motion, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +static int dm_test_mouse_button(struct unit_test_state *uts) +{ + struct udevice *dev; + struct mouse_event event, inject; + + ut_assertok(uclass_first_device_err(UCLASS_MOUSE, &dev)); + + /* put mouse in test mode */ + sandbox_mouse_set_test_mode(dev, true); + + /* inject a button press event */ + inject.type = MOUSE_EV_BUTTON; + inject.button.button = BUTTON_LEFT; + inject.button.press_state = BUTTON_PRESSED; + inject.button.clicks = 1; + inject.button.x = 150; + inject.button.y = 250; + + sandbox_mouse_inject(dev, &inject); + + /* get and verify the event */ + ut_assertok(mouse_get_event(dev, &event)); + ut_asserteq(MOUSE_EV_BUTTON, event.type); + ut_asserteq(BUTTON_LEFT, event.button.button); + ut_asserteq(BUTTON_PRESSED, event.button.press_state); + ut_asserteq(1, event.button.clicks); + ut_asserteq(150, event.button.x); + ut_asserteq(250, event.button.y); + + return 0; +} +DM_TEST(dm_test_mouse_button, UTF_SCAN_PDATA | UTF_SCAN_FDT); From patchwork Mon Sep 15 10:46:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 309 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=1757933274; bh=HXCJcp/+vBKLd5HtJGQHsTd7+yH8B9/61NiC7wq7sEU=; 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=Da17s1AL/znVqFYJjztyyNbfiG0h7oIgCijAPpfyP2DSBXo3QF4rq8CAKTwT8zums JcJV1tyWZszOzE4TDQHCU1z2UwzIMwaACBoycI/VUrd0YfgMMDQ+i3SUn1XQbMNPMF Bl3759JsNWQ7cTz9bUT5W4Va46dGe2eyXHBrRv1LBa/I/KmLndeKlNhDtjIPMhgqjT MZSJhtBzRXjo8ZVzr5xjynn0YSzQdUTPIlwWrGhTQ/tkD68zReRSzTZxDiFkwpFynh 1UuvrVDJikLFCWlwH8OWtLvG9hocLkx8+biF+NHlV8z3Qa1h3cecLZ9IxBPvNYXjQb 0hQcB2A7aGaew== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 02F8567BB1 for ; Mon, 15 Sep 2025 04:47:54 -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 CPhUszSt9p_B for ; Mon, 15 Sep 2025 04:47:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933273; bh=HXCJcp/+vBKLd5HtJGQHsTd7+yH8B9/61NiC7wq7sEU=; 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=LtjbsGdfycnXxqZmjc9+8GZqgel73ljsrTPlBvwNKU773C7dZ/4V8f9RAOwznKqen RA4g86Kzs30FxqsVOI4WZ9CWHVN0W1nh7uJsfTdpvXkMM1heEyPjo9Mvv4LtYI3qAK VhLzJfsoiISkrpw2RYhcc06geNjgmRHnPfi942hrxMvJv94MFjlSjk9+I4S9KTii5r yTFeZgk0c4hjI21IiFgYNc/JZ6o3cpAXAgoWL5k8Psa2CIf3tOxRN6gVNmpK3RaLEz EPmWpmDj8DkoedC/Qq6CBCmSulcz+cq01LNjQAu5CqRzMcBLINZLy6MMeW2W9LFqLJ ER+kxX3tS8TPg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E44F667B04 for ; Mon, 15 Sep 2025 04:47:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933272; bh=ZkAp2x+9oxxRJKFPaZcpj6P0qIw2BRszlBEs/Ajx+GQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YsyeSf63mp5pThH17k2ci41nXqGhrgv9g9bb+K8TteUXPvaM94zZB67C6l9UbwgFm wBYXfwGMlcsk0/X6OmwUzEPWxmMpEovdVJF9BygI3jo9pJosoPP0/G/EvFiaeyuFUb 4QRCcy8rs1pu1guCJN2W7lFDDVx8VC7MxlWSepgk5fMSxVQEwY7zh0c4cOoAOizIQl iFLH7UGOFR6TzwKBwZtPEHA+DCxPQvLMp0pY9uEb3lm9fdrmnlM8KKNxmup4pZCEM2 aOb/f3Ox2ZAz0DECyNXBg5js29/SaBDVc0HtR5/RMiL2ikzDRfARBzRIhV+0+WcdVZ CUTKN6Nfvgzzg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 13C9D67B04; Mon, 15 Sep 2025 04:47:52 -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 aZwt9OSvnWSJ; Mon, 15 Sep 2025 04:47:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933266; bh=bU8rlSBNm+5/ylNmq52I4o+I1GxqvUejAXEtI8/ZT9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ME4El1++u+en/sYMSuhpDcOuaOVly7eRN48aSirMUXAdHkJNrL1rBSHpHbB/To20a WtFmCml5p+Q8zPVwnBvURA+WvqP2VTsLX3OIpS/RdxOs143jaxft8m6tnQsgbPDrKx GCzN/qx894PqFW6DKkzyagBo3aS0rp3Ca901zwTRAumUmvkw/rFnZbYOF0Jj1HDUwJ 0LYFL5D+TJ7nprkdz2dhFp3+Uki333IIsf3ITAZwJutg6btF0jVrjTBtRx5IG9HABK pRj/joYvBUsst1K+1sjKWqdZrJZ0qC6Ec215voOikHBT6SSIrYTfqlwNtYeKIebm4B Tv/foKS9dspCQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D02EE67A99; Mon, 15 Sep 2025 04:47:45 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:51 -0600 Message-ID: <20250915044657.10.I74dbe55eb065be1782737c8b2b86558e53e0292a@changeid> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QW37TXFGM6JXWM54LHOOTBEXPCMGV3BO X-Message-ID-Hash: QW37TXFGM6JXWM54LHOOTBEXPCMGV3BO 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 10/17] 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 | 353 ++++++++++++++++++++++++++++++++++++++ include/usb.h | 1 + 4 files changed, 363 insertions(+) create mode 100644 drivers/input/usb_mouse.c diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index 101257f9767..e98471c7c2e 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig @@ -110,3 +110,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 8c5a395a540..797284ad8f8 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile @@ -20,3 +20,4 @@ obj-$(CONFIG_MOUSE) += mouse-uclass.o ifdef CONFIG_MOUSE obj-$(CONFIG_SANDBOX) += sandbox_mouse.o endif +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..74f093a4b5a --- /dev/null +++ b/drivers/input/usb_mouse.c @@ -0,0 +1,353 @@ +// 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 2025 Simon Glass + */ + +#define LOG_CATEGORY UCLASS_MOUSE + +#include +#include +#include +#include +#include +#include + +enum { + RPT_BUTTON, + RPT_XREL, + RPT_YREL, + RPT_SCROLLY, +}; + +struct usb_mouse_priv { + unsigned long intpipe; + int intpktsize; + int intinterval; + unsigned long 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("cmn", -EINVAL); + + iface = &udev->config.if_desc[ifnum]; + + log_debug("USB device: class=%d, subclass=%d, protocol=%d\n", + iface->desc.bInterfaceClass, iface->desc.bInterfaceSubClass, + iface->desc.bInterfaceProtocol); + + if (iface->desc.bInterfaceClass != USB_CLASS_HID) + return log_msg_ret("cmc", -EINVAL); + + if (iface->desc.bInterfaceSubClass != USB_SUB_HID_BOOT && + iface->desc.bInterfaceSubClass != 0) + return log_msg_ret("cms", -EINVAL); + + /* Accept any HID device with subclass 0 or boot protocol */ + if (iface->desc.bInterfaceSubClass == 0) { + log_debug("Accepting HID device subclass 0 (tablet/other)\n"); + /* TODO: check endpoints for all devices */ + } else { + /* For boot-protocol devices, check for mouse protocol */ + if (iface->desc.bInterfaceProtocol != USB_PROT_HID_MOUSE) + return log_msg_ret("cmp", -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("cmi", -EINVAL); + + if ((ep->bmAttributes & 3) != 3) + return log_msg_ret("cma", -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("ump", 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): ignoring\n", + udev->descriptor.idVendor, + udev->descriptor.idProduct, ret); + /* + * don't abort - QEMU emulation may not support initial state + * read + */ + } + log_debug("USB mouse OK\n"); + + 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[] = { + { + /* Standard USB HID boot mouse */ + .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, + }, + { + /* + * Generic HID device (includes tablets and other pointing + * devices) + */ + .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | + USB_DEVICE_ID_MATCH_INT_SUBCLASS, + .bInterfaceClass = USB_CLASS_HID, + .bInterfaceSubClass = 0, /* None/generic */ + }, + { } +}; + +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 Sep 15 10:46:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 310 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=1757933277; bh=JB+THQi2X43DmJPq1u8m96YfXSsUz4otxk3omklq7nI=; 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=dTj7z3N1AXYQmHNLoyXMGux0wM/ILwDuEurAmyNz4BLKqPTLpOWOoJparMBuCYdsj ml+6KWaKqhiS8BywJcNdWQgIDEvi06m0DD+4uUphoebP/HXsNYgM757tJ0uHiaLV8J vrhiSla2IphbY8oFa5i2FUNvjbzDn8X0+IYP2bvItIsZptv6+9YA7ILSBK2EvT3/sm WNgt+O4OXivMWbpXtg3GLhhSPaywv/CQvMqxlz7M0cfwqavcJhFdcwaci+YoX+GGHu Ct/go55oDuEpjsbXjKVGVJIawUjywEY2NqfhY7hCnSyhu568LBSxCEu5wLc6SfUPv5 K+nHocd/1ErLA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6178E67BB5 for ; Mon, 15 Sep 2025 04:47:57 -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 z1Wz7bvpViX5 for ; Mon, 15 Sep 2025 04:47:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933277; bh=JB+THQi2X43DmJPq1u8m96YfXSsUz4otxk3omklq7nI=; 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=dTj7z3N1AXYQmHNLoyXMGux0wM/ILwDuEurAmyNz4BLKqPTLpOWOoJparMBuCYdsj ml+6KWaKqhiS8BywJcNdWQgIDEvi06m0DD+4uUphoebP/HXsNYgM757tJ0uHiaLV8J vrhiSla2IphbY8oFa5i2FUNvjbzDn8X0+IYP2bvItIsZptv6+9YA7ILSBK2EvT3/sm WNgt+O4OXivMWbpXtg3GLhhSPaywv/CQvMqxlz7M0cfwqavcJhFdcwaci+YoX+GGHu Ct/go55oDuEpjsbXjKVGVJIawUjywEY2NqfhY7hCnSyhu568LBSxCEu5wLc6SfUPv5 K+nHocd/1ErLA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5182867BB0 for ; Mon, 15 Sep 2025 04:47:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933276; bh=vCOBfnrjNhJvczQj7qHZV2GOVbXelVqHmzEvge01Ri0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fdc1A4lyCHrus0lY5Z1CPvBAqqWUvdEF8G/v4w3M6PNi7a3WQ6VUf+B1O2ApIRzme gTHFXKPo0eX1HWOyGHIiHKWbX4t5Ae5sV3LhrNgxTCrajVrg+LumW1kO+qXk4xdE1k 47L8bPGLdRb3gH91qu8Sc6QN3usHdnXDxnlTAR27N/yKVmNuzio9sfSv/be72M3W01 Vz7TdwBo1hFPGLoVbcaYja3xUcoZVDvkjnmlKZgh5ZwRCxsCujgGk4RJyfao35xwp/ EkxCmiHzYsqTXDwjLcoJT2+uLmsl/5oxSCuYH474QTre7KIcVh1V6dFDuuUAijYS6J BpXwDjUsee1JA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4FCF767B04; Mon, 15 Sep 2025 04:47:56 -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 XxTqyF3r22Rw; Mon, 15 Sep 2025 04:47:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933270; bh=cQ4s4ez6//pgex1qDYzZ08PydqMNYN8brvyxeJZp5ww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XlsNwMcF4CsCvq+1amNzD6K3ufFtgJyIfMhvvZ02E+wsYNgcOXl5Q3fXscmXPE6OO m4qKkCJlAr24KUioq+nGnFUwMMkPc82uzx7zW6DEs51VbMYp3QlzW3tWsdIJqPuK0L mv7uHjRxubDTigydJ12H6u/Ok+zGoOSH4nq1MJ5h6evltvUTLFFH2jF+B2B2oZEOCU AY/bVNpjDgApaoIKj1bGn6xMzpSTwa20j57Pleg7FxeC6R6Esv1Omi3fToj6XEFxPk +o1wEwY8kVb/0GJOuMyFwfR/+57nJLkt4OxwqIPRxYG/UcfehEx5ff8V7zmybL4cl9 eA7yYMNuJoFng== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7DB2567B22; Mon, 15 Sep 2025 04:47:50 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:52 -0600 Message-ID: <20250915104705.937780-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HO5LOW4OQCY4KLIK4CNKF7PVAL6AZYXS X-Message-ID-Hash: HO5LOW4OQCY4KLIK4CNKF7PVAL6AZYXS 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 11/17] mouse: Provide a way to read clicks 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 A mouse click is defined as pressing the mouse and then releasing it over a given spot. Add a function the tracks the mouse state and returns the most recent mouse click, if any. Signed-off-by: Simon Glass --- drivers/input/mouse-uclass.c | 43 +++++++++++++ include/mouse.h | 25 ++++++++ test/dm/mouse.c | 121 +++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+) diff --git a/drivers/input/mouse-uclass.c b/drivers/input/mouse-uclass.c index f42ef346c5c..256642ef55e 100644 --- a/drivers/input/mouse-uclass.c +++ b/drivers/input/mouse-uclass.c @@ -23,7 +23,50 @@ int mouse_get_event(struct udevice *dev, struct mouse_event *evt) return 0; } +int mouse_get_click(struct udevice *dev, int *xp, int *yp) +{ + struct mouse_uc_priv *uc_priv = dev_get_uclass_priv(dev); + struct mouse_event event; + int ret; + + /* Get one mouse event */ + ret = mouse_get_event(dev, &event); + if (ret) + return -EAGAIN; /* No event available */ + + /* Only process button events for left button */ + if (event.type == MOUSE_EV_BUTTON && + event.button.button == BUTTON_LEFT) { + enum mouse_press_state_t new_state = event.button.press_state; + bool pending = false; + + /* Detect press->release transition (click) */ + if (uc_priv->left_button_state == BUTTON_PRESSED && + new_state == BUTTON_RELEASED) { + pending = true; + uc_priv->click_x = event.button.x; + uc_priv->click_y = event.button.y; + } + + /* Update button state */ + uc_priv->left_button_state = new_state; + + /* If we just detected a click, return it */ + if (pending) { + if (xp) + *xp = uc_priv->click_x; + if (yp) + *yp = uc_priv->click_y; + + return 0; + } + } + + return -EAGAIN; +} + UCLASS_DRIVER(mouse) = { .id = UCLASS_MOUSE, .name = "mouse", + .per_device_auto = sizeof(struct mouse_uc_priv), }; diff --git a/include/mouse.h b/include/mouse.h index c96c63918ea..0d20f8ffdbc 100644 --- a/include/mouse.h +++ b/include/mouse.h @@ -8,6 +8,8 @@ #ifndef _MOUSE_H #define _MOUSE_H +#include + struct udevice; enum mouse_ev_t { @@ -29,6 +31,19 @@ enum mouse_press_state_t { BUTTON_PRESSED, }; +/** + * struct mouse_uc_priv - private data for mouse uclass + * + * @left_button_state: Current state of left button (BUTTON_PRESSED/BUTTON_RELEASED) + * @click_x: X coordinate where the click occurred + * @click_y: Y coordinate where the click occurred + */ +struct mouse_uc_priv { + enum mouse_press_state_t left_button_state; + int click_x; + int click_y; +}; + /** * struct mouse_event - information about a mouse event * @@ -77,4 +92,14 @@ struct mouse_ops { int mouse_get_event(struct udevice *dev, struct mouse_event *event); +/** + * mouse_get_click() - Check if a left mouse button click has occurred + * + * @dev: Mouse device + * @xp: Returns X coordinate of click (can be NULL) + * @yp: Returns Y coordinate of click (can be NULL) + * Returns: 0 if a click has occurred, -EAGAIN if no click pending + */ +int mouse_get_click(struct udevice *dev, int *xp, int *py); + #endif diff --git a/test/dm/mouse.c b/test/dm/mouse.c index f9c2e88c43a..1b4c2b5f60f 100644 --- a/test/dm/mouse.c +++ b/test/dm/mouse.c @@ -94,3 +94,124 @@ static int dm_test_mouse_button(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_mouse_button, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +static int dm_test_mouse_click(struct unit_test_state *uts) +{ + struct udevice *dev; + struct mouse_event inject; + int x, y; + + ut_assertok(uclass_first_device_err(UCLASS_MOUSE, &dev)); + + /* put mouse in test mode */ + sandbox_mouse_set_test_mode(dev, true); + + /* test that no click is detected initially */ + ut_asserteq(-EAGAIN, mouse_get_click(dev, &x, &y)); + + /* inject a left button press */ + inject.type = MOUSE_EV_BUTTON; + inject.button.button = BUTTON_LEFT; + inject.button.press_state = BUTTON_PRESSED; + inject.button.clicks = 1; + inject.button.x = 300; + inject.button.y = 400; + + sandbox_mouse_inject(dev, &inject); + + /* + * calling mouse_get_click() should not detect a click yet (press + * only) + */ + ut_asserteq(-EAGAIN, mouse_get_click(dev, &x, &y)); + + /* inject a left button release */ + inject.type = MOUSE_EV_BUTTON; + inject.button.button = BUTTON_LEFT; + inject.button.press_state = BUTTON_RELEASED; + inject.button.clicks = 1; + inject.button.x = 300; + inject.button.y = 400; + + sandbox_mouse_inject(dev, &inject); + + /* now mouse_get_click() should detect the click */ + ut_assertok(mouse_get_click(dev, &x, &y)); + ut_asserteq(300, x); + ut_asserteq(400, y); + + /* verify no more clicks are pending */ + ut_asserteq(-EAGAIN, mouse_get_click(dev, &x, &y)); + + return 0; +} +DM_TEST(dm_test_mouse_click, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +static int dm_test_mouse_click_no_coordinates(struct unit_test_state *uts) +{ + struct udevice *dev; + struct mouse_event inject; + + ut_assertok(uclass_first_device_err(UCLASS_MOUSE, &dev)); + + /* put mouse in test mode */ + sandbox_mouse_set_test_mode(dev, true); + + /* inject press and release to create a click */ + inject.type = MOUSE_EV_BUTTON; + inject.button.button = BUTTON_LEFT; + inject.button.press_state = BUTTON_PRESSED; + inject.button.clicks = 1; + inject.button.x = 500; + inject.button.y = 600; + sandbox_mouse_inject(dev, &inject); + + /* process the press event */ + ut_asserteq(-EAGAIN, mouse_get_click(dev, NULL, NULL)); + + inject.button.press_state = BUTTON_RELEASED; + sandbox_mouse_inject(dev, &inject); + + /* + * now test that click is detected without coordinate return + */ + ut_assertok(mouse_get_click(dev, NULL, NULL)); + + return 0; +} +DM_TEST(dm_test_mouse_click_no_coordinates, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +static int dm_test_mouse_right_button(struct unit_test_state *uts) +{ + struct udevice *dev; + struct mouse_event inject; + int x, y; + + ut_assertok(uclass_first_device_err(UCLASS_MOUSE, &dev)); + + /* put mouse in test mode */ + sandbox_mouse_set_test_mode(dev, true); + + /* + * right button events should not be detected as clicks by + * mouse_get_click() + */ + inject.type = MOUSE_EV_BUTTON; + inject.button.button = BUTTON_RIGHT; + inject.button.press_state = BUTTON_PRESSED; + inject.button.clicks = 1; + inject.button.x = 100; + inject.button.y = 200; + sandbox_mouse_inject(dev, &inject); + + ut_asserteq(-EAGAIN, mouse_get_click(dev, &x, &y)); + + inject.button.press_state = BUTTON_RELEASED; + sandbox_mouse_inject(dev, &inject); + + /* still no click detected since it was right button */ + ut_asserteq(-EAGAIN, mouse_get_click(dev, &x, &y)); + + return 0; +} +DM_TEST(dm_test_mouse_right_button, UTF_SCAN_PDATA | UTF_SCAN_FDT); From patchwork Mon Sep 15 10:46:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 311 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=1757933279; bh=9x69h7EqA7wDpct//Zr+T8ocOWRlVlH5aWEQmBrj2jg=; 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=IlXOyIFZQMZE3HhSOVnfTAxtcMa4jKf25wqJFm9WfolK/rbQ8nSChynupz3IEAGh7 i0YWNLJUAfXGWnAh7Fljl3AzTosULxGST+JXvmTb4qAOQU0XQThVLvhwdwAjG9ZSqI /NgrHdfKcA72CX/WUw6o5ge0zTsOncDMSEv9uMz+oxWvsMI5ipZpL8p9mItUxLrz8B CS4VTqM2AB4nJ1sKrWJGIIwPWcWgfDbOmU/pO2pXeq44v3zKfOuYuUgEUBBaIDaDRB 6Ujt/kXVV1YV61JU6dLYovi/Us9ndtX+PXmqGninpHwRbhTqHyk7q6LLATpu7sjYzA iUxHlGfH/xEUA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BB08D67B04 for ; Mon, 15 Sep 2025 04:47:59 -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 KQUg_yROBOB3 for ; Mon, 15 Sep 2025 04:47:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933279; bh=9x69h7EqA7wDpct//Zr+T8ocOWRlVlH5aWEQmBrj2jg=; 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=IlXOyIFZQMZE3HhSOVnfTAxtcMa4jKf25wqJFm9WfolK/rbQ8nSChynupz3IEAGh7 i0YWNLJUAfXGWnAh7Fljl3AzTosULxGST+JXvmTb4qAOQU0XQThVLvhwdwAjG9ZSqI /NgrHdfKcA72CX/WUw6o5ge0zTsOncDMSEv9uMz+oxWvsMI5ipZpL8p9mItUxLrz8B CS4VTqM2AB4nJ1sKrWJGIIwPWcWgfDbOmU/pO2pXeq44v3zKfOuYuUgEUBBaIDaDRB 6Ujt/kXVV1YV61JU6dLYovi/Us9ndtX+PXmqGninpHwRbhTqHyk7q6LLATpu7sjYzA iUxHlGfH/xEUA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2388B67B44 for ; Mon, 15 Sep 2025 04:47:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933276; bh=Eee2rJsLdPhUjY3yj1WqJw/HmOkAXUmrctK11y1FWIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tO8kDICFTfCTgcOc/cCpxY0KUR1R8kbMoB9rWOD5ePxnPt+yWQISPW4c+QkO+HcV+ y8prHhOwD+twVaz1KdPL3rKbaNnF/JJoAHySMEgN5pcj/wHzH+wJuqPzvluZctsxCx ULznSxPkfmycsC23zsWuFW66R1qSLhCx/q/6/1HZaLMzbvmFH922RWIAKrnmfgSI2R +OmkY5VusVY5xUL3TVi82Yc2axVRz2+c3uDV/7kFNG+NuBkvjkTRe3fZ9C8LL0C2Ek Q3j0BOEKZCOnVdbgG8w6hbeKFhDqmdHUO+RnDCPZe3/+fpZK2XQdAqnbNauEb04KPU e3vVKdtJApb5g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D130567B22; Mon, 15 Sep 2025 04:47:56 -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 SmvVaIsXZeIg; Mon, 15 Sep 2025 04:47:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933275; bh=tpLG9OSNf9xPc6ybeUMK3nCUUcGl7QykDRfOoDlXGLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V1xt31rekPXUy7kiGkC60ssTl3NANMYexRi4pp9PDigsjGDbW/MTyIQNNObIYm52J Loe0dfg9aPkbYB5/pM6lxMixKBNlf6p6QZsufuNauBp0YsYJlKDFcfWgciNoR0sBJZ jp0vy/SycbxEE0VHlLhkkGtyCC6CYxS6EJy5SIrSgkVYodYAmSJBfLr4IBAM6OhOXc 3P9OY8TSaTGv1g5g5LpOhJq26q/hsePMaBZcz0RtCZiwu0C0DrW57X5Jfjwpx7zILG 6L4edoEJpgyqwEeexxPBrhMP7JUs8XmGfJAU6Hjd9Z0Rt44QXMtjzETUeSiOBX+pCi BY2wFxtXbO5Gw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1F46F67A99; Mon, 15 Sep 2025 04:47:55 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:53 -0600 Message-ID: <20250915104705.937780-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TAS67MAZMPRRF2KIZVX2FCGCZOE64TR4 X-Message-ID-Hash: TAS67MAZMPRRF2KIZVX2FCGCZOE64TR4 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 12/17] efi: Add the simple-pointer protocol 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 definitions for the simple-pointer protocol so that it can be used in drivers. Signed-off-by: Simon Glass --- include/efi.h | 1 + include/efi_api.h | 29 +++++++++++++++++++++++++++++ lib/efi/device_path.c | 1 + 3 files changed, 31 insertions(+) diff --git a/include/efi.h b/include/efi.h index e9ca4840352..52f3a014f1d 100644 --- a/include/efi.h +++ b/include/efi.h @@ -176,6 +176,7 @@ extern const efi_guid_t efi_guid_loaded_image_device_path; extern const efi_guid_t efi_guid_device_path; extern const efi_guid_t efi_simple_file_system_protocol_guid; +extern const efi_guid_t efi_guid_simple_pointer; /* Generic EFI table header */ struct efi_table_hdr { diff --git a/include/efi_api.h b/include/efi_api.h index 00a9d29b8fe..70e24cb5fc9 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -977,6 +977,35 @@ struct efi_simple_text_input_protocol { struct efi_event *wait_for_key; }; +#define EFI_SIMPLE_POINTER_PROTOCOL_GUID \ + EFI_GUID(0x31878c87, 0x0b75, 0x11d5, \ + 0x9a, 0x4f, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) + +struct efi_simple_pointer_mode { + u64 resolution_x; + u64 resolution_y; + u64 resolution_z; + bool left_button; + bool right_button; +}; + +struct efi_simple_pointer_state { + s32 relative_movement_x; + s32 relative_movement_y; + s32 relative_movement_z; + bool left_button; + bool right_button; +}; + +struct efi_simple_pointer_protocol { + efi_status_t (EFIAPI *reset)(struct efi_simple_pointer_protocol *this, + bool extended_verification); + efi_status_t (EFIAPI *get_state)(struct efi_simple_pointer_protocol *this, + struct efi_simple_pointer_state *state); + struct efi_event *wait_for_input; + struct efi_simple_pointer_mode *mode; +}; + #define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \ EFI_GUID(0x8b843e20, 0x8132, 0x4852, \ 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c) diff --git a/lib/efi/device_path.c b/lib/efi/device_path.c index b09ea030341..939bf5a0679 100644 --- a/lib/efi/device_path.c +++ b/lib/efi/device_path.c @@ -27,6 +27,7 @@ const efi_guid_t efi_global_variable_guid = EFI_GLOBAL_VARIABLE_GUID; const efi_guid_t efi_guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID; const efi_guid_t efi_guid_loaded_image = EFI_LOADED_IMAGE_PROTOCOL_GUID; +const efi_guid_t efi_guid_simple_pointer = EFI_SIMPLE_POINTER_PROTOCOL_GUID; const efi_guid_t efi_guid_loaded_image_device_path = EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID; const efi_guid_t efi_simple_file_system_protocol_guid = From patchwork Mon Sep 15 10:46:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 312 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=1757933283; bh=Z3d9x8i+SkDi2K0itYFK5BAAR1LyL7ME1BOjqXH8/Rw=; 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=dkRjz0NL14q9uAJayz3KPmA/z4lGNJLF8W/pXAQWN6kyNZmJ68fH/Z2ZU4i2vriqD gnlZwfFoFEZl6Rc+BpZcOCgKZld4I8SJpGDrcBFj8bAqZl1b8Qe+C7Y5AcKVeGdc/x YQbViutQ/010j3AlIno2a6zcxAM00MUbmjy7kpdMn8g9+uk/7+6J4j/2Xf4TFwBMyk Ady4zkrH9UwxQ8vq/nXbaST177MjgyUT9hR5up2XRlSdvx4TSypudAuD/RGktRQ0cB H8AmAcXfxNEuY1aNYMq1hgiEvQRJMgpVbWrOeqyoBoEByeccvmuoNzgZgOScxFBoJN asCLZkHbjhIfQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A1F3667BB0 for ; Mon, 15 Sep 2025 04:48:03 -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 zJA48zrYY8S3 for ; Mon, 15 Sep 2025 04:48:03 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933283; bh=Z3d9x8i+SkDi2K0itYFK5BAAR1LyL7ME1BOjqXH8/Rw=; 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=dkRjz0NL14q9uAJayz3KPmA/z4lGNJLF8W/pXAQWN6kyNZmJ68fH/Z2ZU4i2vriqD gnlZwfFoFEZl6Rc+BpZcOCgKZld4I8SJpGDrcBFj8bAqZl1b8Qe+C7Y5AcKVeGdc/x YQbViutQ/010j3AlIno2a6zcxAM00MUbmjy7kpdMn8g9+uk/7+6J4j/2Xf4TFwBMyk Ady4zkrH9UwxQ8vq/nXbaST177MjgyUT9hR5up2XRlSdvx4TSypudAuD/RGktRQ0cB H8AmAcXfxNEuY1aNYMq1hgiEvQRJMgpVbWrOeqyoBoEByeccvmuoNzgZgOScxFBoJN asCLZkHbjhIfQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D96B67B04 for ; Mon, 15 Sep 2025 04:48:03 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933282; bh=9YqulLm+8Eji7SqqlHjWkphPFXlUI97PgjOCy0KcIP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FRgIUOk6BV4Wb3kbistjmRLjRhgimFk9yF3qdOehebl0t4dI5RhETH8rkPw4jgf2C KDsApRZ2VVO0+HXxR7pecxg+Xe9CItrjYygJQAORNUxILOwBAGpzDVKCrLjOohznmG e0kbk9jn3wMgnwm+GdO+p+JDLT3HklmZPvhHG5jGXC+asPstdxBwZoxkiCvbB0EI5E 7j8oU2TdZYtl2MM2KpJfioPpZr56k6ZbNnqGfOuETKXszEpuVBafAsW9Yz14EiQ9Mb Z3gM4d6RN+8LQsg+zzuI20I1ao/ZL6MmHSLBbWwel2ZAuFXo+YUtkvvY6b/vAgSDhf o1j6K8vhRSrzw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0255867B22; Mon, 15 Sep 2025 04:48:02 -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 QL9r066H4HhC; Mon, 15 Sep 2025 04:48:01 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933277; bh=vL3tJYNWWtxiUe2xK2XCsQ8k/uWmC7AzGrPbwyndqDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jh4jcF4q6kZ2NdBY5coLEBDB3aoYx+CbTdESUnW1nxfslFnnUe2ZrONnNGXN4mMOD boLKcDvD8QO8tdlRS8OCmu/N3dbYog944FQRkPtL2XTn9uwgnqpYgB4KF26mtigcdb GPnsBcDLSiAvW0BKq8GeDwVbUVvXiKwqEmt66TK/KPcC8Xb3Tdmu/38JbLVkFsZPwD OHIINDB24PTjAfa6kHJE7fWp5J+skqIiddfm2QpXjufkiTOAM2S5sw+JbKj0tvzpeG BWDhUPClf2djpuGL3XVwyD715yctqw9NReS5ebBb1atBoQbqNIYxIjxTxP0v0J6y6S TeJlGTyfzML0g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 220F267A99; Mon, 15 Sep 2025 04:47:57 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:54 -0600 Message-ID: <20250915104705.937780-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: Q2JDBKWZNKDVZI73IDCM3YUT5INXIXEW X-Message-ID-Hash: Q2JDBKWZNKDVZI73IDCM3YUT5INXIXEW 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 13/17] efi: Provide a mouse driver for EFI 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 In some cases the device may have a touchpad or mouse, so it is useful to be able to use this in U-Boot. Add a simple driver for a mouse that uses the EFI simple-pointer protocol. Signed-off-by: Simon Glass --- drivers/input/Kconfig | 12 ++- drivers/input/Makefile | 1 + drivers/input/efi_mouse.c | 221 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 drivers/input/efi_mouse.c diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index e98471c7c2e..4bc94de0a0a 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig @@ -104,7 +104,7 @@ config TWL4030_INPUT config MOUSE bool "Support for mice and other pointing devices" depends on INPUT - default y if SANDBOX + default y if SANDBOX || EFI_APP help This allows U-Boot to access mouse input, typically needed for graphics boot menus and the like. The driver can provide mouse @@ -118,3 +118,13 @@ config USB_MOUSE typically a boot menu. The driver uses the USB boot interface of the mouse and attempts to auto-configure itself for normal operation. + +config EFI_MOUSE + bool "EFI mouse support" + depends on EFI_APP + default y if EFI_APP + help + This enables mouse support when U-Boot is running as an EFI + application. It uses the EFI Simple Pointer Protocol to access + mouse input from the underlying EFI firmware. This is useful + when U-Boot is used as an EFI boot manager or application. diff --git a/drivers/input/Makefile b/drivers/input/Makefile index 797284ad8f8..4debad9e713 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile @@ -21,3 +21,4 @@ ifdef CONFIG_MOUSE obj-$(CONFIG_SANDBOX) += sandbox_mouse.o endif obj-$(CONFIG_USB_MOUSE) += usb_mouse.o +obj-$(CONFIG_EFI_MOUSE) += efi_mouse.o diff --git a/drivers/input/efi_mouse.c b/drivers/input/efi_mouse.c new file mode 100644 index 00000000000..84347951f62 --- /dev/null +++ b/drivers/input/efi_mouse.c @@ -0,0 +1,221 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * EFI mouse driver using Simple Pointer Protocol + * + * Copyright 2025 Google LLC + * Written by Claude + */ + +#define LOG_CATEGORY UCLASS_MOUSE + +#include +#include +#include +#include +#include + +struct efi_mouse_priv { + struct efi_simple_pointer_protocol *pointer; + struct efi_simple_pointer_state last_state; + bool has_last_state; + int x, y; + int buttons; + int old_buttons; + struct efi_event *timer_event; +}; + +static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) +{ + struct efi_mouse_priv *priv = dev_get_priv(dev); + struct efi_simple_pointer_state state; + efi_status_t ret; + int new_buttons; + if (!priv->pointer) + return -ENODEV; + + /* Use timer-based polling approach like EFI keyboard */ + if (priv->timer_event) { + struct efi_boot_services *boot = efi_get_boot(); + efi_uintn_t index; + struct efi_event *events[2]; + efi_uintn_t num_events = 1; + + events[0] = priv->timer_event; + if (priv->pointer->wait_for_input) { + events[1] = priv->pointer->wait_for_input; + num_events = 2; + } + + ret = boot->wait_for_event(num_events, events, &index); + if (ret != EFI_SUCCESS) + return -EAGAIN; + } + + /* Get current pointer state */ + ret = priv->pointer->get_state(priv->pointer, &state); + if (ret != EFI_SUCCESS) { + if (ret == EFI_NOT_READY) + return -EAGAIN; + printf("EFI mouse: get_state failed (ret=0x%lx)\n", ret); + return -EIO; + } + + /* Check for button changes */ + new_buttons = 0; + if (state.left_button) + new_buttons |= 1 << 0; + if (state.right_button) + new_buttons |= 1 << 1; + + if (new_buttons != priv->old_buttons) { + struct mouse_button *but = &event->button; + u8 diff = new_buttons ^ priv->old_buttons; + int i; + + event->type = MOUSE_EV_BUTTON; + /* Find first changed button */ + for (i = 0; i < 2; i++) { + u8 mask = 1 << i; + if (diff & mask) { + but->button = i; + but->press_state = (new_buttons & mask) ? 1 : 0; + but->clicks = 1; + but->x = priv->x; + but->y = priv->y; + priv->old_buttons ^= mask; + return 0; + } + } + } + + /* Check for movement */ + if (state.relative_movement_x || state.relative_movement_y) { + struct mouse_motion *motion = &event->motion; + + /* Update absolute position */ + priv->x += state.relative_movement_x; + priv->x = max(priv->x, 0); + priv->x = min(priv->x, 0xffff); + + priv->y += state.relative_movement_y; + priv->y = max(priv->y, 0); + priv->y = min(priv->y, 0xffff); + + event->type = MOUSE_EV_MOTION; + motion->state = new_buttons; + motion->x = priv->x; + motion->y = priv->y; + motion->xrel = state.relative_movement_x; + motion->yrel = state.relative_movement_y; + + priv->buttons = new_buttons; + return 0; + } + + priv->buttons = new_buttons; + + return -EAGAIN; +} + +static int efi_mouse_probe(struct udevice *dev) +{ + struct efi_mouse_priv *priv = dev_get_priv(dev); + struct efi_boot_services *boot = efi_get_boot(); + efi_status_t ret; + efi_handle_t *handles; + efi_uintn_t num_handles; + + log_debug("EFI mouse probe\n"); + + /* Find Simple Pointer Protocol handles */ + ret = boot->locate_handle_buffer(BY_PROTOCOL, &efi_guid_simple_pointer, + NULL, &num_handles, &handles); + if (ret != EFI_SUCCESS) { + printf("EFI mouse: No EFI pointer devices found (ret=0x%lx)\n", ret); + return -ENODEV; + } + + log_debug("Found %zu EFI pointer device(s)\n", num_handles); + + /* Use the first pointer device */ + ret = boot->open_protocol(handles[0], &efi_guid_simple_pointer, + (void **)&priv->pointer, efi_get_parent_image(), + NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (ret != EFI_SUCCESS) { + printf("EFI mouse: Failed to open EFI pointer protocol (ret=0x%lx)\n", ret); + efi_free_pool(handles); + return -ENODEV; + } + + efi_free_pool(handles); + + /* Reset the pointer device */ + ret = priv->pointer->reset(priv->pointer, false); + if (ret != EFI_SUCCESS) { + log_warning("Failed to reset EFI pointer device\n"); + /* Continue anyway - some devices might not support reset */ + } + + priv->x = 0; + priv->y = 0; + priv->buttons = 0; + priv->old_buttons = 0; + priv->has_last_state = false; + + /* Create a timer event for periodic checking */ + ret = boot->create_event(EVT_TIMER, TPL_NOTIFY, NULL, NULL, + &priv->timer_event); + if (ret != EFI_SUCCESS) { + printf("EFI mouse: Failed to create timer event (ret=0x%lx)\n", ret); + /* Continue without timer - fallback to direct polling */ + priv->timer_event = NULL; + } else { + /* Set timer to trigger every 10ms (100000 x 100ns = 10ms) */ + ret = boot->set_timer(priv->timer_event, EFI_TIMER_PERIODIC, 10000); + if (ret != EFI_SUCCESS) { + printf("EFI mouse: Failed to set timer (ret=0x%lx)\n", ret); + boot->close_event(priv->timer_event); + priv->timer_event = NULL; + } + } + + log_info("EFI mouse initialized\n"); + return 0; +} + +static int efi_mouse_remove(struct udevice *dev) +{ + struct efi_mouse_priv *priv = dev_get_priv(dev); + struct efi_boot_services *boot = efi_get_boot(); + + if (priv->timer_event) { + boot->close_event(priv->timer_event); + priv->timer_event = NULL; + } + + if (priv->pointer) { + /* Protocol will be automatically closed when the image is unloaded */ + priv->pointer = NULL; + } + + return 0; +} + +static const struct mouse_ops efi_mouse_ops = { + .get_event = efi_mouse_get_event, +}; + +static const struct udevice_id efi_mouse_ids[] = { + { .compatible = "efi,mouse" }, + { } +}; + +U_BOOT_DRIVER(efi_mouse) = { + .name = "efi_mouse", + .id = UCLASS_MOUSE, + .of_match = efi_mouse_ids, + .ops = &efi_mouse_ops, + .probe = efi_mouse_probe, + .remove = efi_mouse_remove, + .priv_auto = sizeof(struct efi_mouse_priv), +}; From patchwork Mon Sep 15 10:46:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 313 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=1757933286; bh=VMBS4V+cVC44sUk39l0XCcwI8PR2rkDanD/wkX6xgLk=; 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=LnLfYo22iP4qw2yKMsnePCtMqbRi3MxN+ozZOvgI748g/tcjiGJmY/PpJMBHS2fr1 7GA4LRXAXSpn3RwVpeYwurxCUu1u22LsdmxfJQ9WbCeOs4vgd5fyz6YR2mRw9eB9E4 +jAiV4ulZT0viDvvScyABjmdh1gT1kv6/HTKH5R/DvEJ60l361jpkdWRhTKWT6nUPF 0I2pJcLpDzRlzgRuKkF2ycDlssEtExuwhJ4pT6ojbatT/iXI3pMpyDgiHtOvm3kIW3 /qndMG3BVvpo9uqAP6BgY+ksCfAnysyDrvLgAILqW/LGzXG2HU1aGHjvj0bmEVbP62 4KsDf5f5yeC0A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 023AC67BC4 for ; Mon, 15 Sep 2025 04:48:06 -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 LE8TNLRySyAc for ; Mon, 15 Sep 2025 04:48:05 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933285; bh=VMBS4V+cVC44sUk39l0XCcwI8PR2rkDanD/wkX6xgLk=; 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=QtrAcZjHYw5nQNngt29rU7ZayELrTNfMFTh0Xmy9RvQBwyy28jDHhz4+6fUWvXNPF rMPq8KzD6wN7yFCpZLBk7bfAwe4sz0V8jlhXwJIhH2H91kwLlngbn7E3KhLuP2OD/c Gt8AAnSE3TKfna3Dvi4EIXjtFZLQtGCaG5ngbrcnJIfQ9QvBi8DomnB+/py85bFLvP f98V8NfCyfR4hLtrXUd+6OxQVCDGzp5znSt11Pi7xomRoPnpUSJ2yA4GiaP372P0Z1 W8jjRBjDb7E3jjiIhBPHGKklVwnztjqNo50ZAWc0xjtNhhOp+jWlGi7U70YQkr06+m hSeEs+WBDBKew== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 04D0267B22 for ; Mon, 15 Sep 2025 04:48:05 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933283; bh=E7w0n9VlxX2fONUC2f0GJqYWk2YJx3V0EcDuoSd/psw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lSsUeo7JGR3ljDQn19FJ+tAi5o2VfufLgBePTRKBf/B7GYBplj+sUtT2z6gUzphQq tfgycMshtb55hUkSMqCzep0ZpC+ISYY5i/LQ6LO3e/LKchGScQi215Cf/5kqZ9dMlQ OMsm/+2SrTcXjCItQk5zQ4N9gjvNHjpWcmz6G7nqUQptM54LZuxR3E4omP7GBslMRe JdRtnSJRdvqNbZ45ojCpoAXuVBzyKiJ2vpnzCslXJGRLEzZYDWUHw0zfXhtiRLuj75 1sTokBWL0l/AxJy7KzwKHStXB/Sfsbijd/K77XVdqMHZBI7U6lzkQU2G7cgTGJa6D4 wKEgXw5CRdmIA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8377367B22; Mon, 15 Sep 2025 04:48:03 -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 73biwzS14-aU; Mon, 15 Sep 2025 04:48:03 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933282; bh=tADpAx1aNNEXmVFDQRvRyalqhuHzyib9eTRywAWSZOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eLblZN8ghgzpGir1ejiPgcyy57JJ1GeXyO6i4elWvINeKn+kvTqNgyHg0G3FMunkN ikzILqm9lVVyBE0PsZbgSjljF2hWVUDxdZq5mjh7wY+LN5eDELV8ugWJXDZ/v0IQtB xngqgf1Rf+3ilsybsMzpVbQ8jF99HAafqa2RFSNGNJ+U4No0mGrnVSAMjRL7ZcvQeZ hp/EwPbRuvuvYkjoqmrN0N8KjGm80WDOCdHD/hM1HjgZvCPgWoGct63sh2nF01kpHs DRHKc82032N1OHG8CHL4CWjOZ3uSiRpC2IDQgoKTOXYqLXMvEIVsaI8xdB1r6UlZaH 1WvXvRRJjWP+w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B58C467B04; Mon, 15 Sep 2025 04:48:01 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:55 -0600 Message-ID: <20250915104705.937780-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3HCJXV2WTAV7NOIEXVXVTRSSMDNGVAGZ X-Message-ID-Hash: 3HCJXV2WTAV7NOIEXVXVTRSSMDNGVAGZ 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 14/17] efi: arm: x86: 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 Provide a devicetree fragment to enable the mouse for x86 and arm, when running as an EFI app. Signed-off-by: Simon Glass --- arch/arm/dts/efi-arm_app.dts | 5 +++++ arch/x86/dts/efi-x86_app.dts | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/arch/arm/dts/efi-arm_app.dts b/arch/arm/dts/efi-arm_app.dts index 38cab04e510..d2a008fba6a 100644 --- a/arch/arm/dts/efi-arm_app.dts +++ b/arch/arm/dts/efi-arm_app.dts @@ -23,9 +23,14 @@ compatible = "efi,reset"; bootph-all; }; + efi-fb { compatible = "efi-fb"; bootph-some-ram; }; + mouse { + compatible = "efi,mouse"; + }; + }; diff --git a/arch/x86/dts/efi-x86_app.dts b/arch/x86/dts/efi-x86_app.dts index 59e2e402d5e..1daba34d5f0 100644 --- a/arch/x86/dts/efi-x86_app.dts +++ b/arch/x86/dts/efi-x86_app.dts @@ -30,4 +30,8 @@ bootph-some-ram; }; + mouse { + compatible = "efi,mouse"; + }; + }; From patchwork Mon Sep 15 10:46:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 314 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=1757933290; bh=AvMRsYFOBpUujEGkFUYA4HP8goOg3yI4CptanrLLCns=; 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=qNBK6+9JNvxdEEItfly2DZzpbGquCKXdKilyrvPHT+QbcIRWAVsRJbQZGPYe6gzly U6q4WXzYiT/GDAEb+yVYCvWAe350Of0RGPaIEWhbB6bCfsdhOrfwPqRhu0Hp3HQ4wA Gcm+QFFpm8Oc7eGhYWiByRuSX3PJ7uI3Due70VtJ2QYtyz9n9Siyi351aswJ99OHEg lD+a+cn5CrKzpmIGsOLYpGIunzG+tsDIzvkJ9mIlKsiIdnrj6d54sWkBmRiYGemxTO ZXl+ZiTYEmZml/gYvFuLV66+iu0QC7n5W3r8W/DFg+hj2BjvbbihOqHpSK2dQt2Yxf HyGBHvM8FVewg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6A60167BBB for ; Mon, 15 Sep 2025 04:48:10 -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 4a6nvWj4frf8 for ; Mon, 15 Sep 2025 04:48:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933290; bh=AvMRsYFOBpUujEGkFUYA4HP8goOg3yI4CptanrLLCns=; 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=qNBK6+9JNvxdEEItfly2DZzpbGquCKXdKilyrvPHT+QbcIRWAVsRJbQZGPYe6gzly U6q4WXzYiT/GDAEb+yVYCvWAe350Of0RGPaIEWhbB6bCfsdhOrfwPqRhu0Hp3HQ4wA Gcm+QFFpm8Oc7eGhYWiByRuSX3PJ7uI3Due70VtJ2QYtyz9n9Siyi351aswJ99OHEg lD+a+cn5CrKzpmIGsOLYpGIunzG+tsDIzvkJ9mIlKsiIdnrj6d54sWkBmRiYGemxTO ZXl+ZiTYEmZml/gYvFuLV66+iu0QC7n5W3r8W/DFg+hj2BjvbbihOqHpSK2dQt2Yxf HyGBHvM8FVewg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5980E67BAC for ; Mon, 15 Sep 2025 04:48:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933288; bh=K9JX5HbmJ8ijVVi8NTsqRokuawZlYkM808cOKWpTC1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vbSUH4t/EQegt69FrErI3VWqwhfJrvV96Q7x1jv6FO1/0Dekw9lZ2fjndc4IDK2A8 fhva9rmyN6BeicHRTd2uVQiDDEuBKTRMf3saEDKZr2ka+Wv295id1btx5h4kBxrhNB ZFzaB+eqh/sCYbZgPOjHT3smEnrPuQ7JjYKrNI0fUFCKNaL57ABv3dYhuJdOpHRghh v+a5LDK2pDDVyVu//IkZKwTnJojt3iOY0XUQyqlGcnSjByTcMso93itRfwkMCa6IEc 1DWUoYBGSDe1/zq5WidGQ4kbSuOZ5xaOB5F66elEd7qIRGiMG+XN6u6USbHSRqJIzL a5NsJez3e1z4A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3BDB067B3C; Mon, 15 Sep 2025 04:48:08 -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 UaWow1H092L9; Mon, 15 Sep 2025 04:48:08 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933284; bh=avUBNZ2uPGZ7FctkqrS6bkLli8Gl1hohj0zxDMUOk1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MJEFOS2EBfShcBXFR5sub8Z0ZYsowk8MxxDZKR9RmiCJHpGHLDtoLv5NM6O8Qol9P QZusERXramAFMsajhfJiqZdlkG5q5KYI3BIgcm9oJqo/7Lz6TGlUrPTP6Q+6gfbb8a XWxvkjmm/nrLH9hPemVBFA63XDCcPxtb2tyD1g5LKwsaoMc4IYis9MN+HptG/LM9aZ e7fgDB1tv9AeZbtv9+NmLnM1vTE8b4hoye4v/oVFpez9hTUkLpVdgbTW8HMFPJptM2 bOKfryy1flFOXxInwztWdiXn9KwPI4bl5BUz3AX8AdzBkFjlJt+eZcejmC2qnMqAWl kebimjC8+RmTg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C688F67B04; Mon, 15 Sep 2025 04:48:03 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:56 -0600 Message-ID: <20250915104705.937780-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: JF2WEN2M7XNCDLGGSCOAJUCCI64VQV3V X-Message-ID-Hash: JF2WEN2M7XNCDLGGSCOAJUCCI64VQV3V 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 15/17] script: Support mouse with build-efi/qemu scripts 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 Provide arguments to QEMU to enable a mouse. Note that this does not work with EFI at present. Signed-off-by: Simon Glass --- scripts/build-efi | 3 +++ scripts/build-qemu | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/build-efi b/scripts/build-efi index f4c96dad7bd..131aad50897 100755 --- a/scripts/build-efi +++ b/scripts/build-efi @@ -112,6 +112,9 @@ class BuildEfi: extra += ['-device', 'qemu-xhci', '-device', 'usb-kbd', '-device', 'usb-tablet'] extra += ['-display', 'default,show-cursor=on'] + else: # x86 + extra += ['-device', 'qemu-xhci', '-device', 'usb-kbd', + '-device', 'usb-tablet'] extra += ['-serial', 'mon:stdio'] serial_msg = '' if self.args.kvm: diff --git a/scripts/build-qemu b/scripts/build-qemu index 0bc312470de..62f0bc41fad 100755 --- a/scripts/build-qemu +++ b/scripts/build-qemu @@ -274,7 +274,11 @@ class BuildQemu: elif self.args.arch == 'arm': qemu_cmd.extend(['-device', 'virtio-gpu-pci']) qemu_cmd.extend(['-device', 'qemu-xhci', '-device', 'usb-kbd', - '-device', 'usb-tablet']) + '-device', 'usb-tablet', '-device', 'usb-mouse']) + qemu_cmd.extend(['-display', 'default,show-cursor=on']) + elif self.args.arch == 'x86': + qemu_cmd.extend(['-device', 'qemu-xhci']) + qemu_cmd.extend(['-device', 'usb-kbd', '-device', 'usb-tablet']) qemu_cmd.extend(['-display', 'default,show-cursor=on']) if not any(item.startswith('-serial') for item in self.qemu_extra): qemu_cmd.extend(['-serial', 'mon:stdio']) From patchwork Mon Sep 15 10:46:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 315 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=1757933292; bh=p7ueCgp3cErjY4vSaU5w8+ieq42O8RjiAwmns9IzWAs=; 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=gvttvPhJV608yPZ7jqxfaWFPFpke7E5TTYt9TbI+fIWXD1Z54zZN09PWniCoV4Vac hTdJwbNizfUP8RQ9d8CEuq/3eDuggsCj7Ccv5wyJUmDiFRb1/6sVfte9TfD5Va4ulR xTUINM/zMbyI3v4sUg6+/6yaVAYSSlBKEbxBt6w3Ig9PuMfNT24wAJBrlXpug5fT4D lXZg88oScJ8m9QfR68jCbGuYneaA1teo6+A5x7l0k9Dv6zNFyW9A0DbHY4JtYgt6ic z0/qLokMxmaEPg4tv5biTjsRx2wOVYH4W5cMXdqQpQe6CJhRowaMLebjyEouv3ItwJ /B2hJhJd4qTfQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C965F67BB0 for ; Mon, 15 Sep 2025 04:48:12 -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 zdcJG64w4VSl for ; Mon, 15 Sep 2025 04:48:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933292; bh=p7ueCgp3cErjY4vSaU5w8+ieq42O8RjiAwmns9IzWAs=; 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=gvttvPhJV608yPZ7jqxfaWFPFpke7E5TTYt9TbI+fIWXD1Z54zZN09PWniCoV4Vac hTdJwbNizfUP8RQ9d8CEuq/3eDuggsCj7Ccv5wyJUmDiFRb1/6sVfte9TfD5Va4ulR xTUINM/zMbyI3v4sUg6+/6yaVAYSSlBKEbxBt6w3Ig9PuMfNT24wAJBrlXpug5fT4D lXZg88oScJ8m9QfR68jCbGuYneaA1teo6+A5x7l0k9Dv6zNFyW9A0DbHY4JtYgt6ic z0/qLokMxmaEPg4tv5biTjsRx2wOVYH4W5cMXdqQpQe6CJhRowaMLebjyEouv3ItwJ /B2hJhJd4qTfQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B585067B44 for ; Mon, 15 Sep 2025 04:48:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933290; bh=oEgZTPUhZMDuUUhbtbfN1gyWASP75xhpuI3cpyBGw6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wKMdXH7KJBDfGoUj0l0SHbYxbiXdFn5XOoOWrq6DSxBA0mN2SYBzXUWqf+0O7/0Kp BxZbdNz0hXAjOpVtCWiyNz+8LASrw13wlB1Jil/paQhSHB34AMHbDF0J3IXZ4NmclV PIZotHbI7qxJe3ymZPHyUXfdwAAsZQ9gSu37nglBXNi6eBMZ4zog6VDKMGelgY9Gep Iw48vgMpuBg/VgEHZeiV0AzPEND4dF2x7Y3wvavGzM298YyhTBFG3/OVbRsaxAo0rf VCjTTUO3ZwFkO1gtlbvQCGt9c9o1HJkuThBwwBYSl7TKh5N3FuRgppgfdD8l4dP4n3 SrQsw+yd0HWSQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1E4AC67B3C; Mon, 15 Sep 2025 04:48:10 -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 JVIRcGsXD6Db; Mon, 15 Sep 2025 04:48:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933288; bh=O496iuUgq+I8kwyu48fqjmkOY7nbUJYajWUMoblQXug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E0cFAvad4g2xDJcaUSIRTGcGxilWKTURR4rDk9MYj5J6+DcHm0mV+PHvCV5cjEGUZ DpaT0AQpRqjsUi+HgrmJ8LYxn+3DHuYTgBNqrMfB/rJsO5tB448uPWgbD9qxSkpp5W u4yVyE8CdWVjRHu3HGI/5IauXoiaWPwDol+sl3qCtKcHJs59XJAfvfDqpvou75Eo5C NXDxnd237l/4w9LyHhmST3+kYsgA+VD35ZGnNHYaXnsQ+xwKTCfT3yI5EH9qyKNFZn 0JcN5tnENjcWgQpYwulYZlBjYlmDslZRyhToXRcItxiwzoh5hJCms1zNnH1Y1tGUcB Tp2y4zsuf4fXw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 60FD867B04; Mon, 15 Sep 2025 04:48:08 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:57 -0600 Message-ID: <20250915104705.937780-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GB3E4E7AM6FZHXSCG5LVIKBUWAS3FTQW X-Message-ID-Hash: GB3E4E7AM6FZHXSCG5LVIKBUWAS3FTQW 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 16/17] x86: emulation: Enable USB 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 The mouse is typically connected via USB on x86, so enable this feature. Signed-off-by: Simon Glass --- configs/qemu-x86_64_defconfig | 3 +++ configs/qemu-x86_defconfig | 3 +++ 2 files changed, 6 insertions(+) diff --git a/configs/qemu-x86_64_defconfig b/configs/qemu-x86_64_defconfig index 15a968e00c3..ac946612b4e 100644 --- a/configs/qemu-x86_64_defconfig +++ b/configs/qemu-x86_64_defconfig @@ -54,6 +54,9 @@ CONFIG_CMD_MEM_SEARCH=y CONFIG_CMD_IDE=y CONFIG_CMD_SPI=y CONFIG_CMD_USB=y +CONFIG_USB=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_PCI=y CONFIG_CMD_CAT=y # CONFIG_CMD_SETEXPR is not set CONFIG_BOOTP_BOOTFILESIZE=y diff --git a/configs/qemu-x86_defconfig b/configs/qemu-x86_defconfig index b531c73426d..b1fe8be705c 100644 --- a/configs/qemu-x86_defconfig +++ b/configs/qemu-x86_defconfig @@ -33,6 +33,9 @@ CONFIG_CMD_MEM_SEARCH=y CONFIG_CMD_IDE=y CONFIG_CMD_SPI=y CONFIG_CMD_USB=y +CONFIG_USB=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_PCI=y CONFIG_CMD_CAT=y # CONFIG_CMD_SETEXPR is not set CONFIG_BOOTP_BOOTFILESIZE=y From patchwork Mon Sep 15 10:46:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 316 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=1757933294; bh=LWmCQvZ019ECfs1JFCkDnPnDz0ugCErvblOhEUeDCJI=; 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=UtMT262sactXDT8Rnbce9g7xmOW+oMpMfKvyUDgWrCxqe8sjYUZRo9hHxAyZMhh6H I6hHamniL+/micSVO6oidHGYP1ahtUVsvnhBIDq2EpSXRk7SMFcCNVV6AWE0y4sQ94 Cc6NbHCZWEZO4omAVjUufmabcz5vAiL4P359oYjdPn3RWAedCdlmGIxMoCAE3HLU5G i9BwgW44o180rqWcL7Bbe5wGnNC+u/rxQDCo+m7wCcgPgboANP285xLQ8XVajAtOps MQyuZJFzurjJOUngGXDLHkI8iW0EtAZOzdDvEE8BK7UKGLXSq/dbeOt6tYEneR+pbC WQ1jhGt3uGswQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 33B4367BAF for ; Mon, 15 Sep 2025 04:48:14 -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 ne6BVoFQH_tX for ; Mon, 15 Sep 2025 04:48:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933294; bh=LWmCQvZ019ECfs1JFCkDnPnDz0ugCErvblOhEUeDCJI=; 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=UtMT262sactXDT8Rnbce9g7xmOW+oMpMfKvyUDgWrCxqe8sjYUZRo9hHxAyZMhh6H I6hHamniL+/micSVO6oidHGYP1ahtUVsvnhBIDq2EpSXRk7SMFcCNVV6AWE0y4sQ94 Cc6NbHCZWEZO4omAVjUufmabcz5vAiL4P359oYjdPn3RWAedCdlmGIxMoCAE3HLU5G i9BwgW44o180rqWcL7Bbe5wGnNC+u/rxQDCo+m7wCcgPgboANP285xLQ8XVajAtOps MQyuZJFzurjJOUngGXDLHkI8iW0EtAZOzdDvEE8BK7UKGLXSq/dbeOt6tYEneR+pbC WQ1jhGt3uGswQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1C3F967B44 for ; Mon, 15 Sep 2025 04:48:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933292; bh=MLNhkVSi3tyduv4ECWce/5yenNTrkvKCNllnTdtk7L4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GF8fx8fSHaGGsjPrrwewi637EWx1WMEBb1vDVUbS5MqIlVQORV+0v17GFUXrkx5Dq mg6+IPxbv7M3VVoecqxp8NXUQ1Sau1HUaMO2f2vb2oAhgfGZXlDzLqns0AtsDmlDyv WaRNuKjQbfc4DKbsJOCtK0Cx7y7Jh+LNMEh5CNpGCXzmkpqMFbhq7kx7A3sceJWJcV fr+vdAtDe83JD8D/cjPHSebUifb4DnBOy/OM/vCu9PKj2GI8VVCS3kkW6PyUZeWmAu Jvf8DmdRb9CJhPeQWJcjcw9C3luHoYA59dHVjt3TyRoFe4AEndVtguaUVH5+prNO+8 l1xrfvYPHuWKw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B6D5B67BAC; Mon, 15 Sep 2025 04:48:12 -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 qJlwYus1EEAo; Mon, 15 Sep 2025 04:48:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757933290; bh=58+DpoG4PjDiwc+EGF5mmrO1T+A9cZdBASddUQpy/zI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LoflDJBTtzCRiuqCa1kOaf4vxqzr92KoXVlEvcv60mVpl7Uet72JVF9IiKNtakIjd B3bSSyhDmcgqQdzbHZdDhZJyhkflyKt3zHOZKcIgr5QeEaO6c41zoDYyXKs4tI/aN7 sNAAjgyKvlrLrtm7eMSywnpwvf2vFWnP69B4wXHSB1ML9Akoi6it64hhsqWcOwDH5J cBUrXUxKNjmHOMaUhqTDjv2z4BTGbURenmfwYXXtDz8lXhjUClLYjfVz2US9DYSNbs uCxLh3YDp6cWHduj2yDWAB/hjL6QRC4vxdrawWaxO6mprHvHHciZAvR+n77KpFr/EJ J3ErtIZGolArA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 618C967BB0; Mon, 15 Sep 2025 04:48:10 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 04:46:58 -0600 Message-ID: <20250915104705.937780-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915104705.937780-1-sjg@u-boot.org> References: <20250915104705.937780-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 45Y37RDQKDXKUUGWX3KZNBQYIWJXPPWX X-Message-ID-Hash: 45Y37RDQKDXKUUGWX3KZNBQYIWJXPPWX 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 17/17] qemu: 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 the mouse when running on QEMU, for ARM and x86. This requires 'usb start' on x86. For ARM, the mouse does not work, perhaps related to the fact that the display does not work either. Signed-off-by: Simon Glass --- drivers/input/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index 4bc94de0a0a..7b34902dd7c 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig @@ -104,7 +104,7 @@ config TWL4030_INPUT config MOUSE bool "Support for mice and other pointing devices" depends on INPUT - default y if SANDBOX || EFI_APP + default y if SANDBOX || EFI_APP || MACH_QEMU help This allows U-Boot to access mouse input, typically needed for graphics boot menus and the like. The driver can provide mouse @@ -113,6 +113,7 @@ config MOUSE config USB_MOUSE bool "USB mouse support" + default y if MACH_QEMU 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