Skip to contentSkip to conversation

fbdev: Add mode changing via sysfs

PATCH In review Antonino A. Daplas 3 participants 3 messages Mar 6, 2005 – Mar 7, 2005 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/10 fbdev: Add mode changing via sysfs

From Jon Smirl <[email protected]>:

This is a first pass at adding two new sysfs attributes to
/sys/class/graphics/fb0 for setting modes. There are two attributes:
modes which contains a list of valid modes, and mode which is the current mode. To switch modes echo one of the entries from the modes list to the mode attribute.
The D,V,S on the modes represents Detailed, Vesa, Standard from the DDC info.

modes is root writable. It can also be used to set the list of modes. For example a /etc file could add modes that are not in the monitor's DDC.

mode is user writable. PAM would set ownership of mode at user login time. This provides a safe way for a user to set the mode without being root. You can only set the mode to one of the modes on the list.

---

 drivers/video/fbmem.c   |   14 +-
 drivers/video/fbsysfs.c |  307 +++++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/fb.h      |    4
 3 files changed, 317 insertions(+), 8 deletions(-)
drivers/video/fbmem.c +8 -6
diff -Nru a/drivers/video/fbmem.c b/drivers/video/fbmem.c
@@ -1059,7 +1059,6 @@
 register_framebuffer(struct fb_info *fb_info)
 {
 	int i;
-	struct class_device *c;
 	struct fb_event event;
 
 	if (num_registered_fb == FB_MAX)
@@ -1070,13 +1069,15 @@
 			break;
 	fb_info->node = i;
 
-	c = class_simple_device_add(fb_class, MKDEV(FB_MAJOR, i),
+	fb_info->class_device = class_simple_device_add(fb_class, MKDEV(FB_MAJOR, i),
 				    fb_info->device, "fb%d", i);
-	if (IS_ERR(c)) {
+	if (IS_ERR(fb_info->class_device)) {
 		/* Not fatal */
-		printk(KERN_WARNING "Unable to create class_device for framebuffer %d; errno = %ld\n", i, PTR_ERR(c));
-	}
-	
+		printk(KERN_WARNING "Unable to create class_device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->class_device));
+		fb_info->class_device = NULL;
+	} else
+		fb_init_class_device(fb_info);
+
 	if (fb_info->pixmap.addr == NULL) {
 		fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
 		if (fb_info->pixmap.addr) {
@@ -1135,6 +1136,7 @@
 	fb_destroy_modelist(&fb_info->modelist);
 	registered_fb[i]=NULL;
 	num_registered_fb--;
+	fb_cleanup_class_device(fb_info);
 	class_simple_device_remove(MKDEV(FB_MAJOR, i));
 	return 0;
 }
drivers/video/fbsysfs.c +305 -2

323 lines not on this page · raw message

include/linux/fb.h +4 -0
diff -Nru a/include/linux/fb.h b/include/linux/fb.h
@@ -715,8 +715,10 @@
 	struct fb_pixmap sprite;	/* Cursor hardware mapper */
 	struct fb_cmap cmap;		/* Current cmap */
 	struct list_head modelist;      /* mode list */
+	struct fb_videomode *mode;	/* current mode */
 	struct fb_ops *fbops;
 	struct device *device;
+	struct class_device *class_device; /* sysfs per device attrs */
 #ifdef CONFIG_FB_TILEBLITTING
 	struct fb_tile_ops *tileops;    /* Tile Blitting */
 #endif
@@ -833,6 +835,8 @@
 /* drivers/video/fbsysfs.c */
 extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
 extern void framebuffer_release(struct fb_info *info);
+extern int fb_init_class_device(struct fb_info *fb_info);
+extern void fb_cleanup_class_device(struct fb_info *head);
 
 /* drivers/video/fbmon.c */
 #define FB_MAXTIMINGS		0

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click

#1 lore raw

include/linux/fb.h line 722

Quoted 13 lines

diff -Nru a/include/linux/fb.h b/include/linux/fb.h

include/linux/fb.h +2 -0
@@ -715,8 +715,10 @@
 	struct fb_pixmap sprite;	/* Cursor hardware mapper */
 	struct fb_cmap cmap;		/* Current cmap */
 	struct list_head modelist;      /* mode list */
+	struct fb_videomode *mode;	/* current mode */
 	struct fb_ops *fbops;
 	struct device *device;
+	struct class_device *class_device; /* sysfs per device attrs */
 #ifdef CONFIG_FB_TILEBLITTING

Why do we need a mode pointer when we have a function that translates the mode to a var?

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

#2 lore raw
Quoted 17 lines · James Simmons

include/linux/fb.h 2005-02-18 15:17:45 +08:00 line 722

Quoted 13 lines

diff -Nru a/include/linux/fb.h b/include/linux/fb.h

include/linux/fb.h 2005-02-18 15:17:45 +08:00 renamed from include/linux/fb.h 2005-03-05 00:18:26 +08:00 +2 -0
@@ -715,8 +715,10 @@
      struct fb_pixmap sprite;        /* Cursor hardware mapper */
      struct fb_cmap cmap;            /* Current cmap */
      struct list_head modelist;      /* mode list */
+     struct fb_videomode *mode;      /* current mode */
      struct fb_ops *fbops;
      struct device *device;
+     struct class_device *class_device; /* sysfs per device attrs */
 #ifdef CONFIG_FB_TILEBLITTING

Why do we need a mode pointer when we have a function that translates the mode to a var?

So that the sysfs attribute can display the name of the current mode.

Signature · 9 lines
Jon Smirl
[email protected]


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click