Mercurial > mplayer.hg
comparison TVout/con2fb/con2fb.c @ 1:3b5f5d1c5041
Initial revision
author | arpi_esp |
---|---|
date | Sat, 24 Feb 2001 20:28:24 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:c1bb2c071d63 | 1:3b5f5d1c5041 |
---|---|
1 /* this is userspace utility which allows you to redirect console to another fb device | |
2 * You can specify devices & consoles by both numbers and devices. Framebuffers numbers | |
3 * are zero based (/dev/fb0 ... ), consoles begins with 1 (/dev/tty1 ... ) | |
4 */ | |
5 #include <linux/fb.h> | |
6 #include <sys/ioctl.h> | |
7 #include <sys/stat.h> | |
8 #include <sys/types.h> | |
9 #include <fcntl.h> | |
10 #include <stdio.h> | |
11 #include <stdlib.h> | |
12 #include <string.h> | |
13 #include <unistd.h> | |
14 | |
15 int main(int argc, char* argv[]) { | |
16 struct fb_con2fbmap c2m; | |
17 char* fbPath; | |
18 u_int32_t con, fb; | |
19 char* e; | |
20 char* progname = strrchr(argv[0], '/'); | |
21 int f; | |
22 | |
23 if (progname) | |
24 progname++; | |
25 else | |
26 progname = argv[0]; | |
27 if (argc < 3) { | |
28 fprintf(stderr, "usage: %s fbdev console\n", progname); | |
29 return 1; | |
30 } | |
31 fb = strtoul(argv[1], &e, 10); | |
32 if (*e) { | |
33 struct stat sbf; | |
34 | |
35 if (stat(argv[1], &sbf)) { | |
36 fprintf(stderr, "%s: are you sure that %s can be used to describe fbdev?\n", progname, argv[1]); | |
37 return 1; | |
38 } | |
39 if (!S_ISCHR(sbf.st_mode)) { | |
40 fprintf(stderr, "%s: %s must be character device\n", progname, argv[1]); | |
41 return 1; | |
42 } | |
43 fb = sbf.st_rdev & 0xFF; | |
44 if (fb >= 32) | |
45 fb >>= 5; | |
46 fbPath = argv[1]; | |
47 } else | |
48 fbPath = "/dev/fb0"; | |
49 con = strtoul(argv[2], &e, 10); | |
50 if (*e) { | |
51 struct stat sbf; | |
52 | |
53 if (stat(argv[2], &sbf)) { | |
54 fprintf(stderr, "%s: are you sure that %s can be used to describe vt?\n", progname, argv[2]); | |
55 return 1; | |
56 } | |
57 if (!S_ISCHR(sbf.st_mode)) { | |
58 fprintf(stderr, "%s: %s must be character device\n", progname, argv[2]); | |
59 return 1; | |
60 } | |
61 con = sbf.st_rdev & 0xFF; | |
62 } | |
63 c2m.console = con; | |
64 c2m.framebuffer = fb; | |
65 f = open(fbPath, O_RDWR); | |
66 if (f < 0) { | |
67 fprintf(stderr, "%s: Cannot open %s\n", progname, fbPath); | |
68 return 1; | |
69 } | |
70 if (ioctl(f, FBIOPUT_CON2FBMAP, &c2m)) { | |
71 fprintf(stderr, "%s: Cannot set console mapping\n", progname); | |
72 close(f); | |
73 return 1; | |
74 } | |
75 close(f); | |
76 return 0; | |
77 } | |
78 | |
79 |