Contents of /trunk/linterm_tools/fw_builder/bootsplash/fbresolution.c
Parent Directory | Revision Log
Revision 658 -
(show annotations)
(download)
Mon Jan 14 16:57:24 2008 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 1725 byte(s)
Mon Jan 14 16:57:24 2008 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 1725 byte(s)
initial import
1 | /* |
2 | * framebuffer tool, inspired from fbi ((c) 1998,99 Gerd Knorr <kraxel@goldbach.in-berlin.de>) |
3 | * |
4 | * (c) 2002 Florent Villard (warly@mandrakesoft.com) |
5 | * |
6 | */ |
7 | |
8 | #include <stdio.h> |
9 | #include <stdlib.h> |
10 | #include <string.h> |
11 | #include <fcntl.h> |
12 | #include <errno.h> |
13 | #include <getopt.h> |
14 | #include <sys/ioctl.h> |
15 | #include <linux/fb.h> |
16 | #define VERSION "0.1.1" |
17 | |
18 | int fd; |
19 | static int fb; |
20 | struct fb_var_screeninfo fb_var; |
21 | |
22 | struct option fbresol_options[] = { |
23 | {"version", no_argument, NULL, 'v'}, /* version */ |
24 | {"help", no_argument, NULL, 'h'}, /* help */ |
25 | {0, 0, 0, 0} |
26 | }; |
27 | |
28 | void version(void) |
29 | { |
30 | fprintf(stderr, "fbresolution version " VERSION |
31 | " (c) 2002 Florent Villard <warly@mandrakesoft.com>; compiled on %s.\n", |
32 | __DATE__); |
33 | } |
34 | |
35 | void usage(char *name) |
36 | { |
37 | char *h; |
38 | h = strrchr(name, '/'); |
39 | fprintf(stderr, |
40 | "\n" |
41 | "This program output the current framebuffer resolution.\n" |
42 | "\n" |
43 | " Usage: %s [ options ]\n" |
44 | "\n" |
45 | " --help [-h] Print this text\n" |
46 | " --version [-v] Show the %s version number\n" |
47 | "\n" "\n", h ? h + 1 : name, h ? h + 1 : name); |
48 | } |
49 | |
50 | int main(int argc, char *argv[]) |
51 | { |
52 | int opt_index = 0; |
53 | int c; |
54 | for (;;) { |
55 | c = getopt_long(argc, argv, "vhnd:t:", fbresol_options, |
56 | &opt_index); |
57 | if (c == -1) |
58 | break; |
59 | switch (c) { |
60 | case 'v': |
61 | version(); |
62 | exit(1); |
63 | break; |
64 | default: |
65 | case 'h': |
66 | usage(argv[0]); |
67 | exit(1); |
68 | } |
69 | } |
70 | if (optind > argc) { |
71 | usage(argv[0]); |
72 | exit(1); |
73 | } |
74 | if (-1 == (fb = open("/dev/fb0", O_RDWR /* O_WRONLY */ ))) { |
75 | fprintf(stderr, "open /dev/fb0: %s\n", strerror(errno)); |
76 | exit(1); |
77 | } |
78 | if (-1 == ioctl(fb, FBIOGET_VSCREENINFO, &fb_var)) { |
79 | perror("ioctl FBIOGET_VSCREENINFO"); |
80 | exit(1); |
81 | } |
82 | printf("%dx%d\n", fb_var.xres, fb_var.yres); |
83 | return 0; |
84 | } |