void-packages/srcpkgs/fbset/patches/03_con2fbmap.patch

110 lines
2.9 KiB
Diff

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);
+}