From 5d910426a6e80194a50e33351c91abcad266c809 Mon Sep 17 00:00:00 2001 From: Alexander Stein Date: Wed, 5 Oct 2011 09:59:57 +0200 Subject: atmel_lcdfb: Adjust HFP calculation so it matches the manual. In the AT91SAM9263 Manual the HFP part in LCDTIM2 is described as follows: * HFP: Horizontal Front Porch Number of idle LCDDOTCK cycles at the end of the line. Idle period is (HFP+2) LCDDOTCK cycles. It is only a minor issue. I also changed all boards using atmel_lcdfb I found to respect the new calculation. Signed-off-by: Alexander Stein Signed-off-by: Florian Tobias Schandinat --- drivers/video/atmel_lcdfb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/video/atmel_lcdfb.c') diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index 244d55b7c0ae..7e66263b18c1 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -396,7 +396,7 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var, var->lower_margin = min_t(u32, var->lower_margin, ATMEL_LCDC_VFP); var->right_margin = min_t(u32, var->right_margin, - (ATMEL_LCDC_HFP >> ATMEL_LCDC_HFP_OFFSET) + 1); + (ATMEL_LCDC_HFP >> ATMEL_LCDC_HFP_OFFSET) + 2); var->hsync_len = min_t(u32, var->hsync_len, (ATMEL_LCDC_HPW >> ATMEL_LCDC_HPW_OFFSET) + 1); var->left_margin = min_t(u32, var->left_margin, @@ -581,7 +581,7 @@ static int atmel_lcdfb_set_par(struct fb_info *info) lcdc_writel(sinfo, ATMEL_LCDC_TIM1, value); /* Horizontal timing */ - value = (info->var.right_margin - 1) << ATMEL_LCDC_HFP_OFFSET; + value = (info->var.right_margin - 2) << ATMEL_LCDC_HFP_OFFSET; value |= (info->var.hsync_len - 1) << ATMEL_LCDC_HPW_OFFSET; value |= (info->var.left_margin - 1); dev_dbg(info->device, " * LCDTIM2 = %08lx\n", value); -- cgit v1.2.3 From acfdc2e1bdb4b148e7546fe8948d8f75bd2f9377 Mon Sep 17 00:00:00 2001 From: Alexander Stein Date: Wed, 5 Oct 2011 09:59:58 +0200 Subject: atmel_lcdfb: Use proper blanking on negative contrast polarity If used with negative polarity the PWM unit cannot be disabled. This would result in a full contrast screen. Instead let the PWM unit enabled using 0x0 as compare value which darkens the display. In result no power saving is possible if inverted contrast polarity is used. Signed-off-by: Alexander Stein Signed-off-by: Florian Tobias Schandinat --- drivers/video/atmel_lcdfb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/video/atmel_lcdfb.c') diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index 7e66263b18c1..8bfee6aecc8b 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -99,8 +99,11 @@ static int atmel_bl_update_status(struct backlight_device *bl) brightness = 0; lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, brightness); - lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, + if (contrast_ctr & ATMEL_LCDC_POL_POSITIVE) + lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, brightness ? contrast_ctr : 0); + else + lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, contrast_ctr); bl->props.fb_blank = bl->props.power = sinfo->bl_power = power; -- cgit v1.2.3 From 5d67b89ce88f2db60573de859649b1b5a8c830d6 Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Thu, 13 Oct 2011 16:45:52 +0200 Subject: atmel_lcdfb: support new-style palette format The newer Atmel SoCs use normal 16bit 565 BGR/RGB for the palette data, rather than the special intensity + 555 format. Fill out palette data correctly on these devices, and at the same time respect the RGB/BGR wiring mode. Signed-off-by: Peter Korsgaard Signed-off-by: Florian Tobias Schandinat --- drivers/video/atmel_lcdfb.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'drivers/video/atmel_lcdfb.c') diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index 8bfee6aecc8b..2226aca44c57 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -684,14 +684,30 @@ static int atmel_lcdfb_setcolreg(unsigned int regno, unsigned int red, case FB_VISUAL_PSEUDOCOLOR: if (regno < 256) { - val = ((red >> 11) & 0x001f); - val |= ((green >> 6) & 0x03e0); - val |= ((blue >> 1) & 0x7c00); - - /* - * TODO: intensity bit. Maybe something like - * ~(red[10] ^ green[10] ^ blue[10]) & 1 - */ + if (cpu_is_at91sam9261() || cpu_is_at91sam9263() + || cpu_is_at91sam9rl()) { + /* old style I+BGR:555 */ + val = ((red >> 11) & 0x001f); + val |= ((green >> 6) & 0x03e0); + val |= ((blue >> 1) & 0x7c00); + + /* + * TODO: intensity bit. Maybe something like + * ~(red[10] ^ green[10] ^ blue[10]) & 1 + */ + } else { + /* new style BGR:565 / RGB:565 */ + if (sinfo->lcd_wiring_mode == + ATMEL_LCDC_WIRING_RGB) { + val = ((blue >> 11) & 0x001f); + val |= ((red >> 0) & 0xf800); + } else { + val = ((red >> 11) & 0x001f); + val |= ((blue >> 0) & 0xf800); + } + + val |= ((green >> 5) & 0x07e0); + } lcdc_writel(sinfo, ATMEL_LCDC_LUT(regno), val); ret = 0; -- cgit v1.2.3 From 6b3cbe4094e3eddc9f38b34118c10aeea845eaf2 Mon Sep 17 00:00:00 2001 From: Florian Tobias Schandinat Date: Wed, 11 Jan 2012 22:26:59 +0000 Subject: Revert "atmel_lcdfb: Adjust HFP calculation so it matches the manual." This reverts commit 5d910426a6e80194a50e33351c91abcad266c809. Nicolas Ferre wrote: "Unfortunately this is not true for all the SoC that embed the atmel_lcdfb... So I may need to rework this patch but it is certainly not applicable in the current form." Signed-off-by: Florian Tobias Schandinat --- arch/arm/mach-at91/board-cap9adk.c | 2 +- arch/arm/mach-at91/board-neocore926.c | 2 +- arch/arm/mach-at91/board-sam9261ek.c | 4 ++-- arch/arm/mach-at91/board-sam9263ek.c | 2 +- arch/arm/mach-at91/board-sam9m10g45ek.c | 2 +- arch/arm/mach-at91/board-sam9rlek.c | 2 +- drivers/video/atmel_lcdfb.c | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/video/atmel_lcdfb.c') diff --git a/arch/arm/mach-at91/board-cap9adk.c b/arch/arm/mach-at91/board-cap9adk.c index 911d9862e6ff..5dffd3be62d2 100644 --- a/arch/arm/mach-at91/board-cap9adk.c +++ b/arch/arm/mach-at91/board-cap9adk.c @@ -299,7 +299,7 @@ static struct fb_videomode at91_tft_vga_modes[] = { .xres = 240, .yres = 320, .pixclock = KHZ2PICOS(4965), - .left_margin = 1, .right_margin = 34, + .left_margin = 1, .right_margin = 33, .upper_margin = 1, .lower_margin = 0, .hsync_len = 5, .vsync_len = 1, diff --git a/arch/arm/mach-at91/board-neocore926.c b/arch/arm/mach-at91/board-neocore926.c index 190dc19ce467..ef816c17dc61 100644 --- a/arch/arm/mach-at91/board-neocore926.c +++ b/arch/arm/mach-at91/board-neocore926.c @@ -230,7 +230,7 @@ static struct fb_videomode at91_tft_vga_modes[] = { .xres = 240, .yres = 320, .pixclock = KHZ2PICOS(5000), - .left_margin = 1, .right_margin = 34, + .left_margin = 1, .right_margin = 33, .upper_margin = 1, .lower_margin = 0, .hsync_len = 5, .vsync_len = 1, diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c index 4f469ea46969..b005b738e8ff 100644 --- a/arch/arm/mach-at91/board-sam9261ek.c +++ b/arch/arm/mach-at91/board-sam9261ek.c @@ -365,7 +365,7 @@ static struct fb_videomode at91_stn_modes[] = { .xres = 320, .yres = 240, .pixclock = KHZ2PICOS(1440), - .left_margin = 1, .right_margin = 2, + .left_margin = 1, .right_margin = 1, .upper_margin = 0, .lower_margin = 0, .hsync_len = 1, .vsync_len = 1, @@ -426,7 +426,7 @@ static struct fb_videomode at91_tft_vga_modes[] = { .xres = 240, .yres = 320, .pixclock = KHZ2PICOS(4965), - .left_margin = 1, .right_margin = 34, + .left_margin = 1, .right_margin = 33, .upper_margin = 1, .lower_margin = 0, .hsync_len = 5, .vsync_len = 1, diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c index 0e96ee9e4ad3..bccdcf23caa1 100644 --- a/arch/arm/mach-at91/board-sam9263ek.c +++ b/arch/arm/mach-at91/board-sam9263ek.c @@ -253,7 +253,7 @@ static struct fb_videomode at91_tft_vga_modes[] = { .xres = 240, .yres = 320, .pixclock = KHZ2PICOS(4965), - .left_margin = 1, .right_margin = 34, + .left_margin = 1, .right_margin = 33, .upper_margin = 1, .lower_margin = 0, .hsync_len = 5, .vsync_len = 1, diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c index 855c68b378d6..92de9127923a 100644 --- a/arch/arm/mach-at91/board-sam9m10g45ek.c +++ b/arch/arm/mach-at91/board-sam9m10g45ek.c @@ -192,7 +192,7 @@ static struct fb_videomode at91_tft_vga_modes[] = { .xres = 480, .yres = 272, .pixclock = KHZ2PICOS(9000), - .left_margin = 1, .right_margin = 2, + .left_margin = 1, .right_margin = 1, .upper_margin = 40, .lower_margin = 1, .hsync_len = 45, .vsync_len = 1, diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c index 0e943a2d9502..b2b748239f36 100644 --- a/arch/arm/mach-at91/board-sam9rlek.c +++ b/arch/arm/mach-at91/board-sam9rlek.c @@ -149,7 +149,7 @@ static struct fb_videomode at91_tft_vga_modes[] = { .xres = 240, .yres = 320, .pixclock = KHZ2PICOS(4965), - .left_margin = 1, .right_margin = 34, + .left_margin = 1, .right_margin = 33, .upper_margin = 1, .lower_margin = 0, .hsync_len = 5, .vsync_len = 1, diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index ced4419e56e2..0d7b20d4285d 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -400,7 +400,7 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var, var->lower_margin = min_t(u32, var->lower_margin, ATMEL_LCDC_VFP); var->right_margin = min_t(u32, var->right_margin, - (ATMEL_LCDC_HFP >> ATMEL_LCDC_HFP_OFFSET) + 2); + (ATMEL_LCDC_HFP >> ATMEL_LCDC_HFP_OFFSET) + 1); var->hsync_len = min_t(u32, var->hsync_len, (ATMEL_LCDC_HPW >> ATMEL_LCDC_HPW_OFFSET) + 1); var->left_margin = min_t(u32, var->left_margin, @@ -585,7 +585,7 @@ static int atmel_lcdfb_set_par(struct fb_info *info) lcdc_writel(sinfo, ATMEL_LCDC_TIM1, value); /* Horizontal timing */ - value = (info->var.right_margin - 2) << ATMEL_LCDC_HFP_OFFSET; + value = (info->var.right_margin - 1) << ATMEL_LCDC_HFP_OFFSET; value |= (info->var.hsync_len - 1) << ATMEL_LCDC_HPW_OFFSET; value |= (info->var.left_margin - 1); dev_dbg(info->device, " * LCDTIM2 = %08lx\n", value); -- cgit v1.2.3