public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [STATUS] fbdev api.
@ 2002-12-02 21:07 James Simmons
  2002-12-02 21:57 ` Tobias Rittweiler
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: James Simmons @ 2002-12-02 21:07 UTC (permalink / raw)
  To: Linux Fbdev development list
  Cc: Linux Kernel Mailing List, Linux console project


Hi!

  I have a new patch avaiable. It is against 2.5.50. The patch is at 

http://phoenix.infradead.org/~jsimmons/fbdev.diff.gz

Have fun!!!!

Drivers ported are: (Give them a try)

    ATI Mach 64
    ATI 128
    VESA 
    VGA16
    HGA
    NIVIDA
    NEOMAGIC
     
The BIG changes are:

1) The seperation of the console code out of the fbdev drivers. 

2) Total modularity of the frmaebuffer console system. Yes that is 
   right. You can build it has modules. Great for testing.

The following are results of the new changes which I have tested.

   With my VIA laptop with my neomagic card I was able to build it with 
vgacon and no fbcon. Then I insmod neofb and the soft accel (cfb*.c) 
needed. It loading and did NOT change the video hardware state. At this 
point I could run fbdev apps including a X server using /dev/fb solely. 
On opening /dev/fb0 the graphics hardware state changed. In theory I could 
exit X and get vgacon back. In order to do this I have to reset the 
hardware back to vga text mode in the fb_release function. It can be done 
but I haven't done it yet.
   With the second experiment I was able to insmod the fonts and fbcon.o.
Then it switched from vgacon to fbcon. In theory I could again call the 
release function and reset the hardware back to a text mode state. All 
that is needed is the hardware specific code to do this.

Things to be done:

    1) A few bugs in fbcon to hammer out. 
 
    2) Fbcon to support changing resolution via the console layer. 

    3) Move the logo code out of fbcon.c to fbmem.c. With pure fbdev 
       you need something to let you know things worked.

    4) Software rotation.

The diffstat is:

 CREDITS                                |   10 
 Documentation/DocBook/kernel-api.tmpl  |    4 
 Documentation/fb/README-sstfb.txt      |  173 
 Documentation/fb/internals.txt         |    5 
 Documentation/fb/sstfb.txt             |  174 
 MAINTAINERS                            |    7 
 arch/alpha/Kconfig                     |   31 
 arch/arm/Kconfig                       |   21 
 arch/i386/Kconfig                      |   55 
 arch/i386/vmlinux.lds.s                |  114 
 arch/ia64/Kconfig                      |   25 
 arch/m68k/Kconfig                      |    7 
 arch/m68knommu/Kconfig                 |   35 
 arch/mips/Kconfig                      |   62 
 arch/mips64/Kconfig                    |   23 
 arch/parisc/Kconfig                    |   30 
 arch/ppc/Kconfig                       |   22 
 arch/ppc64/Kconfig                     |    7 
 arch/sh/Kconfig                        |   55 
 arch/sparc/Kconfig                     |   16 
 arch/sparc64/Kconfig                   |   11 
 arch/v850/Kconfig                      |   35 
 arch/x86_64/Kconfig                    |   55 
 drivers/Makefile                       |    3 
 drivers/char/Makefile                  |    2 
 drivers/char/consolemap.c              |    5 
 drivers/char/keyboard.c                |    1 
 drivers/char/mem.c                     |   12 
 drivers/char/selection.c               |    1 
 drivers/char/toshiba.c                 |    2 
 drivers/char/tty_io.c                  |    7 
 drivers/char/vc_screen.c               |    1 
 drivers/char/vt.c                      |  200 -
 drivers/char/vt_ioctl.c                |   58 
 drivers/video/68328fb.c                |  967 +----
 drivers/video/Kconfig                  |  411 --
 drivers/video/Makefile                 |   54 
 drivers/video/S3triofb.c               |    2 
 drivers/video/amifb.c                  |    2 
 drivers/video/anakinfb.c               |   62 
 drivers/video/atafb.c                  |    2 
 drivers/video/aty/atyfb.h              |   18 
 drivers/video/aty/atyfb_base.c         |   99 
 drivers/video/aty/mach64_ct.c          |    2 
 drivers/video/aty/mach64_cursor.c      |  157 
 drivers/video/aty/mach64_gx.c          |    2 
 drivers/video/aty128fb.c               | 3238 +++++++----------
 drivers/video/cfbcopyarea.c            |  511 +-
 drivers/video/cfbfillrect.c            |  536 ++
 drivers/video/cfbimgblt.c              |  360 +
 drivers/video/chipsfb.c                |    2 
 drivers/video/clps711xfb.c             |   16 
 drivers/video/console/Kconfig          |  221 +
 drivers/video/console/Makefile         |   61 
 drivers/video/console/dummycon.c       |   73 
 drivers/video/console/fbcon-sti.c      |  289 +
 drivers/video/console/fbcon.c          | 2725 ++++++++++++++
 drivers/video/console/fbcon.h          |  142 
 drivers/video/console/font.h           |   53 
 drivers/video/console/font_6x11.c      | 3351 +++++++++++++++++
 drivers/video/console/font_8x16.c      | 4631 ++++++++++++++++++++++++
 drivers/video/console/font_8x8.c       | 2583 +++++++++++++
 drivers/video/console/font_acorn_8x8.c |  277 +
 drivers/video/console/font_mini_4x6.c  | 2158 +++++++++++
 drivers/video/console/font_pearl_8x8.c | 2587 +++++++++++++
 drivers/video/console/font_sun12x22.c  | 6220 +++++++++++++++++++++++++++++++++
 drivers/video/console/font_sun8x16.c   |  275 +
 drivers/video/console/fonts.c          |  142 
 drivers/video/console/mdacon.c         |  631 +++
 drivers/video/console/newport_con.c    |  745 +++
 drivers/video/console/prom.uni         |   11 
 drivers/video/console/promcon.c        |  605 +++
 drivers/video/console/sti.h            |  289 +
 drivers/video/console/sticon.c         |  214 +
 drivers/video/console/sticore.c        |  601 +++
 drivers/video/console/vgacon.c         | 1066 +++++
 drivers/video/controlfb.c              |  499 --
 drivers/video/cyberfb.c                |    2 
 drivers/video/dnfb.c                   |   18 
 drivers/video/dummycon.c               |   74 
 drivers/video/epson1355fb.c            |    2 
 drivers/video/fbcmap.c                 |   92 
 drivers/video/fbcon-accel.c            |  188 
 drivers/video/fbcon-accel.h            |   34 
 drivers/video/fbcon-afb.c              |  448 --
 drivers/video/fbcon-cfb16.c            |  319 -
 drivers/video/fbcon-cfb2.c             |  225 -
 drivers/video/fbcon-cfb24.c            |  333 -
 drivers/video/fbcon-cfb32.c            |  305 -
 drivers/video/fbcon-cfb4.c             |  229 -
 drivers/video/fbcon-cfb8.c             |  294 -
 drivers/video/fbcon-hga.c              |  253 -
 drivers/video/fbcon-ilbm.c             |  296 -
 drivers/video/fbcon-iplan2p2.c         |  476 --
 drivers/video/fbcon-iplan2p4.c         |  497 --
 drivers/video/fbcon-iplan2p8.c         |  534 --
 drivers/video/fbcon-mfb.c              |  217 -
 drivers/video/fbcon-sti.c              |  337 -
 drivers/video/fbcon-vga-planes.c       |  387 --
 drivers/video/fbcon.c                  | 2509 -------------
 drivers/video/fbgen.c                  |  286 -
 drivers/video/fbmem.c                  |  233 -
 drivers/video/fm2fb.c                  |   17 
 drivers/video/font_6x11.c              | 3351 -----------------
 drivers/video/font_8x16.c              | 4631 ------------------------
 drivers/video/font_8x8.c               | 2583 -------------
 drivers/video/font_acorn_8x8.c         |  277 -
 drivers/video/font_mini_4x6.c          | 2158 -----------
 drivers/video/font_pearl_8x8.c         | 2587 -------------
 drivers/video/font_sun12x22.c          | 6220 ---------------------------------
 drivers/video/font_sun8x16.c           |  275 -
 drivers/video/fonts.c                  |  135 
 drivers/video/g364fb.c                 |   74 
 drivers/video/hgafb.c                  |  424 --
 drivers/video/hitfb.c                  |   17 
 drivers/video/hpfb.c                   |   16 
 drivers/video/igafb.c                  |    2 
 drivers/video/imsttfb.c                |   41 
 drivers/video/macfb.c                  |   22 
 drivers/video/macmodes.c               |    3 
 drivers/video/macmodes.h               |   70 
 drivers/video/matrox/i2c-matroxfb.c    |    2 
 drivers/video/matrox/matroxfb_base.c   |    4 
 drivers/video/matrox/matroxfb_crtc2.c  |    4 
 drivers/video/maxinefb.c               |   48 
 drivers/video/mdacon.c                 |  632 ---
 drivers/video/modedb.c                 |    7 
 drivers/video/neofb.c                  |  389 +-
 drivers/video/newport_con.c            |  746 ---
 drivers/video/offb.c                   |   23 
 drivers/video/platinumfb.c             |  451 --
 drivers/video/pm2fb.c                  |    2 
 drivers/video/pm3fb.c                  |    2 
 drivers/video/pmag-ba-fb.c             |   59 
 drivers/video/pmagb-b-fb.c             |   53 
 drivers/video/prom.uni                 |   11 
 drivers/video/promcon.c                |  606 ---
 drivers/video/pvr2fb.c                 |    4 
 drivers/video/q40fb.c                  |   16 
 drivers/video/radeonfb.c               | 3374 ++++++++++-------
 drivers/video/retz3fb.c                |    2 
 drivers/video/riva/Makefile            |    2 
 drivers/video/riva/accel.c             |  427 --
 drivers/video/riva/fbdev.c             | 2099 ++++-------
 drivers/video/riva/riva_hw.h           |    1 
 drivers/video/riva/rivafb.h            |   48 
 drivers/video/sa1100fb.c               |    2 
 drivers/video/sbusfb.c                 |    2 
 drivers/video/sgivwfb.c                |   62 
 drivers/video/sis/Makefile             |    2 
 drivers/video/sis/sis_accel.c          |  495 ++
 drivers/video/sis/sis_main.c           |    2 
 drivers/video/skeletonfb.c             |   28 
 drivers/video/softcursor.c             |   62 
 drivers/video/sstfb.c                  |    2 
 drivers/video/sti-bmode.h              |  287 -
 drivers/video/sti.h                    |  289 -
 drivers/video/sticon-bmode.c           |  895 ----
 drivers/video/sticon.c                 |  215 -
 drivers/video/sticore.c                |  601 ---
 drivers/video/sticore.h                |  407 ++
 drivers/video/stifb.c                  | 1403 ++++++-
 drivers/video/sun3fb.c                 |    2 
 drivers/video/tdfxfb.c                 |  531 +-
 drivers/video/tgafb.c                  |    2 
 drivers/video/tridentfb.c              |    2 
 drivers/video/tx3912fb.c               |   19 
 drivers/video/valkyriefb.c             |   27 
 drivers/video/vesafb.c                 |   24 
 drivers/video/vfb.c                    |   38 
 drivers/video/vga16fb.c                | 1368 +++++--
 drivers/video/vgacon.c                 | 1055 -----
 drivers/video/virgefb.c                |    2 
 include/linux/console.h                |    1 
 include/linux/console_struct.h         |    1 
 include/linux/fb.h                     |  207 -
 include/linux/radeon.h                 |  766 ++++
 include/linux/radeonfb.h               |   15 
 include/linux/sisfb.h                  |   58 
 include/linux/vt_kern.h                |    8 
 include/video/fbcon-afb.h              |   32 
 include/video/fbcon-cfb16.h            |   34 
 include/video/fbcon-cfb2.h             |   32 
 include/video/fbcon-cfb24.h            |   34 
 include/video/fbcon-cfb32.h            |   34 
 include/video/fbcon-cfb4.h             |   32 
 include/video/fbcon-cfb8.h             |   34 
 include/video/fbcon-hga.h              |   32 
 include/video/fbcon-ilbm.h             |   32 
 include/video/fbcon-iplan2p2.h         |   32 
 include/video/fbcon-iplan2p4.h         |   32 
 include/video/fbcon-iplan2p8.h         |   32 
 include/video/fbcon-mac.h              |   32 
 include/video/fbcon-mfb.h              |   32 
 include/video/fbcon-vga-planes.h       |   37 
 include/video/fbcon-vga.h              |   32 
 include/video/fbcon.h                  |  795 ----
 include/video/font.h                   |   53 
 include/video/macmodes.h               |   70 
 include/video/neomagic.h               |    1 
 kernel/printk.c                        |    1 
 201 files changed, 41728 insertions(+), 47259 deletions(-)
 



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [STATUS] fbdev api.
  2002-12-02 21:07 [STATUS] fbdev api James Simmons
@ 2002-12-02 21:57 ` Tobias Rittweiler
  2002-12-02 22:18   ` James Simmons
  2002-12-03 12:23 ` Antonino Daplas
  2002-12-06 19:50 ` Christoph Hellwig
  2 siblings, 1 reply; 12+ messages in thread
From: Tobias Rittweiler @ 2002-12-02 21:57 UTC (permalink / raw)
  To: James Simmons; +Cc: Linux Kernel Mailing List, Linux console project

Hello James,

Monday, December 2, 2002, 10:07:33 PM, you wrote:


JS> Hi!

JS> I have a new patch avaiable. It is against 2.5.50. The patch is at
JS> http://phoenix.infradead.org/~jsimmons/fbdev.diff.gz

JS> [...]
JS> The diffstat is:

JS>  CREDITS                                |   10 

Hunk #1 succeeded at 2836 (offset -6 lines).

JS>  [...]
JS>  arch/i386/vmlinux.lds.s                |  114
               ^^^^^^^^^^^^^^
really intended?

JS>  [...]
JS>  drivers/char/tty_io.c                  |    7

Hunk #1 succeeded at 1503 (offset -6 lines).

JS>  [...]
JS>  drivers/video/Kconfig                  |  411 --

Hunk #19 succeeded at 864 with fuzz 1 (offset -7 lines).

(of course against 2.5.50 vanilla)
--
cheers,
 Tobias


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [STATUS] fbdev api.
  2002-12-02 21:57 ` Tobias Rittweiler
