[parisc-linux-cvs] stifb compile fixes

Helge Deller deller@gmx.de
Tue, 15 Oct 2002 22:52:54 +0200


--Boundary-00=_mAIr9pb/pCW7S+4
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Tuesday 15 October 2002 22:42, Helge Deller wrote:
> CVSROOT:	/var/cvs
> Module name:	linux-2.5
> Changes by:	deller	02/10/15 14:42:51
>
> Modified files:
> 	drivers/video  : fbcon-sti.c
> 	drivers/video/sti: stifb.c
>
> Log message:
> fix stifb build, won't work yet but compiles

the framebuffer code in 2.5 has gotten a big cleanup and we
are now able to remove lots of code.
Nevertheless this driver won't work yet....


--Boundary-00=_mAIr9pb/pCW7S+4
Content-Type: text/plain;
  charset="iso-8859-1";
  name="stifb.patch1"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="stifb.patch1"

Index: fbcon-sti.c
===================================================================
RCS file: /var/cvs/linux-2.5/drivers/video/fbcon-sti.c,v
retrieving revision 1.5
diff -u -p -r1.5 fbcon-sti.c
--- fbcon-sti.c	30 Aug 2002 20:00:11 -0000	1.5
+++ fbcon-sti.c	15 Oct 2002 20:40:07 -0000
@@ -120,10 +120,10 @@ writeb_hp(u8 b, void *dst)
 static void
 fbcon_sti_setup(struct display *p)
 {
-	if (p->line_length)
-		p->next_line = p->line_length;
-	else
+	if (p->var.xres_virtual /*line_length*/)
 		p->next_line = p->var.xres_virtual>>3;
+	else
+		p->next_line = 2048; /* default STI value */
 	p->next_plane = 0;
 }
 
