Merge branch '2019-08-26-master-imports'

- Assorted minor bugfixes
This commit is contained in:
Tom Rini 2019-08-26 17:45:20 -04:00
commit 12277acda0
34 changed files with 92 additions and 2617 deletions

View File

@ -31,8 +31,8 @@ Markus Klotzbuecher <mk@denx.de>
Paul Burton <paul.burton@mips.com> <paul.burton@imgtec.com>
Prabhakar Kushwaha <prabhakar@freescale.com>
Rajeshwari Shinde <rajeshwari.s@samsung.com>
Ricardo Ribalda <ricardo.ribalda@uam.es>
Ricardo Ribalda <ricardo.ribalda@gmail.com>
Ricardo Ribalda <ricardo@ribalda.com> <ricardo.ribalda@uam.es>
Ricardo Ribalda <ricardo@ribalda.com> <ricardo.ribalda@gmail.com>
Sandeep Paulraj <s-paulraj@ti.com>
Shaohui Xie <Shaohui.Xie@freescale.com>
Stefan Roese <stroese>

View File

@ -228,6 +228,20 @@
>;
};
i2c2_pins: pinmux_i2c2_pins {
pinctrl-single,pins = <
OMAP3_CORE1_IOPAD(0x21be, PIN_INPUT | MUX_MODE0) /* i2c2_scl */
OMAP3_CORE1_IOPAD(0x21c0, PIN_INPUT | MUX_MODE0) /* i2c2_sda */
>;
};
i2c3_pins: pinmux_i2c3_pins {
pinctrl-single,pins = <
OMAP3_CORE1_IOPAD(0x21c2, PIN_INPUT | MUX_MODE0) /* i2c3_scl */
OMAP3_CORE1_IOPAD(0x21c4, PIN_INPUT | MUX_MODE0) /* i2c3_sda */
>;
};
tsc2004_pins: pinmux_tsc2004_pins {
pinctrl-single,pins = <
OMAP3_CORE1_IOPAD(0x2186, PIN_INPUT | MUX_MODE4) /* mcbsp4_dr.gpio_153 */
@ -249,18 +263,6 @@
OMAP3_WKUP_IOPAD(0x2a0c, PIN_OUTPUT | MUX_MODE4) /* sys_boot1.gpio_3 */
>;
};
i2c2_pins: pinmux_i2c2_pins {
pinctrl-single,pins = <
OMAP3_CORE1_IOPAD(0x21be, PIN_INPUT | MUX_MODE0) /* i2c2_scl */
OMAP3_CORE1_IOPAD(0x21c0, PIN_INPUT | MUX_MODE0) /* i2c2_sda */
>;
};
i2c3_pins: pinmux_i2c3_pins {
pinctrl-single,pins = <
OMAP3_CORE1_IOPAD(0x21c2, PIN_INPUT | MUX_MODE0) /* i2c3_scl */
OMAP3_CORE1_IOPAD(0x21c4, PIN_INPUT | MUX_MODE0) /* i2c3_sda */
>;
};
};
&omap3_pmx_core2 {

View File

@ -1,5 +1,5 @@
DRACO BOARD
M: Roger Meier <r.meier@siemens.com>
M: Samuel Egli <samuel.egli@siemens.com>
S: Maintained
F: board/siemens/draco/
F: include/configs/draco.h

View File

@ -1,5 +1,5 @@
PXM2 BOARD
M: Roger Meier <r.meier@siemens.com>
M: Samuel Egli <samuel.egli@siemens.com>
S: Maintained
F: board/siemens/pxm2/
F: include/configs/pxm2.h

View File

@ -1,5 +1,5 @@
RUT BOARD
M: Roger Meier <r.meier@siemens.com>
M: Samuel Egli <samuel.egli@siemens.com>
S: Maintained
F: board/siemens/rut/
F: include/configs/rut.h

View File

@ -91,7 +91,7 @@ static int do_gpio_status(bool all, const char *gpio_name)
if (!gpio_name || !bank_name ||
!strncasecmp(gpio_name, bank_name, banklen)) {
const char *p = NULL;
const char *p;
int offset;
p = gpio_name + banklen;

View File

@ -148,7 +148,7 @@ int pci_bar_show(struct udevice *dev)
if ((!is_64 && size_low) || (is_64 && size)) {
size = ~size + 1;
printf(" %d %#016llx %#016llx %d %s %s\n",
printf(" %d %#018llx %#018llx %d %s %s\n",
bar_id, (unsigned long long)base,
(unsigned long long)size, is_64 ? 64 : 32,
is_io ? "I/O" : "MEM",
@ -629,10 +629,10 @@ static void pci_show_regions(struct udevice *bus)
return;
}
printf("# %-16s %-16s %-16s %s\n", "Bus start", "Phys start", "Size",
printf("# %-18s %-18s %-18s %s\n", "Bus start", "Phys start", "Size",
"Flags");
for (i = 0, reg = hose->regions; i < hose->region_count; i++, reg++) {
printf("%d %#016llx %#016llx %#016llx ", i,
printf("%d %#018llx %#018llx %#018llx ", i,
(unsigned long long)reg->bus_start,
(unsigned long long)reg->phys_start,
(unsigned long long)reg->size);

View File

@ -467,12 +467,29 @@ static int reserve_uboot(void)
return 0;
}
#ifdef CONFIG_SYS_NONCACHED_MEMORY
static int reserve_noncached(void)
{
/* round down to SECTION SIZE (typicaly 1MB) limit */
gd->start_addr_sp &= ~(MMU_SECTION_SIZE - 1);
gd->start_addr_sp -= CONFIG_SYS_NONCACHED_MEMORY;
debug("Reserving %dM for noncached_alloc() at: %08lx\n",
CONFIG_SYS_NONCACHED_MEMORY >> 20, gd->start_addr_sp);
return 0;
}
#endif
/* reserve memory for malloc() area */
static int reserve_malloc(void)
{
gd->start_addr_sp = gd->start_addr_sp - TOTAL_MALLOC_LEN;
debug("Reserving %dk for malloc() at: %08lx\n",
TOTAL_MALLOC_LEN >> 10, gd->start_addr_sp);
#ifdef CONFIG_SYS_NONCACHED_MEMORY
reserve_noncached();
#endif
return 0;
}

View File

@ -435,6 +435,7 @@ config SPL_HASH_SUPPORT
config TPL_HASH_SUPPORT
bool "Support hashing drivers in TPL"
depends on TPL
select SHA1
select SHA256
help

View File

@ -15,6 +15,8 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_VERSION_VARIABLE=y
CONFIG_SPL_MTD_SUPPORT=y
CONFIG_SPL_OS_BOOT=y
CONFIG_SPL_USB_GADGET=y
CONFIG_SPL_USB_ETHER=y
CONFIG_SPL_USB_HOST_SUPPORT=y
CONFIG_CMD_SPL=y
CONFIG_CMD_SPL_NAND_OFS=0x00100000
@ -60,6 +62,7 @@ CONFIG_TI_QSPI=y
CONFIG_TIMER=y
CONFIG_OMAP_TIMER=y
CONFIG_USB=y
CONFIG_DM_USB=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_XHCI_DWC3=y
CONFIG_USB_DWC3=y

View File

@ -40,6 +40,7 @@ CONFIG_DEFAULT_DEVICE_TREE="da850-evm"
CONFIG_ENV_IS_IN_FLASH=y
CONFIG_DM=y
CONFIG_BLK=y
CONFIG_DM_GPIO=y
CONFIG_DA8XX_GPIO=y
CONFIG_DM_I2C=y
CONFIG_SYS_I2C_DAVINCI=y

View File

@ -64,6 +64,8 @@ CONFIG_SPI_FLASH_STMICRO=y
CONFIG_SPI_FLASH_WINBOND=y
CONFIG_SPI_FLASH_MTD=y
CONFIG_DM_ETH=y
CONFIG_MII=y
CONFIG_DRIVER_TI_EMAC=y
CONFIG_PHY=y
CONFIG_PHY_DA8XX_USB=y
CONFIG_PINCTRL=y

View File

@ -7,7 +7,7 @@ CONFIG_IDENT_STRING=" vexpress_aemv8a"
CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
CONFIG_USE_BOOTARGS=y
CONFIG_BOOTARGS="console=ttyAMA0 earlyprintk=pl011,0x1c090000 debug user_debug=31 androidboot.hardware=fvpbase root=/dev/vda2 rw rootwait loglevel=9"
CONFIG_BOOTARGS="console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 androidboot.hardware=fvpbase root=/dev/vda2 rw rootwait loglevel=9"
# CONFIG_USE_BOOTCOMMAND is not set
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set

View File

@ -7,7 +7,7 @@ CONFIG_IDENT_STRING=" vexpress_aemv8a"
CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
CONFIG_USE_BOOTARGS=y
CONFIG_BOOTARGS="console=ttyAMA0,115200n8 root=/dev/sda2 rw rootwait earlyprintk=pl011,0x7ff80000 debug user_debug=31 androidboot.hardware=juno loglevel=9"
CONFIG_BOOTARGS="console=ttyAMA0,115200n8 root=/dev/sda2 rw rootwait earlycon=pl011,0x7ff80000 debug user_debug=31 androidboot.hardware=juno loglevel=9"
# CONFIG_USE_BOOTCOMMAND is not set
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set

View File

@ -7,7 +7,7 @@ CONFIG_IDENT_STRING=" vexpress_aemv8a"
CONFIG_DISTRO_DEFAULTS=y
CONFIG_BOOTDELAY=1
CONFIG_USE_BOOTARGS=y
CONFIG_BOOTARGS="console=ttyAMA0 earlyprintk=pl011,0x1c090000 debug user_debug=31 loglevel=9"
CONFIG_BOOTARGS="console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 loglevel=9"
# CONFIG_USE_BOOTCOMMAND is not set
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set

View File

@ -1167,6 +1167,14 @@ int ahci_probe_scsi(struct udevice *ahci_dev, ulong base)
if (ret)
return ret;
/*
* scsi_scan_dev() scans devices up-to the number of max_id.
* Update max_id if the number of detected ports exceeds max_id.
* This allows SCSI to scan all detected ports.
*/
uc_plat->max_id = max_t(unsigned long, uc_priv->n_ports,
uc_plat->max_id);
return 0;
}

View File

@ -48,6 +48,7 @@ config CLK_BOSTON
config SPL_CLK_CCF
bool "SPL Common Clock Framework [CCF] support "
depends on SPL
help
Enable this option if you want to (re-)use the Linux kernel's Common
Clock Framework [CCF] code in U-Boot's SPL.

View File

@ -92,7 +92,7 @@ config DM_SEQ_ALIAS
config SPL_DM_SEQ_ALIAS
bool "Support numbered aliases in device tree in SPL"
depends on DM
depends on SPL_DM
default n
help
Most boards will have a '/aliases' node containing the path to

View File

@ -88,6 +88,7 @@ config CROS_EC
config SPL_CROS_EC
bool "Enable Chrome OS EC in SPL"
depends on SPL
help
Enable access to the Chrome OS EC in SPL. This is a separate
microcontroller typically available on a SPI bus on Chromebooks. It
@ -97,6 +98,7 @@ config SPL_CROS_EC
config TPL_CROS_EC
bool "Enable Chrome OS EC in TPL"
depends on TPL
help
Enable access to the Chrome OS EC in TPL. This is a separate
microcontroller typically available on a SPI bus on Chromebooks. It

View File

@ -73,6 +73,9 @@ static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2,
u64 *prp_pool;
int length = total_len;
int i, nprps;
u32 prps_per_page = (page_size >> 3) - 1;
u32 num_pages;
length -= (page_size - offset);
if (length <= 0) {
@ -89,15 +92,20 @@ static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2,
}
nprps = DIV_ROUND_UP(length, page_size);
num_pages = DIV_ROUND_UP(nprps, prps_per_page);
if (nprps > dev->prp_entry_num) {
free(dev->prp_pool);
dev->prp_pool = malloc(nprps << 3);
/*
* Always increase in increments of pages. It doesn't waste
* much memory and reduces the number of allocations.
*/
dev->prp_pool = memalign(page_size, num_pages * page_size);
if (!dev->prp_pool) {
printf("Error: malloc prp_pool fail\n");
return -ENOMEM;
}
dev->prp_entry_num = nprps;
dev->prp_entry_num = prps_per_page * num_pages;
}
prp_pool = dev->prp_pool;
@ -788,14 +796,6 @@ static int nvme_probe(struct udevice *udev)
}
memset(ndev->queues, 0, NVME_Q_NUM * sizeof(struct nvme_queue *));
ndev->prp_pool = malloc(MAX_PRP_POOL);
if (!ndev->prp_pool) {
ret = -ENOMEM;
printf("Error: %s: Out of memory!\n", udev->name);
goto free_nvme;
}
ndev->prp_entry_num = MAX_PRP_POOL >> 3;
ndev->cap = nvme_readq(&ndev->bar->cap);
ndev->q_depth = min_t(int, NVME_CAP_MQES(ndev->cap) + 1, NVME_Q_DEPTH);
ndev->db_stride = 1 << NVME_CAP_STRIDE(ndev->cap);
@ -805,6 +805,15 @@ static int nvme_probe(struct udevice *udev)
if (ret)
goto free_queue;
/* Allocate after the page size is known */
ndev->prp_pool = memalign(ndev->page_size, MAX_PRP_POOL);
if (!ndev->prp_pool) {
ret = -ENOMEM;
printf("Error: %s: Out of memory!\n", udev->name);
goto free_nvme;
}
ndev->prp_entry_num = MAX_PRP_POOL >> 3;
ret = nvme_setup_io_queues(ndev);
if (ret)
goto free_queue;

View File

@ -19,7 +19,7 @@ config PHY
config SPL_PHY
bool "PHY Core in SPL"
depends on DM
depends on DM && SPL
help
PHY support in SPL.

View File

@ -45,7 +45,7 @@ config SERIAL_PRESENT
config SPL_SERIAL_PRESENT
bool "Provide a serial driver in SPL"
depends on DM_SERIAL
depends on DM_SERIAL && SPL
default y
help
In very space-constrained devices even the full UART driver is too
@ -55,7 +55,7 @@ config SPL_SERIAL_PRESENT
config TPL_SERIAL_PRESENT
bool "Provide a serial driver in TPL"
depends on DM_SERIAL
depends on DM_SERIAL && TPL
default y
help
In very space-constrained devices even the full UART driver is too

View File

@ -1174,10 +1174,6 @@ int file_fat_read_at(const char *filename, loff_t pos, void *buffer,
/* For saving default max clustersize memory allocated to malloc pool */
dir_entry *dentptr = itr->dent;
free(itr);
itr = NULL;
ret = get_contents(&fsdata, dentptr, pos, buffer, maxsize, actread);
out_free_both:

View File

@ -26,8 +26,11 @@
* Enable CONFIG_USB_MUSB_HOST for Host functionalities MSC, keyboard
* Enable CONFIG_USB_MUSB_GADGET for Device functionalities.
*/
#ifdef CONFIG_SPL_BUILD
#undef CONFIG_USB_EHCI_OMAP
#else
#define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO 57
#endif
/* I2C */

View File

@ -30,6 +30,9 @@
/* I2C */
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50 /* EEPROM AT24C64 */
#ifdef CONFIG_SPL_BUILD
#undef CONFIG_USB_EHCI_OMAP
#endif
#ifdef CONFIG_USB_EHCI_OMAP
#define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO 4
#endif

View File

@ -11,7 +11,6 @@
#ifndef CONFIG_SEMIHOSTING
#error CONFIG_TARGET_VEXPRESS64_BASE_FVP requires CONFIG_SEMIHOSTING
#endif
#define CONFIG_ARMV8_SWITCH_TO_EL1
#endif
#define CONFIG_REMAKE_ELF

View File

@ -56,7 +56,7 @@
"bootz; " \
"fi;\0" \
"mmcboot=mmc dev ${mmcdev}; " \
"setenv devnum ${mmcdev}; " \
"devnum ${mmcdev}; " \
"setenv devtype mmc; " \
"if mmc rescan; then " \
"echo SD/MMC found on device ${mmcdev};" \

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,6 @@ CONFIG_SHA1_CHECK_UB_IMG = y
CONFIG_ARCH_SUNXI = y
endif
subdir-$(HOST_TOOLS_ALL) += easylogo
subdir-$(HOST_TOOLS_ALL) += gdb
# Merge all the different vars for envcrc into one

View File

@ -1,5 +0,0 @@
# SPDX-License-Identifier: GPL-2.0+
hostprogs-y := easylogo
always := $(hostprogs-y)

View File

@ -1,611 +0,0 @@
/*
** Easylogo TGA->header converter
** ==============================
** (C) 2000 by Paolo Scaffardi (arsenio@tin.it)
** AIRVENT SAM s.p.a - RIMINI(ITALY)
** (C) 2007-2008 Mike Frysinger <vapier@gentoo.org>
**
** This is still under construction!
*/
#include <errno.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#pragma pack(1)
/*#define ENABLE_ASCII_BANNERS */
typedef struct {
unsigned char id;
unsigned char ColorMapType;
unsigned char ImageTypeCode;
unsigned short ColorMapOrigin;
unsigned short ColorMapLenght;
unsigned char ColorMapEntrySize;
unsigned short ImageXOrigin;
unsigned short ImageYOrigin;
unsigned short ImageWidth;
unsigned short ImageHeight;
unsigned char ImagePixelSize;
unsigned char ImageDescriptorByte;
} tga_header_t;
typedef struct {
unsigned char r, g, b;
} rgb_t;
typedef struct {
unsigned char b, g, r;
} bgr_t;
typedef struct {
unsigned char Cb, y1, Cr, y2;
} yuyv_t;
typedef struct {
void *data, *palette;
int width, height, pixels, bpp, pixel_size, size, palette_size, yuyv;
} image_t;
void *xmalloc (size_t size)
{
void *ret = malloc (size);
if (!ret) {
fprintf (stderr, "\nerror: malloc(%zu) failed: %s",
size, strerror(errno));
exit (1);
}
return ret;
}
void StringUpperCase (char *str)
{
int count = strlen (str);
char c;
while (count--) {
c = *str;
if ((c >= 'a') && (c <= 'z'))
*str = 'A' + (c - 'a');
str++;
}
}
void StringLowerCase (char *str)
{
int count = strlen (str);
char c;
while (count--) {
c = *str;
if ((c >= 'A') && (c <= 'Z'))
*str = 'a' + (c - 'A');
str++;
}
}
void pixel_rgb_to_yuyv (rgb_t * rgb_pixel, yuyv_t * yuyv_pixel)
{
unsigned int pR, pG, pB;
/* Transform (0-255) components to (0-100) */
pR = rgb_pixel->r * 100 / 255;
pG = rgb_pixel->g * 100 / 255;
pB = rgb_pixel->b * 100 / 255;
/* Calculate YUV values (0-255) from RGB beetween 0-100 */
yuyv_pixel->y1 = yuyv_pixel->y2 = 209 * (pR + pG + pB) / 300 + 16;
yuyv_pixel->Cb = pB - (pR / 4) - (pG * 3 / 4) + 128;
yuyv_pixel->Cr = pR - (pG * 3 / 4) - (pB / 4) + 128;
return;
}
void printlogo_rgb (rgb_t * data, int w, int h)
{
int x, y;
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++, data++)
if ((data->r <
30) /*&&(data->g == 0)&&(data->b == 0) */ )
printf (" ");
else
printf ("X");
printf ("\n");
}
}
void printlogo_yuyv (unsigned short *data, int w, int h)
{
int x, y;
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++, data++)
if (*data == 0x1080) /* Because of inverted on i386! */
printf (" ");
else
printf ("X");
printf ("\n");
}
}
static inline unsigned short le16_to_cpu (unsigned short val)
{
union {
unsigned char pval[2];
unsigned short val;
} swapped;
swapped.val = val;
return (swapped.pval[1] << 8) + swapped.pval[0];
}
int image_load_tga (image_t * image, char *filename)
{
FILE *file;
tga_header_t header;
int i;
unsigned char app;
rgb_t *p;
if ((file = fopen (filename, "rb")) == NULL)
return -1;
fread (&header, sizeof (header), 1, file);
/* byte swap: tga is little endian, host is ??? */
header.ColorMapOrigin = le16_to_cpu (header.ColorMapOrigin);
header.ColorMapLenght = le16_to_cpu (header.ColorMapLenght);
header.ImageXOrigin = le16_to_cpu (header.ImageXOrigin);
header.ImageYOrigin = le16_to_cpu (header.ImageYOrigin);
header.ImageWidth = le16_to_cpu (header.ImageWidth);
header.ImageHeight = le16_to_cpu (header.ImageHeight);
image->width = header.ImageWidth;
image->height = header.ImageHeight;
switch (header.ImageTypeCode) {
case 2: /* Uncompressed RGB */
image->yuyv = 0;
image->palette_size = 0;
image->palette = NULL;
break;
default:
printf ("Format not supported!\n");
return -1;
}
image->bpp = header.ImagePixelSize;
image->pixel_size = ((image->bpp - 1) / 8) + 1;
image->pixels = image->width * image->height;
image->size = image->pixels * image->pixel_size;
image->data = xmalloc (image->size);
if (image->bpp != 24) {
printf ("Bpp not supported: %d!\n", image->bpp);
return -1;
}
fread (image->data, image->size, 1, file);
/* Swapping R and B values */
p = image->data;
for (i = 0; i < image->pixels; i++, p++) {
app = p->r;
p->r = p->b;
p->b = app;
}
/* Swapping image */
if (!(header.ImageDescriptorByte & 0x20)) {
unsigned char *temp = xmalloc (image->size);
int linesize = image->pixel_size * image->width;
void *dest = image->data,
*source = temp + image->size - linesize;
printf ("S");
if (temp == NULL) {
printf ("Cannot alloc temp buffer!\n");
return -1;
}
memcpy (temp, image->data, image->size);
for (i = 0; i < image->height;
i++, dest += linesize, source -= linesize)
memcpy (dest, source, linesize);
free (temp);
}
#ifdef ENABLE_ASCII_BANNERS
printlogo_rgb (image->data, image->width, image->height);
#endif
fclose (file);
return 0;
}
void image_free (image_t * image)
{
free (image->data);
free (image->palette);
}
int image_rgb_to_yuyv (image_t * rgb_image, image_t * yuyv_image)
{
rgb_t *rgb_ptr = (rgb_t *) rgb_image->data;
yuyv_t yuyv;
unsigned short *dest;
int count = 0;
yuyv_image->pixel_size = 2;
yuyv_image->bpp = 16;
yuyv_image->yuyv = 1;
yuyv_image->width = rgb_image->width;
yuyv_image->height = rgb_image->height;
yuyv_image->pixels = yuyv_image->width * yuyv_image->height;
yuyv_image->size = yuyv_image->pixels * yuyv_image->pixel_size;
dest = (unsigned short *) (yuyv_image->data =
xmalloc (yuyv_image->size));
yuyv_image->palette = 0;
yuyv_image->palette_size = 0;
while ((count++) < rgb_image->pixels) {
pixel_rgb_to_yuyv (rgb_ptr++, &yuyv);
if ((count & 1) == 0) /* Was == 0 */
memcpy (dest, ((void *) &yuyv) + 2, sizeof (short));
else
memcpy (dest, (void *) &yuyv, sizeof (short));
dest++;
}
#ifdef ENABLE_ASCII_BANNERS
printlogo_yuyv (yuyv_image->data, yuyv_image->width,
yuyv_image->height);
#endif
return 0;
}
int image_rgb888_to_rgb565(image_t *rgb888_image, image_t *rgb565_image)
{
rgb_t *rgb_ptr = (rgb_t *) rgb888_image->data;
unsigned short *dest;
int count = 0;
rgb565_image->pixel_size = 2;
rgb565_image->bpp = 16;
rgb565_image->yuyv = 0;
rgb565_image->width = rgb888_image->width;
rgb565_image->height = rgb888_image->height;
rgb565_image->pixels = rgb565_image->width * rgb565_image->height;
rgb565_image->size = rgb565_image->pixels * rgb565_image->pixel_size;
dest = (unsigned short *) (rgb565_image->data =
xmalloc(rgb565_image->size));
rgb565_image->palette = 0;
rgb565_image->palette_size = 0;
while ((count++) < rgb888_image->pixels) {
*dest++ = ((rgb_ptr->b & 0xF8) << 8) |
((rgb_ptr->g & 0xFC) << 3) |
(rgb_ptr->r >> 3);
rgb_ptr++;
}
return 0;
}
enum comp_t {
COMP_NONE,
COMP_GZIP,
COMP_LZMA,
};
static enum comp_t compression = COMP_NONE;
static bool bss_storage = false;
int image_save_header (image_t * image, char *filename, char *varname)
{
FILE *file = fopen (filename, "w");
char app[256], str[256] = "", def_name[64];
int count = image->size, col = 0;
unsigned char *dataptr = image->data;
if (file == NULL)
return -1;
/* Author information */
fprintf (file,
"/*\n * Generated by EasyLogo, (C) 2000 by Paolo Scaffardi\n *\n");
fprintf (file,
" * To use this, include it and call: easylogo_plot(screen,&%s, width,x,y)\n *\n",
varname);
fprintf (file,
" * Where:\t'screen'\tis the pointer to the frame buffer\n");
fprintf (file, " *\t\t'width'\tis the screen width\n");
fprintf (file, " *\t\t'x'\t\tis the horizontal position\n");
fprintf (file, " *\t\t'y'\t\tis the vertical position\n */\n\n");
/* image compress */
if (compression != COMP_NONE) {
const char *errstr = NULL;
unsigned char *compressed;
const char *comp_name;
struct stat st;
FILE *compfp;
size_t filename_len = strlen(filename);
char *compfilename = xmalloc(filename_len + 20);
char *compcmd = xmalloc(filename_len + 50);
sprintf(compfilename, "%s.bin", filename);
switch (compression) {
case COMP_GZIP:
strcpy(compcmd, "gzip");
comp_name = "GZIP";
break;
case COMP_LZMA:
strcpy(compcmd, "lzma");
comp_name = "LZMA";
break;
default:
errstr = "\nerror: unknown compression method";
goto done;
}
strcat(compcmd, " > ");
strcat(compcmd, compfilename);
compfp = popen(compcmd, "w");
if (!compfp) {
errstr = "\nerror: popen() failed";
goto done;
}
if (fwrite(image->data, image->size, 1, compfp) != 1) {
errstr = "\nerror: writing data to gzip failed";
goto done;
}
if (pclose(compfp)) {
errstr = "\nerror: gzip process failed";
goto done;
}
compfp = fopen(compfilename, "r");
if (!compfp) {
errstr = "\nerror: open() on gzip data failed";
goto done;
}
if (stat(compfilename, &st)) {
errstr = "\nerror: stat() on gzip file failed";
goto done;
}
compressed = xmalloc(st.st_size);
if (fread(compressed, st.st_size, 1, compfp) != 1) {
errstr = "\nerror: reading gzip data failed";
goto done;
}
fclose(compfp);
unlink(compfilename);
dataptr = compressed;
count = st.st_size;
fprintf(file, "#define EASYLOGO_ENABLE_%s %i\n\n", comp_name, count);
if (bss_storage)
fprintf (file, "static unsigned char EASYLOGO_DECOMP_BUFFER[%i];\n\n", image->size);
done:
free(compfilename);
free(compcmd);
if (errstr) {
perror (errstr);
return -1;
}
}
/* Headers */
fprintf (file, "#include <video_easylogo.h>\n\n");
/* Macros */
strcpy (def_name, varname);
StringUpperCase (def_name);
fprintf (file, "#define DEF_%s_WIDTH\t\t%d\n", def_name,
image->width);
fprintf (file, "#define DEF_%s_HEIGHT\t\t%d\n", def_name,
image->height);
fprintf (file, "#define DEF_%s_PIXELS\t\t%d\n", def_name,
image->pixels);
fprintf (file, "#define DEF_%s_BPP\t\t%d\n", def_name, image->bpp);
fprintf (file, "#define DEF_%s_PIXEL_SIZE\t%d\n", def_name,
image->pixel_size);
fprintf (file, "#define DEF_%s_SIZE\t\t%d\n\n", def_name,
image->size);
/* Declaration */
fprintf (file, "unsigned char DEF_%s_DATA[] = {\n",
def_name);
/* Data */
while (count)
switch (col) {
case 0:
sprintf (str, " 0x%02x", *dataptr++);
col++;
count--;
break;
case 16:
fprintf (file, "%s", str);
if (count > 0)
fprintf (file, ",");
fprintf (file, "\n");
col = 0;
break;
default:
strcpy (app, str);
sprintf(str, "%.*s, 0x%02x", (int)sizeof(str) - 7, app,
*dataptr++);
col++;
count--;
break;
}
if (col)
fprintf (file, "%s\n", str);
/* End of declaration */
fprintf (file, "};\n\n");
/* Variable */
fprintf (file, "fastimage_t %s = {\n", varname);
fprintf (file, " DEF_%s_DATA,\n", def_name);
fprintf (file, " DEF_%s_WIDTH,\n", def_name);
fprintf (file, " DEF_%s_HEIGHT,\n", def_name);
fprintf (file, " DEF_%s_BPP,\n", def_name);
fprintf (file, " DEF_%s_PIXEL_SIZE,\n", def_name);
fprintf (file, " DEF_%s_SIZE\n};\n", def_name);
fclose (file);
return 0;
}
#define DEF_FILELEN 256
static void usage (int exit_status)
{
puts (
"EasyLogo 1.0 (C) 2000 by Paolo Scaffardi\n"
"\n"
"Syntax: easylogo [options] inputfile [outputvar [outputfile]]\n"
"\n"
"Options:\n"
" -r Output RGB888 instead of YUYV\n"
" -s Output RGB565 instead of YUYV\n"
" -g Compress with gzip\n"
" -l Compress with lzma\n"
" -b Preallocate space in bss for decompressing image\n"
" -h Help output\n"
"\n"
"Where: 'inputfile' is the TGA image to load\n"
" 'outputvar' is the variable name to create\n"
" 'outputfile' is the output header file (default is 'inputfile.h')"
);
exit (exit_status);
}
int main (int argc, char *argv[])
{
int c;
bool use_rgb888 = false;
bool use_rgb565 = false;
char inputfile[DEF_FILELEN],
outputfile[DEF_FILELEN], varname[DEF_FILELEN];
image_t rgb888_logo, rgb565_logo, yuyv_logo;
while ((c = getopt(argc, argv, "hrsglb")) > 0) {
switch (c) {
case 'h':
usage (0);
break;
case 'r':
use_rgb888 = true;
puts("Using 24-bit RGB888 Output Fromat");
break;
case 's':
use_rgb565 = true;
puts("Using 16-bit RGB565 Output Fromat");
break;
case 'g':
compression = COMP_GZIP;
puts("Compressing with gzip");
break;
case 'l':
compression = COMP_LZMA;
puts("Compressing with lzma");
break;
case 'b':
bss_storage = true;
puts("Preallocating bss space for decompressing image");
break;
default:
usage (1);
break;
}
}
c = argc - optind;
if (c > 4 || c < 1)
usage (1);
strcpy (inputfile, argv[optind]);
if (c > 1)
strcpy (varname, argv[optind + 1]);
else {
/* transform "input.tga" to just "input" */
char *dot;
strcpy (varname, inputfile);
dot = strchr (varname, '.');
if (dot)
*dot = '\0';
}
if (c > 2)
strcpy (outputfile, argv[optind + 2]);
else {
/* just append ".h" to input file name */
strcpy (outputfile, inputfile);
strcat (outputfile, ".h");
}
/* Make sure the output is sent as soon as we printf() */
setbuf(stdout, NULL);
printf ("Doing '%s' (%s) from '%s'...",
outputfile, varname, inputfile);
/* Import TGA logo */
printf ("L");
if (image_load_tga(&rgb888_logo, inputfile) < 0) {
printf ("input file not found!\n");
exit (1);
}
/* Convert, save, and free the image */
if (!use_rgb888 && !use_rgb565) {
printf ("C");
image_rgb_to_yuyv(&rgb888_logo, &yuyv_logo);
printf("S");
image_save_header(&yuyv_logo, outputfile, varname);
image_free(&yuyv_logo);
} else if (use_rgb565) {
printf("C");
image_rgb888_to_rgb565(&rgb888_logo, &rgb565_logo);
printf("S");
image_save_header(&rgb565_logo, outputfile, varname);
image_free(&rgb565_logo);
} else {
printf("S");
image_save_header(&rgb888_logo, outputfile, varname);
}
/* Free original image and copy */
image_free(&rgb888_logo);
printf ("\n");
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

View File

@ -1,4 +0,0 @@
#!/bin/sh
make
./easylogo linux_logo.tga u_boot_logo video_logo.h
mv video_logo.h ../../include