mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-26 06:30:39 +00:00
Merge branch 'master' of /home/wd/git/u-boot/custodians
* 'master' of /home/wd/git/u-boot/custodians: api: export LCD device to external apps font: split font data from video_font.h tools: logo: split bmp arrays from bmp_logo.h lcd: add clear and draw bitmap declaration VIDEO: mx3fb: GCC4.6 fix build warnings Powerpc/DIU: Fixed the 800x600 and 1024x768 resolution bug
This commit is contained in:
commit
bb82de8840
23 changed files with 4944 additions and 4647 deletions
1
Makefile
1
Makefile
|
@ -760,6 +760,7 @@ clean:
|
|||
$(obj)arch/blackfin/cpu/bootrom-asm-offsets.[chs] \
|
||||
$(obj)arch/blackfin/cpu/init.{lds,elf}
|
||||
@rm -f $(obj)include/bmp_logo.h
|
||||
@rm -f $(obj)include/bmp_logo_data.h
|
||||
@rm -f $(obj)lib/asm-offsets.s
|
||||
@rm -f $(obj)include/generated/asm-offsets.h
|
||||
@rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
|
||||
|
|
|
@ -24,7 +24,8 @@ include $(TOPDIR)/config.mk
|
|||
|
||||
LIB = $(obj)libapi.o
|
||||
|
||||
COBJS-$(CONFIG_API) += api.o api_net.o api_storage.o api_platform-$(ARCH).o
|
||||
COBJS-$(CONFIG_API) += api.o api_display.o api_net.o api_storage.o \
|
||||
api_platform-$(ARCH).o
|
||||
|
||||
COBJS := $(COBJS-y)
|
||||
SRCS := $(COBJS:.o=.c)
|
||||
|
|
47
api/api.c
47
api/api.c
|
@ -553,6 +553,50 @@ static int API_env_enum(va_list ap)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* pseudo signature:
|
||||
*
|
||||
* int API_display_get_info(int type, struct display_info *di)
|
||||
*/
|
||||
static int API_display_get_info(va_list ap)
|
||||
{
|
||||
int type;
|
||||
struct display_info *di;
|
||||
|
||||
type = va_arg(ap, int);
|
||||
di = va_arg(ap, struct display_info *);
|
||||
|
||||
return display_get_info(type, di);
|
||||
}
|
||||
|
||||
/*
|
||||
* pseudo signature:
|
||||
*
|
||||
* int API_display_draw_bitmap(ulong bitmap, int x, int y)
|
||||
*/
|
||||
static int API_display_draw_bitmap(va_list ap)
|
||||
{
|
||||
ulong bitmap;
|
||||
int x, y;
|
||||
|
||||
bitmap = va_arg(ap, ulong);
|
||||
x = va_arg(ap, int);
|
||||
y = va_arg(ap, int);
|
||||
|
||||
return display_draw_bitmap(bitmap, x, y);
|
||||
}
|
||||
|
||||
/*
|
||||
* pseudo signature:
|
||||
*
|
||||
* void API_display_clear(void)
|
||||
*/
|
||||
static int API_display_clear(va_list ap)
|
||||
{
|
||||
display_clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cfp_t calls_table[API_MAXCALL] = { NULL, };
|
||||
|
||||
/*
|
||||
|
@ -616,6 +660,9 @@ void api_init(void)
|
|||
calls_table[API_ENV_GET] = &API_env_get;
|
||||
calls_table[API_ENV_SET] = &API_env_set;
|
||||
calls_table[API_ENV_ENUM] = &API_env_enum;
|
||||
calls_table[API_DISPLAY_GET_INFO] = &API_display_get_info;
|
||||
calls_table[API_DISPLAY_DRAW_BITMAP] = &API_display_draw_bitmap;
|
||||
calls_table[API_DISPLAY_CLEAR] = &API_display_clear;
|
||||
calls_no = API_MAXCALL;
|
||||
|
||||
debugf("API initialized with %d calls\n", calls_no);
|
||||
|
|
74
api/api_display.c
Normal file
74
api/api_display.c
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (c) 2011 The Chromium OS Authors.
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <api_public.h>
|
||||
#include <lcd.h>
|
||||
#include <video_font.h> /* Get font width and height */
|
||||
|
||||
/* lcd.h needs BMP_LOGO_HEIGHT to calculate CONSOLE_ROWS */
|
||||
#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
|
||||
#include <bmp_logo.h>
|
||||
#endif
|
||||
|
||||
/* TODO(clchiou): add support of video device */
|
||||
|
||||
int display_get_info(int type, struct display_info *di)
|
||||
{
|
||||
if (!di)
|
||||
return API_EINVAL;
|
||||
|
||||
switch (type) {
|
||||
default:
|
||||
debug("%s: unsupport display device type: %d\n",
|
||||
__FILE__, type);
|
||||
return API_ENODEV;
|
||||
#ifdef CONFIG_LCD
|
||||
case DISPLAY_TYPE_LCD:
|
||||
di->pixel_width = panel_info.vl_col;
|
||||
di->pixel_height = panel_info.vl_row;
|
||||
di->screen_rows = CONSOLE_ROWS;
|
||||
di->screen_cols = CONSOLE_COLS;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
di->type = type;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int display_draw_bitmap(ulong bitmap, int x, int y)
|
||||
{
|
||||
if (!bitmap)
|
||||
return API_EINVAL;
|
||||
#ifdef CONFIG_LCD
|
||||
return lcd_display_bitmap(bitmap, x, y);
|
||||
#else
|
||||
return API_ENODEV;
|
||||
#endif
|
||||
}
|
||||
|
||||
void display_clear(void)
|
||||
{
|
||||
#ifdef CONFIG_LCD
|
||||
lcd_clear();
|
||||
#endif
|
||||
}
|
|
@ -45,4 +45,8 @@ int dev_write_net(void *, void *, int);
|
|||
|
||||
void dev_stor_init(void);
|
||||
|
||||
int display_get_info(int type, struct display_info *di);
|
||||
int display_draw_bitmap(ulong bitmap, int x, int y);
|
||||
void display_clear(void);
|
||||
|
||||
#endif /* _API_PRIVATE_H_ */
|
||||
|
|
|
@ -125,6 +125,7 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||
/************************************************************************/
|
||||
|
||||
#include <video_font.h> /* Get font data, width and height */
|
||||
#include <video_font_data.h>
|
||||
|
||||
#ifdef CONFIG_VIDEO_LOGO
|
||||
#include <video_logo.h> /* Get logo data, width and height */
|
||||
|
|
|
@ -55,6 +55,9 @@
|
|||
#define PSOC_RETRIES 10 /* each of PSOC_WAIT_TIME */
|
||||
#define PSOC_WAIT_TIME 10 /* usec */
|
||||
|
||||
#include <video_font.h>
|
||||
#define FONT_WIDTH VIDEO_FONT_WIDTH
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
/*
|
||||
|
@ -185,7 +188,6 @@ void lcd_enable (void)
|
|||
}
|
||||
#ifdef CONFIG_PROGRESSBAR
|
||||
|
||||
#define FONT_WIDTH 8 /* the same as VIDEO_FONT_WIDTH in video_font.h */
|
||||
void show_progress (int size, int tot)
|
||||
{
|
||||
int cnt;
|
||||
|
|
|
@ -237,9 +237,7 @@ static int bmp_display(ulong addr, int x, int y)
|
|||
}
|
||||
|
||||
#if defined(CONFIG_LCD)
|
||||
extern int lcd_display_bitmap (ulong, int, int);
|
||||
|
||||
ret = lcd_display_bitmap ((unsigned long)bmp, x, y);
|
||||
ret = lcd_display_bitmap((ulong)bmp, x, y);
|
||||
#elif defined(CONFIG_VIDEO)
|
||||
extern int video_display_bitmap (ulong, int, int);
|
||||
|
||||
|
|
18
common/lcd.c
18
common/lcd.c
|
@ -57,12 +57,14 @@
|
|||
/* ** FONT DATA */
|
||||
/************************************************************************/
|
||||
#include <video_font.h> /* Get font data, width and height */
|
||||
#include <video_font_data.h>
|
||||
|
||||
/************************************************************************/
|
||||
/* ** LOGO DATA */
|
||||
/************************************************************************/
|
||||
#ifdef CONFIG_LCD_LOGO
|
||||
# include <bmp_logo.h> /* Get logo data, width and height */
|
||||
# include <bmp_logo_data.h>
|
||||
# if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16)
|
||||
# error Default Color Map overlaps with Logo Color Map
|
||||
# endif
|
||||
|
@ -78,7 +80,6 @@ static inline void lcd_putc_xy (ushort x, ushort y, uchar c);
|
|||
|
||||
static int lcd_init (void *lcdbase);
|
||||
|
||||
static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]);
|
||||
static void *lcd_logo (void);
|
||||
|
||||
static int lcd_getbgcolor (void);
|
||||
|
@ -353,7 +354,14 @@ int drv_lcd_init (void)
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
||||
static
|
||||
int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
||||
{
|
||||
lcd_clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void lcd_clear(void)
|
||||
{
|
||||
#if LCD_BPP == LCD_MONOCHROME
|
||||
/* Setting the palette */
|
||||
|
@ -394,12 +402,10 @@ static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]
|
|||
|
||||
console_col = 0;
|
||||
console_row = 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
cls, 1, 1, lcd_clear,
|
||||
cls, 1, 1, do_lcd_clear,
|
||||
"clear screen",
|
||||
""
|
||||
);
|
||||
|
@ -413,7 +419,7 @@ static int lcd_init (void *lcdbase)
|
|||
|
||||
lcd_ctrl_init (lcdbase);
|
||||
lcd_is_enabled = 1;
|
||||
lcd_clear (NULL, 1, 1, NULL); /* dummy args */
|
||||
lcd_clear();
|
||||
lcd_enable ();
|
||||
|
||||
/* Initialize the console */
|
||||
|
|
|
@ -203,6 +203,7 @@
|
|||
#include <linux/types.h>
|
||||
#include <stdio_dev.h>
|
||||
#include <video_font.h>
|
||||
#include <video_font_data.h>
|
||||
|
||||
#if defined(CONFIG_CMD_DATE)
|
||||
#include <rtc.h>
|
||||
|
@ -286,6 +287,7 @@ void console_cursor(int state);
|
|||
#ifdef CONFIG_VIDEO_LOGO
|
||||
#ifdef CONFIG_VIDEO_BMP_LOGO
|
||||
#include <bmp_logo.h>
|
||||
#include <bmp_logo_data.h>
|
||||
#define VIDEO_LOGO_WIDTH BMP_LOGO_WIDTH
|
||||
#define VIDEO_LOGO_HEIGHT BMP_LOGO_HEIGHT
|
||||
#define VIDEO_LOGO_LUT_OFFSET BMP_LOGO_OFFSET
|
||||
|
|
|
@ -252,8 +252,10 @@ int fsl_diu_init(u16 xres, u16 yres, u32 pixel_format, int gamma_fix)
|
|||
break;
|
||||
case RESOLUTION(800, 600):
|
||||
fsl_diu_mode_db = &fsl_diu_mode_800_600;
|
||||
break;
|
||||
case RESOLUTION(1024, 768):
|
||||
fsl_diu_mode_db = &fsl_diu_mode_1024_768;
|
||||
break;
|
||||
case RESOLUTION(1280, 1024):
|
||||
fsl_diu_mode_db = &fsl_diu_mode_1280_1024;
|
||||
break;
|
||||
|
|
|
@ -824,7 +824,7 @@ void *video_hw_init(void)
|
|||
char *penv;
|
||||
u32 memsize;
|
||||
unsigned long t1, hsynch, vsynch;
|
||||
int bits_per_pixel, i, tmp, vesa_idx = 0, videomode;
|
||||
int bits_per_pixel, i, tmp, videomode;
|
||||
|
||||
tmp = 0;
|
||||
|
||||
|
@ -857,7 +857,6 @@ void *video_hw_init(void)
|
|||
mode = (struct ctfb_res_modes *)
|
||||
&res_mode_init[vesa_modes[i].resindex];
|
||||
bits_per_pixel = vesa_modes[i].bits_per_pixel;
|
||||
vesa_idx = vesa_modes[i].resindex;
|
||||
} else {
|
||||
mode = (struct ctfb_res_modes *) &var_mode;
|
||||
bits_per_pixel = video_get_params(mode, penv);
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
/* include the font data */
|
||||
#include <video_font.h>
|
||||
#include <video_font_data.h>
|
||||
|
||||
#if VIDEO_FONT_WIDTH != 8 || VIDEO_FONT_HEIGHT != 16
|
||||
#error Expecting VIDEO_FONT_WIDTH == 8 && VIDEO_FONT_HEIGHT == 16
|
||||
|
|
|
@ -48,6 +48,7 @@ int main(int argc, char * const argv[])
|
|||
ulong start, now;
|
||||
struct device_info *di;
|
||||
lbasize_t rlen;
|
||||
struct display_info disinfo;
|
||||
|
||||
if (!api_search_sig(&sig))
|
||||
return -1;
|
||||
|
@ -176,6 +177,36 @@ int main(int argc, char * const argv[])
|
|||
while ((env = ub_env_enum(env)) != NULL)
|
||||
printf("%s = %s\n", env, ub_env_get(env));
|
||||
|
||||
printf("\n*** Display ***\n");
|
||||
|
||||
if (ub_display_get_info(DISPLAY_TYPE_LCD, &disinfo)) {
|
||||
printf("LCD info: failed\n");
|
||||
} else {
|
||||
printf("LCD info:\n");
|
||||
printf(" pixel width: %d\n", disinfo.pixel_width);
|
||||
printf(" pixel height: %d\n", disinfo.pixel_height);
|
||||
printf(" screen rows: %d\n", disinfo.screen_rows);
|
||||
printf(" screen cols: %d\n", disinfo.screen_cols);
|
||||
}
|
||||
if (ub_display_get_info(DISPLAY_TYPE_VIDEO, &disinfo)) {
|
||||
printf("video info: failed\n");
|
||||
} else {
|
||||
printf("video info:\n");
|
||||
printf(" pixel width: %d\n", disinfo.pixel_width);
|
||||
printf(" pixel height: %d\n", disinfo.pixel_height);
|
||||
printf(" screen rows: %d\n", disinfo.screen_rows);
|
||||
printf(" screen cols: %d\n", disinfo.screen_cols);
|
||||
}
|
||||
|
||||
printf("*** Press any key to continue ***\n");
|
||||
printf("got char 0x%x\n", ub_getc());
|
||||
|
||||
/*
|
||||
* This only clears messages on screen, not on serial port. It is
|
||||
* equivalent to a no-op if no display is available.
|
||||
*/
|
||||
ub_display_clear();
|
||||
|
||||
/* reset */
|
||||
printf("\n*** Resetting board ***\n");
|
||||
ub_reset();
|
||||
|
|
|
@ -402,3 +402,34 @@ const char * ub_env_enum(const char *last)
|
|||
|
||||
return env_name;
|
||||
}
|
||||
|
||||
/****************************************
|
||||
*
|
||||
* display
|
||||
*
|
||||
****************************************/
|
||||
|
||||
int ub_display_get_info(int type, struct display_info *di)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
if (!syscall(API_DISPLAY_GET_INFO, &err, (uint32_t)type, (uint32_t)di))
|
||||
return API_ESYSC;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int ub_display_draw_bitmap(ulong bitmap, int x, int y)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
if (!syscall(API_DISPLAY_DRAW_BITMAP, &err, bitmap, x, y))
|
||||
return API_ESYSC;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void ub_display_clear(void)
|
||||
{
|
||||
syscall(API_DISPLAY_CLEAR, NULL);
|
||||
}
|
||||
|
|
|
@ -77,4 +77,9 @@ int ub_dev_send(int handle, void *buf, int len);
|
|||
int ub_dev_recv(int handle, void *buf, int len, int *rlen);
|
||||
struct device_info * ub_dev_get(int);
|
||||
|
||||
/* display */
|
||||
int ub_display_get_info(int type, struct display_info *di);
|
||||
int ub_display_draw_bitmap(ulong bitmap, int x, int y);
|
||||
void ub_display_clear(void);
|
||||
|
||||
#endif /* _API_GLUE_H_ */
|
||||
|
|
1
include/.gitignore
vendored
1
include/.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
/autoconf.mk*
|
||||
/asm
|
||||
/bmp_logo.h
|
||||
/bmp_logo_data.h
|
||||
/config.h
|
||||
/config.mk
|
||||
|
|
|
@ -90,6 +90,9 @@ enum {
|
|||
API_ENV_ENUM,
|
||||
API_ENV_GET,
|
||||
API_ENV_SET,
|
||||
API_DISPLAY_GET_INFO,
|
||||
API_DISPLAY_DRAW_BITMAP,
|
||||
API_DISPLAY_CLEAR,
|
||||
API_MAXCALL
|
||||
};
|
||||
|
||||
|
@ -152,4 +155,17 @@ struct device_info {
|
|||
int state;
|
||||
};
|
||||
|
||||
#define DISPLAY_TYPE_LCD 0x0001
|
||||
#define DISPLAY_TYPE_VIDEO 0x0002
|
||||
|
||||
struct display_info {
|
||||
int type;
|
||||
/* screen size in pixels */
|
||||
int pixel_width;
|
||||
int pixel_height;
|
||||
/* screen size in rows and columns of text */
|
||||
int screen_rows;
|
||||
int screen_cols;
|
||||
};
|
||||
|
||||
#endif /* _API_PUBLIC_H_ */
|
||||
|
|
|
@ -210,6 +210,8 @@ void lcd_disable (void);
|
|||
void lcd_putc (const char c);
|
||||
void lcd_puts (const char *s);
|
||||
void lcd_printf (const char *fmt, ...);
|
||||
void lcd_clear(void);
|
||||
int lcd_display_bitmap(ulong bmp_image, int x, int y);
|
||||
|
||||
/* Allow boards to customize the information displayed */
|
||||
void lcd_show_board_info(void);
|
||||
|
|
4614
include/video_font.h
4614
include/video_font.h
File diff suppressed because it is too large
Load diff
4639
include/video_font_data.h
Normal file
4639
include/video_font_data.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -113,8 +113,11 @@ LIBFDT_OBJ_FILES-y += fdt_wip.o
|
|||
|
||||
# Generated LCD/video logo
|
||||
LOGO_H = $(OBJTREE)/include/bmp_logo.h
|
||||
LOGO_DATA_H = $(OBJTREE)/include/bmp_logo_data.h
|
||||
LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
|
||||
LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H)
|
||||
LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
|
||||
LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H)
|
||||
|
||||
ifeq ($(LOGO_BMP),)
|
||||
LOGO_BMP= logos/denx.bmp
|
||||
|
@ -242,7 +245,10 @@ else
|
|||
endif
|
||||
|
||||
$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
|
||||
$(obj)./bmp_logo $(LOGO_BMP) >$@
|
||||
$(obj)./bmp_logo --gen-info $(LOGO_BMP) > $@
|
||||
|
||||
$(LOGO_DATA_H): $(obj)bmp_logo $(LOGO_BMP)
|
||||
$(obj)./bmp_logo --gen-data $(LOGO_BMP) > $@
|
||||
|
||||
#########################################################################
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
#include "compiler.h"
|
||||
|
||||
enum {
|
||||
MODE_GEN_INFO,
|
||||
MODE_GEN_DATA
|
||||
};
|
||||
|
||||
typedef struct bitmap_s { /* bitmap description */
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
|
@ -9,6 +14,11 @@ typedef struct bitmap_s { /* bitmap description */
|
|||
|
||||
#define DEFAULT_CMAP_SIZE 16 /* size of default color map */
|
||||
|
||||
void usage(const char *prog)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [--gen-info|--gen-data] file\n", prog);
|
||||
}
|
||||
|
||||
/*
|
||||
* Neutralize little endians.
|
||||
*/
|
||||
|
@ -39,21 +49,52 @@ int error (char * msg, FILE *fp)
|
|||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void gen_info(bitmap_t *b, uint16_t n_colors)
|
||||
{
|
||||
printf("/*\n"
|
||||
" * Automatically generated by \"tools/bmp_logo\"\n"
|
||||
" *\n"
|
||||
" * DO NOT EDIT\n"
|
||||
" *\n"
|
||||
" */\n\n\n"
|
||||
"#ifndef __BMP_LOGO_H__\n"
|
||||
"#define __BMP_LOGO_H__\n\n"
|
||||
"#define BMP_LOGO_WIDTH\t\t%d\n"
|
||||
"#define BMP_LOGO_HEIGHT\t\t%d\n"
|
||||
"#define BMP_LOGO_COLORS\t\t%d\n"
|
||||
"#define BMP_LOGO_OFFSET\t\t%d\n\n"
|
||||
"extern unsigned short bmp_logo_palette[];\n"
|
||||
"extern unsigned char bmp_logo_bitmap[];\n\n"
|
||||
"#endif /* __BMP_LOGO_H__ */\n",
|
||||
b->width, b->height, n_colors,
|
||||
DEFAULT_CMAP_SIZE);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
int i, x;
|
||||
int mode, i, x;
|
||||
FILE *fp;
|
||||
bitmap_t bmp;
|
||||
bitmap_t *b = &bmp;
|
||||
uint16_t data_offset, n_colors;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf (stderr, "Usage: %s file\n", argv[0]);
|
||||
if (argc < 3) {
|
||||
usage(argv[0]);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if ((fp = fopen (argv[1], "rb")) == NULL) {
|
||||
perror (argv[1]);
|
||||
if (!strcmp(argv[1], "--gen-info"))
|
||||
mode = MODE_GEN_INFO;
|
||||
else if (!strcmp(argv[1], "--gen-data"))
|
||||
mode = MODE_GEN_DATA;
|
||||
else {
|
||||
usage(argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fp = fopen(argv[2], "rb");
|
||||
if (!fp) {
|
||||
perror(argv[2]);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -92,28 +133,26 @@ int main (int argc, char *argv[])
|
|||
n_colors = 256 - DEFAULT_CMAP_SIZE;
|
||||
}
|
||||
|
||||
printf ("/*\n"
|
||||
if (mode == MODE_GEN_INFO) {
|
||||
gen_info(b, n_colors);
|
||||
goto out;
|
||||
}
|
||||
|
||||
printf("/*\n"
|
||||
" * Automatically generated by \"tools/bmp_logo\"\n"
|
||||
" *\n"
|
||||
" * DO NOT EDIT\n"
|
||||
" *\n"
|
||||
" */\n\n\n"
|
||||
"#ifndef __BMP_LOGO_H__\n"
|
||||
"#define __BMP_LOGO_H__\n\n"
|
||||
"#define BMP_LOGO_WIDTH\t\t%d\n"
|
||||
"#define BMP_LOGO_HEIGHT\t\t%d\n"
|
||||
"#define BMP_LOGO_COLORS\t\t%d\n"
|
||||
"#define BMP_LOGO_OFFSET\t\t%d\n"
|
||||
"\n",
|
||||
b->width, b->height, n_colors,
|
||||
DEFAULT_CMAP_SIZE);
|
||||
"#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");
|
||||
printf("unsigned short bmp_logo_palette[] = {\n");
|
||||
|
||||
for (i=0; i<n_colors; ++i) {
|
||||
b->palette[(int)(i*3+2)] = fgetc(fp);
|
||||
|
@ -137,14 +176,13 @@ int main (int argc, char *argv[])
|
|||
printf ("\n");
|
||||
printf ("};\n");
|
||||
printf ("\n");
|
||||
printf ("unsigned char bmp_logo_bitmap[] = {\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[(uint16_t) i + x] = (uint8_t) fgetc (fp) \
|
||||
+ DEFAULT_CMAP_SIZE;
|
||||
}
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
for (i=0; i<(b->height*b->width); ++i) {
|
||||
if ((i%8) == 0)
|
||||
|
@ -156,8 +194,10 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
printf ("\n"
|
||||
"};\n\n"
|
||||
"#endif /* __BMP_LOGO_H__ */\n"
|
||||
"#endif /* __BMP_LOGO_DATA_H__ */\n"
|
||||
);
|
||||
|
||||
return (0);
|
||||
out:
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue