notify fbcon if framebuffer registered
PATCH 1/1 notify fbcon if framebuffer registered
Hi,
Note: Please CC: me on replies, since i am not a member of the linux-fbdev-devel list!
I am helping a team at handhelds.org to port linux to the ipaq h2210, i was trying to get the framebuffer to start when i came across the problem, that our fb device is initialized after fb_console_init. I saw that sometime between 2.6.1 and 2.6.3 you added a notifier_chain for suspend/resume, so i added a new event for newly registered framebuffers, this helps my ipaq fb to start, when the kernel starts.
Here is the patch i came up with: (it is a patch based on the handhelds.org kernel sources, i hope that it still fits your sources. Sorry!)
I basically added a new event in fb.h and notified the event in register_framebuffer. I had to move the fb_register_client call in fb_console_init up, before "if (!num_registered_fb) because it otherwise did not get called in my case. in fbcon_event_notify() i just call take_over_console, which is what fb_console_init would have done, had the framebuffer been registered before, if i understood it correctly.
Regards, Patty
Index: drivers/video/fbmem.c
===================================================================
RCS file: /cvs/linux/kernel26/drivers/video/fbmem.c,v retrieving revision 1.13
video/fbmem.c +7 -0
@@ -167,6 +167,7 @@extern int tcx_setup (char *);extern int leo_init (void );extern int leo_setup (char *); +extern int mq1100fb_init (void );extern int kyrofb_init (void );extern int kyrofb_setup (char *);
@@ -385,6 +386,9 @@ #ifdef CONFIG_FB_VOODOO1 { "sstfb", sstfb_init, sstfb_setup }, #endif +#ifdef CONFIG_FB_MQ1100 + { "mq1100fb", mq1100fb_init, NULL }, +#endif #ifdef CONFIG_FB_KYRO { "kyrofb", kyrofb_init, kyrofb_setup }, #endif
@@ -1303,6 +1307,9 @@devfs_mk_cdev (MKDEV (FB_MAJOR , i),S_IFCHR |S_IRUGO |S_IWUGO ,"fb/%d" , i); + +notifier_call_chain (&fb_notifier_list,FB_EVENT_FB_REGISTERED , fb_info); +return 0 ; }
Index: drivers/video/console/fbcon.c
===================================================================
RCS file: /cvs/linux/kernel26/drivers/video/console/fbcon.c,v retrieving revision 1.3
video/console/fbcon.c +7 -4
@@ -2295,6 +2295,10 @@case FB_EVENT_RESUME :fbcon_resumed (info);break ; +case FB_EVENT_FB_REGISTERED : +/* a framebuffer was registered, try to take over the console */ +take_over_console (&fb_con, first_fb_vc, last_fb_vc, fbcon_is_default); +break ; }return 0 ; }
@@ -2333,16 +2337,15 @@int __init fb_console_init (void ) { -if (!num_registered_fb) -return -ENODEV ; -take_over_console (&fb_con, first_fb_vc, last_fb_vc, fbcon_is_default);acquire_console_sem ();if (!fbcon_event_notifier_registered) {fb_register_client (&fbcon_event_notifer); fbcon_event_notifier_registered =1 ; }release_console_sem (); - +if (!num_registered_fb) +return -ENODEV ; +take_over_console (&fb_con, first_fb_vc, last_fb_vc, fbcon_is_default);return 0 ; }
Index: include/linux/fb.h
===================================================================
RCS file: /cvs/linux/kernel26/include/linux/fb.h,v retrieving revision 1.2
linux/fb.h +2 -0
@@ -353,6 +353,8 @@* if you own it */ #define FB_EVENT_RESUME 0x03 +/* A new framebuffer registered */ +#define FB_EVENT_FB_REGISTERED 0x04extern int fb_register_client (struct notifier_block *nb);extern int fb_unregister_client (struct notifier_block *nb);
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
Quoted 4 lines
I am helping a team at handhelds.org to port linux to the ipaq h2210, i was trying to get the framebuffer to start when i came across the problem, that our fb device is initialized after
fb_console_init.
Is your driver built as a module? That is the only way that could happen that I know of. The new behavior is that the fbdev device doesn't not automatically take over the console. You use the app con2fb to do that. The reason was so developers could debug there drivers easily. Alot of times there is a bug in the xxfb_init code and you end up with a blank display. Very hard to work with. Also some fbdev drivers can work with vgacon. So you could run a fbdev app on vgacon!!! In this case you don't want the fbdev device changing the hardware.
Actually you don't really need fbcon for embedded devices except for
debugging output. If your device is embedded and without fbcon you can call fb_set_var before you register the device.
Quoted 9 lines
I saw
that sometime between 2.6.1 and 2.6.3 you added anotifier_chainfor suspend/resume, so i added a new event for newly registered framebuffers, this helps my ipaq fb to start, when the kernel starts.Here is the patch i came up with: (it is a patch based on the handhelds.org kernel sources, i hope that it still fits your sources. Sorry!)
Quoted 6 lines
I basically added a new event in
fb.hand notified the event inregister_framebuffer. I had to move thefb_register_clientcall infb_console_initup, before "if (!num_registered_fb) because it otherwise did not get called in my case. infbcon_event_notify()i just calltake_over_console, which is whatfb_console_initwould have done, had the framebuffer been registered before, if i understood it correctly.
This patch could come in handy for hotplug events :-) We would also need a unregister event. The only thing is you have to do some filtering here. Say you have a multi-head system. If question you have is do you want to register this device to the fbcon system. The second question is to which VCs do you map this device. In fbcon you have a map for that. I have to think about how to do that. Your patch is a great start. I just need to go over the different possible cases we can have.
Quoted 96 lines
Regards, Patty
Index:
drivers/video/fbmem.c
===================================================================
RCS file: /cvs/linux/kernel26/drivers/video/fbmem.c,v retrieving revision 1.13
diff -u -b -r1.13fbmem.cvideo/fbmem.c +7
-0@@ -167,6 +167,7 @@extern int tcx_setup (char *);extern int leo_init (void );extern int leo_setup (char *); +extern int mq1100fb_init (void );extern int kyrofb_init (void );extern int kyrofb_setup (char *);@@ -385,6 +386,9 @@ #ifdef CONFIG_FB_VOODOO1 { "sstfb", sstfb_init, sstfb_setup }, #endif +#ifdef CONFIG_FB_MQ1100 + { "mq1100fb", mq1100fb_init, NULL }, +#endif #ifdef CONFIG_FB_KYRO { "kyrofb", kyrofb_init, kyrofb_setup }, #endif@@ -1303,6 +1307,9 @@devfs_mk_cdev (MKDEV (FB_MAJOR , i),S_IFCHR |S_IRUGO |S_IWUGO ,"fb/%d" , i); + +notifier_call_chain (&fb_notifier_list,FB_EVENT_FB_REGISTERED , fb_info); +return 0 ; }Index:
drivers/video/console/fbcon.c
===================================================================
RCS file: /cvs/linux/kernel26/drivers/video/console/fbcon.c,v retrieving revision 1.3
diff -u -b -r1.3fbcon.cvideo/console/fbcon.c +4
-0@@ -2295,6 +2295,10 @@case FB_EVENT_RESUME :fbcon_resumed (info);break ; +case FB_EVENT_FB_REGISTERED : +/* a framebuffer was registered, try to take over the console */ +take_over_console (&fb_con, first_fb_vc, last_fb_vc, fbcon_is_default); +break ; }return 0 ;}video/console/fbcon.c +3
-4@@ -2333,16 +2337,15 @@int __init fb_console_init (void ) { -if (!num_registered_fb) -return -ENODEV ; -take_over_console (&fb_con, first_fb_vc, last_fb_vc, fbcon_is_default);acquire_console_sem ();if (!fbcon_event_notifier_registered) {fb_register_client (&fbcon_event_notifer); fbcon_event_notifier_registered =1 ; }release_console_sem (); - +if (!num_registered_fb) +return -ENODEV ; +take_over_console (&fb_con, first_fb_vc, last_fb_vc, fbcon_is_default);return 0 ; }Index:
include/linux/fb.h
===================================================================
RCS file: /cvs/linux/kernel26/include/linux/fb.h,v retrieving revision 1.2
diff -u -b -r1.2fb.hlinux/fb.h +2
-1@@ -353,6 +353,8 @@* if you own it */ #define FB_EVENT_RESUME 0x03 +/* A new framebuffer registered */ +#define FB_EVENT_FB_REGISTERED 0x04extern int fb_register_client (struct notifier_block *nb);extern int fb_unregister_client (struct notifier_block *nb); -------------------------------------------------------
Quoted 9 lines
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Linux-fbdev-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
Hi,
thanks for your reply!
Quoted 7 lines
Is your driver built as a module? That is the only way that could happen that I know of. The new behavior is that the fbdev device doesn't not automatically take over the console. You use the app con2fb to do that.
The reason was so developers could debug there drivers easily. Alot of times there is a bug in thexxfb_initcode and you end up with a blank display. Very hard to work with. Also some fbdev drivers can work with vgacon. So you could run a fbdev app on vgacon!!! In this case you don't want the fbdev device changing the hardware.
Actually you don't really need fbcon for embedded devices except for
debugging output. If your device is embedded and without fbcon you can callfb_set_varbefore you register the device.
The driver is not compiled as a module, but still fb_console_init runs before mq11xxfb_init, originally i just called fb_console_init from within my probe function which worked but was a very ugly way to go, so i came up with the framebuffer_register notification, and since i saw that you added event_notifications in kernel 2.6.3, i adapted my notification and thought i could send you the patch.
It works perfectly for me, sicne my main problem is, that i dont have a serial cable and can only login to my device thru infrared serial port which only starts when linuxrc of initrd is running, thus i needed a way to see kernel messages and the fb seemed an easy way to do that. Thats what i needed the patch for, and it works perfectly for me, i dont need to call any applications, just as soon as my (statically compiled) fb is registered, the fbcon comes up and shows me the boot messages. I agree that it is only needed for debugging output, thats all i currently need it for.
Quoted 5 lines
Quoted 5 lines
This patch could come in handy for hotplug events :-) We would also need a unregister event. The only thing is you have to do some filtering here.
Say you have a multi-head system. If question you have is do you want to register this device to the fbcon system. The second question is to which VCs do you map this device. In fbcon you have a map for that. I have to think about how to do that. Your patch is a great start. I just need to go over the different possible cases we can have.
I'm very glad if you can use the patch, actually i am not very deep into the internals of the fbcon, i just saw, that by calling take_over_console, i can reach my goal, i did not think about any complications or problems, since i dont know enough about the fbcon.
Regards, Patty
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click