From patchwork Tue Jan 19 02:52:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 569732 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id C790D140328 for ; Tue, 19 Jan 2016 13:53:21 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=Hr3Uf8r8; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 745E34BC59; Tue, 19 Jan 2016 03:53:12 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Az7Cubj2xuxe; Tue, 19 Jan 2016 03:53:12 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C54674BC5A; Tue, 19 Jan 2016 03:52:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3C5C64BC3D for ; Tue, 19 Jan 2016 03:52:40 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Md5F7fjZhl1Z for ; Tue, 19 Jan 2016 03:52:40 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ob0-f170.google.com (mail-ob0-f170.google.com [209.85.214.170]) by theia.denx.de (Postfix) with ESMTPS id A3DDA4BC3B for ; Tue, 19 Jan 2016 03:52:36 +0100 (CET) Received: by mail-ob0-f170.google.com with SMTP id py5so208599770obc.2 for ; Mon, 18 Jan 2016 18:52:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=1rhlVJyW3LmRiStRT10h6PCzV658y2JtcRQARli04hU=; b=Hr3Uf8r8+6OC8Pv7o+4w2Fj6CpMt7FPFgUsQU1jaHqM0kV5OzzYKpYirJ8WIu0Fy0k H+3U9Sgiz58OX2mHPLCHVZRDcPFovUgj5nIeaM0+T6w3178+epRbL8LEW5vMCJH8XpW+ SHhPlNGndfYRm9ym8lZZO1kq6o/8Y6MDhjCC5A5UZXRbbaaO80jZuh9iQ7F799Z+eLDw /BGQ5Z06I+yWsnb1GD2ZLNIHbSUA5yV3CWvhBryVuabVpiDDDMZfgmVlilsBD4ELZx+H KVN+9FsHOjTYmeYt49Z4JwChp6qGVqr0YV6SDKNE7sX422E8C175ofb9tQ+qIkWlN9nG g1EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=1rhlVJyW3LmRiStRT10h6PCzV658y2JtcRQARli04hU=; b=VMOtQJAP94gSLOgmNr0sk5bvC/CvnAUtA2JXqOBhPPWpbDz44gjgRK4PouuceuN1ZV Cz+DMno+vWgfTnpJ/4WQUq9XXJetiG4vM109dpCPgOnxC385qzeZUgn+SmzuTXpVzkEZ eFGog/cSD3ssOhpNXiSpV3FE8fv1QDa5zn9K6cIsLEOrHGEkG4Uab40/evzIKrgh44wl olzS9wMFOi+11/KA7NADP3x3+4X+1Nx5HLTMl2rQwdflMhS6nz2M5XJ2wXpWUehLBCzj tBKorvUVu3HaqniNUUFqP7S31LAsQb+Yk/OrbbfrzZ6ll+Drda9oF9iXCmpZ9pJg42Cc Piew== X-Gm-Message-State: AG10YOSFMF9wsJ6EpgxT0HvnbxH+ZW31u6sWbZqPguR3ybxb5hZG/f/eFtrLvnRi+yC8SqGt X-Received: by 10.182.213.71 with SMTP id nq7mr10576698obc.65.1453171954762; Mon, 18 Jan 2016 18:52:34 -0800 (PST) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id z190sm14525258oig.25.2016.01.18.18.52.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jan 2016 18:52:32 -0800 (PST) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 267D0221417; Mon, 18 Jan 2016 19:52:31 -0700 (MST) From: Simon Glass To: U-Boot Mailing List Date: Mon, 18 Jan 2016 19:52:18 -0700 Message-Id: <1453171948-16022-5-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1453171948-16022-1-git-send-email-sjg@chromium.org> References: <1453171948-16022-1-git-send-email-sjg@chromium.org> Subject: [U-Boot] [PATCH v2 04/14] dm: video: Add a 'normal' text console driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Most of the time we don't need to rotate the display so a simple font blitting feature is enough for our purposes. Add a simple driver which supports this function. It provides text output on the console using the standard 8x16-pixel font. Signed-off-by: Simon Glass Acked-by: Anatolij Gustschin --- Changes in v2: None drivers/video/Makefile | 2 +- drivers/video/console_normal.c | 141 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 drivers/video/console_normal.c diff --git a/drivers/video/Makefile b/drivers/video/Makefile index e82f1ae..b4eba8e 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -7,7 +7,7 @@ ifdef CONFIG_DM obj-$(CONFIG_DISPLAY_PORT) += dp-uclass.o -obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o +obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o console_normal.o endif obj-$(CONFIG_ATI_RADEON_FB) += ati_radeon_fb.o videomodes.o diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c new file mode 100644 index 0000000..d1031c8 --- /dev/null +++ b/drivers/video/console_normal.c @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2015 Google, Inc + * (C) Copyright 2001-2015 + * DENX Software Engineering -- wd@denx.de + * Compulab Ltd - http://compulab.co.il/ + * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include /* Get font data, width and height */ + +static int console_normal_set_row(struct udevice *dev, uint row, int clr) +{ + struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); + void *line; + int pixels = VIDEO_FONT_HEIGHT * vid_priv->line_length; + int i; + + line = vid_priv->fb + row * VIDEO_FONT_HEIGHT * vid_priv->line_length; + switch (vid_priv->bpix) { +#ifdef CONFIG_VIDEO_BPP8 + case VIDEO_BPP8: { + uint8_t *dst = line; + + for (i = 0; i < pixels; i++) + *dst++ = clr; + break; + } +#endif +#ifdef CONFIG_VIDEO_BPP16 + case VIDEO_BPP16: { + uint16_t *dst = line; + + for (i = 0; i < pixels; i++) + *dst++ = clr; + break; + } +#endif +#ifdef CONFIG_VIDEO_BPP32 + case VIDEO_BPP32: { + uint32_t *dst = line; + + for (i = 0; i < pixels; i++) + *dst++ = clr; + break; + } +#endif + default: + return -ENOSYS; + } + + return 0; +} + +static int console_normal_move_rows(struct udevice *dev, uint rowdst, + uint rowsrc, uint count) +{ + struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); + void *dst; + void *src; + + dst = vid_priv->fb + rowdst * VIDEO_FONT_HEIGHT * vid_priv->line_length; + src = vid_priv->fb + rowsrc * VIDEO_FONT_HEIGHT * vid_priv->line_length; + memmove(dst, src, VIDEO_FONT_HEIGHT * vid_priv->line_length * count); + + return 0; +} + +static int console_normal_putc_xy(struct udevice *dev, uint x, uint y, char ch) +{ + struct udevice *vid = dev->parent; + struct video_priv *vid_priv = dev_get_uclass_priv(vid); + int i, row; + void *line = vid_priv->fb + y * vid_priv->line_length + + x * VNBYTES(vid_priv->bpix); + + for (row = 0; row < VIDEO_FONT_HEIGHT; row++) { + uchar bits = video_fontdata[ch * VIDEO_FONT_HEIGHT + row]; + + switch (vid_priv->bpix) { +#ifdef CONFIG_VIDEO_BPP8 + case VIDEO_BPP8: { + uint8_t *dst = line; + + for (i = 0; i < VIDEO_FONT_WIDTH; i++) { + *dst++ = (bits & 0x80) ? vid_priv->colour_fg + : vid_priv->colour_bg; + bits <<= 1; + } + break; + } +#endif +#ifdef CONFIG_VIDEO_BPP16 + case VIDEO_BPP16: { + uint16_t *dst = line; + + for (i = 0; i < VIDEO_FONT_WIDTH; i++) { + *dst++ = (bits & 0x80) ? vid_priv->colour_fg + : vid_priv->colour_bg; + bits <<= 1; + } + break; + } +#endif +#ifdef CONFIG_VIDEO_BPP32 + case VIDEO_BPP32: { + uint32_t *dst = line; + + for (i = 0; i < VIDEO_FONT_WIDTH; i++) { + *dst++ = (bits & 0x80) ? vid_priv->colour_fg + : vid_priv->colour_bg; + bits <<= 1; + } + break; + } +#endif + default: + return -ENOSYS; + } + line += vid_priv->line_length; + } + + return 0; +} + +struct vidconsole_ops console_normal_ops = { + .putc_xy = console_normal_putc_xy, + .move_rows = console_normal_move_rows, + .set_row = console_normal_set_row, +}; + +U_BOOT_DRIVER(vidconsole_normal) = { + .name = "vidconsole0", + .id = UCLASS_VIDEO_CONSOLE, + .ops = &console_normal_ops, +};