From patchwork Sun Jan 12 19:06:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1221859 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=O2YyxQm/; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47wmY86T0Sz9s29 for ; Mon, 13 Jan 2020 06:11:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E72A48182E; Sun, 12 Jan 2020 20:08:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="O2YyxQm/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1BD6881811; Sun, 12 Jan 2020 20:07:42 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,T_FILL_THIS_FORM_SHORT, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D63FC8180D for ; Sun, 12 Jan 2020 20:07:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd43.google.com with SMTP id c16so2875433iom.5 for ; Sun, 12 Jan 2020 11:07:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mh8Okggea+cKnntrTSBwz1awmrtkw1rqSsGoQJe/sNY=; b=O2YyxQm/mwR5DoDNetdROjg88EelrA2T31Qb+pbj4B9+eKU/mCTbLLI3RF0Rg9FqLA VOxBUWca15Z6Yl9M2eqBmN5kTYf7Dk+3Tc0XWh5cbjy8gx3WbnkdMg3k15FSX2RR6vNb rP9DSUXDtm0rGg+9qV5Q7CAuu3Ks2hlsJ4orE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mh8Okggea+cKnntrTSBwz1awmrtkw1rqSsGoQJe/sNY=; b=MRdTlERuOUwhiaF9PAfxs8U8XnNUUVoXBdXuz+f6e+SJlIkca/dB7q7cmquwQ7PJvI cZVfYK+WRNMUf/hkCqRtRpMmMJ3hufoTiySOVBVUSmFmPKHK8KeOGAZyc1DEc5rIH2gj 399GVxfGud4Fn1l0WXuOuGxBpbIecq5HhLMzrDQL0h9SNxLpwZ7w/be9XoqWs4LR/1m+ mG6aoz3yQrlIVur5lrmeDJDaADK6MLzVIobbwwp2HCBqGDfLAwGOVjdWt9giTD0Fqn45 czdR+Muoj2pkv9nxBo43vi4VUMzyY2+Z29aKXeMMwbRa2gNBciCCMxju2uYJtXLR8YAc 4Z+Q== X-Gm-Message-State: APjAAAXudY9jsv299AinydzuVhbbF0fqIuwwn5N2f99mJh6okaPbxBR/ WmkDXCBv6XDESzzCb5cmqafEYCxWARQ= X-Google-Smtp-Source: APXvYqxeMu9xUFppQ6wF2Y02D9tuP9b/ibIqAzksfbX6ntuKtUB/hR68ofX60reH9etsSjCdsdfhRw== X-Received: by 2002:a5d:970e:: with SMTP id h14mr2852590iol.201.1578856056675; Sun, 12 Jan 2020 11:07:36 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id r22sm3039219ilb.25.2020.01.12.11.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 11:07:36 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 27/33] sandbox: sdl: Add an option to double the screen size Date: Sun, 12 Jan 2020 12:06:18 -0700 Message-Id: <20200112120216.27.I48cb07fb0d542000360e9f2585be5e895a73d586@changeid> X-Mailer: git-send-email 2.25.0.rc1.283.g88dfdc4193-goog In-Reply-To: <20200112190624.79077-1-sjg@chromium.org> References: <20200112190624.79077-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean On high-DPI displays U-Boot's LCD window can look very small. Add a -K flag to expand it to make things easier to read, while still using the existing resolution internally. Signed-off-by: Simon Glass Reviewed-by: Anatolij Gustschin --- arch/sandbox/cpu/sdl.c | 17 +++++++++++++++-- arch/sandbox/cpu/start.c | 10 ++++++++++ arch/sandbox/include/asm/sdl.h | 9 ++++++--- arch/sandbox/include/asm/state.h | 1 + drivers/video/sandbox_sdl.c | 5 ++++- 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index 58a9cc8168..6416cab96c 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -30,6 +30,8 @@ struct buf_info { * * @width: Width of simulated LCD display * @height: Height of simulated LCD display + * @vis_width: Visible width (may be larger to allow for scaling up) + * @vis_height: Visible height (may be larger to allow for scaling up) * @depth: Depth of the display in bits per pixel (16 or 32) * @pitch: Number of bytes per line of the display * @sample_rate: Current sample rate for audio @@ -46,6 +48,8 @@ struct buf_info { static struct sdl_info { int width; int height; + int vis_width; + int vis_height; int depth; int pitch; uint sample_rate; @@ -94,7 +98,8 @@ static int sandbox_sdl_ensure_init(void) return 0; } -int sandbox_sdl_init_display(int width, int height, int log2_bpp) +int sandbox_sdl_init_display(int width, int height, int log2_bpp, + bool double_size) { struct sandbox_state *state = state_get_current(); int err; @@ -110,11 +115,19 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp) } sdl.width = width; sdl.height = height; + if (double_size) { + sdl.vis_width = sdl.width * 2; + sdl.vis_height = sdl.height * 2; + } else { + sdl.vis_width = sdl.width; + sdl.vis_height = sdl.height; + } + sdl.depth = 1 << log2_bpp; sdl.pitch = sdl.width * sdl.depth / 8; SDL_Window *screen = SDL_CreateWindow("U-Boot", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - sdl.width, sdl.height, 0); + sdl.vis_width, sdl.vis_height, 0); if (!screen) { printf("Unable to initialise SDL screen: %s\n", SDL_GetError()); diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index fa53428436..3655ebf157 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -308,6 +308,16 @@ static int sandbox_cmdline_cb_show_lcd(struct sandbox_state *state, SANDBOX_CMDLINE_OPT_SHORT(show_lcd, 'l', 0, "Show the sandbox LCD display"); +static int sandbox_cmdline_cb_double_lcd(struct sandbox_state *state, + const char *arg) +{ + state->double_lcd = true; + + return 0; +} +SANDBOX_CMDLINE_OPT_SHORT(double_lcd, 'K', 0, + "Double the LCD display size in each direction"); + static const char *term_args[STATE_TERM_COUNT] = { "raw-with-sigs", "raw", diff --git a/arch/sandbox/include/asm/sdl.h b/arch/sandbox/include/asm/sdl.h index c45dbddd70..47fc4889d2 100644 --- a/arch/sandbox/include/asm/sdl.h +++ b/arch/sandbox/include/asm/sdl.h @@ -17,10 +17,13 @@ * @height Window height in pixels * @log2_bpp: Log to base 2 of the number of bits per pixel. So a 32bpp * display will pass 5, since 2*5 = 32 + * @double_size: true to double the visible size in each direction for high-DPI + * displays * @return 0 if OK, -ENODEV if no device, -EIO if SDL failed to initialize * and -EPERM if the video failed to come up. */ -int sandbox_sdl_init_display(int width, int height, int log2_bpp); +int sandbox_sdl_init_display(int width, int height, int log2_bpp, + bool double_size); /** * sandbox_sdl_sync() - Sync current U-Boot LCD frame buffer to SDL @@ -78,8 +81,8 @@ int sandbox_sdl_sound_stop(void); int sandbox_sdl_sound_init(int rate, int channels); #else -static inline int sandbox_sdl_init_display(int width, int height, - int log2_bpp) +static inline int sandbox_sdl_init_display(int width, int height, int log2_bpp, + bool double_size) { return -ENODEV; } diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index ad3e94beb9..705645d714 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -83,6 +83,7 @@ struct sandbox_state { bool write_state; /* Write sandbox state on exit */ bool ignore_missing_state_on_read; /* No error if state missing */ bool show_lcd; /* Show LCD on start-up */ + bool double_lcd; /* Double display size for high-DPI */ enum sysreset_t last_sysreset; /* Last system reset type */ bool sysreset_allowed[SYSRESET_COUNT]; /* Allowed system reset types */ enum state_terminal_raw term_raw; /* Terminal raw/cooked */ diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c index 913651c565..d1272d0918 100644 --- a/drivers/video/sandbox_sdl.c +++ b/drivers/video/sandbox_sdl.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -23,9 +24,11 @@ static int sandbox_sdl_probe(struct udevice *dev) { struct sandbox_sdl_plat *plat = dev_get_platdata(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); + struct sandbox_state *state = state_get_current(); int ret; - ret = sandbox_sdl_init_display(plat->xres, plat->yres, plat->bpix); + ret = sandbox_sdl_init_display(plat->xres, plat->yres, plat->bpix, + state->double_lcd); if (ret) { puts("LCD init failed\n"); return ret;