lkml.org 
[lkml]   [1998]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] framebuffer devfs support (umm redone.. again)
that whatever X server seems to need /dev/fb can use it. It seems to support
adding/removal of devices on the fly, though i havent fully tested. If you see and error in the code, tell me, so it can be fixed. If you think something can be done more efficiently speak out. So far ItWorksOnMyBox(tm).
Sincerely,
Mark Guzman

--- /mnt/src/linux/include/linux/fb.h Thu Jul 30 17:53:11 1998
+++ include/linux/fb.h Thu Jul 30 14:27:38 1998
@@ -293,7 +293,7 @@
void (*blank)(int, struct fb_info*); /* tell fb to (un)blank the screen */
/* arg = 0: unblank */
/* arg > 0: VESA level (arg-1) */
-
+ int devnum; /* /dev/fb<devnum> storage from devfs */
/* From here on everything is device dependent */
};

--- /mnt/src/linux/drivers/char/fbmem.c Thu Jul 30 17:53:06 1998
+++ drivers/char/fbmem.c Thu Jul 30 14:44:25 1998
@@ -28,6 +28,9 @@
#ifdef CONFIG_KMOD
#include <linux/kmod.h>
#endif
+#ifdef CONFIG_DEVFS_FS
+#include <linux/devfs_fs.h>
+#endif /*CONFIG_DEVFS_FS*/

#ifdef __mc68000__
#include <asm/setup.h>
@@ -478,9 +481,10 @@
int i, j;
static int fb_ever_opened[FB_MAX];
static int first = 1;
-
+
if (num_registered_fb == FB_MAX)
return -ENXIO;
+ fb_info.devnum = num_registered_fb; /* helps keep track of what dev it actualy is... */
num_registered_fb++;
for (i = 0 ; i < FB_MAX; i++)
if (!registered_fb[i])
@@ -512,6 +516,7 @@
int i, j;

i = GET_FB_IDX(fb_info->node);
+ framebuffer_unregister_devfs(fb_info.devnum);
for (j = 0; j < MAX_NR_CONSOLES; j++)
if (con2fb_map[j] == i)
return -EBUSY;
@@ -526,6 +531,62 @@
static struct proc_dir_entry *proc_fbmem;
#endif

+/* segfault - July 30 1998 - framebuffer devfs support */
+/* `- added this to make it work right w/ devfs */
+#ifdef CONFIG_DEVFS_FS
+#define FB_MINOR 0
+#define DEVFS_FB_DIRECTORY "fbs"
+char *
+framebuffer_make_lnkname(char *buf, char *name, int idx) {
+ sprintf(buf, "%s%d", name, idx);
+ return buf;
+}
+char *
+framebuffer_make_name(char *buf, int idx) {
+ sprintf(buf, DEVFS_FB_DIRECTORY "/" "%d", idx);
+ return buf;
+}
+/* Register framebuffer entries */
+void
+framebuffer_register_devfs(void)
+{
+ char name_buf[32];
+ char lnk_buf[32];i
+ void *handle, *symlink;
+ int j;
+
+ for (j=0; j<num_registered_fb || j==0; j++) {
+ framebuffer_make_name(name_buf, j); /* create the actual chardev name*/
+ handle = devfs_register(name_buf, 0, DEVFS_FL_TOLERANT,
+ FB_MAJOR, FB_MINOR+(j*0x20),
+ S_IFCHR | S_IRUGO | S_IWUGO, 0, 0, &fb_fops, NULL);
+ framebuffer_make_lnkname(lnk_buf, "fb", j); /* create the symlnk name*/
+ devfs_mk_symlink(NULL, lnk_buf, 0,
+ DEVFS_FL_TOLERANT,
+ name_buf, 0, &symlink);
+ devfs_set_symlink_destination(symlink, handle);
+ }
+}
+void
+framebuffer_unregister_devfs(int devnum)
+{
+ void *handle;
+ char *buf[32];
+ char *lnkbuf[32];
+
+ handle = devfs_find_handle(framebuffer_make_name(buf, devnum), 0,
+ FB_MAJOR, FB_MINOR+(devnum*0x20),
+ DEVFS_SPECIAL_CHR, 0);
+ devfs_unregister(handle);
+ handle = devfs_find_handle(framebuffer_make_lnkname(lnkbuf, "fb", devnum),
+ FB_MAJOR, FB_MINOR+(devnum*0x20),
+ DEVFS_SPECIAL_CHR, 0);
+ devfs_unregister(handle);
+}
+#endif /*CONFIG_DEVFS_FS*/
+/* segfault - July 30 1998 - framebuffer support for devfs*/
+
+
__initfunc(void
fbmem_init(void))
{
@@ -537,6 +598,7 @@
proc_fbmem->read_proc = fbmem_read_proc;
#endif

+ framebuffer_register_devfs(); /*register all the fb devices*/
if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
printk("unable to get major %d for fb devs\n", FB_MAJOR);

@@ -651,3 +713,4 @@

EXPORT_SYMBOL(register_framebuffer);
EXPORT_SYMBOL(unregister_framebuffer);
+EXPORT_SYMBOL(framebuffer_register_devfs);
\
 
 \ /
  Last update: 2005-03-22 13:43    [W:0.070 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site