aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@googlemail.com>2011-09-30 14:49:43 -0400
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2011-10-03 11:52:38 -0400
commitd121c3f3cedb84601ee4839d6a6c33d1e9240cc9 (patch)
treebaf74aef41dfde303bb44b9d6ee1de50c6e17fe7 /drivers/video
parent8b53b7fb57e1ce3441b1a32f8374874b53c4bc31 (diff)
fb: fix au1100fb bitrot.
Removes some bitrot from the au1100fb driver and fix it up so it works again. Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com> Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/au1100fb.c181
-rw-r--r--drivers/video/au1100fb.h6
2 files changed, 61 insertions, 126 deletions
diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
index 01a8fde67f20..649cb35de4ed 100644
--- a/drivers/video/au1100fb.c
+++ b/drivers/video/au1100fb.c
@@ -110,12 +110,6 @@ static struct fb_var_screeninfo au1100fb_var __devinitdata = {
110 .vmode = FB_VMODE_NONINTERLACED, 110 .vmode = FB_VMODE_NONINTERLACED,
111}; 111};
112 112
113static struct au1100fb_drv_info drv_info;
114
115static int nocursor = 0;
116module_param(nocursor, int, 0644);
117MODULE_PARM_DESC(nocursor, "cursor enable/disable");
118
119/* fb_blank 113/* fb_blank
120 * Blank the screen. Depending on the mode, the screen will be 114 * Blank the screen. Depending on the mode, the screen will be
121 * activated with the backlight color, or desactivated 115 * activated with the backlight color, or desactivated
@@ -132,7 +126,7 @@ static int au1100fb_fb_blank(int blank_mode, struct fb_info *fbi)
132 /* Turn on panel */ 126 /* Turn on panel */
133 fbdev->regs->lcd_control |= LCD_CONTROL_GO; 127 fbdev->regs->lcd_control |= LCD_CONTROL_GO;
134#ifdef CONFIG_MIPS_PB1100 128#ifdef CONFIG_MIPS_PB1100
135 if (drv_info.panel_idx == 1) { 129 if (fbdev->panel_idx == 1) {
136 au_writew(au_readw(PB1100_G_CONTROL) 130 au_writew(au_readw(PB1100_G_CONTROL)
137 | (PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD), 131 | (PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD),
138 PB1100_G_CONTROL); 132 PB1100_G_CONTROL);
@@ -147,7 +141,7 @@ static int au1100fb_fb_blank(int blank_mode, struct fb_info *fbi)
147 /* Turn off panel */ 141 /* Turn off panel */
148 fbdev->regs->lcd_control &= ~LCD_CONTROL_GO; 142 fbdev->regs->lcd_control &= ~LCD_CONTROL_GO;
149#ifdef CONFIG_MIPS_PB1100 143#ifdef CONFIG_MIPS_PB1100
150 if (drv_info.panel_idx == 1) { 144 if (fbdev->panel_idx == 1) {
151 au_writew(au_readw(PB1100_G_CONTROL) 145 au_writew(au_readw(PB1100_G_CONTROL)
152 & ~(PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD), 146 & ~(PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD),
153 PB1100_G_CONTROL); 147 PB1100_G_CONTROL);
@@ -428,17 +422,6 @@ int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)
428 return 0; 422 return 0;
429} 423}
430 424
431/* fb_cursor
432 * Used to disable cursor drawing...
433 */
434int au1100fb_fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
435{
436 if (nocursor)
437 return 0;
438 else
439 return -EINVAL; /* just to force soft_cursor() call */
440}
441
442static struct fb_ops au1100fb_ops = 425static struct fb_ops au1100fb_ops =
443{ 426{
444 .owner = THIS_MODULE, 427 .owner = THIS_MODULE,
@@ -450,13 +433,53 @@ static struct fb_ops au1100fb_ops =
450 .fb_imageblit = cfb_imageblit, 433 .fb_imageblit = cfb_imageblit,
451 .fb_rotate = au1100fb_fb_rotate, 434 .fb_rotate = au1100fb_fb_rotate,
452 .fb_mmap = au1100fb_fb_mmap, 435 .fb_mmap = au1100fb_fb_mmap,
453 .fb_cursor = au1100fb_fb_cursor,
454}; 436};
455 437
456 438
457/*-------------------------------------------------------------------------*/ 439/*-------------------------------------------------------------------------*/
458 440
459/* AU1100 LCD controller device driver */ 441static int au1100fb_setup(struct au1100fb_device *fbdev)
442{
443 char *this_opt, *options;
444 int num_panels = ARRAY_SIZE(known_lcd_panels);
445
446 if (num_panels <= 0) {
447 print_err("No LCD panels supported by driver!");
448 return -ENODEV;
449 }
450
451 if (fb_get_options(DRIVER_NAME, &options))
452 return -ENODEV;
453 if (!options)
454 return -ENODEV;
455
456 while ((this_opt = strsep(&options, ",")) != NULL) {
457 /* Panel option */
458 if (!strncmp(this_opt, "panel:", 6)) {
459 int i;
460 this_opt += 6;
461 for (i = 0; i < num_panels; i++) {
462 if (!strncmp(this_opt, known_lcd_panels[i].name,
463 strlen(this_opt))) {
464 fbdev->panel = &known_lcd_panels[i];
465 fbdev->panel_idx = i;
466 break;
467 }
468 }
469 if (i >= num_panels) {
470 print_warn("Panel '%s' not supported!", this_opt);
471 return -ENODEV;
472 }
473 }
474 /* Unsupported option */
475 else
476 print_warn("Unsupported option \"%s\"", this_opt);
477 }
478
479 print_info("Panel=%s", fbdev->panel->name);
480
481 return 0;
482}
460 483
461static int __devinit au1100fb_drv_probe(struct platform_device *dev) 484static int __devinit au1100fb_drv_probe(struct platform_device *dev)
462{ 485{
@@ -465,22 +488,21 @@ static int __devinit au1100fb_drv_probe(struct platform_device *dev)
465 unsigned long page; 488 unsigned long page;
466 u32 sys_clksrc; 489 u32 sys_clksrc;
467 490
468 if (!dev)
469 return -EINVAL;
470
471 /* Allocate new device private */ 491 /* Allocate new device private */
472 if (!(fbdev = kzalloc(sizeof(struct au1100fb_device), GFP_KERNEL))) { 492 fbdev = kzalloc(sizeof(struct au1100fb_device), GFP_KERNEL);
493 if (!fbdev) {
473 print_err("fail to allocate device private record"); 494 print_err("fail to allocate device private record");
474 return -ENOMEM; 495 return -ENOMEM;
475 } 496 }
476 497
477 fbdev->panel = &known_lcd_panels[drv_info.panel_idx]; 498 if (au1100fb_setup(fbdev))
499 goto failed;
478 500
479 platform_set_drvdata(dev, (void *)fbdev); 501 platform_set_drvdata(dev, (void *)fbdev);
480 502
481 /* Allocate region for our registers and map them */ 503 /* Allocate region for our registers and map them */
482 if (!(regs_res = platform_get_resource(to_platform_device(dev), 504 regs_res = platform_get_resource(dev, IORESOURCE_MEM, 0);
483 IORESOURCE_MEM, 0))) { 505 if (!regs_res) {
484 print_err("fail to retrieve registers resource"); 506 print_err("fail to retrieve registers resource");
485 return -EFAULT; 507 return -EFAULT;
486 } 508 }
@@ -500,13 +522,11 @@ static int __devinit au1100fb_drv_probe(struct platform_device *dev)
500 print_dbg("Register memory map at %p", fbdev->regs); 522 print_dbg("Register memory map at %p", fbdev->regs);
501 print_dbg("phys=0x%08x, size=%d", fbdev->regs_phys, fbdev->regs_len); 523 print_dbg("phys=0x%08x, size=%d", fbdev->regs_phys, fbdev->regs_len);
502 524
503
504
505 /* Allocate the framebuffer to the maximum screen size * nbr of video buffers */ 525 /* Allocate the framebuffer to the maximum screen size * nbr of video buffers */
506 fbdev->fb_len = fbdev->panel->xres * fbdev->panel->yres * 526 fbdev->fb_len = fbdev->panel->xres * fbdev->panel->yres *
507 (fbdev->panel->bpp >> 3) * AU1100FB_NBR_VIDEO_BUFFERS; 527 (fbdev->panel->bpp >> 3) * AU1100FB_NBR_VIDEO_BUFFERS;
508 528
509 fbdev->fb_mem = dma_alloc_coherent(dev, PAGE_ALIGN(fbdev->fb_len), 529 fbdev->fb_mem = dma_alloc_coherent(&dev->dev, PAGE_ALIGN(fbdev->fb_len),
510 &fbdev->fb_phys, GFP_KERNEL); 530 &fbdev->fb_phys, GFP_KERNEL);
511 if (!fbdev->fb_mem) { 531 if (!fbdev->fb_mem) {
512 print_err("fail to allocate frambuffer (size: %dK))", 532 print_err("fail to allocate frambuffer (size: %dK))",
@@ -525,7 +545,7 @@ static int __devinit au1100fb_drv_probe(struct platform_device *dev)
525 page < PAGE_ALIGN((unsigned long)fbdev->fb_mem + fbdev->fb_len); 545 page < PAGE_ALIGN((unsigned long)fbdev->fb_mem + fbdev->fb_len);
526 page += PAGE_SIZE) { 546 page += PAGE_SIZE) {
527#if CONFIG_DMA_NONCOHERENT 547#if CONFIG_DMA_NONCOHERENT
528 SetPageReserved(virt_to_page(CAC_ADDR(page))); 548 SetPageReserved(virt_to_page(CAC_ADDR((void *)page)));
529#else 549#else
530 SetPageReserved(virt_to_page(page)); 550 SetPageReserved(virt_to_page(page));
531#endif 551#endif
@@ -578,7 +598,8 @@ failed:
578 release_mem_region(fbdev->regs_phys, fbdev->regs_len); 598 release_mem_region(fbdev->regs_phys, fbdev->regs_len);
579 } 599 }
580 if (fbdev->fb_mem) { 600 if (fbdev->fb_mem) {
581 dma_free_noncoherent(dev, fbdev->fb_len, fbdev->fb_mem, fbdev->fb_phys); 601 dma_free_noncoherent(&dev->dev, fbdev->fb_len, fbdev->fb_mem,
602 fbdev->fb_phys);
582 } 603 }
583 if (fbdev->info.cmap.len != 0) { 604 if (fbdev->info.cmap.len != 0) {
584 fb_dealloc_cmap(&fbdev->info.cmap); 605 fb_dealloc_cmap(&fbdev->info.cmap);
@@ -608,7 +629,8 @@ int au1100fb_drv_remove(struct platform_device *dev)
608 629
609 release_mem_region(fbdev->regs_phys, fbdev->regs_len); 630 release_mem_region(fbdev->regs_phys, fbdev->regs_len);
610 631
611 dma_free_coherent(dev, PAGE_ALIGN(fbdev->fb_len), fbdev->fb_mem, fbdev->fb_phys); 632 dma_free_coherent(&dev->dev, PAGE_ALIGN(fbdev->fb_len), fbdev->fb_mem,
633 fbdev->fb_phys);
612 634
613 fb_dealloc_cmap(&fbdev->info.cmap); 635 fb_dealloc_cmap(&fbdev->info.cmap);
614 kfree(fbdev->info.pseudo_palette); 636 kfree(fbdev->info.pseudo_palette);
@@ -675,101 +697,18 @@ static struct platform_driver au1100fb_driver = {
675 .resume = au1100fb_drv_resume, 697 .resume = au1100fb_drv_resume,
676}; 698};
677 699
678/*-------------------------------------------------------------------------*/ 700static int __init au1100fb_load(void)
679
680/* Kernel driver */
681
682int au1100fb_setup(char *options)
683{
684 char* this_opt;
685 int num_panels = ARRAY_SIZE(known_lcd_panels);
686 char* mode = NULL;
687 int panel_idx = 0;
688
689 if (num_panels <= 0) {
690 print_err("No LCD panels supported by driver!");
691 return -EFAULT;
692 }
693
694 if (options) {
695 while ((this_opt = strsep(&options,",")) != NULL) {
696 /* Panel option */
697 if (!strncmp(this_opt, "panel:", 6)) {
698 int i;
699 this_opt += 6;
700 for (i = 0; i < num_panels; i++) {
701 if (!strncmp(this_opt,
702 known_lcd_panels[i].name,
703 strlen(this_opt))) {
704 panel_idx = i;
705 break;
706 }
707 }
708 if (i >= num_panels) {
709 print_warn("Panel %s not supported!", this_opt);
710 }
711 }
712 if (!strncmp(this_opt, "nocursor", 8)) {
713 this_opt += 8;
714 nocursor = 1;
715 print_info("Cursor disabled");
716 }
717 /* Mode option (only option that start with digit) */
718 else if (isdigit(this_opt[0])) {
719 mode = kstrdup(this_opt, GFP_KERNEL);
720 if (!mode) {
721 print_err("memory allocation failed");
722 return -ENOMEM;
723 }
724 }
725 /* Unsupported option */
726 else {
727 print_warn("Unsupported option \"%s\"", this_opt);
728 }
729 }
730 }
731
732 drv_info.panel_idx = panel_idx;
733 drv_info.opt_mode = mode;
734
735 print_info("Panel=%s Mode=%s",
736 known_lcd_panels[drv_info.panel_idx].name,
737 drv_info.opt_mode ? drv_info.opt_mode : "default");
738
739 return 0;
740}
741
742int __init au1100fb_init(void)
743{ 701{
744 char* options;
745 int ret;
746
747 print_info("" DRIVER_DESC "");
748
749 memset(&drv_info, 0, sizeof(drv_info));
750
751 if (fb_get_options(DRIVER_NAME, &options))
752 return -ENODEV;
753
754 /* Setup driver with options */
755 ret = au1100fb_setup(options);
756 if (ret < 0) {
757 print_err("Fail to setup driver");
758 return ret;
759 }
760
761 return platform_driver_register(&au1100fb_driver); 702 return platform_driver_register(&au1100fb_driver);
762} 703}
763 704
764void __exit au1100fb_cleanup(void) 705static void __exit au1100fb_unload(void)
765{ 706{
766 platform_driver_unregister(&au1100fb_driver); 707 platform_driver_unregister(&au1100fb_driver);
767
768 kfree(drv_info.opt_mode);
769} 708}
770 709
771module_init(au1100fb_init); 710module_init(au1100fb_load);
772module_exit(au1100fb_cleanup); 711module_exit(au1100fb_unload);
773 712
774MODULE_DESCRIPTION(DRIVER_DESC); 713MODULE_DESCRIPTION(DRIVER_DESC);
775MODULE_LICENSE("GPL"); 714MODULE_LICENSE("GPL");
diff --git a/drivers/video/au1100fb.h b/drivers/video/au1100fb.h
index 164fe2f231ec..12d9642d5465 100644
--- a/drivers/video/au1100fb.h
+++ b/drivers/video/au1100fb.h
@@ -108,6 +108,7 @@ struct au1100fb_device {
108 unsigned char* fb_mem; /* FrameBuffer memory map */ 108 unsigned char* fb_mem; /* FrameBuffer memory map */
109 size_t fb_len; 109 size_t fb_len;
110 dma_addr_t fb_phys; 110 dma_addr_t fb_phys;
111 int panel_idx;
111}; 112};
112 113
113/********************************************************************/ 114/********************************************************************/
@@ -364,11 +365,6 @@ static struct au1100fb_panel known_lcd_panels[] =
364 }, 365 },
365}; 366};
366 367
367struct au1100fb_drv_info {
368 int panel_idx;
369 char *opt_mode;
370};
371
372/********************************************************************/ 368/********************************************************************/
373 369
374/* Inline helpers */ 370/* Inline helpers */