From patchwork Thu Jun 13 03:12:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Schocher X-Patchwork-Id: 1114922 X-Patchwork-Delegate: agust@denx.de 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=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45PTMY66s6z9s9y for ; Thu, 13 Jun 2019 13:13:11 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EFACEC22263; Thu, 13 Jun 2019 03:13:08 +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=none 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 3BE9DC21EBA; Thu, 13 Jun 2019 03:13:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E9DF4C21EBA; Thu, 13 Jun 2019 03:13:04 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by lists.denx.de (Postfix) with ESMTPS id A3E4CC21E90 for ; Thu, 13 Jun 2019 03:13:04 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 45PTMN3FMpz1rYX6 for ; Thu, 13 Jun 2019 05:13:04 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 45PTMN36rlz1sYVG for ; Thu, 13 Jun 2019 05:13:04 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 3d5jbnpXaKYh for ; Thu, 13 Jun 2019 05:13:03 +0200 (CEST) X-Auth-Info: /JSkatEJPE4Y/2UH/NzhBJ8I/klOsYNXHhBuZwxaNxE= Received: from mail-internal.denx.de (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA for ; Thu, 13 Jun 2019 05:13:03 +0200 (CEST) Received: from pollux.denx.de (pollux [192.168.1.1]) by mail-internal.denx.de (Postfix) with ESMTP id 73261183195; Thu, 13 Jun 2019 05:12:43 +0200 (CEST) Received: by pollux.denx.de (Postfix, from userid 515) id 5F0681A0086; Thu, 13 Jun 2019 05:12:40 +0200 (CEST) From: Heiko Schocher To: U-Boot Mailing List Date: Thu, 13 Jun 2019 05:12:38 +0200 Message-Id: <20190613031239.76865-1-hs@denx.de> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Cc: Teddy Reed , Otavio Salvador , Thomas Petazzoni , Fabrice Fontaine Subject: [U-Boot] [PATCH] bmp_logo: support CONFIG_DM_VIDEO 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" in case of bmp_logo, the video_bmp driver is used for drawing a bmp logo. This driver supports only "full" bmp data. Adding a logo with the bmp_logo tool to u-boot binary adds currently only real data and drops the bmp header. This patch adds now the full bmp data to the u-boot binary, so video_bmp driver works with the logo embedded into u-boot. Fixed also some checkpatch error poping up with this patch. Signed-off-by: Heiko Schocher --- tools/Makefile | 6 ++++++ tools/bmp_logo.c | 42 +++++++++++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 33e90a8025..d0e1ded61b 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -266,8 +266,14 @@ __build: $(LOGO-y) $(LOGO_H): $(obj)/bmp_logo $(LOGO_BMP) $(obj)/bmp_logo --gen-info $(LOGO_BMP) > $@ +ifeq ($(CONFIG_DM_VIDEO),y) +$(LOGO_DATA_H): $(obj)/bmp_logo $(LOGO_BMP) + $(obj)/bmp_logo --gen-bmp $(LOGO_BMP) > $@ +else $(LOGO_DATA_H): $(obj)/bmp_logo $(LOGO_BMP) $(obj)/bmp_logo --gen-data $(LOGO_BMP) > $@ +#endif +endif # Let clean descend into subdirs subdir- += env diff --git a/tools/bmp_logo.c b/tools/bmp_logo.c index 55f833fb9b..74fcadca63 100644 --- a/tools/bmp_logo.c +++ b/tools/bmp_logo.c @@ -2,7 +2,8 @@ enum { MODE_GEN_INFO, - MODE_GEN_DATA + MODE_GEN_DATA, + MODE_GEN_BMP }; typedef struct bitmap_s { /* bitmap description */ @@ -16,7 +17,8 @@ typedef struct bitmap_s { /* bitmap description */ void usage(const char *prog) { - fprintf(stderr, "Usage: %s [--gen-info|--gen-data] file\n", prog); + fprintf(stderr, "Usage: %s [--gen-info|--gen-data|--gen-bmp] file\n", + prog); } /* @@ -73,6 +75,7 @@ void gen_info(bitmap_t *b, uint16_t n_colors) int main (int argc, char *argv[]) { int mode, i, x; + int size; FILE *fp; bitmap_t bmp; bitmap_t *b = &bmp; @@ -87,6 +90,8 @@ int main (int argc, char *argv[]) mode = MODE_GEN_INFO; else if (!strcmp(argv[1], "--gen-data")) mode = MODE_GEN_DATA; + else if (!strcmp(argv[1], "--gen-bmp")) + mode = MODE_GEN_BMP; else { usage(argv[0]); exit(EXIT_FAILURE); @@ -131,6 +136,7 @@ int main (int argc, char *argv[]) b->width = le_short(b->width); b->height = le_short(b->height); n_colors = le_short(n_colors); + size = b->width * b->height; /* assume we are working with an 8-bit file */ if ((n_colors == 0) || (n_colors > 256 - DEFAULT_CMAP_SIZE)) { @@ -152,10 +158,6 @@ int main (int argc, char *argv[]) "#ifndef __BMP_LOGO_DATA_H__\n" "#define __BMP_LOGO_DATA_H__\n\n"); - /* allocate memory */ - if ((b->data = (uint8_t *)malloc(b->width * b->height)) == NULL) - error ("Error allocating memory for file", fp); - /* read and print the palette information */ printf("unsigned short bmp_logo_palette[] = {\n"); @@ -175,21 +177,39 @@ int main (int argc, char *argv[]) } /* seek to offset indicated by file header */ - fseek(fp, (long)data_offset, SEEK_SET); + if (mode == MODE_GEN_BMP) { + /* copy full bmp file */ + fseek(fp, 0L, SEEK_END); + size = ftell(fp); + fseek(fp, 0L, SEEK_SET); + } else { + fseek(fp, (long)data_offset, SEEK_SET); + } + + /* allocate memory */ + b->data = (uint8_t *)malloc(size); + if (!b->data) + error("Error allocating memory for file", fp); /* read the bitmap; leave room for default color map */ printf ("\n"); printf ("};\n"); printf ("\n"); printf("unsigned char bmp_logo_bitmap[] = {\n"); - for (i=(b->height-1)*b->width; i>=0; i-=b->width) { - for (x = 0; x < b->width; x++) { - b->data[i + x] = (uint8_t) fgetc(fp) + if (mode == MODE_GEN_BMP) { + /* write full bmp */ + for (i = 0; i < size; i++) + b->data[i] = (uint8_t)fgetc(fp); + } else { + for (i = (b->height - 1) * b->width; i >= 0; i -= b->width) { + for (x = 0; x < b->width; x++) { + b->data[i + x] = (uint8_t)fgetc(fp) + DEFAULT_CMAP_SIZE; + } } } - for (i=0; i<(b->height*b->width); ++i) { + for (i = 0; i < size; ++i) { if ((i%8) == 0) putchar ('\t'); printf ("0x%02X,%c",