@ 2002-12-02 22:18   ` James Simmons
  0 siblings, 0 replies; 12+ messages in thread
From: James Simmons @ 2002-12-02 22:18 UTC (permalink / raw)
  To: Tobias Rittweiler; +Cc: Linux Kernel Mailing List, Linux console project


> JS> I have a new patch avaiable. It is against 2.5.50. The patch is at
> JS> http://phoenix.infradead.org/~jsimmons/fbdev.diff.gz
> 
> JS> [...]
> JS> The diffstat is:
> 
> JS>  CREDITS                                |   10 
> 
> Hunk #1 succeeded at 2836 (offset -6 lines).
> 
> JS>  [...]
> JS>  arch/i386/vmlinux.lds.s                |  114
>                ^^^^^^^^^^^^^^
> really intended?
> 
> JS>  [...]
> JS>  drivers/char/tty_io.c                  |    7
> 
> Hunk #1 succeeded at 1503 (offset -6 lines).
> 
> JS>  [...]
> JS>  drivers/video/Kconfig                  |  411 --
> 
> Hunk #19 succeeded at 864 with fuzz 1 (offset -7 lines).

It does work but I made the patch against Linus tree with a few extra 
fixes due to the pci/quirks bug. I will post a exact patch.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [STATUS] fbdev api.
  2002-12-02 21:07 [STATUS] fbdev api James Simmons
  2002-12-02 21:57 ` Tobias Rittweiler
