aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/fbdev/amba-clcd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/fbdev/amba-clcd.c')
-rw-r--r--drivers/video/fbdev/amba-clcd.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
index beadd3edaa17..a7b6217ac87b 100644
--- a/drivers/video/fbdev/amba-clcd.c
+++ b/drivers/video/fbdev/amba-clcd.c
@@ -24,6 +24,7 @@
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/amba/bus.h> 25#include <linux/amba/bus.h>
26#include <linux/amba/clcd.h> 26#include <linux/amba/clcd.h>
27#include <linux/bitops.h>
27#include <linux/clk.h> 28#include <linux/clk.h>
28#include <linux/hardirq.h> 29#include <linux/hardirq.h>
29#include <linux/dma-mapping.h> 30#include <linux/dma-mapping.h>
@@ -650,6 +651,7 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
650{ 651{
651 struct device_node *endpoint; 652 struct device_node *endpoint;
652 int err; 653 int err;
654 unsigned int bpp;
653 u32 max_bandwidth; 655 u32 max_bandwidth;
654 u32 tft_r0b0g0[3]; 656 u32 tft_r0b0g0[3];
655 657
@@ -667,11 +669,22 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
667 669
668 err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth", 670 err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth",
669 &max_bandwidth); 671 &max_bandwidth);
670 if (!err) 672 if (!err) {
671 fb->panel->bpp = 8 * max_bandwidth / (fb->panel->mode.xres * 673 /*
672 fb->panel->mode.yres * fb->panel->mode.refresh); 674 * max_bandwidth is in bytes per second and pixclock in
673 else 675 * pico-seconds, so the maximum allowed bits per pixel is
674 fb->panel->bpp = 32; 676 * 8 * max_bandwidth / (PICOS2KHZ(pixclock) * 1000)
677 * Rearrange this calculation to avoid overflow and then ensure
678 * result is a valid format.
679 */
680 bpp = max_bandwidth / (1000 / 8)
681 / PICOS2KHZ(fb->panel->mode.pixclock);
682 bpp = rounddown_pow_of_two(bpp);
683 if (bpp > 32)
684 bpp = 32;
685 } else
686 bpp = 32;
687 fb->panel->bpp = bpp;
675 688
676#ifdef CONFIG_CPU_BIG_ENDIAN 689#ifdef CONFIG_CPU_BIG_ENDIAN
677 fb->panel->cntl |= CNTL_BEBO; 690 fb->panel->cntl |= CNTL_BEBO;