From: dyamy-lee Date: Mon, 27 Jul 2020 07:41:58 +0000 (+0900) Subject: Implements FOTA(RO, RW) UI, Recovery UI X-Git-Tag: submit/tizen/20200728.042539^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c882c9e0bab66f3a20762a3c8e819c773714d99;p=profile%2Fcommon%2Fapps%2Fnative%2Ffirmware-update-system-ui.git Implements FOTA(RO, RW) UI, Recovery UI Change-Id: I42c102587fe5e1d724f958e8b51d818085160fc8 --- diff --git a/42-tota-gui-common.list b/42-tota-gui-common.list new file mode 100644 index 0000000..bf92139 --- /dev/null +++ b/42-tota-gui-common.list @@ -0,0 +1,126 @@ +# ---- Target contents ----------------------------------------------------- # +VERBATIMS=" +/usr/share/res/images/common_base_rect_bg.png +/usr/share/res/images/common_progress_bar.png +/usr/share/res/images/common_downloading_0.png +/usr/share/res/images/common_downloading_1.png +/usr/share/res/images/common_downloading_2.png +/usr/share/res/images/common_downloading_3.png +/usr/share/res/images/common_downloading_4.png +/usr/share/res/images/common_downloading_5.png +/usr/share/res/images/common_downloading_6.png +/usr/share/res/images/common_downloading_7.png +/usr/share/res/images/common_downloading_8.png +/usr/share/res/images/common_downloading_9.png +/usr/share/res/images/common_downloading_percent.png +/usr/share/res/images/common_progress_000.png +/usr/share/res/images/common_progress_001.png +/usr/share/res/images/common_progress_002.png +/usr/share/res/images/common_progress_003.png +/usr/share/res/images/common_progress_004.png +/usr/share/res/images/common_progress_005.png +/usr/share/res/images/common_progress_006.png +/usr/share/res/images/common_progress_007.png +/usr/share/res/images/common_progress_008.png +/usr/share/res/images/common_progress_009.png +/usr/share/res/images/common_progress_010.png +/usr/share/res/images/common_progress_011.png +/usr/share/res/images/common_progress_012.png +/usr/share/res/images/common_progress_013.png +/usr/share/res/images/common_progress_014.png +/usr/share/res/images/common_progress_015.png +/usr/share/res/images/common_progress_016.png +/usr/share/res/images/common_progress_017.png +/usr/share/res/images/common_progress_018.png +/usr/share/res/images/common_progress_019.png +/usr/share/res/images/common_progress_020.png +/usr/share/res/images/common_progress_021.png +/usr/share/res/images/common_progress_022.png +/usr/share/res/images/common_progress_023.png +/usr/share/res/images/common_progress_024.png +/usr/share/res/images/common_progress_025.png +/usr/share/res/images/common_progress_026.png +/usr/share/res/images/common_progress_027.png +/usr/share/res/images/common_progress_028.png +/usr/share/res/images/common_progress_029.png +/usr/share/res/images/common_progress_030.png +/usr/share/res/images/common_progress_031.png +/usr/share/res/images/common_progress_032.png +/usr/share/res/images/common_progress_033.png +/usr/share/res/images/common_progress_034.png +/usr/share/res/images/common_progress_035.png +/usr/share/res/images/common_progress_036.png +/usr/share/res/images/common_progress_037.png +/usr/share/res/images/common_progress_038.png +/usr/share/res/images/common_progress_039.png +/usr/share/res/images/common_progress_040.png +/usr/share/res/images/common_progress_041.png +/usr/share/res/images/common_progress_042.png +/usr/share/res/images/common_progress_043.png +/usr/share/res/images/common_progress_044.png +/usr/share/res/images/common_progress_045.png +/usr/share/res/images/common_progress_046.png +/usr/share/res/images/common_progress_047.png +/usr/share/res/images/common_progress_048.png +/usr/share/res/images/common_progress_049.png +/usr/share/res/images/common_progress_050.png +/usr/share/res/images/common_progress_051.png +/usr/share/res/images/common_progress_052.png +/usr/share/res/images/common_progress_053.png +/usr/share/res/images/common_progress_054.png +/usr/share/res/images/common_progress_055.png +/usr/share/res/images/common_progress_056.png +/usr/share/res/images/common_progress_057.png +/usr/share/res/images/common_progress_058.png +/usr/share/res/images/common_progress_059.png +/usr/share/res/images/common_progress_060.png +/usr/share/res/images/common_progress_061.png +/usr/share/res/images/common_progress_062.png +/usr/share/res/images/common_progress_063.png +/usr/share/res/images/common_progress_064.png +/usr/share/res/images/common_progress_065.png +/usr/share/res/images/common_progress_066.png +/usr/share/res/images/common_progress_067.png +/usr/share/res/images/common_progress_068.png +/usr/share/res/images/common_progress_069.png +/usr/share/res/images/common_progress_070.png +/usr/share/res/images/common_progress_071.png +/usr/share/res/images/common_progress_072.png +/usr/share/res/images/common_progress_073.png +/usr/share/res/images/common_progress_074.png +/usr/share/res/images/common_progress_075.png +/usr/share/res/images/common_progress_076.png +/usr/share/res/images/common_progress_077.png +/usr/share/res/images/common_progress_078.png +/usr/share/res/images/common_progress_079.png +/usr/share/res/images/common_progress_080.png +/usr/share/res/images/common_progress_081.png +/usr/share/res/images/common_progress_082.png +/usr/share/res/images/common_progress_083.png +/usr/share/res/images/common_progress_084.png +/usr/share/res/images/common_progress_085.png +/usr/share/res/images/common_progress_086.png +/usr/share/res/images/common_progress_087.png +/usr/share/res/images/common_progress_088.png +/usr/share/res/images/common_progress_089.png +/usr/share/res/images/common_progress_090.png +/usr/share/res/images/common_progress_091.png +/usr/share/res/images/common_progress_092.png +/usr/share/res/images/common_progress_093.png +/usr/share/res/images/common_progress_094.png +/usr/share/res/images/common_progress_095.png +/usr/share/res/images/common_progress_096.png +/usr/share/res/images/common_progress_097.png +/usr/share/res/images/common_progress_098.png +/usr/share/res/images/common_progress_099.png +/usr/share/res/images/common_progress_100.png +/usr/share/res/images/common_ro_bg_text.png +/usr/share/res/images/common_recovery_bg_text.png +" + +WITHLIBS=" +/usr/bin/fota_gui +/usr/bin/recovery_gui +/usr/lib/tdm/libtdm-default.so +/usr/lib/bufmgr/libtbm_default.so +" diff --git a/42-tota-gui-wearable.list b/42-tota-gui-wearable.list new file mode 100644 index 0000000..6e45816 --- /dev/null +++ b/42-tota-gui-wearable.list @@ -0,0 +1,124 @@ +# ---- 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 +" diff --git a/42-tota-gui.list b/42-tota-gui.list deleted file mode 100644 index 6e45816..0000000 --- a/42-tota-gui.list +++ /dev/null @@ -1,124 +0,0 @@ -# ---- 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 -" diff --git a/CMakeLists.txt b/CMakeLists.txt index 50cb25b..0e44287 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,8 +12,6 @@ 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") @@ -36,11 +34,12 @@ IF("${ARCH}" STREQUAL "arm") 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) +ADD_SUBDIRECTORY(fota_gui_common) +ADD_SUBDIRECTORY(fota_gui_wearable) +ADD_SUBDIRECTORY(rw-update-ani-wearable) +ADD_SUBDIRECTORY(rw-update-ani-common) +ADD_SUBDIRECTORY(recovery_gui_common) diff --git a/firmware-update-system-ui.manifest b/firmware-update-system-ui.manifest deleted file mode 100644 index 1b29af6..0000000 --- a/firmware-update-system-ui.manifest +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/fota_gui/CMakeLists.txt b/fota_gui/CMakeLists.txt deleted file mode 100644 index c9f832b..0000000 --- a/fota_gui/CMakeLists.txt +++ /dev/null @@ -1,58 +0,0 @@ -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}) diff --git a/fota_gui/fota_fbinfo.h b/fota_gui/fota_fbinfo.h deleted file mode 100644 index 6b60e7f..0000000 --- a/fota_gui/fota_fbinfo.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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__ */ - diff --git a/fota_gui/fota_gr.c b/fota_gui/fota_gr.c deleted file mode 100644 index 8787e34..0000000 --- a/fota_gui/fota_gr.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 -} - diff --git a/fota_gui/fota_gr.h b/fota_gui/fota_gr.h deleted file mode 100644 index 85cfc0a..0000000 --- a/fota_gui/fota_gr.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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__ */ - diff --git a/fota_gui/fota_gr_direct.h b/fota_gui/fota_gr_direct.h deleted file mode 100644 index e0e2cc0..0000000 --- a/fota_gui/fota_gr_direct.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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__ */ diff --git a/fota_gui/fota_gr_direct_tw.c b/fota_gui/fota_gr_direct_tw.c deleted file mode 100644 index cb073cb..0000000 --- a/fota_gui/fota_gr_direct_tw.c +++ /dev/null @@ -1,464 +0,0 @@ -/* - * 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 -#include -#include - -#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); -} - diff --git a/fota_gui/fota_gui_common.h b/fota_gui/fota_gui_common.h deleted file mode 100644 index bf3330a..0000000 --- a/fota_gui/fota_gui_common.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 -#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__ */ diff --git a/fota_gui/fota_gui_log.h b/fota_gui/fota_gui_log.h deleted file mode 100644 index 5faa394..0000000 --- a/fota_gui/fota_gui_log.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 - -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__ */ - diff --git a/fota_gui/fota_gui_main.c b/fota_gui/fota_gui_main.c deleted file mode 100644 index a4e8254..0000000 --- a/fota_gui/fota_gui_main.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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; -} diff --git a/fota_gui/fota_gui_util.c b/fota_gui/fota_gui_util.c deleted file mode 100644 index 6e762d2..0000000 --- a/fota_gui/fota_gui_util.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#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); -} - diff --git a/fota_gui/fota_gui_util.h b/fota_gui/fota_gui_util.h deleted file mode 100644 index e4ec592..0000000 --- a/fota_gui/fota_gui_util.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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_ */ - diff --git a/fota_gui/fota_log.h b/fota_gui/fota_log.h deleted file mode 100644 index c4b303f..0000000 --- a/fota_gui/fota_log.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 - -/* - * 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__ */ - diff --git a/fota_gui/fota_png.c b/fota_gui/fota_png.c deleted file mode 100644 index f36bc50..0000000 --- a/fota_gui/fota_png.c +++ /dev/null @@ -1,455 +0,0 @@ -/* - * 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 -#include -#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); -} diff --git a/fota_gui/fota_png.h b/fota_gui/fota_png.h deleted file mode 100644 index 4d2a525..0000000 --- a/fota_gui/fota_png.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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__ */ diff --git a/fota_gui/tdm-if.c b/fota_gui/tdm-if.c deleted file mode 100644 index c3a2ee3..0000000 --- a/fota_gui/tdm-if.c +++ /dev/null @@ -1,318 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#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 ; -} diff --git a/fota_gui/tdm-if.h b/fota_gui/tdm-if.h deleted file mode 100644 index 9bd8d3b..0000000 --- a/fota_gui/tdm-if.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 -#include -#include -#include -#include - -#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__ */ diff --git a/fota_gui_common/CMakeLists.txt b/fota_gui_common/CMakeLists.txt new file mode 100644 index 0000000..ed5c3ea --- /dev/null +++ b/fota_gui_common/CMakeLists.txt @@ -0,0 +1,63 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(fota-gui-common C) + +#set( CMAKE_VERBOSE_MAKEFILE on ) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(BINDIR "${PREFIX}/bin") +#SET(FOTA_GUI "fota_gui") +SET(FOTA_GUI_COMMON "fota_gui_common") +SET(PKGDIR "${PREFIX}/share") +SET(RESDIR "${PKGDIR}/res") +SET(RESDIR_COMMON "${PKGDIR}/fota/res/images_common") + +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_ro_common_main.c + fota_gr_ro_common.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_COMMON ${GUI_SRCS} fota_gr_direct_ro_common.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_COMMON} ${GUI_SRCS_COMMON}) +TARGET_LINK_LIBRARIES(${FOTA_GUI_COMMON} ${gui_pkgs_LDFLAGS} ${LIBS} -lpthread) + +ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"") +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/images DESTINATION ${RESDIR_COMMON}) + +INSTALL(TARGETS ${FOTA_GUI_COMMON} DESTINATION ${BINDIR}) diff --git a/fota_gui_common/fota_fbinfo.h b/fota_gui_common/fota_fbinfo.h new file mode 100644 index 0000000..6b73ed8 --- /dev/null +++ b/fota_gui_common/fota_fbinfo.h @@ -0,0 +1,33 @@ +/* + * firmware-update-system-ui + * + * 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__ */ + diff --git a/fota_gui_common/fota_gr_direct_ro_common.c b/fota_gui_common/fota_gr_direct_ro_common.c new file mode 100644 index 0000000..38f209e --- /dev/null +++ b/fota_gui_common/fota_gr_direct_ro_common.c @@ -0,0 +1,483 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include + +#include "fota_gui_general.h" +#include "fota_png.h" +#include "fota_fbinfo.h" +#include "tdm-if.h" + +#define UNUSED(x) (void)(x) + +#define COLOR_BLACK 0xFF000000 + +#define MAX_PATH 256 +#define MAX_FILE_PATH 512 + +#if !defined(RESDIR) +#define RESDIR "/usr/share/res" +#endif +#define IMG_BASE RESDIR "/images/" + +#define MAIN_IMG_NAME "common_base_rect_bg.png" +#define MAIN_TEXT_NAME "common_ro_bg_text.png" +#define MAIN_PG_IMG_NAME "common_progress_bar.png" +#define PROGRESS_BAR_IMG_PREFIX "common_progress_" +#define PROGRESS_NUM_PREFIX "common_downloading_" +#define PERCENT_IMG_NAME "common_downloading_percent.png" + +/***************************************************************************** +** global variables +*****************************************************************************/ +const int x_offset_main_bg_text_pos = 518; +const int y_offset_main_bg_text_pos = 300; +const int x_offset_prog_bar_img_pos = 240; +const int y_offset_prog_bar_img_pos = 355; + +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 = 588; + img_y = 395; + + if (percent < 10) + img_x += 7; + else if (percent < 100) + img_x += 14; + else if (percent == 100) + img_x += 21; + + 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 += 14; + 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 += 14; + 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 += 13; + + 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, 610, 395, 65, 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 = x_offset_prog_bar_img_pos; + img_y = y_offset_prog_bar_img_pos; + + 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(); + + if (read_png_file(IMG_BASE MAIN_TEXT_NAME) < 0) + return; + + img_x = x_offset_main_bg_text_pos; + img_y = y_offset_main_bg_text_pos; + + 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_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, 240, 355); + 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_progress(void) +{ + LOG("fota_gr_direct_progress progress : %d \n", s_percent_to_draw); + + if (s_percent_to_draw > 0) { + _gr_direct_progress_bar(&s_fbi, s_percent_to_draw); + _gr_direct_draw_prog_text(&s_fbi, s_saved_percent); + } else if (s_percent_to_draw == 0) { + s_saved_percent = 0; + } + _gr_direct_update_screen(); +} + +/*----------------------------------------------------------------------------- + fota_gr_direct_update_progress + ----------------------------------------------------------------------------*/ +int fota_gr_direct_ro_update_progress(void) +{ + int percent = s_percent_to_draw; + + FILE *fp; + + if (access("/tmp/upgrade/ro_progress", R_OK) == 0) { + fp = fopen("/tmp/upgrade/ro_progress", "r"); + if (fp) { + if (fscanf(fp, "%d", &percent) == EOF) + LOG("Error occurs at reading ro_progress"); + if (percent < 0) + percent = 0; + if (percent > 0xffffff) + percent = 0xffffff; + fclose(fp); + } else + percent = s_percent_to_draw; + } + + s_percent_to_draw = percent; + if (s_saved_percent < s_percent_to_draw) { + LOG("s_saved_percent %d , s_percent_to_draw %d \n", s_saved_percent, s_percent_to_draw); + fota_gr_direct_progress(); + } + return s_saved_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); +} + diff --git a/fota_gui_common/fota_gr_direct_ro_common.h b/fota_gui_common/fota_gr_direct_ro_common.h new file mode 100644 index 0000000..b2bb591 --- /dev/null +++ b/fota_gui_common/fota_gr_direct_ro_common.h @@ -0,0 +1,29 @@ +/* + * firmware-update-system-ui + * + * 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_RO_COMMON_H__ +#define __FOTA_GR_DIRECT_RO_COMMON_H__ + +#include "fota_gui_general.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 int fota_gr_direct_ro_update_progress(void); + +#endif /* __FOTA_GR_DIRECT_RO_COMMON_H__ */ diff --git a/fota_gui_common/fota_gr_ro_common.c b/fota_gui_common/fota_gr_ro_common.c new file mode 100644 index 0000000..b15a6ab --- /dev/null +++ b/fota_gui_common/fota_gr_ro_common.c @@ -0,0 +1,55 @@ +/* + * firmware-update-system-ui + * + * 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_ro_common.h" +#include "fota_gr_direct_ro_common.h" + +/*----------------------------------------------------------------------------- + fota_gr_init + ----------------------------------------------------------------------------*/ +int fota_gr_init(void) +{ + return fota_gr_direct_init(); +} + +/*----------------------------------------------------------------------------- + fota_gr_deinit + ----------------------------------------------------------------------------*/ +void fota_gr_deinit(void) +{ + fota_gr_direct_deinit(); +} + +/*----------------------------------------------------------------------------- + fota_gr_clear_screen + ----------------------------------------------------------------------------*/ +void fota_gr_clear_screen(u32 color) +{ + fota_gr_direct_clear_screen(color); +} + +/*----------------------------------------------------------------------------- + fota_gr_update_progress + ----------------------------------------------------------------------------*/ +int fota_gr_update_progress(void) +{ + int percent = 0; + percent = fota_gr_direct_ro_update_progress(); + return percent; +} + diff --git a/fota_gui_common/fota_gr_ro_common.h b/fota_gui_common/fota_gr_ro_common.h new file mode 100644 index 0000000..9383c53 --- /dev/null +++ b/fota_gui_common/fota_gr_ro_common.h @@ -0,0 +1,28 @@ +/* + * firmware-update-system-ui + * + * 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_RO_COMMON_H__ +#define __FOTA_GR_RO_COMMON_H__ + +extern int fota_gr_init(void); +extern void fota_gr_deinit(void); +extern int fota_gr_update_progress(void); +extern void fota_gr_clear_screen(unsigned int color); + +#endif /* __FOTA_GR_RO_COMMON_H__ */ + diff --git a/fota_gui_common/fota_gui_general.h b/fota_gui_common/fota_gui_general.h new file mode 100644 index 0000000..aa84309 --- /dev/null +++ b/fota_gui_common/fota_gui_general.h @@ -0,0 +1,43 @@ +/* + * firmware-update-system-ui + * + * 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_GENERAL_H__ +#define __FOTA_GUI_GENERAL_H__ + + +#include +#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_GENERAL_H__ */ diff --git a/fota_gui_common/fota_gui_log.h b/fota_gui_common/fota_gui_log.h new file mode 100644 index 0000000..e8d9420 --- /dev/null +++ b/fota_gui_common/fota_gui_log.h @@ -0,0 +1,74 @@ +/* + * firmware-update-system-ui + * + * 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 + +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_RO" + +#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__ */ + diff --git a/fota_gui_common/fota_gui_ro_common_main.c b/fota_gui_common/fota_gui_ro_common_main.c new file mode 100644 index 0000000..4d9a1b5 --- /dev/null +++ b/fota_gui_common/fota_gui_ro_common_main.c @@ -0,0 +1,115 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fota_gui_general.h" +#include "fota_gui_util.h" +#include "fota_gr_ro_common.h" + +//#define WAIT +//#undef WAIT + +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; + +int s_pid = -1; + +static int wait_ani_main_solis(void) +{ + 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 (s_prog_percent < 100) { + usleep(delay); + s_prog_percent = fota_gr_update_progress(); + sleep(1); + } + LOG("MAIN :: 100 percent out = %d\n", s_prog_percent); + + fota_gr_deinit(); + + return 0; +} + +int main(int argc, char **argv) +{ +#ifdef WAIT + 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} + }; + + opt = getopt_long(argc, argv, "", options, &index); + if (opt == -1) { + LOGE("getopt_long failed\n"); + return 0; + } + + switch (index) { + case 0: { + int ret = wait_ani_main_solis(); + return ret; + } + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + default: + break; + } +#else + int ret = 0; + ret = wait_ani_main_solis(); +#endif + _exit_stdio(); + return 0; +} diff --git a/fota_gui_common/fota_gui_util.c b/fota_gui_common/fota_gui_util.c new file mode 100644 index 0000000..5d7d480 --- /dev/null +++ b/fota_gui_common/fota_gui_util.c @@ -0,0 +1,81 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} + diff --git a/fota_gui_common/fota_gui_util.h b/fota_gui_common/fota_gui_util.h new file mode 100644 index 0000000..235a9e0 --- /dev/null +++ b/fota_gui_common/fota_gui_util.h @@ -0,0 +1,26 @@ +/* + * firmware-update-system-ui + * + * 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_ */ + diff --git a/fota_gui_common/fota_png.c b/fota_gui_common/fota_png.c new file mode 100644 index 0000000..88f6e86 --- /dev/null +++ b/fota_gui_common/fota_png.c @@ -0,0 +1,455 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include "fota_gui_general.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); +} diff --git a/fota_gui_common/fota_png.h b/fota_gui_common/fota_png.h new file mode 100644 index 0000000..4a8ce34 --- /dev/null +++ b/fota_gui_common/fota_png.h @@ -0,0 +1,31 @@ +/* + * firmware-update-system-ui + * + * 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__ */ diff --git a/fota_gui_common/tdm-if.c b/fota_gui_common/tdm-if.c new file mode 100644 index 0000000..4d15710 --- /dev/null +++ b/fota_gui_common/tdm-if.c @@ -0,0 +1,319 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fota_gui_general.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 + || output_type == TDM_OUTPUT_TYPE_HDMIA) + && (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 ; +} diff --git a/fota_gui_common/tdm-if.h b/fota_gui_common/tdm-if.h new file mode 100644 index 0000000..dc67910 --- /dev/null +++ b/fota_gui_common/tdm-if.h @@ -0,0 +1,74 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include + +#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__ */ diff --git a/fota_gui_wearable/CMakeLists.txt b/fota_gui_wearable/CMakeLists.txt new file mode 100644 index 0000000..e258784 --- /dev/null +++ b/fota_gui_wearable/CMakeLists.txt @@ -0,0 +1,64 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(fota-gui-wearable C) + +#set( CMAKE_VERBOSE_MAKEFILE on ) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(BINDIR "${PREFIX}/bin") +#SET(FOTA_GUI "fota_gui") +SET(FOTA_GUI_WEARABLE "fota_gui_wearable") +SET(PKGDIR "${PREFIX}/share/fota") +SET(RESDIR "${PKGDIR}/res") +SET(RESDIR_WEARABLE "${RESDIR}/images_wearable") + +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_ro_wearable_main.c + fota_gr_ro_wearable.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_WEARABLE ${GUI_SRCS} fota_gr_direct_ro_wearable.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_WEARABLE} ${GUI_SRCS_WEARABLE}) +TARGET_LINK_LIBRARIES(${FOTA_GUI_WEARABLE} ${gui_pkgs_LDFLAGS} ${LIBS} -lpthread) + +ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"") +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/wearable/ro_update/images DESTINATION ${RESDIR_WEARABLE}) + +INSTALL(TARGETS ${FOTA_GUI_WEARABLE} DESTINATION ${BINDIR}) diff --git a/fota_gui_wearable/fota_fbinfo.h b/fota_gui_wearable/fota_fbinfo.h new file mode 100644 index 0000000..6b73ed8 --- /dev/null +++ b/fota_gui_wearable/fota_fbinfo.h @@ -0,0 +1,33 @@ +/* + * firmware-update-system-ui + * + * 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__ */ + diff --git a/fota_gui_wearable/fota_gr_direct_ro_wearable.c b/fota_gui_wearable/fota_gr_direct_ro_wearable.c new file mode 100644 index 0000000..6faab3b --- /dev/null +++ b/fota_gui_wearable/fota_gr_direct_ro_wearable.c @@ -0,0 +1,489 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include + +#include "fota_gui_general.h" +#include "fota_png.h" +#include "fota_fbinfo.h" +#include "tdm-if.h" + +#define UNUSED(x) (void)(x) + +#define COLOR_BLACK 0xFF000000 + +#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(); + + s_saved_percent = progress; + +} + +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) +{ + 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_saved_percent); + } else if (s_percent_to_draw == 0) { + s_saved_percent = 0; + } + _gr_direct_update_screen(); +} + +/*----------------------------------------------------------------------------- + fota_gr_direct_update_progress + ----------------------------------------------------------------------------*/ +int fota_gr_direct_ro_update_progress(void) +{ + int percent = s_percent_to_draw; + + FILE *fp; + + if (access("/tmp/upgrade/ro_progress", R_OK) == 0) { + fp = fopen("/tmp/upgrade/ro_progress", "r"); + if (fp) { + if (fscanf(fp, "%d", &percent) == EOF) + LOG("Error occurs at reading ro_progress"); + if (percent < 0) + percent = 0; + if (percent > 0xffffff) + percent = 0xffffff; + fclose(fp); + } else + percent = s_percent_to_draw; + } + + s_percent_to_draw = percent; + if (s_saved_percent < s_percent_to_draw) { + LOG("s_saved_percent %d , s_percent_to_draw %d \n", s_saved_percent, s_percent_to_draw); + fota_gr_direct_circular_progress(); + } + return s_saved_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); +} + diff --git a/fota_gui_wearable/fota_gr_direct_ro_wearable.h b/fota_gui_wearable/fota_gr_direct_ro_wearable.h new file mode 100644 index 0000000..ffb7b7b --- /dev/null +++ b/fota_gui_wearable/fota_gr_direct_ro_wearable.h @@ -0,0 +1,29 @@ +/* + * firmware-update-system-ui + * + * 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_RO_WEARABLE_H__ +#define __FOTA_GR_DIRECT_RO_WEARABLE_H__ + +#include "fota_gui_general.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 int fota_gr_direct_ro_update_progress(void); + +#endif /* __FOTA_GR_DIRECT_RO_WEARABLE_H__ */ diff --git a/fota_gui_wearable/fota_gr_ro_wearable.c b/fota_gui_wearable/fota_gr_ro_wearable.c new file mode 100644 index 0000000..c83c563 --- /dev/null +++ b/fota_gui_wearable/fota_gr_ro_wearable.c @@ -0,0 +1,55 @@ +/* + * firmware-update-system-ui + * + * 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_ro_wearable.h" +#include "fota_gr_direct_ro_wearable.h" + +/*----------------------------------------------------------------------------- + fota_gr_init + ----------------------------------------------------------------------------*/ +int fota_gr_init(void) +{ + return fota_gr_direct_init(); +} + +/*----------------------------------------------------------------------------- + fota_gr_deinit + ----------------------------------------------------------------------------*/ +void fota_gr_deinit(void) +{ + fota_gr_direct_deinit(); +} + +/*----------------------------------------------------------------------------- + fota_gr_clear_screen + ----------------------------------------------------------------------------*/ +void fota_gr_clear_screen(u32 color) +{ + fota_gr_direct_clear_screen(color); +} + +/*----------------------------------------------------------------------------- + fota_gr_update_progress + ----------------------------------------------------------------------------*/ +int fota_gr_update_progress(void) +{ + int percent = 0; + percent = fota_gr_direct_ro_update_progress(); + return percent; +} + diff --git a/fota_gui_wearable/fota_gr_ro_wearable.h b/fota_gui_wearable/fota_gr_ro_wearable.h new file mode 100644 index 0000000..9bd169a --- /dev/null +++ b/fota_gui_wearable/fota_gr_ro_wearable.h @@ -0,0 +1,28 @@ +/* + * firmware-update-system-ui + * + * 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_RO_WEARABLE_H__ +#define __FOTA_GR_RO_WEARABLE_H__ + +extern int fota_gr_init(void); +extern void fota_gr_deinit(void); +extern int fota_gr_update_progress(void); +extern void fota_gr_clear_screen(unsigned int color); + +#endif /* __FOTA_GR_RO_WEARABLE_H__ */ + diff --git a/fota_gui_wearable/fota_gui_general.h b/fota_gui_wearable/fota_gui_general.h new file mode 100644 index 0000000..aa84309 --- /dev/null +++ b/fota_gui_wearable/fota_gui_general.h @@ -0,0 +1,43 @@ +/* + * firmware-update-system-ui + * + * 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_GENERAL_H__ +#define __FOTA_GUI_GENERAL_H__ + + +#include +#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_GENERAL_H__ */ diff --git a/fota_gui_wearable/fota_gui_log.h b/fota_gui_wearable/fota_gui_log.h new file mode 100644 index 0000000..e8d9420 --- /dev/null +++ b/fota_gui_wearable/fota_gui_log.h @@ -0,0 +1,74 @@ +/* + * firmware-update-system-ui + * + * 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 + +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_RO" + +#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__ */ + diff --git a/fota_gui_wearable/fota_gui_ro_wearable_main.c b/fota_gui_wearable/fota_gui_ro_wearable_main.c new file mode 100644 index 0000000..2d621e4 --- /dev/null +++ b/fota_gui_wearable/fota_gui_ro_wearable_main.c @@ -0,0 +1,115 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fota_gui_general.h" +#include "fota_gui_util.h" +#include "fota_gr_ro_wearable.h" + +//#define WAIT +//#undef WAIT + +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; + +int s_pid = -1; + +static int wait_ani_main_solis(void) +{ + 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 (s_prog_percent < 100) { + usleep(delay); + s_prog_percent = fota_gr_update_progress(); + sleep(1); + } + LOG("MAIN :: 100 percent out = %d\n", s_prog_percent); + + fota_gr_deinit(); + + return 0; +} + +int main(int argc, char **argv) +{ +#ifdef WAIT + 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} + }; + + opt = getopt_long(argc, argv, "", options, &index); + if (opt == -1) { + LOGE("getopt_long failed\n"); + return 0; + } + + switch (index) { + case 0: { + int ret = wait_ani_main_solis(); + return ret; + } + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + default: + break; + } +#else + int ret = 0; + ret = wait_ani_main_solis(); +#endif + _exit_stdio(); + return 0; +} diff --git a/fota_gui_wearable/fota_gui_util.c b/fota_gui_wearable/fota_gui_util.c new file mode 100644 index 0000000..5d7d480 --- /dev/null +++ b/fota_gui_wearable/fota_gui_util.c @@ -0,0 +1,81 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} + diff --git a/fota_gui_wearable/fota_gui_util.h b/fota_gui_wearable/fota_gui_util.h new file mode 100644 index 0000000..235a9e0 --- /dev/null +++ b/fota_gui_wearable/fota_gui_util.h @@ -0,0 +1,26 @@ +/* + * firmware-update-system-ui + * + * 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_ */ + diff --git a/fota_gui_wearable/fota_png.c b/fota_gui_wearable/fota_png.c new file mode 100644 index 0000000..88f6e86 --- /dev/null +++ b/fota_gui_wearable/fota_png.c @@ -0,0 +1,455 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include "fota_gui_general.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); +} diff --git a/fota_gui_wearable/fota_png.h b/fota_gui_wearable/fota_png.h new file mode 100644 index 0000000..4a8ce34 --- /dev/null +++ b/fota_gui_wearable/fota_png.h @@ -0,0 +1,31 @@ +/* + * firmware-update-system-ui + * + * 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__ */ diff --git a/fota_gui_wearable/tdm-if.c b/fota_gui_wearable/tdm-if.c new file mode 100644 index 0000000..4d15710 --- /dev/null +++ b/fota_gui_wearable/tdm-if.c @@ -0,0 +1,319 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fota_gui_general.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 + || output_type == TDM_OUTPUT_TYPE_HDMIA) + && (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 ; +} diff --git a/fota_gui_wearable/tdm-if.h b/fota_gui_wearable/tdm-if.h new file mode 100644 index 0000000..dc67910 --- /dev/null +++ b/fota_gui_wearable/tdm-if.h @@ -0,0 +1,74 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include + +#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__ */ diff --git a/packaging/firmware-update-system-ui.manifest b/packaging/firmware-update-system-ui.manifest new file mode 100644 index 0000000..1b29af6 --- /dev/null +++ b/packaging/firmware-update-system-ui.manifest @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/packaging/firmware-update-system-ui.spec b/packaging/firmware-update-system-ui.spec index 5ad8181..28a709d 100644 --- a/packaging/firmware-update-system-ui.spec +++ b/packaging/firmware-update-system-ui.spec @@ -1,25 +1,44 @@ Name: firmware-update-system-ui -Summary: Firmware update system GUI application +Summary: firmware-update-system-ui ExclusiveArch: %{arm} -Version: 1.0.0 +Version: 1.2.7 Release: 0 Group: System License: Apache-2.0 Source0: %{name}-%{version}.tar.gz +Source1001: %{name}.manifest BuildRequires: cmake BuildRequires: pkgconfig(libtbm) BuildRequires: pkgconfig(libtdm) BuildRequires: pkgconfig(libpng) -BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(cairo) %description -Firmware update system GUI application +Fota update app + + +##### pkg-wearable +%package wearable +Summary: TOTA update GUI for wearable targets +Requires: %{name} = %{version}-%{release} +Conflicts: %{name}-common +%description wearable +TOTA update GUI for wearable targets + + +%package common +Summary: TOTA update GUI for common targets +Requires: %{name} = %{version}-%{release} +Conflicts: %{name}-wearable +%description common +TOTA update GUI for common targets, ex. rpi3 + %prep %setup -q +cp %{SOURCE1001} . %build export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed" @@ -32,20 +51,61 @@ 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/ +cp 42-tota-gui-wearable.list %{buildroot}%{_datadir}/initrd-recovery/initrd.list.d/ +cp 42-tota-gui-common.list %{buildroot}%{_datadir}/initrd-recovery/initrd.list.d/ + +%post wearable +mv %{_bindir}/fota_gui_wearable %{_bindir}/fota_gui +mv %{_bindir}/rw-update-ani-wearable %{_bindir}/rw-update-ani +mv %{_datadir}/fota/res/images_wearable/images %{_datadir}/fota/res/images +mv %{_prefix}/share/rw-updater/res/images_wearable/images %{_prefix}/share/rw-updater/res/images +mv %{_datadir}/initrd-recovery/initrd.list.d/42-tota-gui-wearable.list %{_datadir}/initrd-recovery/initrd.list.d/42-tota-gui.list + +%post common +mv %{_bindir}/fota_gui_common %{_bindir}/fota_gui +mv %{_bindir}/rw-update-ani-common %{_bindir}/rw-update-ani +mkdir -p %{_datadir}/res +mv %{_datadir}/fota/res/images_common/images %{_datadir}/res/images +mv %{_datadir}/initrd-recovery/initrd.list.d/42-tota-gui-common.list %{_datadir}/initrd-recovery/initrd.list.d/42-tota-gui.list + +mv %{_bindir}/recovery_gui_common %{_bindir}/recovery_gui -%post +%preun wearable +mv %{_bindir}/fota_gui %{_bindir}/fota_gui_wearable +mv %{_bindir}/rw-update-ani %{_bindir}/rw-update-ani-wearable +mv %{_datadir}/fota/res/images %{_datadir}/fota/res/images_wearable +mv %{_prefix}/share/rw-updater/res/images %{_prefix}/share/rw-updater/res/images_wearable +mv %{_datadir}/initrd-recovery/initrd.list.d/42-tota-gui.list %{_datadir}/initrd-recovery/initrd.list.d/42-tota-gui-wearable.list + +%preun common +mv %{_bindir}/fota_gui %{_bindir}/fota_gui_common +mv %{_bindir}/rw-update-ani %{_bindir}/rw-update-ani-common +mv %{_datadir}/res/images %{_datadir}/fota/res/images_common +mv %{_datadir}/initrd-recovery/initrd.list.d/42-tota-gui.list %{_datadir}/initrd-recovery/initrd.list.d/42-tota-gui-common.list + +mv %{_bindir}/recovery_gui %{_bindir}/recovery_gui_common %files -%license LICENSE +%license LICENSE.APLv2 %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/* +%files wearable +%license LICENSE.APLv2 +%manifest firmware-update-system-ui.manifest +%defattr(-,root,root,-) +%attr(700,-,-) %{_datadir}/initrd-recovery/initrd.list.d/42-tota-gui-wearable.list +%{_datadir}/fota/res/images_wearable +%{_bindir}/fota_gui_wearable +%attr(550,system,system_share) %{_bindir}/rw-update-ani-wearable +%{_prefix}/share/rw-updater/res/images_wearable +%files common +%license LICENSE.APLv2 +%manifest firmware-update-system-ui.manifest +%defattr(-,root,root,-) +%attr(700,-,-) %{_datadir}/initrd-recovery/initrd.list.d/42-tota-gui-common.list +%{_datadir}/fota/res/images_common +%{_bindir}/fota_gui_common +%attr(550,system,system_share) %{_bindir}/rw-update-ani-common +%{_bindir}/recovery_gui_common diff --git a/recovery_gui_common/.CMakeLists.txt.swp b/recovery_gui_common/.CMakeLists.txt.swp new file mode 100644 index 0000000..f924d34 Binary files /dev/null and b/recovery_gui_common/.CMakeLists.txt.swp differ diff --git a/recovery_gui_common/CMakeLists.txt b/recovery_gui_common/CMakeLists.txt new file mode 100644 index 0000000..a88d3dc --- /dev/null +++ b/recovery_gui_common/CMakeLists.txt @@ -0,0 +1,62 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(recovery-gui-common C) + +#set( CMAKE_VERBOSE_MAKEFILE on ) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(BINDIR "${PREFIX}/bin") +SET(RECOVERY_GUI_COMMON "recovery_gui_common") +SET(PKGDIR "${PREFIX}/share") +SET(RESDIR "${PKGDIR}/res") +SET(RESDIR_COMMON "${PKGDIR}/recovery/res/images_common") + +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 + recovery_gui_common_main.c + recovery_gr_common.c + recovery_png.c + recovery_gui_util.c + tdm-if.c +) + +FOREACH(flag ${gui_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(GUI_SRCS_COMMON ${GUI_SRCS} recovery_gr_direct_common.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(${RECOVERY_GUI_COMMON} ${GUI_SRCS_COMMON}) +TARGET_LINK_LIBRARIES(${RECOVERY_GUI_COMMON} ${gui_pkgs_LDFLAGS} ${LIBS} -lpthread) + +ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"") +#INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/images DESTINATION ${RESDIR_COMMON}) + +INSTALL(TARGETS ${RECOVERY_GUI_COMMON} DESTINATION ${BINDIR}) diff --git a/recovery_gui_common/recovery_fbinfo.h b/recovery_gui_common/recovery_fbinfo.h new file mode 100644 index 0000000..9609898 --- /dev/null +++ b/recovery_gui_common/recovery_fbinfo.h @@ -0,0 +1,33 @@ +/* + * firmware-update-system-ui + * + * 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 __RECOVERY_FBINFO_H__ +#define __RECOVERY_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 /* __RECOVERY_FBINFO_H__ */ + diff --git a/recovery_gui_common/recovery_gr_common.c b/recovery_gui_common/recovery_gr_common.c new file mode 100644 index 0000000..acd5243 --- /dev/null +++ b/recovery_gui_common/recovery_gr_common.c @@ -0,0 +1,55 @@ +/* + * firmware-update-system-ui + * + * 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 "recovery_gr_common.h" +#include "recovery_gr_direct_common.h" + +/*----------------------------------------------------------------------------- + recovery_gr_init + ----------------------------------------------------------------------------*/ +int recovery_gr_init(void) +{ + return recovery_gr_direct_init(); +} + +/*----------------------------------------------------------------------------- + recovery_gr_deinit + ----------------------------------------------------------------------------*/ +void recovery_gr_deinit(void) +{ + recovery_gr_direct_deinit(); +} + +/*----------------------------------------------------------------------------- + recovery_gr_clear_screen + ----------------------------------------------------------------------------*/ +void recovery_gr_clear_screen(u32 color) +{ + recovery_gr_direct_clear_screen(color); +} + +/*----------------------------------------------------------------------------- + recovery_gr_update_progress + ----------------------------------------------------------------------------*/ +int recovery_gr_update_progress(void) +{ + int percent = 0; + percent = recovery_gr_direct_update_progress(); + return percent; +} + diff --git a/recovery_gui_common/recovery_gr_common.h b/recovery_gui_common/recovery_gr_common.h new file mode 100644 index 0000000..f3122fb --- /dev/null +++ b/recovery_gui_common/recovery_gr_common.h @@ -0,0 +1,28 @@ +/* + * firmware-update-system-ui + * + * 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 __RECOVERY_GR_COMMON_H__ +#define __RECOVERY_GR_COMMON_H__ + +extern int recovery_gr_init(void); +extern void recovery_gr_deinit(void); +extern int recovery_gr_update_progress(void); +extern void recovery_gr_clear_screen(unsigned int color); + +#endif /* __RECOVERY_GR_COMMON_H__ */ + diff --git a/recovery_gui_common/recovery_gr_direct_common.c b/recovery_gui_common/recovery_gr_direct_common.c new file mode 100644 index 0000000..b7e9d71 --- /dev/null +++ b/recovery_gui_common/recovery_gr_direct_common.c @@ -0,0 +1,483 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include + +#include "recovery_gui_general.h" +#include "recovery_png.h" +#include "recovery_fbinfo.h" +#include "tdm-if.h" + +#define UNUSED(x) (void)(x) + +#define COLOR_BLACK 0xFF000000 + +#define MAX_PATH 256 +#define MAX_FILE_PATH 512 + +#if !defined(RESDIR) +#define RESDIR "/usr/share/res" +#endif +#define IMG_BASE RESDIR "/images/" + +#define MAIN_IMG_NAME "common_base_rect_bg.png" +#define MAIN_TEXT_NAME "common_recovery_bg_text.png" +#define MAIN_PG_IMG_NAME "common_progress_bar.png" +#define PROGRESS_BAR_IMG_PREFIX "common_progress_" +#define PROGRESS_NUM_PREFIX "common_downloading_" +#define PERCENT_IMG_NAME "common_downloading_percent.png" + +/***************************************************************************** +** global variables +*****************************************************************************/ +const int x_offset_main_bg_text_pos = 518; +const int y_offset_main_bg_text_pos = 300; +const int x_offset_prog_bar_img_pos = 240; +const int y_offset_prog_bar_img_pos = 355; + +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 = 588; + img_y = 395; + + if (percent < 10) + img_x += 7; + else if (percent < 100) + img_x += 14; + else if (percent == 100) + img_x += 21; + + 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 += 14; + 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 += 14; + 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 += 13; + + 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, 610, 395, 65, 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 = x_offset_prog_bar_img_pos; + img_y = y_offset_prog_bar_img_pos; + + 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(); + + if (read_png_file(IMG_BASE MAIN_TEXT_NAME) < 0) + return; + + img_x = x_offset_main_bg_text_pos; + img_y = y_offset_main_bg_text_pos; + + 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_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, 240, 355); + 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); +} + +/*----------------------------------------------------------------------------- + recovery_gr_direct_update_progress + ----------------------------------------------------------------------------*/ +void recovery_gr_direct_progress(void) +{ + LOG("recovery_gr_direct_progress progress : %d \n", s_percent_to_draw); + + if (s_percent_to_draw > 0) { + _gr_direct_progress_bar(&s_fbi, s_percent_to_draw); + _gr_direct_draw_prog_text(&s_fbi, s_saved_percent); + } else if (s_percent_to_draw == 0) { + s_saved_percent = 0; + } + _gr_direct_update_screen(); +} + +/*----------------------------------------------------------------------------- + recovery_gr_direct_update_progress + ----------------------------------------------------------------------------*/ +int recovery_gr_direct_update_progress(void) +{ + int percent = s_percent_to_draw; + + FILE *fp; + + if (access("/tmp/recovery_progress", R_OK) == 0) { + fp = fopen("/tmp/recovery_progress", "r"); + if (fp) { + if (fscanf(fp, "%d", &percent) == EOF) + LOG("Error occurs at reading progress"); + if (percent < 0) + percent = 0; + if (percent > 0xffffff) + percent = 0xffffff; + fclose(fp); + } else + percent = s_percent_to_draw; + } + + s_percent_to_draw = percent; + if (s_saved_percent < s_percent_to_draw) { + LOG("s_saved_percent %d , s_percent_to_draw %d \n", s_saved_percent, s_percent_to_draw); + recovery_gr_direct_progress(); + } + return s_saved_percent; +} + +/*----------------------------------------------------------------------------- + recovery_gr_direct_clear_screen + ----------------------------------------------------------------------------*/ +void recovery_gr_direct_clear_screen(u32 color) +{ + _gr_direct_clear_screen(&s_fbi, color); + _gr_direct_update_screen(); +} + +/*----------------------------------------------------------------------------- + recovery_gr_direct_init + ----------------------------------------------------------------------------*/ +int recovery_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; +} + +/*----------------------------------------------------------------------------- + recovery_gr_direct_deinit + ----------------------------------------------------------------------------*/ +void recovery_gr_direct_deinit(void) +{ + fb_close(&s_fbi); +} + diff --git a/recovery_gui_common/recovery_gr_direct_common.h b/recovery_gui_common/recovery_gr_direct_common.h new file mode 100644 index 0000000..e861dd8 --- /dev/null +++ b/recovery_gui_common/recovery_gr_direct_common.h @@ -0,0 +1,29 @@ +/* + * firmware-update-system-ui + * + * 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 __RECOVERY_GR_DIRECT_COMMON_H__ +#define __RECOVERY_GR_DIRECT_COMMON_H__ + +#include "recovery_gui_general.h" + +extern int recovery_gr_direct_init(void); +extern void recovery_gr_direct_deinit(void); +extern void recovery_gr_direct_clear_screen(u32 color); +extern int recovery_gr_direct_update_progress(void); + +#endif /* __RECOVERY_GR_DIRECT_COMMON_H__ */ diff --git a/recovery_gui_common/recovery_gui_common_main.c b/recovery_gui_common/recovery_gui_common_main.c new file mode 100644 index 0000000..6a63c96 --- /dev/null +++ b/recovery_gui_common/recovery_gui_common_main.c @@ -0,0 +1,115 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "recovery_gui_general.h" +#include "recovery_gui_util.h" +#include "recovery_gr_common.h" + +//#define WAIT +//#undef WAIT + +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; + +int s_pid = -1; + +static int wait_ani_main_solis(void) +{ + int delay = 20000; + + if (setpriority(PRIO_PROCESS, getpid(), -11) < 0) + LOG("failed to setpriority\n"); + + if (recovery_gr_init() < 0) { + LOG("recovery_gr_init() failed.\n"); + _exit_stdio(); + return -1; + } + + while (s_prog_percent < 100) { + usleep(delay); + s_prog_percent = recovery_gr_update_progress(); + sleep(1); + } + LOG("MAIN :: 100 percent out = %d\n", s_prog_percent); + + recovery_gr_deinit(); + + return 0; +} + +int main(int argc, char **argv) +{ +#ifdef WAIT + 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} + }; + + opt = getopt_long(argc, argv, "", options, &index); + if (opt == -1) { + LOGE("getopt_long failed\n"); + return 0; + } + + switch (index) { + case 0: { + int ret = wait_ani_main_solis(); + return ret; + } + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + default: + break; + } +#else + int ret = 0; + ret = wait_ani_main_solis(); +#endif + _exit_stdio(); + return 0; +} diff --git a/recovery_gui_common/recovery_gui_general.h b/recovery_gui_common/recovery_gui_general.h new file mode 100644 index 0000000..2dfb74d --- /dev/null +++ b/recovery_gui_common/recovery_gui_general.h @@ -0,0 +1,43 @@ +/* + * firmware-update-system-ui + * + * 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 __RECOVERY_GUI_GENERAL_H__ +#define __RECOVERY_GUI_GENERAL_H__ + + +#include +#include "recovery_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 /* __RECOVERY_GUI_GENERAL_H__ */ diff --git a/recovery_gui_common/recovery_gui_log.h b/recovery_gui_common/recovery_gui_log.h new file mode 100644 index 0000000..fe2d43e --- /dev/null +++ b/recovery_gui_common/recovery_gui_log.h @@ -0,0 +1,74 @@ +/* + * firmware-update-system-ui + * + * 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 __RECOVERY_GUI_LOG_H__ +#define __RECOVERY_GUI_LOG_H__ + +#include + +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 "RECOVERY_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 /* __RECOVERY_GUI_LOG_H__ */ + diff --git a/recovery_gui_common/recovery_gui_util.c b/recovery_gui_common/recovery_gui_util.c new file mode 100644 index 0000000..7a26510 --- /dev/null +++ b/recovery_gui_common/recovery_gui_util.c @@ -0,0 +1,81 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include "recovery_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); +} + diff --git a/recovery_gui_common/recovery_gui_util.h b/recovery_gui_common/recovery_gui_util.h new file mode 100644 index 0000000..938ff9b --- /dev/null +++ b/recovery_gui_common/recovery_gui_util.h @@ -0,0 +1,26 @@ +/* + * firmware-update-system-ui + * + * 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 _RECOVERY_GUI_UTIL_H_ +#define _RECOVERY_GUI_UTIL_H_ + +extern void _init_stdio(void); +extern void _exit_stdio(void); + +#endif /* _RECOVERY_GUI_UTIL_H_ */ + diff --git a/recovery_gui_common/recovery_png.c b/recovery_gui_common/recovery_png.c new file mode 100644 index 0000000..21f7083 --- /dev/null +++ b/recovery_gui_common/recovery_png.c @@ -0,0 +1,455 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include "recovery_gui_general.h" +#include "recovery_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); +} diff --git a/recovery_gui_common/recovery_png.h b/recovery_gui_common/recovery_png.h new file mode 100644 index 0000000..c8b9e00 --- /dev/null +++ b/recovery_gui_common/recovery_png.h @@ -0,0 +1,31 @@ +/* + * firmware-update-system-ui + * + * 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 __RECOVERY_PNG_H__ +#define __RECOVERY_PNG_H__ + +#include "recovery_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 /* __RECOVERY_PNG_H__ */ diff --git a/recovery_gui_common/tdm-if.c b/recovery_gui_common/tdm-if.c new file mode 100644 index 0000000..7e7a3c4 --- /dev/null +++ b/recovery_gui_common/tdm-if.c @@ -0,0 +1,319 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "recovery_gui_general.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 + || output_type == TDM_OUTPUT_TYPE_HDMIA) + && (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 ; +} diff --git a/recovery_gui_common/tdm-if.h b/recovery_gui_common/tdm-if.h new file mode 100644 index 0000000..dc67910 --- /dev/null +++ b/recovery_gui_common/tdm-if.h @@ -0,0 +1,74 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include + +#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__ */ diff --git a/res/common/images/common_base_rect_bg.png b/res/common/images/common_base_rect_bg.png new file mode 100755 index 0000000..27b6c1e Binary files /dev/null and b/res/common/images/common_base_rect_bg.png differ diff --git a/res/common/images/common_downloading_0.png b/res/common/images/common_downloading_0.png new file mode 100755 index 0000000..04b3219 Binary files /dev/null and b/res/common/images/common_downloading_0.png differ diff --git a/res/common/images/common_downloading_1.png b/res/common/images/common_downloading_1.png new file mode 100755 index 0000000..bd9910d Binary files /dev/null and b/res/common/images/common_downloading_1.png differ diff --git a/res/common/images/common_downloading_2.png b/res/common/images/common_downloading_2.png new file mode 100755 index 0000000..27d798a Binary files /dev/null and b/res/common/images/common_downloading_2.png differ diff --git a/res/common/images/common_downloading_3.png b/res/common/images/common_downloading_3.png new file mode 100755 index 0000000..7e20156 Binary files /dev/null and b/res/common/images/common_downloading_3.png differ diff --git a/res/common/images/common_downloading_4.png b/res/common/images/common_downloading_4.png new file mode 100755 index 0000000..2273b98 Binary files /dev/null and b/res/common/images/common_downloading_4.png differ diff --git a/res/common/images/common_downloading_5.png b/res/common/images/common_downloading_5.png new file mode 100755 index 0000000..737e8bc Binary files /dev/null and b/res/common/images/common_downloading_5.png differ diff --git a/res/common/images/common_downloading_6.png b/res/common/images/common_downloading_6.png new file mode 100755 index 0000000..07ad086 Binary files /dev/null and b/res/common/images/common_downloading_6.png differ diff --git a/res/common/images/common_downloading_7.png b/res/common/images/common_downloading_7.png new file mode 100755 index 0000000..909cb55 Binary files /dev/null and b/res/common/images/common_downloading_7.png differ diff --git a/res/common/images/common_downloading_8.png b/res/common/images/common_downloading_8.png new file mode 100755 index 0000000..590002e Binary files /dev/null and b/res/common/images/common_downloading_8.png differ diff --git a/res/common/images/common_downloading_9.png b/res/common/images/common_downloading_9.png new file mode 100755 index 0000000..5b80ed7 Binary files /dev/null and b/res/common/images/common_downloading_9.png differ diff --git a/res/common/images/common_downloading_percent.png b/res/common/images/common_downloading_percent.png new file mode 100755 index 0000000..7e5c016 Binary files /dev/null and b/res/common/images/common_downloading_percent.png differ diff --git a/res/common/images/common_progress_000.png b/res/common/images/common_progress_000.png new file mode 100755 index 0000000..0b867ad Binary files /dev/null and b/res/common/images/common_progress_000.png differ diff --git a/res/common/images/common_progress_001.png b/res/common/images/common_progress_001.png new file mode 100755 index 0000000..c305186 Binary files /dev/null and b/res/common/images/common_progress_001.png differ diff --git a/res/common/images/common_progress_002.png b/res/common/images/common_progress_002.png new file mode 100755 index 0000000..398bf92 Binary files /dev/null and b/res/common/images/common_progress_002.png differ diff --git a/res/common/images/common_progress_003.png b/res/common/images/common_progress_003.png new file mode 100755 index 0000000..fbec0f3 Binary files /dev/null and b/res/common/images/common_progress_003.png differ diff --git a/res/common/images/common_progress_004.png b/res/common/images/common_progress_004.png new file mode 100755 index 0000000..3485cdc Binary files /dev/null and b/res/common/images/common_progress_004.png differ diff --git a/res/common/images/common_progress_005.png b/res/common/images/common_progress_005.png new file mode 100755 index 0000000..0741be3 Binary files /dev/null and b/res/common/images/common_progress_005.png differ diff --git a/res/common/images/common_progress_006.png b/res/common/images/common_progress_006.png new file mode 100755 index 0000000..2b4bd06 Binary files /dev/null and b/res/common/images/common_progress_006.png differ diff --git a/res/common/images/common_progress_007.png b/res/common/images/common_progress_007.png new file mode 100755 index 0000000..a932b27 Binary files /dev/null and b/res/common/images/common_progress_007.png differ diff --git a/res/common/images/common_progress_008.png b/res/common/images/common_progress_008.png new file mode 100755 index 0000000..7876bc2 Binary files /dev/null and b/res/common/images/common_progress_008.png differ diff --git a/res/common/images/common_progress_009.png b/res/common/images/common_progress_009.png new file mode 100755 index 0000000..47eb834 Binary files /dev/null and b/res/common/images/common_progress_009.png differ diff --git a/res/common/images/common_progress_010.png b/res/common/images/common_progress_010.png new file mode 100755 index 0000000..7d38d7d Binary files /dev/null and b/res/common/images/common_progress_010.png differ diff --git a/res/common/images/common_progress_011.png b/res/common/images/common_progress_011.png new file mode 100755 index 0000000..3c842a1 Binary files /dev/null and b/res/common/images/common_progress_011.png differ diff --git a/res/common/images/common_progress_012.png b/res/common/images/common_progress_012.png new file mode 100755 index 0000000..e22d550 Binary files /dev/null and b/res/common/images/common_progress_012.png differ diff --git a/res/common/images/common_progress_013.png b/res/common/images/common_progress_013.png new file mode 100755 index 0000000..2675ae6 Binary files /dev/null and b/res/common/images/common_progress_013.png differ diff --git a/res/common/images/common_progress_014.png b/res/common/images/common_progress_014.png new file mode 100755 index 0000000..441f8db Binary files /dev/null and b/res/common/images/common_progress_014.png differ diff --git a/res/common/images/common_progress_015.png b/res/common/images/common_progress_015.png new file mode 100755 index 0000000..f9f445f Binary files /dev/null and b/res/common/images/common_progress_015.png differ diff --git a/res/common/images/common_progress_016.png b/res/common/images/common_progress_016.png new file mode 100755 index 0000000..69be359 Binary files /dev/null and b/res/common/images/common_progress_016.png differ diff --git a/res/common/images/common_progress_017.png b/res/common/images/common_progress_017.png new file mode 100755 index 0000000..b5bdeb1 Binary files /dev/null and b/res/common/images/common_progress_017.png differ diff --git a/res/common/images/common_progress_018.png b/res/common/images/common_progress_018.png new file mode 100755 index 0000000..3074376 Binary files /dev/null and b/res/common/images/common_progress_018.png differ diff --git a/res/common/images/common_progress_019.png b/res/common/images/common_progress_019.png new file mode 100755 index 0000000..a88236e Binary files /dev/null and b/res/common/images/common_progress_019.png differ diff --git a/res/common/images/common_progress_020.png b/res/common/images/common_progress_020.png new file mode 100755 index 0000000..4bd6406 Binary files /dev/null and b/res/common/images/common_progress_020.png differ diff --git a/res/common/images/common_progress_021.png b/res/common/images/common_progress_021.png new file mode 100755 index 0000000..c97e02d Binary files /dev/null and b/res/common/images/common_progress_021.png differ diff --git a/res/common/images/common_progress_022.png b/res/common/images/common_progress_022.png new file mode 100755 index 0000000..c176890 Binary files /dev/null and b/res/common/images/common_progress_022.png differ diff --git a/res/common/images/common_progress_023.png b/res/common/images/common_progress_023.png new file mode 100755 index 0000000..44fdc87 Binary files /dev/null and b/res/common/images/common_progress_023.png differ diff --git a/res/common/images/common_progress_024.png b/res/common/images/common_progress_024.png new file mode 100755 index 0000000..e44d504 Binary files /dev/null and b/res/common/images/common_progress_024.png differ diff --git a/res/common/images/common_progress_025.png b/res/common/images/common_progress_025.png new file mode 100755 index 0000000..96bbe85 Binary files /dev/null and b/res/common/images/common_progress_025.png differ diff --git a/res/common/images/common_progress_026.png b/res/common/images/common_progress_026.png new file mode 100755 index 0000000..fff6998 Binary files /dev/null and b/res/common/images/common_progress_026.png differ diff --git a/res/common/images/common_progress_027.png b/res/common/images/common_progress_027.png new file mode 100755 index 0000000..c541492 Binary files /dev/null and b/res/common/images/common_progress_027.png differ diff --git a/res/common/images/common_progress_028.png b/res/common/images/common_progress_028.png new file mode 100755 index 0000000..901c805 Binary files /dev/null and b/res/common/images/common_progress_028.png differ diff --git a/res/common/images/common_progress_029.png b/res/common/images/common_progress_029.png new file mode 100755 index 0000000..946b60c Binary files /dev/null and b/res/common/images/common_progress_029.png differ diff --git a/res/common/images/common_progress_030.png b/res/common/images/common_progress_030.png new file mode 100755 index 0000000..6d39006 Binary files /dev/null and b/res/common/images/common_progress_030.png differ diff --git a/res/common/images/common_progress_031.png b/res/common/images/common_progress_031.png new file mode 100755 index 0000000..a34af5e Binary files /dev/null and b/res/common/images/common_progress_031.png differ diff --git a/res/common/images/common_progress_032.png b/res/common/images/common_progress_032.png new file mode 100755 index 0000000..18c239a Binary files /dev/null and b/res/common/images/common_progress_032.png differ diff --git a/res/common/images/common_progress_033.png b/res/common/images/common_progress_033.png new file mode 100755 index 0000000..ee345fc Binary files /dev/null and b/res/common/images/common_progress_033.png differ diff --git a/res/common/images/common_progress_034.png b/res/common/images/common_progress_034.png new file mode 100755 index 0000000..39f91fa Binary files /dev/null and b/res/common/images/common_progress_034.png differ diff --git a/res/common/images/common_progress_035.png b/res/common/images/common_progress_035.png new file mode 100755 index 0000000..ef4eee5 Binary files /dev/null and b/res/common/images/common_progress_035.png differ diff --git a/res/common/images/common_progress_036.png b/res/common/images/common_progress_036.png new file mode 100755 index 0000000..fd5c1ed Binary files /dev/null and b/res/common/images/common_progress_036.png differ diff --git a/res/common/images/common_progress_037.png b/res/common/images/common_progress_037.png new file mode 100755 index 0000000..cc64898 Binary files /dev/null and b/res/common/images/common_progress_037.png differ diff --git a/res/common/images/common_progress_038.png b/res/common/images/common_progress_038.png new file mode 100755 index 0000000..1b1778b Binary files /dev/null and b/res/common/images/common_progress_038.png differ diff --git a/res/common/images/common_progress_039.png b/res/common/images/common_progress_039.png new file mode 100755 index 0000000..34700ef Binary files /dev/null and b/res/common/images/common_progress_039.png differ diff --git a/res/common/images/common_progress_040.png b/res/common/images/common_progress_040.png new file mode 100755 index 0000000..1f19066 Binary files /dev/null and b/res/common/images/common_progress_040.png differ diff --git a/res/common/images/common_progress_041.png b/res/common/images/common_progress_041.png new file mode 100755 index 0000000..c04cf94 Binary files /dev/null and b/res/common/images/common_progress_041.png differ diff --git a/res/common/images/common_progress_042.png b/res/common/images/common_progress_042.png new file mode 100755 index 0000000..67a4ad7 Binary files /dev/null and b/res/common/images/common_progress_042.png differ diff --git a/res/common/images/common_progress_043.png b/res/common/images/common_progress_043.png new file mode 100755 index 0000000..a4b7599 Binary files /dev/null and b/res/common/images/common_progress_043.png differ diff --git a/res/common/images/common_progress_044.png b/res/common/images/common_progress_044.png new file mode 100755 index 0000000..ce53ffa Binary files /dev/null and b/res/common/images/common_progress_044.png differ diff --git a/res/common/images/common_progress_045.png b/res/common/images/common_progress_045.png new file mode 100755 index 0000000..dfa9684 Binary files /dev/null and b/res/common/images/common_progress_045.png differ diff --git a/res/common/images/common_progress_046.png b/res/common/images/common_progress_046.png new file mode 100755 index 0000000..9577b88 Binary files /dev/null and b/res/common/images/common_progress_046.png differ diff --git a/res/common/images/common_progress_047.png b/res/common/images/common_progress_047.png new file mode 100755 index 0000000..82d3796 Binary files /dev/null and b/res/common/images/common_progress_047.png differ diff --git a/res/common/images/common_progress_048.png b/res/common/images/common_progress_048.png new file mode 100755 index 0000000..76411c9 Binary files /dev/null and b/res/common/images/common_progress_048.png differ diff --git a/res/common/images/common_progress_049.png b/res/common/images/common_progress_049.png new file mode 100755 index 0000000..b6332ec Binary files /dev/null and b/res/common/images/common_progress_049.png differ diff --git a/res/common/images/common_progress_050.png b/res/common/images/common_progress_050.png new file mode 100755 index 0000000..9dbe110 Binary files /dev/null and b/res/common/images/common_progress_050.png differ diff --git a/res/common/images/common_progress_051.png b/res/common/images/common_progress_051.png new file mode 100755 index 0000000..6a3719d Binary files /dev/null and b/res/common/images/common_progress_051.png differ diff --git a/res/common/images/common_progress_052.png b/res/common/images/common_progress_052.png new file mode 100755 index 0000000..1ce0a1a Binary files /dev/null and b/res/common/images/common_progress_052.png differ diff --git a/res/common/images/common_progress_053.png b/res/common/images/common_progress_053.png new file mode 100755 index 0000000..39f77f5 Binary files /dev/null and b/res/common/images/common_progress_053.png differ diff --git a/res/common/images/common_progress_054.png b/res/common/images/common_progress_054.png new file mode 100755 index 0000000..096461d Binary files /dev/null and b/res/common/images/common_progress_054.png differ diff --git a/res/common/images/common_progress_055.png b/res/common/images/common_progress_055.png new file mode 100755 index 0000000..f0c842b Binary files /dev/null and b/res/common/images/common_progress_055.png differ diff --git a/res/common/images/common_progress_056.png b/res/common/images/common_progress_056.png new file mode 100755 index 0000000..6ed7468 Binary files /dev/null and b/res/common/images/common_progress_056.png differ diff --git a/res/common/images/common_progress_057.png b/res/common/images/common_progress_057.png new file mode 100755 index 0000000..b3fab62 Binary files /dev/null and b/res/common/images/common_progress_057.png differ diff --git a/res/common/images/common_progress_058.png b/res/common/images/common_progress_058.png new file mode 100755 index 0000000..1b5b9d0 Binary files /dev/null and b/res/common/images/common_progress_058.png differ diff --git a/res/common/images/common_progress_059.png b/res/common/images/common_progress_059.png new file mode 100755 index 0000000..d48e761 Binary files /dev/null and b/res/common/images/common_progress_059.png differ diff --git a/res/common/images/common_progress_060.png b/res/common/images/common_progress_060.png new file mode 100755 index 0000000..eb6cf09 Binary files /dev/null and b/res/common/images/common_progress_060.png differ diff --git a/res/common/images/common_progress_061.png b/res/common/images/common_progress_061.png new file mode 100755 index 0000000..79173e2 Binary files /dev/null and b/res/common/images/common_progress_061.png differ diff --git a/res/common/images/common_progress_062.png b/res/common/images/common_progress_062.png new file mode 100755 index 0000000..9bc9039 Binary files /dev/null and b/res/common/images/common_progress_062.png differ diff --git a/res/common/images/common_progress_063.png b/res/common/images/common_progress_063.png new file mode 100755 index 0000000..8028336 Binary files /dev/null and b/res/common/images/common_progress_063.png differ diff --git a/res/common/images/common_progress_064.png b/res/common/images/common_progress_064.png new file mode 100755 index 0000000..95c2023 Binary files /dev/null and b/res/common/images/common_progress_064.png differ diff --git a/res/common/images/common_progress_065.png b/res/common/images/common_progress_065.png new file mode 100755 index 0000000..61e0ae0 Binary files /dev/null and b/res/common/images/common_progress_065.png differ diff --git a/res/common/images/common_progress_066.png b/res/common/images/common_progress_066.png new file mode 100755 index 0000000..f26e9b1 Binary files /dev/null and b/res/common/images/common_progress_066.png differ diff --git a/res/common/images/common_progress_067.png b/res/common/images/common_progress_067.png new file mode 100755 index 0000000..6151bbc Binary files /dev/null and b/res/common/images/common_progress_067.png differ diff --git a/res/common/images/common_progress_068.png b/res/common/images/common_progress_068.png new file mode 100755 index 0000000..1d0f10d Binary files /dev/null and b/res/common/images/common_progress_068.png differ diff --git a/res/common/images/common_progress_069.png b/res/common/images/common_progress_069.png new file mode 100755 index 0000000..99238f7 Binary files /dev/null and b/res/common/images/common_progress_069.png differ diff --git a/res/common/images/common_progress_070.png b/res/common/images/common_progress_070.png new file mode 100755 index 0000000..ee97c9b Binary files /dev/null and b/res/common/images/common_progress_070.png differ diff --git a/res/common/images/common_progress_071.png b/res/common/images/common_progress_071.png new file mode 100755 index 0000000..85f624f Binary files /dev/null and b/res/common/images/common_progress_071.png differ diff --git a/res/common/images/common_progress_072.png b/res/common/images/common_progress_072.png new file mode 100755 index 0000000..2bdb18f Binary files /dev/null and b/res/common/images/common_progress_072.png differ diff --git a/res/common/images/common_progress_073.png b/res/common/images/common_progress_073.png new file mode 100755 index 0000000..e515188 Binary files /dev/null and b/res/common/images/common_progress_073.png differ diff --git a/res/common/images/common_progress_074.png b/res/common/images/common_progress_074.png new file mode 100755 index 0000000..7250a6a Binary files /dev/null and b/res/common/images/common_progress_074.png differ diff --git a/res/common/images/common_progress_075.png b/res/common/images/common_progress_075.png new file mode 100755 index 0000000..4035d02 Binary files /dev/null and b/res/common/images/common_progress_075.png differ diff --git a/res/common/images/common_progress_076.png b/res/common/images/common_progress_076.png new file mode 100755 index 0000000..d5e5edc Binary files /dev/null and b/res/common/images/common_progress_076.png differ diff --git a/res/common/images/common_progress_077.png b/res/common/images/common_progress_077.png new file mode 100755 index 0000000..6920e0a Binary files /dev/null and b/res/common/images/common_progress_077.png differ diff --git a/res/common/images/common_progress_078.png b/res/common/images/common_progress_078.png new file mode 100755 index 0000000..1916439 Binary files /dev/null and b/res/common/images/common_progress_078.png differ diff --git a/res/common/images/common_progress_079.png b/res/common/images/common_progress_079.png new file mode 100755 index 0000000..39df853 Binary files /dev/null and b/res/common/images/common_progress_079.png differ diff --git a/res/common/images/common_progress_080.png b/res/common/images/common_progress_080.png new file mode 100755 index 0000000..82d2778 Binary files /dev/null and b/res/common/images/common_progress_080.png differ diff --git a/res/common/images/common_progress_081.png b/res/common/images/common_progress_081.png new file mode 100755 index 0000000..c0b55e5 Binary files /dev/null and b/res/common/images/common_progress_081.png differ diff --git a/res/common/images/common_progress_082.png b/res/common/images/common_progress_082.png new file mode 100755 index 0000000..7b37803 Binary files /dev/null and b/res/common/images/common_progress_082.png differ diff --git a/res/common/images/common_progress_083.png b/res/common/images/common_progress_083.png new file mode 100755 index 0000000..cc4b97a Binary files /dev/null and b/res/common/images/common_progress_083.png differ diff --git a/res/common/images/common_progress_084.png b/res/common/images/common_progress_084.png new file mode 100755 index 0000000..cb4e0d7 Binary files /dev/null and b/res/common/images/common_progress_084.png differ diff --git a/res/common/images/common_progress_085.png b/res/common/images/common_progress_085.png new file mode 100755 index 0000000..b97b64f Binary files /dev/null and b/res/common/images/common_progress_085.png differ diff --git a/res/common/images/common_progress_086.png b/res/common/images/common_progress_086.png new file mode 100755 index 0000000..7117952 Binary files /dev/null and b/res/common/images/common_progress_086.png differ diff --git a/res/common/images/common_progress_087.png b/res/common/images/common_progress_087.png new file mode 100755 index 0000000..4de4b64 Binary files /dev/null and b/res/common/images/common_progress_087.png differ diff --git a/res/common/images/common_progress_088.png b/res/common/images/common_progress_088.png new file mode 100755 index 0000000..91643f8 Binary files /dev/null and b/res/common/images/common_progress_088.png differ diff --git a/res/common/images/common_progress_089.png b/res/common/images/common_progress_089.png new file mode 100755 index 0000000..2e73bff Binary files /dev/null and b/res/common/images/common_progress_089.png differ diff --git a/res/common/images/common_progress_090.png b/res/common/images/common_progress_090.png new file mode 100755 index 0000000..e7d6ce9 Binary files /dev/null and b/res/common/images/common_progress_090.png differ diff --git a/res/common/images/common_progress_091.png b/res/common/images/common_progress_091.png new file mode 100755 index 0000000..a3184e8 Binary files /dev/null and b/res/common/images/common_progress_091.png differ diff --git a/res/common/images/common_progress_092.png b/res/common/images/common_progress_092.png new file mode 100755 index 0000000..949ef89 Binary files /dev/null and b/res/common/images/common_progress_092.png differ diff --git a/res/common/images/common_progress_093.png b/res/common/images/common_progress_093.png new file mode 100755 index 0000000..c6e4272 Binary files /dev/null and b/res/common/images/common_progress_093.png differ diff --git a/res/common/images/common_progress_094.png b/res/common/images/common_progress_094.png new file mode 100755 index 0000000..44d9787 Binary files /dev/null and b/res/common/images/common_progress_094.png differ diff --git a/res/common/images/common_progress_095.png b/res/common/images/common_progress_095.png new file mode 100755 index 0000000..c5e429c Binary files /dev/null and b/res/common/images/common_progress_095.png differ diff --git a/res/common/images/common_progress_096.png b/res/common/images/common_progress_096.png new file mode 100755 index 0000000..05e4112 Binary files /dev/null and b/res/common/images/common_progress_096.png differ diff --git a/res/common/images/common_progress_097.png b/res/common/images/common_progress_097.png new file mode 100755 index 0000000..e0f251c Binary files /dev/null and b/res/common/images/common_progress_097.png differ diff --git a/res/common/images/common_progress_098.png b/res/common/images/common_progress_098.png new file mode 100755 index 0000000..b670450 Binary files /dev/null and b/res/common/images/common_progress_098.png differ diff --git a/res/common/images/common_progress_099.png b/res/common/images/common_progress_099.png new file mode 100755 index 0000000..1a0251d Binary files /dev/null and b/res/common/images/common_progress_099.png differ diff --git a/res/common/images/common_progress_100.png b/res/common/images/common_progress_100.png new file mode 100755 index 0000000..9e779e8 Binary files /dev/null and b/res/common/images/common_progress_100.png differ diff --git a/res/common/images/common_progress_bar.png b/res/common/images/common_progress_bar.png new file mode 100755 index 0000000..0b867ad Binary files /dev/null and b/res/common/images/common_progress_bar.png differ diff --git a/res/common/images/common_recovery_bg_text.png b/res/common/images/common_recovery_bg_text.png new file mode 100755 index 0000000..3567549 Binary files /dev/null and b/res/common/images/common_recovery_bg_text.png differ diff --git a/res/common/images/common_ro_bg_text.png b/res/common/images/common_ro_bg_text.png new file mode 100755 index 0000000..c8decba Binary files /dev/null and b/res/common/images/common_ro_bg_text.png differ diff --git a/res/common/images/common_rw_bg_text.png b/res/common/images/common_rw_bg_text.png new file mode 100755 index 0000000..d1e111f Binary files /dev/null and b/res/common/images/common_rw_bg_text.png differ diff --git a/res/tw1/images/solis_fota_progress_000.png b/res/tw1/images/solis_fota_progress_000.png deleted file mode 100644 index 1292e6a..0000000 Binary files a/res/tw1/images/solis_fota_progress_000.png and /dev/null differ diff --git a/res/tw1/images/wc_fota_downloading_0.png b/res/tw1/images/wc_fota_downloading_0.png deleted file mode 100644 index 9f1733c..0000000 Binary files a/res/tw1/images/wc_fota_downloading_0.png and /dev/null differ diff --git a/res/tw1/images/wc_fota_downloading_1.png b/res/tw1/images/wc_fota_downloading_1.png deleted file mode 100644 index 711ea7a..0000000 Binary files a/res/tw1/images/wc_fota_downloading_1.png and /dev/null differ diff --git a/res/tw1/images/wc_fota_downloading_2.png b/res/tw1/images/wc_fota_downloading_2.png deleted file mode 100644 index e9aca8e..0000000 Binary files a/res/tw1/images/wc_fota_downloading_2.png and /dev/null differ diff --git a/res/tw1/images/wc_fota_downloading_3.png b/res/tw1/images/wc_fota_downloading_3.png deleted file mode 100644 index 8538e35..0000000 Binary files a/res/tw1/images/wc_fota_downloading_3.png and /dev/null differ diff --git a/res/tw1/images/wc_fota_downloading_4.png b/res/tw1/images/wc_fota_downloading_4.png deleted file mode 100644 index 081e84e..0000000 Binary files a/res/tw1/images/wc_fota_downloading_4.png and /dev/null differ diff --git a/res/tw1/images/wc_fota_downloading_5.png b/res/tw1/images/wc_fota_downloading_5.png deleted file mode 100644 index f015a4e..0000000 Binary files a/res/tw1/images/wc_fota_downloading_5.png and /dev/null differ diff --git a/res/tw1/images/wc_fota_downloading_6.png b/res/tw1/images/wc_fota_downloading_6.png deleted file mode 100644 index d548f5e..0000000 Binary files a/res/tw1/images/wc_fota_downloading_6.png and /dev/null differ diff --git a/res/tw1/images/wc_fota_downloading_7.png b/res/tw1/images/wc_fota_downloading_7.png deleted file mode 100644 index 023aa8e..0000000 Binary files a/res/tw1/images/wc_fota_downloading_7.png and /dev/null differ diff --git a/res/tw1/images/wc_fota_downloading_8.png b/res/tw1/images/wc_fota_downloading_8.png deleted file mode 100644 index 37f59ec..0000000 Binary files a/res/tw1/images/wc_fota_downloading_8.png and /dev/null differ diff --git a/res/tw1/images/wc_fota_downloading_9.png b/res/tw1/images/wc_fota_downloading_9.png deleted file mode 100644 index 5350c7d..0000000 Binary files a/res/tw1/images/wc_fota_downloading_9.png and /dev/null differ diff --git a/res/tw1/images/wc_fota_downloading_slash.png b/res/tw1/images/wc_fota_downloading_slash.png deleted file mode 100644 index 459b921..0000000 Binary files a/res/tw1/images/wc_fota_downloading_slash.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_downloading_0.png b/res/wearable/images/tw_fota_downloading_0.png deleted file mode 100644 index 9f1733c..0000000 Binary files a/res/wearable/images/tw_fota_downloading_0.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_downloading_1.png b/res/wearable/images/tw_fota_downloading_1.png deleted file mode 100644 index 711ea7a..0000000 Binary files a/res/wearable/images/tw_fota_downloading_1.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_downloading_2.png b/res/wearable/images/tw_fota_downloading_2.png deleted file mode 100644 index e9aca8e..0000000 Binary files a/res/wearable/images/tw_fota_downloading_2.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_downloading_3.png b/res/wearable/images/tw_fota_downloading_3.png deleted file mode 100644 index 8538e35..0000000 Binary files a/res/wearable/images/tw_fota_downloading_3.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_downloading_4.png b/res/wearable/images/tw_fota_downloading_4.png deleted file mode 100644 index 081e84e..0000000 Binary files a/res/wearable/images/tw_fota_downloading_4.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_downloading_5.png b/res/wearable/images/tw_fota_downloading_5.png deleted file mode 100644 index f015a4e..0000000 Binary files a/res/wearable/images/tw_fota_downloading_5.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_downloading_6.png b/res/wearable/images/tw_fota_downloading_6.png deleted file mode 100644 index d548f5e..0000000 Binary files a/res/wearable/images/tw_fota_downloading_6.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_downloading_7.png b/res/wearable/images/tw_fota_downloading_7.png deleted file mode 100644 index 023aa8e..0000000 Binary files a/res/wearable/images/tw_fota_downloading_7.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_downloading_8.png b/res/wearable/images/tw_fota_downloading_8.png deleted file mode 100644 index 37f59ec..0000000 Binary files a/res/wearable/images/tw_fota_downloading_8.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_downloading_9.png b/res/wearable/images/tw_fota_downloading_9.png deleted file mode 100644 index 5350c7d..0000000 Binary files a/res/wearable/images/tw_fota_downloading_9.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_downloading_percent.png b/res/wearable/images/tw_fota_downloading_percent.png deleted file mode 100644 index 4bebe5a..0000000 Binary files a/res/wearable/images/tw_fota_downloading_percent.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_000.png b/res/wearable/images/tw_fota_progress_000.png deleted file mode 100644 index 57c4167..0000000 Binary files a/res/wearable/images/tw_fota_progress_000.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_001.png b/res/wearable/images/tw_fota_progress_001.png deleted file mode 100644 index 6ac35be..0000000 Binary files a/res/wearable/images/tw_fota_progress_001.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_002.png b/res/wearable/images/tw_fota_progress_002.png deleted file mode 100644 index ada29ef..0000000 Binary files a/res/wearable/images/tw_fota_progress_002.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_003.png b/res/wearable/images/tw_fota_progress_003.png deleted file mode 100644 index 8d62ed9..0000000 Binary files a/res/wearable/images/tw_fota_progress_003.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_004.png b/res/wearable/images/tw_fota_progress_004.png deleted file mode 100644 index b4cad03..0000000 Binary files a/res/wearable/images/tw_fota_progress_004.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_005.png b/res/wearable/images/tw_fota_progress_005.png deleted file mode 100644 index 336dfd0..0000000 Binary files a/res/wearable/images/tw_fota_progress_005.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_006.png b/res/wearable/images/tw_fota_progress_006.png deleted file mode 100644 index 797aecc..0000000 Binary files a/res/wearable/images/tw_fota_progress_006.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_007.png b/res/wearable/images/tw_fota_progress_007.png deleted file mode 100644 index 9b58022..0000000 Binary files a/res/wearable/images/tw_fota_progress_007.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_008.png b/res/wearable/images/tw_fota_progress_008.png deleted file mode 100644 index 4276f1c..0000000 Binary files a/res/wearable/images/tw_fota_progress_008.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_009.png b/res/wearable/images/tw_fota_progress_009.png deleted file mode 100644 index c59beb5..0000000 Binary files a/res/wearable/images/tw_fota_progress_009.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_010.png b/res/wearable/images/tw_fota_progress_010.png deleted file mode 100644 index 160f583..0000000 Binary files a/res/wearable/images/tw_fota_progress_010.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_011.png b/res/wearable/images/tw_fota_progress_011.png deleted file mode 100644 index dc80fe8..0000000 Binary files a/res/wearable/images/tw_fota_progress_011.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_012.png b/res/wearable/images/tw_fota_progress_012.png deleted file mode 100644 index 9304d6c..0000000 Binary files a/res/wearable/images/tw_fota_progress_012.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_013.png b/res/wearable/images/tw_fota_progress_013.png deleted file mode 100644 index a158ad0..0000000 Binary files a/res/wearable/images/tw_fota_progress_013.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_014.png b/res/wearable/images/tw_fota_progress_014.png deleted file mode 100644 index 2f975aa..0000000 Binary files a/res/wearable/images/tw_fota_progress_014.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_015.png b/res/wearable/images/tw_fota_progress_015.png deleted file mode 100644 index 0f43b63..0000000 Binary files a/res/wearable/images/tw_fota_progress_015.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_016.png b/res/wearable/images/tw_fota_progress_016.png deleted file mode 100644 index 01e638b..0000000 Binary files a/res/wearable/images/tw_fota_progress_016.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_017.png b/res/wearable/images/tw_fota_progress_017.png deleted file mode 100644 index 0853460..0000000 Binary files a/res/wearable/images/tw_fota_progress_017.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_018.png b/res/wearable/images/tw_fota_progress_018.png deleted file mode 100644 index 00d776e..0000000 Binary files a/res/wearable/images/tw_fota_progress_018.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_019.png b/res/wearable/images/tw_fota_progress_019.png deleted file mode 100644 index d9a4e8c..0000000 Binary files a/res/wearable/images/tw_fota_progress_019.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_020.png b/res/wearable/images/tw_fota_progress_020.png deleted file mode 100644 index 9eb0486..0000000 Binary files a/res/wearable/images/tw_fota_progress_020.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_021.png b/res/wearable/images/tw_fota_progress_021.png deleted file mode 100644 index bc2cfeb..0000000 Binary files a/res/wearable/images/tw_fota_progress_021.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_022.png b/res/wearable/images/tw_fota_progress_022.png deleted file mode 100644 index ee2a978..0000000 Binary files a/res/wearable/images/tw_fota_progress_022.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_023.png b/res/wearable/images/tw_fota_progress_023.png deleted file mode 100644 index 4bd3f25..0000000 Binary files a/res/wearable/images/tw_fota_progress_023.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_024.png b/res/wearable/images/tw_fota_progress_024.png deleted file mode 100644 index 50c1afe..0000000 Binary files a/res/wearable/images/tw_fota_progress_024.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_025.png b/res/wearable/images/tw_fota_progress_025.png deleted file mode 100644 index 20344af..0000000 Binary files a/res/wearable/images/tw_fota_progress_025.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_026.png b/res/wearable/images/tw_fota_progress_026.png deleted file mode 100644 index 9efa47a..0000000 Binary files a/res/wearable/images/tw_fota_progress_026.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_027.png b/res/wearable/images/tw_fota_progress_027.png deleted file mode 100644 index 20800fd..0000000 Binary files a/res/wearable/images/tw_fota_progress_027.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_028.png b/res/wearable/images/tw_fota_progress_028.png deleted file mode 100644 index 2022c64..0000000 Binary files a/res/wearable/images/tw_fota_progress_028.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_029.png b/res/wearable/images/tw_fota_progress_029.png deleted file mode 100644 index ce92083..0000000 Binary files a/res/wearable/images/tw_fota_progress_029.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_030.png b/res/wearable/images/tw_fota_progress_030.png deleted file mode 100644 index 85eddd2..0000000 Binary files a/res/wearable/images/tw_fota_progress_030.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_031.png b/res/wearable/images/tw_fota_progress_031.png deleted file mode 100644 index fb5241f..0000000 Binary files a/res/wearable/images/tw_fota_progress_031.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_032.png b/res/wearable/images/tw_fota_progress_032.png deleted file mode 100644 index 94dbf7b..0000000 Binary files a/res/wearable/images/tw_fota_progress_032.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_033.png b/res/wearable/images/tw_fota_progress_033.png deleted file mode 100644 index 8863cfd..0000000 Binary files a/res/wearable/images/tw_fota_progress_033.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_034.png b/res/wearable/images/tw_fota_progress_034.png deleted file mode 100644 index 6a152a9..0000000 Binary files a/res/wearable/images/tw_fota_progress_034.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_035.png b/res/wearable/images/tw_fota_progress_035.png deleted file mode 100644 index 4c04bfa..0000000 Binary files a/res/wearable/images/tw_fota_progress_035.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_036.png b/res/wearable/images/tw_fota_progress_036.png deleted file mode 100644 index 30a5da4..0000000 Binary files a/res/wearable/images/tw_fota_progress_036.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_037.png b/res/wearable/images/tw_fota_progress_037.png deleted file mode 100644 index cd683f4..0000000 Binary files a/res/wearable/images/tw_fota_progress_037.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_038.png b/res/wearable/images/tw_fota_progress_038.png deleted file mode 100644 index aa6cd07..0000000 Binary files a/res/wearable/images/tw_fota_progress_038.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_039.png b/res/wearable/images/tw_fota_progress_039.png deleted file mode 100644 index aeeb890..0000000 Binary files a/res/wearable/images/tw_fota_progress_039.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_040.png b/res/wearable/images/tw_fota_progress_040.png deleted file mode 100644 index 2bdec30..0000000 Binary files a/res/wearable/images/tw_fota_progress_040.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_041.png b/res/wearable/images/tw_fota_progress_041.png deleted file mode 100644 index 219d64a..0000000 Binary files a/res/wearable/images/tw_fota_progress_041.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_042.png b/res/wearable/images/tw_fota_progress_042.png deleted file mode 100644 index 36f9890..0000000 Binary files a/res/wearable/images/tw_fota_progress_042.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_043.png b/res/wearable/images/tw_fota_progress_043.png deleted file mode 100644 index 380dac6..0000000 Binary files a/res/wearable/images/tw_fota_progress_043.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_044.png b/res/wearable/images/tw_fota_progress_044.png deleted file mode 100644 index 1567063..0000000 Binary files a/res/wearable/images/tw_fota_progress_044.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_045.png b/res/wearable/images/tw_fota_progress_045.png deleted file mode 100644 index 748edaf..0000000 Binary files a/res/wearable/images/tw_fota_progress_045.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_046.png b/res/wearable/images/tw_fota_progress_046.png deleted file mode 100644 index 3d3eff3..0000000 Binary files a/res/wearable/images/tw_fota_progress_046.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_047.png b/res/wearable/images/tw_fota_progress_047.png deleted file mode 100644 index 9771f49..0000000 Binary files a/res/wearable/images/tw_fota_progress_047.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_048.png b/res/wearable/images/tw_fota_progress_048.png deleted file mode 100644 index d1c5350..0000000 Binary files a/res/wearable/images/tw_fota_progress_048.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_049.png b/res/wearable/images/tw_fota_progress_049.png deleted file mode 100644 index e45b84b..0000000 Binary files a/res/wearable/images/tw_fota_progress_049.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_050.png b/res/wearable/images/tw_fota_progress_050.png deleted file mode 100644 index c4ea519..0000000 Binary files a/res/wearable/images/tw_fota_progress_050.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_051.png b/res/wearable/images/tw_fota_progress_051.png deleted file mode 100644 index 127ea69..0000000 Binary files a/res/wearable/images/tw_fota_progress_051.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_052.png b/res/wearable/images/tw_fota_progress_052.png deleted file mode 100644 index b0c51a3..0000000 Binary files a/res/wearable/images/tw_fota_progress_052.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_053.png b/res/wearable/images/tw_fota_progress_053.png deleted file mode 100644 index 2aed22b..0000000 Binary files a/res/wearable/images/tw_fota_progress_053.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_054.png b/res/wearable/images/tw_fota_progress_054.png deleted file mode 100644 index 6097e7c..0000000 Binary files a/res/wearable/images/tw_fota_progress_054.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_055.png b/res/wearable/images/tw_fota_progress_055.png deleted file mode 100644 index b90df4c..0000000 Binary files a/res/wearable/images/tw_fota_progress_055.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_056.png b/res/wearable/images/tw_fota_progress_056.png deleted file mode 100644 index 8695306..0000000 Binary files a/res/wearable/images/tw_fota_progress_056.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_057.png b/res/wearable/images/tw_fota_progress_057.png deleted file mode 100644 index 405e6fe..0000000 Binary files a/res/wearable/images/tw_fota_progress_057.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_058.png b/res/wearable/images/tw_fota_progress_058.png deleted file mode 100644 index 21eaa87..0000000 Binary files a/res/wearable/images/tw_fota_progress_058.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_059.png b/res/wearable/images/tw_fota_progress_059.png deleted file mode 100644 index 217b3b5..0000000 Binary files a/res/wearable/images/tw_fota_progress_059.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_060.png b/res/wearable/images/tw_fota_progress_060.png deleted file mode 100644 index 97ffaa3..0000000 Binary files a/res/wearable/images/tw_fota_progress_060.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_061.png b/res/wearable/images/tw_fota_progress_061.png deleted file mode 100644 index dc787a7..0000000 Binary files a/res/wearable/images/tw_fota_progress_061.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_062.png b/res/wearable/images/tw_fota_progress_062.png deleted file mode 100644 index 4ecbe80..0000000 Binary files a/res/wearable/images/tw_fota_progress_062.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_063.png b/res/wearable/images/tw_fota_progress_063.png deleted file mode 100644 index 05c28ee..0000000 Binary files a/res/wearable/images/tw_fota_progress_063.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_064.png b/res/wearable/images/tw_fota_progress_064.png deleted file mode 100644 index 4a538cb..0000000 Binary files a/res/wearable/images/tw_fota_progress_064.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_065.png b/res/wearable/images/tw_fota_progress_065.png deleted file mode 100644 index c46965a..0000000 Binary files a/res/wearable/images/tw_fota_progress_065.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_066.png b/res/wearable/images/tw_fota_progress_066.png deleted file mode 100644 index 695620f..0000000 Binary files a/res/wearable/images/tw_fota_progress_066.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_067.png b/res/wearable/images/tw_fota_progress_067.png deleted file mode 100644 index 8e549da..0000000 Binary files a/res/wearable/images/tw_fota_progress_067.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_068.png b/res/wearable/images/tw_fota_progress_068.png deleted file mode 100644 index 2ba24f4..0000000 Binary files a/res/wearable/images/tw_fota_progress_068.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_069.png b/res/wearable/images/tw_fota_progress_069.png deleted file mode 100644 index 524caab..0000000 Binary files a/res/wearable/images/tw_fota_progress_069.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_070.png b/res/wearable/images/tw_fota_progress_070.png deleted file mode 100644 index 83fc829..0000000 Binary files a/res/wearable/images/tw_fota_progress_070.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_071.png b/res/wearable/images/tw_fota_progress_071.png deleted file mode 100644 index 722d775..0000000 Binary files a/res/wearable/images/tw_fota_progress_071.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_072.png b/res/wearable/images/tw_fota_progress_072.png deleted file mode 100644 index 9ace826..0000000 Binary files a/res/wearable/images/tw_fota_progress_072.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_073.png b/res/wearable/images/tw_fota_progress_073.png deleted file mode 100644 index 0c64d0d..0000000 Binary files a/res/wearable/images/tw_fota_progress_073.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_074.png b/res/wearable/images/tw_fota_progress_074.png deleted file mode 100644 index e44c358..0000000 Binary files a/res/wearable/images/tw_fota_progress_074.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_075.png b/res/wearable/images/tw_fota_progress_075.png deleted file mode 100644 index 6840e50..0000000 Binary files a/res/wearable/images/tw_fota_progress_075.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_076.png b/res/wearable/images/tw_fota_progress_076.png deleted file mode 100644 index 7e7cb00..0000000 Binary files a/res/wearable/images/tw_fota_progress_076.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_077.png b/res/wearable/images/tw_fota_progress_077.png deleted file mode 100644 index 06006b4..0000000 Binary files a/res/wearable/images/tw_fota_progress_077.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_078.png b/res/wearable/images/tw_fota_progress_078.png deleted file mode 100644 index 2ea32ca..0000000 Binary files a/res/wearable/images/tw_fota_progress_078.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_079.png b/res/wearable/images/tw_fota_progress_079.png deleted file mode 100644 index ba007b0..0000000 Binary files a/res/wearable/images/tw_fota_progress_079.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_080.png b/res/wearable/images/tw_fota_progress_080.png deleted file mode 100644 index 3965982..0000000 Binary files a/res/wearable/images/tw_fota_progress_080.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_081.png b/res/wearable/images/tw_fota_progress_081.png deleted file mode 100644 index bce77f3..0000000 Binary files a/res/wearable/images/tw_fota_progress_081.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_082.png b/res/wearable/images/tw_fota_progress_082.png deleted file mode 100644 index 4c6e07f..0000000 Binary files a/res/wearable/images/tw_fota_progress_082.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_083.png b/res/wearable/images/tw_fota_progress_083.png deleted file mode 100644 index e962e65..0000000 Binary files a/res/wearable/images/tw_fota_progress_083.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_084.png b/res/wearable/images/tw_fota_progress_084.png deleted file mode 100644 index ad3c8da..0000000 Binary files a/res/wearable/images/tw_fota_progress_084.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_085.png b/res/wearable/images/tw_fota_progress_085.png deleted file mode 100644 index efbe6bd..0000000 Binary files a/res/wearable/images/tw_fota_progress_085.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_086.png b/res/wearable/images/tw_fota_progress_086.png deleted file mode 100644 index 583dda4..0000000 Binary files a/res/wearable/images/tw_fota_progress_086.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_087.png b/res/wearable/images/tw_fota_progress_087.png deleted file mode 100644 index 5d67e0c..0000000 Binary files a/res/wearable/images/tw_fota_progress_087.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_088.png b/res/wearable/images/tw_fota_progress_088.png deleted file mode 100644 index 553146d..0000000 Binary files a/res/wearable/images/tw_fota_progress_088.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_089.png b/res/wearable/images/tw_fota_progress_089.png deleted file mode 100644 index 1ef9330..0000000 Binary files a/res/wearable/images/tw_fota_progress_089.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_090.png b/res/wearable/images/tw_fota_progress_090.png deleted file mode 100644 index c37815d..0000000 Binary files a/res/wearable/images/tw_fota_progress_090.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_091.png b/res/wearable/images/tw_fota_progress_091.png deleted file mode 100644 index 5554045..0000000 Binary files a/res/wearable/images/tw_fota_progress_091.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_092.png b/res/wearable/images/tw_fota_progress_092.png deleted file mode 100644 index 88eae71..0000000 Binary files a/res/wearable/images/tw_fota_progress_092.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_093.png b/res/wearable/images/tw_fota_progress_093.png deleted file mode 100644 index 1ecd08a..0000000 Binary files a/res/wearable/images/tw_fota_progress_093.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_094.png b/res/wearable/images/tw_fota_progress_094.png deleted file mode 100644 index 68b555a..0000000 Binary files a/res/wearable/images/tw_fota_progress_094.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_095.png b/res/wearable/images/tw_fota_progress_095.png deleted file mode 100644 index b5ebe82..0000000 Binary files a/res/wearable/images/tw_fota_progress_095.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_096.png b/res/wearable/images/tw_fota_progress_096.png deleted file mode 100644 index 340e683..0000000 Binary files a/res/wearable/images/tw_fota_progress_096.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_097.png b/res/wearable/images/tw_fota_progress_097.png deleted file mode 100644 index 9aa46b5..0000000 Binary files a/res/wearable/images/tw_fota_progress_097.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_098.png b/res/wearable/images/tw_fota_progress_098.png deleted file mode 100644 index b056990..0000000 Binary files a/res/wearable/images/tw_fota_progress_098.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_099.png b/res/wearable/images/tw_fota_progress_099.png deleted file mode 100644 index 917a5ae..0000000 Binary files a/res/wearable/images/tw_fota_progress_099.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_100.png b/res/wearable/images/tw_fota_progress_100.png deleted file mode 100644 index e8ecfec..0000000 Binary files a/res/wearable/images/tw_fota_progress_100.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_bg.png b/res/wearable/images/tw_fota_progress_bg.png deleted file mode 100644 index 57c4167..0000000 Binary files a/res/wearable/images/tw_fota_progress_bg.png and /dev/null differ diff --git a/res/wearable/images/tw_fota_progress_final.png b/res/wearable/images/tw_fota_progress_final.png deleted file mode 100644 index 7959b95..0000000 Binary files a/res/wearable/images/tw_fota_progress_final.png and /dev/null differ diff --git a/res/wearable/images/tw_start_downloading.png b/res/wearable/images/tw_start_downloading.png deleted file mode 100644 index b1ab5d2..0000000 Binary files a/res/wearable/images/tw_start_downloading.png and /dev/null differ diff --git a/res/wearable/ro_update/images/tw_fota_downloading_0.png b/res/wearable/ro_update/images/tw_fota_downloading_0.png new file mode 100644 index 0000000..9f1733c Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_downloading_0.png differ diff --git a/res/wearable/ro_update/images/tw_fota_downloading_1.png b/res/wearable/ro_update/images/tw_fota_downloading_1.png new file mode 100644 index 0000000..711ea7a Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_downloading_1.png differ diff --git a/res/wearable/ro_update/images/tw_fota_downloading_2.png b/res/wearable/ro_update/images/tw_fota_downloading_2.png new file mode 100644 index 0000000..e9aca8e Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_downloading_2.png differ diff --git a/res/wearable/ro_update/images/tw_fota_downloading_3.png b/res/wearable/ro_update/images/tw_fota_downloading_3.png new file mode 100644 index 0000000..8538e35 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_downloading_3.png differ diff --git a/res/wearable/ro_update/images/tw_fota_downloading_4.png b/res/wearable/ro_update/images/tw_fota_downloading_4.png new file mode 100644 index 0000000..081e84e Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_downloading_4.png differ diff --git a/res/wearable/ro_update/images/tw_fota_downloading_5.png b/res/wearable/ro_update/images/tw_fota_downloading_5.png new file mode 100644 index 0000000..f015a4e Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_downloading_5.png differ diff --git a/res/wearable/ro_update/images/tw_fota_downloading_6.png b/res/wearable/ro_update/images/tw_fota_downloading_6.png new file mode 100644 index 0000000..d548f5e Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_downloading_6.png differ diff --git a/res/wearable/ro_update/images/tw_fota_downloading_7.png b/res/wearable/ro_update/images/tw_fota_downloading_7.png new file mode 100644 index 0000000..023aa8e Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_downloading_7.png differ diff --git a/res/wearable/ro_update/images/tw_fota_downloading_8.png b/res/wearable/ro_update/images/tw_fota_downloading_8.png new file mode 100644 index 0000000..37f59ec Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_downloading_8.png differ diff --git a/res/wearable/ro_update/images/tw_fota_downloading_9.png b/res/wearable/ro_update/images/tw_fota_downloading_9.png new file mode 100644 index 0000000..5350c7d Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_downloading_9.png differ diff --git a/res/wearable/ro_update/images/tw_fota_downloading_percent.png b/res/wearable/ro_update/images/tw_fota_downloading_percent.png new file mode 100644 index 0000000..4bebe5a Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_downloading_percent.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_000.png b/res/wearable/ro_update/images/tw_fota_progress_000.png new file mode 100644 index 0000000..57c4167 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_000.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_001.png b/res/wearable/ro_update/images/tw_fota_progress_001.png new file mode 100644 index 0000000..6ac35be Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_001.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_002.png b/res/wearable/ro_update/images/tw_fota_progress_002.png new file mode 100644 index 0000000..ada29ef Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_002.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_003.png b/res/wearable/ro_update/images/tw_fota_progress_003.png new file mode 100644 index 0000000..8d62ed9 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_003.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_004.png b/res/wearable/ro_update/images/tw_fota_progress_004.png new file mode 100644 index 0000000..b4cad03 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_004.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_005.png b/res/wearable/ro_update/images/tw_fota_progress_005.png new file mode 100644 index 0000000..336dfd0 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_005.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_006.png b/res/wearable/ro_update/images/tw_fota_progress_006.png new file mode 100644 index 0000000..797aecc Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_006.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_007.png b/res/wearable/ro_update/images/tw_fota_progress_007.png new file mode 100644 index 0000000..9b58022 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_007.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_008.png b/res/wearable/ro_update/images/tw_fota_progress_008.png new file mode 100644 index 0000000..4276f1c Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_008.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_009.png b/res/wearable/ro_update/images/tw_fota_progress_009.png new file mode 100644 index 0000000..c59beb5 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_009.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_010.png b/res/wearable/ro_update/images/tw_fota_progress_010.png new file mode 100644 index 0000000..160f583 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_010.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_011.png b/res/wearable/ro_update/images/tw_fota_progress_011.png new file mode 100644 index 0000000..dc80fe8 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_011.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_012.png b/res/wearable/ro_update/images/tw_fota_progress_012.png new file mode 100644 index 0000000..9304d6c Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_012.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_013.png b/res/wearable/ro_update/images/tw_fota_progress_013.png new file mode 100644 index 0000000..a158ad0 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_013.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_014.png b/res/wearable/ro_update/images/tw_fota_progress_014.png new file mode 100644 index 0000000..2f975aa Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_014.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_015.png b/res/wearable/ro_update/images/tw_fota_progress_015.png new file mode 100644 index 0000000..0f43b63 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_015.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_016.png b/res/wearable/ro_update/images/tw_fota_progress_016.png new file mode 100644 index 0000000..01e638b Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_016.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_017.png b/res/wearable/ro_update/images/tw_fota_progress_017.png new file mode 100644 index 0000000..0853460 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_017.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_018.png b/res/wearable/ro_update/images/tw_fota_progress_018.png new file mode 100644 index 0000000..00d776e Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_018.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_019.png b/res/wearable/ro_update/images/tw_fota_progress_019.png new file mode 100644 index 0000000..d9a4e8c Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_019.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_020.png b/res/wearable/ro_update/images/tw_fota_progress_020.png new file mode 100644 index 0000000..9eb0486 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_020.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_021.png b/res/wearable/ro_update/images/tw_fota_progress_021.png new file mode 100644 index 0000000..bc2cfeb Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_021.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_022.png b/res/wearable/ro_update/images/tw_fota_progress_022.png new file mode 100644 index 0000000..ee2a978 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_022.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_023.png b/res/wearable/ro_update/images/tw_fota_progress_023.png new file mode 100644 index 0000000..4bd3f25 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_023.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_024.png b/res/wearable/ro_update/images/tw_fota_progress_024.png new file mode 100644 index 0000000..50c1afe Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_024.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_025.png b/res/wearable/ro_update/images/tw_fota_progress_025.png new file mode 100644 index 0000000..20344af Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_025.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_026.png b/res/wearable/ro_update/images/tw_fota_progress_026.png new file mode 100644 index 0000000..9efa47a Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_026.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_027.png b/res/wearable/ro_update/images/tw_fota_progress_027.png new file mode 100644 index 0000000..20800fd Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_027.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_028.png b/res/wearable/ro_update/images/tw_fota_progress_028.png new file mode 100644 index 0000000..2022c64 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_028.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_029.png b/res/wearable/ro_update/images/tw_fota_progress_029.png new file mode 100644 index 0000000..ce92083 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_029.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_030.png b/res/wearable/ro_update/images/tw_fota_progress_030.png new file mode 100644 index 0000000..85eddd2 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_030.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_031.png b/res/wearable/ro_update/images/tw_fota_progress_031.png new file mode 100644 index 0000000..fb5241f Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_031.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_032.png b/res/wearable/ro_update/images/tw_fota_progress_032.png new file mode 100644 index 0000000..94dbf7b Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_032.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_033.png b/res/wearable/ro_update/images/tw_fota_progress_033.png new file mode 100644 index 0000000..8863cfd Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_033.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_034.png b/res/wearable/ro_update/images/tw_fota_progress_034.png new file mode 100644 index 0000000..6a152a9 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_034.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_035.png b/res/wearable/ro_update/images/tw_fota_progress_035.png new file mode 100644 index 0000000..4c04bfa Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_035.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_036.png b/res/wearable/ro_update/images/tw_fota_progress_036.png new file mode 100644 index 0000000..30a5da4 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_036.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_037.png b/res/wearable/ro_update/images/tw_fota_progress_037.png new file mode 100644 index 0000000..cd683f4 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_037.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_038.png b/res/wearable/ro_update/images/tw_fota_progress_038.png new file mode 100644 index 0000000..aa6cd07 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_038.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_039.png b/res/wearable/ro_update/images/tw_fota_progress_039.png new file mode 100644 index 0000000..aeeb890 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_039.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_040.png b/res/wearable/ro_update/images/tw_fota_progress_040.png new file mode 100644 index 0000000..2bdec30 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_040.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_041.png b/res/wearable/ro_update/images/tw_fota_progress_041.png new file mode 100644 index 0000000..219d64a Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_041.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_042.png b/res/wearable/ro_update/images/tw_fota_progress_042.png new file mode 100644 index 0000000..36f9890 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_042.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_043.png b/res/wearable/ro_update/images/tw_fota_progress_043.png new file mode 100644 index 0000000..380dac6 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_043.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_044.png b/res/wearable/ro_update/images/tw_fota_progress_044.png new file mode 100644 index 0000000..1567063 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_044.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_045.png b/res/wearable/ro_update/images/tw_fota_progress_045.png new file mode 100644 index 0000000..748edaf Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_045.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_046.png b/res/wearable/ro_update/images/tw_fota_progress_046.png new file mode 100644 index 0000000..3d3eff3 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_046.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_047.png b/res/wearable/ro_update/images/tw_fota_progress_047.png new file mode 100644 index 0000000..9771f49 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_047.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_048.png b/res/wearable/ro_update/images/tw_fota_progress_048.png new file mode 100644 index 0000000..d1c5350 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_048.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_049.png b/res/wearable/ro_update/images/tw_fota_progress_049.png new file mode 100644 index 0000000..e45b84b Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_049.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_050.png b/res/wearable/ro_update/images/tw_fota_progress_050.png new file mode 100644 index 0000000..c4ea519 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_050.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_051.png b/res/wearable/ro_update/images/tw_fota_progress_051.png new file mode 100644 index 0000000..127ea69 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_051.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_052.png b/res/wearable/ro_update/images/tw_fota_progress_052.png new file mode 100644 index 0000000..b0c51a3 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_052.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_053.png b/res/wearable/ro_update/images/tw_fota_progress_053.png new file mode 100644 index 0000000..2aed22b Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_053.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_054.png b/res/wearable/ro_update/images/tw_fota_progress_054.png new file mode 100644 index 0000000..6097e7c Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_054.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_055.png b/res/wearable/ro_update/images/tw_fota_progress_055.png new file mode 100644 index 0000000..b90df4c Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_055.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_056.png b/res/wearable/ro_update/images/tw_fota_progress_056.png new file mode 100644 index 0000000..8695306 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_056.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_057.png b/res/wearable/ro_update/images/tw_fota_progress_057.png new file mode 100644 index 0000000..405e6fe Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_057.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_058.png b/res/wearable/ro_update/images/tw_fota_progress_058.png new file mode 100644 index 0000000..21eaa87 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_058.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_059.png b/res/wearable/ro_update/images/tw_fota_progress_059.png new file mode 100644 index 0000000..217b3b5 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_059.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_060.png b/res/wearable/ro_update/images/tw_fota_progress_060.png new file mode 100644 index 0000000..97ffaa3 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_060.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_061.png b/res/wearable/ro_update/images/tw_fota_progress_061.png new file mode 100644 index 0000000..dc787a7 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_061.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_062.png b/res/wearable/ro_update/images/tw_fota_progress_062.png new file mode 100644 index 0000000..4ecbe80 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_062.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_063.png b/res/wearable/ro_update/images/tw_fota_progress_063.png new file mode 100644 index 0000000..05c28ee Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_063.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_064.png b/res/wearable/ro_update/images/tw_fota_progress_064.png new file mode 100644 index 0000000..4a538cb Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_064.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_065.png b/res/wearable/ro_update/images/tw_fota_progress_065.png new file mode 100644 index 0000000..c46965a Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_065.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_066.png b/res/wearable/ro_update/images/tw_fota_progress_066.png new file mode 100644 index 0000000..695620f Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_066.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_067.png b/res/wearable/ro_update/images/tw_fota_progress_067.png new file mode 100644 index 0000000..8e549da Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_067.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_068.png b/res/wearable/ro_update/images/tw_fota_progress_068.png new file mode 100644 index 0000000..2ba24f4 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_068.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_069.png b/res/wearable/ro_update/images/tw_fota_progress_069.png new file mode 100644 index 0000000..524caab Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_069.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_070.png b/res/wearable/ro_update/images/tw_fota_progress_070.png new file mode 100644 index 0000000..83fc829 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_070.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_071.png b/res/wearable/ro_update/images/tw_fota_progress_071.png new file mode 100644 index 0000000..722d775 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_071.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_072.png b/res/wearable/ro_update/images/tw_fota_progress_072.png new file mode 100644 index 0000000..9ace826 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_072.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_073.png b/res/wearable/ro_update/images/tw_fota_progress_073.png new file mode 100644 index 0000000..0c64d0d Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_073.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_074.png b/res/wearable/ro_update/images/tw_fota_progress_074.png new file mode 100644 index 0000000..e44c358 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_074.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_075.png b/res/wearable/ro_update/images/tw_fota_progress_075.png new file mode 100644 index 0000000..6840e50 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_075.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_076.png b/res/wearable/ro_update/images/tw_fota_progress_076.png new file mode 100644 index 0000000..7e7cb00 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_076.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_077.png b/res/wearable/ro_update/images/tw_fota_progress_077.png new file mode 100644 index 0000000..06006b4 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_077.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_078.png b/res/wearable/ro_update/images/tw_fota_progress_078.png new file mode 100644 index 0000000..2ea32ca Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_078.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_079.png b/res/wearable/ro_update/images/tw_fota_progress_079.png new file mode 100644 index 0000000..ba007b0 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_079.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_080.png b/res/wearable/ro_update/images/tw_fota_progress_080.png new file mode 100644 index 0000000..3965982 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_080.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_081.png b/res/wearable/ro_update/images/tw_fota_progress_081.png new file mode 100644 index 0000000..bce77f3 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_081.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_082.png b/res/wearable/ro_update/images/tw_fota_progress_082.png new file mode 100644 index 0000000..4c6e07f Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_082.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_083.png b/res/wearable/ro_update/images/tw_fota_progress_083.png new file mode 100644 index 0000000..e962e65 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_083.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_084.png b/res/wearable/ro_update/images/tw_fota_progress_084.png new file mode 100644 index 0000000..ad3c8da Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_084.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_085.png b/res/wearable/ro_update/images/tw_fota_progress_085.png new file mode 100644 index 0000000..efbe6bd Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_085.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_086.png b/res/wearable/ro_update/images/tw_fota_progress_086.png new file mode 100644 index 0000000..583dda4 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_086.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_087.png b/res/wearable/ro_update/images/tw_fota_progress_087.png new file mode 100644 index 0000000..5d67e0c Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_087.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_088.png b/res/wearable/ro_update/images/tw_fota_progress_088.png new file mode 100644 index 0000000..553146d Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_088.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_089.png b/res/wearable/ro_update/images/tw_fota_progress_089.png new file mode 100644 index 0000000..1ef9330 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_089.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_090.png b/res/wearable/ro_update/images/tw_fota_progress_090.png new file mode 100644 index 0000000..c37815d Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_090.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_091.png b/res/wearable/ro_update/images/tw_fota_progress_091.png new file mode 100644 index 0000000..5554045 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_091.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_092.png b/res/wearable/ro_update/images/tw_fota_progress_092.png new file mode 100644 index 0000000..88eae71 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_092.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_093.png b/res/wearable/ro_update/images/tw_fota_progress_093.png new file mode 100644 index 0000000..1ecd08a Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_093.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_094.png b/res/wearable/ro_update/images/tw_fota_progress_094.png new file mode 100644 index 0000000..68b555a Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_094.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_095.png b/res/wearable/ro_update/images/tw_fota_progress_095.png new file mode 100644 index 0000000..b5ebe82 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_095.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_096.png b/res/wearable/ro_update/images/tw_fota_progress_096.png new file mode 100644 index 0000000..340e683 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_096.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_097.png b/res/wearable/ro_update/images/tw_fota_progress_097.png new file mode 100644 index 0000000..9aa46b5 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_097.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_098.png b/res/wearable/ro_update/images/tw_fota_progress_098.png new file mode 100644 index 0000000..b056990 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_098.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_099.png b/res/wearable/ro_update/images/tw_fota_progress_099.png new file mode 100644 index 0000000..917a5ae Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_099.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_100.png b/res/wearable/ro_update/images/tw_fota_progress_100.png new file mode 100644 index 0000000..e8ecfec Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_100.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_bg.png b/res/wearable/ro_update/images/tw_fota_progress_bg.png new file mode 100644 index 0000000..57c4167 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_bg.png differ diff --git a/res/wearable/ro_update/images/tw_fota_progress_final.png b/res/wearable/ro_update/images/tw_fota_progress_final.png new file mode 100644 index 0000000..7959b95 Binary files /dev/null and b/res/wearable/ro_update/images/tw_fota_progress_final.png differ diff --git a/res/wearable/ro_update/images/tw_start_downloading.png b/res/wearable/ro_update/images/tw_start_downloading.png new file mode 100644 index 0000000..b1ab5d2 Binary files /dev/null and b/res/wearable/ro_update/images/tw_start_downloading.png differ diff --git a/res/wearable/rw_update/images/tw_fota_downloading_0.png b/res/wearable/rw_update/images/tw_fota_downloading_0.png new file mode 100644 index 0000000..9f1733c Binary files /dev/null and b/res/wearable/rw_update/images/tw_fota_downloading_0.png differ diff --git a/res/wearable/rw_update/images/tw_fota_downloading_1.png b/res/wearable/rw_update/images/tw_fota_downloading_1.png new file mode 100644 index 0000000..711ea7a Binary files /dev/null and b/res/wearable/rw_update/images/tw_fota_downloading_1.png differ diff --git a/res/wearable/rw_update/images/tw_fota_downloading_2.png b/res/wearable/rw_update/images/tw_fota_downloading_2.png new file mode 100644 index 0000000..e9aca8e Binary files /dev/null and b/res/wearable/rw_update/images/tw_fota_downloading_2.png differ diff --git a/res/wearable/rw_update/images/tw_fota_downloading_3.png b/res/wearable/rw_update/images/tw_fota_downloading_3.png new file mode 100644 index 0000000..8538e35 Binary files /dev/null and b/res/wearable/rw_update/images/tw_fota_downloading_3.png differ diff --git a/res/wearable/rw_update/images/tw_fota_downloading_4.png b/res/wearable/rw_update/images/tw_fota_downloading_4.png new file mode 100644 index 0000000..081e84e Binary files /dev/null and b/res/wearable/rw_update/images/tw_fota_downloading_4.png differ diff --git a/res/wearable/rw_update/images/tw_fota_downloading_5.png b/res/wearable/rw_update/images/tw_fota_downloading_5.png new file mode 100644 index 0000000..f015a4e Binary files /dev/null and b/res/wearable/rw_update/images/tw_fota_downloading_5.png differ diff --git a/res/wearable/rw_update/images/tw_fota_downloading_6.png b/res/wearable/rw_update/images/tw_fota_downloading_6.png new file mode 100644 index 0000000..d548f5e Binary files /dev/null and b/res/wearable/rw_update/images/tw_fota_downloading_6.png differ diff --git a/res/wearable/rw_update/images/tw_fota_downloading_7.png b/res/wearable/rw_update/images/tw_fota_downloading_7.png new file mode 100644 index 0000000..023aa8e Binary files /dev/null and b/res/wearable/rw_update/images/tw_fota_downloading_7.png differ diff --git a/res/wearable/rw_update/images/tw_fota_downloading_8.png b/res/wearable/rw_update/images/tw_fota_downloading_8.png new file mode 100644 index 0000000..37f59ec Binary files /dev/null and b/res/wearable/rw_update/images/tw_fota_downloading_8.png differ diff --git a/res/wearable/rw_update/images/tw_fota_downloading_9.png b/res/wearable/rw_update/images/tw_fota_downloading_9.png new file mode 100644 index 0000000..5350c7d Binary files /dev/null and b/res/wearable/rw_update/images/tw_fota_downloading_9.png differ diff --git a/res/wearable/rw_update/images/tw_fota_downloading_slash.png b/res/wearable/rw_update/images/tw_fota_downloading_slash.png new file mode 100644 index 0000000..459b921 Binary files /dev/null and b/res/wearable/rw_update/images/tw_fota_downloading_slash.png differ diff --git a/res/wearable/rw_update/images/tw_fota_progress_rw_bg.png b/res/wearable/rw_update/images/tw_fota_progress_rw_bg.png new file mode 100644 index 0000000..1292e6a Binary files /dev/null and b/res/wearable/rw_update/images/tw_fota_progress_rw_bg.png differ diff --git a/rw-update-ani-common/CMakeLists.txt b/rw-update-ani-common/CMakeLists.txt new file mode 100644 index 0000000..dbbc8bf --- /dev/null +++ b/rw-update-ani-common/CMakeLists.txt @@ -0,0 +1,63 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(rw-update-ani-common C) + +#set( CMAKE_VERBOSE_MAKEFILE on ) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(BINDIR "${PREFIX}/bin") +SET(LIBDIR "\${prefix}/lib") +SET(INCLUDEDIR "\${prefix}/include") +SET(EDJDIR "\${prefix}/share/edje") +SET(VERSION 0.1) +SET(PKGDIR "${PREFIX}/share") +SET(RESDIR "${PKGDIR}/res") +SET(RESDIR_COMMON "${PKGDIR}/fota/res/images_common") + +#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(pkgs_ani REQUIRED + libtbm + libtdm + libpng +) +SET(GUI_SRCS + fota_gui_rw_common_main.c + fota_gr_rw_common.c + fota_png.c + fota_gui_util.c + fota_gr_direct_rw_common.c + tdm-if.c +) + +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") +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(${PROJECT_NAME} ${GUI_SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${gui_pkgs_LDFLAGS} ${LIBS} -lpthread) + +ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"") +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR}) +#INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/images DESTINATION ${RESDIR_COMMON}) diff --git a/rw-update-ani-common/fota_fbinfo.h b/rw-update-ani-common/fota_fbinfo.h new file mode 100644 index 0000000..6b73ed8 --- /dev/null +++ b/rw-update-ani-common/fota_fbinfo.h @@ -0,0 +1,33 @@ +/* + * firmware-update-system-ui + * + * 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__ */ + diff --git a/rw-update-ani-common/fota_gr_direct_rw_common.c b/rw-update-ani-common/fota_gr_direct_rw_common.c new file mode 100644 index 0000000..1292166 --- /dev/null +++ b/rw-update-ani-common/fota_gr_direct_rw_common.c @@ -0,0 +1,500 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include + +#include "fota_gui_general.h" +#include "fota_png.h" +#include "fota_fbinfo.h" +#include "tdm-if.h" + +#define UNUSED(x) (void)(x) + +#define COLOR_BLACK 0xFF000000 + +#define MAX_PATH 256 +#define MAX_FILE_PATH 512 + +#if !defined(RESDIR) +#define RESDIR "/usr/share/res" +#endif +#define IMG_BASE RESDIR "/images/" + +#define MAIN_IMG_NAME "common_base_rect_bg.png" +#define MAIN_TEXT_NAME "common_rw_bg_text.png" +#define MAIN_PG_IMG_NAME "common_progress_bar.png" +#define PROGRESS_BAR_IMG_PREFIX "common_progress_" +#define PROGRESS_NUM_PREFIX "common_downloading_" +#define PERCENT_IMG_NAME "common_downloading_percent.png" + +/***************************************************************************** +** global variables +*****************************************************************************/ +const int x_offset_main_bg_text_pos = 518; +const int y_offset_main_bg_text_pos = 300; +const int x_offset_prog_bar_img_pos = 240; +const int y_offset_prog_bar_img_pos = 355; + +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 = 588; + img_y = 395; + + if (percent < 10) + img_x += 7; + else if (percent < 100) + img_x += 14; + else if (percent == 100) + img_x += 21; + + 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 += 14; + 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 += 14; + 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 += 13; + + 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, 610, 395, 65, 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 = x_offset_prog_bar_img_pos; + img_y = y_offset_prog_bar_img_pos; + + 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(); + + if (read_png_file(IMG_BASE MAIN_TEXT_NAME) < 0) + return; + + img_x = x_offset_main_bg_text_pos; + img_y = y_offset_main_bg_text_pos; + + 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_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, 240, 355); + 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_progress(void) +{ + LOG("fota_gr_direct_progress progress : %d \n", s_percent_to_draw); + + if (s_percent_to_draw > 0) { + _gr_direct_progress_bar(&s_fbi, s_percent_to_draw); + _gr_direct_draw_prog_text(&s_fbi, s_saved_percent); + } else if (s_percent_to_draw == 0) { + s_saved_percent = 0; + } + _gr_direct_update_screen(); +} + +static int total = 0; +void fota_gr_direct_rw_update_progress(void) +{ + + 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) + 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) + LOG("Error occurs at reading progress"); + if (progress < 0) + progress = 0; + if (progress > total) + progress = total; + fclose(fp); + } else + progress = 0; + } + + if (total == 0) + s_percent_to_draw = 0; + else + s_percent_to_draw = 100 * progress / total; + + if (s_saved_percent < s_percent_to_draw) { + LOG("s_saved_percent %d , s_percent_to_draw %d \n", s_saved_percent, s_percent_to_draw); + fota_gr_direct_progress(); + } +} + +/*----------------------------------------------------------------------------- + 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); +} + diff --git a/rw-update-ani-common/fota_gr_direct_rw_common.h b/rw-update-ani-common/fota_gr_direct_rw_common.h new file mode 100644 index 0000000..406deb7 --- /dev/null +++ b/rw-update-ani-common/fota_gr_direct_rw_common.h @@ -0,0 +1,31 @@ +/* + * firmware-update-system-ui + * + * 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_RW_COMMOM_H__ +#define __FOTA_GR_DIRECT_RW_COMMOM_H__ + +#include "fota_gui_general.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); +extern void fota_gr_direct_rw_update_progress(void); + + +#endif /* __FOTA_GR_DIRECT_RW_COMMOM_H__ */ diff --git a/rw-update-ani-common/fota_gr_rw_common.c b/rw-update-ani-common/fota_gr_rw_common.c new file mode 100644 index 0000000..4c1c0dc --- /dev/null +++ b/rw-update-ani-common/fota_gr_rw_common.c @@ -0,0 +1,74 @@ +/* + * firmware-update-system-ui + * + * 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_rw_common.h" +#if defined(USE_CAIRO) +#include "fota_gr_cairo.h" +#else +#include "fota_gr_direct_rw_common.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(void) +{ +#if defined(USE_CAIRO) + fota_gr_cairo_update_progress(percent); +#else + //fota_gr_direct_update_progress(percent); + fota_gr_direct_rw_update_progress(); +#endif +} + diff --git a/rw-update-ani-common/fota_gr_rw_common.h b/rw-update-ani-common/fota_gr_rw_common.h new file mode 100644 index 0000000..d2d49f1 --- /dev/null +++ b/rw-update-ani-common/fota_gr_rw_common.h @@ -0,0 +1,28 @@ +/* + * firmware-update-system-ui + * + * 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_RW_COMMON_H__ +#define __FOTA_GR_RW_COMMON_H__ + +extern int fota_gr_init(void); +extern void fota_gr_deinit(void); +extern void fota_gr_update_progress(void); +extern void fota_gr_clear_screen(unsigned int color); + +#endif /* __FOTA_GR_RW_COMMON_H__ */ + diff --git a/rw-update-ani-common/fota_gui_general.h b/rw-update-ani-common/fota_gui_general.h new file mode 100644 index 0000000..aa84309 --- /dev/null +++ b/rw-update-ani-common/fota_gui_general.h @@ -0,0 +1,43 @@ +/* + * firmware-update-system-ui + * + * 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_GENERAL_H__ +#define __FOTA_GUI_GENERAL_H__ + + +#include +#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_GENERAL_H__ */ diff --git a/rw-update-ani-common/fota_gui_log.h b/rw-update-ani-common/fota_gui_log.h new file mode 100644 index 0000000..b41a6d1 --- /dev/null +++ b/rw-update-ani-common/fota_gui_log.h @@ -0,0 +1,74 @@ +/* + * firmware-update-system-ui + * + * 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 + +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_RW" + +#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__ */ + diff --git a/rw-update-ani-common/fota_gui_rw_common_main.c b/rw-update-ani-common/fota_gui_rw_common_main.c new file mode 100644 index 0000000..a7be28c --- /dev/null +++ b/rw-update-ani-common/fota_gui_rw_common_main.c @@ -0,0 +1,115 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fota_gui_general.h" +#include "fota_gr_rw_common.h" + +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; + + +#define CMD_SUCCESS 0 +#define CMD_ERROR -1 +#define MISSING_PARAM -2 + +int do_exit = 0; + +int s_pid = -1; + + +static int wait_ani_main_solis(void) +{ + 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_update_progress(); + } + + fota_gr_deinit(); + + return 0; +} + +int main(int argc, char **argv) +{ + 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} + }; + + opt = getopt_long(argc, argv, "", options, &index); + if (opt == -1) { + LOGE("getopt_long failed\n"); + return 0; + } + + switch (index) { + case 0: { + int ret = wait_ani_main_solis(); + return ret; + } + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + default: + break; + } + + return 0; +} diff --git a/rw-update-ani-common/fota_gui_util.c b/rw-update-ani-common/fota_gui_util.c new file mode 100644 index 0000000..5d7d480 --- /dev/null +++ b/rw-update-ani-common/fota_gui_util.c @@ -0,0 +1,81 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} + diff --git a/rw-update-ani-common/fota_gui_util.h b/rw-update-ani-common/fota_gui_util.h new file mode 100644 index 0000000..235a9e0 --- /dev/null +++ b/rw-update-ani-common/fota_gui_util.h @@ -0,0 +1,26 @@ +/* + * firmware-update-system-ui + * + * 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_ */ + diff --git a/rw-update-ani-common/fota_png.c b/rw-update-ani-common/fota_png.c new file mode 100644 index 0000000..88f6e86 --- /dev/null +++ b/rw-update-ani-common/fota_png.c @@ -0,0 +1,455 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include "fota_gui_general.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); +} diff --git a/rw-update-ani-common/fota_png.h b/rw-update-ani-common/fota_png.h new file mode 100644 index 0000000..4a8ce34 --- /dev/null +++ b/rw-update-ani-common/fota_png.h @@ -0,0 +1,31 @@ +/* + * firmware-update-system-ui + * + * 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__ */ diff --git a/rw-update-ani-common/tdm-if.c b/rw-update-ani-common/tdm-if.c new file mode 100644 index 0000000..4d15710 --- /dev/null +++ b/rw-update-ani-common/tdm-if.c @@ -0,0 +1,319 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fota_gui_general.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 + || output_type == TDM_OUTPUT_TYPE_HDMIA) + && (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 ; +} diff --git a/rw-update-ani-common/tdm-if.h b/rw-update-ani-common/tdm-if.h new file mode 100644 index 0000000..dc67910 --- /dev/null +++ b/rw-update-ani-common/tdm-if.h @@ -0,0 +1,74 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include + +#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__ */ diff --git a/rw-update-ani-wearable/CMakeLists.txt b/rw-update-ani-wearable/CMakeLists.txt new file mode 100644 index 0000000..0fdf5d4 --- /dev/null +++ b/rw-update-ani-wearable/CMakeLists.txt @@ -0,0 +1,61 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(rw-update-ani-wearable 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") +SET(RESDIR_WEARABLE "${RESDIR}/images_wearable") + +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}\"") +ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS_ANI}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_ani_LDFLAGS}) + + +INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME} DESTINATION bin) +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/wearable/rw_update/images DESTINATION ${RESDIR_WEARABLE}) diff --git a/rw-update-ani-wearable/rw-update-ani_new.c b/rw-update-ani-wearable/rw-update-ani_new.c new file mode 100644 index 0000000..8651862 --- /dev/null +++ b/rw-update-ani-wearable/rw-update-ani_new.c @@ -0,0 +1,420 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CAIRO_LIB +#include "rw-update_new_cairo.h" +#endif +#include +#include + +#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; +} + diff --git a/rw-update-ani-wearable/rw-update-ani_new.h b/rw-update-ani-wearable/rw-update-ani_new.h new file mode 100644 index 0000000..909a875 --- /dev/null +++ b/rw-update-ani-wearable/rw-update-ani_new.h @@ -0,0 +1,25 @@ +/* + * firmware-update-system-ui + * + * 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__ */ + diff --git a/rw-update-ani-wearable/rw-update-log.h b/rw-update-ani-wearable/rw-update-log.h new file mode 100644 index 0000000..5db56ce --- /dev/null +++ b/rw-update-ani-wearable/rw-update-log.h @@ -0,0 +1,105 @@ +/* + * firmware-update-system-ui + * + * 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 +#include + +#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_RW" + +#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__ */ + diff --git a/rw-update-ani-wearable/rw-update_new_cairo.h b/rw-update-ani-wearable/rw-update_new_cairo.h new file mode 100644 index 0000000..37a6c59 --- /dev/null +++ b/rw-update-ani-wearable/rw-update_new_cairo.h @@ -0,0 +1,49 @@ +/* + * firmware-update-system-ui + * + * 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 + +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__ */ diff --git a/rw-update-ani-wearable/rw-update_new_cairo_w_360_360.c b/rw-update-ani-wearable/rw-update_new_cairo_w_360_360.c new file mode 100644 index 0000000..b4c93df --- /dev/null +++ b/rw-update-ani-wearable/rw-update_new_cairo_w_360_360.c @@ -0,0 +1,488 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#define _USE_MATH_DEFINES +#include + +#include "rw-update_new_common.h" +#include "rw-update_new_fb.h" +#include "rw-update_new_cairo.h" + +#include +#include +#include +#include +#include +#include +#include + +#include // 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 "tw_fota_progress_rw_bg.png" +#define PROGRESS_NUM_PREFIX "tw_fota_downloading_" +#define SLASH_IMG_NAME "tw_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; +} diff --git a/rw-update-ani-wearable/rw-update_new_common.h b/rw-update-ani-wearable/rw-update_new_common.h new file mode 100644 index 0000000..67b0708 --- /dev/null +++ b/rw-update-ani-wearable/rw-update_new_common.h @@ -0,0 +1,74 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include + +#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__ */ diff --git a/rw-update-ani-wearable/rw-update_new_common_display.h b/rw-update-ani-wearable/rw-update_new_common_display.h new file mode 100644 index 0000000..5f6c089 --- /dev/null +++ b/rw-update-ani-wearable/rw-update_new_common_display.h @@ -0,0 +1,84 @@ +/* + * firmware-update-system-ui + * + * 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 +#include + +#include +#include +#include + +#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__ */ diff --git a/rw-update-ani-wearable/rw-update_new_fb.h b/rw-update-ani-wearable/rw-update_new_fb.h new file mode 100644 index 0000000..0b69381 --- /dev/null +++ b/rw-update-ani-wearable/rw-update_new_fb.h @@ -0,0 +1,48 @@ +/* + * firmware-update-system-ui + * + * 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__ */ diff --git a/rw-update-ani-wearable/rw-update_new_fb_cairo.c b/rw-update-ani-wearable/rw-update_new_fb_cairo.c new file mode 100644 index 0000000..28ed992 --- /dev/null +++ b/rw-update-ani-wearable/rw-update_new_fb_cairo.c @@ -0,0 +1,256 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include "rw-update-ani_new.h" +#include "rw-update_new_common.h" +#include "rw-update_new_fb.h" +#include +#include + +#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 diff --git a/rw-update-ani-wearable/rw-update_new_tdm_display.c b/rw-update-ani-wearable/rw-update_new_tdm_display.c new file mode 100644 index 0000000..183ba12 --- /dev/null +++ b/rw-update-ani-wearable/rw-update_new_tdm_display.c @@ -0,0 +1,467 @@ +/* + * firmware-update-system-ui + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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 + || output_type == TDM_OUTPUT_TYPE_HDMIA) && + (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; +} diff --git a/rw-update-ani/CMakeLists.txt b/rw-update-ani/CMakeLists.txt deleted file mode 100644 index 845d479..0000000 --- a/rw-update-ani/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -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}) diff --git a/rw-update-ani/rw-update-ani_new.c b/rw-update-ani/rw-update-ani_new.c deleted file mode 100644 index c5f1421..0000000 --- a/rw-update-ani/rw-update-ani_new.c +++ /dev/null @@ -1,420 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef CAIRO_LIB -#include "rw-update_new_cairo.h" -#endif -#include -#include - -#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; -} - diff --git a/rw-update-ani/rw-update-ani_new.h b/rw-update-ani/rw-update-ani_new.h deleted file mode 100644 index d88eb2e..0000000 --- a/rw-update-ani/rw-update-ani_new.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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__ */ - diff --git a/rw-update-ani/rw-update-log.h b/rw-update-ani/rw-update-log.h deleted file mode 100644 index 023d15a..0000000 --- a/rw-update-ani/rw-update-log.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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 -#include - -#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__ */ - diff --git a/rw-update-ani/rw-update_new_cairo.h b/rw-update-ani/rw-update_new_cairo.h deleted file mode 100644 index a52592c..0000000 --- a/rw-update-ani/rw-update_new_cairo.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 - -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__ */ diff --git a/rw-update-ani/rw-update_new_cairo_w_360_360.c b/rw-update-ani/rw-update_new_cairo_w_360_360.c deleted file mode 100644 index 24ca7f9..0000000 --- a/rw-update-ani/rw-update_new_cairo_w_360_360.c +++ /dev/null @@ -1,491 +0,0 @@ -/* - * 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 -#include -#include -#include -#define _USE_MATH_DEFINES -#include - -#include "rw-update_new_common.h" -#include "rw-update_new_fb.h" -#include "rw-update_new_cairo.h" - -#include -#include -#include -#include -#include -#include -#include - -#include // 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; -} diff --git a/rw-update-ani/rw-update_new_common.h b/rw-update-ani/rw-update_new_common.h deleted file mode 100644 index 77bf179..0000000 --- a/rw-update-ani/rw-update_new_common.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 -#include -#include -#include - -#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__ */ diff --git a/rw-update-ani/rw-update_new_common_display.h b/rw-update-ani/rw-update_new_common_display.h deleted file mode 100644 index 456e184..0000000 --- a/rw-update-ani/rw-update_new_common_display.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 -#include - -#include -#include -#include - -#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__ */ diff --git a/rw-update-ani/rw-update_new_fb.h b/rw-update-ani/rw-update_new_fb.h deleted file mode 100644 index 58ef866..0000000 --- a/rw-update-ani/rw-update_new_fb.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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__ */ diff --git a/rw-update-ani/rw-update_new_fb_cairo.c b/rw-update-ani/rw-update_new_fb_cairo.c deleted file mode 100644 index b01631a..0000000 --- a/rw-update-ani/rw-update_new_fb_cairo.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * 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 -#include -#include "rw-update-ani_new.h" -#include "rw-update_new_common.h" -#include "rw-update_new_fb.h" -#include -#include - -#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 diff --git a/rw-update-ani/rw-update_new_tdm_display.c b/rw-update-ani/rw-update_new_tdm_display.c deleted file mode 100644 index a8ff0f7..0000000 --- a/rw-update-ani/rw-update_new_tdm_display.c +++ /dev/null @@ -1,465 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#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; -}