{"id":812146,"url":"http://patchwork.ozlabs.org/api/patches/812146/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170910132236.14318-12-robdclark@gmail.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170910132236.14318-12-robdclark@gmail.com>","list_archive_url":null,"date":"2017-09-10T13:22:32","name":"[U-Boot,v1,11/12] dm: video: Add color ANSI escape sequence support","commit_ref":null,"pull_url":null,"state":"superseded","archived":true,"hash":"9ebec78d757a9c73ca3f5ca38eab1363a143cc87","submitter":{"id":18760,"url":"http://patchwork.ozlabs.org/api/people/18760/?format=json","name":"Rob Clark","email":"robdclark@gmail.com"},"delegate":{"id":3400,"url":"http://patchwork.ozlabs.org/api/users/3400/?format=json","username":"agraf","first_name":"Alexander","last_name":"Graf","email":"agraf@suse.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170910132236.14318-12-robdclark@gmail.com/mbox/","series":[{"id":2401,"url":"http://patchwork.ozlabs.org/api/series/2401/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=2401","date":"2017-09-10T13:22:21","name":"efi_loader+video: support for Shell.efi","version":1,"mbox":"http://patchwork.ozlabs.org/series/2401/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/812146/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/812146/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"IkGB8ZpK\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xqsMR6M8Cz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 10 Sep 2017 23:28:35 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 902E3C21E8C; Sun, 10 Sep 2017 13:27:09 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 66F96C21F9C;\n\tSun, 10 Sep 2017 13:24:11 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid A8A9DC21F7E; Sun, 10 Sep 2017 13:23:29 +0000 (UTC)","from mail-qk0-f195.google.com (mail-qk0-f195.google.com\n\t[209.85.220.195])\n\tby lists.denx.de (Postfix) with ESMTPS id 08936C21F26\n\tfor <u-boot@lists.denx.de>; Sun, 10 Sep 2017 13:23:20 +0000 (UTC)","by mail-qk0-f195.google.com with SMTP id r66so3910387qke.4\n\tfor <u-boot@lists.denx.de>; Sun, 10 Sep 2017 06:23:19 -0700 (PDT)","from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a])\n\tby smtp.gmail.com with ESMTPSA id\n\tm14sm4407130qti.51.2017.09.10.06.23.17\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSun, 10 Sep 2017 06:23:17 -0700 (PDT)"],"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=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=pSolHKWIFOYLriYRoaJrrVzZEfv3e0nodFSb8VLTvys=;\n\tb=IkGB8ZpK5bj3JzTcZFf/edG9GM+Q9xqR8G24TxdMoBb4ilAuXhVbVLSyOE05qpmEvC\n\tBFpmU+PaSXDPfTcD2e7B1HfwSVc3EpB/GJYz1mLu+cIhiRhQqdJm9VBqnHEgiKFkkwFp\n\tTpBwHzNFvG85Z+bGDqHTA4G4+WywP9d2wFx7IESxIAV00H2BzxP1xDHvcZUdViY+y1Kr\n\ttY7Lg7fduJAjGv9PT1BtP2pczI52n4zmUjZ7CgkyfdTmyK/0d6h6bM1JrrnyuCboSpiR\n\tdzc214NcqcFC9NBEV3d1SGKNqdmz69jZ0MRki1sglLnee4y3sEZUF6sZA98QsX5ETGya\n\txUeA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=pSolHKWIFOYLriYRoaJrrVzZEfv3e0nodFSb8VLTvys=;\n\tb=XYSXfJNx0GIMhS9quiMvi7ZCiP4TSYt1bRBScOLap6c56TOTWGDS2uPsYf/ZE5SALy\n\tignvvEdNqVfVVKCha1v/TId1Xt2GB7HRIDhXQSApqX4fjOw8Nl3YL1Bl7077d9+jJb+k\n\t6X2JqMnMlA2PPSqImMtrhzkdbU2+Y9UEx5wxgZkAcHkVIi9w8ANhbg8LfVdtwo2ulhqk\n\tdJp/zBVt0Rgr6xUeu3zGx1aks/bM8S17eKktFmX7Q/d8Q5d2NTNHJfPpyMYk7H36MVYE\n\t4SK25K4bcAVZ/G7l5mBvDulwRZUZZcW0T0FtVuU06MnqNSuWpIgs74N6H/xg0lvE0E4M\n\ttMkQ==","X-Gm-Message-State":"AHPjjUgiJU9ILdCuR13IYr3ehjABNXmeR5p4Sqt0QNTyYZ5w4TS6Bknm\n\td4+4xP9ZOC0HdsQuq1s=","X-Google-Smtp-Source":"ADKCNb747oukZBi7ORFsqjCBqBLXfi/JHPKcy87+WT4qnEbFR3J9hbmpVNrFgK5VrrwArbJvTT8lXQ==","X-Received":"by 10.55.141.66 with SMTP id p63mr11236283qkd.210.1505049798745; \n\tSun, 10 Sep 2017 06:23:18 -0700 (PDT)","From":"Rob Clark <robdclark@gmail.com>","To":"U-Boot Mailing List <u-boot@lists.denx.de>","Date":"Sun, 10 Sep 2017 09:22:32 -0400","Message-Id":"<20170910132236.14318-12-robdclark@gmail.com>","X-Mailer":"git-send-email 2.13.5","In-Reply-To":"<20170910132236.14318-1-robdclark@gmail.com>","References":"<20170910132236.14318-1-robdclark@gmail.com>","Cc":"Heinrich Schuchardt <xypron.glpk@gmx.de>,\n\tLeif Lindholm <leif.lindholm@linaro.org>","Subject":"[U-Boot] [PATCH v1 11/12] dm: video: Add color ANSI escape sequence\n\tsupport","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"Note that this doesn't differentiate (due to lack of information in\nvideo_priv) between different possible component orders for 32bpp.\nBut the main user at this point is efi_loader, and GOP expects xBGR\nso any video drivers that this is incorrect for already have problems.\n(Also, conveniently, this matches what simple-framebuffer bindings\nexpect for kernels that use the simple-framebuffer DT binding to\ntake over the bootloader display.)\n\nSigned-off-by: Rob Clark <robdclark@gmail.com>\n---\n drivers/video/vidconsole-uclass.c | 94 +++++++++++++++++++++++++++++++++++++++\n 1 file changed, 94 insertions(+)","diff":"diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c\nindex 7998b4cf5f..dae65a21ed 100644\n--- a/drivers/video/vidconsole-uclass.c\n+++ b/drivers/video/vidconsole-uclass.c\n@@ -108,6 +108,41 @@ static void vidconsole_newline(struct udevice *dev)\n \tvideo_sync(dev->parent);\n }\n \n+static const struct {\n+\tunsigned r;\n+\tunsigned g;\n+\tunsigned b;\n+} colors[] = {\n+\t{ 0x00, 0x00, 0x00 },  /* black */\n+\t{ 0xff, 0x00, 0x00 },  /* red */\n+\t{ 0x00, 0xff, 0x00 },  /* green */\n+\t{ 0xff, 0xff, 0x00 },  /* yellow */\n+\t{ 0x00, 0x00, 0xff },  /* blue */\n+\t{ 0xff, 0x00, 0xff },  /* magenta */\n+\t{ 0x00, 0xff, 0xff },  /* cyan */\n+\t{ 0xff, 0xff, 0xff },  /* white */\n+};\n+\n+static void set_color(struct video_priv *priv, unsigned idx, unsigned *c)\n+{\n+\tswitch (priv->bpix) {\n+\tcase VIDEO_BPP16:\n+\t\t*c = ((colors[idx].r >> 3) << 0) |\n+\t\t     ((colors[idx].g >> 2) << 5) |\n+\t\t     ((colors[idx].b >> 3) << 11);\n+\t\tbreak;\n+\tcase VIDEO_BPP32:\n+\t\t*c = 0xff000000 |\n+\t\t     (colors[idx].r << 0) |\n+\t\t     (colors[idx].g << 8) |\n+\t\t     (colors[idx].b << 16);\n+\t\tbreak;\n+\tdefault:\n+\t\t/* unsupported, leave current color in place */\n+\t\tbreak;\n+\t}\n+}\n+\n /*\n  * Parse a number from string that ends in a non-numeric character..\n  * sscanf() would be nice.  This is just enough for parsing ANSI escape\n@@ -197,6 +232,65 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)\n \t\t}\n \t\tbreak;\n \t}\n+\tcase 'm': {\n+\t\tstruct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);\n+\t\tchar *s = priv->escape_buf;\n+\t\tchar *end = &priv->escape_buf[priv->escape_len];\n+\n+\t\t/*\n+\t\t * Set graphics mode: [%d;...;%dm\n+\t\t *\n+\t\t * Currently only supports the color attributes:\n+\t\t *\n+\t\t * Foreground Colors:\n+\t\t *\n+\t\t *   30\tBlack\n+\t\t *   31\tRed\n+\t\t *   32\tGreen\n+\t\t *   33\tYellow\n+\t\t *   34\tBlue\n+\t\t *   35\tMagenta\n+\t\t *   36\tCyan\n+\t\t *   37\tWhite\n+\t\t *\n+\t\t * Background Colors:\n+\t\t *\n+\t\t *   40\tBlack\n+\t\t *   41\tRed\n+\t\t *   42\tGreen\n+\t\t *   43\tYellow\n+\t\t *   44\tBlue\n+\t\t *   45\tMagenta\n+\t\t *   46\tCyan\n+\t\t *   47\tWhite\n+\t\t */\n+\n+\t\ts++;    /* [ */\n+\t\twhile (s < end) {\n+\t\t\tint val;\n+\n+\t\t\ts = parsenum(s, &val);\n+\t\t\ts++;\n+\n+\t\t\tswitch (val) {\n+\t\t\tcase 30 ... 37:\n+\t\t\t\t/* fg color */\n+\t\t\t\tset_color(vid_priv, val - 30,\n+\t\t\t\t\t  (unsigned *)&vid_priv->colour_fg);\n+\t\t\t\tbreak;\n+\t\t\tcase 40 ... 47:\n+\t\t\t\t/* bg color */\n+\t\t\t\tset_color(vid_priv, val - 40,\n+\t\t\t\t\t  (unsigned *)&vid_priv->colour_bg);\n+\t\t\t\tbreak;\n+\t\t\tdefault:\n+\t\t\t\t/* unknown/unsupported */\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\tbreak;\n+\t}\n \tdefault:\n \t\tdebug(\"unrecognized escape sequence: %*s\\n\",\n \t\t      priv->escape_len, priv->escape_buf);\n","prefixes":["U-Boot","v1","11/12"]}