2 * $Id: hitfb.c,v 1.2 2000/07/04 06:24:46 yaegashi Exp $
3 * linux/drivers/video/hitfb.c -- Hitachi LCD frame buffer device
4 * (C) 1999 Mihai Spatar
5 * (C) 2000 YAEGASHI Takeshi
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive for
12 #include <linux/config.h>
13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/sched.h>
16 #include <linux/errno.h>
17 #include <linux/string.h>
19 #include <linux/tty.h>
20 #include <linux/slab.h>
21 #include <linux/delay.h>
22 #include <linux/nubus.h>
23 #include <linux/init.h>
26 #include <asm/machvec.h>
27 #include <asm/uaccess.h>
28 #include <asm/pgtable.h>
30 #include <asm/hd64461.h>
32 static struct fb_var_screeninfo hitfb_var __initdata
= {
33 .activate
= FB_ACTIVATE_NOW
,
36 .vmode
= FB_VMODE_NONINTERLACED
,
39 static struct fb_fix_screeninfo hitfb_fix __initdata
= {
40 .id
= "Hitachi HD64461",
41 .type
= FB_TYPE_PACKED_PIXELS
,
42 .visual
= FB_VISUAL_TRUECOLOR
,
43 .accel_flags
= FB_ACCEL_NONE
,
46 static u16 pseudo_palette
[17];
47 struct fb_info fb_info
;
49 static int hitfb_check_var(struct fb_var_screeninfo
*var
, struct fb_info
*info
)
51 var
->xres_virtual
= var
->xres
;
52 var
->yres_virtual
= var
->yres
;
54 switch (var
->bits_per_pixel
) {
58 var
->green
.offset
= 0;
59 var
->green
.length
= 8;
62 var
->transp
.offset
= 0;
63 var
->transp
.length
= 0;
65 case 16: /* RGB 565 */
68 var
->green
.offset
= 5;
69 var
->green
.length
= 6;
72 var
->transp
.offset
= 0;
73 var
->transp
.length
= 0;
79 static int hitfb_set_par(struct fb_info
*info
)
81 info
->fix
.visual
= (info
->var
.bits_per_pixel
== 8) ?
82 FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_TRUECOLOR
;
84 switch(info
->var
.bits_per_pixel
) {
87 info
->fix
.line_length
= info
->var
.xres
;
90 info
->fix
.line_length
= info
->var
.xres
*2;
96 static int hitfb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
97 unsigned blue
, unsigned transp
,
103 outw(regno
<< 8, HD64461_CPTWAR
);
104 outw(red
>> 10, HD64461_CPTWDR
);
105 outw(green
>> 10, HD64461_CPTWDR
);
106 outw(blue
>> 10, HD64461_CPTWDR
);
109 switch(info
->var
.bits_per_pixel
) {
111 ((u16
*)(info
->pseudo_palette
))[regno
] =
113 ((green
& 0xfc00) >> 5) |
114 ((blue
& 0xf800) >> 11);
121 static struct fb_ops hitfb_ops
= {
122 .owner
= THIS_MODULE
,
123 .fb_check_var
= hitfb_check_var
,
124 .fb_set_par
= hitfb_set_par
,
125 .fb_setcolreg
= hitfb_setcolreg
,
126 .fb_fillrect
= cfb_fillrect
,
127 .fb_copyarea
= cfb_copyarea
,
128 .fb_imageblit
= cfb_imageblit
,
129 .fb_cursor
= soft_cursor
,
132 int __init
hitfb_init(void)
134 unsigned short lcdclor
, ldr3
, ldvntr
;
136 hitfb_fix
.smem_start
= CONFIG_HD64461_IOBASE
+ 0x02000000;
137 hitfb_fix
.smem_len
= (MACH_HP680
|| MACH_HP690
) ? 1024*1024 : 512*1024;
139 lcdclor
= inw(HD64461_LCDCLOR
);
140 ldvntr
= inw(HD64461_LDVNTR
);
141 ldr3
= inw(HD64461_LDR3
);
146 hitfb_var
.bits_per_pixel
= 8;
147 hitfb_var
.xres
= lcdclor
;
150 hitfb_var
.bits_per_pixel
= 16;
151 hitfb_var
.xres
= lcdclor
/2;
154 hitfb_var
.yres
= ldvntr
+1;
156 fb_info
.fbops
= &hitfb_ops
;
157 fb_info
.var
= hitfb_var
;
158 fb_info
.fix
= hitfb_fix
;
159 fb_info
.pseudo_palette
= pseudo_palette
;
160 fb_info
.flags
= FBINFO_FLAG_DEFAULT
;
162 fb_info
.screen_base
= (void *) hitfb_fix
.smem_start
;
164 size
= (fb_info
.var
.bits_per_pixel
== 8) ? 256 : 16;
165 fb_alloc_cmap(&fb_info
.cmap
, size
, 0);
167 if (register_framebuffer(&fb_info
) < 0)
170 printk(KERN_INFO
"fb%d: %s frame buffer device\n",
171 fb_info
.node
, fb_info
.fix
.id
);
176 void hitfb_cleanup(struct fb_info
*info
)
178 unregister_framebuffer(info
);
183 MODULE_LICENSE("GPL");
185 int init_module(void)
190 void cleanup_module(void)