13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/errno.h>
16 #include <linux/string.h>
21 #include <linux/pci.h>
27 static char mode_option[32] =
"640x480-16@60";
28 static int crt_option = 1;
29 static char panel_option[32] =
"";
34 {
NULL, 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2,
37 {
NULL, 75, 640, 480, 31746, 120, 16, 16, 01, 64, 3,
40 {
NULL, 85, 640, 480, 27777, 80, 56, 25, 01, 56, 3,
43 {
NULL, 60, 800, 600, 25000, 88, 40, 23, 01, 128, 4,
47 {
NULL, 75, 800, 600, 20202, 160, 16, 21, 01, 80, 3,
51 {
NULL, 85, 800, 600, 17761, 152, 32, 27, 01, 64, 3,
55 {
NULL, 60, 1024, 768, 15384, 160, 24, 29, 3, 136, 6,
58 {
NULL, 75, 1024, 768, 12690, 176, 16, 28, 1, 96, 3,
62 {
NULL, 85, 1024, 768, 10582, 208, 48, 36, 1, 96, 3,
66 {
NULL, 60, 1280, 960, 9259, 312, 96, 36, 1, 112, 3,
70 {
NULL, 85, 1280, 960, 6734, 224, 64, 47, 1, 160, 3,
74 {
NULL, 60, 1280, 1024, 9259, 248, 48, 38, 1, 112, 3,
78 {
NULL, 75, 1280, 1024, 7407, 248, 16, 38, 1, 144, 3,
82 {
NULL, 85, 1280, 1024, 6349, 224, 64, 44, 1, 160, 3,
87 static int gx1_line_delta(
int xres,
int bpp)
89 int line_delta = xres * (bpp >> 3);
91 if (line_delta > 2048)
93 else if (line_delta > 1024)
105 if (var->
xres > 1280 || var->
yres > 1024)
113 var->
red.offset = 11; var->
red.length = 5;
115 var->
blue.offset = 0; var->
blue.length = 5;
118 var->
red.offset = 0; var->
red.length = 8;
120 var->
blue.offset = 0; var->
blue.length = 8;
134 static int gx1fb_set_par(
struct fb_info *info)
138 if (info->
var.bits_per_pixel == 16)
143 info->
fix.line_length = gx1_line_delta(info->
var.xres, info->
var.bits_per_pixel);
145 par->
dc_ops->set_mode(info);
154 return chan << bf->
offset;
157 static int gx1fb_setcolreg(
unsigned regno,
unsigned red,
unsigned green,
163 if (info->
var.grayscale) {
165 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
176 v = chan_to_field(red, &info->
var.red);
177 v |= chan_to_field(green, &info->
var.green);
178 v |= chan_to_field(blue, &info->
var.blue);
185 par->
dc_ops->set_palette_reg(info, regno, red, green, blue);
191 static int gx1fb_blank(
int blank_mode,
struct fb_info *info)
195 return par->
vid_ops->blank_display(info, blank_mode);
228 info->
fix.smem_start = gx_base + 0x800000;
229 info->
fix.smem_len = fb_len;
234 dev_info(&dev->
dev,
"%d Kibyte of video memory at 0x%lx\n",
235 info->
fix.smem_len / 1024, info->
fix.smem_start);
240 static int parse_panel_option(
struct fb_info *info)
244 if (
strcmp(panel_option,
"") != 0) {
259 static struct fb_ops gx1fb_ops = {
261 .fb_check_var = gx1fb_check_var,
262 .fb_set_par = gx1fb_set_par,
263 .fb_setcolreg = gx1fb_setcolreg,
264 .fb_blank = gx1fb_blank,
286 info->
fix.type_aux = 0;
287 info->
fix.xpanstep = 0;
288 info->
fix.ypanstep = 0;
289 info->
fix.ywrapstep = 0;
292 info->
var.nonstd = 0;
294 info->
var.height = -1;
295 info->
var.width = -1;
296 info->
var.accel_flags = 0;
299 info->
fbops = &gx1fb_ops;
305 info->
var.grayscale = 0;
309 if (parse_panel_option(info) < 0)
327 info = gx1fb_init_fbinfo(&pdev->
dev);
336 if ((ret = gx1fb_map_video_memory(info, pdev)) < 0) {
337 dev_err(&pdev->
dev,
"failed to map frame buffer or controller registers\n");
343 if (ret == 0 || ret == 4) {
344 dev_err(&pdev->
dev,
"could not find valid video mode\n");
352 gx1fb_check_var(&info->
var, info);
359 pci_set_drvdata(pdev, info);
387 struct fb_info *info = pci_get_drvdata(pdev);
402 pci_set_drvdata(pdev,
NULL);
412 if (!options || !*options)
415 while ((this_opt =
strsep(&options,
","))) {
419 if (!
strncmp(this_opt,
"mode:", 5))
420 strlcpy(mode_option, this_opt + 5,
sizeof(mode_option));
421 else if (!
strncmp(this_opt,
"crt:", 4))
423 else if (!
strncmp(this_opt,
"panel:", 6))
424 strlcpy(panel_option, this_opt + 6,
sizeof(panel_option));
426 strlcpy(mode_option, this_opt,
sizeof(mode_option));
442 .id_table = gx1fb_id_table,
443 .probe = gx1fb_probe,
447 static int __init gx1fb_init(
void)
456 return pci_register_driver(&gx1fb_driver);
459 static void __devexit gx1fb_cleanup(
void)