mt_logo.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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/disp_drv.h>
  35. #include <platform/primary_display.h>
  36. #include <platform/mt_logo.h>
  37. #include <platform/disp_drv_platform.h>
  38. #include <env.h>
  39. #include <target/board.h>
  40. #include "lcm_drv.h"
  41. #include <string.h>
  42. #include <stdlib.h>
  43. /* show logo header file */
  44. #include <show_logo_common.h>
  45. #include <decompress_common.h>
  46. #include <show_animation_common.h>
  47. /* Operator number */
  48. #define OPTR_NUM_OP01 1
  49. #define OPTR_NUM_OP02 2
  50. #define OPTR_NUM_OP09 9
  51. /* Count of logos for different charging animations */
  52. #define LOGOS_COUNT_NORMAL_CHARGING_ANIM 38
  53. #define LOGOS_COUNT_FAST_CHARGING_ANIM 18
  54. #define LOGOS_COUNT_WIRELESS_CHARGING_ANIM 29
  55. #define MAX_OPERATOR_SUPPORT 5
  56. LCM_SCREEN_T phical_screen;
  57. void *logo_addr = NULL;
  58. static LOGO_CUST_IF *logo_cust_if = NULL;
  59. /*
  60. * Get default operator.
  61. *
  62. */
  63. #if defined(MTK_CARRIEREXPRESS_PACK)
  64. #ifdef GLOBAL_DEVICE_DEFAULT_OPTR
  65. static int get_default_operator()
  66. {
  67. /* Hardcoded values represent operator number. For example,1 means OP01, 2 means OP02.... n means OP0N. */
  68. #if GLOBAL_DEVICE_DEFAULT_OPTR == OPTR_NUM_OP01
  69. return OPTR_NUM_OP01;
  70. #elif GLOBAL_DEVICE_DEFAULT_OPTR == OPTR_NUM_OP02
  71. return OPTR_NUM_OP02;
  72. #elif GLOBAL_DEVICE_DEFAULT_OPTR == OPTR_NUM_OP09
  73. return OPTR_NUM_OP09;
  74. #else
  75. return 0;
  76. #endif
  77. }
  78. #endif
  79. /*
  80. * get Logo index when the global device feature is enabled.
  81. *
  82. */
  83. static int get_logo_index()
  84. {
  85. int logo_index = 0;
  86. int optrs[MAX_OPERATOR_SUPPORT];
  87. char* active_optr = NULL;
  88. int i = 0, j = 0, optr_index = -1, optr_number = -1;
  89. #if defined(MTK_CARRIEREXPRESS_PACK_OP01)
  90. optrs[i++] = OPTR_NUM_OP01;
  91. #endif
  92. #if defined(MTK_CARRIEREXPRESS_PACK_OP02)
  93. optrs[i++] = OPTR_NUM_OP02;
  94. #endif
  95. #if defined(MTK_CARRIEREXPRESS_PACK_OP09)
  96. optrs[i++] = OPTR_NUM_OP09;
  97. #endif
  98. dprintf(INFO, "[lk logo: get_logo_index() - Optr Count: %d]\n",i);
  99. logo_index = 1; // this is for OM LK logo.
  100. #if !defined(MTK_ALPS_BOX_SUPPORT)
  101. logo_index += LOGOS_COUNT_NORMAL_CHARGING_ANIM;
  102. #endif
  103. #if defined(MTK_PUMP_EXPRESS_SUPPORT) || defined(MTK_PUMP_EXPRESS_PLUS_SUPPORT)
  104. logo_index += LOGOS_COUNT_FAST_CHARGING_ANIM;
  105. #endif
  106. #if defined(MTK_WIRELESS_CHARGER_SUPPORT)
  107. logo_index += LOGOS_COUNT_WIRELESS_CHARGING_ANIM;
  108. #endif
  109. // sysenv read property.
  110. active_optr = (char *)get_env("mtk_usp_operator");
  111. if (active_optr == NULL) {
  112. #if !defined(GLOBAL_DEVICE_DEFAULT_OPTR)
  113. dprintf(INFO, "[lk logo: get_logo_index() - Show OM]\n");
  114. return 0;
  115. #else
  116. dprintf(INFO, "[lk logo: get_logo_index() - Default Operator]\n");
  117. optr_number = get_default_operator();
  118. #endif
  119. } else {
  120. dprintf(INFO, "[lk logo: get_logo_index() - Active Optr Number : %d]\n",atoi(active_optr));
  121. optr_number = atoi(active_optr);
  122. }
  123. for (j = 0; j < i && j < MAX_OPERATOR_SUPPORT; j++) {
  124. if (optrs[j] == optr_number) {
  125. dprintf(INFO, "[lk logo: get_logo_index() - Active Optr Index : %d]\n",j);
  126. optr_index = j;
  127. break;
  128. }
  129. }
  130. if (optr_index == -1) {
  131. dprintf(INFO, "[lk logo: get_logo_index() - Operator not present in region : %d]\n",optr_number);
  132. return 0; //show OM
  133. }
  134. dprintf(INFO, "[lk logo: get_logo_index() - Logo index without Optr : %d]\n",logo_index);
  135. logo_index = logo_index + optr_index*2; // calculate the LK Logo index#endif
  136. dprintf(INFO, "[lk logo: get_logo_index() - Logo index with Optr : %d]\n",logo_index);
  137. return logo_index;
  138. }
  139. #endif
  140. /********** show_animationm_ver: charging animation version ************/
  141. /* */
  142. /* version 0: show 4 recatangle growing animation without battery number */
  143. /* version 1: show wave animation with battery number */
  144. /* */
  145. /*** ***/
  146. int show_animationm_ver = 0;
  147. /*
  148. * Get the defined charging animation version
  149. *
  150. */
  151. void sync_anim_version()
  152. {
  153. dprintf(INFO, "[lk logo: %s %d]\n",__FUNCTION__,__LINE__);
  154. #ifdef ANIMATION_NEW
  155. show_animationm_ver = 1 ;
  156. #else
  157. show_animationm_ver = 0 ;
  158. dprintf(INFO, "[lk logo %s %d]not define ANIMATION_NEW:show old animation \n",__FUNCTION__,__LINE__);
  159. #endif
  160. }
  161. /*
  162. * Initliaze charging animation parameters
  163. *
  164. */
  165. void init_fb_screen()
  166. {
  167. dprintf(INFO, "[lk logo: %s %d]\n",__FUNCTION__,__LINE__);
  168. unsigned int fb_size = mt_get_fb_size();
  169. logo_addr = mt_get_logo_db_addr();
  170. phical_screen.width = CFG_DISPLAY_WIDTH;
  171. phical_screen.height = CFG_DISPLAY_HEIGHT;
  172. phical_screen.fb_size = fb_size;
  173. phical_screen.fill_dst_bits = CFG_DISPLAY_BPP;
  174. phical_screen.bits_per_pixel = CFG_DISPLAY_BPP;
  175. // in JB2.MP need to allign width and height to 32 ,but jb5.mp needn't
  176. phical_screen.needAllign = 1;
  177. phical_screen.allignWidth = ALIGN_TO(CFG_DISPLAY_WIDTH, MTK_FB_ALIGNMENT);
  178. /* In GB, no need to adjust 180 showing logo ,for fb driver dealing the change */
  179. /* but in JB, need adjust it for screen 180 roration */
  180. phical_screen.need180Adjust = 0; // need sync with chip driver
  181. dprintf(INFO, "[lk logo: %s %d]MTK_LCM_PHYSICAL_ROTATION = %s\n",__FUNCTION__,__LINE__, MTK_LCM_PHYSICAL_ROTATION);
  182. if (0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "270", 3)) {
  183. phical_screen.rotation = 270;
  184. } else if (0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "90", 2)) {
  185. phical_screen.rotation = 90;
  186. } else if (0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "180", 3) && (phical_screen.need180Adjust == 1)) {
  187. phical_screen.rotation = 180;
  188. } else {
  189. phical_screen.rotation = 0;
  190. }
  191. sync_anim_version();
  192. if (show_animationm_ver == 1) {
  193. unsigned int logonum;
  194. unsigned int *db_addr = logo_addr;
  195. unsigned int *pinfo = (unsigned int*)db_addr;
  196. logonum = pinfo[0];
  197. dprintf(INFO, "[lk logo: %s %d]pinfo[0]=0x%08x, pinfo[1]=0x%08x, pinfo[2]=%d\n", __FUNCTION__,__LINE__,
  198. pinfo[0], pinfo[1], pinfo[2]);
  199. dprintf(INFO, "[lk logo: %s %d]define ANIMATION_NEW:show new animation with capacity num\n",__FUNCTION__,__LINE__);
  200. dprintf(INFO, "[lk logo: %s %d]CAPACITY_LEFT =%d, CAPACITY_TOP =%d \n",__FUNCTION__,__LINE__,(CAPACITY_LEFT) ,(CAPACITY_TOP) );
  201. dprintf(INFO, "[lk logo: %s %d]LCM_HEIGHT=%d, LCM_WIDTH=%d \n",__FUNCTION__,__LINE__,(CAPACITY_RIGHT),(CAPACITY_BOTTOM));
  202. if (logonum < 6) {
  203. show_animationm_ver = 0 ;
  204. } else {
  205. show_animationm_ver = 1 ;
  206. }
  207. }
  208. }
  209. /*
  210. * Custom interface
  211. *
  212. */
  213. void mt_logo_get_custom_if(void)
  214. {
  215. if (logo_cust_if == NULL) {
  216. logo_cust_if = (LOGO_CUST_IF *)LOGO_GetCustomIF();
  217. }
  218. }
  219. /*
  220. * Show first boot logo when phone boot up
  221. *
  222. */
  223. void mt_disp_show_boot_logo(void)
  224. {
  225. int logo_index = 0;
  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. }