Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  *  linux/drivers/video/68328fb.c -- Low level implementation of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *                                   mc68x328 LCD frame buffer device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *	Copyright (C) 2003 Georges Menie
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  This driver assumes an already configured controller (e.g. from config.c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  Keep the code clean of board specific initialization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *  This code has not been tested with colors, colormap management functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *  are minimal (no colormap data written to the 68328 registers...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *  initial version of this driver:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *    Copyright (C) 1998,1999 Kenneth Albanowski <kjahds@kjahds.com>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *                            The Silver Hammer Group, Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *  this version is based on :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *  linux/drivers/video/vfb.c -- Virtual frame buffer device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *      Copyright (C) 2002 James Simmons
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *	Copyright (C) 1997 Geert Uytterhoeven
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *  This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *  License. See the file COPYING in the main directory of this archive for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *  more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <linux/fb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #if defined(CONFIG_M68VZ328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #include <asm/MC68VZ328.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #elif defined(CONFIG_M68EZ328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #include <asm/MC68EZ328.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #elif defined(CONFIG_M68328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #include <asm/MC68328.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #error wrong architecture for the MC68x328 frame buffer device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) static u_long videomemory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static u_long videomemorysize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) static struct fb_info fb_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) static u32 mc68x328fb_pseudo_palette[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) static struct fb_var_screeninfo mc68x328fb_default __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	.red =		{ 0, 8, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)       	.green =	{ 0, 8, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)       	.blue =		{ 0, 8, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)       	.activate =	FB_ACTIVATE_TEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)       	.height =	-1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)       	.width =	-1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)       	.pixclock =	20000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)       	.left_margin =	64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)       	.right_margin =	64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)       	.upper_margin =	32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)       	.lower_margin =	32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)       	.hsync_len =	64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)       	.vsync_len =	2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)       	.vmode =	FB_VMODE_NONINTERLACED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static const struct fb_fix_screeninfo mc68x328fb_fix __initconst = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	.id =		"68328fb",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	.type =		FB_TYPE_PACKED_PIXELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	.xpanstep =	1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	.ypanstep =	1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	.ywrapstep =	1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	.accel =	FB_ACCEL_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)     /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)      *  Interface used by the world
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) int mc68x328fb_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) int mc68x328fb_setup(char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) static int mc68x328fb_check_var(struct fb_var_screeninfo *var,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			 struct fb_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) static int mc68x328fb_set_par(struct fb_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) static int mc68x328fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			 u_int transp, struct fb_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) static int mc68x328fb_pan_display(struct fb_var_screeninfo *var,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			   struct fb_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static int mc68x328fb_mmap(struct fb_info *info, struct vm_area_struct *vma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) static const struct fb_ops mc68x328fb_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	.fb_check_var	= mc68x328fb_check_var,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	.fb_set_par	= mc68x328fb_set_par,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	.fb_setcolreg	= mc68x328fb_setcolreg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	.fb_pan_display	= mc68x328fb_pan_display,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	.fb_fillrect	= cfb_fillrect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	.fb_copyarea	= cfb_copyarea,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	.fb_imageblit	= cfb_imageblit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	.fb_mmap	= mc68x328fb_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)     /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)      *  Internal routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static u_long get_line_length(int xres_virtual, int bpp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	u_long length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	length = xres_virtual * bpp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	length = (length + 31) & ~31;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	length >>= 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	return (length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)     /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)      *  Setting the video mode has been split into two parts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)      *  First part, xxxfb_check_var, must not write anything
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)      *  to hardware, it should only verify and adjust var.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)      *  This means it doesn't alter par but it does use hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)      *  data from it to check this var. 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static int mc68x328fb_check_var(struct fb_var_screeninfo *var,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 			 struct fb_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	u_long line_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	 *  FB_VMODE_CONUPDATE and FB_VMODE_SMOOTH_XPAN are equal!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	 *  as FB_VMODE_SMOOTH_XPAN is only used internally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	if (var->vmode & FB_VMODE_CONUPDATE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		var->vmode |= FB_VMODE_YWRAP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		var->xoffset = info->var.xoffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		var->yoffset = info->var.yoffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	 *  Some very basic checks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (!var->xres)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		var->xres = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	if (!var->yres)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		var->yres = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	if (var->xres > var->xres_virtual)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		var->xres_virtual = var->xres;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	if (var->yres > var->yres_virtual)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		var->yres_virtual = var->yres;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	if (var->bits_per_pixel <= 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		var->bits_per_pixel = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	else if (var->bits_per_pixel <= 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		var->bits_per_pixel = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	else if (var->bits_per_pixel <= 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		var->bits_per_pixel = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	else if (var->bits_per_pixel <= 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		var->bits_per_pixel = 24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	else if (var->bits_per_pixel <= 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		var->bits_per_pixel = 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	if (var->xres_virtual < var->xoffset + var->xres)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		var->xres_virtual = var->xoffset + var->xres;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	if (var->yres_virtual < var->yoffset + var->yres)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		var->yres_virtual = var->yoffset + var->yres;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	 *  Memory limit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	line_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	    get_line_length(var->xres_virtual, var->bits_per_pixel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	if (line_length * var->yres_virtual > videomemorysize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	 * Now that we checked it we alter var. The reason being is that the video
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	 * mode passed in might not work but slight changes to it might make it 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	 * work. This way we let the user know what is acceptable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	switch (var->bits_per_pixel) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		var->red.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		var->red.length = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		var->green.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		var->green.length = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		var->blue.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		var->blue.length = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		var->transp.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		var->transp.length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	case 8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		var->red.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		var->red.length = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		var->green.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		var->green.length = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		var->blue.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		var->blue.length = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		var->transp.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		var->transp.length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	case 16:		/* RGBA 5551 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		if (var->transp.length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 			var->red.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 			var->red.length = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 			var->green.offset = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 			var->green.length = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 			var->blue.offset = 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 			var->blue.length = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			var->transp.offset = 15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			var->transp.length = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		} else {	/* RGB 565 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 			var->red.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 			var->red.length = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			var->green.offset = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 			var->green.length = 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 			var->blue.offset = 11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 			var->blue.length = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 			var->transp.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 			var->transp.length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	case 24:		/* RGB 888 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		var->red.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		var->red.length = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		var->green.offset = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		var->green.length = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		var->blue.offset = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		var->blue.length = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		var->transp.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		var->transp.length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	case 32:		/* RGBA 8888 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		var->red.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		var->red.length = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		var->green.offset = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		var->green.length = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		var->blue.offset = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		var->blue.length = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		var->transp.offset = 24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		var->transp.length = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	var->red.msb_right = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	var->green.msb_right = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	var->blue.msb_right = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	var->transp.msb_right = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) /* This routine actually sets the video mode. It's in here where we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)  * the hardware state info->par and fix which can be affected by the 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)  * change in par. For this driver it doesn't do much. 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) static int mc68x328fb_set_par(struct fb_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	info->fix.line_length = get_line_length(info->var.xres_virtual,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 						info->var.bits_per_pixel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)     /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)      *  Set a single color register. The values supplied are already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)      *  rounded down to the hardware's capabilities (according to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)      *  entries in the var structure). Return != 0 for invalid regno.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) static int mc68x328fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 			 u_int transp, struct fb_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	if (regno >= 256)	/* no. of hw registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	 * Program hardware... do anything you want with transp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	/* grayscale works only partially under directcolor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	if (info->var.grayscale) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		/* grayscale = 0.30*R + 0.59*G + 0.11*B */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		red = green = blue =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		    (red * 77 + green * 151 + blue * 28) >> 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	/* Directcolor:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	 *   var->{color}.offset contains start of bitfield
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	 *   var->{color}.length contains length of bitfield
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	 *   {hardwarespecific} contains width of RAMDAC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	 *   cmap[X] is programmed to (X << red.offset) | (X << green.offset) | (X << blue.offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	 *   RAMDAC[X] is programmed to (red, green, blue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	 * 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	 * Pseudocolor:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	 *    uses offset = 0 && length = RAMDAC register width.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	 *    var->{color}.offset is 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	 *    var->{color}.length contains width of DAC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	 *    cmap is not used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	 *    RAMDAC[X] is programmed to (red, green, blue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	 * Truecolor:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	 *    does not use DAC. Usually 3 are present.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	 *    var->{color}.offset contains start of bitfield
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	 *    var->{color}.length contains length of bitfield
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	 *    cmap is programmed to (red << red.offset) | (green << green.offset) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	 *                      (blue << blue.offset) | (transp << transp.offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	 *    RAMDAC does not exist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) #define CNVT_TOHW(val,width) ((((val)<<(width))+0x7FFF-(val))>>16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	switch (info->fix.visual) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	case FB_VISUAL_TRUECOLOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	case FB_VISUAL_PSEUDOCOLOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 		red = CNVT_TOHW(red, info->var.red.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		green = CNVT_TOHW(green, info->var.green.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		blue = CNVT_TOHW(blue, info->var.blue.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		transp = CNVT_TOHW(transp, info->var.transp.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	case FB_VISUAL_DIRECTCOLOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		red = CNVT_TOHW(red, 8);	/* expect 8 bit DAC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		green = CNVT_TOHW(green, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		blue = CNVT_TOHW(blue, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 		/* hey, there is bug in transp handling... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		transp = CNVT_TOHW(transp, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) #undef CNVT_TOHW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	/* Truecolor has hardware independent palette */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		u32 v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		if (regno >= 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		v = (red << info->var.red.offset) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		    (green << info->var.green.offset) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		    (blue << info->var.blue.offset) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		    (transp << info->var.transp.offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		switch (info->var.bits_per_pixel) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 		case 8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		case 16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 			((u32 *) (info->pseudo_palette))[regno] = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		case 24:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		case 32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 			((u32 *) (info->pseudo_palette))[regno] = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)     /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)      *  Pan or Wrap the Display
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)      *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)      *  This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) static int mc68x328fb_pan_display(struct fb_var_screeninfo *var,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 			   struct fb_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	if (var->vmode & FB_VMODE_YWRAP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		if (var->yoffset < 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		    || var->yoffset >= info->var.yres_virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		    || var->xoffset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		if (var->xoffset + info->var.xres > info->var.xres_virtual ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		    var->yoffset + info->var.yres > info->var.yres_virtual)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	info->var.xoffset = var->xoffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	info->var.yoffset = var->yoffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	if (var->vmode & FB_VMODE_YWRAP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		info->var.vmode |= FB_VMODE_YWRAP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		info->var.vmode &= ~FB_VMODE_YWRAP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)     /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)      *  Most drivers don't need their own mmap function 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) static int mc68x328fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) #ifndef MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	/* this is uClinux (no MMU) specific code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	vma->vm_start = videomemory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) int __init mc68x328fb_setup(char *options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	if (!options || !*options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)     /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)      *  Initialisation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) int __init mc68x328fb_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) #ifndef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	char *option = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	if (fb_get_options("68328fb", &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	mc68x328fb_setup(option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	 *  initialize the default mode from the LCD controller registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	mc68x328fb_default.xres = LXMAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	mc68x328fb_default.yres = LYMAX+1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	mc68x328fb_default.xres_virtual = mc68x328fb_default.xres;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	mc68x328fb_default.yres_virtual = mc68x328fb_default.yres;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	mc68x328fb_default.bits_per_pixel = 1 + (LPICF & 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	videomemory = LSSA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	videomemorysize = (mc68x328fb_default.xres_virtual+7) / 8 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		mc68x328fb_default.yres_virtual * mc68x328fb_default.bits_per_pixel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	fb_info.screen_base = (void *)videomemory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	fb_info.fbops = &mc68x328fb_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	fb_info.var = mc68x328fb_default;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	fb_info.fix = mc68x328fb_fix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	fb_info.fix.smem_start = videomemory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	fb_info.fix.smem_len = videomemorysize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	fb_info.fix.line_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		get_line_length(mc68x328fb_default.xres_virtual, mc68x328fb_default.bits_per_pixel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	fb_info.fix.visual = (mc68x328fb_default.bits_per_pixel) == 1 ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 		FB_VISUAL_MONO10 : FB_VISUAL_PSEUDOCOLOR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	if (fb_info.var.bits_per_pixel == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 		fb_info.var.red.length = fb_info.var.green.length = fb_info.var.blue.length = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 		fb_info.var.red.offset = fb_info.var.green.offset = fb_info.var.blue.offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	fb_info.pseudo_palette = &mc68x328fb_pseudo_palette;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	fb_info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	if (fb_alloc_cmap(&fb_info.cmap, 256, 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	if (register_framebuffer(&fb_info) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		fb_dealloc_cmap(&fb_info.cmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	fb_info(&fb_info, "%s frame buffer device\n", fb_info.fix.id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	fb_info(&fb_info, "%dx%dx%d at 0x%08lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 		mc68x328fb_default.xres_virtual,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 		mc68x328fb_default.yres_virtual,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		1 << mc68x328fb_default.bits_per_pixel, videomemory);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) module_init(mc68x328fb_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) #ifdef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) static void __exit mc68x328fb_cleanup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	unregister_framebuffer(&fb_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	fb_dealloc_cmap(&fb_info.cmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) module_exit(mc68x328fb_cleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) #endif				/* MODULE */