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 7ADE0C433EF for ; Fri, 19 Nov 2021 20:25:46 +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 B59FE613C8 for ; Fri, 19 Nov 2021 20:25:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B59FE613C8 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 F0FB283433; Fri, 19 Nov 2021 21:24:53 +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="UXEid0y1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A00ED83685; Fri, 19 Nov 2021 21:24:40 +0100 (CET) Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) (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 BD26983731 for ; Fri, 19 Nov 2021 21:24:24 +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-oi1-x22e.google.com with SMTP id q25so24093497oiw.0 for ; Fri, 19 Nov 2021 12:24:24 -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=uTjii9r2UxwjO+Cuxr4k4Ds0tfPD4W+arkMEUid4KYc=; b=UXEid0y1b0Chzq9T60xH+u8EHMI/MxByCAMGV3GIeq+57rEQkxiOGgcoMzs8Wn/quG C30RdLUyzXeXBlR4JGYWwlQ51cGEXpSlNt4TQ5dijgOSWk2pA1N9f5H9OAsRz/MEbPbD fxc+EPYFriLS1GwY7M8zP/2qDp5XBdEpc4vhs= 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=uTjii9r2UxwjO+Cuxr4k4Ds0tfPD4W+arkMEUid4KYc=; b=5tCDAsmGiDAhTdEp+6O6lkobOisUti8jERZe8DBsYOC2B/tiJd7B39iB/7HNy1kG/+ wMXDcYEslkNiRp4/rB/MzDDLyqTVijbkMo6lqP3ls/+F2epqPjeJIForufb3YSz6OcgU H5huVjVOQ7L1bN/0EeihVrBJlBkqjVhqHKPIsLNFD1rH7iP0KwXJM4hgi67hHuLRKNbg M9dwk4psHcxLAhdFiQC32yaFHiy0Yop/Df4KK6ZBH38us0EslVh1hmUJz0tGqrONtI6K gxwVryWFzVYww3Ffbxydvf4Xs+jFQ5ei0Ejkz3Qe881F7b9GqJK6IZcmR2HTGnlZVPnb GG8g== X-Gm-Message-State: AOAM530JA/j++WrC4sXFhQmMZWYktH3vt35vJmw9Ol2vWLoVcwNxSVpY fpASApQlRPuneMsei3AC8VRvDEVdJ481BQ== X-Google-Smtp-Source: ABdhPJwADy2ydf24R3Rs2iSfnSCXHPZWn9HHS/WZtBTfHnxELDYI1a10j8rK2IiAIf7wdwWhCB7GVQ== X-Received: by 2002:aca:d704:: with SMTP id o4mr2369940oig.99.1637353462800; Fri, 19 Nov 2021 12:24:22 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 12:24:22 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Anatolij Gustschin , Tom Rini , Simon Glass Subject: [PATCH 04/23] video: sandbox: Set a maximum frame-buffer size Date: Fri, 19 Nov 2021 13:23:48 -0700 Message-Id: <20211119202408.1815506-5-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 If U-Boot starts with the frame buffer set to 16bpp but then runs a test that uses 32bpp, there is not enough space. Update the driver to use the maximum possible frame-buffer size, to avoid this. Signed-off-by: Simon Glass --- drivers/video/sandbox_sdl.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c index 6e430b28244..de8c6609c46 100644 --- a/drivers/video/sandbox_sdl.c +++ b/drivers/video/sandbox_sdl.c @@ -55,10 +55,26 @@ static void set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp) plat->bpix = l2bpp; - uc_plat->size = plat->xres * plat->yres * (1 << plat->bpix) / 8; + uc_plat->size = plat->xres * plat->yres * VNBYTES(plat->bpix); + + /* + * Set up to the maximum size we'll ever need. This is a strange case. + * The video memory is allocated by video_post_bind() called from + * board_init_r(). If a test changes the reoslution so it needs more + * memory later (with sandbox_sdl_set_bpp()), it is too late to make + * the frame buffer larger. + * + * So use a maximum size here. + */ + uc_plat->size = max(uc_plat->size, 1920U * 1080 * VNBYTES(VIDEO_BPP32)); /* Allow space for two buffers, the lower one being the copy buffer */ log_debug("Frame buffer size %x\n", uc_plat->size); + + /* + * If a copy framebuffer is used, double the size and use the last half + * as the copy, with the first half as the normal frame buffer. + */ if (IS_ENABLED(CONFIG_VIDEO_COPY)) uc_plat->size *= 2; } -- 2.34.0.rc2.393.gf8c9666880-goog