10 #include <linux/errno.h>
13 #include <linux/pci.h>
14 #include <linux/slab.h>
15 #include <linux/module.h>
20 #if !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN)
21 #error "The endianness of the target host has not been defined."
33 #define CARMINEFB_DEFAULT_VIDEO_MODE 1
39 static char *fb_mode_str;
132 if (car_modes[i].
hdp == var->
xres &&
138 static void c_set_disp_reg(
const struct carmine_fb *par,
162 static int carmine_setcolreg(
unsigned regno,
unsigned red,
unsigned green,
174 red << 0 | green << 8 | blue << 16);
183 ret = carmine_find_mode(var);
198 var->
green.offset = 8;
199 var->
blue.offset = 16;
202 var->
red.offset = 16;
203 var->
green.offset = 8;
204 var->
blue.offset = 0;
208 var->
green.length = 8;
209 var->
blue.length = 8;
212 var->
red.msb_right = 0;
213 var->
green.msb_right = 0;
214 var->
blue.msb_right = 0;
215 var->
transp.msb_right = 0;
219 static void carmine_init_display_param(
struct carmine_fb *par)
260 height = par->
res->vdp - 1;
274 window_size |= par->
res->hdp;
367 static void set_display_parameters(
struct carmine_fb *par)
376 hdp = par->
res->hdp - 1;
377 vdp = par->
res->vdp - 1;
378 htp = par->
res->htp - 1;
379 hsp = par->
res->hsp - 1;
380 hsw = par->
res->hsw - 1;
381 vtr = par->
res->vtr - 1;
382 vsp = par->
res->vsp - 1;
383 vsw = par->
res->vsw - 1;
407 static int carmine_set_par(
struct fb_info *info)
412 ret = carmine_find_mode(&info->
var);
422 carmine_init_display_param(par);
423 set_display_parameters(par);
426 info->
fix.line_length = info->
var.xres * info->
var.bits_per_pixel / 8;
439 CARMINE_DFLT_IP_CLOCK_ENABLE);
450 flags = CARMINE_DFLT_IP_DCTL_IO_CONT1 << 16 |
451 CARMINE_DFLT_IP_DCTL_IO_CONT0;
456 flags = CARMINE_DFLT_IP_DCTL_MODE << 16 | CARMINE_DFLT_IP_DCTL_ADD;
460 flags = CARMINE_DFLT_IP_DCTL_SET_TIME1 << 16 |
461 CARMINE_DFLT_IP_DCTL_EMODE;
465 flags = CARMINE_DFLT_IP_DCTL_REFRESH << 16 |
466 CARMINE_DFLT_IP_DCTL_SET_TIME2;
470 flags = CARMINE_DFLT_IP_DCTL_RESERVE2 << 16 |
471 CARMINE_DFLT_IP_DCTL_FIFO_DEPTH;
474 flags = CARMINE_DFLT_IP_DCTL_DDRIF2 << 16 | CARMINE_DFLT_IP_DCTL_DDRIF1;
478 flags = CARMINE_DFLT_IP_DCTL_RESERVE0 << 16 |
479 CARMINE_DFLT_IP_DCTL_STATES;
484 if (CARMINE_DCTL_DLL_RESET) {
496 if (loops >= CARMINE_DCTL_INIT_WAIT_LIMIT) {
502 flags = CARMINE_DFLT_IP_DCTL_MODE_AFT_RST << 16 |
503 CARMINE_DFLT_IP_DCTL_ADD;
506 flags = CARMINE_DFLT_IP_DCTL_RESERVE0 << 16 |
507 CARMINE_DFLT_IP_DCTL_STATES_AFT_RST;
529 static struct fb_ops carminefb_ops = {
535 .fb_check_var = carmine_check_var,
536 .fb_set_par = carmine_set_par,
537 .fb_setcolreg = carmine_setcolreg,
557 info->
fbops = &carminefb_ops;
559 info->
fix = carminefb_fix;
574 &carmine_modedb[fb_mode], 32);
575 if (!ret || ret == 4) {
577 goto err_dealloc_cmap;
585 goto err_dealloc_cmap;
600 static void cleanup_fb_device(
struct fb_info *info)
613 struct device *device = &dev->
dev;
630 carminefb_fix.mmio_len,
631 "carminefb regbase")) {
637 carminefb_fix.mmio_len);
641 goto err_free_reg_mmio;
656 "are required.", carminefb_fix.smem_len,
658 goto err_unmap_vregs;
662 carminefb_fix.smem_len,
"carminefb smem")) {
664 goto err_unmap_vregs;
668 carminefb_fix.smem_len);
674 ret = init_hardware(hw);
676 goto err_unmap_screen;
695 goto err_cleanup_fb0;
701 pci_set_drvdata(dev, hw);
705 cleanup_fb_device(hw->
fb[0]);
732 fix = hw->
fb[0]->fix;
734 fix = hw->
fb[1]->fix;
742 cleanup_fb_device(hw->
fb[i]);
749 pci_set_drvdata(dev,
NULL);
754 #define PCI_VENDOR_ID_FUJITU_LIMITED 0x10cf
755 static struct pci_device_id carmine_devices[] __devinitdata = {
758 {0, 0, 0, 0, 0, 0, 0}
763 static struct pci_driver carmine_pci_driver = {
765 .id_table = carmine_devices,
766 .probe = carminefb_probe,
770 static int __init carminefb_init(
void)
773 (CARMINE_USE_DISPLAY0 | CARMINE_USE_DISPLAY1))) {
775 "need the driver at all\n");
778 return pci_register_driver(&carmine_pci_driver);
782 static void __exit carminefb_cleanup(
void)