Commit c270730f580e85ddab82e981abf8a518f78ae803
Committed by
Anatolij Gustschin
1 parent
02110903a8
Exists in
master
and in
54 other branches
tools: logo: split bmp arrays from bmp_logo.h
The generated header bmp_logo.h is useful even outside common/lcd.c for the logo dimension. However, the problem is, the generated bmp_logo.h cannot be included multiple times because bmp_logo_palette[] and bmp_logo_bitmap[] are defined in the bmp_logo.h. This patch fixes this by defining these arrays in another header bmp_logo_data.h and in bmp_logo.h only declaring these arrays. Signed-off-by: Che-Liang Chiou <clchiou@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Anatolij Gustschin <agust@denx.de>
Showing 6 changed files with 71 additions and 21 deletions Side-by-side Diff
Makefile
... | ... | @@ -763,6 +763,7 @@ |
763 | 763 | $(obj)arch/blackfin/cpu/bootrom-asm-offsets.[chs] \ |
764 | 764 | $(obj)arch/blackfin/cpu/init.{lds,elf} |
765 | 765 | @rm -f $(obj)include/bmp_logo.h |
766 | + @rm -f $(obj)include/bmp_logo_data.h | |
766 | 767 | @rm -f $(obj)lib/asm-offsets.s |
767 | 768 | @rm -f $(obj)include/generated/asm-offsets.h |
768 | 769 | @rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s |
common/lcd.c
... | ... | @@ -63,6 +63,7 @@ |
63 | 63 | /************************************************************************/ |
64 | 64 | #ifdef CONFIG_LCD_LOGO |
65 | 65 | # include <bmp_logo.h> /* Get logo data, width and height */ |
66 | +# include <bmp_logo_data.h> | |
66 | 67 | # if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16) |
67 | 68 | # error Default Color Map overlaps with Logo Color Map |
68 | 69 | # endif |
drivers/video/cfb_console.c
... | ... | @@ -286,6 +286,7 @@ |
286 | 286 | #ifdef CONFIG_VIDEO_LOGO |
287 | 287 | #ifdef CONFIG_VIDEO_BMP_LOGO |
288 | 288 | #include <bmp_logo.h> |
289 | +#include <bmp_logo_data.h> | |
289 | 290 | #define VIDEO_LOGO_WIDTH BMP_LOGO_WIDTH |
290 | 291 | #define VIDEO_LOGO_HEIGHT BMP_LOGO_HEIGHT |
291 | 292 | #define VIDEO_LOGO_LUT_OFFSET BMP_LOGO_OFFSET |
include/.gitignore
tools/Makefile
... | ... | @@ -111,8 +111,11 @@ |
111 | 111 | |
112 | 112 | # Generated LCD/video logo |
113 | 113 | LOGO_H = $(OBJTREE)/include/bmp_logo.h |
114 | +LOGO_DATA_H = $(OBJTREE)/include/bmp_logo_data.h | |
114 | 115 | LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H) |
116 | +LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H) | |
115 | 117 | LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H) |
118 | +LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H) | |
116 | 119 | |
117 | 120 | ifeq ($(LOGO_BMP),) |
118 | 121 | LOGO_BMP= logos/denx.bmp |
... | ... | @@ -236,7 +239,10 @@ |
236 | 239 | endif |
237 | 240 | |
238 | 241 | $(LOGO_H): $(obj)bmp_logo $(LOGO_BMP) |
239 | - $(obj)./bmp_logo $(LOGO_BMP) >$@ | |
242 | + $(obj)./bmp_logo --gen-info $(LOGO_BMP) > $@ | |
243 | + | |
244 | +$(LOGO_DATA_H): $(obj)bmp_logo $(LOGO_BMP) | |
245 | + $(obj)./bmp_logo --gen-data $(LOGO_BMP) > $@ | |
240 | 246 | |
241 | 247 | ######################################################################### |
242 | 248 |
tools/bmp_logo.c
1 | 1 | #include "compiler.h" |
2 | 2 | |
3 | +enum { | |
4 | + MODE_GEN_INFO, | |
5 | + MODE_GEN_DATA | |
6 | +}; | |
7 | + | |
3 | 8 | typedef struct bitmap_s { /* bitmap description */ |
4 | 9 | uint16_t width; |
5 | 10 | uint16_t height; |
... | ... | @@ -9,6 +14,11 @@ |
9 | 14 | |
10 | 15 | #define DEFAULT_CMAP_SIZE 16 /* size of default color map */ |
11 | 16 | |
17 | +void usage(const char *prog) | |
18 | +{ | |
19 | + fprintf(stderr, "Usage: %s [--gen-info|--gen-data] file\n", prog); | |
20 | +} | |
21 | + | |
12 | 22 | /* |
13 | 23 | * Neutralize little endians. |
14 | 24 | */ |
15 | 25 | |
16 | 26 | |
17 | 27 | |
... | ... | @@ -39,21 +49,52 @@ |
39 | 49 | exit (EXIT_FAILURE); |
40 | 50 | } |
41 | 51 | |
52 | +void gen_info(bitmap_t *b, uint16_t n_colors) | |
53 | +{ | |
54 | + printf("/*\n" | |
55 | + " * Automatically generated by \"tools/bmp_logo\"\n" | |
56 | + " *\n" | |
57 | + " * DO NOT EDIT\n" | |
58 | + " *\n" | |
59 | + " */\n\n\n" | |
60 | + "#ifndef __BMP_LOGO_H__\n" | |
61 | + "#define __BMP_LOGO_H__\n\n" | |
62 | + "#define BMP_LOGO_WIDTH\t\t%d\n" | |
63 | + "#define BMP_LOGO_HEIGHT\t\t%d\n" | |
64 | + "#define BMP_LOGO_COLORS\t\t%d\n" | |
65 | + "#define BMP_LOGO_OFFSET\t\t%d\n\n" | |
66 | + "extern unsigned short bmp_logo_palette[];\n" | |
67 | + "extern unsigned char bmp_logo_bitmap[];\n\n" | |
68 | + "#endif /* __BMP_LOGO_H__ */\n", | |
69 | + b->width, b->height, n_colors, | |
70 | + DEFAULT_CMAP_SIZE); | |
71 | +} | |
72 | + | |
42 | 73 | int main (int argc, char *argv[]) |
43 | 74 | { |
44 | - int i, x; | |
75 | + int mode, i, x; | |
45 | 76 | FILE *fp; |
46 | 77 | bitmap_t bmp; |
47 | 78 | bitmap_t *b = &bmp; |
48 | 79 | uint16_t data_offset, n_colors; |
49 | 80 | |
50 | - if (argc < 2) { | |
51 | - fprintf (stderr, "Usage: %s file\n", argv[0]); | |
81 | + if (argc < 3) { | |
82 | + usage(argv[0]); | |
52 | 83 | exit (EXIT_FAILURE); |
53 | 84 | } |
54 | 85 | |
55 | - if ((fp = fopen (argv[1], "rb")) == NULL) { | |
56 | - perror (argv[1]); | |
86 | + if (!strcmp(argv[1], "--gen-info")) | |
87 | + mode = MODE_GEN_INFO; | |
88 | + else if (!strcmp(argv[1], "--gen-data")) | |
89 | + mode = MODE_GEN_DATA; | |
90 | + else { | |
91 | + usage(argv[0]); | |
92 | + exit(EXIT_FAILURE); | |
93 | + } | |
94 | + | |
95 | + fp = fopen(argv[2], "rb"); | |
96 | + if (!fp) { | |
97 | + perror(argv[2]); | |
57 | 98 | exit (EXIT_FAILURE); |
58 | 99 | } |
59 | 100 | |
60 | 101 | |
61 | 102 | |
... | ... | @@ -92,28 +133,26 @@ |
92 | 133 | n_colors = 256 - DEFAULT_CMAP_SIZE; |
93 | 134 | } |
94 | 135 | |
95 | - printf ("/*\n" | |
136 | + if (mode == MODE_GEN_INFO) { | |
137 | + gen_info(b, n_colors); | |
138 | + goto out; | |
139 | + } | |
140 | + | |
141 | + printf("/*\n" | |
96 | 142 | " * Automatically generated by \"tools/bmp_logo\"\n" |
97 | 143 | " *\n" |
98 | 144 | " * DO NOT EDIT\n" |
99 | 145 | " *\n" |
100 | 146 | " */\n\n\n" |
101 | - "#ifndef __BMP_LOGO_H__\n" | |
102 | - "#define __BMP_LOGO_H__\n\n" | |
103 | - "#define BMP_LOGO_WIDTH\t\t%d\n" | |
104 | - "#define BMP_LOGO_HEIGHT\t\t%d\n" | |
105 | - "#define BMP_LOGO_COLORS\t\t%d\n" | |
106 | - "#define BMP_LOGO_OFFSET\t\t%d\n" | |
107 | - "\n", | |
108 | - b->width, b->height, n_colors, | |
109 | - DEFAULT_CMAP_SIZE); | |
147 | + "#ifndef __BMP_LOGO_DATA_H__\n" | |
148 | + "#define __BMP_LOGO_DATA_H__\n\n"); | |
110 | 149 | |
111 | 150 | /* allocate memory */ |
112 | 151 | if ((b->data = (uint8_t *)malloc(b->width * b->height)) == NULL) |
113 | 152 | error ("Error allocating memory for file", fp); |
114 | 153 | |
115 | 154 | /* read and print the palette information */ |
116 | - printf ("unsigned short bmp_logo_palette[] = {\n"); | |
155 | + printf("unsigned short bmp_logo_palette[] = {\n"); | |
117 | 156 | |
118 | 157 | for (i=0; i<n_colors; ++i) { |
119 | 158 | b->palette[(int)(i*3+2)] = fgetc(fp); |
120 | 159 | |
... | ... | @@ -137,14 +176,13 @@ |
137 | 176 | printf ("\n"); |
138 | 177 | printf ("};\n"); |
139 | 178 | printf ("\n"); |
140 | - printf ("unsigned char bmp_logo_bitmap[] = {\n"); | |
179 | + printf("unsigned char bmp_logo_bitmap[] = {\n"); | |
141 | 180 | for (i=(b->height-1)*b->width; i>=0; i-=b->width) { |
142 | 181 | for (x = 0; x < b->width; x++) { |
143 | 182 | b->data[(uint16_t) i + x] = (uint8_t) fgetc (fp) \ |
144 | 183 | + DEFAULT_CMAP_SIZE; |
145 | 184 | } |
146 | 185 | } |
147 | - fclose (fp); | |
148 | 186 | |
149 | 187 | for (i=0; i<(b->height*b->width); ++i) { |
150 | 188 | if ((i%8) == 0) |
151 | 189 | |
... | ... | @@ -156,9 +194,11 @@ |
156 | 194 | } |
157 | 195 | printf ("\n" |
158 | 196 | "};\n\n" |
159 | - "#endif /* __BMP_LOGO_H__ */\n" | |
197 | + "#endif /* __BMP_LOGO_DATA_H__ */\n" | |
160 | 198 | ); |
161 | 199 | |
162 | - return (0); | |
200 | +out: | |
201 | + fclose(fp); | |
202 | + return 0; | |
163 | 203 | } |