Re: [PATCH] 2.6.19 m68k Atari: Frame buffer support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 11 Dec 2006, Michael Schmitz wrote:
my final atafb version (modedb set up for Atari modes, although I'm not
sure the timing data make much sense). Leftover dead code removed. Same
quirks as in previous versions (logo uses amifb's cfb driver which goes
slightly wrong).

Signed-Off-By: <schmitz@xxxxxxxxxx>

A few more fixes (compile-tested only):
  - Use `unsigned int' instead of `unsigned'
  - Correct type of second parameter of fb_hwswitch.pan_display()
  - struct pt_regs * is gone
  - Use C99 named initializers
  - Kill unused fb_update_var() and atafb_set_var()
  - Kill a few more unused local variables
  - Move atafb_init() so we don't need a forward declaration for atafb_setup()
  - atafb_iplan2p*(): Kill pointer assignment warnings
  - Fix comment

Signed-off-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>

--- linux-m68k-2.6.19.orig/drivers/video/atafb.c
+++ linux-m68k-2.6.19/drivers/video/atafb.c
@@ -93,9 +93,9 @@
 static int atafb_check_var(struct fb_var_screeninfo *var,
 			   struct fb_info *info);
 static int atafb_set_par(struct fb_info *info);
-static int atafb_setcolreg(unsigned regno, unsigned red, unsigned green,
-			   unsigned blue, unsigned transp,
-			   struct fb_info *info);
+static int atafb_setcolreg(unsigned int regno, unsigned int red,
+			   unsigned int green, unsigned int blue,
+			   unsigned int transp, struct fb_info *info);
 static int atafb_blank(int blank, struct fb_info *info);
 static int atafb_pan_display(struct fb_var_screeninfo *var,
 			     struct fb_info *info);
@@ -414,13 +414,13 @@ static struct fb_hwswitch {
 						struct atafb_par *par );
 	void (*get_par)( struct atafb_par *par );
 	void (*set_par)( struct atafb_par *par );
-	int  (*getcolreg)( unsigned regno, unsigned *red,
-					   unsigned *green, unsigned *blue,
-					   unsigned *transp, struct fb_info *info );
+	int  (*getcolreg)( unsigned int regno, unsigned int *red,
+			   unsigned int *green, unsigned int *blue,
+			   unsigned int *transp, struct fb_info *info );
 	void (*set_screen_base)(void *s_base);
 	int  (*blank)( int blank_mode );
 	int  (*pan_display)( struct fb_var_screeninfo *var,
-						 struct atafb_par *par);
+			     struct fb_info *info);
 } *fbhw;
 
 static char *autodetect_names[] = {"autodetect", NULL};
@@ -856,9 +856,9 @@ static void tt_set_par( struct atafb_par
 }
 
 
