From mboxrd@z Thu Jan 1 00:00:00 1970 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 DB3B6C76196 for ; Mon, 3 Apr 2023 11:30:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0932685E34; Mon, 3 Apr 2023 13:30:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com 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=ti.com header.i=@ti.com header.b="MfzBhUCc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 549E185E36; Mon, 3 Apr 2023 13:30:17 +0200 (CEST) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 71D5885C65 for ; Mon, 3 Apr 2023 13:30:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=devarsht@ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 333BU8uJ079735; Mon, 3 Apr 2023 06:30:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1680521408; bh=czoYAm6VLZNvmgaSWZqjH8eb8t0xQ3z9g1ijkOiGaaA=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=MfzBhUCcyh2iWR5xFTxsxlGsuRDHu+p/iyINuCrM1OPlDHXm8f/W471mGJZw5ytvq ObKgscxYo5Cs9UHrZpmUsF98uIK0GnwRhNnG4lYX7sQuAMEq4dn927BnQY+KXcWHLE 2jNdAMyyNRgancGEkE1iszIGQ9vVJyv9DYyWiTag= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 333BU75Q030662 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 3 Apr 2023 06:30:08 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Mon, 3 Apr 2023 06:30:07 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Mon, 3 Apr 2023 06:30:07 -0500 Received: from [172.24.145.199] (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 333BU5w6112829; Mon, 3 Apr 2023 06:30:05 -0500 Message-ID: Date: Mon, 3 Apr 2023 17:00:03 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH V5 08/13] cmd: bmp: Split bmp commands and functions Content-Language: en-US To: Nikhil M Jain , , CC: , , References: <20230403081443.77933-1-n-jain1@ti.com> <20230403081443.77933-9-n-jain1@ti.com> From: Devarsh Thakkar In-Reply-To: <20230403081443.77933-9-n-jain1@ti.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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 On 03/04/23 13:44, Nikhil M Jain wrote: > To enable splash screen at spl, need to compile cmd/bmp.c which also s/spl/SPL > includes bmp commands, since SPL can't have commands split bmp.c into since SPL doesn't use bmp commands, split cmd/bmp.c into ... > common/bmp.c which includes all bmp functions and cmd/bmp.c contains cmd/bmp.c which only contains > bmp commands. > > Add delclaration for bmp_info in video.h. s/delclaration/function declaration > > Signed-off-by: Nikhil M Jain > --- > V5: > - Rename cmd/bmp_cmd to cmd/bmp. > > V4: > - No change. > > V3 (patch introduced): > - Split bmp functions and commands. > > cmd/bmp.c | 161 +----------------------------------------------- > common/bmp.c | 153 +++++++++++++++++++++++++++++++++++++++++++++ > include/video.h | 7 +++ > 3 files changed, 162 insertions(+), 159 deletions(-) > create mode 100644 common/bmp.c > > diff --git a/cmd/bmp.c b/cmd/bmp.c > index 46d0d916e8..735790fda7 100644 > --- a/cmd/bmp.c > +++ b/cmd/bmp.c > @@ -11,82 +11,11 @@ > #include > #include > #include > -#include > -#include > #include > -#include > -#include > #include > #include > #include > -#include > - Just to confirm, please test once with u-boot proper and bmp display command too if not done already. > -static int bmp_info (ulong addr); > - > -/* > - * Allocate and decompress a BMP image using gunzip(). > - * > - * Returns a pointer to the decompressed image data. This pointer is > - * aligned to 32-bit-aligned-address + 2. > - * See doc/README.displaying-bmps for explanation. > - * > - * The allocation address is passed to 'alloc_addr' and must be freed > - * by the caller after use. > - * > - * Returns NULL if decompression failed, or if the decompressed data > - * didn't contain a valid BMP signature. > - */ > -#ifdef CONFIG_VIDEO_BMP_GZIP > -struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, > - void **alloc_addr) > -{ > - void *dst; > - unsigned long len; > - struct bmp_image *bmp; > - > - /* > - * Decompress bmp image > - */ > - len = CONFIG_VIDEO_LOGO_MAX_SIZE; > - /* allocate extra 3 bytes for 32-bit-aligned-address + 2 alignment */ > - dst = malloc(CONFIG_VIDEO_LOGO_MAX_SIZE + 3); > - if (!dst) { > - puts("Error: malloc in gunzip failed!\n"); > - return NULL; > - } > - > - /* align to 32-bit-aligned-address + 2 */ > - bmp = dst + 2; > - > - if (gunzip(bmp, CONFIG_VIDEO_LOGO_MAX_SIZE, map_sysmem(addr, 0), > - &len)) { > - free(dst); > - return NULL; > - } > - if (len == CONFIG_VIDEO_LOGO_MAX_SIZE) > - puts("Image could be truncated (increase CONFIG_VIDEO_LOGO_MAX_SIZE)!\n"); > - > - /* > - * Check for bmp mark 'BM' > - */ > - if (!((bmp->header.signature[0] == 'B') && > - (bmp->header.signature[1] == 'M'))) { > - free(dst); > - return NULL; > - } > - > - debug("Gzipped BMP image detected!\n"); > - > - *alloc_addr = dst; > - return bmp; > -} > -#else > -struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, > - void **alloc_addr) > -{ > - return NULL; > -} > -#endif > +#include > > static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc, > char *const argv[]) > @@ -137,7 +66,7 @@ static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc, > return CMD_RET_USAGE; > } > > - return (bmp_display(addr, x, y)); > + return (bmp_display(addr, x, y)); > } > > static struct cmd_tbl cmd_bmp_sub[] = { > @@ -145,22 +74,6 @@ static struct cmd_tbl cmd_bmp_sub[] = { > U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""), > }; > > -#ifdef CONFIG_NEEDS_MANUAL_RELOC > -void bmp_reloc(void) { > - fixup_cmdtable(cmd_bmp_sub, ARRAY_SIZE(cmd_bmp_sub)); > -} > -#endif > - > -/* > - * Subroutine: do_bmp > - * > - * Description: Handler for 'bmp' command.. > - * > - * Inputs: argv[1] contains the subcommand > - * > - * Return: None > - * > - */ > static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) > { > struct cmd_tbl *c; > @@ -183,73 +96,3 @@ U_BOOT_CMD( > "info - display image info\n" > "bmp display [x y] - display image at x,y" > ); > - > -/* > - * Subroutine: bmp_info > - * > - * Description: Show information about bmp file in memory > - * > - * Inputs: addr address of the bmp file > - * > - * Return: None > - * > - */ > -static int bmp_info(ulong addr) > -{ > - struct bmp_image *bmp = (struct bmp_image *)map_sysmem(addr, 0); > - void *bmp_alloc_addr = NULL; > - unsigned long len; > - > - if (!((bmp->header.signature[0]=='B') && > - (bmp->header.signature[1]=='M'))) > - bmp = gunzip_bmp(addr, &len, &bmp_alloc_addr); > - > - if (bmp == NULL) { > - printf("There is no valid bmp file at the given address\n"); > - return 1; > - } > - > - printf("Image size : %d x %d\n", le32_to_cpu(bmp->header.width), > - le32_to_cpu(bmp->header.height)); > - printf("Bits per pixel: %d\n", le16_to_cpu(bmp->header.bit_count)); > - printf("Compression : %d\n", le32_to_cpu(bmp->header.compression)); > - > - if (bmp_alloc_addr) > - free(bmp_alloc_addr); > - > - return(0); > -} > - > -int bmp_display(ulong addr, int x, int y) > -{ > - struct udevice *dev; > - int ret; > - struct bmp_image *bmp = map_sysmem(addr, 0); > - void *bmp_alloc_addr = NULL; > - unsigned long len; > - > - if (!((bmp->header.signature[0]=='B') && > - (bmp->header.signature[1]=='M'))) > - bmp = gunzip_bmp(addr, &len, &bmp_alloc_addr); > - > - if (!bmp) { > - printf("There is no valid bmp file at the given address\n"); > - return 1; > - } > - addr = map_to_sysmem(bmp); > - > - ret = uclass_first_device_err(UCLASS_VIDEO, &dev); > - if (!ret) { > - bool align = false; > - > - if (x == BMP_ALIGN_CENTER || y == BMP_ALIGN_CENTER) > - align = true; > - > - ret = video_bmp_display(dev, addr, x, y, align); > - } > - > - if (bmp_alloc_addr) > - free(bmp_alloc_addr); > - > - return ret ? CMD_RET_FAILURE : 0; > -} > diff --git a/common/bmp.c b/common/bmp.c > new file mode 100644 > index 0000000000..540d06e63f > --- /dev/null > +++ b/common/bmp.c > @@ -0,0 +1,153 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * (C) Copyright 2002 > + * Detlev Zundel, DENX Software Engineering, dzu@denx.de. > + */ > + > +/* > + * BMP handling routines > + */ > + > +#include > +#include > +#include Do you need above header ? please remove any extra headers if not needed. Regards Devarsh > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* > + * Allocate and decompress a BMP image using gunzip(). > + * > + * Returns a pointer to the decompressed image data. This pointer is > + * aligned to 32-bit-aligned-address + 2. > + * See doc/README.displaying-bmps for explanation. > + * > + * The allocation address is passed to 'alloc_addr' and must be freed > + * by the caller after use. > + * > + * Returns NULL if decompression failed, or if the decompressed data > + * didn't contain a valid BMP signature. > + */ > +#ifdef CONFIG_VIDEO_BMP_GZIP > +struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, > + void **alloc_addr) > +{ > + void *dst; > + unsigned long len; > + struct bmp_image *bmp; > + > + /* > + * Decompress bmp image > + */ > + len = CONFIG_VIDEO_LOGO_MAX_SIZE; > + /* allocate extra 3 bytes for 32-bit-aligned-address + 2 alignment */ > + dst = malloc(CONFIG_VIDEO_LOGO_MAX_SIZE + 3); > + if (!dst) { > + puts("Error: malloc in gunzip failed!\n"); > + return NULL; > + } > + > + /* align to 32-bit-aligned-address + 2 */ > + bmp = dst + 2; > + > + if (gunzip(bmp, CONFIG_VIDEO_LOGO_MAX_SIZE, map_sysmem(addr, 0), > + &len)) { > + free(dst); > + return NULL; > + } > + if (len == CONFIG_VIDEO_LOGO_MAX_SIZE) > + puts("Image could be truncated (increase CONFIG_VIDEO_LOGO_MAX_SIZE)!\n"); > + > + /* > + * Check for bmp mark 'BM' > + */ > + if (!((bmp->header.signature[0] == 'B') && > + (bmp->header.signature[1] == 'M'))) { > + free(dst); > + return NULL; > + } > + > + debug("Gzipped BMP image detected!\n"); > + > + *alloc_addr = dst; > + return bmp; > +} > +#else > +struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, > + void **alloc_addr) > +{ > + return NULL; > +} > +#endif > + > + > +#ifdef CONFIG_NEEDS_MANUAL_RELOC > +void bmp_reloc(void) { > + fixup_cmdtable(cmd_bmp_sub, ARRAY_SIZE(cmd_bmp_sub)); > +} > +#endif > + > +int bmp_info(ulong addr) > +{ > + struct bmp_image *bmp = (struct bmp_image *)map_sysmem(addr, 0); > + void *bmp_alloc_addr = NULL; > + unsigned long len; > + > + if (!((bmp->header.signature[0]=='B') && > + (bmp->header.signature[1]=='M'))) > + bmp = gunzip_bmp(addr, &len, &bmp_alloc_addr); > + > + if (bmp == NULL) { > + printf("There is no valid bmp file at the given address\n"); > + return 1; > + } > + > + printf("Image size : %d x %d\n", le32_to_cpu(bmp->header.width), > + le32_to_cpu(bmp->header.height)); > + printf("Bits per pixel: %d\n", le16_to_cpu(bmp->header.bit_count)); > + printf("Compression : %d\n", le32_to_cpu(bmp->header.compression)); > + > + if (bmp_alloc_addr) > + free(bmp_alloc_addr); > + > + return(0); > +} > + > +int bmp_display(ulong addr, int x, int y) > +{ > + struct udevice *dev; > + int ret; > + struct bmp_image *bmp = map_sysmem(addr, 0); > + void *bmp_alloc_addr = NULL; > + unsigned long len; > + > + if (!((bmp->header.signature[0]=='B') && > + (bmp->header.signature[1]=='M'))) > + bmp = gunzip_bmp(addr, &len, &bmp_alloc_addr); > + > + if (!bmp) { > + printf("There is no valid bmp file at the given address\n"); > + return 1; > + } > + addr = map_to_sysmem(bmp); > + > + ret = uclass_first_device_err(UCLASS_VIDEO, &dev); > + if (!ret) { > + bool align = false; > + > + if (x == BMP_ALIGN_CENTER || y == BMP_ALIGN_CENTER) > + align = true; > + > + ret = video_bmp_display(dev, addr, x, y, align); > + } > + > + if (bmp_alloc_addr) > + free(bmp_alloc_addr); > + > + return ret ? CMD_RET_FAILURE : 0; > +} > diff --git a/include/video.h b/include/video.h > index 4d99e5dc27..b38fb9081a 100644 > --- a/include/video.h > +++ b/include/video.h > @@ -357,4 +357,11 @@ void *video_get_u_boot_logo(void); > */ > int bmp_display(ulong addr, int x, int y); > > +/* > + * bmp_info() - Show information about bmp file > + * > + * @addr: address of bmp file > + */ > +int bmp_info(ulong addr); > + > #endif