--- /dev/null
+# ---- Target contents ----------------------------------------------------- #
+VERBATIMS="
+/usr/share/fota/res/images/tw_fota_downloading_0.png
+/usr/share/fota/res/images/tw_fota_downloading_1.png
+/usr/share/fota/res/images/tw_fota_downloading_2.png
+/usr/share/fota/res/images/tw_fota_downloading_3.png
+/usr/share/fota/res/images/tw_fota_downloading_4.png
+/usr/share/fota/res/images/tw_fota_downloading_5.png
+/usr/share/fota/res/images/tw_fota_downloading_6.png
+/usr/share/fota/res/images/tw_fota_downloading_7.png
+/usr/share/fota/res/images/tw_fota_downloading_8.png
+/usr/share/fota/res/images/tw_fota_downloading_9.png
+/usr/share/fota/res/images/tw_fota_downloading_percent.png
+/usr/share/fota/res/images/tw_fota_progress_000.png
+/usr/share/fota/res/images/tw_fota_progress_001.png
+/usr/share/fota/res/images/tw_fota_progress_002.png
+/usr/share/fota/res/images/tw_fota_progress_003.png
+/usr/share/fota/res/images/tw_fota_progress_004.png
+/usr/share/fota/res/images/tw_fota_progress_005.png
+/usr/share/fota/res/images/tw_fota_progress_006.png
+/usr/share/fota/res/images/tw_fota_progress_007.png
+/usr/share/fota/res/images/tw_fota_progress_008.png
+/usr/share/fota/res/images/tw_fota_progress_009.png
+/usr/share/fota/res/images/tw_fota_progress_010.png
+/usr/share/fota/res/images/tw_fota_progress_011.png
+/usr/share/fota/res/images/tw_fota_progress_012.png
+/usr/share/fota/res/images/tw_fota_progress_013.png
+/usr/share/fota/res/images/tw_fota_progress_014.png
+/usr/share/fota/res/images/tw_fota_progress_015.png
+/usr/share/fota/res/images/tw_fota_progress_016.png
+/usr/share/fota/res/images/tw_fota_progress_017.png
+/usr/share/fota/res/images/tw_fota_progress_018.png
+/usr/share/fota/res/images/tw_fota_progress_019.png
+/usr/share/fota/res/images/tw_fota_progress_020.png
+/usr/share/fota/res/images/tw_fota_progress_021.png
+/usr/share/fota/res/images/tw_fota_progress_022.png
+/usr/share/fota/res/images/tw_fota_progress_023.png
+/usr/share/fota/res/images/tw_fota_progress_024.png
+/usr/share/fota/res/images/tw_fota_progress_025.png
+/usr/share/fota/res/images/tw_fota_progress_026.png
+/usr/share/fota/res/images/tw_fota_progress_027.png
+/usr/share/fota/res/images/tw_fota_progress_028.png
+/usr/share/fota/res/images/tw_fota_progress_029.png
+/usr/share/fota/res/images/tw_fota_progress_030.png
+/usr/share/fota/res/images/tw_fota_progress_031.png
+/usr/share/fota/res/images/tw_fota_progress_032.png
+/usr/share/fota/res/images/tw_fota_progress_033.png
+/usr/share/fota/res/images/tw_fota_progress_034.png
+/usr/share/fota/res/images/tw_fota_progress_035.png
+/usr/share/fota/res/images/tw_fota_progress_036.png
+/usr/share/fota/res/images/tw_fota_progress_037.png
+/usr/share/fota/res/images/tw_fota_progress_038.png
+/usr/share/fota/res/images/tw_fota_progress_039.png
+/usr/share/fota/res/images/tw_fota_progress_040.png
+/usr/share/fota/res/images/tw_fota_progress_041.png
+/usr/share/fota/res/images/tw_fota_progress_042.png
+/usr/share/fota/res/images/tw_fota_progress_043.png
+/usr/share/fota/res/images/tw_fota_progress_044.png
+/usr/share/fota/res/images/tw_fota_progress_045.png
+/usr/share/fota/res/images/tw_fota_progress_046.png
+/usr/share/fota/res/images/tw_fota_progress_047.png
+/usr/share/fota/res/images/tw_fota_progress_048.png
+/usr/share/fota/res/images/tw_fota_progress_049.png
+/usr/share/fota/res/images/tw_fota_progress_050.png
+/usr/share/fota/res/images/tw_fota_progress_051.png
+/usr/share/fota/res/images/tw_fota_progress_052.png
+/usr/share/fota/res/images/tw_fota_progress_053.png
+/usr/share/fota/res/images/tw_fota_progress_054.png
+/usr/share/fota/res/images/tw_fota_progress_055.png
+/usr/share/fota/res/images/tw_fota_progress_056.png
+/usr/share/fota/res/images/tw_fota_progress_057.png
+/usr/share/fota/res/images/tw_fota_progress_058.png
+/usr/share/fota/res/images/tw_fota_progress_059.png
+/usr/share/fota/res/images/tw_fota_progress_060.png
+/usr/share/fota/res/images/tw_fota_progress_061.png
+/usr/share/fota/res/images/tw_fota_progress_062.png
+/usr/share/fota/res/images/tw_fota_progress_063.png
+/usr/share/fota/res/images/tw_fota_progress_064.png
+/usr/share/fota/res/images/tw_fota_progress_065.png
+/usr/share/fota/res/images/tw_fota_progress_066.png
+/usr/share/fota/res/images/tw_fota_progress_067.png
+/usr/share/fota/res/images/tw_fota_progress_068.png
+/usr/share/fota/res/images/tw_fota_progress_069.png
+/usr/share/fota/res/images/tw_fota_progress_070.png
+/usr/share/fota/res/images/tw_fota_progress_071.png
+/usr/share/fota/res/images/tw_fota_progress_072.png
+/usr/share/fota/res/images/tw_fota_progress_073.png
+/usr/share/fota/res/images/tw_fota_progress_074.png
+/usr/share/fota/res/images/tw_fota_progress_075.png
+/usr/share/fota/res/images/tw_fota_progress_076.png
+/usr/share/fota/res/images/tw_fota_progress_077.png
+/usr/share/fota/res/images/tw_fota_progress_078.png
+/usr/share/fota/res/images/tw_fota_progress_079.png
+/usr/share/fota/res/images/tw_fota_progress_080.png
+/usr/share/fota/res/images/tw_fota_progress_081.png
+/usr/share/fota/res/images/tw_fota_progress_082.png
+/usr/share/fota/res/images/tw_fota_progress_083.png
+/usr/share/fota/res/images/tw_fota_progress_084.png
+/usr/share/fota/res/images/tw_fota_progress_085.png
+/usr/share/fota/res/images/tw_fota_progress_086.png
+/usr/share/fota/res/images/tw_fota_progress_087.png
+/usr/share/fota/res/images/tw_fota_progress_088.png
+/usr/share/fota/res/images/tw_fota_progress_089.png
+/usr/share/fota/res/images/tw_fota_progress_090.png
+/usr/share/fota/res/images/tw_fota_progress_091.png
+/usr/share/fota/res/images/tw_fota_progress_092.png
+/usr/share/fota/res/images/tw_fota_progress_093.png
+/usr/share/fota/res/images/tw_fota_progress_094.png
+/usr/share/fota/res/images/tw_fota_progress_095.png
+/usr/share/fota/res/images/tw_fota_progress_096.png
+/usr/share/fota/res/images/tw_fota_progress_097.png
+/usr/share/fota/res/images/tw_fota_progress_098.png
+/usr/share/fota/res/images/tw_fota_progress_099.png
+/usr/share/fota/res/images/tw_fota_progress_100.png
+/usr/share/fota/res/images/tw_fota_progress_bg.png
+/usr/share/fota/res/images/tw_fota_progress_final.png
+/usr/share/fota/res/images/tw_start_downloading.png
+"
+
+WITHLIBS="
+/usr/bin/fota_gui
+/usr/lib/tdm/libtdm-default.so
+/usr/lib/bufmgr/libtbm_default.so
+"
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(tota-gui C)
+
+ADD_DEFINITIONS("-DFEATURE_SUPPORT_CAPABILITY")
+
+STRING(FIND ${CMAKE_C_FLAGS} "mfloat-abi=hard" IFFOUND1)
+STRING(FIND ${CMAKE_C_FLAGS} "mhard-float" IFFOUND2)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/)
+
+SET(PACKAGE ${PROJECT_NAME})
+SET(PKGNAME "${PACKAGE}")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/bin")
+SET(PKGDIR "${PREFIX}/share/fota")
+SET(RESDIR "${PKGDIR}/res")
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -fPIE")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -pie")
+
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/wearable/images DESTINATION ${RESDIR})
+ADD_SUBDIRECTORY(fota_gui)
+ADD_SUBDIRECTORY(rw-update-ani)
+
--- /dev/null
+Copyright (c) 2000 - 2020 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+\r
+\r
--- /dev/null
+Copyright (c) 2000 - 2020 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under the Apache License, Version 2.0.
+Please, see the LICENSE.APLv2 file for Apache License, Version 2 terms and conditions.
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+ <assign>
+ <filesystem path="/usr/bin/*" exec_label="none" />
+ </assign>
+</manifest>
+
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+#set( CMAKE_VERBOSE_MAKEFILE on )
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/bin")
+SET(FOTA_GUI "fota_gui")
+
+
+STRING(FIND ${CMAKE_C_FLAGS} "mfloat-abi=hard" IFFOUND1)
+STRING(FIND ${CMAKE_C_FLAGS} "mhard-float" IFFOUND2)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(gui_pkgs REQUIRED
+ libtbm
+ libtdm
+ libpng
+)
+SET(GUI_SRCS
+ fota_gui_main.c
+ fota_gr.c
+ fota_png.c
+ fota_gui_util.c
+ tdm-if.c
+)
+
+FOREACH(flag ${gui_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+
+SET(GUI_SRCS ${GUI_SRCS} fota_gr_direct_tw.c)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -pie")
+
+ADD_EXECUTABLE(${FOTA_GUI} ${GUI_SRCS})
+TARGET_LINK_LIBRARIES(${FOTA_GUI} ${gui_pkgs_LDFLAGS} ${LIBS} -lpthread)
+
+INSTALL(TARGETS ${FOTA_GUI} DESTINATION ${BINDIR})
+INSTALL(TARGETS ${FOTA_GUI_TEST} DESTINATION ${BINDIR})
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FOTA_FBINFO_H__
+#define __FOTA_FBINFO_H__
+
+typedef struct _FbInfo {
+ unsigned char *buf[2];
+ unsigned int current_fb_id;
+ int w;
+ int h;
+ int sz;
+ int degree;
+ int full_flag;
+} FbInfo;
+
+#endif /* __FOTA_FBINFO_H__ */
+
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "fota_gr.h"
+#if defined(USE_CAIRO)
+#include "fota_gr_cairo.h"
+#else
+#include "fota_gr_direct.h"
+#endif
+
+/*-----------------------------------------------------------------------------
+ fota_gr_init
+ ----------------------------------------------------------------------------*/
+int fota_gr_init(void)
+{
+#if defined(USE_CAIRO)
+ return fota_gr_cairo_init();
+#else
+ return fota_gr_direct_init();
+#endif
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_deinit
+ ----------------------------------------------------------------------------*/
+void fota_gr_deinit(void)
+{
+#if defined(USE_CAIRO)
+ fota_gr_cairo_deinit();
+#else
+ fota_gr_direct_deinit();
+#endif
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_clear_screen
+ ----------------------------------------------------------------------------*/
+void fota_gr_clear_screen(u32 color)
+{
+#if defined(USE_CAIRO)
+ fota_gr_cairo_clear_screen(color);
+#else
+ fota_gr_direct_clear_screen(color);
+#endif
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_update_progress
+ ----------------------------------------------------------------------------*/
+void fota_gr_update_progress(int percent)
+{
+#if defined(USE_CAIRO)
+ fota_gr_cairo_update_progress(percent);
+#else
+ fota_gr_direct_update_progress(percent);
+#endif
+}
+
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FOTA_GR_H__
+#define __FOTA_GR_H__
+
+extern int fota_gr_init(void);
+extern void fota_gr_deinit(void);
+extern void fota_gr_update_progress(int percent);
+extern void fota_gr_clear_screen(unsigned int color);
+
+extern void fota_gr_direct_circular_progress(void);
+#endif /* __FOTA_GR_H__ */
+
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FOTA_GR_DIRECT_H__
+#define __FOTA_GR_DIRECT_H__
+
+#include "fota_gui_common.h"
+
+extern int fota_gr_direct_init(void);
+extern void fota_gr_direct_deinit(void);
+extern void fota_gr_direct_clear_screen(u32 color);
+extern void fota_gr_direct_update_progress(int percent);
+
+#endif /* __FOTA_GR_DIRECT_H__ */
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*****************************************************************************
+** header files
+*****************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "fota_gui_common.h"
+#include "fota_png.h"
+#include "fota_fbinfo.h"
+#include "tdm-if.h"
+
+#define UNUSED(x) (void)(x)
+
+#define COLOR_BLACK 0x0000
+
+#define MAX_PATH 256
+#define MAX_FILE_PATH 512
+
+#if !defined(RESDIR)
+#define RESDIR "/usr/share/fota/res"
+#endif
+#define IMG_BASE RESDIR "/images/"
+
+#define MAIN_IMG_NAME "tw_start_downloading.png"
+#define MAIN_PG_IMG_NAME "tw_fota_progress_bg.png"
+#define PROGRESS_BAR_IMG_PREFIX "tw_fota_progress_"
+#define PROGRESS_NUM_PREFIX "tw_fota_downloading_"
+#define PERCENT_IMG_NAME "tw_fota_downloading_percent.png"
+
+/*****************************************************************************
+** global variables
+*****************************************************************************/
+FbInfo s_fbi;
+tdm_if_disp s_disp;
+
+int s_percent_to_draw = 0;
+int s_saved_percent = -1;
+
+/*-----------------------------------------------------------------------------
+ fb_open()
+ ----------------------------------------------------------------------------*/
+int fb_open(FbInfo *fbi)
+{
+ memset(&s_disp, 0x00, sizeof(struct _tdm_if_disp));
+
+ if (tdm_if_display_init(&s_disp)) {
+ LOGE("tdm_if_display_init fail!!\n");
+ return -1;
+ }
+
+ fbi->buf[FRONT_BUFFER] = s_disp.buffer[FRONT_BUFFER];
+ fbi->buf[BACK_BUFFER] = s_disp.buffer[BACK_BUFFER];
+ fbi->current_fb_id = s_disp.current_buf_id;
+ fbi->w = s_disp.width;
+ fbi->h = s_disp.height;
+ fbi->sz = s_disp.buffer_size;
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------
+ fb_close()
+ ----------------------------------------------------------------------------*/
+void fb_close(FbInfo *fbi)
+{
+ UNUSED(fbi);
+ tdm_if_display_deinit(&s_disp);
+}
+
+/*------------------------------------------------------------------------------
+ fb_display()
+------------------------------------------------------------------------------*/
+int fb_display(FbInfo *fbi)
+{
+ s_disp.current_buf_id = fbi->current_fb_id;
+ LOG("current_fb_id : %d\n", fbi->current_fb_id);
+ tdm_if_display_update(&s_disp);
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------
+ fb_draw_img_forced_update()
+ ----------------------------------------------------------------------------*/
+void fb_draw_img_forced_update(FbInfo *fbi)
+{
+ int ret = 0;
+ ret = fb_display(fbi);
+ LOG("current_fb_id : %d, ret : %d\n", fbi->current_fb_id, ret);
+}
+/*-----------------------------------------------------------------------------
+ fb_draw_img_check_lcd_on()
+ ----------------------------------------------------------------------------*/
+void fb_draw_img_check_lcd_on(FbInfo *fbi)
+{
+
+ int ret = 0;
+
+ fbi->current_fb_id = FRONT_BUFFER;
+
+ LOG("current_fb_id :%d\n", fbi->current_fb_id);
+
+ ret = fb_display(fbi);
+
+ LOG("%s - drawing... ret : %d\n", __func__, ret);
+}
+
+/*-----------------------------------------------------------------------------
+ fb_clear_screen()
+ ----------------------------------------------------------------------------*/
+void fb_clear_screen(FbInfo *fbi, unsigned int color)
+{
+ unsigned int *fb_buf_cur = NULL;
+ int loop_count = fbi->w * fbi->h;
+
+ fb_buf_cur = (unsigned int *)fbi->buf[FRONT_BUFFER];
+
+ if (fb_buf_cur == NULL) {
+ LOG("fb_buf_cur is null error...\n");
+ return;
+ }
+ while (loop_count--)
+ *(fb_buf_cur++) = color;
+
+}
+
+/*-----------------------------------------------------------------------------
+ _gr_direct_fill_rect
+ ----------------------------------------------------------------------------*/
+static void _gr_direct_fill_rect(FbInfo *fbi, s32 x, s32 y, s32 w, s32 h, u32 color)
+{
+ unsigned int *fb_buf_int = NULL;
+ unsigned int *fb_buf_cur = NULL;
+ s32 dx = 0;
+ s32 dy = 0;
+ s32 wb = 0;
+
+ if (NULL == fbi)
+ return;
+
+ dx = w;
+ dy = h;
+ wb = w * sizeof(u32);
+
+ fb_buf_int = (unsigned int *)fbi->buf[FRONT_BUFFER];
+ fb_buf_int += y * fbi->w + x;
+ fb_buf_cur = fb_buf_int;
+
+ while (dx--)
+ *fb_buf_cur++ = color;
+
+ fb_buf_cur -= w;
+ fb_buf_cur += fbi->w;
+ dy--;
+ while (dy--) {
+ memcpy((void*)fb_buf_cur, (void*)fb_buf_int, wb);
+ fb_buf_cur += fbi->w;
+ }
+
+}
+
+/*-----------------------------------------------------------------------------
+ _gr_direct_clear_screen
+ ----------------------------------------------------------------------------*/
+static void _gr_direct_clear_screen(FbInfo *fbi, u32 color)
+{
+ unsigned int *fb_buf_int = NULL;
+ unsigned int *fb_buf_cur = NULL;
+ s32 dx = 0;
+ s32 dy = 0;
+ s32 w = 0;
+
+ if (NULL == fbi)
+ return;
+
+ dx = fbi->w;
+ dy = fbi->h;
+ w = fbi->w * sizeof(u32);
+
+ fb_buf_int = (unsigned int *)fbi->buf[FRONT_BUFFER];
+ fb_buf_cur = fb_buf_int;
+
+ while (dx--)
+ *fb_buf_cur++ = color;
+
+ dy--;
+ while (dy--) {
+ memcpy((void*)fb_buf_cur, (void*)fb_buf_int, w);
+ fb_buf_cur += fbi->w;
+ }
+}
+
+/*-----------------------------------------------------------------------------
+ _gr_direct_draw_text
+ ----------------------------------------------------------------------------*/
+static void _gr_direct_draw_text(FbInfo *fbi, int percent)
+{
+ char img_name[MAX_PATH];
+ int img_x;
+ int img_y;
+ int num;
+
+ img_x = 110;
+ img_y = 240;
+
+ if (percent < 10)
+ img_x += 10;
+ else if (percent < 100)
+ img_x += 20;
+ else if (percent == 100)
+ img_x += 30;
+
+ if (percent == 100) {
+ snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, 1);
+ if (read_png_file(img_name) < 0)
+ return;
+
+ draw_png_img_xy(fbi, img_x, img_y);
+ release_png_res();
+ }
+
+ img_x += 18;
+ if (percent >= 10) {
+ num = percent / 10;
+ if (num == 10)
+ num = 0;
+
+ snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, num);
+ if (read_png_file(img_name) < 0)
+ return;
+
+ draw_png_img_xy(fbi, img_x, img_y);
+ release_png_res();
+ }
+
+ img_x += 18;
+ num = percent % 10;
+
+ snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, num);
+ if (read_png_file(img_name) < 0)
+ return;
+
+ draw_png_img_xy(fbi, img_x, img_y);
+ release_png_res();
+
+ img_x += 17;
+
+ snprintf(img_name, MAX_PATH, "%s%s", IMG_BASE, PERCENT_IMG_NAME);
+ if (read_png_file(img_name) < 0)
+ return;
+
+ draw_png_img_xy(fbi, img_x, img_y);
+ release_png_res();
+}
+
+/*-----------------------------------------------------------------------------
+ _gr_direct_draw_prog_text
+ ----------------------------------------------------------------------------*/
+static void _gr_direct_draw_prog_text(FbInfo *fbi, int percent)
+{
+ if (percent <= 0)
+ percent = 0;
+
+ if (percent > 100)
+ percent = 100;
+
+ _gr_direct_fill_rect(fbi, 110, 240, 100, 41, COLOR_BLACK);
+ _gr_direct_draw_text(fbi, percent);
+}
+
+static void _gr_direct_draw_main_prog_img(FbInfo *fbi, int percent)
+{
+ int img_x = 0;
+ int img_y = 0;
+
+ if (read_png_file(IMG_BASE MAIN_PG_IMG_NAME) < 0)
+ return;
+
+ img_x = 0;
+ img_y = 0;
+
+ draw_png_img_xy(fbi, img_x, img_y);
+ release_png_res();
+}
+
+/*-----------------------------------------------------------------------------
+ _gr_direct_draw_main_img
+ ----------------------------------------------------------------------------*/
+static void _gr_direct_draw_main_img(FbInfo *fbi)
+{
+ int img_x = 0;
+ int img_y = 0;
+
+ if (read_png_file(IMG_BASE MAIN_IMG_NAME) < 0)
+ return;
+
+ img_x = 0;
+ img_y = 0;
+
+ draw_png_img_xy(fbi, img_x, img_y);
+ release_png_res();
+
+}
+
+/*-----------------------------------------------------------------------------
+ __init_screen
+ ----------------------------------------------------------------------------*/
+static void __init_screen(FbInfo *fbi)
+{
+ _gr_direct_clear_screen(fbi, COLOR_BLACK);
+
+ //_gr_direct_draw_text_img(fbi);
+
+ _gr_direct_draw_main_img(fbi);
+
+ _gr_direct_draw_main_prog_img(fbi, 0);
+
+ _gr_direct_draw_prog_text(fbi, 0);
+}
+
+static void _gr_direct_final_circle_progress_bar(FbInfo *fbi, int progress)
+{
+ char img_name[MAX_PATH];
+
+ // draw current progress image
+ snprintf(img_name, MAX_PATH, "%s%sfinal.png", IMG_BASE, PROGRESS_BAR_IMG_PREFIX);
+ if (read_png_file(img_name) < 0) {
+ LOG("ERROR \n");
+ return;
+ }
+
+ draw_png_img_xy(fbi, 0, 0);
+ release_png_res();
+}
+
+static void _gr_direct_circle_progress_bar(FbInfo *fbi, int progress)
+{
+ char img_name[MAX_PATH];
+
+ static int prog_pre = 0;
+ int count = 0;
+ int prog_cnt = 0;
+
+ if (progress <= 0)
+ return;
+
+ if (progress > 100)
+ progress = 100;
+
+ prog_cnt = progress;
+
+ for (; prog_pre <= prog_cnt; prog_pre++) {
+ LOG("prog_pre/prog_cnt : %d, %d \n", prog_pre , prog_cnt);
+
+ // draw current progress image
+ snprintf(img_name, MAX_PATH, "%s%s%03d.png", IMG_BASE, PROGRESS_BAR_IMG_PREFIX, prog_pre);
+ if (read_png_file(img_name) < 0) {
+ LOG("ERROR \n");
+ return;
+ }
+
+ draw_png_img_xy(fbi, 0, 0);
+ release_png_res();
+
+ s_saved_percent = prog_pre;
+
+ count++;
+
+ if (count > 3)
+ break;
+ }
+}
+
+/*-----------------------------------------------------------------------------
+ _gr_direct_update_screen
+ ----------------------------------------------------------------------------*/
+static void _gr_direct_update_screen()
+{
+ s_disp.current_buf_id = s_fbi.current_fb_id;
+
+ tdm_if_display_update(&s_disp);
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_direct_update_progress
+ ----------------------------------------------------------------------------*/
+void fota_gr_direct_circular_progress(void)
+{
+ if (s_saved_percent != s_percent_to_draw) {
+
+ LOG("fota_gr_direct_circular_progress progress : %d \n", s_percent_to_draw);
+
+ if (s_percent_to_draw == 100) {
+ _gr_direct_final_circle_progress_bar(&s_fbi, 100);
+ _gr_direct_draw_prog_text(&s_fbi, 100);
+
+ } else if (s_percent_to_draw > 0) {
+ _gr_direct_circle_progress_bar(&s_fbi, s_percent_to_draw);
+ _gr_direct_draw_prog_text(&s_fbi, s_percent_to_draw);
+ }
+ }
+ _gr_direct_update_screen();
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_direct_update_progress
+ ----------------------------------------------------------------------------*/
+void fota_gr_direct_update_progress(int percent)
+{
+ s_percent_to_draw = percent;
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_direct_clear_screen
+ ----------------------------------------------------------------------------*/
+void fota_gr_direct_clear_screen(u32 color)
+{
+ _gr_direct_clear_screen(&s_fbi, color);
+ _gr_direct_update_screen();
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_direct_init
+ ----------------------------------------------------------------------------*/
+int fota_gr_direct_init(void)
+{
+ /* open display interface */
+ if (fb_open(&s_fbi) < 0)
+ LOG("fb_open failed \n");
+
+ __init_screen(&s_fbi);
+
+ tdm_if_lcd_on(&s_disp);
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_direct_deinit
+ ----------------------------------------------------------------------------*/
+void fota_gr_direct_deinit(void)
+{
+ fb_close(&s_fbi);
+}
+
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FOTA_GUI_COMMON_H__
+#define __FOTA_GUI_COMMON_H__
+
+
+#include <stdio.h>
+#include "fota_gui_log.h"
+
+typedef signed char s8;
+typedef unsigned char u8;
+
+typedef signed short s16;
+typedef unsigned short u16;
+
+typedef signed int s32;
+typedef unsigned int u32;
+typedef u32 size_t;
+
+typedef signed long sl32;
+typedef unsigned long ul32;
+
+typedef signed long long s64;
+typedef unsigned long long u64;
+
+
+#endif /* __FOTA_GUI_COMMON_H__ */
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FOTA_GUI_LOG_H__
+#define __FOTA_GUI_LOG_H__
+
+#include <stdio.h>
+
+extern unsigned int __log_level__;
+extern FILE *__log_out_file__;
+
+#define LOG_INFO (1<<8)
+#define LOG_SSENGINE (1<<7)
+#define LOG_FUNCS (1<<6)
+#define LOG_GUI (1<<5)
+#define LOG_DEBUG (1<<4)
+#define LOG_FILE (1<<3)
+#define LOG_FLASH (1<<2)
+
+#define LOG_PRFIX "FOTA_GUI"
+
+#define DEBUG_STDOUT
+//#define DEBUG_FILE
+
+#ifdef DEBUG_STDOUT
+#define LOGE(s, args...) printf(LOG_PRFIX "/ERROR(%s) " s, __func__, ##args) // Error log
+#define LOGL(mask, s, args...) do { if ((mask) & __log_level__) \
+ printf(LOG_PRFIX "/(%s): " s, __func__, ##args); } while (0)
+#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
+
+#elif defined(DEBUG_FILE)
+#define LOGE(s, args...) fprintf(__log_out_file__, LOG_PRFIX "/ERROR(%s) " s, __func__, ##args)
+#define LOGL(mask, s, args...) do { if ((mask) & __log_level__) \
+ fprintf(__log_out_file__, LOG_PRFIX "/(%s): " s , __func__, ##args); } while (0)
+#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
+
+#elif defined(DEBUG_STDOUT_FILE) // debug printf
+#define LOGE(s, args...) do {\
+ printf(LOG_PRFIX "/ERROR(%s) " s, __func__, ##args);\
+ fprintf(__log_out_file__, LOG_PRFIX "/ERROR(%s) " s, __func__, ##args);\
+ } while (0)
+#define LOGL(mask, s, args...) do { \
+ if ((mask) & __log_level__) { \
+ printf(LOG_PRFIX "/(%s): " s , __func__, ##args);\
+ fprintf(__log_out_file__, LOG_PRFIX "/(%s): " s, __func__, ##args);\
+ } \
+ } while (0)
+#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
+
+#else
+#define LOGE(s, args...)
+#define LOGL(mask, s, args...)
+#define LOG(s, args...)
+
+#endif
+
+
+#endif /* __FOTA_GUI_LOG_H__ */
+
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/un.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+#include <pthread.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+#include "fota_gui_common.h"
+#include "fota_gui_util.h"
+#include "fota_gr.h"
+
+#define SERV_PATH "/tmp/FotaGuiSocket"
+
+
+unsigned int __log_level__ =
+ (LOG_DEBUG | LOG_FLASH | LOG_FILE | LOG_FUNCS | LOG_GUI | LOG_SSENGINE | LOG_INFO);
+FILE *__log_out_file__;
+
+int s_prog_percent = 0;
+int s_last_prog_percent = 0;
+
+
+typedef struct {
+ char cmd_name[64];
+ int argc;
+ char argv[3][64];
+} sock_cmd;
+
+typedef struct {
+ int ack;
+ char ack_desc[256];
+} sock_ack;
+
+#define CMD_SUCCESS 0
+#define CMD_ERROR -1
+#define MISSING_PARAM -2
+
+int do_exit = 0;
+
+int s_pid = -1;
+
+int run_command(sock_cmd * recvbuff, sock_ack * sendbuff, int connfd)
+{
+ char cmd[100];
+ int argc = 0, ret = -1;
+ int val = 0;
+
+ memset(cmd, 0x00, sizeof(cmd));
+ strncpy(cmd, recvbuff->cmd_name, sizeof(cmd)-1);
+ argc = recvbuff->argc;
+
+ if (!strcmp(cmd, "draw_progress")) {
+ LOG("draw_progress selected\n");
+ if (argc != 1) {
+ sendbuff->ack = MISSING_PARAM;
+ strncpy(sendbuff->ack_desc, "Missing parameter",
+ sizeof(sendbuff->ack_desc) - 1);
+ ret = send(connfd, sendbuff, sizeof(sock_ack), 0);
+ } else {
+ LOG("argv[0]: %s\n", recvbuff->argv[0]);
+ ret = CMD_SUCCESS;
+ sendbuff->ack = ret;
+ strncpy(sendbuff->ack_desc, "Command recieved",
+ sizeof(sendbuff->ack_desc) - 1);
+ ret = send(connfd, sendbuff, sizeof(sock_ack), 0);
+
+ val = atoi(recvbuff->argv[0]);
+ if (val < 0)
+ val = 0;
+ else if (val > 100)
+ val = 100;
+
+ s_prog_percent = val;
+ fota_gr_update_progress(s_prog_percent);
+ s_last_prog_percent = s_prog_percent;
+ }
+ } else if (!strcmp(cmd, "draw_end")) {
+ LOG("draw_end selected\n");
+ if (argc != 0) {
+ sendbuff->ack = MISSING_PARAM;
+ strncpy(sendbuff->ack_desc, "Missing parameter",
+ sizeof(sendbuff->ack_desc) - 1);
+ ret = send(connfd, sendbuff, sizeof(sock_ack), 0);
+ } else {
+ LOG("argv[0]: %s\n", recvbuff->argv[0]);
+ ret = CMD_SUCCESS;
+ sendbuff->ack = ret;
+ strncpy(sendbuff->ack_desc, "Command recieved",
+ sizeof(sendbuff->ack_desc) - 1);
+ ret = send(connfd, sendbuff, sizeof(sock_ack), 0);
+ LOG("send() returned %d\n", ret);
+ return -1;
+ }
+ } else {
+ LOG("Command Not Found \n");
+ sendbuff->ack = MISSING_PARAM;
+ strncpy(sendbuff->ack_desc, "Command Not found",
+ sizeof(sendbuff->ack_desc) - 1);
+ ret = send(connfd, sendbuff, sizeof(sock_ack), 0);
+ }
+
+ LOG("run_command() ret = %d\n", ret);
+ return ret;
+}
+
+static void *__thread_draw_progress_img(void *arg)
+{
+ int delay = 20000;
+
+ if (setpriority(PRIO_PROCESS, getpid(), -11) < 0)
+ LOG("failed to setpriority\n");
+
+ if (fota_gr_init() < 0) {
+ LOG("fota_gr_init() failed.\n");
+ _exit_stdio();
+ return -1;
+ }
+
+ while (do_exit != 1) {
+ usleep(delay);
+ fota_gr_direct_circular_progress();
+ }
+
+ fota_gr_deinit();
+
+ return NULL;
+}
+
+int main(int argc, char **argv)
+{
+ int connfd = 0, sockfd = 0;
+ socklen_t slen, clen;
+ struct sockaddr_un saddr, caddr;
+ int cnt, done;
+ sock_cmd *recvbuff = NULL;
+ sock_ack *sendbuff = NULL;
+
+// _init_stdio();
+
+ fota_gr_update_progress(s_prog_percent);
+ s_last_prog_percent = s_prog_percent;
+ int error = 0;
+ pthread_t th_id = 0;
+
+ error = pthread_create(&th_id, NULL, __thread_draw_progress_img, NULL);
+ if (error != 0) {
+ LOG("Thread creation failed errno [%d]\n", errno);
+ _exit_stdio();
+ return -1;
+ }
+
+ recvbuff = malloc(sizeof(sock_cmd));
+ if (recvbuff == NULL) {
+ LOG("memory allocation failed:\n");
+ _exit_stdio();
+ return -1;
+ }
+
+ sendbuff = malloc(sizeof(sock_ack));
+ if (sendbuff == NULL) {
+ LOG("memory allocation failed:\n");
+ _exit_stdio();
+ return -1;
+ }
+
+ sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (sockfd <= 0) {
+ LOG("invalide sockfd\n");
+ _exit_stdio();
+ return -1;
+ }
+
+ memset((char *)&saddr, 0, sizeof(saddr));
+ saddr.sun_family = AF_UNIX;
+ strncpy(saddr.sun_path, SERV_PATH,
+ sizeof(saddr.sun_path) - 1);
+ slen = sizeof(saddr);
+
+ unlink(SERV_PATH);
+ if (bind(sockfd, (const struct sockaddr *)&saddr, slen) < 0) {
+ LOG("bind fail\n");
+ _exit_stdio();
+ return -1;
+ }
+
+ if (chmod(SERV_PATH, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) /* 0777 */
+ LOG("failed to change the socket permission\n");
+
+ if (listen(sockfd, 5) < 0) {
+ LOG("listen fail\n");
+ _exit_stdio();
+ return -1;
+ }
+
+ while (1) {
+ clen = sizeof(caddr);
+ connfd = accept(sockfd, (struct sockaddr *)&caddr, &clen);
+ if (connfd < 0) {
+ LOG("accept fail \n");
+ _exit_stdio();
+ return -1;
+ }
+
+ LOG("Client Connected...\n");
+
+ done = 0;
+ do {
+ cnt = 0;
+ cnt = recv(connfd, recvbuff, sizeof(sock_cmd), 0);
+ if (cnt <= 0) {
+ if (cnt < 0)
+ perror("recv!");
+ done = 1;
+ LOG("recv() <= 0\n");
+ }
+
+ if (!done) {
+ if (run_command(recvbuff, sendbuff, connfd) < 0) {
+ done = 1;
+ do_exit = 1;
+ LOG("run_command() < 0\n");
+ }
+ }
+ } while (!done);
+
+ close(connfd);
+
+ if (do_exit)
+ break;
+ }
+
+ close(sockfd);
+
+ LOG("waiting for termination of thread((th_id) = %lu)\n", (th_id));
+ if (pthread_join(th_id, NULL) != 0) {
+ LOG("pthread_join failed for thread [%lu] errno [%d]\n",
+ th_id, errno);
+ _exit_stdio();
+ return -1;
+ }
+
+ _exit_stdio();
+
+ return 0;
+}
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "fota_gui_log.h"
+
+int s_fd_stdin = -1;
+int s_fd_stdout = -1;
+int s_fd_stderr = -1;
+
+/*-----------------------------------------------------------------------------
+ set_default_stdio
+ ----------------------------------------------------------------------------*/
+static int set_default_stdio(int flags, int nfd)
+{
+ int fd, r;
+
+ fd = open("/dev/null", flags|O_NOCTTY);
+ if (fd < 0)
+ return -errno;
+
+ if (fd == nfd) {
+ return fd;
+ } else {
+ r = dup2(fd, nfd) < 0 ? -errno : nfd;
+ close(fd);
+ return r;
+ }
+}
+
+/*-----------------------------------------------------------------------------
+ _init_stdio
+ ----------------------------------------------------------------------------*/
+void _init_stdio(void)
+{
+ s_fd_stdin = set_default_stdio(O_RDONLY, STDIN_FILENO);
+
+ s_fd_stdout = set_default_stdio(O_WRONLY, STDOUT_FILENO);
+
+ s_fd_stderr = set_default_stdio(O_WRONLY, STDERR_FILENO);
+}
+
+/*-----------------------------------------------------------------------------
+ _exit_stdio
+ ----------------------------------------------------------------------------*/
+void _exit_stdio(void)
+{
+ if (s_fd_stdin >= 0)
+ close(s_fd_stdin);
+
+ if (s_fd_stdout >= 0)
+ close(s_fd_stdout);
+
+ if (s_fd_stderr >= 0)
+ close(s_fd_stderr);
+}
+
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _FOTA_GUI_UTIL_H_
+#define _FOTA_GUI_UTIL_H_
+
+extern void _init_stdio(void);
+extern void _exit_stdio(void);
+
+#endif /* _FOTA_GUI_UTIL_H_ */
+
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FOTA_LOG_H__
+#define __FOTA_LOG_H__
+
+#include <stdio.h>
+
+/*
+ * DEBUGGING FEATURE
+ */
+
+extern unsigned int __log_level__;
+extern FILE *__log_out_file__;
+
+#define LOG_INFO (1<<8)
+#define LOG_SSENGINE (1<<7)
+#define LOG_FUNCS (1<<6)
+#define LOG_GUI (1<<5)
+#define LOG_DEBUG (1<<4)
+#define LOG_FILE (1<<3)
+#define LOG_FLASH (1<<2)
+
+#define LOG_PRFIX "FOTA_GUI"
+
+#define DEBUG_STDOUT
+//#define DEBUG_FILE
+
+#ifdef DEBUG_STDOUT
+#define LOGE(s, args...) printf(LOG_PRFIX "/ERROR(%s) " s, __func__, ##args) // Error log
+#define LOGL(mask, s, args...) do { if ((mask) & __log_level__) \
+ printf(LOG_PRFIX "/(%s): " s, __func__, ##args); } while (0)
+#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
+
+#elif defined(DEBUG_FILE)
+#define LOGE(s, args...) fprintf(__log_out_file__, LOG_PRFIX "/ERROR(%s) " s, __func__, ##args)
+#define LOGL(mask, s, args...) do { if ((mask) & __log_level__) \
+ fprintf(__log_out_file__, LOG_PRFIX "/(%s): " s , __func__, ##args); } while (0)
+#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
+
+#elif defined(DEBUG_STDOUT_FILE) // debug printf
+#define LOGE(s, args...) do {\
+ printf(LOG_PRFIX "/ERROR(%s) " s, __func__, ##args);\
+ fprintf(__log_out_file__, LOG_PRFIX "/ERROR(%s) " s, __func__, ##args);\
+ } while (0)
+#define LOGL(mask, s, args...) do {\
+ if ((mask) & __log_level__) {\
+ printf(LOG_PRFIX "/(%s): " s , __func__, ##args);\
+ fprintf(__log_out_file__, LOG_PRFIX "/(%s): " s, __func__, ##args);\
+ } \
+ } while (0)
+#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
+
+#else
+#define LOGE(s, args...)
+#define LOGL(mask, s, args...)
+#define LOG(s, args...)
+
+#endif
+
+
+#endif /* __FOTA_LOG_H__ */
+
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <png.h>
+#include "fota_gui_common.h"
+#include "fota_png.h"
+
+int png_img_width;
+int png_img_height;
+/* clear screen based on img size */
+//int png_img_width_batt_normal;
+//int png_img_height_batt_normal;
+
+png_byte png_color_type;
+png_byte png_bit_depth;
+
+png_structp png_ptr;
+png_infop info_ptr;
+int number_of_passes;
+png_bytep *row_pointers;
+
+/*-----------------------------------------------------------------------------
+ read_png_file()
+ ----------------------------------------------------------------------------*/
+int read_png_file(char *file_name)
+{
+ char header[8]; /* 8 is the maximum size that can be checked */
+ int y;
+ size_t rn;
+
+ /* open file and test for it being a png */
+ FILE *fp = fopen(file_name, "rb");
+ if (!fp) {
+ LOG("[read_png_file] File %s could not be opened"
+ " for reading \n", file_name);
+
+ LOG("Failed to open png file, path = [%s]\n", file_name);
+ return -1;
+ }
+
+ rn = fread(header, 1, 8, fp);
+ if (rn != 8)
+ LOG("fread() read num mismatch\n");
+ if (png_sig_cmp((png_bytep)header, 0, 8)) {
+ fclose(fp);
+ LOG("[read_png_file] File %s is not recognized"
+ " as a PNG file \n", file_name);
+ LOG("Failed to recognized PNG file\n");
+ return -1;
+ }
+
+ /* initialize stuff */
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if (!png_ptr) {
+ fclose(fp);
+ LOG("[read_png_file] png_create_read_struct failed \n");
+
+ LOG("Failed png_create_read_struct()\n");
+ return -1;
+ }
+
+ info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr) {
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
+ fclose(fp);
+ LOG("[read_png_file] png_create_info_struct failed \n");
+
+ LOG("Failed png_create_info_struct()\n");
+ return -1;
+ }
+
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ fclose(fp);
+ LOG("[read_png_file] Error during init_io \n");
+
+ LOG("Failed png_destroy_read_struct()\n");
+ return -1;
+ }
+
+ int bit_depth, color_type;
+ png_uint_32 png_width;
+ png_uint_32 png_height;
+
+ png_init_io(png_ptr, fp);
+ png_set_sig_bytes(png_ptr, 8);
+ png_read_info(png_ptr, info_ptr);
+
+ int ret = png_get_IHDR(png_ptr, info_ptr, &png_width, &png_height, &bit_depth, &color_type, NULL, NULL, NULL);
+ if (ret == 0) {
+ LOGE("Failed png_get_IHDR(), ret = [%d]\n", ret);
+ } else if (ret == 1) {
+ LOG("color_type = [%d]\n", color_type);
+
+ if (color_type == PNG_COLOR_TYPE_RGB)
+ LOG("png color type is PNG_COLOR_TYPE_RGB, color_type = [%d]\n", color_type);
+ else if (color_type == PNG_COLOR_TYPE_RGBA)
+ LOG("png color type is PNG_COLOR_TYPE_RGBA, color_type = [%d]\n", color_type);
+ else if (color_type == PNG_COLOR_TYPE_PALETTE)
+ LOG("png color type is PNG_COLOR_TYPE_PALETTE, color_type = [%d]\n", color_type);
+ else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
+ LOG("png color type is PNG_COLOR_TYPE_RGB_ALPHA, color_type = [%d]\n", color_type);
+ else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ LOG("png color type is PNG_COLOR_TYPE_GRAY_ALPHA, color_type = [%d]\n", color_type);
+ else if (color_type == PNG_COLOR_TYPE_GA)
+ LOG("png color type is PNG_COLOR_TYPE_GA, color_type = [%d]\n", color_type);
+ else
+ LOG("Unknown color type = [%d]\n", color_type);
+ }
+
+ png_img_width = png_width;
+ png_img_height = png_height;
+ png_color_type = color_type;
+ LOG("png_color_type = [%d]\n", png_color_type);
+ png_bit_depth = bit_depth;
+
+ number_of_passes = png_set_interlace_handling(png_ptr);
+ png_read_update_info(png_ptr, info_ptr);
+
+ /* read file */
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ fclose(fp);
+ LOG("[read_png_file] Error during read_image \n");
+
+ LOG("Failed png_destroy_read_struct()\n");
+ return -1;
+ }
+
+ png_size_t row_size = 0;
+
+ row_pointers = (png_bytep *) malloc(sizeof(png_bytep)*png_img_height);
+ for (y = 0; y < png_img_height; y++) {
+ row_size = png_get_rowbytes(png_ptr, info_ptr);
+ row_pointers[y] = (png_byte *) malloc(row_size);
+ }
+
+ png_read_image(png_ptr, row_pointers);
+
+ fclose(fp);
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------
+ draw_png_img_clip_xy()
+ - x1, y1 : cordinate on canvas (fb)
+ - cx, cy, cw, ch : image clip (rect on image)
+ ----------------------------------------------------------------------------*/
+void draw_png_img_clip_xy(FbInfo *fbi, int x1, int y1, int cx, int cy, int cw, int ch)
+{
+ unsigned int *fb_buf_cur = NULL;
+ int bpp;
+ int x, y;
+ /* temp patch - lcd resoultion for qualcomm */
+
+ fb_buf_cur = (unsigned int *)fbi->buf[0];
+
+ /* check out range */
+ if ((x1 + cw > fbi->w) ||
+ (y1 + ch > fbi->h)) {
+ LOG("[%s] output range exceeds frame buffer range \n", __func__);
+ return;
+ }
+
+ if ((cw > png_img_width) || (ch > png_img_height)) {
+ LOG("[%s] clip range exceeds image range \n", __func__);
+ return;
+ }
+
+ if (png_color_type == PNG_COLOR_TYPE_RGB)
+ bpp = 3;
+ else if (png_color_type == PNG_COLOR_TYPE_RGBA)
+ bpp = 4;
+ else {
+ LOG("[draw_png_img_xy] png type does not match RGB or RGBA \n");
+ return;
+ }
+ /* temp patch - lcd resoultion for qualcomm */
+ fb_buf_cur += (y1 * (fbi->w));
+ fb_buf_cur += x1;
+ for (y = 0; y < ch; y++) {
+ png_byte *row = (png_byte *) row_pointers[cy + y];
+ if (png_bit_depth == 8)
+ row += (bpp * cx);
+ else if (png_bit_depth == 16)
+ row += (bpp * 2 * cx);
+ for (x = 0; x < cw; x++) {
+ if (bpp == 3) {
+ if (png_bit_depth == 8) {
+ (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
+ (row[0] << 16) | (row[1] << 8) | (row[2]);
+ row += bpp;
+ } else if (png_bit_depth == 16) {
+ (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
+ (row[0] << 16) | (row[2] << 8) | (row[4]);
+ row += bpp*2;
+ }
+ } else if (bpp == 4) {
+ if (png_bit_depth == 8) {
+ if (row[3] != 0) {
+ char r1, g1, b1, a1;
+ char r2, g2, b2, a2;
+ char r3, g3, b3, a3;
+ // background pixel
+ b1 = ((*fb_buf_cur)&0x000000ff);
+ g1 = ((*fb_buf_cur)&0x0000ff00)>>8;
+ r1 = ((*fb_buf_cur)&0x00ff0000)>>16;
+ a1 = ((*fb_buf_cur)&0xff000000)>>24;
+ // new pixel
+ r2 = row[0];
+ g2 = row[1];
+ b2 = row[2];
+ a2 = row[3];
+ // blended pixel
+ r3 = (r2 * a2 + r1 * (0xff - a2)) >> 8 ;
+ g3 = (g2 * a2 + g1 * (0xff - a2)) >> 8;
+ b3 = (b2 * a2 + b1 * (0xff - a2)) >> 8;
+ a3 = a1;
+ (*fb_buf_cur) = (a3 << 24) |
+ (r3 << 16) | (g3 << 8) | (b3);
+ }
+ row += bpp;
+ } else if (png_bit_depth == 16) {
+ if (row[6] != 0) {
+ short r1, g1, b1, a1;
+ short r2, g2, b2, a2;
+ char r3, g3, b3, a3;
+ // background pixel
+ b1 = ((*fb_buf_cur)&0x000000ff)<<8;
+ g1 = ((*fb_buf_cur)&0x0000ff00);
+ r1 = ((*fb_buf_cur)&0x00ff0000)>>8;
+ a1 = ((*fb_buf_cur)&0xff000000)>>16;
+ // new pixel
+ r2 = (row[0]<<8) + row[1];
+ g2 = (row[2]<<8) + row[3];
+ b2 = (row[4]<<8) + row[5];
+ a2 = (row[6]<<8) + row[7];
+ // blended pixel
+ r3 = (r2 * a2 + r1 * (0xffff - a2)) >> 24;
+ g3 = (g2 * a2 + g1 * (0xffff - a2)) >> 24;
+ b3 = (b2 * a2 + b1 * (0xffff - a2)) >> 24;
+ a3 = a1 >> 8;
+ (*fb_buf_cur) = (a3 << 24) |
+ (r3 << 16) | (g3 << 8) | (b3);
+ }
+ row += bpp*2;
+ }
+ }
+ fb_buf_cur++;
+ }
+ fb_buf_cur -= cw;
+ fb_buf_cur += fbi->w;/* temp patch - lcd resoultion for qualcomm */
+ }
+
+}
+
+/*-----------------------------------------------------------------------------
+ draw_png_img_xy()
+ ----------------------------------------------------------------------------*/
+void draw_png_img_xy(FbInfo *fbi, int x1, int y1)
+{
+ unsigned int *fb_buf_cur = NULL;
+ int bpp;
+ int x, y;
+ /* temp patch - lcd resoultion for qualcomm */
+
+ fb_buf_cur = (unsigned int *)fbi->buf[0];
+
+ /* check out range */
+ if ((x1 + png_img_width > fbi->w) ||
+ (y1 + png_img_height > fbi->h)) {
+ LOG("[draw_png_img_xy] output range exceeds frame buffer range \n");
+
+ LOG("[draw_png_img_xy] output range exceeds frame buffer range \n");
+ return;
+ }
+
+ LOG("png_color_type = [%d]", png_color_type);
+ if (png_color_type == PNG_COLOR_TYPE_RGB) {
+ bpp = 3;
+ LOG("png color type is PNG_COLOR_TYPE_RGB, png_color_type = [%d]\n", png_color_type);
+ } else if (png_color_type == PNG_COLOR_TYPE_RGBA) {
+ bpp = 4;
+ LOG("png color type is PNG_COLOR_TYPE_RGBA, png_color_type = [%d]\n", png_color_type);
+ } else {
+ LOG("[draw_png_img_xy] png type does not match RGB or RGBA \n");
+
+ LOG("[draw_png_img_xy] png type does not match RGB or RGBA, png_color_type = [%d] \n", png_color_type);
+ return;
+ }
+
+ /* temp patch - lcd resoultion for qualcomm */
+ fb_buf_cur += (y1 * (fbi->w));
+ fb_buf_cur += x1;
+ for (y = 0; y < png_img_height; y++) {
+ png_byte *row = (png_byte *) row_pointers[y];
+ for (x = 0; x < png_img_width; x++) {
+ if (bpp == 3) {
+ if (png_bit_depth == 8) {
+ (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
+ (row[0] << 16) | (row[1] << 8) | (row[2]);
+ row += bpp;
+ } else if (png_bit_depth == 16) {
+ (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
+ (row[0] << 16) | (row[2] << 8) | (row[4]);
+ row += bpp*2;
+ }
+ } else if (bpp == 4) {
+ if (png_bit_depth == 8) {
+ if (row[3] != 0) {
+ char r1, g1, b1, a1;
+ char r2, g2, b2, a2;
+ char r3, g3, b3, a3;
+ // background pixel
+ b1 = ((*fb_buf_cur)&0x000000ff);
+ g1 = ((*fb_buf_cur)&0x0000ff00)>>8;
+ r1 = ((*fb_buf_cur)&0x00ff0000)>>16;
+ a1 = ((*fb_buf_cur)&0xff000000)>>24;
+ // new pixel
+ r2 = row[0];
+ g2 = row[1];
+ b2 = row[2];
+ a2 = row[3];
+ // blended pixel
+ r3 = (r2 * a2 + r1 * (0xff - a2)) >> 8 ;
+ g3 = (g2 * a2 + g1 * (0xff - a2)) >> 8;
+ b3 = (b2 * a2 + b1 * (0xff - a2)) >> 8;
+ a3 = a1;
+ (*fb_buf_cur) = (a3 << 24) |
+ (r3 << 16) | (g3 << 8) | (b3);
+ }
+ row += bpp;
+ } else if (png_bit_depth == 16) {
+ if (row[6] != 0) {
+ short r1, g1, b1, a1;
+ short r2, g2, b2, a2;
+ char r3, g3, b3, a3;
+ // background pixel
+ b1 = ((*fb_buf_cur)&0x000000ff)<<8;
+ g1 = ((*fb_buf_cur)&0x0000ff00);
+ r1 = ((*fb_buf_cur)&0x00ff0000)>>8;
+ a1 = ((*fb_buf_cur)&0xff000000)>>16;
+ // new pixel
+ r2 = (row[0]<<8) + row[1];
+ g2 = (row[2]<<8) + row[3];
+ b2 = (row[4]<<8) + row[5];
+ a2 = (row[6]<<8) + row[7];
+ // blended pixel
+ r3 = (r2 * a2 + r1 * (0xffff - a2)) >> 24;
+ g3 = (g2 * a2 + g1 * (0xffff - a2)) >> 24;
+ b3 = (b2 * a2 + b1 * (0xffff - a2)) >> 24;
+ a3 = a1 >> 8;
+ (*fb_buf_cur) = (a3 << 24) |
+ (r3 << 16) | (g3 << 8) | (b3);
+ }
+ row += bpp*2;
+ }
+ }
+ fb_buf_cur++;
+ }
+ fb_buf_cur -= png_img_width;
+ fb_buf_cur += fbi->w;/* temp patch - lcd resoultion for qualcomm */
+ }
+
+}
+
+/*-----------------------------------------------------------------------------
+ draw_png_mask_xy()
+ - draw pixel only when alpha>0 of given png image
+ ----------------------------------------------------------------------------*/
+void draw_png_mask_xy(FbInfo *fbi, int x1, int y1, char r, char g, char b)
+{
+ unsigned int *fb_buf_cur = NULL;
+ int bpp;
+ int x, y;
+ /* temp patch - lcd resoultion for qualcomm */
+
+ fb_buf_cur = (unsigned int *)fbi->buf[0];
+
+ /* check out range */
+ if ((x1 + png_img_width > fbi->w) ||
+ (y1 + png_img_height > fbi->h)) {
+ LOG("[draw_png_img_xy] output range exceeds frame buffer range \n");
+ return;
+ }
+
+ if (png_color_type == PNG_COLOR_TYPE_RGB) {
+ bpp = 3;
+ LOG("[draw_png_img_xy] PNG_COLOR_TYPE_RGB : no mask channel \n");
+ return;
+ } else if (png_color_type == PNG_COLOR_TYPE_RGBA)
+ bpp = 4;
+ else {
+ LOG("[draw_png_img_xy] png type does not match RGB or RGBA \n");
+ return;
+ }
+ /* temp patch - lcd resoultion for qualcomm */
+ fb_buf_cur += (y1 * (fbi->w));
+ fb_buf_cur += x1;
+ for (y = 0; y < png_img_height; y++) {
+ png_byte *row = (png_byte *) row_pointers[y];
+ for (x = 0; x < png_img_width; x++) {
+ if (bpp == 4) {
+ if (png_bit_depth == 8) {
+ if (row[3] != 0) {
+ (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
+ (r << 16) | (g << 8) | (b);
+ }
+ row += bpp;
+ } else if (png_bit_depth == 16) {
+ if (row[6] != 0) {
+ (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
+ (r << 16) | (g << 8) | (b);
+ }
+ row += bpp*2;
+ }
+ }
+ fb_buf_cur++;
+ }
+ fb_buf_cur -= png_img_width;
+ fb_buf_cur += fbi->w;/* temp patch - lcd resoultion for qualcomm */
+ }
+
+}
+
+/*-----------------------------------------------------------------------------
+ release_png_res()
+ ----------------------------------------------------------------------------*/
+void release_png_res(void)
+{
+ int y;
+
+ for (y = 0; y < png_img_height; y++)
+ free((void *)row_pointers[y]);
+ free((void *)row_pointers);
+
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+}
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FOTA_PNG_H__
+#define __FOTA_PNG_H__
+
+#include "fota_fbinfo.h"
+
+extern int read_png_file(char *file_name);
+extern void draw_png_img_xy(FbInfo *fbi, int x1, int y1);
+extern void draw_png_img_clip_xy(FbInfo *fbi, int x1, int y1, int cx, int cy, int cw, int ch);
+extern void draw_png_mask_xy(FbInfo *fbi, int x1, int y1, char r, char g, char b);
+extern void release_png_res(void);
+
+
+#endif /* __FOTA_PNG_H__ */
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/poll.h>
+#include <sys/time.h>
+#include "fota_gui_common.h"
+#include "tdm-if.h"
+
+static void tdm_if_display_commit_handler_cb(tdm_output *output, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+{
+ LOG("commit_handle_cb!!\n");
+
+ return ;
+}
+
+int tdm_if_display_init(tdm_if_disp *st_disp)
+{
+ int color = 0;
+ int buf_cnt;
+
+ tdm_error err = TDM_ERROR_NONE;
+
+ tdm_output *output = NULL;
+ tdm_output_type output_type = TDM_OUTPUT_TYPE_Unknown;
+ tdm_output_conn_status conn_status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
+ const tdm_output_mode *output_mode;
+ int output_count = 0;
+
+ tdm_info_layer layer_info;
+
+ tbm_surface_info_s surf_info;
+
+ int i = 0;
+
+ LOG("start\n");
+
+ st_disp->disp = tdm_display_init(&err);
+ if (!st_disp->disp) {
+ LOGE("failed to init tdm_display. error num = %d\n", err);
+ goto exit;
+ }
+
+ err = tdm_display_get_fd(st_disp->disp, &st_disp->tdm_fd);
+ if (err != TDM_ERROR_NONE) {
+ LOGE("failed to get tdm fd. error num = %d\n", err);
+ goto exit;
+ }
+
+ st_disp->drm_fd = tdm_helper_get_fd("TDM_DRM_MASTER_FD");
+ if (st_disp->drm_fd == -1) {
+ LOGE("failed to get tdm fd. error num = %d\n", err);
+ goto exit;
+ }
+
+ err = tdm_display_get_output_count(st_disp->disp, &output_count);
+ if (err != TDM_ERROR_NONE) {
+ LOGE("failed to get output count. error num = %d\n", err);
+ goto exit;
+ }
+
+ for (i = 0; i < output_count; i++) {
+ output = tdm_display_get_output(st_disp->disp, i, &err);
+ if (err != TDM_ERROR_NONE) {
+ LOGE("failed to get outout. error num = %d\n", err);
+ goto exit;
+ }
+
+ err = tdm_output_get_output_type(output, &output_type);
+ if (err != TDM_ERROR_NONE) {
+ LOGE("failed to get output type. error num = %d\n", err);
+ goto exit;
+ }
+
+ err = tdm_output_get_conn_status(output, &conn_status);
+ if (err != TDM_ERROR_NONE) {
+ LOGE("failed to get output connection status. error num = %d\n", err);
+ goto exit;
+ }
+
+ LOG("output_type=%d conn_status=%d\n", output_type, conn_status);
+ if ((output_type == TDM_OUTPUT_TYPE_LVDS || output_type == TDM_OUTPUT_TYPE_DSI) &&
+ (conn_status == TDM_OUTPUT_CONN_STATUS_CONNECTED)) {
+ int cnt = 0;
+ err = tdm_output_get_available_modes(output, &output_mode, &cnt);
+ if (err != TDM_ERROR_NONE) {
+ LOGE("failed to get output available modes. error num = %d\n", err);
+ goto exit;
+ }
+
+ err = tdm_output_set_mode(output, &output_mode[0]);
+ if (err != TDM_ERROR_NONE) {
+ LOGE("failed to set mode. error num = %d\n", err);
+ goto exit;
+ }
+
+ /* GET MODE INFO */
+ st_disp->output = output;
+ st_disp->width = output_mode->hdisplay;
+ st_disp->height = output_mode->vdisplay;
+
+ unsigned int width_mm = 0;
+ unsigned int height_mm = 0;
+ err = tdm_output_get_physical_size(output, &width_mm, &height_mm);
+ LOG("TDM_OUTPUT_MODE:name[%s] mode:wh[%d %d] mm[%d %d]\n",
+ output_mode->name, st_disp->width, st_disp->height, width_mm, height_mm);
+
+ break;
+ }
+ }
+
+ /* MEMORY ALLOCATION */
+ st_disp->bufmgr = tbm_bufmgr_init(st_disp->drm_fd);
+ if (!st_disp->bufmgr) {
+ LOGE("failed to tbm_bufmgr_init\n");
+ goto exit;
+ }
+
+ st_disp->buffer_size = st_disp->width * st_disp->height * RGB32_PITCH;
+ st_disp->stride = st_disp->width * RGB32_PITCH;
+
+ surf_info.width = st_disp->width;
+ surf_info.height = st_disp->height;
+ surf_info.format = TBM_FORMAT_ARGB8888;
+ surf_info.bpp = 32;
+ surf_info.size = st_disp->buffer_size;
+ surf_info.num_planes = 1;
+ surf_info.planes[0].size = st_disp->buffer_size;
+ surf_info.planes[0].offset = 0;
+ surf_info.planes[0].stride = st_disp->stride;
+
+ for (buf_cnt = 0; buf_cnt < MAX_BUF; buf_cnt++) {
+ st_disp->bo[buf_cnt] = tbm_bo_alloc(st_disp->bufmgr, st_disp->buffer_size, TBM_BO_NONCACHABLE);
+ if (!st_disp->bo[buf_cnt]) {
+ LOGE("failed to tbm_bo_alloc\n");
+ goto exit;
+ }
+
+ st_disp->bo_handle[buf_cnt] = tbm_bo_map(st_disp->bo[buf_cnt], TBM_DEVICE_CPU, TBM_OPTION_WRITE);
+ st_disp->buffer[buf_cnt] = st_disp->bo_handle[buf_cnt].ptr;
+ st_disp->handle[buf_cnt] = tbm_bo_get_handle(st_disp->bo[buf_cnt], TBM_DEVICE_2D).u32;
+
+ memset(st_disp->buffer[buf_cnt], color, st_disp->stride * st_disp->height);
+
+ tbm_bo_unmap(st_disp->bo[buf_cnt]);
+
+ st_disp->surf[buf_cnt] = tbm_surface_internal_create_with_bos(&surf_info, &st_disp->bo[buf_cnt], 1);
+ if (!st_disp->surf[buf_cnt]) {
+ LOGE("failed to create tbm_surface!!\n");
+ goto exit;
+ }
+ }
+
+ /* CHECK HWC USAGE */
+ tdm_output_capability output_caps;
+ tdm_output_get_capabilities(st_disp->output, &output_caps);
+ if (output_caps & TDM_OUTPUT_CAPABILITY_HWC)
+ st_disp->use_tdm_hwc = true;
+ else
+ st_disp->use_tdm_hwc = false;
+
+ /* SET LAYER */
+ if (st_disp->use_tdm_hwc) {
+ st_disp->hwc = tdm_output_get_hwc(st_disp->output, &err);
+ if (!st_disp->hwc) {
+ LOGE("failed to get hwc. error num = %d\n", err);
+ goto exit;
+ }
+ } else {
+ tdm_layer_capability layer_caps;
+ tdm_layer *tmp_layer = NULL;
+ for (i = 0; i < output_count; i++) {
+ tmp_layer = tdm_output_get_layer(st_disp->output, output_count, &err);
+ tdm_layer_get_capabilities(tmp_layer, &layer_caps);
+ if (layer_caps & TDM_LAYER_CAPABILITY_PRIMARY)
+ break;
+ }
+
+ if (!tmp_layer) {
+ LOGE("failed to get output layer. error num = %d\n", err);
+ goto exit;
+ }
+
+ st_disp->layer = tmp_layer;
+
+ layer_info.src_config.size.h = st_disp->width;
+ layer_info.src_config.size.v = st_disp->height;
+ layer_info.src_config.pos.x = 0;
+ layer_info.src_config.pos.y = 0;
+ layer_info.src_config.pos.w = st_disp->width;
+ layer_info.src_config.pos.h = st_disp->height;
+ layer_info.src_config.format = TBM_FORMAT_ARGB8888;
+ layer_info.dst_pos.x = 0;
+ layer_info.dst_pos.y = 0;
+ layer_info.dst_pos.w = st_disp->width;
+ layer_info.dst_pos.h = st_disp->height;
+ layer_info.transform = TDM_TRANSFORM_NORMAL;
+
+ err = tdm_layer_set_info(st_disp->layer, &layer_info);
+ if (err != TDM_ERROR_NONE) {
+ LOGE("failed to get output layer. error num = %d\n", err);
+ goto exit;
+ }
+ }
+
+ st_disp->current_buf_id = 0;
+ LOG("done\n");
+ return 0;
+exit:
+ tdm_if_display_deinit(st_disp);
+ return -1;
+}
+
+void tdm_if_display_deinit(tdm_if_disp *st_disp)
+{
+ int buf_cnt = 0;
+
+ if (st_disp->disp != NULL) {
+ /* RELEASE RESOURCE */
+ for (buf_cnt = 0; buf_cnt < MAX_BUF; buf_cnt++) {
+ if (st_disp->surf[buf_cnt] != NULL)
+ tbm_surface_destroy(st_disp->surf[buf_cnt]);
+
+ if (st_disp->bo[buf_cnt] != NULL)
+ tbm_bo_unref(st_disp->bo[buf_cnt]);
+ }
+
+ if (st_disp->bufmgr != NULL)
+ tbm_bufmgr_deinit(st_disp->bufmgr);
+ st_disp->bufmgr = NULL;
+
+ tdm_display_deinit(st_disp->disp);
+ st_disp->disp = NULL;
+ }
+}
+
+void tdm_if_display_update(tdm_if_disp *st_disp)
+{
+ /* DISPLAY UPDATE */
+ int buf_cnt = 0;
+
+ buf_cnt = st_disp->current_buf_id;
+ //st_disp->current_buf_id = (++st_disp->current_buf_id)%MAX_BUF;
+
+ if (st_disp->use_tdm_hwc) {
+ uint32_t num_types;
+ tdm_region damage;
+ memset(&damage, 0, sizeof(damage));
+
+ tdm_hwc_set_client_target_buffer(st_disp->hwc, st_disp->surf[buf_cnt], damage);
+ tdm_hwc_validate(st_disp->hwc, NULL, 0, &num_types);
+ tdm_hwc_accept_validation(st_disp->hwc);
+ tdm_hwc_commit(st_disp->hwc, 1, tdm_if_display_commit_handler_cb, st_disp);
+ } else {
+ tdm_layer_set_buffer(st_disp->layer, st_disp->surf[buf_cnt]);
+
+ // TODO: sync or async??
+ tdm_output_commit(st_disp->output, 1, tdm_if_display_commit_handler_cb, st_disp);
+ }
+
+ return ;
+}
+
+void tdm_if_lcd_on(tdm_if_disp *st_disp)
+{
+ /* SET DPMS ON */
+ LOG("DPMS ON!\n");
+ tdm_output_set_dpms(st_disp->output, TDM_OUTPUT_DPMS_ON);
+ return ;
+}
+
+void tdm_if_lcd_suspend(tdm_if_disp *st_disp)
+{
+ /* SET DPMS SUSPEND */
+ LOG("DPMS SUSPEND!\n");
+ tdm_output_set_dpms(st_disp->output, TDM_OUTPUT_DPMS_SUSPEND);
+
+ return ;
+}
+
+void tdm_if_lcd_off(tdm_if_disp *st_disp)
+{
+ /* SET DPMS OFF */
+ LOG("DPMS OFF!\n");
+
+ tdm_output_set_dpms(st_disp->output, TDM_OUTPUT_DPMS_OFF);
+
+ return ;
+}
--- /dev/null
+/*
+ * tota-ua
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TDM_IF_H__
+#define __TDM_IF_H__
+
+#include <tdm.h>
+#include <tbm_bufmgr.h>
+#include <tdm_helper.h>
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
+
+#define MAX_BUF 2
+#define RGB32_BPP 32
+#define RGB32_PITCH 4
+
+typedef struct _tdm_if_disp {
+ tdm_display *disp;
+ tdm_output *output;
+ tdm_layer *layer;
+ tdm_pp *pp;
+ int tdm_fd;
+ int drm_fd;
+
+ tbm_surface_h surf[MAX_BUF];
+ tbm_surface_h pp_surf[MAX_BUF];
+ tbm_bufmgr bufmgr;
+ unsigned int handle[MAX_BUF];
+ unsigned int pp_handle[MAX_BUF];
+ tbm_bo bo[MAX_BUF];
+ tbm_bo_handle bo_handle[MAX_BUF];
+ tbm_bo pp_bo[MAX_BUF];
+ tbm_bo_handle pp_bo_handle[MAX_BUF];
+ void *buffer[MAX_BUF];
+ void *pp_buffer[MAX_BUF];
+ int buffer_size;
+ int width;
+ int height;
+ int stride;
+ int current_buf_id;
+
+ bool use_tdm_hwc;
+ tdm_hwc *hwc;
+} tdm_if_disp;
+
+typedef enum {
+ FRONT_BUFFER = 0,
+ BACK_BUFFER
+} BUFFER_TYPE;
+
+extern tdm_if_disp s_disp;
+
+int tdm_if_display_init(tdm_if_disp *st_disp);
+void tdm_if_display_deinit(tdm_if_disp *st_disp);
+void tdm_if_display_update(tdm_if_disp *st_disp);
+void tdm_if_lcd_on(tdm_if_disp *st_disp);
+void tdm_if_lcd_suspend(tdm_if_disp *st_disp);
+void tdm_if_lcd_off(tdm_if_disp *st_disp);
+#endif /* __TDM_IF_H__ */
--- /dev/null
+Name: firmware-update-system-ui
+Summary: Firmware update system GUI application
+ExclusiveArch: %{arm}
+Version: 1.0.0
+Release: 0
+Group: System
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+
+BuildRequires: cmake
+BuildRequires: pkgconfig(libtbm)
+BuildRequires: pkgconfig(libtdm)
+BuildRequires: pkgconfig(libpng)
+BuildRequires: pkgconfig(libtzplatform-config)
+
+BuildRequires: pkgconfig(cairo)
+
+%description
+Firmware update system GUI application
+
+%prep
+%setup -q
+
+%build
+export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed"
+LDFLAGS="$LDFLAGS"
+
+%cmake -DCMAKE_INSTALL_PREFIX=%{_prefix}
+
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+mkdir -p %{buildroot}%{_datadir}/initrd-recovery/initrd.list.d
+cp 42-tota-gui.list %{buildroot}%{_datadir}/initrd-recovery/initrd.list.d/
+
+%post
+
+%files
+%license LICENSE
+%manifest firmware-update-system-ui.manifest
+
+%defattr(-,root,root,-)
+%attr(700,-,-) %{_datadir}/initrd-recovery/initrd.list.d/42-tota-gui.list
+%{_datadir}/fota/res/images
+%{_bindir}/fota_gui
+
+%attr(550,system,system_share) %{_bindir}/rw-update-ani
+%{_prefix}/share/rw-updater/*
+
+
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(rw-update-ani C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+SET(EDJDIR "\${prefix}/share/edje")
+SET(VERSION 0.1)
+SET(PKGDIR "${PREFIX}/share/rw-updater")
+SET(RESDIR "${PKGDIR}/res")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs_ani REQUIRED
+ cairo
+ libtbm
+ libtdm
+ dlog
+)
+SET(SRCS_ANI
+ rw-update-ani_new.c
+ rw-update_new_fb_cairo.c
+ rw-update_new_cairo_w_360_360.c
+ rw-update_new_tdm_display.c
+)
+
+ADD_DEFINITIONS("-DFEATURE_ROTATE")
+ADD_DEFINITIONS("-DCAIRO_LIB")
+
+FOREACH(flag ${pkgs_ani_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" MATCHES "^arm.*")
+ ADD_DEFINITIONS("-DTARGET")
+ MESSAGE("add -DTARGET")
+ENDIF()
+
+ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+ADD_EXECUTABLE(rw-update-ani ${SRCS_ANI})
+TARGET_LINK_LIBRARIES(rw-update-ani ${pkgs_ani_LDFLAGS})
+
+
+INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/rw-update-ani DESTINATION bin)
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/tw1/images DESTINATION ${RESDIR})
--- /dev/null
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sched.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/poll.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <getopt.h>
+
+#ifdef CAIRO_LIB
+#include "rw-update_new_cairo.h"
+#endif
+#include <fnmatch.h>
+#include <locale.h>
+
+#include "rw-update_new_common.h"
+#include "rw-update_new_fb.h"
+#ifdef FEATURE_ROTATE
+#include "rw-update_new_common_display.h"
+#endif
+
+#define EVT_LOOP_DURATION 1000
+
+#define MAX_KEY_PATH 4
+#define CMDLINE_SIZE 20
+
+#define FILE_IO_BUF_SIZE 128
+#define CHG_ENV_BATT_STATUS "/sys/class/power_supply/battery/status"
+
+FbInfo fbi;
+
+static pthread_t keyevent_thread;
+
+static char key_path[MAX_KEY_PATH+1][256];
+
+static const char granted_event[5][256] = {
+ "gpio-keys",
+ "sci-keypad",
+ "qpnp_pon",
+ "LPM_MOTION",
+ "s2mpw01-power-keys"
+};
+
+int read_from_file(const char *path, char *buf, size_t size)
+{
+ _FUNC_ENTER;
+
+ if (path == NULL) {
+ _DEBUG_EXCEPTION("Inputted parameter is wrong");
+ return -1;
+ }
+
+ if (size == 0) {
+ _DEBUG_EXCEPTION("Inputted parameter is wrong");
+ return 0;
+ }
+
+ int fd;
+ ssize_t count;
+
+ fd = open(path, O_RDONLY, 0);
+ if (fd == -1) {
+ _DEBUG_EXCEPTION("Could not open '%s'", path);
+ _FUNC_EXIT;
+ return -1;
+ }
+ _DEBUG_LOG("open '%s'\n", path);
+
+ count = read(fd, buf, size);
+ if (count > 0) {
+ count = (count < (ssize_t)size) ? count : ((ssize_t)size - 1);
+ while (count > 0 && buf[count - 1] == '\n')
+ count--;
+ buf[count] = '\0';
+ } else {
+ buf[0] = '\0';
+ }
+ _DEBUG_LOG("read '%s'\n", buf);
+
+ close(fd);
+
+ _FUNC_EXIT;
+ return (int)count;
+}
+
+static int read_event_node(void)
+{
+ _FUNC_ENTER;
+
+ FILE *fp = NULL;
+ char buffer[1024];
+ char *event_node = NULL;
+ int flag = 0;
+ int i = 0;
+ int node_cnt = 0;
+
+ for (i = 0; i < sizeof(granted_event) / sizeof(granted_event[0]); i++) {
+ fp = fopen("/proc/bus/input/devices", "r");
+ if (!fp) {
+ _DEBUG_EXCEPTION("Unable to open file. %m");
+ return -1;
+ }
+
+ memset(buffer, 0, sizeof(buffer));
+ while (fgets(buffer, sizeof(buffer), fp)) {
+ char *ptr = NULL;
+ if ((ptr = strstr(buffer, granted_event[i])))
+ flag = 1;
+ if (flag) {
+ if ((ptr = strstr(buffer, "Handlers="))) {
+ ptr = strstr(ptr, "event");
+ if (ptr) {
+ char *ptr2 = strchr(ptr, ' ');
+ if (ptr2)
+ *ptr2 = '\0';
+
+ flag = 0;
+
+ event_node = strndup(ptr, strlen(ptr));
+ if (!event_node) {
+ fclose(fp);
+ _DEBUG_EXCEPTION("event_node is null");
+ _FUNC_EXIT;
+ return -1;
+ } else {
+ _DEBUG_LOG("event_node : %s", event_node);
+ snprintf(key_path[node_cnt++], CMDLINE_SIZE, "/dev/input/%s", event_node);
+
+ free(event_node);
+
+ if (node_cnt > MAX_KEY_PATH) {
+ _DEBUG_EXCEPTION("node_cnt(%d) bigger than MAX_KEY_PATH(%d)", node_cnt, MAX_KEY_PATH);
+ fclose(fp);
+ _FUNC_EXIT;
+ return -1;
+ }
+ }
+ }
+ }
+ } else {
+ flag = 0;
+ }
+ }
+
+ fclose(fp);
+ }
+
+ _FUNC_EXIT;
+ return node_cnt;
+}
+
+#ifdef FEATURE_ROTATE
+static int read_degree(FbInfo *fbi)
+{
+ _FUNC_ENTER;
+
+ char buffer[256] = {0,};
+ int value = 0;
+
+ if (read_from_file("/sys/class/sensors/ssp_sensor/fota_rotate_info", buffer, 256) < 0) {
+ value = -1;
+ _DEBUG_EXCEPTION("[%s] err %d", __func__, value);
+ fbi->degree = 0;
+
+ _FUNC_EXIT;
+ return value;
+ }
+
+ fbi->degree = atoi(buffer);
+ _DEBUG_LOG("fbi->degree : %d", fbi->degree);
+
+ _FUNC_EXIT;
+ return 0;
+}
+#endif
+
+int is_batt_status(void)
+{
+ int value = 0;
+ char buf[FILE_IO_BUF_SIZE];
+
+ if (read_from_file(CHG_ENV_BATT_STATUS, buf, FILE_IO_BUF_SIZE) < 0) {
+ _DEBUG_EXCEPTION("read_from_file error");
+ return -1;
+ }
+ if (strncmp(buf, "Charging", 8) == 0)
+ value = BATT_STATE_CHARGING;
+ else if (strncmp(buf, "Discharging", 11) == 0)
+ value = BATT_STATE_DISCONNECT;
+ else if (strncmp(buf, "Full", 4) == 0)
+ value = BATT_STATE_FULL;
+ else
+ value = BATT_STATE_NOTCHARGE;
+
+ return value;
+}
+
+/*-----------------------------------------------------------------------------
+ event_monitor_process()
+ ----------------------------------------------------------------------------*/
+void* event_monitor_process(void *arg)
+{
+ _FUNC_ENTER;
+
+ int readcount = 0;
+ int ret = 0;
+ int i = 0;
+ int num_arg = *(int *)arg;
+ static unsigned int sys_power_cnt = 0;
+ struct pollfd pollevents[MAX_KEY_PATH];
+ struct input_event event;
+
+ _DEBUG_LOG("[main] event_monitor_process() started. %d\n", num_arg);
+
+ memset(pollevents, 0, sizeof(pollevents));
+
+ for (i = 0; i < num_arg; i++) {
+ if ((pollevents[i].fd = open(key_path[i], O_RDWR)) < 0) {
+ _DEBUG_EXCEPTION("%s: open error, fd = %d\n", key_path[i], pollevents[i].fd);
+
+ _FUNC_EXIT;
+ return (void *)i + 1;
+ }
+ pollevents[i].events = POLLIN | POLLERR;
+ }
+
+ while (1) {
+ ret = poll(pollevents, num_arg, EVT_LOOP_DURATION);
+ if (ret < 0)
+ _DEBUG_EXCEPTION("poll error, ret = [%d]\n", ret);
+
+ /* key event */
+ for (i = 0; i < num_arg; i++) {
+ if (pollevents[i].revents & POLLIN) {
+ readcount = read(pollevents[i].fd, &event, sizeof(event));
+ if (readcount != sizeof(event)) {
+ _DEBUG_EXCEPTION("key[%d] read error, readcount = [%d]\n", i, readcount);
+ continue;
+ }
+ _DEBUG_LOG("poll event:%d, fd:%d type=%d code=%d value=%d sys_power_cnt : %d, arg : %s", i, pollevents[i].fd, event.type, event.code, event.value, sys_power_cnt, key_path[i]);
+
+ if (event.type == EV_KEY)
+ _DEBUG_LOG("keycode%d : 0x%x, value: %d\n", i, event.code, event.value);
+#ifdef FEATURE_ROTATE
+ else if (event.type == EV_ABS) {
+ if (event.code == ABS_X) {
+ _DEBUG_LOG("LPM_MOTION event.code %d, event.value : %d ", event.code, event.value);
+ if (event.value == 1 || event.value == 3) {
+ fbi.degree = event.value;
+
+ int battery_state = is_batt_status();
+ if (battery_state == BATT_STATE_CHARGING || battery_state == BATT_STATE_FULL)
+ fb_draw_img_rotate_update(&fbi);
+ }
+ }
+ } else {
+ _DEBUG_LOG("etc event.code %d, event.value : %d ", event.code, event.value);
+ }
+#endif
+ }
+ }
+ }
+
+ _FUNC_EXIT;
+ return (void *)0;
+}
+
+int rw_update_process(void)
+{
+ _FUNC_ENTER;
+
+ int delay = 50000;
+ //int progress = 0;
+
+ while (1) {
+ usleep(delay);
+ fb_draw_screen(&fbi);
+ sleep(1);
+ }
+
+ _DEBUG_LOG("%s process killed!!", __func__);
+
+ _FUNC_EXIT;
+ return 0;
+}
+
+static int wait_ani_main_solis(void)
+{
+ _FUNC_ENTER;
+
+ int ret = 0;
+ int status = 0;
+ int event_cnt = 0;
+
+ event_cnt = read_event_node();
+ if (event_cnt < 0)
+ _DEBUG_EXCEPTION("read_event_node failed, event_cnt = [%d]", event_cnt);
+
+#ifdef FEATURE_ROTATE
+ /* get degree */
+ ret = read_degree(&fbi);
+ if (ret < 0)
+ _DEBUG_EXCEPTION("read_degree failed, ret = [%d]", ret);
+#endif
+ /* open display interface */
+ if (fb_open(&fbi) < 0) {
+ _DEBUG_EXCEPTION("fb_open failed");
+ goto main_err_exit;
+ }
+
+ /* cairo initialize */
+#ifdef CAIRO_LIB
+ cairo_ui_init(fbi.w, fbi.h);
+#endif
+
+ _DEBUG_LOG("charging-animation main function called.");
+
+ chg_common_lcd_on(&s_disp);
+
+ ret = pthread_create(&keyevent_thread, NULL, event_monitor_process, (void*)&event_cnt);
+ if (ret < 0) {
+ _DEBUG_LOG("[main] event_monitor_process ret : %d", ret);
+ goto main_exit;
+ }
+
+ /* image drawing main thread */
+ rw_update_process();
+
+main_exit:
+ _DEBUG_LOG("[main] main_exit \n");
+
+ fb_close(&fbi);
+
+#ifdef CAIRO_LIB
+ cairo_ui_exit();
+ pthread_join(keyevent_thread, (void *)&status);
+ _DEBUG_LOG("[main] keyevent_thread err_exit %d\n", status);
+#endif
+
+main_err_exit:
+ _DEBUG_EXCEPTION("[main] main_err_exit \n");
+ exit(0);
+
+ _FUNC_EXIT;
+ return 0;
+
+}
+
+int main(int argc, char *argv[])
+{
+ _FUNC_ENTER;
+
+ int opt = 0;
+ int index = 0;
+
+ struct option options[] = {
+ {"wait", 0, 0, 0},
+ {"", 0, 0, 0},
+ {"", 0, 0, 0},
+ {"", 0, 0, 0},
+ {"", 0, 0, 0},
+ {0, 0, 0, 0}
+ };
+
+ if (setpriority(PRIO_PROCESS, getpid(), -11) < 0)
+ _DEBUG_EXCEPTION("failed to setpriority\n");
+
+ opt = getopt_long(argc, argv, "", options, &index);
+ if (opt == -1) {
+ _DEBUG_EXCEPTION("getopt_long failed\n");
+ _FUNC_EXIT;
+ return 0;
+ }
+
+ switch (index) {
+ case 0: {
+ int ret = wait_ani_main_solis();
+
+ _FUNC_EXIT;
+ return ret;
+ }
+ case 1:
+ break;
+ case 2:
+ break;
+ case 3:
+ break;
+ case 4:
+ break;
+ default:
+ break;
+ }
+
+ _FUNC_EXIT;
+ return 0;
+}
+
--- /dev/null
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RW_UPDATE_ANI_NEW_H__
+#define __RW_UPDATE_ANI_NEW_H__
+
+int is_batt_status(void);
+
+#endif /* __RW_UPDATE_ANI_H__ */
+
--- /dev/null
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FOTA_LOG_H__
+#define __FOTA_LOG_H__
+
+#include <stdio.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "FOTA_GUI_RW"
+
+#define COLOR_RED "\033[0;31m"
+#define COLOR_GREEN "\033[0;32m"
+#define COLOR_BROWN "\033[0;33m"
+#define COLOR_BLUE "\033[0;34m"
+#define COLOR_PURPLE "\033[0;35m"
+#define COLOR_CYAN "\033[0;36m"
+#define COLOR_LIGHTBLUE "\033[0;37m"
+#define COLOR_END "\033[0;m"
+
+#define _DEBUG_SECURE_LOG(fmt, args...) SECURE_SLOGD(fmt, ##args)
+#define _DEBUG_SECURE_EXCEPTION(fmt, args...) SECURE_SLOGE(COLOR_RED"* Critical * " fmt COLOR_END, ##args)
+
+#define _DEBUG_LOG(fmt, args...) SLOGI(fmt, ##args)
+#define _DEBUG_INFO(fmt, args...) SLOGI(COLOR_GREEN fmt COLOR_END, ##args)
+#define _DEBUG_WARNING(fmt, args...) SLOGW(COLOR_BLUE"* Warning * " fmt COLOR_END, ##args)
+#define _DEBUG_CHECK(fmt, args...) SLOGI(COLOR_LIGHTBLUE fmt, ##args)
+#define _DEBUG_EXCEPTION(fmt, args...) SLOGE(COLOR_RED"* Critical * " fmt COLOR_END, ##args)
+#define _FUNC_ENTER SLOGI(COLOR_GREEN"ENTER >>>>"COLOR_END)
+#define _FUNC_EXIT SLOGI(COLOR_GREEN"EXIT <<<<"COLOR_END)
+
+/*
+ * DEBUGGING FEATURE
+ */
+
+extern unsigned int __log_level__;
+extern FILE *__log_out_file__;
+
+#define LOG_INFO (1<<8)
+#define LOG_RWANI (1<<7)
+#define LOG_FUNCS (1<<6)
+#define LOG_GUI (1<<5)
+#define LOG_DEBUG (1<<4)
+#define LOG_FILE (1<<3)
+#define LOG_FLASH (1<<2)
+
+#define LOG_PRFIX "FOTA_GUI"
+
+#define DEBUG_STDOUT
+//#define DEBUG_FILE
+
+#ifdef DEBUG_STDOUT
+#define LOGE(s, args...) printf(LOG_PRFIX "/ERROR(%s) " s, __func__, ##args) // Error log
+#define LOGL(mask, s, args...) do { if ((mask) & __log_level__) \
+ printf(LOG_PRFIX "/(%s): " s, __func__, ##args); } while (0)
+#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
+
+#elif defined(DEBUG_FILE)
+#define LOGE(s, args...) fprintf(__log_out_file__, LOG_PRFIX "/ERROR(%s) " s, __func__, ##args)
+#define LOGL(mask, s, args...) do { if ((mask) & __log_level__) \
+ fprintf(__log_out_file__, LOG_PRFIX "/(%s): " s , __func__, ##args); } while (0)
+#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
+
+#elif defined(DEBUG_STDOUT_FILE) // debug printf
+#define LOGE(s, args...) do {\
+ printf(LOG_PRFIX "/ERROR(%s) " s, __func__, ##args);\
+ fprintf(__log_out_file__, LOG_PRFIX "/ERROR(%s) " s, __func__, ##args);\
+ } while (0)
+#define LOGL(mask, s, args...) do { \
+ if ((mask) & __log_level__) {\
+ printf(LOG_PRFIX "/(%s): " s , __func__, ##args);\
+ fprintf(__log_out_file__, LOG_PRFIX "/(%s): " s, __func__, ##args);\
+ } \
+ } while (0)
+#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
+
+#else
+#define LOGE(s, args...)
+#define LOGL(mask, s, args...)
+#define LOG(s, args...)
+
+#endif
+
+
+#endif /* __FOTA_LOG_H__ */
+
--- /dev/null
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RW_UPDATE_NEW_CAIRO_H__
+#define __RW_UPDATE_NEW_CAIRO_H__
+
+#include <cairo.h>
+
+typedef struct _CairoInfo {
+ cairo_t *Cr;
+ cairo_surface_t *Surface;
+ int id;
+ int width;
+ int height;
+ int currentitem;
+ int currentfocus;
+ int currentselected;
+} CairoInfo;
+
+extern long check_existence(const char *file_path);
+extern int cairo_ui_init(int width, int height);
+extern void cairo_ui_exit(void);
+extern void cairo_clear_window(void);
+extern void cairo_backgound_image(void);
+extern void cairo_mask_image(void);
+extern void cairo_update_screen(unsigned int * buffer, unsigned int size);
+extern void cairo_draw_main_img(void);
+extern void cairo_draw_main_text_img(void);
+extern void cairo_draw_progress_bar(unsigned int progress);
+extern void cairo_draw_num_progress(int progress, int total);
+extern void cairo_draw_text(void);
+extern int cairo_get_text_status(void);
+
+#endif /* __RW_UPDATE_NEW_CAIRO_H__ */
--- /dev/null
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#define _USE_MATH_DEFINES
+#include <math.h>
+
+#include "rw-update_new_common.h"
+#include "rw-update_new_fb.h"
+#include "rw-update_new_cairo.h"
+
+#include <time.h>
+#include <sys/time.h>
+#include <unicode/udat.h>
+#include <unicode/udatpg.h>
+#include <unicode/ustring.h>
+#include <glib.h>
+#include <sys/stat.h>
+
+#include <libintl.h> // dgettext
+
+CairoInfo cairoinfo;
+
+#define DEFAULT_FONT "SamsungOneUI"
+#define TEXT_COLOR 1, 1, 1 /* #12b4ff */
+#define TEXT_FONT_SIZE_MAX 32
+#define TEXT_FONT_SIZE_MIN 16
+
+#define RW_PROCESS_MSG dgettext("rw-updater", "WDS_FOTA_BODY_FINALISING_NUPDATE_ING_ABB")
+//#define RW_PROCESS_MSG "Finalising\nupdate..."
+
+
+#if !defined(RESDIR)
+#define RESDIR "/usr/share/rw-updater/res"
+#endif
+#define IMG_BASE RESDIR "/images/"
+#define MAIN_IMG_NAME "solis_fota_progress_000.png"
+#define POPUP_IMG_NAME "wc_popup_line.png"
+#define PROGRESS_IMG_PREFIX "solis_fota_progress_"
+#define PROGRESS_BAR_IMG_PREFIX "solis_fota_progress_"
+#define PROGRESS_NUM_PREFIX "wc_fota_downloading_"
+#define SLASH_IMG_NAME "wc_fota_downloading_slash.png"
+
+#define RO_TEXT_IMG_FILE_PATH "/opt/usr/data/fota/FotaBgImage2.png"
+
+#define MAX_FILE_PATH 512
+
+#define PROGRESS_IMG_CNT 101
+#define PROGRESS_NUM_CNT 10
+
+#define TEXT_FONT_SIZE_MAX 32
+#define TEXT_FONT_SIZE_MIN 16
+
+cairo_surface_t *img_surf_main = NULL;
+cairo_surface_t *img_surf_popup = NULL;
+cairo_surface_t *img_surf_main_txt = NULL;
+cairo_surface_t *img_surf_prog[PROGRESS_IMG_CNT] = {NULL,};
+cairo_surface_t *img_surf_num[PROGRESS_NUM_CNT] = {NULL,};
+cairo_surface_t *img_surf_slash = NULL;
+
+int main_img_x = 0;
+int main_img_y = 0;
+int main_img_w = 0;
+int main_img_h = 0;
+
+#define BG_COLOR 0.0, 0.0, 0.0
+
+#define MAX_BUF_LEN 512
+char s_rw_process_msg1[MAX_BUF_LEN];
+char s_rw_process_msg2[MAX_BUF_LEN];
+int s_bnewline = 0;
+
+static double s_text_x1 = 0.0;
+static double s_text_x2 = 0.0;
+static double s_text_y1 = 0.0;
+static double s_text_y2 = 0.0;
+
+static int s_font_sz = 0.0;
+
+int s_font_initialized = 0;
+
+/*-----------------------------------------------------------------------------
+ cairo_update_screen()
+ ----------------------------------------------------------------------------*/
+void cairo_update_screen(unsigned int *buffer, unsigned int size)
+{
+ _FUNC_ENTER;
+
+ unsigned char *temp_buffer = NULL;
+
+ /* get buffer pointer of cairo surface */
+ temp_buffer = cairo_image_surface_get_data(cairoinfo.Surface);
+ if (temp_buffer == NULL) {
+ _DEBUG_EXCEPTION("cairo_update_screen temp_buffer NULL error!!");
+ _FUNC_EXIT;
+ return;
+ }
+
+ memcpy((void*)buffer, (void*)temp_buffer, size);
+
+ _FUNC_EXIT;
+}
+
+/*-----------------------------------------------------------------------------
+ cairo_clear_window()
+ ----------------------------------------------------------------------------*/
+void cairo_clear_window(void)
+{
+ _FUNC_ENTER;
+
+ /* set default color */
+ cairo_set_source_rgb(cairoinfo.Cr, BG_COLOR);
+
+ /* fill buffer to default color */
+ cairo_paint(cairoinfo.Cr);
+
+ _FUNC_EXIT;
+}
+
+long check_existence(const char *file_path)
+{
+ _FUNC_ENTER;
+
+ if (file_path == NULL) {
+ _DEBUG_EXCEPTION("Inputted paramter is wrong");
+ _FUNC_EXIT;
+ return 0;
+ }
+ _DEBUG_LOG("%s\n", file_path);
+
+ struct stat statbuf;
+ char filename[MAX_FILE_PATH] = {0,};
+
+ if (strncpy(filename, file_path, strlen(file_path) + 1) == NULL) {
+ _DEBUG_EXCEPTION("strncpy error=%s\n", filename);
+ _FUNC_EXIT;
+ return 0;
+ }
+ if (stat(filename, &statbuf)) {
+ if (ENOENT == errno) {
+ _DEBUG_EXCEPTION("stat %s: %m\n", filename);
+ _FUNC_EXIT;
+ return 0;
+ }
+ }
+ _DEBUG_LOG("satbuf.st_size = %d\n", (int)statbuf.st_size);
+
+ _FUNC_EXIT;
+ return statbuf.st_size;
+}
+
+/*-----------------------------------------------------------------*
+ cairo_image_init()
+ ------------------------------------------------------------------*/
+static void cairo_image_init(void)
+{
+ _FUNC_ENTER;
+
+ int i = 0;
+ char img_name[1024] = {0,};
+
+ snprintf(img_name, 1024, "%s%s", IMG_BASE, MAIN_IMG_NAME);
+ _DEBUG_LOG("img name = %s\n", img_name);
+ img_surf_main = cairo_image_surface_create_from_png(img_name);
+
+ for (i = 0; i < PROGRESS_NUM_CNT; i++) {
+ snprintf(img_name, 1024, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, i);
+ _DEBUG_LOG("img name = %s\n", img_name);
+ img_surf_num[i] = cairo_image_surface_create_from_png(img_name);
+ }
+
+ snprintf(img_name, 1024, "%s%s", IMG_BASE, SLASH_IMG_NAME);
+ _DEBUG_LOG("img name = %s\n", img_name);
+ img_surf_slash = cairo_image_surface_create_from_png(img_name);
+
+ if (check_existence((char *)RO_TEXT_IMG_FILE_PATH) > 0)
+ img_surf_main_txt = cairo_image_surface_create_from_png(RO_TEXT_IMG_FILE_PATH);
+
+ main_img_w = cairo_image_surface_get_width(img_surf_main);
+ main_img_h = cairo_image_surface_get_height(img_surf_main);
+ main_img_x = (cairoinfo.width - main_img_w)/2;
+ main_img_y = 0;
+ _DEBUG_LOG("main_img_w = %d, main_img_h = %d\n", main_img_w, main_img_h);
+ _DEBUG_LOG("main_img_x = %d, main_img_y = %d\n", main_img_x, main_img_y);
+
+ _FUNC_EXIT;
+}
+
+/*-----------------------------------------------------------------*
+ cairo_image_exit()
+ ------------------------------------------------------------------*/
+static void cairo_image_exit()
+{
+ _FUNC_ENTER;
+
+ int i = 0;
+
+ cairo_surface_destroy(img_surf_main);
+ for (i = 0; i < PROGRESS_NUM_CNT; i++)
+ cairo_surface_destroy(img_surf_num[i]);
+ cairo_surface_destroy(img_surf_slash);
+
+ if (check_existence((char *)RO_TEXT_IMG_FILE_PATH) > 0)
+ cairo_surface_destroy(img_surf_main_txt);
+
+ _FUNC_EXIT;
+}
+
+/*-----------------------------------------------------------------------------
+ cairo_backgound_image()
+ ----------------------------------------------------------------------------*/
+void cairo_backgound_image(void)
+{
+}
+/*-----------------------------------------------------------------*
+ cairo_draw_main_img()
+ ------------------------------------------------------------------*/
+void cairo_draw_main_img(void)
+{
+ _FUNC_ENTER;
+
+ cairo_set_source_surface(cairoinfo.Cr, img_surf_main, main_img_x, main_img_y);
+ cairo_rectangle(cairoinfo.Cr, main_img_x, main_img_y, main_img_w, main_img_h);
+ cairo_fill(cairoinfo.Cr);
+
+ _FUNC_EXIT;
+}
+
+void cairo_mask_image(void)
+{
+#if 0
+ cairo_set_source_surface(cairoinfo.Cr, img_surf_black_mask, main_img_x, main_img_y);
+ cairo_rectangle(cairoinfo.Cr, main_img_x, main_img_y, main_img_w, main_img_h);
+ cairo_fill(cairoinfo.Cr);
+#endif
+}
+
+void cairo_draw_main_text_img(void)
+{
+ _FUNC_ENTER;
+
+ if (img_surf_main_txt) {
+ cairo_set_source_surface(cairoinfo.Cr, img_surf_main_txt, main_img_x, main_img_y);
+ cairo_rectangle(cairoinfo.Cr, main_img_x, main_img_y, main_img_w, main_img_h);
+ cairo_fill(cairoinfo.Cr);
+ }
+
+ _FUNC_EXIT;
+}
+
+void cairo_draw_progress_bar(unsigned int progress)
+{
+ _FUNC_ENTER;
+
+ double xc = 180.0;
+ double yc = 180.0;
+ double radius = 180.0;
+ double angle1 = 270.0 * (M_PI/180.0);
+ double angle2 = 360.0 * (M_PI/180.0);
+
+ if (progress > 100)
+ progress = 100;
+
+ if (progress <= 25)
+ angle2 = (270 + progress * 36 / 10) * (M_PI/180.0);
+ else if (progress > 25 && progress <= 99)
+ angle2 = (-90 + progress * 36 / 10) * (M_PI/180.0);
+ else
+ angle1 = 0;
+
+ cairo_set_line_width(cairoinfo.Cr, 17.0);
+ cairo_set_source_rgb(cairoinfo.Cr, 0.0, 0.7, 1.0);
+ cairo_arc(cairoinfo.Cr, xc, yc, radius, angle1, angle2);
+ cairo_stroke(cairoinfo.Cr);
+
+ _FUNC_EXIT;
+}
+
+void cairo_draw_num_progress(int progress, int total)
+{
+ _FUNC_ENTER;
+
+ int img_x = 110;
+ int img_y = 240;
+ int num;
+
+ cairo_set_source_rgb(cairoinfo.Cr, BG_COLOR);
+ cairo_rectangle(cairoinfo.Cr, img_x, img_y, 140, 40);
+ cairo_fill(cairoinfo.Cr);
+
+ if (total < 10)
+ img_x += 80;
+ else if (total < 100)
+ img_x += 90;
+ else
+ img_x += 100;
+
+ num = total;
+ while (num > 0) {
+ cairo_set_source_surface(cairoinfo.Cr, img_surf_num[num % 10], img_x, img_y);
+ cairo_paint(cairoinfo.Cr);
+ img_x -= 18;
+ num /= 10;
+ }
+
+ cairo_set_source_surface(cairoinfo.Cr, img_surf_slash, img_x, img_y);
+ cairo_paint(cairoinfo.Cr);
+ img_x -= 17;
+
+ num = progress;
+ while (num > 0) {
+ cairo_set_source_surface(cairoinfo.Cr, img_surf_num[num % 10], img_x, img_y);
+ cairo_paint(cairoinfo.Cr);
+ img_x -= 18;
+ num /= 10;
+ }
+
+ _FUNC_EXIT;
+}
+
+void cairo_draw_text(void)
+{
+ _FUNC_ENTER;
+
+ _DEBUG_LOG("s_font_initialized");
+
+ /* set text color */
+ cairo_set_source_rgb(cairoinfo.Cr, TEXT_COLOR);
+
+ /* set text font */
+ cairo_set_font_size(cairoinfo.Cr, (double)s_font_sz);
+ cairo_select_font_face(cairoinfo.Cr, DEFAULT_FONT, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+
+ /* set text position */
+ cairo_move_to(cairoinfo.Cr, s_text_x1, s_text_y1);
+
+ if (s_bnewline)
+ /* set text position */
+ cairo_move_to(cairoinfo.Cr, s_text_x2, s_text_y2);
+
+ _FUNC_EXIT;
+ return;
+}
+
+static void *__thread_font_init(void *arg)
+{
+ _FUNC_ENTER;
+
+ double text_x1;
+ double text_x2;
+ double text_y;
+ int font_sz = 0;
+ char* pos_newline;
+
+ /* separate text based on new line */
+ s_rw_process_msg1[MAX_BUF_LEN - 1] = 0x00;
+ s_rw_process_msg2[MAX_BUF_LEN - 1] = 0x00;
+ strncpy(s_rw_process_msg1, RW_PROCESS_MSG, MAX_BUF_LEN - 1);
+ strncpy(s_rw_process_msg2, RW_PROCESS_MSG, MAX_BUF_LEN - 1);
+ _DEBUG_LOG("[%s], [%s]\n", s_rw_process_msg1, s_rw_process_msg2);
+
+ pos_newline = strchr(s_rw_process_msg1, '\n');
+ if (pos_newline != NULL) {
+ strncpy(s_rw_process_msg2, pos_newline + 1, MAX_BUF_LEN - 1);
+ *pos_newline = 0x00;
+ s_bnewline = 1;
+ }
+
+ /* set text font */
+ cairo_select_font_face(cairoinfo.Cr, DEFAULT_FONT, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+
+ /* calculate proper font size */
+ for (font_sz = TEXT_FONT_SIZE_MAX; font_sz >= TEXT_FONT_SIZE_MIN; font_sz -= 2) {
+ /* set font size */
+ cairo_set_font_size(cairoinfo.Cr, (double)font_sz);
+ }
+
+ if (font_sz < TEXT_FONT_SIZE_MIN)
+ font_sz = TEXT_FONT_SIZE_MIN;
+
+ /* set text position */
+ text_x1 = (double)cairoinfo.width / 2;
+ text_x2 = (double)cairoinfo.width / 2;
+
+ if (s_bnewline)
+ text_y = 180 - font_sz;
+ else
+ text_y = 180;
+
+ /* keep for later use */
+ s_text_x1 = text_x1;
+ s_text_y1 = text_y;
+ s_text_x2 = text_x2;
+ s_text_y2 = text_y + ((double)(font_sz)) * 1.2;
+ s_font_sz = font_sz;
+
+ s_font_initialized = 1;
+
+ _FUNC_EXIT;
+ return NULL;
+}
+
+/*-----------------------------------------------------------------------------
+ cairo_ui_init()
+ ----------------------------------------------------------------------------*/
+int cairo_ui_init(int width, int height)
+{
+ _FUNC_ENTER;
+
+ _DEBUG_LOG("cairo_image_init w :%d , h :%d", width, height);
+
+ cairo_status_t status;
+
+ /* get LCD resolution from fbinfo */
+ cairoinfo.width = width;
+ cairoinfo.height = height;
+
+ /* create cairo image surface(image surface means memory buffer) */
+ cairoinfo.Surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, cairoinfo.width, cairoinfo.height);
+ status = cairo_surface_status(cairoinfo.Surface);
+ if (status != CAIRO_STATUS_SUCCESS) {
+ _DEBUG_EXCEPTION("cairo_image_init surface not create!!");
+ _FUNC_EXIT;
+ return -1;
+ }
+
+ /* create cairo context */
+ cairoinfo.Cr = cairo_create(cairoinfo.Surface);
+ status = cairo_status(cairoinfo.Cr);
+ if (status != CAIRO_STATUS_SUCCESS) {
+ _DEBUG_EXCEPTION("cairo_image_init cairo_create fail!!");
+ _FUNC_EXIT;
+ return -1;
+ }
+
+ cairo_image_init();
+
+ cairo_clear_window();
+
+ /* draw main text image */
+ if (check_existence((char *)RO_TEXT_IMG_FILE_PATH) > 0) {
+ cairo_draw_main_text_img();
+ } else {
+ pthread_t th_id;
+
+ int error = pthread_create(&th_id, NULL, __thread_font_init, NULL);
+ if (error != 0) {
+ _DEBUG_EXCEPTION("Thread creation failed errno [%d]\n", errno);
+ _FUNC_EXIT;
+ return -1;
+ }
+ }
+
+ _FUNC_EXIT;
+ return 0;
+}
+
+void cairo_ui_exit(void)
+{
+ _FUNC_ENTER;
+
+ cairo_image_exit();
+ cairo_destroy(cairoinfo.Cr);
+
+ _FUNC_EXIT;
+}
+
+int cairo_get_text_status(void)
+{
+ _FUNC_ENTER;
+ _FUNC_EXIT;
+ return s_font_initialized;
+}
--- /dev/null
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RW_UPDATE_NEW_COMMON_H__
+#define __RW_UPDATE_NEW_COMMON_H__
+
+#include <stdio.h>
+#include <errno.h>
+#include <dlog.h>
+#include <stdbool.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "FOTA_GUI_RW"
+
+#define COLOR_RED "\033[0;31m"
+#define COLOR_GREEN "\033[0;32m"
+#define COLOR_BROWN "\033[0;33m"
+#define COLOR_BLUE "\033[0;34m"
+#define COLOR_PURPLE "\033[0;35m"
+#define COLOR_CYAN "\033[0;36m"
+#define COLOR_LIGHTBLUE "\033[0;37m"
+#define COLOR_END "\033[0;m"
+
+#define _DEBUG_SECURE_LOG(fmt, args...) SECURE_SLOGD(fmt, ##args)
+#define _DEBUG_SECURE_EXCEPTION(fmt, args...) SECURE_SLOGE(COLOR_RED"* Critical * " fmt COLOR_END, ##args)
+
+#define _DEBUG_LOG(fmt, args...) SLOGI(fmt, ##args)
+#define _DEBUG_INFO(fmt, args...) SLOGI(COLOR_GREEN fmt COLOR_END, ##args)
+#define _DEBUG_WARNING(fmt, args...) SLOGW(COLOR_BLUE"* Warning * " fmt COLOR_END, ##args)
+#define _DEBUG_CHECK(fmt, args...) SLOGI(COLOR_LIGHTBLUE fmt, ##args)
+#define _DEBUG_EXCEPTION(fmt, args...) SLOGE(COLOR_RED"* Critical * " fmt COLOR_END, ##args)
+#define _FUNC_ENTER SLOGI(COLOR_GREEN"ENTER >>>>"COLOR_END)
+#define _FUNC_EXIT SLOGI(COLOR_GREEN"EXIT <<<<"COLOR_END)
+
+#define FILE_IO_BUF_SIZE 128
+
+#define TRUE 1
+#define FALSE 0
+
+#define UNUSED(x) (void)(x)
+
+#ifdef FEATURE_ROTATE
+enum {
+ BATT_STATE_CHARGING = 0,
+ BATT_STATE_FULL,
+ BATT_STATE_ERROR,
+ BATT_STATE_DISCONNECT,
+ BATT_STATE_LOWBATT,
+ BATT_STATE_OVERVOLTAGE,
+ BATT_STATE_OVERHEAT,
+ BATT_STATE_NOTCHARGE,
+ BATT_STATE_COLD
+};
+#endif
+
+#endif /* __RW_UPDATE_NEW_COMMON_H__ */
--- /dev/null
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RW_UPDATE_NEW_COMMON_DISPLAY_H__
+#define __RW_UPDATE_NEW_COMMON_DISPLAY_H__
+
+#include <tdm.h>
+#include <tbm_bufmgr.h>
+
+#include <tdm_helper.h>
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
+
+#define MAX_BUF 2
+#define RGB32_BPP 32
+#define RGB32_PITCH 4
+
+typedef struct chg_common_disp {
+ tdm_display *disp;
+ tdm_output *output;
+ tdm_layer *layer;
+ tdm_pp *pp;
+ int tdm_fd;
+ int drm_fd;
+
+ tbm_surface_h surf[MAX_BUF];
+ tbm_surface_h pp_surf[MAX_BUF];
+ tbm_bufmgr bufmgr;
+ unsigned int handle[MAX_BUF];
+ unsigned int pp_handle[MAX_BUF];
+ tbm_bo bo[MAX_BUF];
+ tbm_bo_handle bo_handle[MAX_BUF];
+ tbm_bo pp_bo[MAX_BUF];
+ tbm_bo_handle pp_bo_handle[MAX_BUF];
+ void *buffer[MAX_BUF];
+ void *pp_buffer[MAX_BUF];
+ int buffer_size;
+ int width;
+ int height;
+ int stride;
+ int current_buf_id;
+ int degree;
+
+ bool use_tdm_hwc;
+ tdm_hwc *hwc;
+} common_disp;
+
+typedef enum {
+ FRONT_BUFFER = 0,
+ BACK_BUFFER
+} BUFFER_TYPE;
+
+enum {
+ CHG_DEGREE_0 = 0,
+ CHG_DEGREE_90 = 1,
+ CHG_DEGREE_180 = 2,
+ CHG_DEGREE_270 = 3,
+};
+
+extern common_disp s_disp;
+
+int chg_common_display_init(common_disp *st_disp);
+void chg_common_display_deinit(common_disp *st_disp);
+void chg_common_display_update(common_disp *st_disp);
+void chg_common_lcd_on(common_disp *st_disp);
+void chg_common_lcd_suspend(common_disp *st_disp);
+void chg_common_lcd_off(common_disp *st_disp);
+void chg_common_display_rotate(common_disp *st_disp);
+#endif /* __RW_UPDATE_NEW_COMMON_DISPLAY_H__ */
--- /dev/null
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __CHG_FB_H__
+#define __CHG_FB_H__
+
+typedef enum _CHG_SLEEP_TYPE {
+ CHG_SLEEP_TYPE_NORMAL,
+ CHG_SLEEP_TYPE_EFFECT,
+ CHG_SLEEP_TYPE_TEMP_ERROR
+} CHG_SLEEP_TYPE;
+
+typedef struct _FbInfo {
+ unsigned char *buf[2];
+ unsigned int current_fb_id;
+ int w;
+ int h;
+ int sz;
+ int degree;
+ CHG_SLEEP_TYPE sleep_type;
+ int full_flag;
+} FbInfo;
+
+extern int fb_open(FbInfo *fbi);
+extern void fb_close(FbInfo *fbi);
+extern int fb_display(FbInfo *fbi);
+extern void fb_clear_screen(FbInfo *fbi, unsigned int color);
+extern void fb_fill_rect(FbInfo *fbi, int x1, int y1, int x2, int y2,
+ unsigned int color);
+extern void fb_draw_screen(FbInfo *fbi);
+#ifdef FEATURE_ROTATE
+extern void fb_draw_img_rotate_update(FbInfo *fbi);
+#endif
+#endif /* __CHG_FB_H__ */
--- /dev/null
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include "rw-update-ani_new.h"
+#include "rw-update_new_common.h"
+#include "rw-update_new_fb.h"
+#include <sys/ioctl.h>
+#include <unistd.h>
+
+#ifdef CAIRO_LIB
+#include "rw-update_new_cairo.h"
+#endif
+#include "rw-update_new_common_display.h"
+
+common_disp s_disp;
+
+/*-----------------------------------------------------------------------------
+ fb_open()
+ ----------------------------------------------------------------------------*/
+int fb_open(FbInfo *fbi)
+{
+ _FUNC_ENTER;
+
+ memset(&s_disp, 0x00, sizeof(struct chg_common_disp));
+
+ if (chg_common_display_init(&s_disp)) {
+ _DEBUG_EXCEPTION("chg_common_display_init fail!!");
+ _FUNC_EXIT;
+ return -1;
+ }
+
+ fbi->buf[FRONT_BUFFER] = s_disp.buffer[FRONT_BUFFER];
+ fbi->buf[BACK_BUFFER] = s_disp.buffer[BACK_BUFFER];
+ fbi->current_fb_id = s_disp.current_buf_id;
+ fbi->w = s_disp.width;
+ fbi->h = s_disp.height;
+ fbi->sz = s_disp.buffer_size;
+
+ _FUNC_EXIT;
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------
+ fb_close()
+ ----------------------------------------------------------------------------*/
+void fb_close(FbInfo *fbi)
+{
+ _FUNC_ENTER;
+
+ chg_common_display_deinit(&s_disp);
+
+ _FUNC_EXIT;
+}
+
+/*------------------------------------------------------------------------------
+ fb_display()
+------------------------------------------------------------------------------*/
+int fb_display(FbInfo *fbi)
+{
+ s_disp.current_buf_id = fbi->current_fb_id;
+
+ //_DEBUG_LOG("current_fb_id : %d", fbi->current_fb_id);
+#ifdef FEATURE_ROTATE
+ s_disp.degree = fbi->degree;
+
+ int battery_state = is_batt_status();
+
+ if ((fbi->degree != CHG_DEGREE_0) &&
+ (battery_state == BATT_STATE_CHARGING || battery_state == BATT_STATE_FULL)) {
+ chg_common_display_rotate(&s_disp);
+ } else
+#endif
+ {
+ chg_common_display_update(&s_disp);
+ }
+
+ return 0;
+}
+
+#ifdef FEATURE_ROTATE
+/*------------------------------------------------------------------------------
+ fb_rotate()
+------------------------------------------------------------------------------*/
+int fb_rotate(FbInfo *fbi)
+{
+ s_disp.current_buf_id = fbi->current_fb_id;
+ _DEBUG_LOG("current_fb_id : %d", fbi->current_fb_id);
+ s_disp.degree = fbi->degree;
+ chg_common_display_rotate(&s_disp);
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------
+ fb_draw_img_rotate_update()
+ ----------------------------------------------------------------------------*/
+void fb_draw_img_rotate_update(FbInfo *fbi)
+{
+ int ret = 0;
+
+ ret = fb_rotate(fbi);
+ _DEBUG_LOG("ret : %d", ret);
+}
+#endif
+
+/*-----------------------------------------------------------------------------
+ fb_draw_img_forced_update()
+ ----------------------------------------------------------------------------*/
+void fb_draw_img_forced_update(FbInfo *fbi)
+{
+ int ret = 0;
+ ret = fb_display(fbi);
+ _DEBUG_LOG("current_fb_id : %d, ret : %d", fbi->current_fb_id, ret);
+}
+/*-----------------------------------------------------------------------------
+ fb_draw_img_check_lcd_on()
+ ----------------------------------------------------------------------------*/
+void fb_draw_img_check_lcd_on(FbInfo *fbi)
+{
+ _FUNC_ENTER;
+
+ int ret = 0;
+
+ fbi->current_fb_id = FRONT_BUFFER;
+ //_DEBUG_LOG("current_fb_id :%d", fbi->current_fb_id);
+
+ ret = fb_display(fbi);
+ _DEBUG_LOG("%s - drawing... ret : %d", __func__, ret);
+
+ _FUNC_EXIT;
+}
+
+/*-----------------------------------------------------------------------------
+ fb_clear_screen()
+ ----------------------------------------------------------------------------*/
+void fb_clear_screen(FbInfo *fbi, unsigned int color)
+{
+ unsigned int *fb_buf_cur = NULL;
+ int loop_count = fbi->w * fbi->h;
+
+ fb_buf_cur = (unsigned int *)fbi->buf[FRONT_BUFFER];
+
+ if (fb_buf_cur == NULL) {
+ _DEBUG_LOG("fb_buf_cur is null error...");
+ return;
+ }
+ while (loop_count--)
+ *(fb_buf_cur++) = color;
+}
+
+#ifdef CAIRO_LIB
+
+/*-----------------------------------------------------------------------------
+ fb_update_screen()
+ ----------------------------------------------------------------------------*/
+void fb_update_screen(FbInfo *fbi)
+{
+ _FUNC_ENTER;
+
+ unsigned int *fb_buf_cur = NULL;
+
+ fb_buf_cur = (unsigned int *)fbi->buf[FRONT_BUFFER];
+ if (fb_buf_cur == NULL) {
+ _DEBUG_EXCEPTION("fb_buf_cur is null error...");
+ _FUNC_EXIT;
+ return;
+ }
+
+ cairo_update_screen(fb_buf_cur, fbi->sz);
+
+ _FUNC_EXIT;
+}
+
+static int progress_before = -1;
+static int total = 0;
+
+void fb_draw_screen(FbInfo *fbi)
+{
+ _FUNC_ENTER;
+
+ int acc;
+ int progress = 0;
+ static int b_text_drawn = 0;
+ FILE *fp;
+
+ if (total <= 0 && access("/tmp/upgrade/total", R_OK) == 0) {
+ fp = fopen("/tmp/upgrade/total", "r");
+ if (fp) {
+ if (fscanf(fp, "%d", &total) == EOF)
+ _DEBUG_LOG("Error occurs at reading total");
+ if (total < 0)
+ total = 0;
+ if (total > 0xffffff)
+ total = 0xffffff;
+ fclose(fp);
+ } else
+ total = 0;
+ }
+
+ if (access("/tmp/upgrade/progress", R_OK) == 0) {
+ fp = fopen("/tmp/upgrade/progress", "r");
+ if (fp) {
+ if (fscanf(fp, "%d", &progress) == EOF)
+ _DEBUG_LOG("Error occurs at reading progress");
+ if (progress < 0)
+ progress = 0;
+ if (progress > total)
+ progress = total;
+ fclose(fp);
+ } else
+ progress = 0;
+ }
+
+ _DEBUG_LOG("progress: %d/%d", progress, total);
+
+ if (total > 0 && progress > progress_before) {
+ for (acc = progress_before + 1; acc <= progress; acc++) {
+ /* draw image */
+ cairo_draw_main_img();
+
+ cairo_draw_progress_bar(100 * acc / total);
+ cairo_draw_num_progress(acc, total);
+
+ if (cairo_get_text_status() == 1) {
+ if (b_text_drawn == 0) {
+ cairo_draw_text();
+ b_text_drawn = 1;
+ }
+ }
+
+ fb_update_screen(fbi);
+ fb_draw_img_check_lcd_on(fbi);
+ }
+ progress_before = progress;
+ }
+
+ _FUNC_EXIT;
+}
+#endif
--- /dev/null
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/poll.h>
+#include <sys/time.h>
+#include <tdm.h>
+#include <tdm_helper.h>
+#include "rw-update_new_common.h"
+#include "rw-update_new_common_display.h"
+
+static void chg_common_display_commit_handler_cb(tdm_output *output, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+{
+ _DEBUG_LOG("commit_handle_cb!!\n");
+ return;
+}
+
+int chg_common_display_init(common_disp *st_disp)
+{
+ _FUNC_ENTER;
+
+ int color = 0;
+ int buf_cnt;
+ int output_count = 0;
+ int i = 0;
+
+ tdm_error err = TDM_ERROR_NONE;
+ tdm_output *output = NULL;
+ tdm_output_type output_type = TDM_OUTPUT_TYPE_Unknown;
+ tdm_output_conn_status conn_status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
+ const tdm_output_mode *output_mode;
+ tdm_info_layer layer_info;
+ tbm_surface_info_s surf_info;
+
+ st_disp->disp = tdm_display_init(&err);
+ if (!st_disp->disp) {
+ _DEBUG_EXCEPTION("failed to init tdm_display. error num = %d\n", err);
+ goto exit;
+ }
+
+ err = tdm_display_get_fd(st_disp->disp, &st_disp->tdm_fd);
+ if (err != TDM_ERROR_NONE) {
+ _DEBUG_EXCEPTION("failed to get tdm fd. error num = %d\n", err);
+ goto exit;
+ }
+
+ st_disp->drm_fd = tdm_helper_get_fd("TDM_DRM_MASTER_FD");
+ if (st_disp->drm_fd == -1) {
+ _DEBUG_EXCEPTION("failed to get tdm fd. error num = %d\n", err);
+ goto exit;
+ }
+
+ err = tdm_display_get_output_count(st_disp->disp, &output_count);
+ if (err != TDM_ERROR_NONE) {
+ _DEBUG_EXCEPTION("failed to get output count. error num = %d\n", err);
+ goto exit;
+ }
+
+ for (i = 0; i < output_count; i++) {
+ output = tdm_display_get_output(st_disp->disp, i, &err);
+ if (err != TDM_ERROR_NONE) {
+ _DEBUG_EXCEPTION("failed to get outout. error num = %d\n", err);
+ goto exit;
+ }
+
+ err = tdm_output_get_output_type(output, &output_type);
+ if (err != TDM_ERROR_NONE) {
+ _DEBUG_EXCEPTION("failed to get output type. error num = %d\n", err);
+ goto exit;
+ }
+
+ err = tdm_output_get_conn_status(output, &conn_status);
+ if (err != TDM_ERROR_NONE) {
+ _DEBUG_EXCEPTION("failed to get output connection status. error num = %d\n", err);
+ goto exit;
+ }
+
+ _DEBUG_LOG("output_type=%d conn_status=%d\n", output_type, conn_status);
+ if ((output_type == TDM_OUTPUT_TYPE_LVDS || output_type == TDM_OUTPUT_TYPE_DSI) &&
+ (conn_status == TDM_OUTPUT_CONN_STATUS_CONNECTED)) {
+ int cnt = 0;
+ err = tdm_output_get_available_modes(output, &output_mode, &cnt);
+ if (err != TDM_ERROR_NONE) {
+ _DEBUG_EXCEPTION("failed to get output available modes. error num = %d\n", err);
+ goto exit;
+ }
+
+ err = tdm_output_set_mode(output, &output_mode[0]);
+ if (err != TDM_ERROR_NONE) {
+ _DEBUG_EXCEPTION("failed to set mode. error num = %d\n", err);
+ goto exit;
+ }
+
+ /* GET MODE INFO */
+ st_disp->output = output;
+ st_disp->width = output_mode->hdisplay;
+ st_disp->height = output_mode->vdisplay;
+
+ unsigned int width_mm = 0;
+ unsigned int height_mm = 0;
+
+ err = tdm_output_get_physical_size(output, &width_mm, &height_mm);
+ _DEBUG_LOG("err = [%d]", err);
+ _DEBUG_LOG("TDM_OUTPUT_MODE:name[%s] mode:wh[%d %d] mm[%d %d]", output_mode->name, st_disp->width, st_disp->height, width_mm, height_mm);
+
+ break;
+ }
+ }
+
+ /* MEMORY ALLOCATION */
+ st_disp->bufmgr = tbm_bufmgr_init(st_disp->drm_fd);
+ if (!st_disp->bufmgr) {
+ _DEBUG_EXCEPTION("failed to tbm_bufmgr_init\n");
+ goto exit;
+ }
+
+ st_disp->buffer_size = st_disp->width * st_disp->height * RGB32_PITCH;
+ st_disp->stride = st_disp->width * RGB32_PITCH;
+
+ surf_info.width = st_disp->width;
+ surf_info.height = st_disp->height;
+ surf_info.format = TBM_FORMAT_ARGB8888;
+ surf_info.bpp = 32;
+ surf_info.size = st_disp->buffer_size;
+ surf_info.num_planes = 1;
+ surf_info.planes[0].size = st_disp->buffer_size;
+ surf_info.planes[0].offset = 0;
+ surf_info.planes[0].stride = st_disp->stride;
+
+ for (buf_cnt = 0; buf_cnt < MAX_BUF; buf_cnt++) {
+ st_disp->bo[buf_cnt] = tbm_bo_alloc(st_disp->bufmgr, st_disp->buffer_size, TBM_BO_NONCACHABLE);
+ if (!st_disp->bo[buf_cnt]) {
+ _DEBUG_EXCEPTION("failed to tbm_bo_alloc\n");
+ goto exit;
+ }
+
+ st_disp->bo_handle[buf_cnt] = tbm_bo_map(st_disp->bo[buf_cnt], TBM_DEVICE_CPU, TBM_OPTION_WRITE);
+ st_disp->buffer[buf_cnt] = st_disp->bo_handle[buf_cnt].ptr;
+ st_disp->handle[buf_cnt] = tbm_bo_get_handle(st_disp->bo[buf_cnt], TBM_DEVICE_2D).u32;
+
+ memset(st_disp->buffer[buf_cnt], color, st_disp->stride * st_disp->height);
+
+ tbm_bo_unmap(st_disp->bo[buf_cnt]);
+
+ st_disp->surf[buf_cnt] = tbm_surface_internal_create_with_bos(&surf_info, &st_disp->bo[buf_cnt], 1);
+ if (!st_disp->surf[buf_cnt]) {
+ _DEBUG_EXCEPTION("failed to create tbm_surface!!\n");
+ goto exit;
+ }
+ }
+
+#ifdef FEATURE_ROTATE
+ for (buf_cnt = 0; buf_cnt < MAX_BUF; buf_cnt++) {
+ st_disp->pp_bo[buf_cnt] = tbm_bo_alloc(st_disp->bufmgr, st_disp->buffer_size, TBM_BO_NONCACHABLE);
+ if (!st_disp->pp_bo[buf_cnt]) {
+ _DEBUG_EXCEPTION("failed to tbm_bo_alloc pp\n");
+ goto exit;
+ }
+
+ st_disp->pp_bo_handle[buf_cnt] = tbm_bo_map(st_disp->pp_bo[buf_cnt], TBM_DEVICE_CPU, TBM_OPTION_WRITE);
+ st_disp->pp_buffer[buf_cnt] = st_disp->pp_bo_handle[buf_cnt].ptr;
+ st_disp->pp_handle[buf_cnt] = tbm_bo_get_handle(st_disp->pp_bo[buf_cnt], TBM_DEVICE_2D).u32;
+
+ memset(st_disp->pp_buffer[buf_cnt], 0x00, st_disp->stride * st_disp->height);
+
+ tbm_bo_unmap(st_disp->pp_bo[buf_cnt]);
+
+ st_disp->pp_surf[buf_cnt] = tbm_surface_internal_create_with_bos(&surf_info, &st_disp->pp_bo[buf_cnt], 1);
+ if (!st_disp->surf[buf_cnt]) {
+ _DEBUG_EXCEPTION("failed to create tbm_surface for pp!!\n");
+ goto exit;
+ }
+ _DEBUG_LOG("pp:b[%d]hdl[%d]", buf_cnt, st_disp->pp_handle[buf_cnt]);
+ }
+#endif
+
+ /* CHECK HWC USAGE */
+ tdm_output_capability output_caps;
+ tdm_output_get_capabilities(st_disp->output, &output_caps);
+ if (output_caps & TDM_OUTPUT_CAPABILITY_HWC)
+ st_disp->use_tdm_hwc = true;
+ else
+ st_disp->use_tdm_hwc = false;
+
+ /* SET LAYER */
+ if (st_disp->use_tdm_hwc) {
+ st_disp->hwc = tdm_output_get_hwc(st_disp->output, &err);
+ if (!st_disp->hwc) {
+ _DEBUG_EXCEPTION("failed to get hwc. error num = %d\n", err);
+ goto exit;
+ }
+ } else {
+ tdm_layer_capability layer_caps;
+ tdm_layer *tmp_layer = NULL;
+
+ for (i = 0; i < output_count; i++) {
+ tmp_layer = tdm_output_get_layer(st_disp->output, output_count, &err);
+ tdm_layer_get_capabilities(tmp_layer, &layer_caps);
+ if (layer_caps & TDM_LAYER_CAPABILITY_PRIMARY)
+ break;
+ }
+
+ if (!tmp_layer) {
+ _DEBUG_EXCEPTION("failed to get output layer. error num = %d\n", err);
+ goto exit;
+ }
+
+ st_disp->layer = tmp_layer;
+
+ layer_info.src_config.size.h = st_disp->width;
+ layer_info.src_config.size.v = st_disp->height;
+ layer_info.src_config.pos.x = 0;
+ layer_info.src_config.pos.y = 0;
+ layer_info.src_config.pos.w = st_disp->width;
+ layer_info.src_config.pos.h = st_disp->height;
+ layer_info.src_config.format = TBM_FORMAT_ARGB8888;
+ layer_info.dst_pos.x = 0;
+ layer_info.dst_pos.y = 0;
+ layer_info.dst_pos.w = st_disp->width;
+ layer_info.dst_pos.h = st_disp->height;
+ layer_info.transform = TDM_TRANSFORM_NORMAL;
+
+ err = tdm_layer_set_info(st_disp->layer, &layer_info);
+ if (err != TDM_ERROR_NONE) {
+ _DEBUG_EXCEPTION("failed to get output layer. error num = %d\n", err);
+ goto exit;
+ }
+ }
+
+ /* SETUP PP */
+#ifdef FEATURE_ROTATE
+ st_disp->pp = tdm_display_create_pp(st_disp->disp, &err);
+ if (err != TDM_ERROR_NONE) {
+ _DEBUG_EXCEPTION("failed to get output layer. error num = %d\n", err);
+ goto exit;
+ }
+#endif
+
+ st_disp->current_buf_id = 0;
+ _DEBUG_LOG("done");
+ _FUNC_EXIT;
+ return 0;
+
+exit:
+ chg_common_display_deinit(st_disp);
+ _FUNC_EXIT;
+ return -1;
+}
+
+void chg_common_display_deinit(common_disp *st_disp)
+{
+ _FUNC_ENTER;
+
+ int buf_cnt = 0;
+
+ if (st_disp->disp != NULL) {
+ /* RELEASE RESOURCE */
+ for (buf_cnt = 0; buf_cnt < MAX_BUF; buf_cnt++) {
+ if (st_disp->surf[buf_cnt] != NULL)
+ tbm_surface_destroy(st_disp->surf[buf_cnt]);
+
+ if (st_disp->bo[buf_cnt] != NULL)
+ tbm_bo_unref(st_disp->bo[buf_cnt]);
+
+#ifdef FEATURE_ROTATE
+ if (st_disp->pp_surf[buf_cnt] != NULL)
+ tbm_surface_destroy(st_disp->pp_surf[buf_cnt]);
+
+ if (st_disp->pp_bo[buf_cnt] != NULL)
+ tbm_bo_unref(st_disp->pp_bo[buf_cnt]);
+#endif
+ }
+
+ if (st_disp->bufmgr != NULL)
+ tbm_bufmgr_deinit(st_disp->bufmgr);
+ st_disp->bufmgr = NULL;
+
+#ifdef FEATURE_ROTATE
+ if (st_disp->pp) {
+ tdm_pp_destroy(st_disp->pp);
+ st_disp->pp = NULL;
+ }
+#endif
+
+ tdm_display_deinit(st_disp->disp);
+ st_disp->disp = NULL;
+ }
+
+ _FUNC_EXIT;
+}
+
+#ifdef FEATURE_ROTATE
+void chg_common_display_rotate(common_disp *st_disp)
+{
+ int buf_cnt = 0;
+ int dst_degree = st_disp->degree;
+
+ tdm_error err = TDM_ERROR_NONE;
+ tdm_info_pp pp_info;
+
+ memset(&pp_info, 0x00, sizeof(tdm_info_pp));
+
+ pp_info.src_config.size.h = st_disp->width;
+ pp_info.src_config.size.v = st_disp->height;
+ pp_info.src_config.pos.x = 0;
+ pp_info.src_config.pos.y = 0;
+ pp_info.src_config.pos.w = st_disp->width;
+ pp_info.src_config.pos.h = st_disp->height;
+ pp_info.src_config.format = TBM_FORMAT_ARGB8888;
+
+ pp_info.dst_config.size.h = st_disp->width;
+ pp_info.dst_config.size.v = st_disp->height;
+ pp_info.dst_config.pos.x = 0;
+ pp_info.dst_config.pos.y = 0;
+ pp_info.dst_config.pos.w = st_disp->width;
+ pp_info.dst_config.pos.h = st_disp->height;
+ pp_info.dst_config.format = TBM_FORMAT_ARGB8888;
+
+ pp_info.sync = 1;
+ pp_info.flags = 0;
+
+ switch (dst_degree) {
+ case CHG_DEGREE_0:
+ pp_info.transform = TDM_TRANSFORM_NORMAL;
+ break;
+ case CHG_DEGREE_90:
+ pp_info.transform = TDM_TRANSFORM_90;
+ break;
+ case CHG_DEGREE_180:
+ pp_info.transform = TDM_TRANSFORM_180;
+ break;
+ case CHG_DEGREE_270:
+ pp_info.transform = TDM_TRANSFORM_270;
+ break;
+ default:
+ pp_info.transform = TDM_TRANSFORM_NORMAL;
+ break;
+ }
+
+ _DEBUG_LOG("dst_degree : %d", dst_degree);
+
+ buf_cnt = st_disp->current_buf_id;
+
+ err = tdm_pp_set_info(st_disp->pp, &pp_info);
+ if (err != TDM_ERROR_NONE) {
+ _DEBUG_LOG("failed to set pp info. error num = %d\n", err);
+ return;
+ }
+
+ err = tdm_pp_attach(st_disp->pp, st_disp->surf[buf_cnt], st_disp->pp_surf[buf_cnt]);
+ if (err != TDM_ERROR_NONE) {
+ _DEBUG_LOG("failed to attach pp. error num = %d\n", err);
+ return;
+ }
+
+ err = tdm_pp_commit(st_disp->pp);
+ if (err != TDM_ERROR_NONE) {
+ _DEBUG_LOG("failed to attach pp. error num = %d\n", err);
+ return;
+ }
+
+ if (st_disp->use_tdm_hwc) {
+ uint32_t num_types;
+ tdm_region damage;
+ memset(&damage, 0, sizeof(damage));
+
+ tdm_hwc_set_client_target_buffer(st_disp->hwc, st_disp->surf[buf_cnt], damage);
+ tdm_hwc_validate(st_disp->hwc, NULL, 0, &num_types);
+ tdm_hwc_accept_validation(st_disp->hwc);
+ tdm_hwc_commit(st_disp->hwc, 1, chg_common_display_commit_handler_cb, st_disp);
+ } else {
+ tdm_layer_set_buffer(st_disp->layer, st_disp->pp_surf[buf_cnt]);
+
+ // TODO: sync or async??
+ tdm_output_commit(st_disp->output, 1, chg_common_display_commit_handler_cb, st_disp);
+ }
+}
+#endif
+
+
+void chg_common_display_update(common_disp *st_disp)
+{
+ /* DISPLAY UPDATE */
+ int buf_cnt = 0;
+
+ buf_cnt = st_disp->current_buf_id;
+ //st_disp->current_buf_id = (++st_disp->current_buf_id)%MAX_BUF;
+
+ if (st_disp->use_tdm_hwc) {
+ uint32_t num_types;
+ tdm_region damage;
+ memset(&damage, 0, sizeof(damage));
+
+ tdm_hwc_set_client_target_buffer(st_disp->hwc, st_disp->surf[buf_cnt], damage);
+ tdm_hwc_validate(st_disp->hwc, NULL, 0, &num_types);
+ tdm_hwc_accept_validation(st_disp->hwc);
+ tdm_hwc_commit(st_disp->hwc, 1, chg_common_display_commit_handler_cb, st_disp);
+ } else {
+ tdm_layer_set_buffer(st_disp->layer, st_disp->surf[buf_cnt]);
+
+ // TODO: sync or async??
+ tdm_output_commit(st_disp->output, 1, chg_common_display_commit_handler_cb, st_disp);
+ }
+
+ return;
+}
+
+void chg_common_lcd_on(common_disp *st_disp)
+{
+ _FUNC_ENTER;
+
+ /* SET DPMS ON */
+ _DEBUG_LOG("DPMS ON!\n");
+ tdm_output_set_dpms(st_disp->output, TDM_OUTPUT_DPMS_ON);
+
+ _FUNC_EXIT;
+ return;
+}
+
+void chg_common_lcd_suspend(common_disp *st_disp)
+{
+ /* SET DPMS SUSPEND */
+ _DEBUG_LOG("DPMS SUSPEND!\n");
+ tdm_output_set_dpms(st_disp->output, TDM_OUTPUT_DPMS_SUSPEND);
+
+ return;
+}
+
+void chg_common_lcd_off(common_disp *st_disp)
+{
+ /* SET DPMS OFF */
+ _DEBUG_LOG("DPMS OFF!\n");
+ tdm_output_set_dpms(st_disp->output, TDM_OUTPUT_DPMS_OFF);
+
+ return;
+}