patch-2.2.13 linux/drivers/video/creatorfb.c

Next file: linux/drivers/video/dummycon.c
Previous file: linux/drivers/video/chipsfb.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.12/linux/drivers/video/creatorfb.c linux/drivers/video/creatorfb.c
@@ -333,9 +333,11 @@
 {
 	struct fb_info_sbusfb *fb = (struct fb_info_sbusfb *)p->fb_info;
 	register struct ffb_fbc *fbc = fb->s.ffb.fbc;
+	unsigned long flags;
 	u64 yx, hw;
 	int fg;
 	
+	spin_lock_irqsave(&fb->lock, flags);
 	fg = ((u32 *)p->dispsw_data)[attr_bgcol_ec(p,conp)];
 	if (fg != fb->s.ffb.fg_cache) {
 		FFBFifo(fb, 5);
@@ -356,14 +358,17 @@
 	}
 	*(volatile u64 *)&fbc->by = yx + fb->s.ffb.yx_margin;
 	*(volatile u64 *)&fbc->bh = hw;
+	spin_unlock_irqrestore(&fb->lock, flags);
 }
 
 static void ffb_fill(struct fb_info_sbusfb *fb, struct display *p, int s,
 		     int count, unsigned short *boxes)
 {
 	register struct ffb_fbc *fbc = fb->s.ffb.fbc;
+	unsigned long flags;
 	int fg;
 
+	spin_lock_irqsave(&fb->lock, flags);
 	fg = ((u32 *)p->dispsw_data)[attr_bgcol(p,s)];
 	if (fg != fb->s.ffb.fg_cache) {
 		FFBFifo(fb, 1);
@@ -378,16 +383,19 @@
 		fbc->bw = boxes[2] - boxes[0];
 		boxes += 4;
 	}
+	spin_unlock_irqrestore(&fb->lock, flags);
 }
 
 static void ffb_putc(struct vc_data *conp, struct display *p, int c, int yy, int xx)
 {
 	struct fb_info_sbusfb *fb = (struct fb_info_sbusfb *)p->fb_info;
 	register struct ffb_fbc *fbc = fb->s.ffb.fbc;
+	unsigned long flags;
 	int i, xy;
 	u8 *fd;
 	u64 fgbg;
 
+	spin_lock_irqsave(&fb->lock, flags);
 	if (fontheightlog(p)) {
 		xy = (yy << (16 + fontheightlog(p)));
 		i = ((c & p->charmask) << fontheightlog(p));
@@ -422,6 +430,7 @@
 			fd += 2;
 		}
 	}
+	spin_unlock_irqrestore(&fb->lock, flags);
 }
 
 static void ffb_putcs(struct vc_data *conp, struct display *p, const unsigned short *s,
@@ -429,10 +438,12 @@
 {
 	struct fb_info_sbusfb *fb = (struct fb_info_sbusfb *)p->fb_info;
 	register struct ffb_fbc *fbc = fb->s.ffb.fbc;
+	unsigned long flags;
 	int i, xy;
 	u8 *fd1, *fd2, *fd3, *fd4;
 	u64 fgbg;
 
+	spin_lock_irqsave(&fb->lock, flags);
 	fgbg = (((u64)(((u32 *)p->dispsw_data)[attr_fgcol(p,scr_readw(s))])) << 32) |
 	       ((u32 *)p->dispsw_data)[attr_bgcol(p,scr_readw(s))];
 	if (fgbg != *(u64 *)&fb->s.ffb.fg_cache) {
@@ -520,6 +531,7 @@
 		}
 		xy += fontwidth(p);
 	}
+	spin_unlock_irqrestore(&fb->lock, flags);
 }
 
 static void ffb_revc(struct display *p, int xx, int yy)