@ 2002-12-03 12:23 ` Antonino Daplas
  2002-12-03 22:18   ` James Simmons
  2002-12-06 19:50 ` Christoph Hellwig
  2 siblings, 1 reply; 12+ messages in thread
From: Antonino Daplas @ 2002-12-03 12:23 UTC (permalink / raw)
  To: James Simmons
  Cc: Linux Fbdev development list, Linux Kernel Mailing List,
	Linux console project

[-- Attachment #1: Type: text/plain, Size: 2493 bytes --]

On Tue, 2002-12-03 at 02:07, James Simmons wrote:
> 
> Hi!
> 
>   I have a new patch avaiable. It is against 2.5.50. The patch is at 
> 
> http://phoenix.infradead.org/~jsimmons/fbdev.diff.gz
> 
> Have fun!!!!
> 
> Drivers ported are: (Give them a try)
> 
>     ATI Mach 64
>     ATI 128
>     VESA 
>     VGA16
>     HGA
>     NIVIDA
>     NEOMAGIC
>      
> The BIG changes are:
> 
> 1) The seperation of the console code out of the fbdev drivers. 
> 
> 2) Total modularity of the frmaebuffer console system. Yes that is 
>    right. You can build it has modules. Great for testing.
> 
> The following are results of the new changes which I have tested.
> 
>    With my VIA laptop with my neomagic card I was able to build it with 
> vgacon and no fbcon. Then I insmod neofb and the soft accel (cfb*.c) 
> needed. It loading and did NOT change the video hardware state. At this 
> point I could run fbdev apps including a X server using /dev/fb solely. 
> On opening /dev/fb0 the graphics hardware state changed. In theory I could 
> exit X and get vgacon back. In order to do this I have to reset the 
> hardware back to vga text mode in the fb_release function. It can be done 
> but I haven't done it yet.
>    With the second experiment I was able to insmod the fonts and fbcon.o.
> Then it switched from vgacon to fbcon. In theory I could again call the 
> release function and reset the hardware back to a text mode state. All 
> that is needed is the hardware specific code to do this.
> 
> Things to be done:
> 
>     1) A few bugs in fbcon to hammer out. 
>  
>     2) Fbcon to support changing resolution via the console layer. 
> 
>     3) Move the logo code out of fbcon.c to fbmem.c. With pure fbdev 
>        you need something to let you know things worked.
> 
>     4) Software rotation.
> 

Attached is a patch against linux-2.5.50 + your fbdev.diff.

a.  changed __MOD_INC_USE_COUNT and __MOD_DEC_USE_COUNT to
try_module_get() and module_put() respectively.  This will allow modules
to be safely unloaded.

b.  Another rewrite of fbcon_show_logo() so it's more understandable
(hopefully).  I also added support for the rest of the visuals, but
untested yet.  

Tested with different hardware (little endian):
truecolor, directcolor, pseudocolor, vga 4-bit pseudocolor.  

Not tested:
static psuedocolor, mono01, and mono10.

c.  prevent fbcon module from loading if no fbdev is registered.  Also
made fbcon module unsafe to unload (for now).  This is optional, of course.


[-- Attachment #2: fbcon.diff --]
[-- Type: text/x-patch, Size: 12619 bytes --]

diff -Naur linux-2.5.50-js/drivers/video/console/fbcon.c linux/drivers/video/console/fbcon.c
--- linux-2.5.50-js/drivers/video/console/fbcon.c	2002-12-03 10:55:55.000000000 +0000
+++ linux/drivers/video/console/fbcon.c	2002-12-03 10:56:26.000000000 +0000
@@ -317,18 +317,16 @@
 	if (newidx != con2fb_map[unit]) {
 		oldfb = registered_fb[oldidx];
 		newfb = registered_fb[newidx];
-		if (newfb->fbops->owner)
-			__MOD_INC_USE_COUNT(newfb->fbops->owner);
+		if (!try_module_get(newfb->fbops->owner))
+			return;
 		if (newfb->fbops->fb_open
 		    && newfb->fbops->fb_open(newfb, 0)) {
-			if (newfb->fbops->owner)
-				__MOD_DEC_USE_COUNT(newfb->fbops->owner);
+			module_put(newfb->fbops->owner);
 			return;
 		}
 		if (oldfb->fbops->fb_release)
 			oldfb->fbops->fb_release(oldfb, 0);
-		if (oldfb->fbops->owner)
-			__MOD_DEC_USE_COUNT(oldfb->fbops->owner);
+		module_put(oldfb->fbops->owner);
 		vc = fb_display[unit].conp;
 		fontdata = fb_display[unit].fontdata;
 		userfont = fb_display[unit].userfont;
@@ -596,10 +594,10 @@
 	info->currcon = -1;
 	
 	owner = info->fbops->owner;
-	if (owner)
-		__MOD_INC_USE_COUNT(owner);
-	if (info->fbops->fb_open && info->fbops->fb_open(info, 0) && owner)
-		__MOD_DEC_USE_COUNT(owner);
+	if (!try_module_get(owner))
+		return NULL;
+	if (info->fbops->fb_open && info->fbops->fb_open(info, 0))
+		module_put(owner);
 	
 	if (info->fix.type != FB_TYPE_TEXT) {
 		if (fbcon_softback_size) {
@@ -2549,111 +2547,226 @@
 	return n < 0 ? d >> -n : d << n;
 }
 
-static int __init fbcon_show_logo(void)
+static void __init fbcon_set_logocmap(struct fb_info *info)
+{
+	int i, j, n;
+
+	for (i = 0; i < LINUX_LOGO_COLORS; i += n) {
+		n = LINUX_LOGO_COLORS - i;
+		if (n > 16)
+			/* palette_cmap provides space for only 16 colors at once */
+			n = 16;
+		palette_cmap.start = 32 + i;
+		palette_cmap.len = n;
+		for (j = 0; j < n; ++j) {
+			palette_cmap.red[j] =
+				(linux_logo_red[i + j] << 8) |
+				linux_logo_red[i + j];
+			palette_cmap.green[j] =
+				(linux_logo_green[i + j] << 8) |
+				linux_logo_green[i + j];
+			palette_cmap.blue[j] =
+				(linux_logo_blue[i + j] << 8) |
+				linux_logo_blue[i + j];
+		}
+		fb_set_cmap(&palette_cmap, 1, info);
+	}
+}
+
+static void  __init fbcon_set_logo_truepalette(struct fb_info *info, u32 *palette)
+{
+	unsigned char mask[9] = { 0,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff };
+	unsigned char redmask, greenmask, bluemask;
+	int redshift, greenshift, blueshift;
+	int i;
+	
+	/*
+	 * We have to create a temporary palette since console palette is only
+	 * 16 colors long.
+	 */
+	/* Bug: Doesn't obey msb_right ... (who needs that?) */
+	redmask   = mask[info->var.red.length   < 8 ? info->var.red.length   : 8];
+	greenmask = mask[info->var.green.length < 8 ? info->var.green.length : 8];
+	bluemask  = mask[info->var.blue.length  < 8 ? info->var.blue.length  : 8];
+	redshift   = info->var.red.offset   - (8 - info->var.red.length);
+	greenshift = info->var.green.offset - (8 - info->var.green.length);
+	blueshift  = info->var.blue.offset  - (8 - info->var.blue.length);
+	
+	
+	for ( i = 0; i < LINUX_LOGO_COLORS; i++) {
+		palette[i+32] = (safe_shift((linux_logo_red[i]   & redmask), redshift) |
+				 safe_shift((linux_logo_green[i] & greenmask), greenshift) |
+				 safe_shift((linux_logo_blue[i]  & bluemask), blueshift));
+	}
+}
+
+static void __init fbcon_set_logo_directpalette(struct fb_info *info, u32 *palette)
+{
+	int redshift, greenshift, blueshift;
+	int i;
+
+	redshift = info->var.red.offset;
+	greenshift = info->var.green.offset;
+	blueshift = info->var.blue.offset;
+	
+	for (i = 32; i < LINUX_LOGO_COLORS; i++) 
+		palette[i] = i << redshift | i << greenshift | i << blueshift;
+
+}
+	
+static void __init fbcon_set_logo(struct fb_info *info, u8 *logo, int needs_logo)
 {
-	struct display *p = &fb_display[fg_console];	/* draw to vt in foreground */
+	int i, j;
+
+	switch (needs_logo) {
+	case 4:
+		for (i = 0; i < (LOGO_W * LOGO_H)/2; i++) {
+			logo[i*2] = linux_logo16[i] >> 4;
+			logo[(i*2)+1] = linux_logo16[i] & 0xf;
+		}
+		break;
+	case 1:
+	case ~1:
+	default:
+		for (i = 0; i < (LOGO_W * LOGO_H)/8; i++) 
+			for (j = 0; j < 8; j++) 
+				logo[i*2] = (linux_logo_bw[i] &  (7 - j)) ? 
+					((needs_logo == 1) ? 1 : 0) :
+					((needs_logo == 1) ? 0 : 1);
+				
+		break;
+	} 
+}	
+	
+/*
+ * Three (3) kinds of logo maps exist.  linux_logo (>16 colors), linux_logo_16 
+ * (16 colors) and linux_logo_bw (2 colors).  Depending on the visual format and
+ * color depth of the framebuffer, the DAC, the pseudo_palette, and the logo data
+ * will be adjusted accordingly.
+ *
+ * Case 1 - linux_logo:
+ * Color exceeds the number of console colors (16), thus we set the hardware DAC 
+ * using fb_set_cmap() appropriately.  The "needs_cmapreset"  flag will be set. 
+ *
+ * For visuals that require color info from the pseudo_palette, we also construct
+ * one for temporary use. The "needs_directpalette" or "needs_truepalette" flags
+ * will be set.
+ *
+ * Case 2 - linux_logo_16:
+ * The number of colors just matches the console colors, thus there is no need
+ * to set the DAC or the pseudo_palette.  However, the bitmap is packed, ie, 
+ * each byte contains color information for two pixels (upper and lower nibble).  
+ * To be consistent with fb_imageblit() usage, we therefore separate the two 
+ * nibbles into separate bytes. The "needs_logo" flag will be set to 4.
+ *
+ * Case 3 - linux_logo_bw:
+ * This is similar with Case 2.  Each byte contains information for 8 pixels.
+ * We isolate each bit and expand each into a byte. The "needs_logo" flag will
+ * be set to 1.
+ */
+static int __init fbcon_show_logo(void)
+	{
+		struct display *p = &fb_display[fg_console];	/* draw to vt in foreground */
 	struct fb_info *info = p->fb_info;
 	struct vc_data *vc = info->display_fg;
 	struct fb_image image;
 	u32 *palette = NULL, *saved_palette = NULL;
-	int depth = info->var.bits_per_pixel;
-	unsigned char *fb = info->screen_base;
-	unsigned char *logo;
-	int i, j, n, x;
-	int logo_depth, done = 0;
+	unsigned char *fb = info->screen_base, *logo_new = NULL;
+	int done = 0, x;
+	int needs_cmapreset = 0;
+	int needs_truepalette = 0;
+	int needs_directpalette = 0;
+	int needs_logo = 0;
 
 	/* Return if the frame buffer is not mapped */
-	if (!fb)
+	if (!fb || !info->fbops->fb_imageblit)
 		return 0;
 
-	/*
-	 * Set colors if visual is PSEUDOCOLOR and we have enough colors, or for
-	 * DIRECTCOLOR
-	 * We don't have to set the colors for the 16-color logo, since that logo
-	 * uses the standard VGA text console palette
-	 */
-	if ((info->fix.visual == FB_VISUAL_PSEUDOCOLOR && depth >= 8) ||
-	    (info->fix.visual == FB_VISUAL_DIRECTCOLOR && depth >= 24))
-		for (i = 0; i < LINUX_LOGO_COLORS; i += n) {
-			n = LINUX_LOGO_COLORS - i;
-			if (n > 16)
-				/* palette_cmap provides space for only 16 colors at once */
-				n = 16;
-			palette_cmap.start = 32 + i;
-			palette_cmap.len = n;
-			for (j = 0; j < n; ++j) {
-				palette_cmap.red[j] =
-				    (linux_logo_red[i + j] << 8) |
-				    linux_logo_red[i + j];
-				palette_cmap.green[j] =
-				    (linux_logo_green[i + j] << 8) |
-				    linux_logo_green[i + j];
-				palette_cmap.blue[j] =
-				    (linux_logo_blue[i + j] << 8) |
-				    linux_logo_blue[i + j];
-			}
-			fb_set_cmap(&palette_cmap, 1, info);
-		}
-
-	if (depth >= 8) {
-		logo = linux_logo;
-		logo_depth = 8;
-	} else if (depth >= 4) {
-		logo = linux_logo16;
-		logo_depth = 4;
-	} else {
-		logo = linux_logo_bw;
-		logo_depth = 1;
-	}
-
-	if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
-		unsigned char mask[9] =
-		    { 0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
-		unsigned char redmask, greenmask, bluemask;
-		int redshift, greenshift, blueshift;
-
-		/* Bug: Doesn't obey msb_right ... (who needs that?) */
-		redmask =
-		    mask[info->var.red.length <
-			 8 ? info->var.red.length : 8];
-		greenmask =
-		    mask[info->var.green.length <
-			 8 ? info->var.green.length : 8];
-		bluemask =
-		    mask[info->var.blue.length <
-			 8 ? info->var.blue.length : 8];
-		redshift =
-		    info->var.red.offset - (8 - info->var.red.length);
-		greenshift =
-		    info->var.green.offset - (8 - info->var.green.length);
-		blueshift =
-		    info->var.blue.offset - (8 - info->var.blue.length);
+	image.depth = info->var.bits_per_pixel;
 
-		/*
-		 * We have to create a temporary palette since console palette is only
-		 * 16 colors long.
-		 */
+	/* reasonable default */
+	if (image.depth >= 8)
+		image.data = linux_logo;
+	else if (image.depth >= 4) 
+		image.data = linux_logo16;
+	else 
+		image.data = linux_logo_bw;
+
+	switch (info->fix.visual) {
+	case FB_VISUAL_TRUECOLOR:
+		needs_truepalette = 1;
+		if (image.depth >= 4 && image.depth <= 8)
+			needs_logo = 4;
+		else if (image.depth < 4)
+			needs_logo = 1;
+		break;
+	case FB_VISUAL_DIRECTCOLOR:
+		if (image.depth >= 24) {
+			needs_directpalette = 1;
+			needs_cmapreset = 1;
+		}
+		/* 16 colors */
+		else if (image.depth >= 16)
+			needs_logo = 4;
+		/* 2 colors */
+		else
+			needs_logo = 1;
+		break;
+	case FB_VISUAL_MONO01:
+		/* reversed 0 = fg, 1 = bg */
+		needs_logo = ~1;
+		break;
+	case FB_VISUAL_MONO10:
+		needs_logo = 1;
+		break;
+	case FB_VISUAL_PSEUDOCOLOR:
+	default:
+		if (image.depth >= 8)
+			needs_cmapreset = 1;
+		/* fall through */
+	case FB_VISUAL_STATIC_PSEUDOCOLOR:
+		/* 16 colors */
+		if (image.depth >= 4 && image.depth < 8)
+			needs_logo = 4;
+		/* 2 colors */
+		else if (image.depth < 4)
+			needs_logo = 1;
+		break;
+	}		    
+	
+	if (needs_cmapreset) 
+		fbcon_set_logocmap(info);
+	
+	if (needs_truepalette || needs_directpalette) {
 		palette = kmalloc(256 * 4, GFP_KERNEL);
 		if (palette == NULL)
-			return (LOGO_H + vc->vc_font.height - 1)/vc->vc_font.height;
+			return 1;
+
+		if (needs_truepalette)
+			fbcon_set_logo_truepalette(info, palette);
+		else
+			fbcon_set_logo_directpalette(info, palette);
 
-		for (i = 0; i < LINUX_LOGO_COLORS; i++) {
-			palette[i + 32] =
-			    (safe_shift
-			     ((linux_logo_red[i] & redmask),
-			      redshift) | safe_shift((linux_logo_green[i] &
-						      greenmask),
-						     greenshift) |
-			     safe_shift((linux_logo_blue[i] & bluemask),
-					blueshift));
-		}
 		saved_palette = info->pseudo_palette;
 		info->pseudo_palette = palette;
 	}
+	
+	if (needs_logo) {
+		logo_new = kmalloc(LOGO_W * LOGO_H, GFP_KERNEL);
+		if (logo_new == NULL) {
+			if (palette)
+				kfree(palette);
+			if (saved_palette)
+				info->pseudo_palette = saved_palette;
+			return 1;
+		}
+
+		image.data = logo_new;
+		fbcon_set_logo(info, logo_new, needs_logo);
+	}
+
 	image.width = LOGO_W;
 	image.height = LOGO_H;
-	image.depth = depth;
-	image.data = logo;
 	image.dy = 0;
 
 	for (x = 0; x < num_online_cpus() * (LOGO_W + 8) &&
@@ -2667,6 +2780,8 @@
 		kfree(palette);
 	if (saved_palette != NULL)
 		info->pseudo_palette = saved_palette;
+	if (logo_new != NULL)
+		kfree(logo_new);
 	/* 
 	 * Modes not yet supported: packed pixels with depth != 8 (does such a
 	 * thing exist in reality?) 
@@ -2701,7 +2816,10 @@
 
 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);
+	__unsafe(THIS_MODULE);
 	return 0;
 }
 
diff -Naur linux-2.5.50-js/drivers/video/fbmem.c linux/drivers/video/fbmem.c
--- linux-2.5.50-js/drivers/video/fbmem.c	2002-12-03 10:55:42.000000000 +0000
+++ linux/drivers/video/fbmem.c	2002-12-03 10:57:29.000000000 +0000
@@ -730,12 +730,12 @@
 #endif /* CONFIG_KMOD */
 	if (!(info = registered_fb[fbidx]))
 		return -ENODEV;
-	if (info->fbops->owner)
-		__MOD_INC_USE_COUNT(info->fbops->owner);
+	if (!try_module_get(info->fbops->owner))
+		return -ENODEV;
 	if (info->fbops->fb_open) {
 		res = info->fbops->fb_open(info,1);
-		if (res && info->fbops->owner)
-			__MOD_DEC_USE_COUNT(info->fbops->owner);
+		if (res)
+			module_put(info->fbops->owner);
 	}
 	return res;
 }
@@ -750,8 +750,7 @@
 	info = registered_fb[fbidx];
 	if (info->fbops->fb_release)
 		info->fbops->fb_release(info,1);
-	if (info->fbops->owner)
-		__MOD_DEC_USE_COUNT(info->fbops->owner);
+	module_put(info->fbops->owner);
 	unlock_kernel();
 	return 0;
 }

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [STATUS] fbdev api.
  2002-12-03 12:23 ` Antonino Daplas
