Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
67bf3c24
Commit
67bf3c24
authored
Mar 02, 2003
by
David S. Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FRAMEBUFFER]: Convert cg14 driver to new APIs.
parent
57b55f79
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
606 additions
and
3 deletions
+606
-3
drivers/video/Kconfig
drivers/video/Kconfig
+2
-2
drivers/video/Makefile
drivers/video/Makefile
+2
-1
drivers/video/cg14.c
drivers/video/cg14.c
+597
-0
drivers/video/fbmem.c
drivers/video/fbmem.c
+5
-0
No files found.
drivers/video/Kconfig
View file @
67bf3c24
...
...
@@ -823,9 +823,9 @@ config FB_TCX
This is the frame buffer device driver for the TCX 24/8bit frame
buffer.
config FB_CG
FOURTEEN
config FB_CG
14
bool "CGfourteen (SX) support"
depends on FB_SBUS
&& SPARC32
depends on FB_SBUS
help
This is the frame buffer device driver for the CGfourteen frame
buffer on Desktop SPARCsystems with the SX graphics option.
...
...
drivers/video/Makefile
View file @
67bf3c24
...
...
@@ -72,7 +72,6 @@ obj-$(CONFIG_FB_VOODOO1) += sstfb.o cfbfillrect.o cfbcopyarea.o cfbimgb
# One by one these are being converted over to the new APIs
#obj-$(CONFIG_FB_TCX) += tcxfb.o sbusfb.o
#obj-$(CONFIG_FB_CGFOURTEEN) += cgfourteenfb.o sbusfb.o
#obj-$(CONFIG_FB_P9100) += p9100fb.o sbusfb.o
#obj-$(CONFIG_FB_LEO) += leofb.o sbusfb.o
...
...
@@ -82,6 +81,8 @@ obj-$(CONFIG_FB_CG3) += cg3.o sbuslib.o cfbimgblt.o cfbcopyarea.o
cfbfillrect.o
obj-$(CONFIG_FB_BW2)
+=
bw2.o sbuslib.o cfbimgblt.o cfbcopyarea.o
\
cfbfillrect.o
obj-$(CONFIG_FB_CG14)
+=
cg14.o sbuslib.o cfbimgblt.o cfbcopyarea.o
\
cfbfillrect.o
# Files generated that shall be removed upon make clean
clean-files
:=
promcon_tbl.c
...
...
drivers/video/cg
fourteenfb
.c
→
drivers/video/cg
14
.c
View file @
67bf3c24
/* $Id: cgfourteenfb.c,v 1.11 2001/09/19 00:04:33 davem Exp $
* cgfourteenfb.c: CGfourteen frame buffer driver
/* cg14.c: CGFOURTEEN frame buffer driver
*
* Copyright (C) 2003 David S. Miller (davem@redhat.com)
* Copyright (C) 1996,1998 Jakub Jelinek (jj@ultra.linux.cz)
* Copyright (C) 1995 Miguel de Icaza (miguel@nuclecu.unam.mx)
*
* Driver layout based loosely on tgafb.c, see that file for credits.
*/
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/tty.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/fb.h>
#include <linux/init.h>
#include <linux/selection.h>
#include <linux/fb.h>
#include <linux/mm.h>
#include <video/sbusfb.h>
#include <asm/io.h>
#include <asm/pgtable.h>
#include <asm/uaccess.h>
#include <asm/sbus.h>
#include <asm/oplib.h>
#include <asm/fbio.h>
#include "sbuslib.h"
/*
* Local functions.
*/
static
int
cg14_check_var
(
struct
fb_var_screeninfo
*
,
struct
fb_info
*
);
static
int
cg14_set_par
(
struct
fb_info
*
);
static
int
cg14_setcolreg
(
unsigned
,
unsigned
,
unsigned
,
unsigned
,
unsigned
,
struct
fb_info
*
);
#include <video/fbcon-cfb8.h>
static
int
cg14_mmap
(
struct
fb_info
*
,
struct
file
*
,
struct
vm_area_struct
*
);
static
int
cg14_ioctl
(
struct
inode
*
,
struct
file
*
,
unsigned
int
,
unsigned
long
,
struct
fb_info
*
);
/*
* Frame buffer operations
*/
static
struct
fb_ops
cg14_ops
=
{
.
owner
=
THIS_MODULE
,
.
fb_check_var
=
cg14_check_var
,
.
fb_set_par
=
cg14_set_par
,
.
fb_setcolreg
=
cg14_setcolreg
,
.
fb_fillrect
=
cfb_fillrect
,
.
fb_copyarea
=
cfb_copyarea
,
.
fb_imageblit
=
cfb_imageblit
,
.
fb_mmap
=
cg14_mmap
,
.
fb_ioctl
=
cg14_ioctl
,
.
fb_cursor
=
soft_cursor
,
};
#define CG14_MCR_INTENABLE_SHIFT 7
#define CG14_MCR_INTENABLE_MASK 0x80
...
...
@@ -72,8 +99,6 @@
#define CG14_MCR_PIXMODE_16 2
#define CG14_MCR_PIXMODE_32 3
MODULE_LICENSE
(
"GPL"
);
struct
cg14_regs
{
volatile
u8
mcr
;
/* Master Control Reg */
volatile
u8
ppr
;
/* Packed Pixel Reg */
...
...
@@ -161,285 +186,412 @@ struct cg14_clut {
u32
c_clutd_inc
[
256
];
};
static
struct
sbus_mmap_map
cg14_mmap_map
[]
__initdata
=
{
{
CG14_REGS
,
0x80000000
,
0x1000
},
{
CG14_XLUT
,
0x80003000
,
0x1000
},
{
CG14_CLUT1
,
0x80004000
,
0x1000
},
{
CG14_CLUT2
,
0x80005000
,
0x1000
},
{
CG14_CLUT3
,
0x80006000
,
0x1000
},
{
CG3_MMAP_OFFSET
-
0x7000
,
0x80000000
,
0x7000
},
{
CG3_MMAP_OFFSET
,
0x00000000
,
SBUS_MMAP_FBSIZE
(
1
)
},
{
MDI_CURSOR_MAP
,
0x80001000
,
0x1000
},
{
MDI_CHUNKY_BGR_MAP
,
0x01000000
,
0x400000
},
{
MDI_PLANAR_X16_MAP
,
0x02000000
,
0x200000
},
{
MDI_PLANAR_C16_MAP
,
0x02800000
,
0x200000
},
{
MDI_PLANAR_X32_MAP
,
0x03000000
,
0x100000
},
{
MDI_PLANAR_B32_MAP
,
0x03400000
,
0x100000
},
{
MDI_PLANAR_G32_MAP
,
0x03800000
,
0x100000
},
{
MDI_PLANAR_R32_MAP
,
0x03c00000
,
0x100000
},
{
0
,
0
,
0
}
};
#define CG14_MMAP_ENTRIES 16
st
atic
void
cg14_loadcmap
(
struct
fb_info_sbusfb
*
fb
,
struct
display
*
p
,
int
index
,
int
count
)
{
struct
cg14_clut
*
clut
=
fb
->
s
.
cg14
.
clut
;
unsigned
long
flags
;
st
ruct
cg14_par
{
spinlock_t
lock
;
struct
cg14_regs
*
regs
;
struct
cg14_clut
*
clut
;
struct
cg14_cursor
*
cursor
;
spin_lock_irqsave
(
&
fb
->
lock
,
flags
);
for
(;
count
--
;
index
++
)
{
u32
val
;
u32
flags
;
#define CG14_FLAG_BLANKED 0x00000001
val
=
((
fb
->
color_map
CM
(
index
,
2
)
<<
16
)
|
(
fb
->
color_map
CM
(
index
,
1
)
<<
8
)
|
(
fb
->
color_map
CM
(
index
,
0
)));
sbus_writel
(
val
,
&
clut
->
c_clut
[
index
]);
}
spin_unlock_irqrestore
(
&
fb
->
lock
,
flags
);
}
unsigned
long
physbase
;
unsigned
long
iospace
;
unsigned
long
fbsize
;
static
void
cg14_margins
(
struct
fb_info_sbusfb
*
fb
,
struct
display
*
p
,
int
x_margin
,
int
y_margin
)
{
fb
->
info
.
screen_base
+=
(
y_margin
-
fb
->
y_margin
)
*
fb
->
info
.
fix
.
line_length
+
(
x_margin
-
fb
->
x_margin
);
}
static
void
cg14_setcursormap
(
struct
fb_info_sbusfb
*
fb
,
u8
*
red
,
u8
*
green
,
u8
*
blue
)
{
struct
cg14_cursor
*
cur
=
fb
->
s
.
cg14
.
cursor
;
unsigned
long
flags
;
struct
sbus_mmap_map
mmap_map
[
CG14_MMAP_ENTRIES
];
spin_lock_irqsave
(
&
fb
->
lock
,
flags
)
;
sbus_writel
(((
red
[
0
])
|
(
green
[
0
]
<<
8
)
|
(
blue
[
0
]
<<
16
)),
&
cur
->
color0
)
;
s
bus_writel
(((
red
[
1
])
|
(
green
[
1
]
<<
8
)
|
(
blue
[
1
]
<<
16
)),
&
cur
->
color1
)
;
s
pin_unlock_irqrestore
(
&
fb
->
lock
,
flags
)
;
}
int
mode
;
int
ramsize
;
s
truct
sbus_dev
*
sdev
;
s
truct
list_head
list
;
}
;
/* Set cursor shape */
static
void
cg14_setcurshape
(
struct
fb_info_sbusfb
*
fb
)
static
void
__cg14_reset
(
struct
cg14_par
*
par
)
{
struct
cg14_cursor
*
cur
=
fb
->
s
.
cg14
.
cursor
;
unsigned
long
flags
;
int
i
;
struct
cg14_regs
*
regs
=
par
->
regs
;
u8
val
;
spin_lock_irqsave
(
&
fb
->
lock
,
flags
);
for
(
i
=
0
;
i
<
32
;
i
++
){
sbus_writel
(
fb
->
cursor
.
bits
[
0
][
i
],
&
cur
->
cpl0
[
i
]);
sbus_writel
(
fb
->
cursor
.
bits
[
1
][
i
],
&
cur
->
cpl1
[
i
]);
}
spin_unlock_irqrestore
(
&
fb
->
lock
,
flags
);
val
=
sbus_readb
(
&
regs
->
mcr
);
val
&=
~
(
CG14_MCR_PIXMODE_MASK
);
sbus_writeb
(
val
,
&
regs
->
mcr
);
}
/* Load cursor information */
static
void
cg14_setcursor
(
struct
fb_info_sbusfb
*
fb
)
/**
* cg14_check_var - Optional function. Validates a var passed in.
* @var: frame buffer variable screen structure
* @info: frame buffer structure that represents a single frame buffer
*/
static
int
cg14_check_var
(
struct
fb_var_screeninfo
*
var
,
struct
fb_info
*
info
)
{
struct
cg_cursor
*
c
=
&
fb
->
cursor
;
struct
cg14_cursor
*
cur
=
fb
->
s
.
cg14
.
cursor
;
unsigned
long
flags
;
if
(
var
->
bits_per_pixel
!=
8
)
return
-
EINVAL
;
spin_lock_irqsave
(
&
fb
->
lock
,
flags
);
if
(
c
->
enable
)
{
u8
tmp
=
sbus_readb
(
&
cur
->
ccr
);
if
(
var
->
xres_virtual
!=
var
->
xres
||
var
->
yres_virtual
!=
var
->
yres
)
return
-
EINVAL
;
if
(
var
->
nonstd
)
return
-
EINVAL
;
if
((
var
->
vmode
&
FB_VMODE_MASK
)
!=
FB_VMODE_NONINTERLACED
)
return
-
EINVAL
;
tmp
|=
CG14_CCR_ENABLE
;
sbus_writeb
(
tmp
,
&
cur
->
ccr
);
}
else
{
u8
tmp
=
sbus_readb
(
&
cur
->
ccr
);
if
(
var
->
xres
!=
info
->
var
.
xres
||
var
->
yres
!=
info
->
var
.
yres
)
return
-
EINVAL
;
tmp
&=
~
CG14_CCR_ENABLE
;
sbus_writeb
(
tmp
,
&
cur
->
ccr
);
}
sbus_writew
(((
c
->
cpos
.
fbx
-
c
->
chot
.
fbx
)
&
0xfff
),
&
cur
->
cursx
);
sbus_writew
(((
c
->
cpos
.
fby
-
c
->
chot
.
fby
)
&
0xfff
),
&
cur
->
cursy
);
spin_unlock_irqrestore
(
&
fb
->
lock
,
flags
);
return
0
;
}
static
void
cg14_switch_from_graph
(
struct
fb_info_sbusfb
*
fb
)
/**
* cg14_set_par - Optional function. Alters the hardware state.
* @info: frame buffer structure that represents a single frame buffer
*/
static
int
cg14_set_par
(
struct
fb_info
*
info
)
{
return
0
;
}
/**
* cg14_setcolreg - Optional function. Sets a color register.
* @regno: boolean, 0 copy local, 1 get_user() function
* @red: frame buffer colormap structure
* @green: The green value which can be up to 16 bits wide
* @blue: The blue value which can be up to 16 bits wide.
* @transp: If supported the alpha value which can be up to 16 bits wide.
* @info: frame buffer info structure
*/
static
int
cg14_setcolreg
(
unsigned
regno
,
unsigned
red
,
unsigned
green
,
unsigned
blue
,
unsigned
transp
,
struct
fb_info
*
info
)
{
struct
cg14_par
*
par
=
(
struct
cg14_par
*
)
info
->
par
;
struct
cg14_clut
*
clut
=
par
->
clut
;
unsigned
long
flags
;
u32
val
;
spin_lock_irqsave
(
&
fb
->
lock
,
flags
);
if
(
regno
>=
256
)
return
1
;
/* Set the 8-bpp mode */
if
(
fb
->
open
&&
fb
->
mmaped
){
volatile
char
*
mcr
=
&
fb
->
s
.
cg14
.
regs
->
mcr
;
char
tmp
;
val
=
(
red
|
(
green
<<
8
)
|
(
blue
<<
16
));
fb
->
s
.
cg14
.
mode
=
8
;
tmp
=
sbus_readb
(
mcr
);
tmp
&=
~
(
CG14_MCR_PIXMODE_MASK
);
sbus_writeb
(
tmp
,
mcr
);
}
spin_unlock_irqrestore
(
&
fb
->
lock
,
flags
);
spin_lock_irqsave
(
&
par
->
lock
,
flags
);
sbus_writel
(
val
,
&
clut
->
c_clut
[
regno
]);
spin_unlock_irqrestore
(
&
par
->
lock
,
flags
);
return
0
;
}
static
void
cg14_reset
(
struct
fb_info_sbusfb
*
fb
)
static
int
cg14_mmap
(
struct
fb_info
*
info
,
struct
file
*
file
,
struct
vm_area_struct
*
vma
)
{
volatile
char
*
mcr
=
&
fb
->
s
.
cg14
.
regs
->
mcr
;
unsigned
long
flags
;
char
tmp
;
struct
cg14_par
*
par
=
(
struct
cg14_par
*
)
info
->
par
;
spin_lock_irqsave
(
&
fb
->
lock
,
flags
);
tmp
=
sbus_readb
(
mcr
);
tmp
&=
~
(
CG14_MCR_PIXMODE_MASK
);
sbus_writeb
(
tmp
,
mcr
);
spin_unlock_irqrestore
(
&
fb
->
lock
,
flags
);
return
sbusfb_mmap_helper
(
par
->
mmap_map
,
par
->
physbase
,
par
->
fbsize
,
par
->
iospace
,
vma
);
}
static
int
cg14_ioctl
(
struct
fb_info_sbusfb
*
fb
,
unsigned
int
cmd
,
unsigned
long
arg
)
static
int
cg14_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
,
struct
fb_info
*
info
)
{
volatile
char
*
mcr
=
&
fb
->
s
.
cg14
.
regs
->
mcr
;
struct
mdi_cfginfo
*
mdii
;
struct
cg14_par
*
par
=
(
struct
cg14_par
*
)
info
->
par
;
struct
cg14_regs
*
regs
=
par
->
regs
;
struct
mdi_cfginfo
kmdi
,
*
mdii
;
unsigned
long
flags
;
int
mode
,
ret
=
0
;
char
tmp
;
int
cur_mode
,
mode
,
ret
=
0
;
switch
(
cmd
)
{
case
MDI_RESET
:
spin_lock_irqsave
(
&
fb
->
lock
,
flags
);
tmp
=
sbus_readb
(
mcr
);
tmp
&=
~
CG14_MCR_PIXMODE_MASK
;
sbus_writeb
(
tmp
,
mcr
);
spin_unlock_irqrestore
(
&
fb
->
lock
,
flags
);
spin_lock_irqsave
(
&
par
->
lock
,
flags
);
__cg14_reset
(
par
);
spin_unlock_irqrestore
(
&
par
->
lock
,
flags
);
break
;
case
MDI_GET_CFGINFO
:
mdii
=
(
struct
mdi_cfginfo
*
)
arg
;
if
(
put_user
(
FBTYPE_MDICOLOR
,
&
mdii
->
mdi_type
)
||
__put_user
(
fb
->
type
.
fb_height
,
&
mdii
->
mdi_height
)
||
__put_user
(
fb
->
type
.
fb_width
,
&
mdii
->
mdi_width
)
||
__put_user
(
fb
->
s
.
cg14
.
mode
,
&
mdii
->
mdi_mode
)
||
__put_user
(
72
,
&
mdii
->
mdi_pixfreq
)
||
/* FIXME */
__put_user
(
fb
->
s
.
cg14
.
ramsize
,
&
mdii
->
mdi_size
))
return
-
EFAULT
;
memset
(
&
kmdi
,
0
,
sizeof
(
kmdi
));
spin_lock_irqsave
(
&
par
->
lock
,
flags
);
kmdi
.
mdi_type
=
FBTYPE_MDICOLOR
;
kmdi
.
mdi_height
=
info
->
var
.
yres
;
kmdi
.
mdi_width
=
info
->
var
.
xres
;
kmdi
.
mdi_mode
=
par
->
mode
;
kmdi
.
mdi_pixfreq
=
72
;
/* FIXME */
kmdi
.
mdi_size
=
par
->
ramsize
;
spin_unlock_irqrestore
(
&
par
->
lock
,
flags
);
mdii
=
(
struct
mdi_cfginfo
*
)
arg
;
if
(
copy_to_user
(
mdii
,
&
kmdi
,
sizeof
(
kmdi
)))
ret
=
-
EFAULT
;
break
;
case
MDI_SET_PIXELMODE
:
if
(
get_user
(
mode
,
(
int
*
)
arg
))
return
-
EFAULT
;
if
(
get_user
(
mode
,
(
int
*
)
arg
))
{
ret
=
-
EFAULT
;
break
;
}
spin_lock_irqsave
(
&
fb
->
lock
,
flags
);
tmp
=
sbus_readb
(
mcr
);
switch
(
mode
){
spin_lock_irqsave
(
&
par
->
lock
,
flags
);
cur_mode
=
sbus_readb
(
&
regs
->
mcr
);
cur_mode
&=
~
CG14_MCR_PIXMODE_MASK
;
switch
(
mode
)
{
case
MDI_32_PIX
:
tmp
=
(
tmp
&
~
CG14_MCR_PIXMODE_MASK
)
|
(
CG14_MCR_PIXMODE_32
<<
CG14_MCR_PIXMODE_SHIFT
);
cur_mode
|=
(
CG14_MCR_PIXMODE_32
<<
CG14_MCR_PIXMODE_SHIFT
);
break
;
case
MDI_16_PIX
:
tmp
=
(
tmp
&
~
CG14_MCR_PIXMODE_MASK
)
|
0x20
;
cur_mode
|=
0x20
;
break
;
case
MDI_8_PIX
:
tmp
=
(
tmp
&
~
CG14_MCR_PIXMODE_MASK
);
break
;
default:
ret
=
-
ENOSYS
;
break
;
};
if
(
ret
==
0
)
{
sbus_writeb
(
tmp
,
mcr
);
fb
->
s
.
cg14
.
mode
=
mode
;
if
(
!
ret
)
{
sbus_writeb
(
cur_mode
,
&
regs
->
mcr
);
par
->
mode
=
mode
;
}
spin_unlock_irqrestore
(
&
fb
->
lock
,
flags
);
spin_unlock_irqrestore
(
&
par
->
lock
,
flags
);
break
;
default:
ret
=
-
EINVAL
;
break
;
};
return
ret
;
}
static
unsigned
long
__init
get_phys
(
unsigned
long
addr
)
{
return
__get_phys
(
addr
);
}
/*
* Initialisation
*/
static
int
__init
get_iospace
(
unsigned
long
addr
)
static
void
cg14_init_fix
(
struct
fb_info
*
info
,
int
linebytes
)
{
return
__get_iospace
(
addr
);
struct
cg14_par
*
par
=
(
struct
cg14_par
*
)
info
->
par
;
strncpy
(
info
->
fix
.
id
,
par
->
sdev
->
prom_name
,
sizeof
(
info
->
fix
.
id
)
-
1
);
info
->
fix
.
id
[
sizeof
(
info
->
fix
.
id
)
-
1
]
=
0
;
info
->
fix
.
type
=
FB_TYPE_PACKED_PIXELS
;
info
->
fix
.
visual
=
FB_VISUAL_TRUECOLOR
;
info
->
fix
.
line_length
=
linebytes
;
info
->
fix
.
accel
=
FB_ACCEL_SUN_CG14
;
}
static
char
idstring
[
60
]
__initdata
=
{
0
};
static
struct
sbus_mmap_map
__cg14_mmap_map
[
CG14_MMAP_ENTRIES
]
__initdata
=
{
{
CG14_REGS
,
0x80000000
,
0x1000
},
{
CG14_XLUT
,
0x80003000
,
0x1000
},
{
CG14_CLUT1
,
0x80004000
,
0x1000
},
{
CG14_CLUT2
,
0x80005000
,
0x1000
},
{
CG14_CLUT3
,
0x80006000
,
0x1000
},
{
CG3_MMAP_OFFSET
-
0x7000
,
0x80000000
,
0x7000
},
{
CG3_MMAP_OFFSET
,
0x00000000
,
SBUS_MMAP_FBSIZE
(
1
)
},
{
MDI_CURSOR_MAP
,
0x80001000
,
0x1000
},
{
MDI_CHUNKY_BGR_MAP
,
0x01000000
,
0x400000
},
{
MDI_PLANAR_X16_MAP
,
0x02000000
,
0x200000
},
{
MDI_PLANAR_C16_MAP
,
0x02800000
,
0x200000
},
{
MDI_PLANAR_X32_MAP
,
0x03000000
,
0x100000
},
{
MDI_PLANAR_B32_MAP
,
0x03400000
,
0x100000
},
{
MDI_PLANAR_G32_MAP
,
0x03800000
,
0x100000
},
{
MDI_PLANAR_R32_MAP
,
0x03c00000
,
0x100000
},
{
0
,
0
,
0
}
};
struct
all_info
{
struct
fb_info
info
;
struct
cg14_par
par
;
struct
list_head
list
;
};
static
LIST_HEAD
(
cg14_list
);
char
__init
*
cgfourteenfb_init
(
struct
fb_info_sbusfb
*
fb
)
static
void
cg14_init_one
(
struct
sbus_dev
*
sdev
,
int
node
,
int
parent_node
)
{
struct
fb_fix_screeninfo
*
fix
=
&
fb
->
info
.
fix
;
struct
display
*
disp
=
&
fb
->
disp
;
struct
fbtype
*
type
=
&
fb
->
type
;
unsigned
long
rphys
,
phys
;
struct
all_info
*
all
;
unsigned
long
phys
,
rphys
;
u32
bases
[
6
];
int
is_8mb
,
i
;
int
is_8mb
,
linebytes
,
i
;
#ifndef FBCON_HAS_CFB8
return
NULL
;
#endif
prom_getproperty
(
fb
->
prom_node
,
"address"
,
(
char
*
)
&
bases
[
0
],
8
);
if
(
!
sdev
)
{
prom_getproperty
(
node
,
"address"
,
(
char
*
)
&
bases
[
0
],
sizeof
(
bases
));
if
(
!
bases
[
0
])
{
printk
(
"cg14 not mmaped
\n
"
);
return
NULL
;
printk
(
KERN_ERR
"cg14: Device is not mapped.
\n
"
);
return
;
}
if
(
get_iospace
(
bases
[
0
])
!=
get_iospace
(
bases
[
1
]))
{
printk
(
"Ugh. cg14 iospaces don't match
\n
"
);
return
NULL
;
if
(
__get_iospace
(
bases
[
0
])
!=
__
get_iospace
(
bases
[
1
]))
{
printk
(
KERN_ERR
"cg14: I/O spaces don't match.
\n
"
);
return
;
}
fb
->
physbase
=
phys
=
get_phys
(
bases
[
1
]);
rphys
=
get_phys
(
bases
[
0
]);
fb
->
iospace
=
get_iospace
(
bases
[
0
]);
fb
->
s
.
cg14
.
regs
=
(
struct
cg14_regs
*
)(
unsigned
long
)
bases
[
0
];
fb
->
s
.
cg14
.
clut
=
(
void
*
)((
unsigned
long
)
bases
[
0
]
+
CG14_CLUT1
);
fb
->
s
.
cg14
.
cursor
=
(
void
*
)((
unsigned
long
)
bases
[
0
]
+
CG14_CURSORREGS
);
fb
->
info
.
screen_base
=
(
char
*
)
bases
[
1
];
/* CG14_VCA_8MB_MASK is not correctly set on the 501-2482
* VSIMM, so we read the memory size from the PROM
*/
prom_getproperty
(
fb
->
prom_node
,
"reg"
,
(
char
*
)
&
bases
[
0
],
24
);
is_8mb
=
bases
[
5
]
==
0x800000
;
fb
->
mmap_map
=
kmalloc
(
sizeof
(
cg14_mmap_map
),
GFP_KERNEL
);
if
(
!
fb
->
mmap_map
)
return
NULL
;
for
(
i
=
0
;
;
i
++
)
{
fb
->
mmap_map
[
i
].
voff
=
cg14_mmap_map
[
i
].
voff
;
fb
->
mmap_map
[
i
].
poff
=
(
cg14_mmap_map
[
i
].
poff
&
0x80000000
)
?
(
cg14_mmap_map
[
i
].
poff
&
0x7fffffff
)
+
rphys
-
phys
:
cg14_mmap_map
[
i
].
poff
;
fb
->
mmap_map
[
i
].
size
=
cg14_mmap_map
[
i
].
size
;
if
(
is_8mb
&&
fb
->
mmap_map
[
i
].
size
>=
0x100000
&&
fb
->
mmap_map
[
i
].
size
<=
0x400000
)
fb
->
mmap_map
[
i
].
size
<<=
1
;
if
(
!
cg14_mmap_map
[
i
].
size
)
}
all
=
kmalloc
(
sizeof
(
*
all
),
GFP_KERNEL
);
if
(
!
all
)
{
printk
(
KERN_ERR
"cg14: Cannot allocate memory.
\n
"
);
return
;
}
memset
(
all
,
0
,
sizeof
(
*
all
));
INIT_LIST_HEAD
(
&
all
->
list
);
spin_lock_init
(
&
all
->
par
.
lock
);
sbusfb_fill_var
(
&
all
->
info
.
var
,
node
,
8
);
linebytes
=
prom_getintdefault
(
sdev
->
prom_node
,
"linebytes"
,
all
->
info
.
var
.
xres
);
all
->
par
.
fbsize
=
PAGE_ALIGN
(
linebytes
*
all
->
info
.
var
.
yres
);
all
->
par
.
sdev
=
sdev
;
if
(
sdev
)
{
rphys
=
sdev
->
reg_addrs
[
0
].
phys_addr
;
all
->
par
.
physbase
=
phys
=
sdev
->
reg_addrs
[
1
].
phys_addr
;
all
->
par
.
iospace
=
sdev
->
reg_addrs
[
0
].
which_io
;
all
->
par
.
regs
=
(
struct
cg14_regs
*
)
sbus_ioremap
(
&
sdev
->
resource
[
0
],
0
,
sizeof
(
struct
cg14_regs
),
"cg14 regs"
);
all
->
par
.
clut
=
(
struct
cg14_clut
*
)
sbus_ioremap
(
&
sdev
->
resource
[
0
],
CG14_CLUT1
,
sizeof
(
struct
cg14_clut
),
"cg14 clut"
);
all
->
par
.
cursor
=
(
struct
cg14_cursor
*
)
sbus_ioremap
(
&
sdev
->
resource
[
0
],
CG14_CURSORREGS
,
sizeof
(
struct
cg14_cursor
),
"cg14 cursor"
);
all
->
info
.
screen_base
=
(
char
*
)
sbus_ioremap
(
&
sdev
->
resource
[
1
],
0
,
all
->
par
.
fbsize
,
"cg14 ram"
);
}
else
{
rphys
=
__get_phys
(
bases
[
0
]);
all
->
par
.
physbase
=
phys
=
__get_phys
(
bases
[
1
]);
all
->
par
.
iospace
=
__get_iospace
(
bases
[
0
]);
all
->
par
.
regs
=
(
struct
cg14_regs
*
)(
unsigned
long
)
bases
[
0
];
all
->
par
.
clut
=
(
struct
cg14_clut
*
)((
unsigned
long
)
bases
[
0
]
+
CG14_CLUT1
);
all
->
par
.
cursor
=
(
struct
cg14_cursor
*
)((
unsigned
long
)
bases
[
0
]
+
CG14_CURSORREGS
);
all
->
info
.
screen_base
=
(
char
*
)(
unsigned
long
)
bases
[
1
];
}
prom_getproperty
(
node
,
"reg"
,
(
char
*
)
&
bases
[
0
],
sizeof
(
bases
));
is_8mb
=
(
bases
[
5
]
==
0x800000
);
if
(
sizeof
(
all
->
par
.
mmap_map
)
!=
sizeof
(
__cg14_mmap_map
))
{
extern
void
__cg14_mmap_sized_wrongly
(
void
);
__cg14_mmap_sized_wrongly
();
}
memcpy
(
&
all
->
par
.
mmap_map
,
&
__cg14_mmap_map
,
sizeof
(
all
->
par
.
mmap_map
));
for
(
i
=
0
;
i
<
CG14_MMAP_ENTRIES
;
i
++
)
{
struct
sbus_mmap_map
*
map
=
&
all
->
par
.
mmap_map
[
i
];
if
(
!
map
->
size
)
break
;
if
(
map
->
poff
&
0x80000000
)
map
->
poff
=
(
map
->
poff
&
0x7fffffff
)
+
rphys
-
phys
;
if
(
is_8mb
&&
map
->
size
>=
0x100000
&&
map
->
size
<=
0x400000
)
map
->
size
*=
2
;
}
strcpy
(
fb
->
info
.
modename
,
"CGfourteen"
);
strcpy
(
fix
->
id
,
"CGfourteen"
);
fix
->
line_length
=
fb
->
info
.
var
.
xres_virtual
;
fix
->
accel
=
FB_ACCEL_SUN_CG14
;
all
->
par
.
mode
=
MDI_8_PIX
;
all
->
par
.
ramsize
=
(
is_8mb
?
0x800000
:
0x400000
);
disp
->
scrollmode
=
SCROLL_YREDRAW
;
fb
->
info
.
screen_base
+=
fix
->
line_length
*
fb
->
y_margin
+
fb
->
x_margin
;
fb
->
dispsw
=
fbcon_cfb8
;
all
->
info
.
node
=
NODEV
;
all
->
info
.
flags
=
FBINFO_FLAG_DEFAULT
;
all
->
info
.
fbops
=
&
cg14_ops
;
all
->
info
.
currcon
=
-
1
;
all
->
info
.
par
=
&
all
->
par
;
type
->
fb_depth
=
24
;
fb
->
emulations
[
1
]
=
FBTYPE_SUN3COLOR
;
__cg14_reset
(
&
all
->
par
);
fb
->
margins
=
cg14_margins
;
fb
->
loadcmap
=
cg14_loadcmap
;
fb
->
setcursor
=
cg14_setcursor
;
fb
->
setcursormap
=
cg14_setcursormap
;
fb
->
setcurshape
=
cg14_setcurshape
;
fb
->
reset
=
cg14_reset
;
fb
->
switch_from_graph
=
cg14_switch_from_graph
;
fb
->
ioctl
=
cg14_ioctl
;
if
(
fb_alloc_cmap
(
&
all
->
info
.
cmap
,
256
,
0
))
{
printk
(
KERN_ERR
"cg14: Could not allocate color map.
\n
"
)
;
kfree
(
all
)
;
return
;
}
cg14_set_par
(
&
all
->
info
)
;
cg14_init_fix
(
&
all
->
info
,
linebytes
)
;
fb
->
s
.
cg14
.
mode
=
8
;
fb
->
s
.
cg14
.
ramsize
=
(
is_8mb
)
?
0x800000
:
0x400000
;
if
(
register_framebuffer
(
&
all
->
info
)
<
0
)
{
printk
(
KERN_ERR
"cg14: Could not register framebuffer.
\n
"
);
fb_dealloc_cmap
(
&
all
->
info
.
cmap
);
kfree
(
all
);
return
;
}
cg14_reset
(
fb
);
list_add
(
&
all
->
list
,
&
cg14_list
);
sprintf
(
idstring
,
"cgfourteen at %x.%08lx, %dMB, rev=%d, impl=%d"
,
fb
->
iospace
,
phys
,
is_8mb
?
8
:
4
,
fb
->
s
.
cg14
.
regs
->
rev
>>
4
,
fb
->
s
.
cg14
.
regs
->
rev
&
0xf
);
printk
(
"cg14: cgfourteen at %lx:%lx
\n
"
,
all
->
par
.
physbase
,
all
->
par
.
iospace
);
return
idstring
;
}
int
__init
cg14_init
(
void
)
{
struct
sbus_bus
*
sbus
;
struct
sbus_dev
*
sdev
;
#ifdef CONFIG_SPARC32
{
int
root
,
node
;
root
=
prom_getchild
(
prom_root_node
);
root
=
prom_searchsiblings
(
root
,
"obio"
);
if
(
root
)
{
node
=
prom_searchsiblings
(
prom_getchild
(
root
),
"cgfourteen"
);
if
(
node
)
cg14_init_one
(
NULL
,
node
,
root
);
}
}
#endif
for_all_sbusdev
(
sdev
,
sbus
)
{
if
(
!
strcmp
(
sdev
->
prom_name
,
"cgfourteen"
))
cg14_init_one
(
sdev
,
sdev
->
prom_node
,
sbus
->
prom_node
);
}
return
0
;
}
void
__exit
cg14_exit
(
void
)
{
struct
list_head
*
pos
,
*
tmp
;
list_for_each_safe
(
pos
,
tmp
,
&
cg14_list
)
{
struct
all_info
*
all
=
list_entry
(
pos
,
typeof
(
*
all
),
list
);
unregister_framebuffer
(
&
all
->
info
);
fb_dealloc_cmap
(
&
all
->
info
.
cmap
);
kfree
(
all
);
}
}
int
__init
cg14_setup
(
char
*
arg
)
{
/* No cmdline options yet... */
return
0
;
}
#ifdef MODULE
module_init
(
cg14_init
);
module_exit
(
cg14_exit
);
#endif
MODULE_DESCRIPTION
(
"framebuffer driver for CGfourteen chipsets"
);
MODULE_AUTHOR
(
"David S. Miller <davem@redhat.com>"
);
MODULE_LICENSE
(
"GPL"
);
drivers/video/fbmem.c
View file @
67bf3c24
...
...
@@ -152,6 +152,8 @@ extern int cg3_init(void);
extern
int
cg3_setup
(
char
*
);
extern
int
bw2_init
(
void
);
extern
int
bw2_setup
(
char
*
);
extern
int
cg14_init
(
void
);
extern
int
cg14_setup
(
char
*
);
static
struct
{
const
char
*
name
;
...
...
@@ -255,6 +257,9 @@ static struct {
#ifdef CONFIG_FB_BW2
{
"bw2"
,
bw2_init
,
bw2_setup
},
#endif
#ifdef CONFIG_FB_CG14
{
"cg14"
,
cg14_init
,
cg14_setup
},
#endif
/*
* Generic drivers that are used as fallbacks
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment