2 * drivers/video/pnx4008/pnxrgbfb.c
4 * PNX4008's framebuffer support
6 * Author: Grigory Tolstolytkin <gtolstolytkin@ru.mvista.com>
7 * Based on Philips Semiconductors's code
9 * Copyrght (c) 2005 MontaVista Software, Inc.
10 * Copyright (c) 2005 Philips Semiconductors
11 * This file is licensed under the terms of the GNU General Public License
12 * version 2. This program is licensed "as is" without any warranty of any
13 * kind, whether express or implied.
16 #include <linux/module.h>
17 #include <linux/kernel.h>
18 #include <linux/errno.h>
19 #include <linux/string.h>
21 #include <linux/slab.h>
22 #include <linux/vmalloc.h>
23 #include <linux/delay.h>
24 #include <linux/interrupt.h>
26 #include <linux/init.h>
27 #include <linux/platform_device.h>
29 #include <asm/uaccess.h>
33 static u32 colreg
[16];
35 static struct fb_var_screeninfo rgbfb_var __initdata
= {
38 .xres_virtual
= LCD_X_RES
,
39 .yres_virtual
= LCD_Y_RES
,
51 .vmode
= FB_VMODE_NONINTERLACED
,
53 static struct fb_fix_screeninfo rgbfb_fix __initdata
= {
55 .line_length
= LCD_X_RES
* LCD_BBP
,
56 .type
= FB_TYPE_PACKED_PIXELS
,
57 .visual
= FB_VISUAL_TRUECOLOR
,
61 .accel
= FB_ACCEL_NONE
,
64 static int channel_owned
;
66 static int no_cursor(struct fb_info
*info
, struct fb_cursor
*cursor
)
71 static int rgbfb_setcolreg(u_int regno
, u_int red
, u_int green
, u_int blue
,
72 u_int transp
, struct fb_info
*info
)
77 colreg
[regno
] = ((red
& 0xff00) << 8) | (green
& 0xff00) |
78 ((blue
& 0xff00) >> 8);
82 static int rgbfb_mmap(struct fb_info
*info
, struct vm_area_struct
*vma
)
84 return pnx4008_sdum_mmap(info
, vma
, NULL
);
87 static struct fb_ops rgbfb_ops
= {
88 .fb_mmap
= rgbfb_mmap
,
89 .fb_setcolreg
= rgbfb_setcolreg
,
90 .fb_fillrect
= cfb_fillrect
,
91 .fb_copyarea
= cfb_copyarea
,
92 .fb_imageblit
= cfb_imageblit
,
95 static int rgbfb_remove(struct platform_device
*pdev
)
97 struct fb_info
*info
= platform_get_drvdata(pdev
);
100 unregister_framebuffer(info
);
101 fb_dealloc_cmap(&info
->cmap
);
102 framebuffer_release(info
);
103 platform_set_drvdata(pdev
, NULL
);
107 pnx4008_free_dum_channel(channel_owned
, pdev
->id
);
108 pnx4008_set_dum_exit_notification(pdev
->id
);
113 static int __devinit
rgbfb_probe(struct platform_device
*pdev
)
115 struct fb_info
*info
;
116 struct dumchannel_uf chan_uf
;
120 info
= framebuffer_alloc(sizeof(u32
) * 16, &pdev
->dev
);
126 pnx4008_get_fb_addresses(FB_TYPE_RGB
, (void **)&info
->screen_base
,
127 (dma_addr_t
*) &rgbfb_fix
.smem_start
,
128 &rgbfb_fix
.smem_len
);
130 if ((ret
= pnx4008_alloc_dum_channel(pdev
->id
)) < 0)
134 chan_uf
.channelnr
= channel_owned
;
135 chan_uf
.dirty
= (u32
*) NULL
;
136 chan_uf
.source
= (u32
*) rgbfb_fix
.smem_start
;
137 chan_uf
.x_offset
= 0;
138 chan_uf
.y_offset
= 0;
139 chan_uf
.width
= LCD_X_RES
;
140 chan_uf
.height
= LCD_Y_RES
;
142 if ((ret
= pnx4008_put_dum_channel_uf(chan_uf
, pdev
->id
))< 0)
146 pnx4008_set_dum_channel_sync(channel_owned
, CONF_SYNC_ON
,
151 pnx4008_set_dum_channel_dirty_detect(channel_owned
,
152 CONF_DIRTYDETECTION_ON
,
157 if (!fb_get_options("pnxrgbfb", &option
) && option
&&
158 !strcmp(option
, "nocursor"))
159 rgbfb_ops
.fb_cursor
= no_cursor
;
162 info
->flags
= FBINFO_FLAG_DEFAULT
;
163 info
->fbops
= &rgbfb_ops
;
164 info
->fix
= rgbfb_fix
;
165 info
->var
= rgbfb_var
;
166 info
->screen_size
= rgbfb_fix
.smem_len
;
167 info
->pseudo_palette
= info
->par
;
170 ret
= fb_alloc_cmap(&info
->cmap
, 256, 0);
174 ret
= register_framebuffer(info
);
177 platform_set_drvdata(pdev
, info
);
182 fb_dealloc_cmap(&info
->cmap
);
184 framebuffer_release(info
);
186 pnx4008_free_dum_channel(channel_owned
, pdev
->id
);
193 static struct platform_driver rgbfb_driver
= {
195 .name
= "pnx4008-rgbfb",
197 .probe
= rgbfb_probe
,
198 .remove
= rgbfb_remove
,
201 static int __init
rgbfb_init(void)
203 return platform_driver_register(&rgbfb_driver
);
206 static void __exit
rgbfb_exit(void)
208 platform_driver_unregister(&rgbfb_driver
);
211 module_init(rgbfb_init
);
212 module_exit(rgbfb_exit
);
214 MODULE_LICENSE("GPL");