@ 2002-12-03 22:18   ` James Simmons
  2002-12-04  3:32     ` Antonino Daplas
  0 siblings, 1 reply; 12+ messages in thread
From: James Simmons @ 2002-12-03 22:18 UTC (permalink / raw)
  To: Antonino Daplas
  Cc: Linux Fbdev development list, Linux Kernel Mailing List,
	Linux console project


> Attached is a patch against linux-2.5.50 + your fbdev.diff.

Applied :-)

> b.  Another rewrite of fbcon_show_logo() so it's more understandable
> (hopefully).  I also added support for the rest of the visuals, but
> untested yet.
> Not tested:
> static psuedocolor, mono01, and mono10.

I have a mono hga card.

> c.  prevent fbcon module from loading if no fbdev is registered.  Also
> made fbcon module unsafe to unload (for now).  This is optional, of course.

It is a good idea until we have the ability to switch back to text mode.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [STATUS] fbdev api.
  2002-12-03 22:18   ` James Simmons
@ 2002-12-04  3:32     ` Antonino Daplas
  2002-12-04 23:00       ` James Simmons
  0 siblings, 1 reply; 12+ messages in thread
From: Antonino Daplas @ 2002-12-04  3:32 UTC (permalink / raw)
  To: James Simmons
  Cc: Linux Fbdev development list, Linux Kernel Mailing List,
	Linux console project

On Wed, 2002-12-04 at 03:18, James Simmons wrote:
> 
> > Attached is a patch against linux-2.5.50 + your fbdev.diff.
> 
> Applied :-)
> 
> > b.  Another rewrite of fbcon_show_logo() so it's more understandable
> > (hopefully).  I also added support for the rest of the visuals, but
> > untested yet.
> > Not tested:
> > static psuedocolor, mono01, and mono10.
> 
> I have a mono hga card.
> 
Can you apply the following patch to include logo drawing support for all formats :-)?

diff -Naur linux-2.5.50-js/drivers/video/cfbimgblt.c linux/drivers/video/cfbimgblt.c
--- linux-2.5.50-js/drivers/video/cfbimgblt.c	2002-12-04 03:14:19.000000000 +0000
+++ linux/drivers/video/cfbimgblt.c	2002-12-04 03:13:57.000000000 +0000
@@ -123,11 +123,11 @@
 			shift = start_index;
 		}
 		while (n--) {
-			if (p->fix.visual == FB_VISUAL_PSEUDOCOLOR)
-				color = *src & bitmask; 
 			if (p->fix.visual == FB_VISUAL_TRUECOLOR ||
 			    p->fix.visual == FB_VISUAL_DIRECTCOLOR )
 				color = palette[*src] & bitmask;
+			else
+				color = *src & bitmask; 
 			val |= SHIFT_HIGH(color, shift);
 			if (shift >= null_bits) {
 				FB_WRITEL(val, dst++);

> > c.  prevent fbcon module from loading if no fbdev is registered.  Also
> > made fbcon module unsafe to unload (for now).  This is optional, of course.
> 
> It is a good idea until we have the ability to switch back to text mode.
> 
It's not the switch back to text mode, that's very doable (see my other
reply).  It's during give_up_console() at fbcon module exit.  At this
point, the console suddenly disappears and freezes the system.  Maybe we
can save the global "conswitchp" during fbcon module init, then
something like this at fbcon module exit:

void __exit fb_console_exit(void)
{	
	give_up_console(&fbcon);
	take_over_console(saved_conswitchp, ...);	
}

Is this feasible?

Tony


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [STATUS] fbdev api.
  2002-12-04  3:32     ` Antonino Daplas
@ 2002-12-04 23:00       ` James Simmons
  0 siblings, 0 replies; 12+ messages in thread
From: James Simmons @ 2002-12-04 23:00 UTC (permalink / raw)
  To: Antonino Daplas
  Cc: Linux Fbdev development list, Linux Kernel Mailing List,
	Linux console project


> Can you apply the following patch to include logo drawing support for all formats :-)?

Applied :-)

> It's not the switch back to text mode, that's very doable (see my other
> reply).  It's during give_up_console() at fbcon module exit.  At this
> point, the console suddenly disappears and freezes the system.  Maybe we
> can save the global "conswitchp" during fbcon module init, then
> something like this at fbcon module exit:
>
> void __exit fb_console_exit(void)
> {
> 	give_up_console(&fbcon);
> 	take_over_console(saved_conswitchp, ...);
> }
>
> Is this feasible?

I thought about it but the solution is not easy. Consider that we have
vgacon and mdacon. Then I load in hgafb. Here the goal is to take over
mdacon. So we have to prevent taking over vgacon. Since there is only on
conswitchp we are in trouble.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [STATUS] fbdev api.
@ 2002-12-06 19:42 Tobias Rittweiler
  2002-12-06 23:55 ` Antonino Daplas
  0 siblings, 1 reply; 12+ messages in thread