Index: sti/stifb.c
===================================================================
RCS file: /var/cvs/linux-2.5/drivers/video/sti/stifb.c,v
retrieving revision 1.1
diff -u -p -r1.1 stifb.c
--- sti/stifb.c	23 Jul 2002 18:08:34 -0000	1.1
+++ sti/stifb.c	15 Oct 2002 20:40:08 -0000
@@ -116,21 +116,11 @@ typedef struct {                  
 
 struct stifb_info {
 	struct fb_info info;
-        struct fb_var_screeninfo var;
-        struct fb_fix_screeninfo fix;
-	struct display disp;
+	unsigned int id;
+	ngle_rom_t ngle_rom;
 	struct sti_struct *sti;
-	unsigned int id, real_id;
-	int currcon;
-	int cmap_reload:1;   
 	int deviceSpecificConfig;
-	ngle_rom_t ngle_rom;
-	struct { u8 red, green, blue; } palette[256];
-#ifdef FBCON_HAS_CFB32	
-	union {
-		u32 cfb32[16];
-	} fbcon_cmap;
-#endif			
+	struct display disp;
 };
 
 static int stifb_force_bpp[MAX_STI_ROMS] = {0, };
@@ -172,10 +162,10 @@ static int stifb_force_bpp[MAX_STI_ROMS]
 #define REG_44		0x210030
 #define REG_45		0x210034
 
-#define READ_BYTE(fb,reg)		__raw_readb((fb)->fix.mmio_start + (reg))
-#define READ_WORD(fb,reg)		__raw_readl((fb)->fix.mmio_start + (reg))
-#define WRITE_BYTE(value,fb,reg)	__raw_writeb((value),(fb)->fix.mmio_start + (reg))
-#define WRITE_WORD(value,fb,reg)	__raw_writel((value),(fb)->fix.mmio_start + (reg))
+#define READ_BYTE(fb,reg)		__raw_readb((fb)->info.fix.mmio_start + (reg))
+#define READ_WORD(fb,reg)		__raw_readl((fb)->info.fix.mmio_start + (reg))
+#define WRITE_BYTE(value,fb,reg)	__raw_writeb((value),(fb)->info.fix.mmio_start + (reg))
+#define WRITE_WORD(value,fb,reg)	__raw_writel((value),(fb)->info.fix.mmio_start + (reg))
 
 #define ENABLE	1	/* for enabling/disabling screen */	
 #define DISABLE 0
@@ -210,13 +200,13 @@ SETUP_FB(struct stifb_info *fb)
 			reg10_value = 0x13601000;
 			break;
 		case S9000_ID_A1439A:
-			if (fb->var.bits_per_pixel == 32)						
+			if (fb->info.var.bits_per_pixel == 32)						
 				reg10_value = 0xBBA0A000;
 			else 
 				reg10_value = 0x13601000;
 			break;
 		case S9000_ID_HCRX:
-			if (fb->var.bits_per_pixel == 32)
+			if (fb->info.var.bits_per_pixel == 32)
 				reg10_value = 0xBBA0A000;
 			else					
 				reg10_value = 0x13602000;
@@ -254,7 +244,7 @@ static void
 FINISH_IMAGE_COLORMAP_ACCESS(struct stifb_info *fb) 
 {		
 	WRITE_WORD(0x400, fb, REG_2);
-	if (fb->var.bits_per_pixel == 32) {
+	if (fb->info.var.bits_per_pixel == 32) {
 		WRITE_WORD(0x83000100, fb, REG_1);
 	} else {
 		if (fb->id == S9000_ID_ARTIST || fb->id == CRT_ID_VISUALIZE_EG)
@@ -493,7 +483,7 @@ static void 
 ngleSetupAttrPlanes(struct stifb_info *fb, int BufferNumber)
 {
 	SETUP_ATTR_ACCESS(fb, BufferNumber);
-	SET_ATTR_SIZE(fb, fb->var.xres, fb->var.yres);
+	SET_ATTR_SIZE(fb, fb->info.var.xres, fb->info.var.yres);
 	FINISH_ATTR_ACCESS(fb);
 	SETUP_FB(fb);
 }
@@ -510,8 +500,8 @@ rattlerSetupPlanes(struct stifb_info *fb
 	WRITE_BYTE(1, fb, REG_16b1);
 
 	/* XXX: replace by fb_setmem(), smem_start or screen_base ? */
-	memset_io(fb->fix.smem_start, 0xff,
-		fb->var.yres*fb->fix.line_length);
+	memset_io(fb->info.fix.smem_start, 0xff,
+		fb->info.var.yres*fb->info.fix.line_length);
     
 	CRX24_SET_OVLY_MASK(fb);
 	SETUP_FB(fb);
@@ -590,7 +580,7 @@ setHyperLutBltCtl(struct stifb_info *fb,
 	lutBltCtl.fields.lutType = HYPER_CMAP_TYPE;
 
 	/* Expect lutIndex to be 0 or 1 for image cmaps, 2 or 3 for overlay cmaps */
-	if (fb->var.bits_per_pixel == 8)
+	if (fb->info.var.bits_per_pixel == 8)
 		lutBltCtl.fields.lutOffset = 2 * 256;
 	else
 		lutBltCtl.fields.lutOffset = 0 * 256;
@@ -671,7 +661,7 @@ ngleResetAttrPlanes(struct stifb_info *f
 					       DataDynamic, MaskOtc,
 					       BGx(0), FGx(0)));
 	packed_dst = 0;
-	packed_len = (fb->var.xres << 16) | fb->var.yres;
+	packed_len = (fb->info.var.xres << 16) | fb->info.var.yres;
 	GET_FIFO_SLOTS(fb, nFreeFifoSlots, 2);
 	NGLE_SET_DSTXY(fb, packed_dst);
 	SET_LENXY_START_RECFILL(fb, packed_len);
@@ -721,7 +711,7 @@ ngleClearOverlayPlanes(struct stifb_info
         NGLE_REALLY_SET_IMAGE_PLANEMASK(fb, mask);
     
         packed_dst = 0;
-        packed_len = (fb->var.xres << 16) | fb->var.yres;
+        packed_len = (fb->info.var.xres << 16) | fb->info.var.yres;
         NGLE_SET_DSTXY(fb, packed_dst);
     
         /* Write zeroes to overlay planes */		       
@@ -743,7 +733,7 @@ hyperResetPlanes(struct stifb_info *fb, 
 	NGLE_LOCK(fb);
 
 	if (IS_24_DEVICE(fb))
-		if (fb->var.bits_per_pixel == 32)
+		if (fb->info.var.bits_per_pixel == 32)
 			controlPlaneReg = 0x04000F00;
 		else
 			controlPlaneReg = 0x00000F00;   /* 0x00000800 should be enought, but lets clear all 4 bits */
@@ -873,7 +863,7 @@ SETUP_HCRX(struct stifb_info *fb)
 	GET_FIFO_SLOTS(fb, nFreeFifoSlots, 7);
 	
 	if (IS_24_DEVICE(fb)) {
-		hyperbowl = (fb->var.bits_per_pixel == 32) ?
+		hyperbowl = (fb->info.var.bits_per_pixel == 32) ?
 			HYPERBOWL_MODE01_8_24_LUT0_TRANSPARENT_LUT1_OPAQUE :
 			HYPERBOWL_MODE01_8_24_LUT0_OPAQUE_LUT1_OPAQUE;
 
@@ -904,55 +894,52 @@ SETUP_HCRX(struct stifb_info *fb)
 
 /* ------------------- driver specific functions --------------------------- */
 
-static int
-stifb_getcolreg(u_int regno, u_int *red, u_int *green,
-	      u_int *blue, u_int *transp, struct fb_info *info)
-{
-	struct stifb_info *fb = (struct stifb_info *) info;
-
-	if (regno > 255)
-		return 1;
-	*red = (fb->palette[regno].red<<8) | fb->palette[regno].red;
-	*green = (fb->palette[regno].green<<8) | fb->palette[regno].green;
-	*blue = (fb->palette[regno].blue<<8) | fb->palette[regno].blue;
-	*transp = 0;
-
-	return 0;
-}
 
 static int
 stifb_setcolreg(u_int regno, u_int red, u_int green,
 	      u_int blue, u_int transp, struct fb_info *info)
 {
 	struct stifb_info *fb = (struct stifb_info *) info;
+	u32 color;
 
-	if (regno > 255)
+	if (regno >= 256)  /* no. of hw registers */
 		return 1;
+	
+	START_IMAGE_COLORMAP_ACCESS(fb);
+	
+	if (fb->info.var.grayscale) {
+		/* gray = 0.30*R + 0.59*G + 0.11*B */
+		color = ((red * 77) +
+			 (green * 151) +
+			 (blue * 28)) >> 8;
+	} else {
+		color = ((red << 16) |
+			 (green << 8) |
+			 (blue));
+	}
 
-	red >>= 8;
-	green >>= 8;
-	blue >>= 8;
+	WRITE_IMAGE_COLOR(fb, regno, color);
 	
-	if ((fb->palette[regno].red != red) ||
-	    (fb->palette[regno].green != green) ||
-	    (fb->palette[regno].blue != blue))
-		fb->cmap_reload = 1;
-	    
-	fb->palette[regno].red = red;
-	fb->palette[regno].green = green;
-	fb->palette[regno].blue = blue;
-    
-#ifdef FBCON_HAS_CFB32
-	if (regno < 16 && fb->var.bits_per_pixel == 32) {
-		fb->fbcon_cmap.cfb32[regno] = ((red << 16) |
-					       (green << 8) |
-					       (blue << 0) |
-					       (transp << 24));
+	if (fb->id == S9000_ID_HCRX) {
+		NgleLutBltCtl lutBltCtl;
+
+		lutBltCtl = setHyperLutBltCtl(fb,
+				0,	/* Offset w/i LUT */
+				256);	/* Load entire LUT */
+		NGLE_BINC_SET_SRCADDR(fb,
+				NGLE_LONG_FB_ADDRESS(0, 0x100, 0)); 
+				/* 0x100 is same as used in WRITE_IMAGE_COLOR() */
+		START_COLORMAPLOAD(fb, lutBltCtl.all);
+		SETUP_FB(fb);
+	} else {
+		/* cleanup colormap hardware */
+		FINISH_IMAGE_COLORMAP_ACCESS(fb);
 	}
-#endif
+
 	return 0;
 }
 
+#if 0
 static void
 stifb_loadcmap(struct stifb_info *fb)
 {
@@ -964,10 +951,10 @@ stifb_loadcmap(struct stifb_info *fb)
 
 	START_IMAGE_COLORMAP_ACCESS(fb);
 	for (i = 0; i < 256; i++) {
-		if (fb->var.bits_per_pixel > 8) {
+		if (fb->info.var.bits_per_pixel > 8) {
 			color = (i << 16) | (i << 8) | i;
 		} else {
-			if (fb->var.grayscale) {
+			if (fb->info.var.grayscale) {
 				/* gray = 0.30*R + 0.59*G + 0.11*B */
 				color = ((fb->palette[i].red * 77) +
 					 (fb->palette[i].green * 151) +
@@ -997,89 +984,9 @@ stifb_loadcmap(struct stifb_info *fb)
 	}
 	fb->cmap_reload = 0;
 }
+#endif
 
 static int
-stifb_get_fix(struct fb_fix_screeninfo *fix, int con,
-	      struct fb_info *info)
-{
-	memcpy (fix, &((struct stifb_info *)info)->fix, sizeof (*fix));
-	return 0;
-}
-
-static int
-stifb_get_var(struct fb_var_screeninfo *var, int con,
-	      struct fb_info *info)
-{
-	memcpy (var, &((struct stifb_info *)info)->var, sizeof (*var));
-	return 0;
-}
-
-static int
-stifb_set_var(struct fb_var_screeninfo *var, int con,
-	      struct fb_info *info)
-{
-	struct display *disp;
-	
-	if (con >= 0)
-		disp = &fb_display[con];
-	else
-		disp = info->disp;
-
-	if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
-		if (disp->var.xres != var->xres ||
-		    disp->var.yres != var->yres ||
-		    disp->var.xres_virtual != var->xres_virtual ||
-		    disp->var.yres_virtual != var->yres_virtual ||
-		    disp->var.bits_per_pixel != var->bits_per_pixel ||
-		    disp->var.accel_flags != var->accel_flags)
-			return -EINVAL;
-	}
-	return 0;
-}
-
-static int
-stifb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
-	       struct fb_info *info)
-{
-	struct stifb_info *fb = (struct stifb_info *)info;
-	
-	if (con == fb->currcon) /* current console ? */
-		return fb_get_cmap(cmap, kspc, stifb_getcolreg, info);
-	else if (fb_display[con].cmap.len) /* non default colormap ? */
-		fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
-	else
-		fb_copy_cmap(fb_default_cmap(fb_display[con].var.bits_per_pixel > 8 ? 16 : 256), cmap, kspc ? 0: 2);
-	return 0;
-}
-
-static int
-stifb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
-	       struct fb_info *info)
-{
-	struct stifb_info *fb = (struct stifb_info *)info;
-	struct display *disp;
-	int err;
-	
-	if (con >= 0)
-		disp = &fb_display[con];
-	else
-		disp = info->disp;
-
-	if (!disp->cmap.len) { /* no colormap allocated ? */
-		if ((err = fb_alloc_cmap(&disp->cmap, disp->var.bits_per_pixel > 8 ? 16 : 256, 0)))
-			return err;
-	}
-	if (con == fb->currcon || con == -1) {
-		err = fb_set_cmap(cmap, kspc, info);
-		if (!err)
-			stifb_loadcmap ((struct stifb_info *)info);
-		return err;
-	} else
-		fb_copy_cmap(cmap, &disp->cmap, kspc ? 0 : 1);
-	return 0;
-}
-					 
-static void
 stifb_blank(int blank_mode, struct fb_info *info)
 {
 	struct stifb_info *fb = (struct stifb_info *) info;
@@ -1105,10 +1012,11 @@ stifb_blank(int blank_mode, struct fb_in
 	}
 	
 	SETUP_FB(fb);
+	return 0;
 }
 
-static void
-stifb_set_disp(struct stifb_info *fb)
+static void __init
+stifb_init_display(struct stifb_info *fb)
 {
 	int id = fb->id;
 
@@ -1143,7 +1051,7 @@ stifb_set_disp(struct stifb_info *fb)
         switch (id) {
 	 case S9000_ID_A1659A:
 	 case S9000_ID_A1439A:
-	    if (fb->var.bits_per_pixel == 32)
+	    if (fb->info.var.bits_per_pixel == 32)
 		ngleSetupAttrPlanes(fb, BUFF1_CMAP3);
 	    else {
 		ngleSetupAttrPlanes(fb, BUFF1_CMAP0);
@@ -1153,7 +1061,7 @@ stifb_set_disp(struct stifb_info *fb)
 	    break;
 	 case S9000_ID_ARTIST:
 	 case CRT_ID_VISUALIZE_EG:
-	    if (fb->var.bits_per_pixel == 32)
+	    if (fb->info.var.bits_per_pixel == 32)
 		ngleSetupAttrPlanes(fb, BUFF1_CMAP3);
 	    else {
 		ngleSetupAttrPlanes(fb, ARTIST_CMAP0);
@@ -1165,44 +1073,23 @@ stifb_set_disp(struct stifb_info *fb)
 	SETUP_FB(fb);
 }
 
-static int
-stifb_switch(int con, struct fb_info *info)
-{
-	struct stifb_info *fb = (struct stifb_info *)info;
-	
-	/* Do we have to save the colormap ? */
-	if (fb->currcon != -1 && fb_display[fb->currcon].cmap.len)
-		fb_get_cmap(&fb_display[fb->currcon].cmap, 1, stifb_getcolreg, info);
-
-	fb->currcon = con;
-	/* Install new colormap */
-	if (fb_display[con].cmap.len)
-		fb_set_cmap(&fb_display[con].cmap, 1, info);
-	else
-		fb_set_cmap(fb_default_cmap(fb_display[con].var.bits_per_pixel > 8 ? 16 : 256),
-			    1, info);
-	stifb_loadcmap ((struct stifb_info *)info);
-	return 0;
-}
-
-static int
-stifb_update_var(int con, struct fb_info *info)
-{
-	return 0;
-}
 
 /* ------------ Interfaces to hardware functions ------------ */
 
 static struct fb_ops stifb_ops = {
-	owner:		THIS_MODULE,
-	fb_get_fix:	stifb_get_fix,
-	fb_get_var:	stifb_get_var,
-	fb_set_var:	stifb_set_var,
-	fb_get_cmap:	stifb_get_cmap,
-	fb_set_cmap:	stifb_set_cmap,
-	fb_setcolreg:	stifb_setcolreg,
-	fb_blank:	stifb_blank,
-//	fb_pan_display:	fbgen_pan_display,
+	.owner		= THIS_MODULE,
+	.fb_set_var	= gen_set_var,
+	.fb_get_cmap	= gen_get_cmap,
+	.fb_set_cmap	= gen_set_cmap,
+	.fb_setcolreg	= stifb_setcolreg,
+	/* .fb_pan_display = stifb_pan_display, */
+	.fb_blank	= stifb_blank,
+
+	/*
+	.fb_fillrect	= cfb_fillrect,
+	.fb_copyarea	= cfb_copyarea,
+	.fb_imageblit	= cfb_imageblit, 
+	*/
 };
 
 
@@ -1217,28 +1104,33 @@ stifb_init_fb(struct sti_struct *sti, in
 	struct fb_var_screeninfo *var;
 	struct display *disp;
 	struct stifb_info *fb;
+	struct fb_info *info;
 	unsigned long sti_rom_address;
 	char *dev_name;
 	int bpp, xres, yres;
 
-	fb = kmalloc(sizeof(struct stifb_info), GFP_ATOMIC);
+#if 1	
+	printk(KERN_ERR, "%s: stifb doesn't work yet in kernel 2.5\n", __FUNCTION__);
+	return -ENODEV;
+#endif
+	
+	fb = kmalloc(sizeof(*fb), GFP_ATOMIC);
 	if (!fb) {
 		printk(KERN_ERR "stifb: Could not allocate stifb structure\n");
 		return -ENODEV;
 	}
 	
+	info = &fb->info;
+
 	/* set struct to a known state */
-	memset(fb, 0, sizeof(struct stifb_info));
-	fix = &fb->fix;
-	var = &fb->var;
+	memset(fb, 0, sizeof(*fb));
+	fix = &info->fix;
+	var = &info->var;
 	disp = &fb->disp;
 
-	fb->currcon = -1;
-	fb->cmap_reload = 1;
 	fb->sti = sti;
 	/* store upper 32bits of the graphics id */
 	fb->id = fb->sti->graphics_id[0];
-	fb->real_id = fb->id;	/* save the real id */
 
 	/* only supported cards are allowed */
 	switch (fb->id) {
@@ -1380,29 +1272,21 @@ stifb_init_fb(struct sti_struct *sti, in
 	var->yres = var->yres_virtual = yres;
 	var->bits_per_pixel = bpp;
 
-	disp->var = *var;
-	disp->visual = fix->visual;
-	disp->type = fix->type;
-	disp->type_aux = fix->type_aux;
-	disp->line_length = fix->line_length;
-	disp->var.activate = FB_ACTIVATE_NOW;
-	disp->can_soft_blank = 1;
-	disp->scrollmode = SCROLL_YREDRAW;
-	
-	strcpy(fb->info.modename, "stifb");
-	fb->info.node = NODEV;
-	fb->info.flags = FBINFO_FLAG_DEFAULT;
-	fb->info.fbops = &stifb_ops;
-	fb->info.screen_base = (void*) REGION_BASE(fb,1);
-	fb->info.disp = disp;
-	fb->info.changevar = NULL;
-	fb->info.switch_con = &stifb_switch;
-	fb->info.updatevar = &stifb_update_var;
-	fb->info.flags = FBINFO_FLAG_DEFAULT;
-	
-	stifb_set_var(&disp->var, 1, &fb->info);
-	
-	stifb_set_disp(fb);
+	strcpy(info->modename, "stifb");
+	info->node = NODEV;
+	info->fbops = &stifb_ops;
+	info->screen_base = (void*) REGION_BASE(fb,1);
+	info->disp = disp;
+	info->changevar = NULL;
+	info->switch_con = gen_switch;
+	info->updatevar = &gen_update_var;
+	info->flags = FBINFO_FLAG_DEFAULT;
+	info->currcon = -1;
+
+	/* This has to been done !!! */
+	fb_alloc_cmap(&info->cmap, 256, 0);
+	stifb_init_display(fb);
+	gen_set_disp(-1, info);
 
 	if (!request_mem_region(fix->smem_start, fix->smem_len, "stifb")) {
 		printk(KERN_ERR "stifb: cannot reserve fb region 0x%04lx-0x%04lx\n",
@@ -1454,7 +1338,7 @@ stifb_init(void)
 	for (i = 0; i < MAX_STI_ROMS; i++) {
 		sti = sti_get_rom(i);
 		if (sti)
-			stifb_init_fb (sti, stifb_force_bpp[i]);
+			stifb_init_fb(sti, stifb_force_bpp[i]);
 		else
 			break;
 	}
@@ -1465,7 +1349,7 @@ stifb_init(void)
  *  Cleanup
  */
 
-void __exit
+static void __exit
 stifb_cleanup(struct fb_info *info)
 {
 	// unregister_framebuffer(info); 

--Boundary-00=_mAIr9pb/pCW7S+4--