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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 60226C77B7A for ; Thu, 1 Jun 2023 16:29:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A5FEB865BB; Thu, 1 Jun 2023 18:25:46 +0200 (CEST) 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="CSF5IiSI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CFAFC86358; Thu, 1 Jun 2023 18:25:16 +0200 (CEST) Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) (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 9175086383 for ; Thu, 1 Jun 2023 18:25:04 +0200 (CEST) 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-il1-x131.google.com with SMTP id e9e14a558f8ab-33b5dba8c6cso3415495ab.2 for ; Thu, 01 Jun 2023 09:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685636684; x=1688228684; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5b0kTaAkYbxIu9zF6TWjDBfix0YhWgdp7hPIQrsAAwE=; b=CSF5IiSIDNThtHSxxYzsoYyD5e4c8DonDR0JONnfU8+tZXo8rCyqNIvFfEF2EVc1CP 3S7bKeH0QdZxT0eayzh9G4omzTaQNyCcVSRMXiRBR9WdOPz6DPh3f29SSmsz5eQn7qwk OzvydBujir9f9/FWd5nmE7L0B3PKc/rY1D41U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685636684; x=1688228684; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5b0kTaAkYbxIu9zF6TWjDBfix0YhWgdp7hPIQrsAAwE=; b=e/8M1Ao/VrApcQsAtbUO0EA7zyKBPwPLsBLpaz8LjbrjD3GgFSUbOhlpdKM74lA+LZ nPchvjM5p9qF5oKMQm/0PYYCYPSupKrPXUPTK6xhAqFTLMx3cvdh52Yf3khcTLNdR5bD nUVj4xc8nY8shpokATY0HV/ygzDbWT5WliIQA9vybH9fr9GH8pHzE2V3GufTV4uLSKRd 3q3oNju1FHIGaqsTz8imYKE6se5wnb1S3mlnK4+xc3ARr/Huf2Fynk17qU4y47JBCO9O p/J6j+0SvoK95NrvoGHWXUu1MCVL17ROES2l/eENSFDE+lGSScg2HggvHb47p8i1rv3Q Ao6Q== X-Gm-Message-State: AC+VfDwoH/BV0KwpMzpSG+O6XjohidMhLSAQR6BggPI63kvrT+r0nbmQ J0U0EsM8Q13qHegTwGqiIPwR3/XjWniTOT1798w= X-Google-Smtp-Source: ACHHUZ5nNKpEMZCLvtRdAh7uBIzUYWiiEKAbHujs6nYAOSaWIiH0Qgbmosxep6x/YkDh2xgpxTMemw== X-Received: by 2002:a92:d90e:0:b0:334:c74c:43f9 with SMTP id s14-20020a92d90e000000b00334c74c43f9mr4863418iln.13.1685636684112; Thu, 01 Jun 2023 09:24:44 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id l1-20020a922901000000b0033a6e7ee4e3sm3862098ilg.1.2023.06.01.09.24.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 09:24:43 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Tom Rini , Simon Glass , Anatolij Gustschin Subject: [PATCH 21/40] video: Allow temporary colour changes Date: Thu, 1 Jun 2023 10:22:45 -0600 Message-ID: <20230601162404.220488-20-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog In-Reply-To: <20230601162404.220488-1-sjg@chromium.org> References: <20230601162404.220488-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean It is sometimes necessary to highlight some text in a different colour. Add an easy way to do this and then restore the original console colours. Signed-off-by: Simon Glass --- drivers/video/vidconsole-uclass.c | 20 ++++++++++++++++++++ include/video_console.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index a21fde0e1d46..3f89537c47b7 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -596,6 +596,26 @@ int vidconsole_select_font(struct udevice *dev, const char *name, uint size) return ops->select_font(dev, name, size); } +void vidconsole_push_colour(struct udevice *dev, enum colour_idx fg, + enum colour_idx bg, struct vidconsole_colour *old) +{ + struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); + + old->colour_fg = vid_priv->colour_fg; + old->colour_bg = vid_priv->colour_bg; + + vid_priv->colour_fg = video_index_to_colour(vid_priv, fg); + vid_priv->colour_bg = video_index_to_colour(vid_priv, bg); +} + +void vidconsole_pop_colour(struct udevice *dev, struct vidconsole_colour *old) +{ + struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); + + vid_priv->colour_fg = old->colour_fg; + vid_priv->colour_bg = old->colour_bg; +} + /* Set up the number of rows and colours (rotated drivers override this) */ static int vidconsole_pre_probe(struct udevice *dev) { diff --git a/include/video_console.h b/include/video_console.h index 3db9a7e1fb95..81d4c4d874df 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -71,6 +71,17 @@ struct vidfont_info { const char *name; }; +/** + * struct vidconsole_colour - Holds colour information + * + * @colour_fg: Foreground colour (pixel value) + * @colour_bg: Background colour (pixel value) + */ +struct vidconsole_colour { + u32 colour_fg; + u32 colour_bg; +}; + /** * struct vidconsole_ops - Video console operations * @@ -204,6 +215,25 @@ int vidconsole_get_font(struct udevice *dev, int seq, */ int vidconsole_select_font(struct udevice *dev, const char *name, uint size); +/** + * vidconsole_push_colour() - Temporarily change the font colour + * + * @dev: Device to adjust + * @fg: Foreground colour to select + * @bg: Background colour to select + * @old: Place to store the current colour, so it can be restored + */ +void vidconsole_push_colour(struct udevice *dev, enum colour_idx fg, + enum colour_idx bg, struct vidconsole_colour *old); + +/** + * vidconsole_pop_colour() - Restore the original colour + * + * @dev: Device to adjust + * @old: Old colour to be restored + */ +void vidconsole_pop_colour(struct udevice *dev, struct vidconsole_colour *old); + /** * vidconsole_putc_xy() - write a single character to a position * -- 2.41.0.rc0.172.g3f132b7071-goog