Magellan Linux

Annotation of /trunk/linterm_tools/fw_builder/bootsplash/fbtruetype.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 658 - (hide annotations) (download)
Mon Jan 14 16:57:24 2008 UTC (16 years, 4 months ago) by niro
File MIME type: text/plain
File size: 2925 byte(s)
initial import

1 niro 658 /*
2     * fbmngplay - fb console MNG player.
3     * (c) 2001-2002 by Stefan Reinauer, <stepan@suse.de>
4     *
5     * This program is based on mngplay, written and (C) by
6     * Ralph Giles <giles@ashlu.bc.ca>
7     *
8     * This program my be redistributed under the terms of the
9     * GNU General Public Licence, version 2, or at your preference,
10     * any later version.
11     */
12    
13     #include <stdlib.h>
14     #include <stdio.h>
15     #include <string.h>
16     #include <unistd.h>
17     #include <fcntl.h>
18     #include <getopt.h>
19     #include <sys/mman.h>
20     #include <sys/ioctl.h>
21     #include <linux/fb.h>
22     #include <signal.h>
23    
24    
25     #include "fbtruetype.h"
26     #include "messages.h"
27     #include "console.h"
28    
29     volatile int run = 1;
30     int verbose = 0;
31     int buffered = 0;
32     int waitsignal = 0;
33     int delta = 16;
34     int sconly = 0;
35    
36     unsigned int fbbytes, fbx, fby;
37     unsigned int fbypos = 100, fbxpos = 100;
38     unsigned int fblinelen, alpha = 100;
39     unsigned char *framebuffer, *font = DEFAULT_FONTNAME;
40     unsigned int fgcolor = 0xff0000;
41     unsigned int fontsize = 36;
42     int strict_font = 0;
43     int rendertext(char *text, char *fontname, unsigned int size,
44     unsigned int forecol);
45    
46     int main(int argc, char *argv[])
47     {
48     int fbdev, c, option_index;
49     unsigned int alpha;
50     struct fb_var_screeninfo var;
51     struct fb_fix_screeninfo fix;
52    
53     /* Check which console we're running on */
54     init_consoles();
55    
56     alpha = 100;
57     while (1) {
58     static struct option long_options[] = {
59     {"help", 0, 0, 'h'},
60     {"verbose", 0, 0, 'v'},
61     {"alpha", 1, 0, 'a'},
62     {"version", 0, 0, 'V'},
63     {"start-console", 0, 0, 'S'},
64     {"size", 1, 0, 's'},
65     {"console", 1, 0, 'c'},
66     {"font", 1, 0, 'f'},
67     {"textcolor", 1, 0, 't'},
68     {0, 0, 0, 0}
69     };
70    
71     c = getopt_long(argc, argv, "a:x:y:h?vVSc:f:t:s:",
72     long_options, &option_index);
73    
74     if (c == -1)
75     break;
76    
77     switch (c) {
78     case 'a':
79     alpha = atoi(optarg);
80     if (alpha > 100)
81     alpha = 100;
82     break;
83     case 'x':
84     fbxpos = atoi(optarg);
85     break;
86     case 'y':
87     fbypos = atoi(optarg);
88     break;
89     case '?':
90     case 'h':
91     usage(argv[0]);
92     exit(0);
93     case 'v':
94     verbose = 1;
95     break;
96     case 'V':
97     version();
98     exit(0);
99     case 'c':
100     start_console = atoi(optarg) - 1;
101     case 'S':
102     sconly = 1;
103     break;
104     case 'f':
105     strict_font = 1;
106     font = strdup(optarg);
107     break;
108     case 't':
109     fgcolor = strtol(optarg, NULL, 16);
110     break;
111     case 's':
112     fontsize = strtol(optarg, NULL, 10);
113     break;
114    
115     default:
116     break;
117     }
118     }
119     if (optind >= argc) {
120     printf("No text\n");
121     exit(0);
122     }
123    
124     /* Initialize framebuffer */
125     fbdev = open("/dev/fb0", O_RDWR);
126     if (fbdev < 0) {
127     fprintf(stderr, "error while opening framebuffer.\n");
128     exit(fbdev);
129     }
130    
131     ioctl(fbdev, FBIOGET_VSCREENINFO, &var);
132     fbbytes = var.bits_per_pixel >> 3;
133     fbx = var.xres;
134     fby = var.yres;
135     ioctl(fbdev, FBIOGET_FSCREENINFO, &fix);
136     fblinelen = fix.line_length;
137    
138     framebuffer = mmap(NULL, fblinelen * fby,
139     PROT_WRITE | PROT_READ, MAP_SHARED, fbdev, 0);
140    
141     rendertext(argv[optind], font, fontsize, fgcolor);
142     return 0;
143     }