1.1 --- a/stage2/jzlcd.c Tue Jan 26 16:03:49 2016 +0100
1.2 +++ b/stage2/jzlcd.c Tue Jan 26 16:57:26 2016 +0100
1.3 @@ -236,6 +236,53 @@
1.4 | (jzfb.vsw + jzfb.bfw + jzfb.h + jzfb.efw);
1.5 }
1.6
1.7 +static void jz_lcd_samsung_init(unsigned int pclk)
1.8 +{
1.9 + unsigned int total, tp_s, tp_e, ckv_s, ckv_e;
1.10 + unsigned int rev_s, rev_e, inv_s, inv_e;
1.11 +
1.12 + jz_lcd_tft_init();
1.13 +
1.14 + total = jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw;
1.15 + tp_s = jzfb.blw + jzfb.w + 1;
1.16 + tp_e = tp_s + 1;
1.17 + /* ckv_s = tp_s - jz_clocks.pixclk/(1000000000/4100); */
1.18 + ckv_s = tp_s - pclk/(1000000000/4100);
1.19 + ckv_e = tp_s + total;
1.20 + rev_s = tp_s - 11; /* -11.5 clk */
1.21 + rev_e = rev_s + total;
1.22 + inv_s = tp_s;
1.23 + inv_e = inv_s + total;
1.24 + REG_LCD_CLS = (tp_s << 16) | tp_e;
1.25 + REG_LCD_PS = (ckv_s << 16) | ckv_e;
1.26 + REG_LCD_SPL = (rev_s << 16) | rev_e;
1.27 + REG_LCD_REV = (inv_s << 16) | inv_e;
1.28 + jzfb.cfg |= STFT_REVHI | STFT_SPLHI;
1.29 +}
1.30 +
1.31 +static void jz_lcd_sharp_init()
1.32 +{
1.33 + unsigned int total, cls_s, cls_e, ps_s, ps_e;
1.34 + unsigned int spl_s, spl_e, rev_s, rev_e;
1.35 +
1.36 + jz_lcd_tft_init();
1.37 +
1.38 + total = jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw;
1.39 + spl_s = 1;
1.40 + spl_e = spl_s + 1;
1.41 + cls_s = 0;
1.42 + cls_e = total - 60; /* > 4us (pclk = 80ns) */
1.43 + ps_s = cls_s;
1.44 + ps_e = cls_e;
1.45 + rev_s = total - 40; /* > 3us (pclk = 80ns) */
1.46 + rev_e = rev_s + total;
1.47 + jzfb.cfg |= STFT_PSHI;
1.48 + REG_LCD_SPL = (spl_s << 16) | spl_e;
1.49 + REG_LCD_CLS = (cls_s << 16) | cls_e;
1.50 + REG_LCD_PS = (ps_s << 16) | ps_e;
1.51 + REG_LCD_REV = (rev_s << 16) | rev_e;
1.52 +}
1.53 +
1.54 static unsigned int jz_lcd_get_pixel_clock()
1.55 {
1.56 unsigned int pclk;
1.57 @@ -365,50 +412,13 @@
1.58
1.59 case MODE_TFT_SAMSUNG:
1.60 {
1.61 - unsigned int total, tp_s, tp_e, ckv_s, ckv_e;
1.62 - unsigned int rev_s, rev_e, inv_s, inv_e;
1.63 -
1.64 - jz_lcd_tft_init();
1.65 -
1.66 - total = jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw;
1.67 - tp_s = jzfb.blw + jzfb.w + 1;
1.68 - tp_e = tp_s + 1;
1.69 - /* ckv_s = tp_s - jz_clocks.pixclk/(1000000000/4100); */
1.70 - ckv_s = tp_s - pclk/(1000000000/4100);
1.71 - ckv_e = tp_s + total;
1.72 - rev_s = tp_s - 11; /* -11.5 clk */
1.73 - rev_e = rev_s + total;
1.74 - inv_s = tp_s;
1.75 - inv_e = inv_s + total;
1.76 - REG_LCD_CLS = (tp_s << 16) | tp_e;
1.77 - REG_LCD_PS = (ckv_s << 16) | ckv_e;
1.78 - REG_LCD_SPL = (rev_s << 16) | rev_e;
1.79 - REG_LCD_REV = (inv_s << 16) | inv_e;
1.80 - jzfb.cfg |= STFT_REVHI | STFT_SPLHI;
1.81 + jz_lcd_samsung_init(pclk);
1.82 break;
1.83 }
1.84
1.85 case MODE_TFT_SHARP:
1.86 {
1.87 - unsigned int total, cls_s, cls_e, ps_s, ps_e;
1.88 - unsigned int spl_s, spl_e, rev_s, rev_e;
1.89 -
1.90 - jz_lcd_tft_init();
1.91 -
1.92 - total = jzfb.blw + jzfb.w + jzfb.elw + jzfb.hsw;
1.93 - spl_s = 1;
1.94 - spl_e = spl_s + 1;
1.95 - cls_s = 0;
1.96 - cls_e = total - 60; /* > 4us (pclk = 80ns) */
1.97 - ps_s = cls_s;
1.98 - ps_e = cls_e;
1.99 - rev_s = total - 40; /* > 3us (pclk = 80ns) */
1.100 - rev_e = rev_s + total;
1.101 - jzfb.cfg |= STFT_PSHI;
1.102 - REG_LCD_SPL = (spl_s << 16) | spl_e;
1.103 - REG_LCD_CLS = (cls_s << 16) | cls_e;
1.104 - REG_LCD_PS = (ps_s << 16) | ps_e;
1.105 - REG_LCD_REV = (rev_s << 16) | rev_e;
1.106 + jz_lcd_sharp_init();
1.107 break;
1.108 }
1.109
1.110 @@ -441,8 +451,25 @@
1.111 return 0;
1.112 }
1.113
1.114 +static inline u8 LCD_CODE(u8 bpp)
1.115 +{
1.116 + u8 code = 0;
1.117 + while (bpp && !(bpp & 1))
1.118 + {
1.119 + bpp >>= 1;
1.120 + code += 1;
1.121 + }
1.122 + return code;
1.123 +}
1.124 +
1.125 /* Public operations. */
1.126
1.127 +void lcd_set_bpp(u8 bpp)
1.128 +{
1.129 + jzfb.bpp = bpp;
1.130 + panel_info.vl_bpix = LCD_CODE(bpp);
1.131 +}
1.132 +
1.133 void lcd_enable(void)
1.134 {
1.135 /* Clear the disable bit and set the enable bit. */
2.1 --- a/stage2/jzlcd.h Tue Jan 26 16:03:49 2016 +0100
2.2 +++ b/stage2/jzlcd.h Tue Jan 26 16:57:26 2016 +0100
2.3 @@ -25,6 +25,9 @@
2.4 #ifndef __JZLCD_H__
2.5 #define __JZLCD_H__
2.6
2.7 +#include "xburst_types.h"
2.8 +
2.9 +void lcd_set_bpp(u8 bpp);
2.10 unsigned long lcd_ctrl_init();
2.11 void lcd_enable(void);
2.12 void lcd_disable(void);