--- /dev/null
+/*
+ * 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 __FBINFO_H__
+#define __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 /* __FBINFO_H__ */
+
--- /dev/null
+/*
+ * 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 <stdlib.h>
+#include <png.h>
+#include "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_img_original()
+ ----------------------------------------------------------------------------*/
+void draw_png_img_original(void *fbi, int x1, int y1, int fbi_w, int fbi_h, int fbi_stride)
+{
+ unsigned int *fb_buf_cur = NULL;
+ int bpp;
+ int x, y;
+ int end_width, end_height;
+ /* temp patch - lcd resoultion for qualcomm */
+
+ fb_buf_cur = (unsigned int *)fbi;
+
+ /* check out range */
+ if ((x1 > fbi_w ) || (y1 > fbi_h)) {
+ LOG("[draw_png_img_xy] output range exceeds frame buffer range \n");
+ return;
+ }
+ if(x1 + png_img_width > fbi_w)
+ end_width = fbi_w- x1;
+ else
+ end_width = png_img_width;
+ if(y1 + png_img_height > fbi_h)
+ end_height = fbi_h - y1;
+ else
+ end_height = png_img_height;
+
+ 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 */
+ for (y = 0; y < png_img_height; y++) {
+ if(y > end_height) continue;
+ fb_buf_cur = (unsigned int *) (fbi + ((y1 + y) * fbi_stride));
+ fb_buf_cur += x1;
+ png_byte *row = (png_byte *) row_pointers[y];
+ for (x = 0; x < png_img_width; x++) {
+ if(x > end_width) continue;
+ 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++;
+ }
+ }
+
+}
+
+
+/*-----------------------------------------------------------------------------
+ draw_png_mask_xy()
+ - draw pixel only when alpha>0 of given png image
+ ----------------------------------------------------------------------------*/
+void draw_png_mask_xy(FbInfo *fbi, int x1, int y1, char r, char g, char b)
+{
+ unsigned int *fb_buf_cur = NULL;
+ int bpp;
+ int x, y;
+ /* temp patch - lcd resoultion for qualcomm */
+
+ fb_buf_cur = (unsigned int *)fbi->buf[0];
+
+ /* check out range */
+ if ((x1 + png_img_width > fbi->w) ||
+ (y1 + png_img_height > fbi->h)) {
+ LOG("[draw_png_img_xy] output range exceeds frame buffer range \n");
+ return;
+ }
+
+ if (png_color_type == PNG_COLOR_TYPE_RGB) {
+ bpp = 3;
+ LOG("[draw_png_img_xy] PNG_COLOR_TYPE_RGB : no mask channel \n");
+ return;
+ } else if (png_color_type == PNG_COLOR_TYPE_RGBA)
+ bpp = 4;
+ else {
+ LOG("[draw_png_img_xy] png type does not match RGB or RGBA \n");
+ return;
+ }
+ /* temp patch - lcd resoultion for qualcomm */
+ fb_buf_cur += (y1 * (fbi->w));
+ fb_buf_cur += x1;
+ for (y = 0; y < png_img_height; y++) {
+ png_byte *row = (png_byte *) row_pointers[y];
+ for (x = 0; x < png_img_width; x++) {
+ if (bpp == 4) {
+ if (png_bit_depth == 8) {
+ if (row[3] != 0) {
+ (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
+ (r << 16) | (g << 8) | (b);
+ }
+ row += bpp;
+ } else if (png_bit_depth == 16) {
+ if (row[6] != 0) {
+ (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
+ (r << 16) | (g << 8) | (b);
+ }
+ row += bpp*2;
+ }
+ }
+ fb_buf_cur++;
+ }
+ fb_buf_cur -= png_img_width;
+ fb_buf_cur += fbi->w;/* temp patch - lcd resoultion for qualcomm */
+ }
+
+}
+
+/*-----------------------------------------------------------------------------
+ release_png_res()
+ ----------------------------------------------------------------------------*/
+void release_png_res(void)
+{
+ int y;
+
+ for (y = 0; y < png_img_height; y++)
+ free((void *)row_pointers[y]);
+ free((void *)row_pointers);
+
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+}
--- /dev/null
+/*
+ * 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 "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_original(void *fbi, int x1, int y1, int fbi_w, int fbi_h, int fbi_stride);
+extern void draw_png_img_clip_xy(FbInfo *fbi, int x1, int y1, int cx, int cy, int cw, int ch);
+extern void draw_png_mask_xy(FbInfo *fbi, int x1, int y1, char r, char g, char b);
+extern void release_png_res(void);
+
+
+#endif /* __FOTA_PNG_H__ */
--- /dev/null
+/*
+ * 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 __GUI_GENERAL_H__
+#define __GUI_GENERAL_H__
+
+
+#include <stdio.h>
+#include "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 signed long sl32;
+typedef unsigned long ul32;
+
+typedef signed long long s64;
+typedef unsigned long long u64;
+
+
+#endif /* __GUI_GENERAL_H__ */
--- /dev/null
+/*
+ * 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 __GUI_LOG_H__
+#define __GUI_LOG_H__
+
+#include <stdio.h>
+
+extern unsigned int __log_level__;
+extern FILE *__log_out_file__;
+
+#define LOG_INFO (1<<8)
+#define LOG_SSENGINE (1<<7)
+#define LOG_FUNCS (1<<6)
+#define LOG_GUI (1<<5)
+#define LOG_DEBUG (1<<4)
+#define LOG_FILE (1<<3)
+#define LOG_FLASH (1<<2)
+
+#if !defined(LOG_PRFIX)
+#define LOG_PRFIX "FOTA_GUI"
+#endif
+
+#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 /* __GUI_LOG_H__ */
+
--- /dev/null
+/*
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "gui_log.h"
+
+int s_fd_stdin = -1;
+int s_fd_stdout = -1;
+int s_fd_stderr = -1;
+
+/*-----------------------------------------------------------------------------
+ set_default_stdio
+ ----------------------------------------------------------------------------*/
+static int set_default_stdio(int flags, int nfd)
+{
+ int fd, r;
+
+ fd = open("/dev/null", flags|O_NOCTTY);
+ if (fd < 0)
+ return -errno;
+
+ if (fd == nfd) {
+ return fd;
+ } else {
+ r = dup2(fd, nfd) < 0 ? -errno : nfd;
+ close(fd);
+ return r;
+ }
+}
+
+/*-----------------------------------------------------------------------------
+ _init_stdio
+ ----------------------------------------------------------------------------*/
+void _init_stdio(void)
+{
+ s_fd_stdin = set_default_stdio(O_RDONLY, STDIN_FILENO);
+
+ s_fd_stdout = set_default_stdio(O_WRONLY, STDOUT_FILENO);
+
+ s_fd_stderr = set_default_stdio(O_WRONLY, STDERR_FILENO);
+}
+
+/*-----------------------------------------------------------------------------
+ _exit_stdio
+ ----------------------------------------------------------------------------*/
+void _exit_stdio(void)
+{
+ if (s_fd_stdin >= 0)
+ close(s_fd_stdin);
+
+ if (s_fd_stdout >= 0)
+ close(s_fd_stdout);
+
+ if (s_fd_stderr >= 0)
+ close(s_fd_stderr);
+}
+
--- /dev/null
+/*
+ * 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 _GUI_UTIL_H_
+#define _GUI_UTIL_H_
+
+extern void _init_stdio(void);
+extern void _exit_stdio(void);
+
+#endif /* _GUI_UTIL_H_ */
+
--- /dev/null
+/*
+ * 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 <stdbool.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/poll.h>
+#include <sys/time.h>
+#include "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 ;
+}
--- /dev/null
+/*
+ * 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 <tdm.h>
+#include <tbm_bufmgr.h>
+#include <tdm_helper.h>
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
+
+#define MAX_BUF 2
+#define RGB32_BPP 32
+#define RGB32_PITCH 4
+
+typedef struct _tdm_if_disp {
+ tdm_display *disp;
+ tdm_output *output;
+ tdm_layer *layer;
+ tdm_pp *pp;
+ int tdm_fd;
+ int drm_fd;
+
+ tbm_surface_h surf[MAX_BUF];
+ tbm_surface_h pp_surf[MAX_BUF];
+ tbm_bufmgr bufmgr;
+ unsigned int handle[MAX_BUF];
+ unsigned int pp_handle[MAX_BUF];
+ tbm_bo bo[MAX_BUF];
+ tbm_bo_handle bo_handle[MAX_BUF];
+ tbm_bo pp_bo[MAX_BUF];
+ tbm_bo_handle pp_bo_handle[MAX_BUF];
+ void *buffer[MAX_BUF];
+ void *pp_buffer[MAX_BUF];
+ int buffer_size;
+ int width;
+ int height;
+ int stride;
+ int current_buf_id;
+
+ bool use_tdm_hwc;
+ tdm_hwc *hwc;
+} tdm_if_disp;
+
+typedef enum {
+ FRONT_BUFFER = 0,
+ BACK_BUFFER
+} BUFFER_TYPE;
+
+extern tdm_if_disp s_disp;
+
+int tdm_if_display_init(tdm_if_disp *st_disp);
+void tdm_if_display_deinit(tdm_if_disp *st_disp);
+void tdm_if_display_update(tdm_if_disp *st_disp);
+void tdm_if_lcd_on(tdm_if_disp *st_disp);
+void tdm_if_lcd_suspend(tdm_if_disp *st_disp);
+void tdm_if_lcd_off(tdm_if_disp *st_disp);
+#endif /* __TDM_IF_H__ */
STRING(FIND ${CMAKE_C_FLAGS} "mhard-float" IFFOUND2)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+SET(BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../base)
+INCLUDE_DIRECTORIES(${BASE_DIR})
IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
SET(CMAKE_BUILD_TYPE "Release")
libtdm
libpng
)
+SET(BASE_SRCS
+ ${BASE_DIR}/fota_png.c
+ ${BASE_DIR}/gui_util.c
+ ${BASE_DIR}/tdm-if.c
+)
SET(GUI_SRCS
+ ${BASE_SRCS}
fota_gui_ro_common_main.c
fota_gr_ro_common.c
- fota_png.c
- fota_gui_util.c
- tdm-if.c
)
+MESSAGE(${GUI_SRCS})
FOREACH(flag ${gui_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
ADD_DEFINITIONS("-DROTATE=0")
+ADD_DEFINITIONS("-DLOG_PRFIX=\"FOTA_RO\"")
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/images DESTINATION ${RESDIR_COMMON})
INSTALL(TARGETS ${FOTA_GUI_COMMON} DESTINATION ${BINDIR})
+++ /dev/null
-/*
- * 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__ */
-
#include <unistd.h>
#include <pixman.h>
-#include "fota_gui_general.h"
+#include "gui_general.h"
#include "fota_png.h"
-#include "fota_fbinfo.h"
+#include "fbinfo.h"
#include "tdm-if.h"
#define UNUSED(x) (void)(x)
#ifndef __FOTA_GR_DIRECT_RO_COMMON_H__
#define __FOTA_GR_DIRECT_RO_COMMON_H__
-#include "fota_gui_general.h"
+#include "gui_general.h"
extern int fota_gr_direct_init(void);
extern void fota_gr_direct_deinit(void);
+++ /dev/null
-/*
- * 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 <stdio.h>
-#include "fota_gui_log.h"
-
-typedef signed char s8;
-typedef unsigned char u8;
-
-typedef signed short s16;
-typedef unsigned short u16;
-
-typedef signed int s32;
-typedef unsigned int u32;
-
-typedef signed long sl32;
-typedef unsigned long ul32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-
-#endif /* __FOTA_GUI_GENERAL_H__ */
+++ /dev/null
-/*
- * 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 <stdio.h>
-
-extern unsigned int __log_level__;
-extern FILE *__log_out_file__;
-
-#define LOG_INFO (1<<8)
-#define LOG_SSENGINE (1<<7)
-#define LOG_FUNCS (1<<6)
-#define LOG_GUI (1<<5)
-#define LOG_DEBUG (1<<4)
-#define LOG_FILE (1<<3)
-#define LOG_FLASH (1<<2)
-
-#define LOG_PRFIX "FOTA_GUI_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__ */
-
#include <sys/time.h>
#include <sys/resource.h>
-#include "fota_gui_general.h"
-#include "fota_gui_util.h"
+#include "gui_general.h"
+#include "gui_util.h"
#include "fota_gr_ro_common.h"
//#define WAIT
+++ /dev/null
-/*
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include "fota_gui_log.h"
-
-int s_fd_stdin = -1;
-int s_fd_stdout = -1;
-int s_fd_stderr = -1;
-
-/*-----------------------------------------------------------------------------
- set_default_stdio
- ----------------------------------------------------------------------------*/
-static int set_default_stdio(int flags, int nfd)
-{
- int fd, r;
-
- fd = open("/dev/null", flags|O_NOCTTY);
- if (fd < 0)
- return -errno;
-
- if (fd == nfd) {
- return fd;
- } else {
- r = dup2(fd, nfd) < 0 ? -errno : nfd;
- close(fd);
- return r;
- }
-}
-
-/*-----------------------------------------------------------------------------
- _init_stdio
- ----------------------------------------------------------------------------*/
-void _init_stdio(void)
-{
- s_fd_stdin = set_default_stdio(O_RDONLY, STDIN_FILENO);
-
- s_fd_stdout = set_default_stdio(O_WRONLY, STDOUT_FILENO);
-
- s_fd_stderr = set_default_stdio(O_WRONLY, STDERR_FILENO);
-}
-
-/*-----------------------------------------------------------------------------
- _exit_stdio
- ----------------------------------------------------------------------------*/
-void _exit_stdio(void)
-{
- if (s_fd_stdin >= 0)
- close(s_fd_stdin);
-
- if (s_fd_stdout >= 0)
- close(s_fd_stdout);
-
- if (s_fd_stderr >= 0)
- close(s_fd_stderr);
-}
-
+++ /dev/null
-/*
- * 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_ */
-
+++ /dev/null
-/*
- * 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 <stdlib.h>
-#include <png.h>
-#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_img_original()
- ----------------------------------------------------------------------------*/
-void draw_png_img_original(void *fbi, int x1, int y1, int fbi_w, int fbi_h, int fbi_stride)
-{
- unsigned int *fb_buf_cur = NULL;
- int bpp;
- int x, y;
- int end_width, end_height;
- /* temp patch - lcd resoultion for qualcomm */
-
- fb_buf_cur = (unsigned int *)fbi;
-
- /* check out range */
- if ((x1 > fbi_w ) || (y1 > fbi_h)) {
- LOG("[draw_png_img_xy] output range exceeds frame buffer range \n");
- return;
- }
- if(x1 + png_img_width > fbi_w)
- end_width = fbi_w- x1;
- else
- end_width = png_img_width;
- if(y1 + png_img_height > fbi_h)
- end_height = fbi_h - y1;
- else
- end_height = png_img_height;
-
- 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 */
- for (y = 0; y < png_img_height; y++) {
- if(y > end_height) continue;
- fb_buf_cur = (unsigned int *) (fbi + ((y1 + y) * fbi_stride));
- fb_buf_cur += x1;
- png_byte *row = (png_byte *) row_pointers[y];
- for (x = 0; x < png_img_width; x++) {
- if(x > end_width) continue;
- 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++;
- }
- }
-
-}
-
-
-/*-----------------------------------------------------------------------------
- draw_png_mask_xy()
- - draw pixel only when alpha>0 of given png image
- ----------------------------------------------------------------------------*/
-void draw_png_mask_xy(FbInfo *fbi, int x1, int y1, char r, char g, char b)
-{
- unsigned int *fb_buf_cur = NULL;
- int bpp;
- int x, y;
- /* temp patch - lcd resoultion for qualcomm */
-
- fb_buf_cur = (unsigned int *)fbi->buf[0];
-
- /* check out range */
- if ((x1 + png_img_width > fbi->w) ||
- (y1 + png_img_height > fbi->h)) {
- LOG("[draw_png_img_xy] output range exceeds frame buffer range \n");
- return;
- }
-
- if (png_color_type == PNG_COLOR_TYPE_RGB) {
- bpp = 3;
- LOG("[draw_png_img_xy] PNG_COLOR_TYPE_RGB : no mask channel \n");
- return;
- } else if (png_color_type == PNG_COLOR_TYPE_RGBA)
- bpp = 4;
- else {
- LOG("[draw_png_img_xy] png type does not match RGB or RGBA \n");
- return;
- }
- /* temp patch - lcd resoultion for qualcomm */
- fb_buf_cur += (y1 * (fbi->w));
- fb_buf_cur += x1;
- for (y = 0; y < png_img_height; y++) {
- png_byte *row = (png_byte *) row_pointers[y];
- for (x = 0; x < png_img_width; x++) {
- if (bpp == 4) {
- if (png_bit_depth == 8) {
- if (row[3] != 0) {
- (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
- (r << 16) | (g << 8) | (b);
- }
- row += bpp;
- } else if (png_bit_depth == 16) {
- if (row[6] != 0) {
- (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
- (r << 16) | (g << 8) | (b);
- }
- row += bpp*2;
- }
- }
- fb_buf_cur++;
- }
- fb_buf_cur -= png_img_width;
- fb_buf_cur += fbi->w;/* temp patch - lcd resoultion for qualcomm */
- }
-
-}
-
-/*-----------------------------------------------------------------------------
- release_png_res()
- ----------------------------------------------------------------------------*/
-void release_png_res(void)
-{
- int y;
-
- for (y = 0; y < png_img_height; y++)
- free((void *)row_pointers[y]);
- free((void *)row_pointers);
-
- png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-}
+++ /dev/null
-/*
- * 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_original(void *fbi, int x1, int y1, int fbi_w, int fbi_h, int fbi_stride);
-extern void draw_png_img_clip_xy(FbInfo *fbi, int x1, int y1, int cx, int cy, int cw, int ch);
-extern void draw_png_mask_xy(FbInfo *fbi, int x1, int y1, char r, char g, char b);
-extern void release_png_res(void);
-
-
-#endif /* __FOTA_PNG_H__ */
+++ /dev/null
-/*
- * 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 <stdbool.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/poll.h>
-#include <sys/time.h>
-#include "fota_gui_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 ;
-}
+++ /dev/null
-/*
- * 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 <tdm.h>
-#include <tbm_bufmgr.h>
-#include <tdm_helper.h>
-#include <tbm_surface.h>
-#include <tbm_surface_internal.h>
-
-#define MAX_BUF 2
-#define RGB32_BPP 32
-#define RGB32_PITCH 4
-
-typedef struct _tdm_if_disp {
- tdm_display *disp;
- tdm_output *output;
- tdm_layer *layer;
- tdm_pp *pp;
- int tdm_fd;
- int drm_fd;
-
- tbm_surface_h surf[MAX_BUF];
- tbm_surface_h pp_surf[MAX_BUF];
- tbm_bufmgr bufmgr;
- unsigned int handle[MAX_BUF];
- unsigned int pp_handle[MAX_BUF];
- tbm_bo bo[MAX_BUF];
- tbm_bo_handle bo_handle[MAX_BUF];
- tbm_bo pp_bo[MAX_BUF];
- tbm_bo_handle pp_bo_handle[MAX_BUF];
- void *buffer[MAX_BUF];
- void *pp_buffer[MAX_BUF];
- int buffer_size;
- int width;
- int height;
- int stride;
- int current_buf_id;
-
- bool use_tdm_hwc;
- tdm_hwc *hwc;
-} tdm_if_disp;
-
-typedef enum {
- FRONT_BUFFER = 0,
- BACK_BUFFER
-} BUFFER_TYPE;
-
-extern tdm_if_disp s_disp;
-
-int tdm_if_display_init(tdm_if_disp *st_disp);
-void tdm_if_display_deinit(tdm_if_disp *st_disp);
-void tdm_if_display_update(tdm_if_disp *st_disp);
-void tdm_if_lcd_on(tdm_if_disp *st_disp);
-void tdm_if_lcd_suspend(tdm_if_disp *st_disp);
-void tdm_if_lcd_off(tdm_if_disp *st_disp);
-#endif /* __TDM_IF_H__ */
STRING(FIND ${CMAKE_C_FLAGS} "mhard-float" IFFOUND2)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+SET(BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../base)
+INCLUDE_DIRECTORIES(${BASE_DIR})
IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
SET(CMAKE_BUILD_TYPE "Release")
libtdm
libpng
)
+SET(BASE_SRCS
+ ${BASE_DIR}/fota_png.c
+ ${BASE_DIR}/gui_util.c
+ ${BASE_DIR}/tdm-if.c
+)
SET(GUI_SRCS
+ ${BASE_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})
TARGET_LINK_LIBRARIES(${FOTA_GUI_WEARABLE} ${gui_pkgs_LDFLAGS} ${LIBS} -lpthread)
ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
+ADD_DEFINITIONS("-DLOG_PRFIX=\"FOTA_TW_RO\"")
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/wearable/ro_update/images DESTINATION ${RESDIR_WEARABLE})
INSTALL(TARGETS ${FOTA_GUI_WEARABLE} DESTINATION ${BINDIR})
+++ /dev/null
-/*
- * 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__ */
-
#include <string.h>
#include <unistd.h>
-#include "fota_gui_general.h"
+#include "gui_general.h"
#include "fota_png.h"
-#include "fota_fbinfo.h"
+#include "fbinfo.h"
#include "tdm-if.h"
#define UNUSED(x) (void)(x)
#ifndef __FOTA_GR_DIRECT_RO_WEARABLE_H__
#define __FOTA_GR_DIRECT_RO_WEARABLE_H__
-#include "fota_gui_general.h"
+#include "gui_general.h"
extern int fota_gr_direct_init(void);
extern void fota_gr_direct_deinit(void);
+++ /dev/null
-/*
- * 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 <stdio.h>
-#include "fota_gui_log.h"
-
-typedef signed char s8;
-typedef unsigned char u8;
-
-typedef signed short s16;
-typedef unsigned short u16;
-
-typedef signed int s32;
-typedef unsigned int u32;
-
-typedef signed long sl32;
-typedef unsigned long ul32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-
-#endif /* __FOTA_GUI_GENERAL_H__ */
+++ /dev/null
-/*
- * 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 <stdio.h>
-
-extern unsigned int __log_level__;
-extern FILE *__log_out_file__;
-
-#define LOG_INFO (1<<8)
-#define LOG_SSENGINE (1<<7)
-#define LOG_FUNCS (1<<6)
-#define LOG_GUI (1<<5)
-#define LOG_DEBUG (1<<4)
-#define LOG_FILE (1<<3)
-#define LOG_FLASH (1<<2)
-
-#define LOG_PRFIX "FOTA_GUI_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__ */
-
#include <sys/time.h>
#include <sys/resource.h>
-#include "fota_gui_general.h"
-#include "fota_gui_util.h"
+#include "gui_general.h"
+#include "gui_util.h"
#include "fota_gr_ro_wearable.h"
//#define WAIT
+++ /dev/null
-/*
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include "fota_gui_log.h"
-
-int s_fd_stdin = -1;
-int s_fd_stdout = -1;
-int s_fd_stderr = -1;
-
-/*-----------------------------------------------------------------------------
- set_default_stdio
- ----------------------------------------------------------------------------*/
-static int set_default_stdio(int flags, int nfd)
-{
- int fd, r;
-
- fd = open("/dev/null", flags|O_NOCTTY);
- if (fd < 0)
- return -errno;
-
- if (fd == nfd) {
- return fd;
- } else {
- r = dup2(fd, nfd) < 0 ? -errno : nfd;
- close(fd);
- return r;
- }
-}
-
-/*-----------------------------------------------------------------------------
- _init_stdio
- ----------------------------------------------------------------------------*/
-void _init_stdio(void)
-{
- s_fd_stdin = set_default_stdio(O_RDONLY, STDIN_FILENO);
-
- s_fd_stdout = set_default_stdio(O_WRONLY, STDOUT_FILENO);
-
- s_fd_stderr = set_default_stdio(O_WRONLY, STDERR_FILENO);
-}
-
-/*-----------------------------------------------------------------------------
- _exit_stdio
- ----------------------------------------------------------------------------*/
-void _exit_stdio(void)
-{
- if (s_fd_stdin >= 0)
- close(s_fd_stdin);
-
- if (s_fd_stdout >= 0)
- close(s_fd_stdout);
-
- if (s_fd_stderr >= 0)
- close(s_fd_stderr);
-}
-
+++ /dev/null
-/*
- * 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_ */
-
+++ /dev/null
-/*
- * 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 <stdlib.h>
-#include <png.h>
-#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);
-}
+++ /dev/null
-/*
- * 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__ */
+++ /dev/null
-/*
- * 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 <stdbool.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/poll.h>
-#include <sys/time.h>
-#include "fota_gui_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 ;
-}
+++ /dev/null
-/*
- * 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 <tdm.h>
-#include <tbm_bufmgr.h>
-#include <tdm_helper.h>
-#include <tbm_surface.h>
-#include <tbm_surface_internal.h>
-
-#define MAX_BUF 2
-#define RGB32_BPP 32
-#define RGB32_PITCH 4
-
-typedef struct _tdm_if_disp {
- tdm_display *disp;
- tdm_output *output;
- tdm_layer *layer;
- tdm_pp *pp;
- int tdm_fd;
- int drm_fd;
-
- tbm_surface_h surf[MAX_BUF];
- tbm_surface_h pp_surf[MAX_BUF];
- tbm_bufmgr bufmgr;
- unsigned int handle[MAX_BUF];
- unsigned int pp_handle[MAX_BUF];
- tbm_bo bo[MAX_BUF];
- tbm_bo_handle bo_handle[MAX_BUF];
- tbm_bo pp_bo[MAX_BUF];
- tbm_bo_handle pp_bo_handle[MAX_BUF];
- void *buffer[MAX_BUF];
- void *pp_buffer[MAX_BUF];
- int buffer_size;
- int width;
- int height;
- int stride;
- int current_buf_id;
-
- bool use_tdm_hwc;
- tdm_hwc *hwc;
-} tdm_if_disp;
-
-typedef enum {
- FRONT_BUFFER = 0,
- BACK_BUFFER
-} BUFFER_TYPE;
-
-extern tdm_if_disp s_disp;
-
-int tdm_if_display_init(tdm_if_disp *st_disp);
-void tdm_if_display_deinit(tdm_if_disp *st_disp);
-void tdm_if_display_update(tdm_if_disp *st_disp);
-void tdm_if_lcd_on(tdm_if_disp *st_disp);
-void tdm_if_lcd_suspend(tdm_if_disp *st_disp);
-void tdm_if_lcd_off(tdm_if_disp *st_disp);
-#endif /* __TDM_IF_H__ */
STRING(FIND ${CMAKE_C_FLAGS} "mhard-float" IFFOUND2)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+SET(BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../base)
+INCLUDE_DIRECTORIES(${BASE_DIR})
IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
SET(CMAKE_BUILD_TYPE "Release")
libtdm
libpng
)
+SET(BASE_SRCS
+ ${BASE_DIR}/gui_util.c
+ ${BASE_DIR}/tdm-if.c
+ ${BASE_DIR}/fota_png.c
+)
SET(GUI_SRCS
+ ${BASE_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})
+++ /dev/null
-/*
- * 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__ */
-
#include <unistd.h>
#include <pixman.h>
-#include "recovery_gui_general.h"
-#include "recovery_png.h"
-#include "recovery_fbinfo.h"
+#include "gui_general.h"
+#include "fota_png.h"
+#include "fbinfo.h"
#include "tdm-if.h"
#define UNUSED(x) (void)(x)
#ifndef __RECOVERY_GR_DIRECT_COMMON_H__
#define __RECOVERY_GR_DIRECT_COMMON_H__
-#include "recovery_gui_general.h"
+#include "gui_general.h"
extern int recovery_gr_direct_init(void);
extern void recovery_gr_direct_deinit(void);
#include <sys/time.h>
#include <sys/resource.h>
-#include "recovery_gui_general.h"
-#include "recovery_gui_util.h"
+#include "gui_general.h"
+#include "gui_util.h"
#include "recovery_gr_common.h"
//#define WAIT
+++ /dev/null
-/*
- * 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 <stdio.h>
-#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 signed long sl32;
-typedef unsigned long ul32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-
-#endif /* __RECOVERY_GUI_GENERAL_H__ */
+++ /dev/null
-/*
- * 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 <stdio.h>
-
-extern unsigned int __log_level__;
-extern FILE *__log_out_file__;
-
-#define LOG_INFO (1<<8)
-#define LOG_SSENGINE (1<<7)
-#define LOG_FUNCS (1<<6)
-#define LOG_GUI (1<<5)
-#define LOG_DEBUG (1<<4)
-#define LOG_FILE (1<<3)
-#define LOG_FLASH (1<<2)
-
-#define LOG_PRFIX "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__ */
-
+++ /dev/null
-/*
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include "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);
-}
-
+++ /dev/null
-/*
- * 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_ */
-
+++ /dev/null
-/*
- * 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 <stdlib.h>
-#include <png.h>
-#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_img_original()
- ----------------------------------------------------------------------------*/
-void draw_png_img_original(void *fbi, int x1, int y1, int fbi_w, int fbi_h, int fbi_stride)
-{
- unsigned int *fb_buf_cur = NULL;
- int bpp;
- int x, y;
- int end_width, end_height;
- /* temp patch - lcd resoultion for qualcomm */
-
- fb_buf_cur = (unsigned int *)fbi;
-
- /* check out range */
- if ((x1 > fbi_w ) || (y1 > fbi_h)) {
- LOG("[draw_png_img_xy] output range exceeds frame buffer range \n");
- return;
- }
- if(x1 + png_img_width > fbi_w)
- end_width = fbi_w- x1;
- else
- end_width = png_img_width;
- if(y1 + png_img_height > fbi_h)
- end_height = fbi_h - y1;
- else
- end_height = png_img_height;
-
- 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 */
- for (y = 0; y < png_img_height; y++) {
- if(y > end_height) continue;
- fb_buf_cur = (unsigned int *) (fbi + ((y1 + y) * fbi_stride));
- fb_buf_cur += x1;
- png_byte *row = (png_byte *) row_pointers[y];
- for (x = 0; x < png_img_width; x++) {
- if(x > end_width) continue;
- 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++;
- }
- }
-
-}
-
-
-/*-----------------------------------------------------------------------------
- draw_png_mask_xy()
- - draw pixel only when alpha>0 of given png image
- ----------------------------------------------------------------------------*/
-void draw_png_mask_xy(FbInfo *fbi, int x1, int y1, char r, char g, char b)
-{
- unsigned int *fb_buf_cur = NULL;
- int bpp;
- int x, y;
- /* temp patch - lcd resoultion for qualcomm */
-
- fb_buf_cur = (unsigned int *)fbi->buf[0];
-
- /* check out range */
- if ((x1 + png_img_width > fbi->w) ||
- (y1 + png_img_height > fbi->h)) {
- LOG("[draw_png_img_xy] output range exceeds frame buffer range \n");
- return;
- }
-
- if (png_color_type == PNG_COLOR_TYPE_RGB) {
- bpp = 3;
- LOG("[draw_png_img_xy] PNG_COLOR_TYPE_RGB : no mask channel \n");
- return;
- } else if (png_color_type == PNG_COLOR_TYPE_RGBA)
- bpp = 4;
- else {
- LOG("[draw_png_img_xy] png type does not match RGB or RGBA \n");
- return;
- }
- /* temp patch - lcd resoultion for qualcomm */
- fb_buf_cur += (y1 * (fbi->w));
- fb_buf_cur += x1;
- for (y = 0; y < png_img_height; y++) {
- png_byte *row = (png_byte *) row_pointers[y];
- for (x = 0; x < png_img_width; x++) {
- if (bpp == 4) {
- if (png_bit_depth == 8) {
- if (row[3] != 0) {
- (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
- (r << 16) | (g << 8) | (b);
- }
- row += bpp;
- } else if (png_bit_depth == 16) {
- if (row[6] != 0) {
- (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
- (r << 16) | (g << 8) | (b);
- }
- row += bpp*2;
- }
- }
- fb_buf_cur++;
- }
- fb_buf_cur -= png_img_width;
- fb_buf_cur += fbi->w;/* temp patch - lcd resoultion for qualcomm */
- }
-
-}
-
-/*-----------------------------------------------------------------------------
- release_png_res()
- ----------------------------------------------------------------------------*/
-void release_png_res(void)
-{
- int y;
-
- for (y = 0; y < png_img_height; y++)
- free((void *)row_pointers[y]);
- free((void *)row_pointers);
-
- png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-}
+++ /dev/null
-/*
- * 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_original(void *fbi, int x1, int y1, int fbi_w, int fbi_h, int fbi_stride);
-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__ */
+++ /dev/null
-/*
- * 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 <stdbool.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/poll.h>
-#include <sys/time.h>
-#include "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 ;
-}
+++ /dev/null
-/*
- * 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 <tdm.h>
-#include <tbm_bufmgr.h>
-#include <tdm_helper.h>
-#include <tbm_surface.h>
-#include <tbm_surface_internal.h>
-
-#define MAX_BUF 2
-#define RGB32_BPP 32
-#define RGB32_PITCH 4
-
-typedef struct _tdm_if_disp {
- tdm_display *disp;
- tdm_output *output;
- tdm_layer *layer;
- tdm_pp *pp;
- int tdm_fd;
- int drm_fd;
-
- tbm_surface_h surf[MAX_BUF];
- tbm_surface_h pp_surf[MAX_BUF];
- tbm_bufmgr bufmgr;
- unsigned int handle[MAX_BUF];
- unsigned int pp_handle[MAX_BUF];
- tbm_bo bo[MAX_BUF];
- tbm_bo_handle bo_handle[MAX_BUF];
- tbm_bo pp_bo[MAX_BUF];
- tbm_bo_handle pp_bo_handle[MAX_BUF];
- void *buffer[MAX_BUF];
- void *pp_buffer[MAX_BUF];
- int buffer_size;
- int width;
- int height;
- int stride;
- int current_buf_id;
-
- bool use_tdm_hwc;
- tdm_hwc *hwc;
-} tdm_if_disp;
-
-typedef enum {
- FRONT_BUFFER = 0,
- BACK_BUFFER
-} BUFFER_TYPE;
-
-extern tdm_if_disp s_disp;
-
-int tdm_if_display_init(tdm_if_disp *st_disp);
-void tdm_if_display_deinit(tdm_if_disp *st_disp);
-void tdm_if_display_update(tdm_if_disp *st_disp);
-void tdm_if_lcd_on(tdm_if_disp *st_disp);
-void tdm_if_lcd_suspend(tdm_if_disp *st_disp);
-void tdm_if_lcd_off(tdm_if_disp *st_disp);
-#endif /* __TDM_IF_H__ */
#STRING(FIND ${CMAKE_C_FLAGS} "mhard-float" IFFOUND2)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+SET(BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../base)
+INCLUDE_DIRECTORIES(${BASE_DIR})
IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
SET(CMAKE_BUILD_TYPE "Release")
libtdm
libpng
)
+
+SET(BASE_SRCS
+ ${BASE_DIR}/fota_png.c
+ ${BASE_DIR}/gui_util.c
+ ${BASE_DIR}/tdm-if.c
+)
SET(GUI_SRCS
+ ${BASE_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})
ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
ADD_DEFINITIONS("-DROTATE=0")
+ADD_DEFINITIONS("-DLOG_PRFIX=\"FOTA_RW\"")
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
#INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/images DESTINATION ${RESDIR_COMMON})
+++ /dev/null
-/*
- * 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__ */
-
#include <unistd.h>
#include <pixman.h>
-#include "fota_gui_general.h"
+#include "gui_general.h"
#include "fota_png.h"
-#include "fota_fbinfo.h"
+#include "fbinfo.h"
#include "tdm-if.h"
#define UNUSED(x) (void)(x)
#ifndef __FOTA_GR_DIRECT_RW_COMMOM_H__
#define __FOTA_GR_DIRECT_RW_COMMOM_H__
-#include "fota_gui_general.h"
+#include "gui_general.h"
extern int fota_gr_direct_init(void);
extern void fota_gr_direct_deinit(void);
+++ /dev/null
-/*
- * 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 <stdio.h>
-#include "fota_gui_log.h"
-
-typedef signed char s8;
-typedef unsigned char u8;
-
-typedef signed short s16;
-typedef unsigned short u16;
-
-typedef signed int s32;
-typedef unsigned int u32;
-
-typedef signed long sl32;
-typedef unsigned long ul32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-
-#endif /* __FOTA_GUI_GENERAL_H__ */
+++ /dev/null
-/*
- * 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 <stdio.h>
-
-extern unsigned int __log_level__;
-extern FILE *__log_out_file__;
-
-#define LOG_INFO (1<<8)
-#define LOG_SSENGINE (1<<7)
-#define LOG_FUNCS (1<<6)
-#define LOG_GUI (1<<5)
-#define LOG_DEBUG (1<<4)
-#define LOG_FILE (1<<3)
-#define LOG_FLASH (1<<2)
-
-#define LOG_PRFIX "FOTA_GUI_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__ */
-
#include <sys/time.h>
#include <sys/resource.h>
-#include "fota_gui_general.h"
+#include "gui_general.h"
#include "fota_gr_rw_common.h"
unsigned int __log_level__ =
+++ /dev/null
-/*
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include "fota_gui_log.h"
-
-int s_fd_stdin = -1;
-int s_fd_stdout = -1;
-int s_fd_stderr = -1;
-
-/*-----------------------------------------------------------------------------
- set_default_stdio
- ----------------------------------------------------------------------------*/
-static int set_default_stdio(int flags, int nfd)
-{
- int fd, r;
-
- fd = open("/dev/null", flags|O_NOCTTY);
- if (fd < 0)
- return -errno;
-
- if (fd == nfd) {
- return fd;
- } else {
- r = dup2(fd, nfd) < 0 ? -errno : nfd;
- close(fd);
- return r;
- }
-}
-
-/*-----------------------------------------------------------------------------
- _init_stdio
- ----------------------------------------------------------------------------*/
-void _init_stdio(void)
-{
- s_fd_stdin = set_default_stdio(O_RDONLY, STDIN_FILENO);
-
- s_fd_stdout = set_default_stdio(O_WRONLY, STDOUT_FILENO);
-
- s_fd_stderr = set_default_stdio(O_WRONLY, STDERR_FILENO);
-}
-
-/*-----------------------------------------------------------------------------
- _exit_stdio
- ----------------------------------------------------------------------------*/
-void _exit_stdio(void)
-{
- if (s_fd_stdin >= 0)
- close(s_fd_stdin);
-
- if (s_fd_stdout >= 0)
- close(s_fd_stdout);
-
- if (s_fd_stderr >= 0)
- close(s_fd_stderr);
-}
-
+++ /dev/null
-/*
- * 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_ */
-
+++ /dev/null
-/*
- * 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 <stdlib.h>
-#include <png.h>
-#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_img_original()
- ----------------------------------------------------------------------------*/
-void draw_png_img_original(void *fbi, int x1, int y1, int fbi_w, int fbi_h, int fbi_stride)
-{
- unsigned int *fb_buf_cur = NULL;
- int bpp;
- int x, y;
- int end_width, end_height;
- /* temp patch - lcd resoultion for qualcomm */
-
- fb_buf_cur = (unsigned int *)fbi;
-
- /* check out range */
- if ((x1 > fbi_w ) || (y1 > fbi_h)) {
- LOG("[draw_png_img_xy] output range exceeds frame buffer range \n");
- return;
- }
- if(x1 + png_img_width > fbi_w)
- end_width = fbi_w- x1;
- else
- end_width = png_img_width;
- if(y1 + png_img_height > fbi_h)
- end_height = fbi_h - y1;
- else
- end_height = png_img_height;
-
- 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 */
- for (y = 0; y < png_img_height; y++) {
- if(y > end_height) continue;
- fb_buf_cur = (unsigned int *) (fbi + ((y1 + y) * fbi_stride));
- fb_buf_cur += x1;
- png_byte *row = (png_byte *) row_pointers[y];
- for (x = 0; x < png_img_width; x++) {
- if(x > end_width) continue;
- 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++;
- }
- }
-
-}
-
-/*-----------------------------------------------------------------------------
- draw_png_mask_xy()
- - draw pixel only when alpha>0 of given png image
- ----------------------------------------------------------------------------*/
-void draw_png_mask_xy(FbInfo *fbi, int x1, int y1, char r, char g, char b)
-{
- unsigned int *fb_buf_cur = NULL;
- int bpp;
- int x, y;
- /* temp patch - lcd resoultion for qualcomm */
-
- fb_buf_cur = (unsigned int *)fbi->buf[0];
-
- /* check out range */
- if ((x1 + png_img_width > fbi->w) ||
- (y1 + png_img_height > fbi->h)) {
- LOG("[draw_png_img_xy] output range exceeds frame buffer range \n");
- return;
- }
-
- if (png_color_type == PNG_COLOR_TYPE_RGB) {
- bpp = 3;
- LOG("[draw_png_img_xy] PNG_COLOR_TYPE_RGB : no mask channel \n");
- return;
- } else if (png_color_type == PNG_COLOR_TYPE_RGBA)
- bpp = 4;
- else {
- LOG("[draw_png_img_xy] png type does not match RGB or RGBA \n");
- return;
- }
- /* temp patch - lcd resoultion for qualcomm */
- fb_buf_cur += (y1 * (fbi->w));
- fb_buf_cur += x1;
- for (y = 0; y < png_img_height; y++) {
- png_byte *row = (png_byte *) row_pointers[y];
- for (x = 0; x < png_img_width; x++) {
- if (bpp == 4) {
- if (png_bit_depth == 8) {
- if (row[3] != 0) {
- (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
- (r << 16) | (g << 8) | (b);
- }
- row += bpp;
- } else if (png_bit_depth == 16) {
- if (row[6] != 0) {
- (*fb_buf_cur) = ((*fb_buf_cur)&0xff000000) |
- (r << 16) | (g << 8) | (b);
- }
- row += bpp*2;
- }
- }
- fb_buf_cur++;
- }
- fb_buf_cur -= png_img_width;
- fb_buf_cur += fbi->w;/* temp patch - lcd resoultion for qualcomm */
- }
-
-}
-
-/*-----------------------------------------------------------------------------
- release_png_res()
- ----------------------------------------------------------------------------*/
-void release_png_res(void)
-{
- int y;
-
- for (y = 0; y < png_img_height; y++)
- free((void *)row_pointers[y]);
- free((void *)row_pointers);
-
- png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-}
+++ /dev/null
-/*
- * 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_original(void *fbi, int x1, int y1, int fbi_w, int fbi_h, int fbi_stride);
-extern void draw_png_img_clip_xy(FbInfo *fbi, int x1, int y1, int cx, int cy, int cw, int ch);
-extern void draw_png_mask_xy(FbInfo *fbi, int x1, int y1, char r, char g, char b);
-extern void release_png_res(void);
-
-
-#endif /* __FOTA_PNG_H__ */
+++ /dev/null
-/*
- * 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 <stdbool.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/poll.h>
-#include <sys/time.h>
-#include "fota_gui_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 ;
-}
+++ /dev/null
-/*
- * 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 <tdm.h>
-#include <tbm_bufmgr.h>
-#include <tdm_helper.h>
-#include <tbm_surface.h>
-#include <tbm_surface_internal.h>
-
-#define MAX_BUF 2
-#define RGB32_BPP 32
-#define RGB32_PITCH 4
-
-typedef struct _tdm_if_disp {
- tdm_display *disp;
- tdm_output *output;
- tdm_layer *layer;
- tdm_pp *pp;
- int tdm_fd;
- int drm_fd;
-
- tbm_surface_h surf[MAX_BUF];
- tbm_surface_h pp_surf[MAX_BUF];
- tbm_bufmgr bufmgr;
- unsigned int handle[MAX_BUF];
- unsigned int pp_handle[MAX_BUF];
- tbm_bo bo[MAX_BUF];
- tbm_bo_handle bo_handle[MAX_BUF];
- tbm_bo pp_bo[MAX_BUF];
- tbm_bo_handle pp_bo_handle[MAX_BUF];
- void *buffer[MAX_BUF];
- void *pp_buffer[MAX_BUF];
- int buffer_size;
- int width;
- int height;
- int stride;
- int current_buf_id;
-
- bool use_tdm_hwc;
- tdm_hwc *hwc;
-} tdm_if_disp;
-
-typedef enum {
- FRONT_BUFFER = 0,
- BACK_BUFFER
-} BUFFER_TYPE;
-
-extern tdm_if_disp s_disp;
-
-int tdm_if_display_init(tdm_if_disp *st_disp);
-void tdm_if_display_deinit(tdm_if_disp *st_disp);
-void tdm_if_display_update(tdm_if_disp *st_disp);
-void tdm_if_lcd_on(tdm_if_disp *st_disp);
-void tdm_if_lcd_suspend(tdm_if_disp *st_disp);
-void tdm_if_lcd_off(tdm_if_disp *st_disp);
-#endif /* __TDM_IF_H__ */