-static int tt_getcolreg(unsigned regno, unsigned *red,
-			unsigned *green, unsigned *blue,
-			unsigned *transp, struct fb_info *info)
+static int tt_getcolreg(unsigned int regno, unsigned int *red,
+			unsigned int *green, unsigned int *blue,
+			unsigned int *transp, struct fb_info *info)
 {
 	int t, col;
 
@@ -884,9 +884,9 @@ static int tt_getcolreg(unsigned regno, 
 }
 
 
-static int tt_setcolreg(unsigned regno, unsigned red,
-			unsigned green, unsigned blue,
-			unsigned transp, struct fb_info *info)
+static int tt_setcolreg(unsigned int regno, unsigned int red,
+			unsigned int green, unsigned int blue,
+			unsigned int transp, struct fb_info *info)
 {
 	if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH)
 		regno += 254;
@@ -1718,7 +1718,7 @@ static void falcon_set_par( struct atafb
 }
 
 
-static irqreturn_t falcon_vbl_switcher( int irq, void *dummy, struct pt_regs *fp )
+static irqreturn_t falcon_vbl_switcher( int irq, void *dummy )
 {
 	struct falcon_hw *hw = &f_new_mode;
 
@@ -1812,9 +1812,9 @@ static int falcon_pan_display( struct fb
 }
 
 
-static int falcon_getcolreg( unsigned regno, unsigned *red,
-				 unsigned *green, unsigned *blue,
-				 unsigned *transp, struct fb_info *info )
+static int falcon_getcolreg( unsigned int regno, unsigned int *red,
+				 unsigned int *green, unsigned int *blue,
+				 unsigned int *transp, struct fb_info *info )
 {	unsigned long col;
 	
 	if (regno > 255)
@@ -1832,9 +1832,9 @@ static int falcon_getcolreg( unsigned re
 }
 
 
-static int falcon_setcolreg( unsigned regno, unsigned red,
-							 unsigned green, unsigned blue,
-							 unsigned transp, struct fb_info *info )
+static int falcon_setcolreg( unsigned int regno, unsigned int red,
+							 unsigned int green, unsigned int blue,
+							 unsigned int transp, struct fb_info *info )
 {
 	if (regno > 255)
 		return 1;
@@ -2130,9 +2130,9 @@ static void stste_set_par( struct atafb_
 }
 
 
-static int stste_getcolreg(unsigned regno, unsigned *red,
-			   unsigned *green, unsigned *blue,
-			   unsigned *transp, struct fb_info *info)
+static int stste_getcolreg(unsigned int regno, unsigned int *red,
+			   unsigned int *green, unsigned int *blue,
+			   unsigned int *transp, struct fb_info *info)
 {
 	unsigned col, t;
 	
@@ -2166,9 +2166,9 @@ static int stste_getcolreg(unsigned regn
 }
 
 
-static int stste_setcolreg(unsigned regno, unsigned red,
-			   unsigned green, unsigned blue,
-			   unsigned transp, struct fb_info *info)
+static int stste_setcolreg(unsigned int regno, unsigned int red,
+			   unsigned int green, unsigned int blue,
+			   unsigned int transp, struct fb_info *info)
 {
 	if (regno > 15)
 		return 1;
@@ -2412,9 +2412,9 @@ static void ext_set_par( struct atafb_pa
 		tmp=INB(0x3da);			\
 	} while (0)
 
-static int ext_getcolreg( unsigned regno, unsigned *red,
-						  unsigned *green, unsigned *blue,
-						  unsigned *transp, struct fb_info *info )
+static int ext_getcolreg( unsigned int regno, unsigned int *red,
+						  unsigned int *green, unsigned int *blue,
+						  unsigned int *transp, struct fb_info *info )
 {
 	if (! external_vgaiobase)
 		return 1;
@@ -2426,9 +2426,9 @@ static int ext_getcolreg( unsigned regno
 	    return 0;
 }
 	
-static int ext_setcolreg( unsigned regno, unsigned red,
-						  unsigned green, unsigned blue,
-						  unsigned transp, struct fb_info *info )
+static int ext_setcolreg( unsigned int regno, unsigned int red,
+						  unsigned int green, unsigned int blue,
+						  unsigned int transp, struct fb_info *info )
 
 {	unsigned char colmask = (1 << external_bitspercol) - 1;
 
@@ -2514,32 +2514,56 @@ static int pan_display( struct fb_var_sc
 
 #ifdef ATAFB_TT
 static struct fb_hwswitch tt_switch = {
-	tt_detect, tt_encode_fix, tt_decode_var, tt_encode_var,
-	tt_get_par, tt_set_par, tt_getcolreg, 
-	set_screen_base, NULL, pan_display
+	.detect			= tt_detect,
+	.encode_fix		= tt_encode_fix,
+	.decode_var		= tt_decode_var,
+	.encode_var		= tt_encode_var,
+	.get_par		= tt_get_par,
+	.set_par		= tt_set_par,
+	.getcolreg		= tt_getcolreg,
+	.set_screen_base	= set_screen_base,
+	.pan_display		= pan_display
 };
 #endif
 
 #ifdef ATAFB_FALCON
 static struct fb_hwswitch falcon_switch = {
-	falcon_detect, falcon_encode_fix, falcon_decode_var, falcon_encode_var,
-	falcon_get_par, falcon_set_par, falcon_getcolreg,
-	set_screen_base, falcon_blank, falcon_pan_display
+	.detect			= falcon_detect,
+	.encode_fix		= falcon_encode_fix,
+	.decode_var		= falcon_decode_var,
+	.encode_var		= falcon_encode_var,
+	.get_par		= falcon_get_par,
+	.set_par		= falcon_set_par,
+	.getcolreg		= falcon_getcolreg,
+	.set_screen_base	= set_screen_base,
+	.blank			= falcon_blank,
+	.pan_display		= falcon_pan_display
 };
 #endif
 
 #ifdef ATAFB_STE
 static struct fb_hwswitch st_switch = {
-	stste_detect, stste_encode_fix, stste_decode_var, stste_encode_var,
-	stste_get_par, stste_set_par, stste_getcolreg,
-	stste_set_screen_base, NULL, pan_display
+	.detect			= stste_detect,
+	.encode_fix		= stste_encode_fix,
+	.decode_var		= stste_decode_var,
+	.encode_var		= stste_encode_var,
+	.get_par		= stste_get_par,
+	.set_par		= stste_set_par,
+	.getcolreg		= stste_getcolreg,
+	.set_screen_base	= stste_set_screen_base,
+	.pan_display		= pan_display
 };
 #endif
 
 #ifdef ATAFB_EXT
 static struct fb_hwswitch ext_switch = {
-	ext_detect, ext_encode_fix, ext_decode_var, ext_encode_var,
-	ext_get_par, ext_set_par, ext_getcolreg, NULL, NULL, NULL
+	.detect			= ext_detect,
+	.encode_fix		= ext_encode_fix,
+	.decode_var		= ext_decode_var,
+	.encode_var		= ext_encode_var,
+	.get_par		= ext_get_par,
+	.set_par		= ext_set_par,
+	.getcolreg		= ext_getcolreg,
 };
 #endif
 
@@ -2572,19 +2596,6 @@ static void ata_set_par( struct atafb_pa
 /* used for hardware scrolling */
 
 static int
-fb_update_var(struct fb_info *info)
-{
-	int off=info->var.yoffset*info->var.xres_virtual*
-			info->var.bits_per_pixel>>3;
-
-	current_par.screen_base=screen_base + off;
-
-	if (fbhw->set_screen_base)
-		fbhw->set_screen_base(current_par.screen_base);
-	return 0;
-}
-
-static int
 do_fb_set_var(struct fb_var_screeninfo *var, int isactive)
 {
 	int err,activate;
@@ -2676,33 +2687,6 @@ atafb_set_disp(struct fb_info *info)
 	}
 }
 
-static int
-atafb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
-{
-	int err,oldxres,oldyres,oldbpp,oldxres_virtual,
-	    oldyres_virtual,oldyoffset;
-	if ((err=do_fb_set_var(var, 1)))
-		return err;
-	if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
-		oldxres=info->var.xres;
-		oldyres=info->var.yres;
-		oldxres_virtual=info->var.xres_virtual;
-		oldyres_virtual=info->var.yres_virtual;
-		oldbpp=info->var.bits_per_pixel;
-		oldyoffset=info->var.yoffset;
-		info->var=*var;
-		if (oldxres != var->xres || oldyres != var->yres 
-		    || oldxres_virtual != var->xres_virtual
-		    || oldyres_virtual != var->yres_virtual
-		    || oldbpp != var->bits_per_pixel
-		    || oldyoffset != var->yoffset) {
-			atafb_set_disp(info);
-		}
-	}
-	var->activate=0;
-	return 0;
-}
-
 static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
                            u_int transp, struct fb_info *info)
 {
@@ -2715,8 +2699,6 @@ static int atafb_setcolreg(u_int regno, 
 static int
 atafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
 {
-	int xoffset = var->xoffset;
-	int yoffset = var->yoffset;
 	int err;
 
         if (var->vmode & FB_VMODE_YWRAP) {
@@ -2765,8 +2747,7 @@ static void atafb_fillrect(struct fb_inf
 			   const struct fb_fillrect *rect)
 {
 	struct atafb_par *par = (struct atafb_par *)info->par;
-	int dst_idx, x2, y2;
-	unsigned long *dst;
+	int x2, y2;
 	u32 width, height;
 
 	if (!rect->width || !rect->height)
@@ -2805,8 +2786,6 @@ static void atafb_copyarea(struct fb_inf
 	struct atafb_par *par = (struct atafb_par *)info->par;
 	int x2, y2;
 	u32 dx, dy, sx, sy, width, height;
-	unsigned long *dst, *src;
-	int dst_idx, src_idx;
 	int rev_copy = 0;
 
 	/* clip the destination */
@@ -3054,174 +3033,6 @@ check_default_par( int detected_mode )
 }
 
 
-int __init atafb_init(void)
-{
-	int pad;
-	int detected_mode;
-	unsigned int defmode;
-	unsigned long mem_req;
-
-#ifndef MODULE
-	char *option = NULL;
-
-	if (fb_get_options("atafb", &option)) {
-		return -ENODEV;
-	}
-	atafb_setup(option);
-#endif
-	printk("atafb_init: start\n");
-
-	if (!MACH_IS_ATARI)
-	        return -ENXIO;
-
-	do {
-#ifdef ATAFB_EXT
-		if (external_addr) {
-			printk("atafb_init: initializing external hw\n");
-			fbhw = &ext_switch;
-			atafb_ops.fb_setcolreg = &ext_setcolreg;
-			defmode = DEFMODE_EXT;
-			break;
-		}
-#endif
-#ifdef ATAFB_TT
-		if (ATARIHW_PRESENT(TT_SHIFTER)) {
-			printk("atafb_init: initializing TT hw\n");
-			fbhw = &tt_switch;
-			atafb_ops.fb_setcolreg = &tt_setcolreg;
-			defmode = DEFMODE_TT;
-			break;
-		}
-#endif
-#ifdef ATAFB_FALCON
-		if (ATARIHW_PRESENT(VIDEL_SHIFTER)) {
-			printk("atafb_init: initializing Falcon hw\n");
-			fbhw = &falcon_switch;
-			atafb_ops.fb_setcolreg = &falcon_setcolreg;
-			request_irq(IRQ_AUTO_4, falcon_vbl_switcher, IRQ_TYPE_PRIO,
-			            "framebuffer/modeswitch", falcon_vbl_switcher);
-			defmode = DEFMODE_F30;
-			break;
-		}
-#endif
-#ifdef ATAFB_STE
-		if (ATARIHW_PRESENT(STND_SHIFTER) ||
-		    ATARIHW_PRESENT(EXTD_SHIFTER)) {
-			printk("atafb_init: initializing ST/E hw\n");
-			fbhw = &st_switch;
-			atafb_ops.fb_setcolreg = &stste_setcolreg;
-			defmode = DEFMODE_STE;
-			break;
-		}
-		fbhw = &st_switch;
-		atafb_ops.fb_setcolreg = &stste_setcolreg;
-		printk("Cannot determine video hardware; defaulting to ST(e)\n");
-#else /* ATAFB_STE */
-		/* no default driver included */
-		/* Nobody will ever see this message :-) */
-		panic("Cannot initialize video hardware");
-#endif
-	} while (0);
-
-	/* Multisync monitor capabilities */
-	/* Atari-TOS defaults if no boot option present */
-	if (fb_info.monspecs.hfmin == 0) {
-	    fb_info.monspecs.hfmin = 31000;
-	    fb_info.monspecs.hfmax = 32000;
-	    fb_info.monspecs.vfmin = 58;
-	    fb_info.monspecs.vfmax = 62;
-	}
-
-	detected_mode = fbhw->detect();
-	check_default_par(detected_mode);
-#ifdef ATAFB_EXT
-	if (!external_addr) {
-#endif /* ATAFB_EXT */
-		mem_req = default_mem_req + ovsc_offset + ovsc_addlen;
-		mem_req = PAGE_ALIGN(mem_req) + PAGE_SIZE;
-		screen_base = atari_stram_alloc(mem_req, "atafb");
-		if (!screen_base)
-			panic("Cannot allocate screen memory");
-		memset(screen_base, 0, mem_req);
-		pad = -(unsigned long)screen_base & (PAGE_SIZE-1);
-		screen_base+=pad;
-		real_screen_base=screen_base+ovsc_offset;
-		screen_len = (mem_req - pad - ovsc_offset) & PAGE_MASK;
-		st_ovsc_switch();
-		if (CPU_IS_040_OR_060) {
-			/* On a '040+, the cache mode of video RAM must be set to
-			 * write-through also for internal video hardware! */
-			cache_push(virt_to_phys(screen_base), screen_len);
-			kernel_set_cachemode(screen_base, screen_len,
-					     IOMAP_WRITETHROUGH);
-		}
-		printk("atafb: screen_base %p real_screen_base %p screen_len %ld\n",
-			screen_base, real_screen_base, screen_len);
-#ifdef ATAFB_EXT
-	}
-	else {
-		/* Map the video memory (physical address given) to somewhere
-		 * in the kernel address space.
-		 */
-		external_addr =
-		  ioremap_writethrough((unsigned long)external_addr,
-				       external_len);
-		if (external_vgaiobase)
-			external_vgaiobase =
-			  (unsigned long)ioremap(external_vgaiobase, 0x10000);
-		screen_base      =
-		real_screen_base = external_addr;
-		screen_len       = external_len & PAGE_MASK;
-		memset (screen_base, 0, external_len);
-	}
-#endif /* ATAFB_EXT */
-
-//	strcpy(fb_info.mode->name, "Atari Builtin ");
-	fb_info.fbops = &atafb_ops;
-	// try to set default (detected; requested) var
-	do_fb_set_var(&atafb_predefined[default_par-1], 1);
-	// reads hw state into current par, which may not be sane yet
-	ata_get_par(&current_par);
-	fb_info.par = &current_par;
-	// tries to read from HW which may not be initialized yet
-	// so set sane var first, then call atafb_set_par
-	atafb_get_var(&current_var, &fb_info);
-	fb_info.var = current_var;
-	fb_info.flags = FBINFO_FLAG_DEFAULT;
-
-	if (!fb_find_mode(&fb_info.var, &fb_info, mode_option, atafb_modedb,
-			  NUM_TOTAL_MODES, &atafb_modedb[defmode], 
-			  current_var.bits_per_pixel)) {
-		return -EINVAL;
-	}
-
-// 	strcat(fb_info.mode->name, fb_var_names[default_par-1][0]);
-
-	atafb_set_disp(&fb_info);
-
-	fb_alloc_cmap(&(fb_info.cmap), 1<<fb_info.var.bits_per_pixel, 0);
-
-	printk("Determined %dx%d, depth %d\n",
-	       fb_info.var.xres, fb_info.var.yres, fb_info.var.bits_per_pixel);
-	if ((current_var.xres != current_var.xres_virtual) ||
-	    (current_var.yres != current_var.yres_virtual))
-	   printk("   virtual %dx%d\n",
-			  current_var.xres_virtual, current_var.yres_virtual);
-
-	if (register_framebuffer(&fb_info) < 0)
-		return -EINVAL;
-
-	// FIXME: mode needs setting!
-	//printk("fb%d: %s frame buffer device, using %dK of video memory\n",
-	//       fb_info.node, fb_info.mode->name, screen_len>>10);
-	printk("fb%d: frame buffer device, using %dK of video memory\n",
-	       fb_info.node, screen_len>>10);
-
-	/* TODO: This driver cannot be unloaded yet */
-	return 0;
-}
-
-
 #ifdef ATAFB_EXT
 static void __init atafb_setup_ext(char *spec)
 {
@@ -3484,6 +3295,173 @@ int __init atafb_setup( char *options )
     return 0;
 }
 
+
+int __init atafb_init(void)
+{
+	int pad;
+	int detected_mode;
+	unsigned int defmode = 0;
+	unsigned long mem_req;
+
+#ifndef MODULE
+	char *option = NULL;
+
+	if (fb_get_options("atafb", &option)) {
+		return -ENODEV;
+	}
+	atafb_setup(option);
+#endif
+	printk("atafb_init: start\n");
+
+	if (!MACH_IS_ATARI)
+	        return -ENXIO;
+
+	do {
+#ifdef ATAFB_EXT
+		if (external_addr) {
+			printk("atafb_init: initializing external hw\n");
+			fbhw = &ext_switch;
+			atafb_ops.fb_setcolreg = &ext_setcolreg;
+			defmode = DEFMODE_EXT;
+			break;
+		}
+#endif
+#ifdef ATAFB_TT
+		if (ATARIHW_PRESENT(TT_SHIFTER)) {
+			printk("atafb_init: initializing TT hw\n");
+			fbhw = &tt_switch;
+			atafb_ops.fb_setcolreg = &tt_setcolreg;
+			defmode = DEFMODE_TT;
+			break;
+		}
+#endif
+#ifdef ATAFB_FALCON
+		if (ATARIHW_PRESENT(VIDEL_SHIFTER)) {
+			printk("atafb_init: initializing Falcon hw\n");
+			fbhw = &falcon_switch;
+			atafb_ops.fb_setcolreg = &falcon_setcolreg;
+			request_irq(IRQ_AUTO_4, falcon_vbl_switcher, IRQ_TYPE_PRIO,
+			            "framebuffer/modeswitch", falcon_vbl_switcher);
+			defmode = DEFMODE_F30;
+			break;
+		}
+#endif
+#ifdef ATAFB_STE
+		if (ATARIHW_PRESENT(STND_SHIFTER) ||
+		    ATARIHW_PRESENT(EXTD_SHIFTER)) {
+			printk("atafb_init: initializing ST/E hw\n");
+			fbhw = &st_switch;
+			atafb_ops.fb_setcolreg = &stste_setcolreg;
+			defmode = DEFMODE_STE;
+			break;
+		}
+		fbhw = &st_switch;
+		atafb_ops.fb_setcolreg = &stste_setcolreg;
+		printk("Cannot determine video hardware; defaulting to ST(e)\n");
+#else /* ATAFB_STE */
+		/* no default driver included */
+		/* Nobody will ever see this message :-) */
+		panic("Cannot initialize video hardware");
+#endif
+	} while (0);
+
+	/* Multisync monitor capabilities */
+	/* Atari-TOS defaults if no boot option present */
+	if (fb_info.monspecs.hfmin == 0) {
+	    fb_info.monspecs.hfmin = 31000;
+	    fb_info.monspecs.hfmax = 32000;
+	    fb_info.monspecs.vfmin = 58;
+	    fb_info.monspecs.vfmax = 62;
+	}
+
+	detected_mode = fbhw->detect();
+	check_default_par(detected_mode);
+#ifdef ATAFB_EXT
+	if (!external_addr) {
+#endif /* ATAFB_EXT */
+		mem_req = default_mem_req + ovsc_offset + ovsc_addlen;
+		mem_req = PAGE_ALIGN(mem_req) + PAGE_SIZE;
+		screen_base = atari_stram_alloc(mem_req, "atafb");
+		if (!screen_base)
+			panic("Cannot allocate screen memory");
+		memset(screen_base, 0, mem_req);
+		pad = -(unsigned long)screen_base & (PAGE_SIZE-1);
+		screen_base+=pad;
+		real_screen_base=screen_base+ovsc_offset;
+		screen_len = (mem_req - pad - ovsc_offset) & PAGE_MASK;
+		st_ovsc_switch();
+		if (CPU_IS_040_OR_060) {
+			/* On a '040+, the cache mode of video RAM must be set to
+			 * write-through also for internal video hardware! */
+			cache_push(virt_to_phys(screen_base), screen_len);
+			kernel_set_cachemode(screen_base, screen_len,
+					     IOMAP_WRITETHROUGH);
+		}
+		printk("atafb: screen_base %p real_screen_base %p screen_len %d\n",
+			screen_base, real_screen_base, screen_len);
+#ifdef ATAFB_EXT
+	}
+	else {
+		/* Map the video memory (physical address given) to somewhere
+		 * in the kernel address space.
+		 */
+		external_addr =
+		  ioremap_writethrough((unsigned long)external_addr,
+				       external_len);
+		if (external_vgaiobase)
+			external_vgaiobase =
+			  (unsigned long)ioremap(external_vgaiobase, 0x10000);
+		screen_base      =
+		real_screen_base = external_addr;
+		screen_len       = external_len & PAGE_MASK;
+		memset (screen_base, 0, external_len);
+	}
+#endif /* ATAFB_EXT */
+
+//	strcpy(fb_info.mode->name, "Atari Builtin ");
+	fb_info.fbops = &atafb_ops;
+	// try to set default (detected; requested) var
+	do_fb_set_var(&atafb_predefined[default_par-1], 1);
+	// reads hw state into current par, which may not be sane yet
+	ata_get_par(&current_par);
+	fb_info.par = &current_par;
+	// tries to read from HW which may not be initialized yet
+	// so set sane var first, then call atafb_set_par
+	atafb_get_var(&current_var, &fb_info);
+	fb_info.var = current_var;
+	fb_info.flags = FBINFO_FLAG_DEFAULT;
+
+	if (!fb_find_mode(&fb_info.var, &fb_info, mode_option, atafb_modedb,
+			  NUM_TOTAL_MODES, &atafb_modedb[defmode],
+			  current_var.bits_per_pixel)) {
+		return -EINVAL;
+	}
+
+// 	strcat(fb_info.mode->name, fb_var_names[default_par-1][0]);
+
+	atafb_set_disp(&fb_info);
+
+	fb_alloc_cmap(&(fb_info.cmap), 1<<fb_info.var.bits_per_pixel, 0);
+
+	printk("Determined %dx%d, depth %d\n",
+	       fb_info.var.xres, fb_info.var.yres, fb_info.var.bits_per_pixel);
+	if ((current_var.xres != current_var.xres_virtual) ||
+	    (current_var.yres != current_var.yres_virtual))
+	   printk("   virtual %dx%d\n",
+			  current_var.xres_virtual, current_var.yres_virtual);
+
+	if (register_framebuffer(&fb_info) < 0)
+		return -EINVAL;
+
+	// FIXME: mode needs setting!
+	//printk("fb%d: %s frame buffer device, using %dK of video memory\n",
+	//       fb_info.node, fb_info.mode->name, screen_len>>10);
+	printk("fb%d: frame buffer device, using %dK of video memory\n",
+	       fb_info.node, screen_len>>10);
+
+	/* TODO: This driver cannot be unloaded yet */
+	return 0;
+}
 module_init(atafb_init);
 
 #ifdef MODULE
--- linux-m68k-2.6.19.orig/drivers/video/atafb_iplan2p2.c
+++ linux-m68k-2.6.19/drivers/video/atafb_iplan2p2.c
@@ -307,14 +307,10 @@ void atafb_iplan2p2_linefill(struct fb_i
                              const u8 *data, u32 bgcolor, u32 fgcolor)
 {
     u8 *dest;
-    u8 *cdat;
     int rows;
     int bytes = next_line;
     u16 eorx, fgx, bgx, fdx;
 
-    // source data
-    cdat = data;
-
     // advance from odd to even (dx>>3) by 3: 0 1 4 5 .... 
     // dest = (p->screen_base + yy * p->next_line + (xx>>1)*4 + (xx & 1));
     dest = (u8*) info->screen_base + dy * bytes + (dx>>4)*4 + ((dx>>3)&1);
@@ -324,7 +320,7 @@ void atafb_iplan2p2_linefill(struct fb_i
     eorx = fgx ^ bgx;
 
       for(rows = width/8; rows-- ;) {
-	fdx = dup2w(*cdat++);
+	fdx = dup2w(*data++);
 	movepw(dest, (fdx & eorx) ^ bgx);
 	INC_2P(dest);
       }
--- linux-m68k-2.6.19.orig/drivers/video/atafb_iplan2p4.c
+++ linux-m68k-2.6.19/drivers/video/atafb_iplan2p4.c
@@ -314,14 +314,10 @@ void atafb_iplan2p4_linefill(struct fb_i
                              const u8 *data, u32 bgcolor, u32 fgcolor)
 {
     u8 *dest;
-    u8 *cdat;
     int rows;
     int bytes = next_line;
     u32 eorx, fgx, bgx, fdx;
 
-    // source data
-    cdat = data;
-
     // advance from odd to even dx by 7: 0 1 8 9 ...
     // dest = (p->screen_base + yy * bytes + (xx>>1)*8 + (xx & 1));
 
@@ -332,7 +328,7 @@ void atafb_iplan2p4_linefill(struct fb_i
     eorx = fgx ^ bgx;
 
       for(rows = width/8; rows-- ;) {
-	fdx = dup4l(*cdat++);
+	fdx = dup4l(*data++);
 	movepl(dest, (fdx & eorx) ^ bgx);
 	INC_4P(dest);
       }
--- linux-m68k-2.6.19.orig/drivers/video/atafb_iplan2p4.h
+++ linux-m68k-2.6.19/drivers/video/atafb_iplan2p4.h
@@ -1,5 +1,5 @@
 /*
- *  FBcon low-level driver for Atari interleaved bitplanes (8 planes) (iplan2p8)
+ *  FBcon low-level driver for Atari interleaved bitplanes (4 planes) (iplan2p4)
  */
 
 #ifndef _VIDEO_FBCON_IPLAN2P4_H
--- linux-m68k-2.6.19.orig/drivers/video/atafb_iplan2p8.c
+++ linux-m68k-2.6.19/drivers/video/atafb_iplan2p8.c
@@ -349,14 +349,10 @@ void atafb_iplan2p8_linefill(struct fb_i
                              const u8 *data, u32 bgcolor, u32 fgcolor)
 {
     u8 *dest;
-    u8 *cdat;
     int rows;
     int bytes = next_line;
     u32 eorx1, eorx2, fgx1, fgx2, bgx1, bgx2, fdx;
 
-    // source data
-    cdat = data;
-
     // advance from odd to even (dx>>3) by 16
     // dest = (p->screen_base + yy * bytes + (xx>>1)*16 + (xx & 1));
 
@@ -368,7 +364,7 @@ void atafb_iplan2p8_linefill(struct fb_i
     eorx1 = fgx1 ^ bgx1; eorx2  = fgx2 ^ bgx2;
 
       for(rows = width/8; rows-- ;) {
-	fdx = dup4l(*cdat++);
+	fdx = dup4l(*data++);
 	movepl2(dest, (fdx & eorx1) ^ bgx1, (fdx & eorx2) ^ bgx2);
 	INC_8P(dest);
       }
--- linux-m68k-2.6.19.orig/drivers/video/atafb_mfb.c
+++ linux-m68k-2.6.19/drivers/video/atafb_mfb.c
@@ -80,16 +80,12 @@ void atafb_mfb_linefill(struct fb_info *
                         int dy, int dx, u32 width,
                         const u8 *data, u32 bgcolor, u32 fgcolor)
 {
-    u8 *dest, *cdat;
-    u_int rows;
-    u8 d;
-
-    dest = (u8*) info->screen_base+dy*next_line+(dx>>3) + (dx & 1);
-    cdat = data;
+    u8 *dest = (u8*) info->screen_base+dy*next_line+(dx>>3) + (dx & 1);
+    unsigned int rows;
 
     for (rows = width/8; rows--; /* check margins */ ) {
         // use fast_memmove or fb_memmove
-	*dest++ = *cdat++;
+	*dest++ = *data++;
     }
 }
 

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
-
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Video for Linux]     [Yosemite News]     [Linux S/390]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux