diff -Naur linux-2.5.50-js/drivers/video/Makefile linux/drivers/video/Makefile --- linux-2.5.50-js/drivers/video/Makefile 2002-12-04 15:22:38.000000000 +0000 +++ linux/drivers/video/Makefile 2002-12-04 15:22:12.000000000 +0000 @@ -50,7 +50,8 @@ obj-$(CONFIG_FB_S3TRIO) += S3triofb.o obj-$(CONFIG_FB_TGA) += tgafb.o obj-$(CONFIG_FB_VESA) += vesafb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o -obj-$(CONFIG_FB_VGA16) += vga16fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o +obj-$(CONFIG_FB_VGA16) += vga16fb.o cfbfillrect.o cfbcopyarea.o \ + cfbimgblt.o vgastate.o obj-$(CONFIG_FB_VIRGE) += virgefb.o obj-$(CONFIG_FB_G364) += g364fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_FM2) += fm2fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o diff -Naur linux-2.5.50-js/drivers/video/vga16fb.c linux/drivers/video/vga16fb.c --- linux-2.5.50-js/drivers/video/vga16fb.c 2002-12-04 15:22:42.000000000 +0000 +++ linux/drivers/video/vga16fb.c 2002-12-04 15:21:26.000000000 +0000 @@ -7,7 +7,8 @@ * * This file is subject to the terms and conditions of the GNU General * Public License. See the file COPYING in the main directory of this - * archive for more details. */ + * archive for more details. + */ #include #include @@ -69,6 +70,8 @@ unsigned char ModeControl; /* CRT-Controller:17h */ unsigned char ClockingMode; /* Seq-Controller:01h */ } vga_state; + struct fb_vgastate state; + atomic_t ref_count; int palette_blanked, vesa_blanked, mode, isVGA; u8 misc, pel_msk, vss, clkdiv; u8 crtc[VGA_CRT_C]; @@ -295,6 +298,34 @@ #define FAIL(X) return -EINVAL +static int vga16fb_open(struct fb_info *info, int user) +{ + struct vga16fb_par *par = (struct vga16fb_par *) info->par; + int cnt = atomic_read(&par->ref_count); + + if (!cnt) { + memset(&par->state, 0, sizeof(struct fb_vgastate)); + par->state.flags = 8; + fb_save_vga(&par->state); + } + atomic_inc(&par->ref_count); + return 0; +} + +static int vga16fb_release(struct fb_info *info, int user) +{ + struct vga16fb_par *par = (struct vga16fb_par *) info->par; + int cnt = atomic_read(&par->ref_count); + + if (!cnt) + return -EINVAL; + if (cnt == 1) + fb_restore_vga(&par->state); + atomic_dec(&par->ref_count); + + return 0; +} + static int vga16fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { @@ -1346,6 +1377,8 @@ static struct fb_ops vga16fb_ops = { .owner = THIS_MODULE, + .fb_open = vga16fb_open, + .fb_release = vga16fb_release, .fb_check_var = vga16fb_check_var, .fb_set_par = vga16fb_set_par, .fb_setcolreg = vga16fb_setcolreg,