ark1668_display_cfg.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. #include "ark1668_lcd.h"
  2. #define UPDATING_WIDTH 200
  3. #define UPDATING_HEIGHT 20
  4. #define PROGRESS_WIDTH 200
  5. #define PROGRESS_HEIGHT 32
  6. #define UPDATE_LOGO_WIDTH PROGRESS_WIDTH
  7. #define UPDATE_LOGO_HEIGHT (UPDATING_HEIGHT+PROGRESS_HEIGHT)
  8. #if 1
  9. //chinese
  10. #define UPDATING_POINT_COUNT 397
  11. static unsigned short updating[UPDATING_POINT_COUNT] =
  12. {
  13. 810, 821, 828, 840, 866, 878, 883, 894, 900, 1008, 1009, 1010, 1021, 1024, 1025, 1026,
  14. 1027, 1028, 1040, 1060, 1066, 1076, 1077, 1078, 1079, 1080, 1083, 1086, 1093, 1094, 1096, 1097,
  15. 1098, 1099, 1100, 1206, 1207, 1210, 1220, 1223, 1224, 1225, 1227, 1228, 1240, 1260, 1261, 1263,
  16. 1264, 1265, 1266, 1267, 1268, 1269, 1275, 1276, 1277, 1280, 1281, 1283, 1285, 1293, 1299, 1404,
  17. 1405, 1406, 1407, 1410, 1420, 1422, 1425, 1427, 1436, 1440, 1441, 1442, 1443, 1444, 1445, 1461,
  18. 1466, 1467, 1468, 1477, 1481, 1483, 1484, 1492, 1494, 1498, 1499, 1500, 1501, 1502, 1603, 1606,
  19. 1610, 1619, 1621, 1622, 1624, 1627, 1628, 1629, 1636, 1637, 1638, 1639, 1640, 1641, 1644, 1645,
  20. 1664, 1665, 1666, 1667, 1669, 1677, 1678, 1679, 1680, 1683, 1684, 1685, 1686, 1692, 1694, 1695,
  21. 1696, 1697, 1698, 1702, 1806, 1810, 1812, 1813, 1814, 1818, 1819, 1820, 1821, 1824, 1825, 1826,
  22. 1827, 1828, 1829, 1836, 1840, 1844, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868,
  23. 1869, 1870, 1874, 1875, 1876, 1877, 1880, 1881, 1882, 1883, 1884, 1885, 1891, 1892, 1894, 1896,
  24. 1897, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2014, 2020, 2024, 2025, 2028,
  25. 2036, 2040, 2044, 2058, 2059, 2060, 2063, 2068, 2076, 2077, 2078, 2080, 2085, 2090, 2092, 2094,
  26. 2096, 2097, 2098, 2099, 2100, 2101, 2206, 2210, 2219, 2220, 2221, 2222, 2223, 2224, 2226, 2227,
  27. 2228, 2236, 2237, 2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2260, 2264, 2265, 2266, 2267,
  28. 2268, 2276, 2277, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2292, 2294, 2295, 2296, 2298, 2406,
  29. 2410, 2419, 2420, 2423, 2426, 2427, 2436, 2440, 2460, 2464, 2465, 2466, 2467, 2468, 2475, 2477,
  30. 2480, 2485, 2492, 2494, 2498, 2499, 2500, 2501, 2502, 2606, 2610, 2621, 2622, 2623, 2626, 2627,
  31. 2640, 2660, 2662, 2663, 2664, 2668, 2674, 2675, 2677, 2680, 2681, 2682, 2683, 2684, 2685, 2692,
  32. 2694, 2695, 2696, 2697, 2698, 2805, 2810, 2820, 2821, 2822, 2825, 2826, 2827, 2840, 2851, 2852,
  33. 2860, 2861, 2862, 2864, 2865, 2866, 2867, 2868, 2874, 2877, 2880, 2885, 2892, 2897, 2899, 3004,
  34. 3005, 3010, 3018, 3019, 3021, 3022, 3024, 3025, 3028, 3040, 3051, 3052, 3060, 3061, 3064, 3068,
  35. 3077, 3080, 3083, 3085, 3092, 3096, 3100, 3106, 3107, 3114, 3115, 3122, 3123, 3203, 3204, 3210,
  36. 3221, 3223, 3224, 3228, 3229, 3230, 3240, 3252, 3264, 3266, 3267, 3268, 3277, 3280, 3284, 3285,
  37. 3292, 3295, 3296, 3300, 3301, 3403, 3422, 3423, 3451, 3464, 3494, 3495, 3502,
  38. };
  39. #else
  40. //english
  41. #define UPDATING_POINT_COUNT 237
  42. static unsigned short updating[UPDATING_POINT_COUNT] =
  43. {
  44. 1021, 1022, 1023, 1044, 1045, 1222, 1223, 1235, 1236, 1422, 1423, 1435, 1436, 1601, 1602, 1603,
  45. 1605, 1606, 1607, 1609, 1610, 1611, 1612, 1613, 1614, 1619, 1620, 1621, 1622, 1623, 1627, 1628,
  46. 1629, 1630, 1633, 1634, 1635, 1636, 1637, 1638, 1642, 1643, 1644, 1645, 1649, 1650, 1652, 1653,
  47. 1654, 1659, 1660, 1661, 1662, 1663, 1802, 1803, 1806, 1807, 1810, 1811, 1814, 1815, 1818, 1819,
  48. 1822, 1823, 1826, 1827, 1830, 1831, 1835, 1836, 1844, 1845, 1850, 1851, 1852, 1854, 1855, 1858,
  49. 1859, 1861, 1862, 2002, 2003, 2006, 2007, 2010, 2011, 2014, 2015, 2018, 2019, 2022, 2023, 2028,
  50. 2029, 2030, 2031, 2035, 2036, 2044, 2045, 2050, 2054, 2055, 2058, 2059, 2061, 2062, 2202, 2203,
  51. 2206, 2207, 2210, 2211, 2214, 2215, 2218, 2219, 2222, 2223, 2227, 2228, 2230, 2231, 2235, 2236,
  52. 2244, 2245, 2250, 2254, 2255, 2259, 2260, 2261, 2402, 2403, 2406, 2407, 2410, 2411, 2414, 2415,
  53. 2418, 2419, 2422, 2423, 2426, 2427, 2430, 2431, 2435, 2436, 2444, 2445, 2450, 2454, 2455, 2458,
  54. 2459, 2466, 2467, 2468, 2474, 2475, 2476, 2482, 2483, 2484, 2603, 2604, 2605, 2606, 2607, 2608,
  55. 2610, 2611, 2612, 2613, 2614, 2619, 2620, 2621, 2622, 2623, 2624, 2627, 2628, 2629, 2630, 2631,
  56. 2632, 2636, 2637, 2638, 2642, 2643, 2644, 2645, 2646, 2647, 2649, 2650, 2651, 2652, 2654, 2655,
  57. 2656, 2658, 2659, 2660, 2661, 2662, 2666, 2667, 2668, 2674, 2675, 2676, 2682, 2683, 2684, 2810,
  58. 2811, 2858, 2859, 2862, 2863, 3009, 3010, 3011, 3012, 3059, 3060, 3061, 3062,
  59. };
  60. #endif
  61. static struct screen_info screens [] = {
  62. {SCREEN_QUN700, SCREEN_TYPE_RGB, LVDS_FORMAT_RGB0888, 800, 480, 40, 36, 16, 32, 32, 41, 0, 1, 1, 0, 0x8, 12, SCREEN_CLKSEL_SYSPLL,0,13,1, DISP_RGB_888,RGB_MODE_BGR,32,0,0, 0,0,0,0},
  63. {SCREEN_CVBS_NTSC, SCREEN_TYPE_CVBS, CVBS_FORMAT_NTSC, 720, 480, 0, 0, 21, 0, 0, 135, 0, 0, 0, 0, 0x1F,0, 0,0,0,0, DISP_RGB_888,RGB_MODE_BGR,32,0,1, 0,0,0,0},
  64. {SCREEN_CVBS_PAL, SCREEN_TYPE_CVBS, CVBS_FORMAT_PAL, 720, 576, 0, 0, 23, 0, 0, 141, 0, 0, 0, 0, 0x1F,0, 0,0,0,0, DISP_RGB_888,RGB_MODE_BGR,32,0,1, 0,0,0,0},
  65. {SCREEN_VGA8060, SCREEN_TYPE_VGA, VGA_FORMAT_800x600, 800, 600, 23, 1, 3, 79, 39, 127, 0, 0, 0, 0, 0x1F,0, SCREEN_CLKSEL_DDSCLK,200,5,0, DISP_RGB_888,RGB_MODE_BGR,32,0,0, 0,0,0,0},
  66. {SCREEN_TYPE_YPBPR720P, SCREEN_TYPE_YPBPR, YPBPR_FORMAT_720P60HZ, 1280, 720, 0, 0, 29, 0, 0, 369, 0, 0, 0, 0, 0x1F,0, SCREEN_CLKSEL_DDSCLK,297,4,0, DISP_RGB_888,RGB_MODE_BGR,32,0,0, 0,0,0,0},
  67. {SCREEN_C101EAN, SCREEN_TYPE_LVDS, LVDS_FORMAT_RGB0888, 1280, 720, 14, 14, 10, 60, 60, 46, 0, 1, 1, 0, 0x8, 12, SCREEN_CLKSEL_SYSPLL,0,6,1, DISP_RGB_888,RGB_MODE_BGR,32,0xE0EC,0, 0,0,0,0},
  68. {SCREEN_CLAA101, SCREEN_TYPE_LVDS, LVDS_FORMAT_RGB0888, 1024, 600, 8, 8, 10, 50, 50, 60, 0, 1, 1, 0, 0x8, 12, SCREEN_CLKSEL_SYSPLL,0,7,1, DISP_RGB_888,RGB_MODE_BGR,32,0x160FD,0, 0,0,0,0},
  69. {0},
  70. {0},//SCREEN_USER_TYPE
  71. };
  72. #define UPDATELOGO_DISPLAY_ADDR 0xE200000
  73. static int g_screen_id = 0;
  74. struct screen_info *g_screen_info;
  75. display_updatepara g_display_para;
  76. static void screen_info_show(struct screen_info *p_info)
  77. {
  78. printf("screen_id=%d------------------->\n",p_info->screen_id);
  79. printf("ScreenType:%d, subType:%d,Width:%d, Height:%d,Format:%d, TvoutType:%d,screen_id:%d,interlace:%d\r\n",
  80. p_info->screen_type,p_info->format,p_info->width, p_info->height, p_info->src_format,p_info->tvout_format,p_info->screen_id,p_info->interlace);
  81. printf("RgbMode:%d ,BPP:%d ,pad_unset:%d\r\n", p_info->rgb_mode,p_info->bpp,p_info->pad_unset);
  82. printf("HFP:%d,HBP:%d,HSW:%d,VBP:%d,VFP:%d,VSW:%d,HSYNCPolarity:0x%0x,VSYNCPolarity:0x%0x ,DEPolarity:%d\r\n",
  83. p_info->hfp,p_info->hbp,p_info->hsw,p_info->vbp,p_info->vfp,p_info->vsw,p_info->hsync_active,p_info->vsync_active,p_info->de_active);
  84. printf("CLKSource:%d,CLKFreq:%d,CLKDIV1:%d,CLKDIV2:%d,CLKPolarity:%d,LVDSCfg:0x%0x,FrameRate:%d,\r\n",
  85. p_info->clk_source,p_info->clk_freq,p_info->clk_div1,p_info->clk_div2,p_info->vclk_active,p_info->lvds_cfg,p_info->frame_rate);
  86. }
  87. static void updating_init(void)
  88. {
  89. int i;
  90. unsigned int *p = (unsigned int *)(UPDATELOGO_DISPLAY_ADDR);
  91. unsigned int color = 0xffffffff;
  92. int pos = 0;
  93. for(i = 0; i < UPDATING_WIDTH*UPDATING_HEIGHT; i++){
  94. if(updating[pos] == i){
  95. *p = color;
  96. pos++;
  97. }
  98. p++;
  99. }
  100. }
  101. static void update_progress_init(void)
  102. {
  103. int i, j;
  104. unsigned int *p = (unsigned int *)(UPDATELOGO_DISPLAY_ADDR + UPDATING_HEIGHT*PROGRESS_WIDTH*4);
  105. int height = UPDATE_LOGO_HEIGHT;
  106. unsigned int color = 0xffffffff;
  107. for(j = UPDATING_HEIGHT; j < height; j++){
  108. for(i = 0; i < PROGRESS_WIDTH; i++){
  109. if(j < (UPDATING_HEIGHT + 2) || j > (height -3) || \
  110. i < 2 || i > (PROGRESS_WIDTH -3)){
  111. *p = color;
  112. }
  113. p++;
  114. }
  115. }
  116. }
  117. static void update_progress_set(int percent)
  118. {
  119. int i, j, end;;
  120. unsigned int *p = (unsigned int *)(UPDATELOGO_DISPLAY_ADDR + UPDATING_HEIGHT*PROGRESS_WIDTH*4);
  121. int height = UPDATE_LOGO_HEIGHT;
  122. unsigned int color = 0xff00ff00;
  123. if(percent < 0 || percent > 100){
  124. printf("update progress percent=%d, error.",percent);
  125. return;
  126. }
  127. end = percent * (PROGRESS_WIDTH-3)/100;
  128. for(j = UPDATING_HEIGHT; j < height; j++){
  129. for(i = 0; i < PROGRESS_WIDTH; i++){
  130. if(j > (UPDATING_HEIGHT + 2) && j < (height -3) \
  131. && i > 2 && i < end){
  132. *p = color;
  133. }
  134. p++;
  135. }
  136. }
  137. if(percent >= 90){
  138. udelay(200000);
  139. }
  140. else if(percent == 100){
  141. udelay(500000);
  142. ark_osd_en_layer(OSD2_LAYER, 0);
  143. }
  144. }
  145. static void display_updatelogo(void)
  146. {
  147. struct screen_info *screen = &screens[g_screen_id];
  148. int x, y, height;
  149. unsigned int src_width = UPDATE_LOGO_WIDTH;
  150. unsigned int src_height = UPDATE_LOGO_HEIGHT;
  151. memset((void *)UPDATELOGO_DISPLAY_ADDR, 0 , src_width*src_height*4);
  152. updating_init();
  153. update_progress_init();
  154. if (!IS_TVENC_SCREEN(screen))
  155. ark_disp_wait_lcd_frame_int();
  156. else
  157. ark_disp_wait_tvenc_frame_int();
  158. x = (screen->width - src_width) / 2;
  159. y = (screen->height - src_height) / 2;
  160. height = src_height;
  161. if (is_interlace_tvenc(screen)) {
  162. y /= 2;
  163. height /= 2;
  164. }
  165. ark_set_osd_image(OSD2_LAYER, DISP_RGB_888, src_width, height);
  166. ark_set_osd_addr(OSD2_LAYER, UPDATELOGO_DISPLAY_ADDR);
  167. ark_disp_set_osd_layer_position(OSD2_LAYER, x, y);
  168. //printf("---->%d %d %d %d.\n",x, y,src_width,height);
  169. }
  170. void ark_display_init(int screen_id)
  171. {
  172. struct screen_info *screen = &screens[screen_id];
  173. int interlace;
  174. //lcd clk enable
  175. rSYS_AHB_CLK_EN |= 1 << 8;
  176. rSYS_AXI_CLK_EN |= 1 << 1;
  177. rSYS_PER_CLK_EN |= 1 << 4;
  178. screen_info_show(screen);
  179. g_screen_info = screen;
  180. memset(&g_display_para, 0 ,sizeof(g_display_para));
  181. memcpy(&g_display_para.screeninfo, screen, sizeof(struct screen_info));
  182. ark_backlight_config_f(screen->screen_id);
  183. ark_display_initialize_port(screen);
  184. interlace = is_interlace_tvenc(screen);
  185. display_updatelogo();
  186. ark_osd_en_layer(OSD2_LAYER, 1);
  187. ark_osd_en_layer(OSD1_LAYER, 0);
  188. if (IS_TVENC_SCREEN(screen) && interlace) {
  189. ark_set_osd_frame_mode(OSD2_LAYER, 1);
  190. }
  191. ark_backlight_config(screen->screen_id);
  192. }
  193. int do_disconfig (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  194. {
  195. unsigned long percent = 0;
  196. int ret;
  197. if(argc < 2)
  198. return cmd_usage(cmdtp);
  199. ret = strict_strtoul(argv[1], 10, &percent);
  200. if(ret < 0){
  201. printf("error format screen id\n");
  202. }
  203. if(percent > 100)
  204. {
  205. printf("Invalide param.\n");
  206. return cmd_usage(cmdtp);
  207. }
  208. if(percent == 0){
  209. g_screen_id = SCREEN_CLAA101;
  210. ark_display_init(g_screen_id);
  211. printf("ark display init g_screen_id=%d.\n",g_screen_id);
  212. }else{
  213. update_progress_set(percent);
  214. printf("update progress set percent=%ld.\n",percent);
  215. }
  216. return 0;
  217. }
  218. /***************************************************/
  219. U_BOOT_CMD(
  220. disconfig, CONFIG_SYS_MAXARGS, 0, do_disconfig,
  221. "config display",
  222. "disconfig percent\n"
  223. "percent(0:) \n"
  224. );