From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C33C7C433EF for ; Fri, 19 Nov 2021 20:24:58 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F056161AD2 for ; Fri, 19 Nov 2021 20:24:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F056161AD2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 89FB3833E7; Fri, 19 Nov 2021 21:24:45 +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=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="HKjbYWHV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5236C83452; Fri, 19 Nov 2021 21:24:35 +0100 (CET) Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) (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 7213183723 for ; Fri, 19 Nov 2021 21:24:22 +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-ot1-x32f.google.com with SMTP id x19-20020a9d7053000000b0055c8b39420bso18511418otj.1 for ; Fri, 19 Nov 2021 12:24:22 -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=h+IjyACJ0Ief3NIw421/zE/04r+fQBIgR+7UQDlk9Xc=; b=HKjbYWHVmgL//Be2maMGMvGoBZwwyE3kr5KbtOTsfDNF9ar9Nk3YtDjop0hDKHRgSx fVGpIuxo1qaZLRWBfVLwjAJukfCtWQl0NqftTvXumSAnBzpgmzVs2uEvnGcrAidPCi8s faMl/erufGKjdP4FUKqISLvm/PpmVgXrXtBIU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h+IjyACJ0Ief3NIw421/zE/04r+fQBIgR+7UQDlk9Xc=; b=8ElDWqV3m3N0K02GZRlr8Ulq/+28vgDKjjl84lVv2ZBvp5Jn57wl1ajV4SoY7bWryS 5/6IVtYduwm21FmEHpw/vSXdW+UzFw3J+1/W5uNeSqTIXsQ6070ohZKNv5Tn7mHDkmJt 56DFPqs8RsmQcGA9yEVYsmC8GDIT+YkeBgp6V+VwFvJJaUFCJPC1V3OnmYv2xBNZ8tTs Gm36y/mw6zxMdqLM5dDXNkfP6r0CafcAsxebeU6QP7n4NGi4Njmnl68yj2U6Knt32PA0 +9tPRTHVpEXCdYiu8Fsojtvv+W8SQIaWqEr+BCi4VCuoxOVeWKH1hrOsU4vtvSi8qHyC bNiQ== X-Gm-Message-State: AOAM533yr4YSV1zu2DMYp1kzNtq+zqRPGmr492uUANqRawaATB0AKWCj Cx0zagU8lHYK05LKtIr4q5KiiJ6389mvAQ== X-Google-Smtp-Source: ABdhPJwImnbU+9iLEQ6H3ePhHt8Vov+qz5sHZB3wjJWBBpvz/vInyMc+5p5T5RDOOeQhY/XvS8BZmA== X-Received: by 2002:a9d:7601:: with SMTP id k1mr7140225otl.356.1637353460919; Fri, 19 Nov 2021 12:24:20 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id bl33sm197093oib.47.2021.11.19.12.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 12:24:20 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Anatolij Gustschin , Tom Rini , Simon Glass , Harald Seiler Subject: [PATCH 02/23] video: sandbox: Avoid duplicate display windows Date: Fri, 19 Nov 2021 13:23:46 -0700 Message-Id: <20211119202408.1815506-3-sjg@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211119202408.1815506-1-sjg@chromium.org> References: <20211119202408.1815506-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 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.103.2 at phobos.denx.de X-Virus-Status: Clean When unit tests are run they currently create a new window. Update the code so that the old one is removed first. This avoids the confusion as to which one is active. Signed-off-by: Simon Glass --- arch/sandbox/cpu/sdl.c | 33 +++++++++++++++++++++++++++------ arch/sandbox/include/asm/sdl.h | 7 +++++++ drivers/video/sandbox_sdl.c | 15 +++++++++++++++ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index 7ff0df2ee54..f4ca36b35c8 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -44,6 +44,7 @@ struct buf_info { * @stopping: true if audio will stop once it runs out of data * @texture: SDL texture to use for U-Boot display contents * @renderer: SDL renderer to use + * @screen: SDL window to use * @src_depth: Number of bits per pixel in the source frame buffer (that we read * from and render to SDL) */ @@ -63,6 +64,7 @@ static struct sdl_info { bool stopping; SDL_Texture *texture; SDL_Renderer *renderer; + SDL_Window *screen; int src_depth; } sdl; @@ -101,6 +103,23 @@ static int sandbox_sdl_ensure_init(void) return 0; } +int sandbox_sdl_remove_display(void) +{ + if (!sdl.renderer) { + printf("SDL renderer does not exist\n"); + return -ENOENT; + } + + SDL_DestroyTexture(sdl.texture); + SDL_DestroyRenderer(sdl.renderer); + SDL_DestroyWindow(sdl.screen); + sdl.texture = NULL; + sdl.renderer = NULL; + sdl.screen = NULL; + + return 0; +} + int sandbox_sdl_init_display(int width, int height, int log2_bpp, bool double_size) { @@ -112,6 +131,9 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp, err = sandbox_sdl_ensure_init(); if (err) return err; + if (sdl.renderer) + sandbox_sdl_remove_display(); + if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { printf("Unable to initialise SDL LCD: %s\n", SDL_GetError()); return -EPERM; @@ -134,16 +156,15 @@ 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_Window *screen = SDL_CreateWindow("U-Boot", SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - sdl.vis_width, sdl.vis_height, - SDL_WINDOW_RESIZABLE); - if (!screen) { + sdl.screen = SDL_CreateWindow("U-Boot", SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, sdl.vis_width, + sdl.vis_height, SDL_WINDOW_RESIZABLE); + if (!sdl.screen) { printf("Unable to initialise SDL screen: %s\n", SDL_GetError()); return -EIO; } - sdl.renderer = SDL_CreateRenderer(screen, -1, + sdl.renderer = SDL_CreateRenderer(sdl.screen, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); if (!sdl.renderer) { diff --git a/arch/sandbox/include/asm/sdl.h b/arch/sandbox/include/asm/sdl.h index 47fc4889d20..25dbdb59442 100644 --- a/arch/sandbox/include/asm/sdl.h +++ b/arch/sandbox/include/asm/sdl.h @@ -25,6 +25,13 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp, bool double_size); +/** + * sandbox_sdl_remove_display() - Remove the SDL screen + * + * @return 0 if OK, -ENOENT if the SDL had not been inited. + */ +int sandbox_sdl_remove_display(void); + /** * sandbox_sdl_sync() - Sync current U-Boot LCD frame buffer to SDL * diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c index 32739de4feb..6e430b28244 100644 --- a/drivers/video/sandbox_sdl.c +++ b/drivers/video/sandbox_sdl.c @@ -63,6 +63,20 @@ static void set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp) uc_plat->size *= 2; } +static int sandbox_sdl_remove(struct udevice *dev) +{ + /* + * Removing the display it a bit annoying when running unit tests, since + * they remove all devices. It is nice to be able to see what the test + * wrote onto the display. So this comment is just here to show how to + * do it, if we want to make it optional one day. + * + * sandbox_sdl_remove_display(); + */ + + return 0; +} + static int sandbox_sdl_bind(struct udevice *dev) { struct sandbox_sdl_plat *plat = dev_get_plat(dev); @@ -90,5 +104,6 @@ U_BOOT_DRIVER(sandbox_lcd_sdl) = { .of_match = sandbox_sdl_ids, .bind = sandbox_sdl_bind, .probe = sandbox_sdl_probe, + .remove = sandbox_sdl_remove, .plat_auto = sizeof(struct sandbox_sdl_plat), }; -- 2.34.0.rc2.393.gf8c9666880-goog