From patchwork Mon Jan 19 20:41:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1640 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=1768855363; bh=zzKpnhGTgXu1URKWrngfjM3+TFhjcXB3qQYTRrU2yCw=; 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=ifCHZ3pdn+hALAs03WDPVdABybmVAlKDgM0JmSwwGoh64da6jiIU71N9KnaSme8B+ HdpZIygs8Yr9Jx7xXpOQAtk7KGZci0QNlSPIqGBylK48QlP+ywm6koMRlmJcMMWnz1 kuxMAfDuVp+sGkHXVvr6XCLLucRMqQva8LvanUvWZ4HyQ8146vU1V5KL91umY3CJ9Y 3M6ySkPBZtdKaasVrUmIbG8Is+x74GzQ2mVq438j95Wq5psazTm9yEPX14Bmk9b8Jc uDq8Njw32KdyRnBknv/7kqQAVqfCgmQOviGk+SJp/mHby7EbM06JC2JksCs+jXn1b3 VaSVRaeO1eTXg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0511D69504 for ; Mon, 19 Jan 2026 13:42:43 -0700 (MST) 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 7LLdToNVHTUj for ; Mon, 19 Jan 2026 13:42:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855362; bh=zzKpnhGTgXu1URKWrngfjM3+TFhjcXB3qQYTRrU2yCw=; 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=pTeuUhm9S/4vJkBeEK2OryhulWClFi2n2buFa6uxuAFx7xIsAZZL0deS0WDvks6f9 CpqDsL3HfHPQPFjoATT67lbk+8ZPogk5+fCJbYKSJcTHtTTiQ+qlH5m/gg9pe28FJ3 XuFqZ9jtCArVBTpfyJtPpLdrhlPjP7/njey+Er3btiE9v2yIFshzKd0u1B0evxErBa UnS5ID7QU2pHDw9TaPdsAQxwbQXn6u299Yg8PX203nj+IjJWeCbAIHWGFhK2p6dK3P 7VSMRt0pn7Uapki31OBUVmEjC6BvQxeldIDe7Gh+6UQ7/uhhnkRoPdxednrdpJd21q JlN2k4ZtzGTlw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E7E04694CE for ; Mon, 19 Jan 2026 13:42:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855360; bh=R8AbyUtIX6OKu8ocjHu6STWPiFc4hQoNns7EEeTfH3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w8Kw6Grunr74eOSKCvUr6MD76/COFD8HTPUIOawOKxsN8cUM9D3ZZjIQx+mflaSBK SqgxYVvdSdM7IbsUeINStDTkXC01NJb+lLOJXpahqFGgkpxjJt7JrHNKnmlrfnse8L MuDhBZhrIxSMU+6tLVChPLrw8RCpLq++AfAfqNvnR0/UECnfQoRYFYU5A51g5dT7az 68426WaCCcozpScx5slMrGaFgPInNXldHpoubEpF916QKMZ5Hevmmg/nEQ64BfBTeL Vg+EG5xyPkTxKJ+YUP+fN2Lg88z2alkSA8DhOrDv4gAGCKexDxH8m8TwvK1kRSw5rE 0mzxmO/e1XIcw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B81CD693BA; Mon, 19 Jan 2026 13:42:40 -0700 (MST) 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 tLscFdvjaqCD; Mon, 19 Jan 2026 13:42:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855356; bh=Hq8UTd3vX9kWLVXIM0zBe8CpBkam3BtfZUTos/uApIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k/kgJoKBy5S8IYHMrNDPU+JfBxJZgmz4mpKf2Ql4v0RFNtZUuhyKl84lbf07QOUNt t8EkFNY74m9ggPFwn7QUTisyNMBXVdXvxrucbrgv54Cn1CUdIFCR9Ig8vq7q9pv2fr Rx/IvFDoZb/OBbLhlpve42EBxiEPNuYIPQu61xpm97hWFl0g2fPN6UGMCRI8zUM+m1 ssQHxkMMGbFyb3swTkdSObvvitdBassjLXZZakFFit6fNMLbm5Okgr00+LmLT1DGPW kSjDNzeTnogrUuIZb8Cgq7O9Jvd063jIcPONHBfD2FWDsDLIdAkSVB51TuO3fak30f ufuaLYsAeZlew== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 67B60693E3; Mon, 19 Jan 2026 13:42:36 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 19 Jan 2026 13:41:03 -0700 Message-ID: <20260119204130.3972647-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260119204130.3972647-1-sjg@u-boot.org> References: <20260119204130.3972647-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: WW46PGFGF2URYDFAPJCTDRBBYWLIHICE X-Message-ID-Hash: WW46PGFGF2URYDFAPJCTDRBBYWLIHICE 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/27] sandbox: Add grid-drawing option to sandbox_sdl_sync() 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 an optional struct parameter to sandbox_sdl_sync() to control sync behaviour. Initially this supports drawing a 10-pixel grid overlay on the display, useful for debugging UI layout. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- arch/sandbox/cpu/sdl.c | 20 +++++++++++++++++++- arch/sandbox/include/asm/sdl.h | 8 ++++++-- arch/sandbox/include/asm/sdl_sync.h | 21 +++++++++++++++++++++ drivers/video/sandbox_sdl.c | 2 +- 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 arch/sandbox/include/asm/sdl_sync.h diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index dd2589c64e2..4a98d920c9f 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -310,7 +311,21 @@ static int copy_to_texture(void *lcd_base, const struct vid_bbox *damage) return 0; } -int sandbox_sdl_sync(void *lcd_base, const struct vid_bbox *damage) +static void draw_grid(void) +{ + int x, y; + + SDL_SetRenderDrawColor(sdl.renderer, 192, 192, 192, SDL_ALPHA_OPAQUE); + + for (x = 0; x < sdl.vis_width; x += 10) + SDL_RenderDrawLine(sdl.renderer, x, 0, x, sdl.vis_height - 1); + + for (y = 0; y < sdl.vis_height; y += 10) + SDL_RenderDrawLine(sdl.renderer, 0, y, sdl.vis_width - 1, y); +} + +int sandbox_sdl_sync(void *lcd_base, const struct vid_bbox *damage, + const struct sandbox_sdl_sync_opts *opts) { struct SDL_Rect rect; int ret; @@ -329,6 +344,9 @@ int sandbox_sdl_sync(void *lcd_base, const struct vid_bbox *damage) return -EIO; } + if (opts && opts->draw_grid) + draw_grid(); + /* * On some machines this does not appear. Draw an empty rectangle which * seems to fix that. diff --git a/arch/sandbox/include/asm/sdl.h b/arch/sandbox/include/asm/sdl.h index a80db51ad19..b2965a0a700 100644 --- a/arch/sandbox/include/asm/sdl.h +++ b/arch/sandbox/include/asm/sdl.h @@ -8,6 +8,7 @@ #include #include +#include struct mouse_event; struct vid_bbox; @@ -44,9 +45,11 @@ int sandbox_sdl_remove_display(void); * * @lcd_base: Base of frame buffer * @damage: Optional damage rectangle to limit the update region (may be NULL) + * @opts: Optional sync options (may be NULL) * Return: 0 if screen was updated, -ENODEV is there is no screen. */ -int sandbox_sdl_sync(void *lcd_base, const struct vid_bbox *damage); +int sandbox_sdl_sync(void *lcd_base, const struct vid_bbox *damage, + const struct sandbox_sdl_sync_opts *opts); /** * sandbox_sdl_scan_keys() - scan for pressed keys @@ -139,7 +142,8 @@ static inline int sandbox_sdl_remove_display(void) } static inline int sandbox_sdl_sync(void *lcd_base, - const struct vid_bbox *damage) + const struct vid_bbox *damage, + const struct sandbox_sdl_sync_opts *opts) { return -ENODEV; } diff --git a/arch/sandbox/include/asm/sdl_sync.h b/arch/sandbox/include/asm/sdl_sync.h new file mode 100644 index 00000000000..78f4233e056 --- /dev/null +++ b/arch/sandbox/include/asm/sdl_sync.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2026 Canonical Ltd + * Written by Simon Glass + */ + +#ifndef __SANDBOX_SDL_SYNC_H +#define __SANDBOX_SDL_SYNC_H + +#include + +/** + * struct sandbox_sdl_sync_opts - Options for sandbox_sdl_sync() + * + * @draw_grid: Draw a grid overlay on the display + */ +struct sandbox_sdl_sync_opts { + bool draw_grid; +}; + +#endif diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c index 7954e266d98..2e2ebe14f84 100644 --- a/drivers/video/sandbox_sdl.c +++ b/drivers/video/sandbox_sdl.c @@ -146,7 +146,7 @@ static int sandbox_sdl_video_sync(struct udevice *vid, uint flags) memset(&plat->last_sync_damage, '\0', sizeof(plat->last_sync_damage)); - return sandbox_sdl_sync(uc_priv->fb, damage); + return sandbox_sdl_sync(uc_priv->fb, damage, NULL); } static const struct video_ops sandbox_sdl_ops = {