From: Tobias Rittweiler @ 2002-12-06 19:42 UTC (permalink / raw)
  To: James Simmons; +Cc: Linux Kernel Mailing List, Linux console project

Hello James,

Monday, December 2, 2002, 10:07:33 PM, you wrote:

JS> Hi!

JS> I have a new patch avaiable. It is against 2.5.50. The patch is at
JS> http://phoenix.infradead.org/~jsimmons/fbdev.diff.gz

Besides the hunks posted recently, I encountered three problems/bugs:

a) Although your patch fixes the FB oddness for me, it makes booting
   without using framebuffer fail, IOW the kernel hangs:

   Video mode to be used for restore is f00
   BIOS-provided physical RAM map:
    BIOS-e820: 0000000000000000 - 00000000000a0000 (usable)

b) After returning from blanking mode (via APM) to normal mode, no
   character is drawn. Let's assume I'm using VIM when that happens:
   After putting any character to return from blank mode, the screen stays
   blanked apart from the cursor that _is_ shown. Now I'm able to move
   the cursor, and when the cursor encounters a character, this char
   is drawn (and keeps drawn). Though when I press Ctrl-L or when I go one line
   above to the current top-line (i.e. by forcing a redrawn), the
   whole screen is drawn properly.

c) instruction:          | produces:
   ======================|==================
   1. typing abc def     | $ abc def
                         |          ^ (<- cursor)
   2. going three chars  | $ abc def
      ro the left        |       ^
   3. pressing backspace | $ abcddef
                         |      ^
   4. pressing enter     | -bash: abcdef: command not found
                         |

