linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [Linux-fbdev-devel] [PATCH] FBDev: vga16fb port
@ 2002-12-04 10:38 Petr Vandrovec
  0 siblings, 0 replies; 22+ messages in thread
From: Petr Vandrovec @ 2002-12-04 10:38 UTC (permalink / raw)
  To: Antonino Daplas
  Cc: James Simmons, linux-fbdev-devel, Linux Kernel Mailing List,
	luther

On  4 Dec 02 at 17:08, Antonino Daplas wrote:
> On Wed, 2002-12-04 at 12:32, Sven Luther wrote:
> > On Tue, Dec 03, 2002 at 05:22:35PM +0500, Antonino Daplas wrote:
> > > >   2) The ability to go back to vga text mode on close of /dev/fb. 
> > > >      Yes fbdev/fbcon supports that now. 
> > > 
> > > I'll take a stab at writing VGA save/restore routines which hopefully is
> > > generic enough to be used by various hardware.  No promises though, VGA
> > > programming gives me a headache :(
> > 
> > BTW, i am writing a fbdev for a card where the docs tell me to disable
> > vga output before enabling graphical output. Does i need to do this in
> > the fbdev i write, or is it already handled by the vga layer, or
> > whatever ?
> 
> Most cards with a VGA core needs to disable the VGA output before going
> to graphics mode.  Disabling VGA output is hardware specific, and is
> usually automatic when you go to graphics mode.
> 
> Because James wrote the fb framework to be very modular, then you must
> be careful to save/restore the initial video state  when loading or
> unloading.  Theoretically, a driver should load, but not go to graphics
> mode immediately.  Only upon a call to xxxfb_set_par() should the driver
> do so.  Before going to graphics mode, that's were you save the initial
> state.  Have a reference count or something to keep track of the number
> of users, and when this reference count becomes zero, restore the
> initial state.  You should be able to do this by hooking these routines
> in fb_open() and fb_release().

FYI, I'm not going to support any hardware restoration on last fb_release,
nor hardware init only after first fb_open in matroxfb. Either you want
this driver, or not. Besides that I do not see any reason to have such 
code, matroxfb provides multiple framebuffers, and to get them
all work, hardware must be in known state, it is impossible to program
only half of chip and expect that it will somehow work. It will crash,
lock your PCI bus, or even commits suicide.

And I'm sure that other possible solution, that opening /dev/fb1 
(or /dev/videoX or /dev/dri/mga) will cause your vgacon picture to 
disappear, violates principle of least surprise.
                                            Best regards,
                                                Petr Vandrovec
                                                vandrove@vc.cvut.cz
                                                

^ permalink raw reply	[flat|nested] 22+ messages in thread
* [PATCH] FBDev: vga16fb port
@ 2002-11-28  7:24 Antonino Daplas
  2002-12-02 20:31 ` [Linux-fbdev-devel] " James Simmons
  0 siblings, 1 reply; 22+ messages in thread
From: Antonino Daplas @ 2002-11-28  7:24 UTC (permalink / raw)
  To: Linux Fbdev development list; +Cc: Linux Kernel Mailing List

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

Attached is a patch against 2.5.49 + James Simmons' latest fbdev.diff.

Added support for logo drawing.
Fixed vga16fb_imageblit() limitation of 8-pixel wide bitmap blitting
only.

Tony



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

diff -Naur linux-2.5.49/drivers/video/vga16fb.c linux/drivers/video/vga16fb.c
--- linux-2.5.49/drivers/video/vga16fb.c	2002-11-28 06:44:07.000000000 +0000
+++ linux/drivers/video/vga16fb.c	2002-11-28 06:47:06.000000000 +0000
@@ -1062,8 +1062,10 @@
                 }
         } else {
                 line_ofs = info->fix.line_length - area->width;
-                dest = info->screen_base + area->dx + area->width + (area->dy + height - 1) * info->fix.line_length;
-                src = info->screen_base + area->sx + area->width + (area->sy + height - 1) * info->fix.line_length;
+                dest = info->screen_base + area->dx + area->width +
+			(area->dy + height - 1) * info->fix.line_length;
+                src = info->screen_base + area->sx + area->width +
+			(area->sy + height - 1) * info->fix.line_length;
                 while (height--) {
                         for (x = 0; x < area->width; x++) {
                                 --src;
@@ -1147,8 +1149,10 @@
 					dst += line_ofs;
 				}
 			} else {
-				dst = info->screen_base + (area->dx/8) + width + (area->dy + height - 1) * info->fix.line_length;
-				src = info->screen_base + (area->sx/8) + width + (area->sy + height  - 1) * info->fix.line_length;
+				dst = info->screen_base + (area->dx/8) + width + 
+					(area->dy + height - 1) * info->fix.line_length;
+				src = info->screen_base + (area->sx/8) + width + 
+					(area->sy + height  - 1) * info->fix.line_length;
 				while (height--) {
 					for (x = 0; x < width; x++) {
 						dst--;
@@ -1222,65 +1226,123 @@
         setindex(oldindex);
 }
 
-void vga16fb_imageblit(struct fb_info *info, struct fb_image *image)
+void vga_imageblit_expand(struct fb_info *info, struct fb_image *image)
 {
-	char *where = info->screen_base + (image->dx/image->width) + image->dy * info->fix.line_length;
+	char *where = info->screen_base + (image->dx/8) + 
+		image->dy * info->fix.line_length;
 	struct vga16fb_par *par = (struct vga16fb_par *) info->par;
-	u8 *cdat = image->data;
-	int y;
+	u8 *cdat = image->data, *dst;
+	int x, y;
 
 	switch (info->fix.type) {
-		case FB_TYPE_VGA_PLANES:
-			if (info->fix.type_aux == FB_AUX_VGA_PLANES_VGA4) {
-				if (par->isVGA) {
-					setmode(2);
-					setop(0);
-					setsr(0xf);
-					setcolor(image->fg_color);
-					selectmask();
+	case FB_TYPE_VGA_PLANES:
+		if (info->fix.type_aux == FB_AUX_VGA_PLANES_VGA4) {
+			if (par->isVGA) {
+				setmode(2);
+				setop(0);
+				setsr(0xf);
+				setcolor(image->fg_color);
+				selectmask();
+				
+				setmask(0xff);
+				writeb(image->bg_color, where);
+				rmb();
+				readb(where); /* fill latches */
+				setmode(3);
+				wmb();
+				for (y = 0; y < image->height; y++) {
+					dst = where;
+					for (x = image->width/8; x--;) 
+						writeb(*cdat++, dst++);
+					where += info->fix.line_length;
+				}
+				wmb();
+			} else {
+				setmode(0);
+				setop(0);
+				setsr(0xf);
+				setcolor(image->bg_color);
+				selectmask();
+				
+				setmask(0xff);
+				for (y = 0; y < image->height; y++) {
+					dst = where;
+					for (x=image->width/8; x--;){
+						rmw(dst);
+						setcolor(image->fg_color);
+						selectmask();
+						if (*cdat) {
+							setmask(*cdat++);
+							rmw(dst++);
+						}
+					}
+					where += info->fix.line_length;
+				}
+			}
+		} else 
+			vga_8planes_imageblit(info, image);
+		break;
+#ifdef FBCON_HAS_VGA
+	case FB_TYPE_TEXT:
+		break;
+#endif
+	case FB_TYPE_PACKED_PIXELS:
+	default:
+		cfb_imageblit(info, image);
+		break;
+	}
+}
 
-					setmask(0xff);
-					writeb(image->bg_color, where);
-					rmb();
-					readb(where); /* fill latches */
-					setmode(3);
-					wmb();
-					for (y = 0; y < image->height; y++, where += info->fix.line_length)
-						writeb(cdat[y], where);
-						wmb();
-				} else {
-					setmode(0);
-					setop(0);
-					setsr(0xf);
-					setcolor(image->bg_color);
-					selectmask();
+void vga_imageblit_color(struct fb_info *info, struct fb_image *image) 
+{
+	/*
+	 * Draw logo 
+	 */
+	struct vga16fb_par *par = (struct vga16fb_par *) info->par;
+	char *where = info->screen_base + image->dy * info->fix.line_length + 
+		image->dx/8;
+	char *cdat = image->data, *dst;
+	int x, y;
 
-					setmask(0xff);
-					for (y = 0; y < image->height; y++, where += info->fix.line_length)
-						rmw(where);
+	switch (info->fix.type) {
+	case FB_TYPE_VGA_PLANES:
+		if (info->fix.type_aux == FB_AUX_VGA_PLANES_VGA4 &&
+		    par->isVGA) {
+			setsr(0xf);
+			setop(0);
+			setmode(0);
+			
+			for (y = 0; y < image->height; y++) {
+				for (x = 0; x < image->width; x++) {
+					dst = where + x/8;
 
-					where -= info->fix.line_length * y;
-					setcolor(image->fg_color);
+					setcolor(*cdat);
 					selectmask();
-					for (y = 0; y < image->height; y++, where += info->fix.line_length)
-					if (cdat[y]) {
-						setmask(cdat[y]);
-						rmw(where);
-					}
+					setmask(1 << (7 - (x % 8)));
+					fb_readb(dst);
+					fb_writeb(0, dst);
+
+					cdat++;
 				}
-			} else 
-				vga_8planes_imageblit(info, image);
-			break;
-#ifdef FBCON_HAS_VGA
-		case FB_TYPE_TEXT:
-			break;
-#endif
-		case FB_TYPE_PACKED_PIXELS:
-		default:
-			cfb_imageblit(info, image);
-			break;
+				where += info->fix.line_length;
+			}
+		}
+		break;
+	case FB_TYPE_PACKED_PIXELS:
+		cfb_imageblit(info, image);
+		break;
+	default:
+		break;
 	}
 }
+				
+void vga16fb_imageblit(struct fb_info *info, struct fb_image *image)
+{
+	if (image->depth == 1)
+		vga_imageblit_expand(info, image);
+	else if (image->depth == info->var.bits_per_pixel)
+		vga_imageblit_color(info, image);
+}
 
 static struct fb_ops vga16fb_ops = {
 	.owner		= THIS_MODULE,
@@ -1292,6 +1354,7 @@
 	.fb_fillrect	= vga16fb_fillrect,
 	.fb_copyarea	= vga16fb_copyarea,
 	.fb_imageblit	= vga16fb_imageblit,
+	.fb_cursor      = soft_cursor,
 };
 
 int vga16fb_setup(char *options)
@@ -1343,6 +1406,11 @@
 	i = (vga16fb_defined.bits_per_pixel == 8) ? 256 : 16;
 	fb_alloc_cmap(&vga16fb.cmap, i, 0);
 
+	if (vga16fb_check_var(&vga16fb.var, &vga16fb))
+		return -EINVAL;
+
+	vga16fb_update_fix(&vga16fb);
+
 	if (register_framebuffer(&vga16fb) < 0) {
 		iounmap(vga16fb.screen_base);
 		return -EINVAL;

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

end of thread, other threads:[~2002-12-06  1:36 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-04 10:38 [Linux-fbdev-devel] [PATCH] FBDev: vga16fb port Petr Vandrovec
  -- strict thread matches above, loose matches on Subject: below --
2002-11-28  7:24 Antonino Daplas
2002-12-02 20:31 ` [Linux-fbdev-devel] " James Simmons
2002-12-03 12:22   ` Antonino Daplas
2002-12-03 15:47     ` Alan Cox
2002-12-03 20:50       ` Antonino Daplas
2002-12-03 22:01         ` James Simmons
2002-12-03 22:02       ` James Simmons
2002-12-04  3:19         ` Tomas Szepe
2002-12-04  7:32     ` Sven Luther
2002-12-04 12:08       ` Antonino Daplas
2002-12-04 10:28         ` Sven Luther
2002-12-04 17:27           ` Antonino Daplas
2002-12-04 16:47             ` Sven Luther
2002-12-05  1:04               ` Antonino Daplas
2002-12-05 17:35                 ` James Simmons
2002-12-05 18:03                   ` Sven Luther
2002-12-05 20:37                     ` James Simmons
2002-12-05 20:44                       ` Sven Luther
2002-12-06  0:50                         ` James Simmons
2002-12-06  1:36                         ` Antonino Daplas
2002-12-03 20:49   ` Antonino Daplas
2002-12-04 23:44     ` James Simmons

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).