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/fm2fb.c -- BSC FrameMaster II/Rainbow II frame buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *				   device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *	Copyright (C) 1998 Steffen A. Mork (linux-dev@morknet.de)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *	Copyright (C) 1999 Geert Uytterhoeven
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  Written for 2.0.x by Steffen A. Mork
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *  Ported to 2.1.x by Geert Uytterhoeven
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *  Ported to new api by James Simmons
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *  This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *  License. See the file COPYING in the main directory of this archive for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *  more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/fb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/zorro.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *	Some technical notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *	The BSC FrameMaster II (or Rainbow II) is a simple very dumb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *	frame buffer which allows to display 24 bit true color images.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *	Each pixel is 32 bit width so it's very easy to maintain the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *	frame buffer. One long word has the following layout:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *	AARRGGBB which means: AA the alpha channel byte, RR the red
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *	channel, GG the green channel and BB the blue channel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *	The FrameMaster II supports the following video modes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *	- PAL/NTSC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *	- interlaced/non interlaced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *	- composite sync/sync/sync over green
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *	The resolution is to the following both ones:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *	- 768x576 (PAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *	- 768x480 (NTSC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  *	This means that pixel access per line is fixed due to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  *	fixed line width. In case of maximal resolution the frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  *	buffer needs an amount of memory of 1.769.472 bytes which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  *	is near to 2 MByte (the allocated address space of Zorro2).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  *	The memory is channel interleaved. That means every channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  *	owns four VRAMs. Unfortunately most FrameMasters II are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  *	not assembled with memory for the alpha channel. In this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  *	case it could be possible to add the frame buffer into the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  *	normal memory pool.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  *	At relative address 0x1ffff8 of the frame buffers base address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  *	there exists a control register with the number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  *	four control bits. They have the following meaning:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  *	bit value meaning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  *	 0    1   0=interlaced/1=non interlaced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  *	 1    2   0=video out disabled/1=video out enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  *	 2    4   0=normal mode as jumpered via JP8/1=complement mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  *	 3    8   0=read  onboard ROM/1 normal operation (required)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  *	As mentioned above there are several jumper. I think there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  *	is not very much information about the FrameMaster II in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  *	the world so I add these information for completeness.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  *	JP1  interlace selection (1-2 non interlaced/2-3 interlaced)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  *	JP2  wait state creation (leave as is!)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  *	JP3  wait state creation (leave as is!)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *	JP4  modulate composite sync on green output (1-2 composite
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *	     sync on green channel/2-3 normal composite sync)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  *	JP5  create test signal, shorting this jumper will create
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  *	     a white screen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  *	JP6  sync creation (1-2 composite sync/2-3 H-sync output)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *	JP8  video mode (1-2 PAL/2-3 NTSC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  *	With the following jumpering table you can connect the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  *	FrameMaster II to a normal TV via SCART connector:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  *	JP1:  2-3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  *	JP4:  2-3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  *	JP6:  2-3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  *	JP8:  1-2 (means PAL for Europe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  *	NOTE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  *	There is no other possibility to change the video timings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  *	except the interlaced/non interlaced, sync control and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  *	video mode PAL (50 Hz)/NTSC (60 Hz). Inside this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  *	FrameMaster II driver are assumed values to avoid anomalies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  *	to a future X server. Except the pixel clock is really
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  *	constant at 30 MHz.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  *	9 pin female video connector:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  *	1  analog red 0.7 Vss
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  *	2  analog green 0.7 Vss
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)  *	3  analog blue 0.7 Vss
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  *	4  H-sync TTL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  *	5  V-sync TTL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  *	6  ground
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  *	7  ground
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  *	8  ground
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  *	9  ground
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  *	Some performance notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  *	The FrameMaster II was not designed to display a console
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  *	this driver would do! It was designed to display still true
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  *	color images. Imagine: When scroll up a text line there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  *	must copied ca. 1.7 MBytes to another place inside this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  *	frame buffer. This means 1.7 MByte read and 1.7 MByte write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  *	over the slow 16 bit wide Zorro2 bus! A scroll of one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  *	line needs 1 second so do not expect to much from this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  *	driver - he is at the limit!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  *	definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define FRAMEMASTER_SIZE	0x200000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #define FRAMEMASTER_REG		0x1ffff8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define FRAMEMASTER_NOLACE	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define FRAMEMASTER_ENABLE	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define FRAMEMASTER_COMPL	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define FRAMEMASTER_ROM		8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) static volatile unsigned char *fm2fb_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static struct fb_fix_screeninfo fb_fix = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	.smem_len =	FRAMEMASTER_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	.type =		FB_TYPE_PACKED_PIXELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	.visual =	FB_VISUAL_TRUECOLOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	.line_length =	(768 << 2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	.mmio_len =	(8),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	.accel =	FB_ACCEL_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) static int fm2fb_mode = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #define FM2FB_MODE_PAL	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #define FM2FB_MODE_NTSC	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static struct fb_var_screeninfo fb_var_modes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)     {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	/* 768 x 576, 32 bpp (PAL) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	768, 576, 768, 576, 0, 0, 32, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	{ 16, 8, 0 }, { 8, 8, 0 }, { 0, 8, 0 }, { 24, 8, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	0, FB_ACTIVATE_NOW, -1, -1, FB_ACCEL_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	33333, 10, 102, 10, 5, 80, 34, FB_SYNC_COMP_HIGH_ACT, 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)     }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	/* 768 x 480, 32 bpp (NTSC - not supported yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	768, 480, 768, 480, 0, 0, 32, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	{ 16, 8, 0 }, { 8, 8, 0 }, { 0, 8, 0 }, { 24, 8, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	0, FB_ACTIVATE_NOW, -1, -1, FB_ACCEL_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	33333, 10, 102, 10, 5, 80, 34, FB_SYNC_COMP_HIGH_ACT, 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)     /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)      *  Interface used by the world
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static int fm2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)                            u_int transp, struct fb_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static int fm2fb_blank(int blank, struct fb_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static const struct fb_ops fm2fb_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	.owner		= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	.fb_setcolreg	= fm2fb_setcolreg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	.fb_blank	= fm2fb_blank,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	.fb_fillrect	= cfb_fillrect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	.fb_copyarea	= cfb_copyarea,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	.fb_imageblit	= cfb_imageblit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) };
^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)      *  Blank the display.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) static int fm2fb_blank(int blank, struct fb_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	unsigned char t = FRAMEMASTER_ROM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	if (!blank)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		t |= FRAMEMASTER_ENABLE | FRAMEMASTER_NOLACE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	fm2fb_reg[0] = t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)     /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)      *  Set a single color register. The values supplied are already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)      *  rounded down to the hardware's capabilities (according to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)      *  entries in the var structure). Return != 0 for invalid regno.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) static int fm2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)                          u_int transp, struct fb_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	if (regno < 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		red >>= 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		green >>= 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		blue >>= 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		((u32*)(info->pseudo_palette))[regno] = (red << 16) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			(green << 8) | blue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)     /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)      *  Initialisation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) static int fm2fb_probe(struct zorro_dev *z, const struct zorro_device_id *id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) static const struct zorro_device_id fm2fb_devices[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	{ ZORRO_PROD_BSC_FRAMEMASTER_II },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	{ ZORRO_PROD_HELFRICH_RAINBOW_II },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	{ 0 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) MODULE_DEVICE_TABLE(zorro, fm2fb_devices);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) static struct zorro_driver fm2fb_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	.name		= "fm2fb",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	.id_table	= fm2fb_devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	.probe		= fm2fb_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) static int fm2fb_probe(struct zorro_dev *z, const struct zorro_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	struct fb_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	unsigned long *ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	int is_fm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	int x, y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	is_fm = z->id == ZORRO_PROD_BSC_FRAMEMASTER_II;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	if (!zorro_request_device(z,"fm2fb"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	info = framebuffer_alloc(16 * sizeof(u32), &z->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	if (!info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		zorro_release_device(z);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		framebuffer_release(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		zorro_release_device(z);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	/* assigning memory to kernel space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	fb_fix.smem_start = zorro_resource_start(z);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	info->screen_base = ioremap(fb_fix.smem_start, FRAMEMASTER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	fb_fix.mmio_start = fb_fix.smem_start + FRAMEMASTER_REG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	fm2fb_reg  = (unsigned char *)(info->screen_base+FRAMEMASTER_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	strcpy(fb_fix.id, is_fm ? "FrameMaster II" : "Rainbow II");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	/* make EBU color bars on display */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	ptr = (unsigned long *)fb_fix.smem_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	for (y = 0; y < 576; y++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		for (x = 0; x < 96; x++) *ptr++ = 0xffffff;/* white */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		for (x = 0; x < 96; x++) *ptr++ = 0xffff00;/* yellow */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		for (x = 0; x < 96; x++) *ptr++ = 0x00ffff;/* cyan */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		for (x = 0; x < 96; x++) *ptr++ = 0x00ff00;/* green */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		for (x = 0; x < 96; x++) *ptr++ = 0xff00ff;/* magenta */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		for (x = 0; x < 96; x++) *ptr++ = 0xff0000;/* red */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		for (x = 0; x < 96; x++) *ptr++ = 0x0000ff;/* blue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		for (x = 0; x < 96; x++) *ptr++ = 0x000000;/* black */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	fm2fb_blank(0, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	if (fm2fb_mode == -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		fm2fb_mode = FM2FB_MODE_PAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	info->fbops = &fm2fb_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	info->var = fb_var_modes[fm2fb_mode];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	info->pseudo_palette = info->par;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	info->par = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	info->fix = fb_fix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	info->flags = FBINFO_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	if (register_framebuffer(info) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		fb_dealloc_cmap(&info->cmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		iounmap(info->screen_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		framebuffer_release(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		zorro_release_device(z);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	fb_info(info, "%s frame buffer device\n", fb_fix.id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) int __init fm2fb_setup(char *options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	char *this_opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	if (!options || !*options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	while ((this_opt = strsep(&options, ",")) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		if (!strncmp(this_opt, "pal", 3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 			fm2fb_mode = FM2FB_MODE_PAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		else if (!strncmp(this_opt, "ntsc", 4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 			fm2fb_mode = FM2FB_MODE_NTSC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) int __init fm2fb_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	char *option = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	if (fb_get_options("fm2fb", &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	fm2fb_setup(option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	return zorro_register_driver(&fm2fb_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) module_init(fm2fb_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) MODULE_LICENSE("GPL");