HTH.
--
cheers,
 Tobias


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [STATUS] fbdev api.
  2002-12-02 21:07 [STATUS] fbdev api James Simmons
  2002-12-02 21:57 ` Tobias Rittweiler
  2002-12-03 12:23 ` Antonino Daplas
@ 2002-12-06 19:50 ` Christoph Hellwig
  2002-12-06 21:21   ` James Simmons
  2 siblings, 1 reply; 12+ messages in thread
From: Christoph Hellwig @ 2002-12-06 19:50 UTC (permalink / raw)
  To: James Simmons
  Cc: Linux Fbdev development list, Linux Kernel Mailing List,
	Linux console project

On Mon, Dec 02, 2002 at 09:07:33PM +0000, James Simmons wrote:
> 
> Hi!
> 
>   I have a new patch avaiable. It is against 2.5.50. The patch is at 

Any chance you could sync with linus again?  fb in mainline is pretty
rotten..


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [STATUS] fbdev api.
  2002-12-06 19:50 ` Christoph Hellwig
@ 2002-12-06 21:21   ` James Simmons
  0 siblings, 0 replies; 12+ messages in thread
From: James Simmons @ 2002-12-06 21:21 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Linux Fbdev development list, Linux Kernel Mailing List,
	Linux console project


> > Hi!
> > 
> >   I have a new patch avaiable. It is against 2.5.50. The patch is at 
> 
> Any chance you could sync with linus again?  fb in mainline is pretty
> rotten..

