offb.c (0aea30a07ec6b50de0fc5f5b2ec34a68ead86b61) offb.c (52b1b46c39ae4321459a1a28dd4e596497b375b8)
1/*
2 * linux/drivers/video/offb.c -- Open Firmware based frame buffer device
3 *
4 * Copyright (C) 1997 Geert Uytterhoeven
5 *
6 * This driver is partly based on the PowerMac console driver:
7 *
8 * Copyright (C) 1996 Paul Mackerras

--- 372 unchanged lines hidden (view full) ---

381 par->cmap_data = par->cmap_adr + 1;
382 }
383 }
384 }
385 info->fix.visual = (par->cmap_type != cmap_unknown) ?
386 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_STATIC_PSEUDOCOLOR;
387}
388
1/*
2 * linux/drivers/video/offb.c -- Open Firmware based frame buffer device
3 *
4 * Copyright (C) 1997 Geert Uytterhoeven
5 *
6 * This driver is partly based on the PowerMac console driver:
7 *
8 * Copyright (C) 1996 Paul Mackerras

--- 372 unchanged lines hidden (view full) ---

381 par->cmap_data = par->cmap_adr + 1;
382 }
383 }
384 }
385 info->fix.visual = (par->cmap_type != cmap_unknown) ?
386 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_STATIC_PSEUDOCOLOR;
387}
388
389static void __init offb_init_fb(const char *name,
390 int width, int height, int depth,
391 int pitch, unsigned long address,
392 int foreign_endian, struct device_node *dp)
389static void offb_init_fb(struct platform_device *parent, const char *name,
390 int width, int height, int depth,
391 int pitch, unsigned long address,
392 int foreign_endian, struct device_node *dp)
393{
394 unsigned long res_size = pitch * height;
395 struct offb_par *par = &default_par;
396 unsigned long res_start = address;
397 struct fb_fix_screeninfo *fix;
398 struct fb_var_screeninfo *var;
399 struct fb_info *info;
400

--- 4 unchanged lines hidden (view full) ---

405 "Using unsupported %dx%d %s at %lx, depth=%d, pitch=%d\n",
406 width, height, name, address, depth, pitch);
407 if (depth != 8 && depth != 15 && depth != 16 && depth != 32) {
408 printk(KERN_ERR "%pOF: can't use depth = %d\n", dp, depth);
409 release_mem_region(res_start, res_size);
410 return;
411 }
412
393{
394 unsigned long res_size = pitch * height;
395 struct offb_par *par = &default_par;
396 unsigned long res_start = address;
397 struct fb_fix_screeninfo *fix;
398 struct fb_var_screeninfo *var;
399 struct fb_info *info;
400

--- 4 unchanged lines hidden (view full) ---

405 "Using unsupported %dx%d %s at %lx, depth=%d, pitch=%d\n",
406 width, height, name, address, depth, pitch);
407 if (depth != 8 && depth != 15 && depth != 16 && depth != 32) {
408 printk(KERN_ERR "%pOF: can't use depth = %d\n", dp, depth);
409 release_mem_region(res_start, res_size);
410 return;
411 }
412
413 info = framebuffer_alloc(sizeof(u32) * 16, NULL);
413 info = framebuffer_alloc(sizeof(u32) * 16, &parent->dev);
414
415 if (!info) {
416 release_mem_region(res_start, res_size);
417 return;
418 }
414
415 if (!info) {
416 release_mem_region(res_start, res_size);
417 return;
418 }
419 platform_set_drvdata(parent, info);
419
420 fix = &info->fix;
421 var = &info->var;
422 info->par = par;
423
424 if (name) {
425 strcpy(fix->id, "OFfb ");
426 strncat(fix->id, name, sizeof(fix->id) - sizeof("OFfb "));

--- 103 unchanged lines hidden (view full) ---

530out_aper:
531 iounmap(par->cmap_adr);
532 par->cmap_adr = NULL;
533 framebuffer_release(info);
534 release_mem_region(res_start, res_size);
535}
536
537
420
421 fix = &info->fix;
422 var = &info->var;
423 info->par = par;
424
425 if (name) {
426 strcpy(fix->id, "OFfb ");
427 strncat(fix->id, name, sizeof(fix->id) - sizeof("OFfb "));

--- 103 unchanged lines hidden (view full) ---

531out_aper:
532 iounmap(par->cmap_adr);
533 par->cmap_adr = NULL;
534 framebuffer_release(info);
535 release_mem_region(res_start, res_size);
536}
537
538
538static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
539static void offb_init_nodriver(struct platform_device *parent, struct device_node *dp,
540 int no_real_node)
539{
540 unsigned int len;
541 int i, width = 640, height = 480, depth = 8, pitch = 640;
542 unsigned int flags, rsize, addr_prop = 0;
543 unsigned long max_size = 0;
544 u64 rstart, address = OF_BAD_ADDR;
545 const __be32 *pp, *addrp, *up;
546 u64 asize;

--- 98 unchanged lines hidden (view full) ---

645 pdev = pci_get_device(vid, did, NULL);
646 if (!pdev || pci_enable_device(pdev))
647 return;
648 }
649#endif
650 /* kludge for valkyrie */
651 if (of_node_name_eq(dp, "valkyrie"))
652 address += 0x1000;
541{
542 unsigned int len;
543 int i, width = 640, height = 480, depth = 8, pitch = 640;
544 unsigned int flags, rsize, addr_prop = 0;
545 unsigned long max_size = 0;
546 u64 rstart, address = OF_BAD_ADDR;
547 const __be32 *pp, *addrp, *up;
548 u64 asize;

--- 98 unchanged lines hidden (view full) ---

647 pdev = pci_get_device(vid, did, NULL);
648 if (!pdev || pci_enable_device(pdev))
649 return;
650 }
651#endif
652 /* kludge for valkyrie */
653 if (of_node_name_eq(dp, "valkyrie"))
654 address += 0x1000;
653 offb_init_fb(no_real_node ? "bootx" : NULL,
655 offb_init_fb(parent, no_real_node ? "bootx" : NULL,
654 width, height, depth, pitch, address,
655 foreign_endian, no_real_node ? NULL : dp);
656 }
657}
658
656 width, height, depth, pitch, address,
657 foreign_endian, no_real_node ? NULL : dp);
658 }
659}
660
659static int __init offb_init(void)
661static int offb_remove(struct platform_device *pdev)
660{
662{
661 struct device_node *dp = NULL, *boot_disp = NULL;
663 struct fb_info *info = platform_get_drvdata(pdev);
662
664
663 if (fb_get_options("offb", NULL))
664 return -ENODEV;
665 if (info)
666 unregister_framebuffer(info);
665
667
666 /* Check if we have a MacOS display without a node spec */
667 if (of_get_property(of_chosen, "linux,bootx-noscreen", NULL) != NULL) {
668 /* The old code tried to work out which node was the MacOS
669 * display based on the address. I'm dropping that since the
670 * lack of a node spec only happens with old BootX versions
671 * (users can update) and with this code, they'll still get
672 * a display (just not the palette hacks).
673 */
674 offb_init_nodriver(of_chosen, 1);
675 }
668 return 0;
669}
676
670
677 for_each_node_by_type(dp, "display") {
678 if (of_get_property(dp, "linux,opened", NULL) &&
679 of_get_property(dp, "linux,boot-display", NULL)) {
680 boot_disp = dp;
681 offb_init_nodriver(dp, 0);
682 }
683 }
684 for_each_node_by_type(dp, "display") {
685 if (of_get_property(dp, "linux,opened", NULL) &&
686 dp != boot_disp)
687 offb_init_nodriver(dp, 0);
688 }
671static int offb_probe_bootx_noscreen(struct platform_device *pdev)
672{
673 offb_init_nodriver(pdev, of_chosen, 1);
689
690 return 0;
691}
692
674
675 return 0;
676}
677
678static struct platform_driver offb_driver_bootx_noscreen = {
679 .driver = {
680 .name = "bootx-noscreen",
681 },
682 .probe = offb_probe_bootx_noscreen,
683 .remove = offb_remove,
684};
693
685
686static int offb_probe_display(struct platform_device *pdev)
687{
688 offb_init_nodriver(pdev, pdev->dev.of_node, 0);
689
690 return 0;
691}
692
693static const struct of_device_id offb_of_match_display[] = {
694 { .compatible = "display", },
695 { },
696};
697MODULE_DEVICE_TABLE(of, offb_of_match_display);
698
699static struct platform_driver offb_driver_display = {
700 .driver = {
701 .name = "of-display",
702 .of_match_table = offb_of_match_display,
703 },
704 .probe = offb_probe_display,
705 .remove = offb_remove,
706};
707
708static int __init offb_init(void)
709{
710 if (fb_get_options("offb", NULL))
711 return -ENODEV;
712
713 platform_driver_register(&offb_driver_bootx_noscreen);
714 platform_driver_register(&offb_driver_display);
715
716 return 0;
717}
694module_init(offb_init);
718module_init(offb_init);
719
720static void __exit offb_exit(void)
721{
722 platform_driver_unregister(&offb_driver_display);
723 platform_driver_unregister(&offb_driver_bootx_noscreen);
724}
725module_exit(offb_exit);
726
695MODULE_LICENSE("GPL");
727MODULE_LICENSE("GPL");