linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Antonino A. Daplas" <adaplas@hotpop.com>
To: Linux Fbdev development list <linux-fbdev-devel@lists.sourceforge.net>
Cc: Andrew Morton <akpm@osdl.org>
Subject: [PATCH 3/5] Video Mode Handling - Delete entries from mode list
Date: Mon, 9 Aug 2004 09:46:01 +0800	[thread overview]
Message-ID: <200408090946.01213.adaplas@hotpop.com> (raw)

Hi,

This is optional but applying it should enhance fbdev functionality.

The patch allows removal of entries to the mode list.  This is done by setting the
var->activate field to FB_ACTIVATE_INV_MODE.  Only modes that are not in
use by any of the console or by the current var will be deleted.

The diff is against 2.6.8-rc3-mm1 but should apply cleanly to 2.6.8-rc3-mm2
as well.

Tony

Signed-off-by: Antonino Daplas <adaplas@pol.net>
---

 drivers/video/console/fbcon.c |   35 ++++++++++++++++++++++++++++++++++-
 drivers/video/fbmem.c         |   28 +++++++++++++++++++++++++---
 include/linux/fb.h            |    9 +++++++++
 3 files changed, 68 insertions(+), 4 deletions(-)

diff -uprN linux-2.6.8-rc3-mm1-orig/drivers/video/console/fbcon.c linux-2.6.8-rc3-mm1/drivers/video/console/fbcon.c
--- linux-2.6.8-rc3-mm1-orig/drivers/video/console/fbcon.c	2004-08-08 22:32:24.759309552 +0800
+++ linux-2.6.8-rc3-mm1/drivers/video/console/fbcon.c	2004-08-08 22:33:05.726081656 +0800
@@ -2671,10 +2671,39 @@ static void fbcon_modechanged(struct fb_
 	}
 }
 
