From patchwork Mon Oct 6 20:58:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 522 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=1759784378; bh=jcwmBGn30nq38qtA/mKxCw5EJPDbOb8G6apAuvNMBog=; 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=Gtc9Rq1v923mXQZKDAQpqhXZI+dYNXxnjf/ePs8nPcE4aMgvsfl8t6bzHlv6x93CN vpm6BNviABKpOLrksZTzKPnLzei1gBdx0H5Nn0TWZ0vIQzHdtNAo42aIHX44A7Bm5D k4YW3wEXoKZ/O7buv14vLNg03gv1K8b/eNHtbx0YQxwyJu4oubwsmGm1qCqSDbcU9P nObNx3Vt02oLbIUipXYHezGJ7wPeOsOIMVKPLZeFpRW2tXINkli0wYcAeHoOx+y+jS pgW56/vD+RWHnZ93jVGbv35U8NkWMfG4i/+4G/cvYE/lAEvgV80HMK8Igqerna426N /Q8yZWSSLedXA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 43BCF67F55 for ; Mon, 6 Oct 2025 14:59:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 7d-TVo8U2VER for ; Mon, 6 Oct 2025 14:59:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759784376; bh=jcwmBGn30nq38qtA/mKxCw5EJPDbOb8G6apAuvNMBog=; 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=QqIdICi/HLWT2chz8M3reIpLy8/8aS8pwv2mncTfI59BHaagaX/sjeMBsxA6MaRY/ kEj9UXhMKIHRAzYbNZG7lCrymiDgBjpNAKW0RF8XSnBXr6EWC0IPa5OAHR9JybFXYK P5MwXyhrqN7S67kKekA/pKTHfSlTvi5R5nbVqYIUVo3sHof/K0BJpqsjVaA+GdpJUj KVUpKbbXCO5a+OxrwXBlGfSxjanKoyPka29/c4XebngWzgmDnMM/Rpp6j+WWwMNqfN CODoaa+BkfcjP1ba7tV6Szq4yo7Hj3F4/mATKY4cTlLZG9MKS4ROiiSuebN3Gl2T9P aV2bUwTaEfXbg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3AE9067F03 for ; Mon, 6 Oct 2025 14:59:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759784373; bh=pIz0izu0ZAqYCtradf2djE0SAEMVei1i28N4YqVGve0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=skLFwUPsyTnVyNxIBHmyxjCrkqXwFAa3SNNOm6/MKhjycb4ZtSeti9YTcPqj/JK22 qZW1xSLLBiavu/UPdViTiHi1g9jgh566IXx++EJHfu/fNkBqUx+cA4b1iI3NH4eoHn tNagp/jVi3MMKV7jigzogGNNH49ztfpRRdhmmmUK7mi0mWHOrq9XoWkHKgjce0aghK MjLxrBeWDQcnoYg9sxzDiANOPDXaQNsYTkm6GjbQMJC+J1Wufmv0d31a+pMEKOad2Q mVHuluwD966Q/kLmhryV19ESimjblFg1r5S+wt349CSaNUhnAs1306Tgmi7gO2Mp2r 8B43Wo1cAY0Dg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5534E67EE4; Mon, 6 Oct 2025 14:59:33 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id ZR1OU7yyIF5u; Mon, 6 Oct 2025 14:59:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759784369; bh=KvF7jLQZcj1xEnlMzDXPOVTCJMJ1H+Mos02U7rBL3ZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M/LeSh8eFRyi0/ncyDJvwtu21odWRROJwjbDc85ajPUmWMVKbTwOQwxFtyGcrD/JE X4mdtj2A2yVTgkx1etOUxIj2O4+ozy812IkX5KS81e4I+5qHdCL0k2MGfgaVGDmJR5 leWSte6U64ytyjEAR+Y91++xrGkbuIkFojGfsKS9xjkAfL9wPYEzoJhLqHkszApepQ u9oY81TB2HhvapY7hWp7HKU7vDVLyJzHCuLf++omDahdrPm61X5FW9BpGzfXjoDUyA F8GSNed9GMy5JhUHe0N3Z1oDj8vfGFay7UbeGoKCoN3VCeLr4gofwTmSudDQr2evZm bgh89mxPnvXDw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 95F1767FCB; Mon, 6 Oct 2025 14:59:29 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 14:58:39 -0600 Message-ID: <20251006205856.2009292-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006205856.2009292-1-sjg@u-boot.org> References: <20251006205856.2009292-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LK4SOPA6VTJ73W6CMWSLSLGVR266KABA X-Message-ID-Hash: LK4SOPA6VTJ73W6CMWSLSLGVR266KABA 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/14] mouse: Add support for scaling of video-device coordinates 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 mouse_set_video() function to set up the video device associated with the mouse. This allows mouse drivers to scale coordinates to match the display resolution. The video device information is stored in mouse_uc_priv rather than being driver-specific, providing a common place for all mouse drivers to access display dimensions for coordinate scaling. Update expo_set_mouse_enable() to call mouse_set_video() to configure the mouse with the display device. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/expo.c | 5 +++++ drivers/input/mouse-uclass.c | 17 +++++++++++++++++ include/mouse.h | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/boot/expo.c b/boot/expo.c index 8ec301d4dcf..99b9ad4d52b 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -178,6 +178,11 @@ int expo_set_mouse_enable(struct expo *exp, bool enable) if (ret) return log_msg_ret("sme", ret); + /* Tell the mouse driver about the video device for coordinate scaling */ + ret = mouse_set_video(exp->mouse, exp->display); + if (ret) + return log_msg_ret("msv", ret); + /* Get mouse pointer image and dimensions */ exp->mouse_ptr = video_image_getptr(riscos_arrow); if (exp->mouse_ptr) { diff --git a/drivers/input/mouse-uclass.c b/drivers/input/mouse-uclass.c index efb52d3377b..4ade394d68a 100644 --- a/drivers/input/mouse-uclass.c +++ b/drivers/input/mouse-uclass.c @@ -7,6 +7,7 @@ #include #include #include +#include int mouse_get_event(struct udevice *dev, struct mouse_event *evt) { @@ -93,6 +94,22 @@ int mouse_set_ptr_visible(struct udevice *dev, bool visible) return ops->set_ptr_visible(dev, visible); } +int mouse_set_video(struct udevice *dev, struct udevice *video_dev) +{ + struct mouse_uc_priv *uc_priv = dev_get_uclass_priv(dev); + + uc_priv->video_dev = video_dev; + if (video_dev) { + uc_priv->video_width = video_get_xsize(video_dev); + uc_priv->video_height = video_get_ysize(video_dev); + } else { + uc_priv->video_width = 0; + uc_priv->video_height = 0; + } + + return 0; +} + UCLASS_DRIVER(mouse) = { .id = UCLASS_MOUSE, .name = "mouse", diff --git a/include/mouse.h b/include/mouse.h index 98f54f73d88..560c7d14587 100644 --- a/include/mouse.h +++ b/include/mouse.h @@ -38,11 +38,17 @@ enum mouse_press_state_t { * @left_button_state: Current state of left button (BUTTON_PRESSED/BUTTON_RELEASED) * @click_pos: Position where the click occurred * @last_pos: Last position received from mouse + * @video_dev: Video device for coordinate scaling + * @video_width: Width of video display + * @video_height: Height of video display */ struct mouse_uc_priv { enum mouse_press_state_t left_button_state; struct vid_pos click_pos; struct vid_pos last_pos; + struct udevice *video_dev; + int video_width; + int video_height; }; /** @@ -159,4 +165,16 @@ int mouse_get_pos(struct udevice *dev, struct vid_pos *pos); */ int mouse_set_ptr_visible(struct udevice *dev, bool visible); +/** + * mouse_set_video() - Set the video device for coordinate scaling + * + * Sets up the video device in the mouse uclass private data so mouse drivers + * can scale coordinates to match the display resolution. + * + * @dev: Mouse device + * @video_dev: Video device + * Returns: 0 if OK, -ve on error + */ +int mouse_set_video(struct udevice *dev, struct udevice *video_dev); + #endif