File: 03_con2fbmap.patch

package info (click to toggle)
fbset 2.1-35
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 944 kB
  • sloc: ansic: 1,509; yacc: 137; lex: 128; perl: 113; makefile: 105; sh: 10
file content (110 lines) | stat: -rw-r--r-- 2,983 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Status: not-sent
# This supposedly does not need to be sent upstream as there's fbutils,
# although its development has stagnated.

---
 con2fbmap.1 |   29 ++++++++++++++++++++++++++
 con2fbmap.c |   66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+)

--- /dev/null
+++ b/con2fbmap.1
@@ -0,0 +1,29 @@
+.TH con2fbmap 1 2006-01-18 2.1 "Linux frame buffer utils"
+.SH NAME
+con2fbmap \- shows and sets mapping between consoles and framebuffer devices.
+.SH SYNOPSIS
+.B con2fbmap
+.RI console
+.RI [ framebuffer ]
+.SH DESCRIPTION
+.B This documentation is not finished
+.PP
+.B con2fbmap
+is a system utility to show or change the mapping of the consoles  to the
+frame buffer device. The frame buffer device provides a simple and unique
+interface to access different kinds of graphic displays.
+.PP
+Frame buffer devices are accessed via special device nodes located in the
+/dev directory. The naming scheme for these nodes is always
+.IR \fBfb < n >,
+where
+.I n
+is the number of the used frame buffer device.
+.PP
+.SH OPTIONS
+The first option must be there, and identify the console on which to work.
+If the second option is not set, con2fbmap shows the current mapping of
+identified console. If the second argument is given (as a number) con2fbmap
+maps the identified console to said framebuffer device.
+.TP
+Sven LUTHER <luther@debian.org>
--- /dev/null
+++ b/con2fbmap.c
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <linux/fb.h>
+
+#define DEFAULT_FRAMEBUFFER	"/dev/fb0"
+#define DEFAULT_FRAMEBUFFER_DEVFS	"/dev/fb/0"
+
+const char *programname;
+
+void Usage(void)
+{
+    fprintf(stderr, "\nUsage: %s console [framebuffer]\n\n", programname);
+    exit(1);
+}
+
+int main(int argc, char *argv[])
+{
+    int do_write = 0;
+    char *fbpath; /* any frame buffer will do */
+    int fd;
+    struct fb_con2fbmap map;
+
+    programname = argv[0];
+    switch (argc) {
+	case 3:
+	    do_write = 1;
+	    map.framebuffer = atoi(argv[2]);
+	case 2:
+	    map.console = atoi(argv[1]);
+	    break;
+	default:
+	    Usage();
+    }
+
+    if (access("/dev/.devfsd", F_OK) == 0)  /* devfs detected */
+	fbpath = DEFAULT_FRAMEBUFFER_DEVFS;
+    else
+	fbpath = DEFAULT_FRAMEBUFFER;
+
+    if ((fd = open(fbpath, O_RDONLY)) == -1) {
+	fprintf(stderr, "open %s: %s\n", fbpath, strerror(errno));
+	exit(1);
+    }
+    if (do_write) {
+	if (ioctl(fd, FBIOPUT_CON2FBMAP, &map)) {
+	    fprintf(stderr, "ioctl FBIOPUT_CON2FBMAP: %s\n", strerror(errno));
+	    exit(1);
+	}
+    } else {
+	if (ioctl(fd, FBIOGET_CON2FBMAP, &map)) {
+	    fprintf(stderr, "ioctl FBIOGET_CON2FBMAP: %s\n", strerror(errno));
+	    exit(1);
+	}
+	printf("console %d is mapped to framebuffer %d\n", map.console,
+	       map.framebuffer);
+    }
+    close(fd);
+    exit(0);
+}