diff options
author | eric miao <eric.miao@marvell.com> | 2008-04-30 03:52:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 11:29:31 -0400 |
commit | 2c42dd8ebdd92ad59d9a68f88f0e20ad9f45270a (patch) | |
tree | 1013b04a3543aa1f1e1c9a2472ba15eb2e8f0cd9 /drivers/video/pxafb.c | |
parent | ce4fb7b892a6d6c6a0f87366b26fd834d2923dd7 (diff) |
pxafb: introduce "struct pxafb_dma_buff" for palette and dma descriptors
Use structure and array for palette buffer and dma descriptors to:
1. better organize code for future expansion like overlays
2. separate palette and dma descriptors from frame buffer
Signed-off-by: eric miao <eric.miao@marvell.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/pxafb.c')
-rw-r--r-- | drivers/video/pxafb.c | 132 |
1 files changed, 61 insertions, 71 deletions
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index d97dc9383d47..4e8f68b7c5b3 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c | |||
@@ -361,7 +361,6 @@ static int pxafb_set_par(struct fb_info *info) | |||
361 | { | 361 | { |
362 | struct pxafb_info *fbi = (struct pxafb_info *)info; | 362 | struct pxafb_info *fbi = (struct pxafb_info *)info; |
363 | struct fb_var_screeninfo *var = &info->var; | 363 | struct fb_var_screeninfo *var = &info->var; |
364 | unsigned long palette_mem_size; | ||
365 | 364 | ||
366 | if (var->bits_per_pixel == 16) | 365 | if (var->bits_per_pixel == 16) |
367 | fbi->fb.fix.visual = FB_VISUAL_TRUECOLOR; | 366 | fbi->fb.fix.visual = FB_VISUAL_TRUECOLOR; |
@@ -384,13 +383,7 @@ static int pxafb_set_par(struct fb_info *info) | |||
384 | fbi->palette_size = var->bits_per_pixel == 1 ? | 383 | fbi->palette_size = var->bits_per_pixel == 1 ? |
385 | 4 : 1 << var->bits_per_pixel; | 384 | 4 : 1 << var->bits_per_pixel; |
386 | 385 | ||
387 | if ((fbi->lccr4 & LCCR4_PAL_FOR_MASK) == LCCR4_PAL_FOR_0) | 386 | fbi->palette_cpu = (u16 *)&fbi->dma_buff->palette[0]; |
388 | palette_mem_size = fbi->palette_size * sizeof(u16); | ||
389 | else | ||
390 | palette_mem_size = fbi->palette_size * sizeof(u32); | ||
391 | |||
392 | fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE - palette_mem_size); | ||
393 | fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size; | ||
394 | 387 | ||
395 | /* | 388 | /* |
396 | * Set (any) board control register to handle new color depth | 389 | * Set (any) board control register to handle new color depth |
@@ -546,6 +539,48 @@ unsigned long pxafb_get_hsync_time(struct device *dev) | |||
546 | } | 539 | } |
547 | EXPORT_SYMBOL(pxafb_get_hsync_time); | 540 | EXPORT_SYMBOL(pxafb_get_hsync_time); |
548 | 541 | ||
542 | static int setup_frame_dma(struct pxafb_info *fbi, int dma, int pal, | ||
543 | unsigned int offset, size_t size) | ||
544 | { | ||
545 | struct pxafb_dma_descriptor *dma_desc, *pal_desc; | ||
546 | unsigned int dma_desc_off, pal_desc_off; | ||
547 | |||
548 | if (dma < 0 || dma >= DMA_MAX) | ||
549 | return -EINVAL; | ||
550 | |||
551 | dma_desc = &fbi->dma_buff->dma_desc[dma]; | ||
552 | dma_desc_off = offsetof(struct pxafb_dma_buff, dma_desc[dma]); | ||
553 | |||
554 | dma_desc->fsadr = fbi->screen_dma + offset; | ||
555 | dma_desc->fidr = 0; | ||
556 | dma_desc->ldcmd = size; | ||
557 | |||
558 | if (pal < 0 || pal >= PAL_MAX) { | ||
559 | dma_desc->fdadr = fbi->dma_buff_phys + dma_desc_off; | ||
560 | fbi->fdadr[dma] = fbi->dma_buff_phys + dma_desc_off; | ||
561 | } else { | ||
562 | pal_desc = &fbi->dma_buff->pal_desc[dma]; | ||
563 | pal_desc_off = offsetof(struct pxafb_dma_buff, dma_desc[pal]); | ||
564 | |||
565 | pal_desc->fsadr = fbi->dma_buff_phys + pal * PALETTE_SIZE; | ||
566 | pal_desc->fidr = 0; | ||
567 | |||
568 | if ((fbi->lccr4 & LCCR4_PAL_FOR_MASK) == LCCR4_PAL_FOR_0) | ||
569 | pal_desc->ldcmd = fbi->palette_size * sizeof(u16); | ||
570 | else | ||
571 | pal_desc->ldcmd = fbi->palette_size * sizeof(u32); | ||
572 | |||
573 | pal_desc->ldcmd |= LDCMD_PAL; | ||
574 | |||
575 | /* flip back and forth between palette and frame buffer */ | ||
576 | pal_desc->fdadr = fbi->dma_buff_phys + dma_desc_off; | ||
577 | dma_desc->fdadr = fbi->dma_buff_phys + pal_desc_off; | ||
578 | fbi->fdadr[dma] = fbi->dma_buff_phys + dma_desc_off; | ||
579 | } | ||
580 | |||
581 | return 0; | ||
582 | } | ||
583 | |||
549 | /* | 584 | /* |
550 | * pxafb_activate_var(): | 585 | * pxafb_activate_var(): |
551 | * Configures LCD Controller based on entries in var parameter. | 586 | * Configures LCD Controller based on entries in var parameter. |
@@ -557,6 +592,7 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, | |||
557 | struct pxafb_lcd_reg new_regs; | 592 | struct pxafb_lcd_reg new_regs; |
558 | u_long flags; | 593 | u_long flags; |
559 | u_int lines_per_panel, pcd = get_pcd(fbi, var->pixclock); | 594 | u_int lines_per_panel, pcd = get_pcd(fbi, var->pixclock); |
595 | size_t nbytes; | ||
560 | 596 | ||
561 | #if DEBUG_VAR | 597 | #if DEBUG_VAR |
562 | if (var->xres < 16 || var->xres > 1024) | 598 | if (var->xres < 16 || var->xres > 1024) |
@@ -634,54 +670,15 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, | |||
634 | /* Update shadow copy atomically */ | 670 | /* Update shadow copy atomically */ |
635 | local_irq_save(flags); | 671 | local_irq_save(flags); |
636 | 672 | ||
637 | /* setup dma descriptors */ | 673 | nbytes = lines_per_panel * fbi->fb.fix.line_length; |
638 | fbi->dmadesc_fblow_cpu = (struct pxafb_dma_descriptor *) | ||
639 | ((unsigned int)fbi->palette_cpu - 3*16); | ||
640 | fbi->dmadesc_fbhigh_cpu = (struct pxafb_dma_descriptor *) | ||
641 | ((unsigned int)fbi->palette_cpu - 2*16); | ||
642 | fbi->dmadesc_palette_cpu = (struct pxafb_dma_descriptor *) | ||
643 | ((unsigned int)fbi->palette_cpu - 1*16); | ||
644 | |||
645 | fbi->dmadesc_fblow_dma = fbi->palette_dma - 3*16; | ||
646 | fbi->dmadesc_fbhigh_dma = fbi->palette_dma - 2*16; | ||
647 | fbi->dmadesc_palette_dma = fbi->palette_dma - 1*16; | ||
648 | |||
649 | #define BYTES_PER_PANEL (lines_per_panel * fbi->fb.fix.line_length) | ||
650 | |||
651 | /* populate descriptors */ | ||
652 | fbi->dmadesc_fblow_cpu->fdadr = fbi->dmadesc_fblow_dma; | ||
653 | fbi->dmadesc_fblow_cpu->fsadr = fbi->screen_dma + BYTES_PER_PANEL; | ||
654 | fbi->dmadesc_fblow_cpu->fidr = 0; | ||
655 | fbi->dmadesc_fblow_cpu->ldcmd = BYTES_PER_PANEL; | ||
656 | |||
657 | fbi->fdadr1 = fbi->dmadesc_fblow_dma; /* only used in dual-panel mode */ | ||
658 | |||
659 | fbi->dmadesc_fbhigh_cpu->fsadr = fbi->screen_dma; | ||
660 | fbi->dmadesc_fbhigh_cpu->fidr = 0; | ||
661 | fbi->dmadesc_fbhigh_cpu->ldcmd = BYTES_PER_PANEL; | ||
662 | |||
663 | fbi->dmadesc_palette_cpu->fsadr = fbi->palette_dma; | ||
664 | fbi->dmadesc_palette_cpu->fidr = 0; | ||
665 | if ((fbi->lccr4 & LCCR4_PAL_FOR_MASK) == LCCR4_PAL_FOR_0) | ||
666 | fbi->dmadesc_palette_cpu->ldcmd = fbi->palette_size * | ||
667 | sizeof(u16); | ||
668 | else | ||
669 | fbi->dmadesc_palette_cpu->ldcmd = fbi->palette_size * | ||
670 | sizeof(u32); | ||
671 | fbi->dmadesc_palette_cpu->ldcmd |= LDCMD_PAL; | ||
672 | 674 | ||
673 | if (var->bits_per_pixel == 16) { | 675 | if ((fbi->lccr0 & LCCR0_SDS) == LCCR0_Dual) |
674 | /* palette shouldn't be loaded in true-color mode */ | 676 | setup_frame_dma(fbi, DMA_LOWER, PAL_NONE, nbytes, nbytes); |
675 | fbi->dmadesc_fbhigh_cpu->fdadr = fbi->dmadesc_fbhigh_dma; | 677 | |
676 | fbi->fdadr0 = fbi->dmadesc_fbhigh_dma; /* no pal just fbhigh */ | 678 | if (var->bits_per_pixel >= 16) |
677 | /* init it to something, even though we won't be using it */ | 679 | setup_frame_dma(fbi, DMA_BASE, PAL_NONE, 0, nbytes); |
678 | fbi->dmadesc_palette_cpu->fdadr = fbi->dmadesc_palette_dma; | 680 | else |
679 | } else { | 681 | setup_frame_dma(fbi, DMA_BASE, PAL_BASE, 0, nbytes); |
680 | /* flips back and forth between pal and fbhigh */ | ||
681 | fbi->dmadesc_palette_cpu->fdadr = fbi->dmadesc_fbhigh_dma; | ||
682 | fbi->dmadesc_fbhigh_cpu->fdadr = fbi->dmadesc_palette_dma; | ||
683 | fbi->fdadr0 = fbi->dmadesc_palette_dma; | ||
684 | } | ||
685 | 682 | ||
686 | fbi->reg_lccr0 = new_regs.lccr0; | 683 | fbi->reg_lccr0 = new_regs.lccr0; |
687 | fbi->reg_lccr1 = new_regs.lccr1; | 684 | fbi->reg_lccr1 = new_regs.lccr1; |
@@ -701,8 +698,8 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, | |||
701 | (__raw_readl(fbi->mmio_base + LCCR1) != fbi->reg_lccr1) || | 698 | (__raw_readl(fbi->mmio_base + LCCR1) != fbi->reg_lccr1) || |
702 | (__raw_readl(fbi->mmio_base + LCCR2) != fbi->reg_lccr2) || | 699 | (__raw_readl(fbi->mmio_base + LCCR2) != fbi->reg_lccr2) || |
703 | (__raw_readl(fbi->mmio_base + LCCR3) != fbi->reg_lccr3) || | 700 | (__raw_readl(fbi->mmio_base + LCCR3) != fbi->reg_lccr3) || |
704 | (__raw_readl(fbi->mmio_base + FDADR0) != fbi->fdadr0) || | 701 | (__raw_readl(fbi->mmio_base + FDADR0) != fbi->fdadr[0]) || |
705 | (__raw_readl(fbi->mmio_base + FDADR1) != fbi->fdadr1)) | 702 | (__raw_readl(fbi->mmio_base + FDADR1) != fbi->fdadr[1])) |
706 | pxafb_schedule_work(fbi, C_REENABLE); | 703 | pxafb_schedule_work(fbi, C_REENABLE); |
707 | 704 | ||
708 | return 0; | 705 | return 0; |
@@ -777,8 +774,8 @@ static void pxafb_setup_gpio(struct pxafb_info *fbi) | |||
777 | static void pxafb_enable_controller(struct pxafb_info *fbi) | 774 | static void pxafb_enable_controller(struct pxafb_info *fbi) |
778 | { | 775 | { |
779 | pr_debug("pxafb: Enabling LCD controller\n"); | 776 | pr_debug("pxafb: Enabling LCD controller\n"); |
780 | pr_debug("fdadr0 0x%08x\n", (unsigned int) fbi->fdadr0); | 777 | pr_debug("fdadr0 0x%08x\n", (unsigned int) fbi->fdadr[0]); |
781 | pr_debug("fdadr1 0x%08x\n", (unsigned int) fbi->fdadr1); | 778 | pr_debug("fdadr1 0x%08x\n", (unsigned int) fbi->fdadr[1]); |
782 | pr_debug("reg_lccr0 0x%08x\n", (unsigned int) fbi->reg_lccr0); | 779 | pr_debug("reg_lccr0 0x%08x\n", (unsigned int) fbi->reg_lccr0); |
783 | pr_debug("reg_lccr1 0x%08x\n", (unsigned int) fbi->reg_lccr1); | 780 | pr_debug("reg_lccr1 0x%08x\n", (unsigned int) fbi->reg_lccr1); |
784 | pr_debug("reg_lccr2 0x%08x\n", (unsigned int) fbi->reg_lccr2); | 781 | pr_debug("reg_lccr2 0x%08x\n", (unsigned int) fbi->reg_lccr2); |
@@ -793,8 +790,8 @@ static void pxafb_enable_controller(struct pxafb_info *fbi) | |||
793 | __raw_writel(fbi->reg_lccr1, fbi->mmio_base + LCCR1); | 790 | __raw_writel(fbi->reg_lccr1, fbi->mmio_base + LCCR1); |
794 | __raw_writel(fbi->reg_lccr0 & ~LCCR0_ENB, fbi->mmio_base + LCCR0); | 791 | __raw_writel(fbi->reg_lccr0 & ~LCCR0_ENB, fbi->mmio_base + LCCR0); |
795 | 792 | ||
796 | __raw_writel(fbi->fdadr0, fbi->mmio_base + FDADR0); | 793 | __raw_writel(fbi->fdadr[0], fbi->mmio_base + FDADR0); |
797 | __raw_writel(fbi->fdadr1, fbi->mmio_base + FDADR1); | 794 | __raw_writel(fbi->fdadr[1], fbi->mmio_base + FDADR1); |
798 | __raw_writel(fbi->reg_lccr0 | LCCR0_ENB, fbi->mmio_base + LCCR0); | 795 | __raw_writel(fbi->reg_lccr0 | LCCR0_ENB, fbi->mmio_base + LCCR0); |
799 | } | 796 | } |
800 | 797 | ||
@@ -1038,8 +1035,6 @@ static int pxafb_resume(struct platform_device *dev) | |||
1038 | */ | 1035 | */ |
1039 | static int __init pxafb_map_video_memory(struct pxafb_info *fbi) | 1036 | static int __init pxafb_map_video_memory(struct pxafb_info *fbi) |
1040 | { | 1037 | { |
1041 | u_long palette_mem_size; | ||
1042 | |||
1043 | /* | 1038 | /* |
1044 | * We reserve one page for the palette, plus the size | 1039 | * We reserve one page for the palette, plus the size |
1045 | * of the framebuffer. | 1040 | * of the framebuffer. |
@@ -1062,14 +1057,9 @@ static int __init pxafb_map_video_memory(struct pxafb_info *fbi) | |||
1062 | fbi->fb.fix.smem_start = fbi->screen_dma; | 1057 | fbi->fb.fix.smem_start = fbi->screen_dma; |
1063 | fbi->palette_size = fbi->fb.var.bits_per_pixel == 8 ? 256 : 16; | 1058 | fbi->palette_size = fbi->fb.var.bits_per_pixel == 8 ? 256 : 16; |
1064 | 1059 | ||
1065 | if ((fbi->lccr4 & LCCR4_PAL_FOR_MASK) == LCCR4_PAL_FOR_0) | 1060 | fbi->dma_buff = (void *)fbi->map_cpu; |
1066 | palette_mem_size = fbi->palette_size * sizeof(u16); | 1061 | fbi->dma_buff_phys = fbi->map_dma; |
1067 | else | 1062 | fbi->palette_cpu = (u16 *)&fbi->dma_buff->palette[0]; |
1068 | palette_mem_size = fbi->palette_size * sizeof(u32); | ||
1069 | |||
1070 | fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE | ||
1071 | - palette_mem_size); | ||
1072 | fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size; | ||
1073 | } | 1063 | } |
1074 | 1064 | ||
1075 | return fbi->map_cpu ? 0 : -ENOMEM; | 1065 | return fbi->map_cpu ? 0 : -ENOMEM; |