@@ -530,8 +542,10 @@
 static void ffb_loadcmap (struct fb_info_sbusfb *fb, struct display *p, int index, int count)
 {
 	struct ffb_dac *dac = fb->s.ffb.dac;
+	unsigned long flags;
 	int i, j = count;
 	
+	spin_lock_irqsave(&fb->lock, flags);
 	dac->type = 0x2000 | index;
 	for (i = index; j--; i++)
 		/* Feed the colors in :)) */
@@ -539,11 +553,13 @@
 			     ((fb->color_map CM(i,1)) << 8) |
 			     ((fb->color_map CM(i,2)) << 16);
 	if (!p)
-		return;
+		goto out;
 	for (i = index, j = count; i < 16 && j--; i++)
 		((u32 *)p->dispsw_data)[i] = ((fb->color_map CM(i,0))) |
 			      		     ((fb->color_map CM(i,1)) << 8) |
 					     ((fb->color_map CM(i,2)) << 16);
+out:
+	spin_unlock_irqrestore(&fb->lock, flags);
 }
 
 static struct display_switch ffb_dispsw __initdata = {
@@ -554,17 +570,20 @@
 static void ffb_margins (struct fb_info_sbusfb *fb, struct display *p, int x_margin, int y_margin)
 {
 	register struct ffb_fbc *fbc = fb->s.ffb.fbc;
+	unsigned long flags;
 
+	spin_lock_irqsave(&fb->lock, flags);
 	fb->s.ffb.xy_margin = (y_margin << 16) + x_margin;
 	fb->s.ffb.yx_margin = (((u64)y_margin) << 32) + x_margin;
 	p->screen_base += 8192 * (y_margin - fb->y_margin) + 4 * (x_margin - fb->x_margin);
 	FFBWait(fbc);
+	spin_unlock_irqrestore(&fb->lock, flags);
 }
 
-static inline void ffb_curs_enable (struct fb_info_sbusfb *fb, int enable)
+static __inline__ void __ffb_curs_enable (struct fb_info_sbusfb *fb, int enable)
 {
 	struct ffb_dac *dac = fb->s.ffb.dac;
-	
+
 	dac->type2 = 0x100;
 	if (fb->s.ffb.dac_rev <= 2)
 		dac->value2 = enable ? 3 : 0;
@@ -575,20 +594,25 @@
 static void ffb_setcursormap (struct fb_info_sbusfb *fb, u8 *red, u8 *green, u8 *blue)
 {
 	struct ffb_dac *dac = fb->s.ffb.dac;
+	unsigned long flags;
 	
-	ffb_curs_enable (fb, 0);
+	spin_lock_irqsave(&fb->lock, flags);
+	__ffb_curs_enable (fb, 0);
 	dac->type2 = 0x102;
 	dac->value2 = (red[0] | (green[0]<<8) | (blue[0]<<16));
 	dac->value2 = (red[1] | (green[1]<<8) | (blue[1]<<16));
+	spin_unlock_irqrestore(&fb->lock, flags);
 }
 
 /* Set cursor shape */
 static void ffb_setcurshape (struct fb_info_sbusfb *fb)
 {
 	struct ffb_dac *dac = fb->s.ffb.dac;
+	unsigned long flags;
 	int i, j;
 
-	ffb_curs_enable (fb, 0);
+	spin_lock_irqsave(&fb->lock, flags);
+	__ffb_curs_enable (fb, 0);
 	for (j = 0; j < 2; j++) {
 		dac->type2 = j ? 0 : 0x80;
 		for (i = 0; i < 0x40; i++) {
@@ -601,6 +625,7 @@
 			}
 		}
 	}	
+	spin_unlock_irqrestore(&fb->lock, flags);
 }
 
 /* Load cursor information */
@@ -608,19 +633,24 @@
 {
 	struct ffb_dac *dac = fb->s.ffb.dac;
 	struct cg_cursor *c = &fb->cursor;
+	unsigned long flags;
 
+	spin_lock_irqsave(&fb->lock, flags);
 	dac->type2 = 0x104;
 	/* Should this be just 0x7ff?? 
 	   Should I do some margin handling and setcurshape in that case? */
 	dac->value2 = (((c->cpos.fby - c->chot.fby) & 0xffff) << 16)
 	              |((c->cpos.fbx - c->chot.fbx) & 0xffff);
-	ffb_curs_enable (fb, fb->cursor.enable);
+	__ffb_curs_enable (fb, fb->cursor.enable);
+	spin_unlock_irqrestore(&fb->lock, flags);
 }
 
 static void ffb_switch_from_graph (struct fb_info_sbusfb *fb)
 {
 	register struct ffb_fbc *fbc = fb->s.ffb.fbc;
+	unsigned long flags;
 
+	spin_lock_irqsave(&fb->lock, flags);
 	FFBWait(fbc);
 	fb->s.ffb.fifo_cache = 0;
 	FFBFifo(fb, 8);
@@ -633,6 +663,7 @@
 	fbc->fg = fb->s.ffb.fg_cache;
 	fbc->bg = fb->s.ffb.bg_cache;
 	FFBWait(fbc);
+	spin_unlock_irqrestore(&fb->lock, flags);
 }                                
 
 static char idstring[60] __initdata = { 0 };

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)