mt_logo.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("MediaTek Software") are
  4. * protected under relevant copyright laws. The information contained herein
  5. * is confidential and proprietary to MediaTek Inc. and/or its licensors.
  6. * Without the prior written permission of MediaTek inc. and/or its licensors,
  7. * any reproduction, modification, use or disclosure of MediaTek Software,
  8. * and information contained herein, in whole or in part, shall be strictly prohibited.
  9. */
  10. /* MediaTek Inc. (C) 2015. All rights reserved.
  11. *
  12. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  13. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  14. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
  15. * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  18. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  19. * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  20. * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
  21. * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
  22. * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
  23. * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
  24. * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  25. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
  26. * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  27. * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  28. * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
  29. * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  30. */
  31. #include <debug.h>
  32. #include <platform/mt_typedefs.h>
  33. #include <platform/mt_disp_drv.h>
  34. #include <platform/mt_logo.h>
  35. #include <platform/disp_drv_platform.h>
  36. #include <env.h>
  37. #include <target/board.h>
  38. #include "lcm_drv.h"
  39. #include <string.h>
  40. #include <stdlib.h>
  41. /* show logo header file */
  42. #include <show_logo_common.h>
  43. #include <decompress_common.h>
  44. #include <show_animation_common.h>
  45. /* Operator number */
  46. #define OPTR_NUM_OP01 1
  47. #define OPTR_NUM_OP02 2
  48. #define OPTR_NUM_OP09 9
  49. /* Count of logos for different charging animations */
  50. #define LOGOS_COUNT_NORMAL_CHARGING_ANIM 38
  51. #define LOGOS_COUNT_FAST_CHARGING_ANIM 18
  52. #define LOGOS_COUNT_WIRELESS_CHARGING_ANIM 29
  53. #define MAX_OPERATOR_SUPPORT 5
  54. LCM_SCREEN_T phical_screen;
  55. void *logo_addr = NULL;
  56. static LOGO_CUST_IF *logo_cust_if = NULL;
  57. /*
  58. * Get default operator.
  59. *
  60. */
  61. #if defined(MTK_CARRIEREXPRESS_PACK)
  62. #ifdef GLOBAL_DEVICE_DEFAULT_OPTR
  63. static int get_default_operator()
  64. {
  65. /* Hardcoded values represent operator number. For example,1 means OP01, 2 means OP02.... n means OP0N. */
  66. #if GLOBAL_DEVICE_DEFAULT_OPTR == OPTR_NUM_OP01
  67. return OPTR_NUM_OP01;
  68. #elif GLOBAL_DEVICE_DEFAULT_OPTR == OPTR_NUM_OP02
  69. return OPTR_NUM_OP02;
  70. #elif GLOBAL_DEVICE_DEFAULT_OPTR == OPTR_NUM_OP09
  71. return OPTR_NUM_OP09;
  72. #else
  73. return 0;
  74. #endif
  75. }
  76. #endif
  77. /*
  78. * get Logo index when the global device feature is enabled.
  79. *
  80. */
  81. static int get_logo_index()
  82. {
  83. int logo_index = 0;
  84. int optrs[MAX_OPERATOR_SUPPORT];
  85. char* active_optr = NULL;
  86. int i = 0, j = 0, optr_index = -1, optr_number = -1;
  87. #if defined(MTK_CARRIEREXPRESS_PACK_OP01)
  88. optrs[i++] = OPTR_NUM_OP01;
  89. #endif
  90. #if defined(MTK_CARRIEREXPRESS_PACK_OP02)
  91. optrs[i++] = OPTR_NUM_OP02;
  92. #endif
  93. #if defined(MTK_CARRIEREXPRESS_PACK_OP09)
  94. optrs[i++] = OPTR_NUM_OP09;
  95. #endif
  96. dprintf(INFO, "[lk logo: get_logo_index() - Optr Count: %d]\n",i);
  97. logo_index = 1; // this is for OM LK logo.
  98. #if !defined(MTK_ALPS_BOX_SUPPORT)
  99. logo_index += LOGOS_COUNT_NORMAL_CHARGING_ANIM;
  100. #endif
  101. #if defined(MTK_PUMP_EXPRESS_SUPPORT) || defined(MTK_PUMP_EXPRESS_PLUS_SUPPORT)
  102. logo_index += LOGOS_COUNT_FAST_CHARGING_ANIM;
  103. #endif
  104. #if defined(MTK_WIRELESS_CHARGER_SUPPORT)
  105. logo_index += LOGOS_COUNT_WIRELESS_CHARGING_ANIM;
  106. #endif
  107. // sysenv read property.
  108. active_optr = (char *)get_env("mtk_usp_operator");
  109. if (active_optr == NULL) {
  110. #if !defined(GLOBAL_DEVICE_DEFAULT_OPTR)
  111. dprintf(INFO, "[lk logo: get_logo_index() - Show OM]\n");
  112. return 0;
  113. #else
  114. dprintf(INFO, "[lk logo: get_logo_index() - Default Operator]\n");
  115. optr_number = get_default_operator();
  116. #endif
  117. } else {
  118. dprintf(INFO, "[lk logo: get_logo_index() - Active Optr Number : %d]\n",atoi(active_optr));
  119. optr_number = atoi(active_optr);
  120. }
  121. for (j = 0; j < i && j < MAX_OPERATOR_SUPPORT; j++) {
  122. if (optrs[j] == optr_number) {
  123. dprintf(INFO, "[lk logo: get_logo_index() - Active Optr Index : %d]\n",j);
  124. optr_index = j;
  125. break;
  126. }
  127. }
  128. if (optr_index == -1) {
  129. dprintf(INFO, "[lk logo: get_logo_index() - Operator not present in region : %d]\n",optr_number);
  130. return 0; //show OM
  131. }
  132. dprintf(INFO, "[lk logo: get_logo_index() - Logo index without Optr : %d]\n",logo_index);
  133. logo_index = logo_index + optr_index*2; // calculate the LK Logo index#endif
  134. dprintf(INFO, "[lk logo: get_logo_index() - Logo index with Optr : %d]\n",logo_index);
  135. return logo_index;
  136. }
  137. #endif
  138. /********** show_animationm_ver: charging animation version ************/
  139. /* */
  140. /* version 0: show 4 recatangle growing animation without battery number */
  141. /* version 1: show wave animation with battery number */
  142. /* */
  143. /*** ***/
  144. int show_animationm_ver = 0;
  145. /*
  146. * Get the defined charging animation version
  147. *
  148. */
  149. void sync_anim_version()
  150. {
  151. dprintf(INFO, "[lk logo: %s %d]\n",__FUNCTION__,__LINE__);
  152. #ifdef ANIMATION_NEW
  153. show_animationm_ver = 1 ;
  154. #else
  155. show_animationm_ver = 0 ;
  156. dprintf(INFO, "[lk logo %s %d]not define ANIMATION_NEW:show old animation \n",__FUNCTION__,__LINE__);
  157. #endif
  158. }
  159. /*
  160. * Initliaze charging animation parameters
  161. *
  162. */
  163. void init_fb_screen()
  164. {
  165. dprintf(INFO, "[lk logo: %s %d]\n",__FUNCTION__,__LINE__);
  166. unsigned int fb_size = mt_get_fb_size();
  167. logo_addr = mt_get_logo_db_addr();
  168. phical_screen.width = CFG_DISPLAY_WIDTH;
  169. phical_screen.height = CFG_DISPLAY_HEIGHT;
  170. phical_screen.fb_size = fb_size;
  171. phical_screen.fill_dst_bits = CFG_DISPLAY_BPP;
  172. phical_screen.bits_per_pixel = CFG_DISPLAY_BPP;
  173. // in JB2.MP need to allign width and height to 32 ,but jb5.mp needn't
  174. phical_screen.needAllign = 1;
  175. phical_screen.allignWidth = ALIGN_TO(CFG_DISPLAY_WIDTH, MTK_FB_ALIGNMENT);
  176. /* In GB, no need to adjust 180 showing logo ,for fb driver dealing the change */
  177. /* but in JB, need adjust it for screen 180 roration */
  178. phical_screen.need180Adjust = 0; // need sync with chip driver
  179. dprintf(INFO, "[lk logo: %s %d]MTK_LCM_PHYSICAL_ROTATION = %s\n",__FUNCTION__,__LINE__, MTK_LCM_PHYSICAL_ROTATION);
  180. if (0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "270", 3)) {
  181. phical_screen.rotation = 270;
  182. } else if (0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "90", 2)) {
  183. phical_screen.rotation = 90;
  184. } else if (0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "180", 3) && (phical_screen.need180Adjust == 1)) {
  185. phical_screen.rotation = 180;
  186. } else {
  187. phical_screen.rotation = 0;
  188. }
  189. sync_anim_version();
  190. if (show_animationm_ver == 1) {
  191. unsigned int logonum;
  192. unsigned int *db_addr = logo_addr;
  193. unsigned int *pinfo = (unsigned int*)db_addr;
  194. logonum = pinfo[0];
  195. dprintf(INFO, "[lk logo: %s %d]pinfo[0]=0x%08x, pinfo[1]=0x%08x, pinfo[2]=%d\n", __FUNCTION__,__LINE__,
  196. pinfo[0], pinfo[1], pinfo[2]);
  197. dprintf(INFO, "[lk logo: %s %d]define ANIMATION_NEW:show new animation with capacity num\n",__FUNCTION__,__LINE__);
  198. dprintf(INFO, "[lk logo: %s %d]CAPACITY_LEFT =%d, CAPACITY_TOP =%d \n",__FUNCTION__,__LINE__,(CAPACITY_LEFT) ,(CAPACITY_TOP) );
  199. dprintf(INFO, "[lk logo: %s %d]LCM_HEIGHT=%d, LCM_WIDTH=%d \n",__FUNCTION__,__LINE__,(CAPACITY_RIGHT),(CAPACITY_BOTTOM));
  200. if (logonum < 6) {
  201. show_animationm_ver = 0 ;
  202. } else {
  203. show_animationm_ver = 1 ;
  204. }
  205. }
  206. }
  207. /*
  208. * Custom interface
  209. *
  210. */
  211. void mt_logo_get_custom_if(void)
  212. {
  213. if (logo_cust_if == NULL) {
  214. logo_cust_if = (LOGO_CUST_IF *)LOGO_GetCustomIF();
  215. }
  216. }
  217. /*
  218. * Show first boot logo when phone boot up
  219. *
  220. */
  221. void mt_disp_show_boot_logo(void)
  222. {
  223. int logo_index = 0;
  224. int x = 0;
  225. char* test = NULL;
  226. dprintf(INFO, "[lk logo: %s %d]\n",__FUNCTION__,__LINE__);
  227. mt_logo_get_custom_if();
  228. #if defined(MTK_CARRIEREXPRESS_PACK)
  229. #if 0 // test
  230. test = (char *)get_env("VAIBHAV");
  231. if (test == NULL) {
  232. dprintf(INFO, "[lk logo: SysEnv is not set]\n");
  233. if (set_env("VAIBHAV","5") == 0) {
  234. dprintf(INFO, "[lk logo: SysEnv set to 5 Succesfully]\n");
  235. x = 1;
  236. } else {
  237. dprintf(INFO, "[lk logo: SysEnv set fails!!!]\n");
  238. return;
  239. }
  240. } else {
  241. dprintf(INFO, "[lk logo: SysEnv already set to %d]\n",atoi(test));
  242. }
  243. #endif
  244. logo_index = get_logo_index();
  245. /*if(x == 1){
  246. logo_index = 0;
  247. dprintf(INFO, "[lk logo: First Boot So show OM logo]\n");
  248. }*/
  249. dprintf(INFO, "[lk logo: Final logo_index: %d]\n",logo_index);
  250. #endif
  251. if (logo_cust_if->show_boot_logo) {
  252. logo_cust_if->show_boot_logo();
  253. } else {
  254. ///show_logo(0);
  255. init_fb_screen();
  256. fill_animation_logo(logo_index, mt_get_fb_addr(), mt_get_tempfb_addr(), logo_addr, phical_screen);
  257. mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
  258. }
  259. return;
  260. }
  261. /*
  262. * Custom interface : charging state
  263. *
  264. */
  265. void mt_disp_enter_charging_state(void)
  266. {
  267. mt_logo_get_custom_if();
  268. if (logo_cust_if->enter_charging_state) {
  269. logo_cust_if->enter_charging_state();
  270. } else {
  271. dprintf(INFO, "[lk logo: %s %d]do nothing \n",__FUNCTION__,__LINE__);
  272. }
  273. return;
  274. }
  275. /*
  276. * Show full battery when poweroff charging
  277. *
  278. */
  279. void mt_disp_show_battery_full(void)
  280. {
  281. dprintf(INFO, "[lk logo: %s %d]\n",__FUNCTION__,__LINE__);
  282. mt_disp_show_battery_capacity(100);
  283. }
  284. /*
  285. * Show animation when poweroff charging
  286. *
  287. */
  288. void mt_disp_show_battery_capacity(UINT32 capacity)
  289. {
  290. dprintf(INFO, "[lk logo: %s %d]capacity =%d\n",__FUNCTION__,__LINE__, capacity);
  291. mt_logo_get_custom_if();
  292. if (logo_cust_if->show_battery_capacity) {
  293. logo_cust_if->show_battery_capacity(capacity);
  294. } else {
  295. init_fb_screen();
  296. fill_animation_battery_by_ver(capacity, mt_get_fb_addr(), mt_get_tempfb_addr(), logo_addr, phical_screen, show_animationm_ver);
  297. mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
  298. }
  299. }
  300. /*
  301. * Show charging over logo
  302. *
  303. */
  304. void mt_disp_show_charger_ov_logo(void)
  305. {
  306. dprintf(INFO, "[lk logo: %s %d]\n",__FUNCTION__,__LINE__);
  307. mt_logo_get_custom_if();
  308. if (logo_cust_if->show_boot_logo) {
  309. logo_cust_if->show_boot_logo();
  310. } else {
  311. init_fb_screen();
  312. fill_animation_logo(CHARGER_OV_INDEX, mt_get_fb_addr(), mt_get_tempfb_addr(), logo_addr, phical_screen);
  313. mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
  314. }
  315. return;
  316. }
  317. /*
  318. * Show low battery logo
  319. *
  320. */
  321. void mt_disp_show_low_battery(void)
  322. {
  323. dprintf(INFO, "[lk logo: %s %d]\n",__FUNCTION__,__LINE__);
  324. mt_logo_get_custom_if();
  325. if (logo_cust_if->show_boot_logo) {
  326. logo_cust_if->show_boot_logo();
  327. } else {
  328. init_fb_screen();
  329. //show_logo(2);
  330. fill_animation_logo(LOW_BATTERY_INDEX, mt_get_fb_addr(), mt_get_tempfb_addr(), logo_addr, phical_screen);
  331. mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
  332. }
  333. return;
  334. }
  335. /*
  336. * Fill rectangle region for with black or other color
  337. *
  338. */
  339. void mt_disp_fill_rect(UINT32 left, UINT32 top,
  340. UINT32 right, UINT32 bottom,
  341. UINT32 color)
  342. {
  343. dprintf(INFO, "[lk logo: %s %d]\n",__FUNCTION__,__LINE__);
  344. init_fb_screen();
  345. RECT_REGION_T rect = {left, top, right, bottom};
  346. fill_rect_with_color(mt_get_fb_addr(), rect, color, phical_screen);
  347. }