ark1668_display_cfg.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. {SCREEN_CLAA101, SCREEN_TYPE_LVDS, LVDS_FORMAT_RGB0888, 1280, 480,20, 20, 13, 70, 70, 20, 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},
  70. {0},
  71. {0},//SCREEN_USER_TYPE
  72. };
  73. #define UPDATELOGO_DISPLAY_ADDR 0xE200000
  74. static int g_screen_id = 0;
  75. struct screen_info *g_screen_info;
  76. display_updatepara g_display_para;
  77. static void screen_info_show(struct screen_info *p_info)
  78. {
  79. printf("screen_id=%d------------------->\n",p_info->screen_id);
  80. printf("ScreenType:%d, subType:%d,Width:%d, Height:%d,Format:%d, TvoutType:%d,screen_id:%d,interlace:%d\r\n",
  81. 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);
  82. printf("RgbMode:%d ,BPP:%d ,pad_unset:%d\r\n", p_info->rgb_mode,p_info->bpp,p_info->pad_unset);
  83. printf("HFP:%d,HBP:%d,HSW:%d,VBP:%d,VFP:%d,VSW:%d,HSYNCPolarity:0x%0x,VSYNCPolarity:0x%0x ,DEPolarity:%d\r\n",
  84. 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);
  85. printf("CLKSource:%d,CLKFreq:%d,CLKDIV1:%d,CLKDIV2:%d,CLKPolarity:%d,LVDSCfg:0x%0x,FrameRate:%d,\r\n",
  86. 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);
  87. }
  88. static void updating_init(void)
  89. {
  90. int i;
  91. unsigned int *p = (unsigned int *)(UPDATELOGO_DISPLAY_ADDR);
  92. unsigned int color = 0xffffffff;
  93. int pos = 0;
  94. for(i = 0; i < UPDATING_WIDTH*UPDATING_HEIGHT; i++){
  95. if(updating[pos] == i){
  96. *p = color;
  97. pos++;
  98. }
  99. p++;
  100. }
  101. }
  102. static void update_progress_init(void)
  103. {
  104. int i, j;
  105. unsigned int *p = (unsigned int *)(UPDATELOGO_DISPLAY_ADDR + UPDATING_HEIGHT*PROGRESS_WIDTH*4);
  106. int height = UPDATE_LOGO_HEIGHT;
  107. unsigned int color = 0xffffffff;
  108. for(j = UPDATING_HEIGHT; j < height; j++){
  109. for(i = 0; i < PROGRESS_WIDTH; i++){
  110. if(j < (UPDATING_HEIGHT + 2) || j > (height -3) || \
  111. i < 2 || i > (PROGRESS_WIDTH -3)){
  112. *p = color;
  113. }
  114. p++;
  115. }
  116. }
  117. }
  118. static void update_progress_set(int percent)
  119. {
  120. int i, j, end;;
  121. unsigned int *p = (unsigned int *)(UPDATELOGO_DISPLAY_ADDR + UPDATING_HEIGHT*PROGRESS_WIDTH*4);
  122. int height = UPDATE_LOGO_HEIGHT;
  123. unsigned int color = 0xff00ff00;
  124. if(percent < 0 || percent > 100){
  125. printf("update progress percent=%d, error.",percent);
  126. return;
  127. }
  128. end = percent * (PROGRESS_WIDTH-3)/100;
  129. for(j = UPDATING_HEIGHT; j < height; j++){
  130. for(i = 0; i < PROGRESS_WIDTH; i++){
  131. if(j > (UPDATING_HEIGHT + 2) && j < (height -3) \
  132. && i > 2 && i < end){
  133. *p = color;
  134. }
  135. p++;
  136. }
  137. }
  138. if(percent >= 90){
  139. udelay(200000);
  140. }
  141. else if(percent == 100){
  142. udelay(500000);
  143. ark_osd_en_layer(OSD2_LAYER, 0);
  144. }
  145. }
  146. static void display_updatelogo(void)
  147. {
  148. struct screen_info *screen = &screens[g_screen_id];
  149. int x, y, height;
  150. unsigned int src_width = UPDATE_LOGO_WIDTH;
  151. unsigned int src_height = UPDATE_LOGO_HEIGHT;
  152. memset((void *)UPDATELOGO_DISPLAY_ADDR, 0 , src_width*src_height*4);
  153. updating_init();
  154. update_progress_init();
  155. if (!IS_TVENC_SCREEN(screen))
  156. ark_disp_wait_lcd_frame_int();
  157. else
  158. ark_disp_wait_tvenc_frame_int();
  159. x = (screen->width - src_width) / 2;
  160. y = (screen->height - src_height) / 2;
  161. height = src_height;
  162. if (is_interlace_tvenc(screen)) {
  163. y /= 2;
  164. height /= 2;
  165. }
  166. ark_set_osd_image(OSD2_LAYER, DISP_RGB_888, src_width, height);
  167. ark_set_osd_addr(OSD2_LAYER, UPDATELOGO_DISPLAY_ADDR);
  168. ark_disp_set_osd_layer_position(OSD2_LAYER, x, y);
  169. //printf("---->%d %d %d %d.\n",x, y,src_width,height);
  170. }
  171. void ark_display_init(int screen_id)
  172. {
  173. struct screen_info *screen = &screens[screen_id];
  174. int interlace;
  175. //lcd clk enable
  176. rSYS_AHB_CLK_EN |= 1 << 8;
  177. rSYS_AXI_CLK_EN |= 1 << 1;
  178. rSYS_PER_CLK_EN |= 1 << 4;
  179. screen_info_show(screen);
  180. g_screen_info = screen;
  181. memset(&g_display_para, 0 ,sizeof(g_display_para));
  182. memcpy(&g_display_para.screeninfo, screen, sizeof(struct screen_info));
  183. ark_backlight_config_f(screen->screen_id);
  184. ark_display_initialize_port(screen);
  185. interlace = is_interlace_tvenc(screen);
  186. display_updatelogo();
  187. ark_osd_en_layer(OSD2_LAYER, 1);
  188. ark_osd_en_layer(OSD1_LAYER, 0);
  189. if (IS_TVENC_SCREEN(screen) && interlace) {
  190. ark_set_osd_frame_mode(OSD2_LAYER, 1);
  191. }
  192. ark_backlight_config(screen->screen_id);
  193. }
  194. int do_disconfig (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  195. {
  196. unsigned long percent = 0;
  197. int ret;
  198. if(argc < 2)
  199. return cmd_usage(cmdtp);
  200. ret = strict_strtoul(argv[1], 10, &percent);
  201. if(ret < 0){
  202. printf("error format screen id\n");
  203. }
  204. if(percent > 100)
  205. {
  206. printf("Invalide param.\n");
  207. return cmd_usage(cmdtp);
  208. }
  209. if(percent == 0){
  210. g_screen_id = SCREEN_CLAA101;
  211. ark_display_init(g_screen_id);
  212. printf("ark display init g_screen_id=%d.\n",g_screen_id);
  213. }else{
  214. update_progress_set(percent);
  215. printf("update progress set percent=%ld.\n",percent);
  216. }
  217. return 0;
  218. }
  219. /***************************************************/
  220. U_BOOT_CMD(
  221. disconfig, CONFIG_SYS_MAXARGS, 0, do_disconfig,
  222. "config display",
  223. "disconfig percent\n"
  224. "percent(0:) \n"
  225. );