+static void fbcon_mode_deleted(struct fb_info *info,
+			       struct fb_videomode *mode)
+{
+	struct fb_info *fb_info;
+	struct display *p;
+	int i, j, found = 0;
+
+	/* before deletion, ensure that mode is not in use */
+	for (i = first_fb_vc; i <= last_fb_vc; i++) {
+		j = (int) con2fb_map[i];
+		if (j == -1)
+			continue;
+		fb_info = registered_fb[j];
+		if (fb_info != info)
+			continue;
+		p = &fb_display[i];
+		if (!p || !p->mode)
+			continue;
+		if (fb_mode_is_equal(p->mode, mode)) {
+			found = 1;
+			break;
+		}
+	}
+	if (!found)
+		fb_delete_videomode(mode, &info->monspecs.modelist);
+}
+
 static int fbcon_event_notify(struct notifier_block *self, 
 			      unsigned long action, void *data)
 {
-	struct fb_info *info = (struct fb_info *) data;
+	struct fb_event *event = (struct fb_event *) data;
+	struct fb_info *info = event->info;
+	struct fb_videomode *mode;
 
 	switch(action) {
 	case FB_EVENT_SUSPEND:
@@ -2686,6 +2715,10 @@ static int fbcon_event_notify(struct not
 	case FB_EVENT_MODE_CHANGE:
 		fbcon_modechanged(info);
 		break;
+	case FB_EVENT_MODE_DELETE:
+		mode = (struct fb_videomode *) event->data;
+		fbcon_mode_deleted(info, mode);
+		break;
 	}
 
 	return 0;
diff -uprN linux-2.6.8-rc3-mm1-orig/drivers/video/fbmem.c linux-2.6.8-rc3-mm1/drivers/video/fbmem.c
--- linux-2.6.8-rc3-mm1-orig/drivers/video/fbmem.c	2004-08-08 22:32:24.784305752 +0800
+++ linux-2.6.8-rc3-mm1/drivers/video/fbmem.c	2004-08-08 22:32:57.384349792 +0800
@@ -1083,6 +1083,22 @@ fb_set_var(struct fb_info *info, struct 
 {
 	int err;
 
+	if (var->activate & FB_ACTIVATE_INV_MODE) {
+		struct fb_videomode mode1, mode2;
+		struct fb_event event;
+
+		fb_var_to_videomode(&mode1, var);
+		fb_var_to_videomode(&mode2, &info->var);
+		/* make sure we don't delete the videomode of current var */
+		if (fb_mode_is_equal(&mode1, &mode2))
+			return -EINVAL;
+		event.info = info;
+		event.data = &mode1;
+		notifier_call_chain(&fb_notifier_list, FB_EVENT_MODE_DELETE,
+				    &event);
+		return 0;
+	}
+
 	if ((var->activate & FB_ACTIVATE_FORCE) ||
 	    memcmp(&info->var, var, sizeof(struct fb_var_screeninfo))) {
 		if (!info->fbops->fb_check_var) {
@@ -1108,9 +1124,12 @@ fb_set_var(struct fb_info *info, struct 
 			fb_add_videomode(&mode, &info->monspecs.modelist);
 
 			if (info->flags & FBINFO_MISC_MODECHANGEUSER) {
+				struct fb_event event;
+
 				info->flags &= ~FBINFO_MISC_MODECHANGEUSER;
+				event.info = info;
 				notifier_call_chain(&fb_notifier_list,
-						    FB_EVENT_MODE_CHANGE, info);
+						    FB_EVENT_MODE_CHANGE, &event);
 			}
 		}
 	}
@@ -1520,12 +1539,15 @@ int fb_unregister_client(struct notifier
  */
 void fb_set_suspend(struct fb_info *info, int state)
 {
+	struct fb_event event;
+	
+	event.info = info;
 	if (state) {
-		notifier_call_chain(&fb_notifier_list, FB_EVENT_SUSPEND, info);
+		notifier_call_chain(&fb_notifier_list, FB_EVENT_SUSPEND, &event);
 		info->state = FBINFO_STATE_SUSPENDED;
 	} else {
 		info->state = FBINFO_STATE_RUNNING;
-		notifier_call_chain(&fb_notifier_list, FB_EVENT_RESUME, info);
+		notifier_call_chain(&fb_notifier_list, FB_EVENT_RESUME, &event);
 	}
 }
 
diff -uprN linux-2.6.8-rc3-mm1-orig/include/linux/fb.h linux-2.6.8-rc3-mm1/include/linux/fb.h
--- linux-2.6.8-rc3-mm1-orig/include/linux/fb.h	2004-08-08 22:32:24.827299216 +0800
+++ linux-2.6.8-rc3-mm1/include/linux/fb.h	2004-08-08 22:32:42.715579784 +0800
@@ -159,6 +159,7 @@ struct fb_bitfield {
 #define FB_CHANGE_CMAP_VBL     32	/* change colormap on vbl	*/
 #define FB_ACTIVATE_ALL	       64	/* change all VCs on this fb	*/
 #define FB_ACTIVATE_FORCE     128	/* force apply even when no change*/
+#define FB_ACTIVATE_INV_MODE  256       /* invalidate videomode */
 
 #define FB_ACCELF_TEXT		1	/* (OBSOLETE) see fb_info.flags and vc_mode */
 
@@ -449,6 +450,14 @@ struct fb_cursor_user {
  *	if you own it
  */
 #define FB_EVENT_RESUME			0x03
+/*      An entry from the modelist was removed */
+#define FB_EVENT_MODE_DELETE            0x04
+
+struct fb_event {
+	struct fb_info *info;
+	void *data;
+};
+
 
 extern int fb_register_client(struct notifier_block *nb);
 extern int fb_unregister_client(struct notifier_block *nb);




-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com

                 reply	other threads:[~2004-08-09  1:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200408090946.01213.adaplas@hotpop.com \
    --to=adaplas@hotpop.com \
    --cc=adaplas@pol.net \
    --cc=akpm@osdl.org \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).