1.1 --- a/stage2/jzlcd.c Wed Jun 28 00:20:14 2017 +0200
1.2 +++ b/stage2/jzlcd.c Wed Jun 28 01:04:22 2017 +0200
1.3 @@ -2,7 +2,7 @@
1.4 * JzRISC LCD controller
1.5 *
1.6 * Copyright (C) Xiangfu Liu <xiangfu@sharism.cc>
1.7 - * Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -32,7 +32,7 @@
1.13 extern struct jzfb_info jzfb;
1.14 extern vidinfo_t panel_info;
1.15
1.16 -static unsigned short lcd_get_panels()
1.17 +static uint16_t lcd_get_panels()
1.18 {
1.19 return ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL) ||
1.20 ((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL) ? 2 : 1;
1.21 @@ -42,55 +42,55 @@
1.22
1.23 /* Functions returning region sizes. */
1.24
1.25 -static unsigned long lcd_get_size(vidinfo_t *vid)
1.26 +static uint32_t lcd_get_size(vidinfo_t *vid)
1.27 {
1.28 /* Lines must be aligned to a word boundary. */
1.29 - unsigned long line_length = ALIGN((vid->vl_col * NBITS(vid->vl_bpix)) / 8, sizeof(u32));
1.30 + uint32_t line_length = ALIGN((vid->vl_col * NBITS(vid->vl_bpix)) / 8, sizeof(uint32_t));
1.31 return line_length * vid->vl_row;
1.32 }
1.33
1.34 -static unsigned long lcd_get_aligned_size(vidinfo_t *vid)
1.35 +static uint32_t lcd_get_aligned_size(vidinfo_t *vid)
1.36 {
1.37 /* LCD_CTRL_BST_16 requires 16-word alignment. */
1.38 - return ALIGN(lcd_get_size(vid), 16 * sizeof(u32));
1.39 + return ALIGN(lcd_get_size(vid), 16 * sizeof(uint32_t));
1.40 }
1.41
1.42 -static unsigned long lcd_get_min_size(vidinfo_t *vid)
1.43 +static uint32_t lcd_get_min_size(vidinfo_t *vid)
1.44 {
1.45 /* Lines must be aligned to a word boundary. */
1.46 - unsigned long line_length = ALIGN((vid->vl_col * 32) / 8, sizeof(u32));
1.47 + uint32_t line_length = ALIGN((vid->vl_col * 32) / 8, sizeof(uint32_t));
1.48 return line_length * vid->vl_row;
1.49 }
1.50
1.51 -static unsigned long lcd_get_aligned_min_size(vidinfo_t *vid)
1.52 +static uint32_t lcd_get_aligned_min_size(vidinfo_t *vid)
1.53 {
1.54 /* LCD_CTRL_BST_16 requires 16-word alignment. */
1.55 - return ALIGN(lcd_get_min_size(vid), 16 * sizeof(u32));
1.56 + return ALIGN(lcd_get_min_size(vid), 16 * sizeof(uint32_t));
1.57 }
1.58
1.59 -static unsigned long lcd_get_palette_size(vidinfo_t *vid)
1.60 +static uint32_t lcd_get_palette_size(vidinfo_t *vid)
1.61 {
1.62 if (NBITS(vid->vl_bpix) < 12)
1.63 - return NCOLORS(vid->vl_bpix) * sizeof(u16);
1.64 + return NCOLORS(vid->vl_bpix) * sizeof(uint16_t);
1.65 else
1.66 return 0;
1.67 }
1.68
1.69 -static unsigned long lcd_get_aligned_palette_size(vidinfo_t *vid)
1.70 +static uint32_t lcd_get_aligned_palette_size(vidinfo_t *vid)
1.71 {
1.72 /* LCD_CTRL_BST_16 requires 16-word alignment. */
1.73 - return ALIGN(lcd_get_palette_size(vid), 16 * sizeof(u32));
1.74 + return ALIGN(lcd_get_palette_size(vid), 16 * sizeof(uint32_t));
1.75 }
1.76
1.77 -static unsigned long lcd_get_descriptors_size()
1.78 +static uint32_t lcd_get_descriptors_size()
1.79 {
1.80 return 3 * sizeof(struct jz_fb_dma_descriptor);
1.81 }
1.82
1.83 -static unsigned long lcd_get_total_size(vidinfo_t *vid)
1.84 +static uint32_t lcd_get_total_size(vidinfo_t *vid)
1.85 {
1.86 - unsigned long size = lcd_get_aligned_size(vid) * lcd_get_panels();
1.87 - unsigned long min_size = lcd_get_aligned_min_size(vid);
1.88 + uint32_t size = lcd_get_aligned_size(vid) * lcd_get_panels();
1.89 + uint32_t min_size = lcd_get_aligned_min_size(vid);
1.90
1.91 /* Round up to nearest full page, or MMU section if defined. */
1.92 return ALIGN((size >= min_size ? size : min_size) + lcd_get_aligned_palette_size(vid) + lcd_get_descriptors_size(), PAGE_SIZE);
1.93 @@ -100,19 +100,19 @@
1.94
1.95 /* Functions returning addresses of each data region. */
1.96
1.97 -static unsigned long lcd_get_palette(unsigned long addr)
1.98 +static uint32_t lcd_get_palette(uint32_t addr)
1.99 {
1.100 /* Allocate memory at the end of the region for the palette. */
1.101 return addr - lcd_get_aligned_palette_size(&panel_info);
1.102 }
1.103
1.104 -static unsigned long lcd_get_descriptors(unsigned long addr)
1.105 +static uint32_t lcd_get_descriptors(uint32_t addr)
1.106 {
1.107 /* Allocate memory before the palette for the descriptor array. */
1.108 return lcd_get_palette(addr) - lcd_get_descriptors_size();
1.109 }
1.110
1.111 -static unsigned long lcd_get_framebuffer(unsigned long addr, unsigned short panel)
1.112 +static uint32_t lcd_get_framebuffer(uint32_t addr, uint16_t panel)
1.113 {
1.114 /* Allocate pages for the frame buffer and palette. */
1.115 return addr - lcd_get_total_size(&panel_info) + (panel * lcd_get_aligned_size(&panel_info));
1.116 @@ -172,9 +172,9 @@
1.117 flush_cache_all();
1.118 }
1.119
1.120 -static unsigned int jz_lcd_stn_init(unsigned int stnH)
1.121 +static uint32_t jz_lcd_stn_init(uint32_t stnH)
1.122 {
1.123 - unsigned int val = 0;
1.124 + uint32_t val = 0;
1.125
1.126 switch (jzfb.bpp) {
1.127 case 1:
1.128 @@ -236,10 +236,10 @@
1.129 | (jzfb.vsw + jzfb.bfw + jzfb.h + jzfb.efw);
1.130 }
1.131
1.132 -static void jz_lcd_samsung_init(unsigned int pclk)
1.133 +static void jz_lcd_samsung_init(uint32_t pclk)
1.134 {
1.135 - unsigned int total, tp_s, tp_e, ckv_s, ckv_e;
1.136 - unsigned int rev_s, rev_e, inv_s, inv_e;
1.137 + uint32_t total, tp_s, tp_e, ckv_s, ckv_e;
1.138 + uint32_t rev_s, rev_e, inv_s, inv_e;
1.139
1.140 jz_lcd_tft_init();
1.141
1.142 @@ -262,8 +262,8 @@
1.143
1.144 static void jz_lcd_sharp_init()
1.145 {
1.146 - unsigned int total, cls_s, cls_e, ps_s, ps_e;
1.147 - unsigned int spl_s, spl_e, rev_s, rev_e;
1.148 + uint32_t total, cls_s, cls_e, ps_s, ps_e;
1.149 + uint32_t spl_s, spl_e, rev_s, rev_e;
1.150
1.151 jz_lcd_tft_init();
1.152
1.153 @@ -283,9 +283,9 @@
1.154 REG_LCD_REV = (rev_s << 16) | rev_e;
1.155 }
1.156
1.157 -static unsigned int jz_lcd_get_pixel_clock()
1.158 +static uint32_t jz_lcd_get_pixel_clock()
1.159 {
1.160 - unsigned int pclk;
1.161 + uint32_t pclk;
1.162
1.163 /* Derive pixel clock from frame clock. */
1.164
1.165 @@ -315,9 +315,9 @@
1.166 return pclk;
1.167 }
1.168
1.169 -static void jz_lcd_set_timing(unsigned int pclk)
1.170 +static void jz_lcd_set_timing(uint32_t pclk)
1.171 {
1.172 - unsigned int val;
1.173 + uint32_t val;
1.174
1.175 #ifdef CONFIG_CPU_JZ4730
1.176 val = __cpm_get_pllout() / pclk;
1.177 @@ -359,8 +359,8 @@
1.178 static int jz_lcd_hw_init(vidinfo_t *vid)
1.179 {
1.180 struct jz_fb_info *fbi = &vid->jz_fb;
1.181 - unsigned int val = 0;
1.182 - unsigned int pclk = jz_lcd_get_pixel_clock();
1.183 + uint32_t val = 0;
1.184 + uint32_t pclk = jz_lcd_get_pixel_clock();
1.185
1.186 /* Setting Control register */
1.187 switch (jzfb.bpp) {
1.188 @@ -442,18 +442,18 @@
1.189
1.190 /* Configure DMA. */
1.191
1.192 - REG_LCD_DA0 = (unsigned long) fbi->fdadr0; /* frame descriptor */
1.193 + REG_LCD_DA0 = (uint32_t) fbi->fdadr0; /* frame descriptor */
1.194
1.195 if (((jzfb.cfg & MODE_MASK) == MODE_STN_COLOR_DUAL) ||
1.196 ((jzfb.cfg & MODE_MASK) == MODE_STN_MONO_DUAL))
1.197 - REG_LCD_DA1 = (unsigned long) fbi->fdadr1; /* frame descriptor */
1.198 + REG_LCD_DA1 = (uint32_t) fbi->fdadr1; /* frame descriptor */
1.199
1.200 return 0;
1.201 }
1.202
1.203 -static inline u8 LCD_CODE(u8 bpp)
1.204 +static inline uint8_t LCD_CODE(uint8_t bpp)
1.205 {
1.206 - u8 code = 0;
1.207 + uint8_t code = 0;
1.208 while (bpp && !(bpp & 1))
1.209 {
1.210 bpp >>= 1;
1.211 @@ -464,7 +464,7 @@
1.212
1.213 /* Public operations. */
1.214
1.215 -void lcd_set_bpp(u8 bpp)
1.216 +void lcd_set_bpp(uint8_t bpp)
1.217 {
1.218 jzfb.bpp = bpp;
1.219 panel_info.vl_bpix = LCD_CODE(bpp);
1.220 @@ -488,21 +488,21 @@
1.221 REG_LCD_CTRL &= ~(1<<4); /* LCDCTRL.ENA, quick disable */
1.222 }
1.223
1.224 -static inline u16 rgb8_to_rgb16(u8 rgb)
1.225 +static inline uint16_t rgb8_to_rgb16(uint8_t rgb)
1.226 {
1.227 return ((((rgb & 0xe0) >> 5) * 4) << 11) | ((((rgb & 0x1c) >> 2) * 9) << 6) | ((rgb & 0x03) * 10);
1.228 }
1.229
1.230 -static inline u16 rgb4_to_rgb16(u8 rgb)
1.231 +static inline uint16_t rgb4_to_rgb16(uint8_t rgb)
1.232 {
1.233 return ((((rgb & 8) >> 3) * 0x1f) << 11) | ((((rgb & 6) >> 1) * 0x15) << 5) | ((rgb & 1) * 0x1f);
1.234 }
1.235
1.236 static void lcd_init_palette(vidinfo_t *vid)
1.237 {
1.238 - u16 *palette = (u16 *) lcd_get_palette(get_memory_size());
1.239 - u16 *end = (u16 *) palette + NCOLORS(vid->vl_bpix);
1.240 - u8 value = 0;
1.241 + uint16_t *palette = (uint16_t *) lcd_get_palette(get_memory_size());
1.242 + uint16_t *end = (uint16_t *) palette + NCOLORS(vid->vl_bpix);
1.243 + uint8_t value = 0;
1.244
1.245 while (palette < end)
1.246 {
1.247 @@ -523,7 +523,7 @@
1.248 }
1.249 }
1.250
1.251 -unsigned long lcd_ctrl_init()
1.252 +uint32_t lcd_ctrl_init()
1.253 {
1.254 struct jz_fb_info *fbi = &panel_info.jz_fb;
1.255