From patchwork Tue Nov 6 22:21:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 993960 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42qPXf5jWNz9sBk for ; Wed, 7 Nov 2018 09:36:18 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 87FB1C2277C; Tue, 6 Nov 2018 22:26:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C89C7C22756; Tue, 6 Nov 2018 22:23:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 62F16C22756; Tue, 6 Nov 2018 22:22:54 +0000 (UTC) Received: from mail-io1-f73.google.com (mail-io1-f73.google.com [209.85.166.73]) by lists.denx.de (Postfix) with ESMTPS id 96E2FC2275D for ; Tue, 6 Nov 2018 22:22:49 +0000 (UTC) Received: by mail-io1-f73.google.com with SMTP id q26-v6so16491354ioi.21 for ; Tue, 06 Nov 2018 14:22:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=o1jaCoZ2eurDCtbPRkpwNstWqXT+vxU81qNZlwhMxQ4=; b=ZzSD9KsNx/Ec+y/8EqbKTtw8dZGqHaIn6WHa9AFe6zzrxgdGZ6z50csxYOWhNlpc2P N8+sYlQTYJgQEbUQgLrKC19cGmhvUu3R+ggdSNnL0B39/tm7iSwnJsgJPODF8s0HMfUX rycU/rfRNFgRoXgjbj+UfqeM9DUQjYsHsFmpvQ2xVg+WwD5rYv7Ov+e0An2oqm3z/qxL o4oJ/pIqaoidpLIg9OqlMmBcuGhVBegUjBb2Mm9OVomuYvn7HpV2rb50V6fKQr0mfn+d z2VN+50HM92nM7zG1MY5LaWRqYsKopr7xOncAd1YsGeCVu7aI8+vY2bUS4cT2IJobNus xDBA== X-Gm-Message-State: AGRZ1gI/Z/vPcd1HZVtkasvlfUPvI/cQm2MRHers1JJMEcypWNLVuO85 neXIqEzzSlNIZ6RCLKfFUFetHeE= X-Google-Smtp-Source: AJdET5dZBImQZGYH+1Iq45eKoGbdhl+RS4s68fXKFx8Rlg649wW4UKNPb78mQVF276eITrVnY4+LULo= X-Received: by 2002:a24:5495:: with SMTP id t143-v6mr2787831ita.34.1541542968668; Tue, 06 Nov 2018 14:22:48 -0800 (PST) Date: Tue, 6 Nov 2018 15:21:36 -0700 In-Reply-To: <20181106222142.94537-1-sjg@chromium.org> Message-Id: <20181106222142.94537-20-sjg@chromium.org> Mime-Version: 1.0 References: <20181106222142.94537-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 19/25] video: Update video_set_default_colors() to support invert X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" It is useful to be able to invert the colours in some cases so that the text matches the background colour. Add a parameter to the function to support this. It is strange that function takes a private data structure from another driver as an argument. It seems better to pass the device and have the function internally work out how to find its required information. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/video/vidconsole-uclass.c | 2 +- drivers/video/video-uclass.c | 27 +++++++++++++++++++-------- include/video.h | 5 +++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 1874887f2f3..d7568bc79a5 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -344,7 +344,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch) switch (val) { case 0: /* all attributes off */ - video_set_default_colors(vid_priv); + video_set_default_colors(dev->parent, false); break; case 1: /* bold */ diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 44dfa71b6f4..b6551b69d3a 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -115,18 +115,29 @@ int video_clear(struct udevice *dev) return 0; } -void video_set_default_colors(struct video_priv *priv) +void video_set_default_colors(struct udevice *dev, bool invert) { + struct video_priv *priv = dev_get_uclass_priv(dev); + int fore, back; + #ifdef CONFIG_SYS_WHITE_ON_BLACK /* White is used when switching to bold, use light gray here */ - priv->fg_col_idx = VID_LIGHT_GRAY; - priv->colour_fg = vid_console_color(priv, VID_LIGHT_GRAY); - priv->colour_bg = vid_console_color(priv, VID_BLACK); + fore = VID_LIGHT_GRAY; + back = VID_BLACK; #else - priv->fg_col_idx = VID_BLACK; - priv->colour_fg = vid_console_color(priv, VID_BLACK); - priv->colour_bg = vid_console_color(priv, VID_WHITE); + fore = VID_BLACK; + back = VID_WHITE; #endif + if (invert) { + int temp; + + temp = fore; + fore = back; + back = temp; + } + priv->fg_col_idx = fore; + priv->colour_fg = vid_console_color(priv, fore); + priv->colour_bg = vid_console_color(priv, back); } /* Flush video activity to the caches */ @@ -219,7 +230,7 @@ static int video_post_probe(struct udevice *dev) priv->fb_size = priv->line_length * priv->ysize; /* Set up colors */ - video_set_default_colors(priv); + video_set_default_colors(dev, false); if (!CONFIG_IS_ENABLED(NO_FB_CLEAR)) video_clear(dev); diff --git a/include/video.h b/include/video.h index 75200f0e452..3f9139eea44 100644 --- a/include/video.h +++ b/include/video.h @@ -191,9 +191,10 @@ void video_set_flush_dcache(struct udevice *dev, bool flush); /** * Set default colors and attributes * - * @priv device information + * @dev: video device + * @invert true to invert colours */ -void video_set_default_colors(struct video_priv *priv); +void video_set_default_colors(struct udevice *dev, bool invert); #endif /* CONFIG_DM_VIDEO */