I think the time has come. Alot of improvmenents have happened :-) The 
final api for the low level drivers is done. Any further changes will be 
in fbmem.c and fbcon. I just synced up the latest work. 




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [STATUS] fbdev api.
  2002-12-06 19:42 Tobias Rittweiler
@ 2002-12-06 23:55 ` Antonino Daplas
  2002-12-07  0:49   ` James Simmons
  0 siblings, 1 reply; 12+ messages in thread
From: Antonino Daplas @ 2002-12-06 23:55 UTC (permalink / raw)
  To: Tobias Rittweiler
  Cc: James Simmons, Linux Kernel Mailing List, Linux console project

On Sat, 2002-12-07 at 00:42, Tobias Rittweiler wrote:
> Hello James,
> 
> Monday, December 2, 2002, 10:07:33 PM, you wrote:
> 
> JS> Hi!
> 
> JS> I have a new patch avaiable. It is against 2.5.50. The patch is at
> JS> http://phoenix.infradead.org/~jsimmons/fbdev.diff.gz
> 
> Besides the hunks posted recently, I encountered three problems/bugs:
> 
> a) Although your patch fixes the FB oddness for me, it makes booting
>    without using framebuffer fail, IOW the kernel hangs:
> 
>    Video mode to be used for restore is f00
>    BIOS-provided physical RAM map:
>     BIOS-e820: 0000000000000000 - 00000000000a0000 (usable)
> 
Do you have framebuffer console enabled but with no framebuffer device
enabled at boot time?  This will always fail with James' current patch.

The diff I submitted in one of my replies in this thread (fbcon.diff)
might fix that (not sure).

> b) After returning from blanking mode (via APM) to normal mode, no
>    character is drawn. Let's assume I'm using VIM when that happens:
>    After putting any character to return from blank mode, the screen stays
>    blanked apart from the cursor that _is_ shown. Now I'm able to move
>    the cursor, and when the cursor encounters a character, this char
>    is drawn (and keeps drawn). Though when I press Ctrl-L or when I go one line
>    above to the current top-line (i.e. by forcing a redrawn), the
>    whole screen is drawn properly.
> 
Can you try this?

diff -Naur linux-2.5.50-js/drivers/video/console/fbcon.c linux/drivers/video/console/fbcon.c
--- linux-2.5.50-js/drivers/video/console/fbcon.c	2002-12-06 23:33:56.000000000 +0000
+++ linux/drivers/video/console/fbcon.c	2002-12-06 23:33:18.000000000 +0000
@@ -1986,6 +1986,8 @@
 						 vc->vc_cols);
 			vc->vc_video_erase_char = oldc;
 		}
+		else
+			update_screen(vc->vc_num);
 		return 0;
 	} else {
 		/* Tell console.c that it has to restore the screen itself */

> c) instruction:          | produces:
>    ======================|==================
>    1. typing abc def     | $ abc def
>                          |          ^ (<- cursor)
>    2. going three chars  | $ abc def
>       ro the left        |       ^
>    3. pressing backspace | $ abcddef
>                          |      ^
>    4. pressing enter     | -bash: abcdef: command not found
>                          |

I get this also. Seems to occur only with colored terms.  When I do 

set TERM=vt100

the problem disappears, so I thought this was an isolated case with my
setup :-). Similar glitches happen also in emacs with syntax
highlighting turned on.

Tony




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [STATUS] fbdev api.
  2002-12-06 23:55 ` Antonino Daplas
@ 2002-12-07  0:49   ` James Simmons
  0 siblings, 0 replies; 12+ messages in thread
From: James Simmons @ 2002-12-07  0:49 UTC (permalink / raw)
  To: Antonino Daplas
  Cc: Tobias Rittweiler, Linux Kernel Mailing List,
	Linux console project


> diff -Naur linux-2.5.50-js/drivers/video/console/fbcon.c linux/drivers/video/console/fbcon.c
> --- linux-2.5.50-js/drivers/video/console/fbcon.c	2002-12-06 23:33:56.000000000 +0000
> +++ linux/drivers/video/console/fbcon.c	2002-12-06 23:33:18.000000000 +0000
> @@ -1986,6 +1986,8 @@
>  						 vc->vc_cols);
>  			vc->vc_video_erase_char = oldc;
>  		}
> +		else
> +			update_screen(vc->vc_num);
>  		return 0;
>  	} else {
>  		/* Tell console.c that it has to restore the screen itself */

Applied :-)




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2002-12-07  0:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-02 21:07 [STATUS] fbdev api James Simmons
2002-12-02 21:57 ` Tobias Rittweiler
2002-12-02 22:18   ` James Simmons
2002-12-03 12:23 ` Antonino Daplas
2002-12-03 22:18   ` James Simmons
2002-12-04  3:32     ` Antonino Daplas
2002-12-04 23:00       ` James Simmons
2002-12-06 19:50 ` Christoph Hellwig
2002-12-06 21:21   ` James Simmons
  -- strict thread matches above, loose matches on Subject: below --
2002-12-06 19:42 Tobias Rittweiler
2002-12-06 23:55 ` Antonino Daplas
2002-12-07  0:49   ` James Simmons

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox