Esempio n. 1
0
void main_draw_image(struct template_t *tmp_tpl) {
	int x = 0, y = 0, zindex = 0;
	char *image = NULL, *ext = NULL;
	template_get_setting_number(tmp_tpl, "x", &x);
	template_get_setting_number(tmp_tpl, "y", &y);
	template_get_setting_number(tmp_tpl, "z-index", &zindex);
	template_get_setting_string(tmp_tpl, "image", &image);
	template_get_setting_string(tmp_tpl, "extension", &ext);

	if(nodaemon == 0) {
		if(strcmp(ext, "jpg") == 0) {
			draw_jpg(x, y, zindex, image);
		} else if(strcmp(ext, "png") == 0) {
			draw_png(x, y, zindex, image);
		}
	}
}
Esempio n. 2
0
void *update_progress(void *param) {
	pthread_mutex_lock(&progress_lock);
	int last_percentage = 0;
	int new_percentage = -1;
	int n = 0;

	while(main_loop) {
		int target_width = 0;
		int x = 0, y = 0;

		if(percentage == 100 || percentage == -1 || percentage == 0) {
			target_width = (int)progress.background_w;
		} else {
			target_width = (int)(progress.background_w * (((double)percentage/100)));
		}

		if(draw_loop) {
			while(draw_loop) {
				pthread_mutex_lock(&progress_lock);
				if(target_width > 0 && nodaemon == 0 && black == 0) {
					if(progress_active == 0) {
						if(strcmp(progress.active_start_e, "jpg") == 0) {
							draw_jpg(progress.background_x, progress.background_y, progress.background_z, progress.active_start_img);
						} else if(strcmp(progress.active_start_e, "png") == 0) {
							draw_png(progress.background_x, progress.background_y, progress.background_z, progress.active_start_img);
						}
					} else {
						if(strcmp(progress.inactive_start_e, "jpg") == 0) {
							draw_jpg(progress.background_x, progress.background_y, progress.background_z, progress.inactive_start_img);
						} else if(strcmp(progress.inactive_start_e, "png") == 0) {
							draw_png(progress.background_x, progress.background_y, progress.background_z, progress.inactive_start_img);
						}
					}
				}
				if(progress_active == 0) {
					x += progress.active_start_w;
				} else {
					x += progress.inactive_start_w;
				}

				if(progress_active == 0) {
					if(target_width >= (progress.background_w-progress.active_end_w)) {
						y = (int)(progress.background_w-progress.inactive_end_w);
					} else {
						y = (int)target_width;
					}
				} else {
					if(target_width >= (progress.background_w-progress.inactive_end_w)) {
						y = (int)(progress.background_w-progress.inactive_end_w);
					} else {
						y = (int)target_width;
					}
				}

				if(x < y) {
					while(x < y) {
						if(nodaemon == 0 && black == 0) {
							if(progress_active == 0) {
								if(strcmp(progress.active_fill_e, "jpg") == 0) {
									draw_jpg(progress.background_x+x, progress.background_y, progress.background_z, progress.active_fill_img);
								} else if(strcmp(progress.active_fill_e, "png") == 0) {
									draw_png(progress.background_x+x, progress.background_y, progress.background_z, progress.active_fill_img);
								}
								if(percentage == -1) {
									usleep((__useconds_t)(speed*progress.active_fill_w));
								}
							} else {
								if(strcmp(progress.inactive_fill_e, "jpg") == 0) {
									draw_jpg(progress.background_x+x, progress.background_y, progress.background_z, progress.inactive_fill_img);
								} else if(strcmp(progress.inactive_fill_e, "png") == 0) {
									draw_png(progress.background_x+x, progress.background_y, progress.background_z, progress.inactive_fill_img);
								}
								if(percentage == -1) {
									usleep((__useconds_t)(speed*progress.inactive_fill_w));
								}
							}
						}
						x++;
					}
				}

				if(x < target_width) {
					if(nodaemon == 0 && black == 0) {
						if(progress_active == 0) {
							if(strcmp(progress.active_end_e, "jpg") == 0) {
								draw_jpg(progress.background_x+x, progress.background_y, progress.background_z, progress.active_end_img);
							} else if(strcmp(progress.active_end_e, "png") == 0) {
								draw_png(progress.background_x+x, progress.background_y, progress.background_z, progress.active_end_img);
							}
						} else {
							if(strcmp(progress.inactive_end_e, "jpg") == 0) {
								draw_jpg(progress.background_x+x, progress.background_y, progress.background_z, progress.inactive_end_img);
							} else if(strcmp(progress.inactive_end_e, "png") == 0) {
								draw_png(progress.background_x+x, progress.background_y, progress.background_z, progress.inactive_end_img);
							}
						}
						x = (int)target_width;
					}
				}
				if(x == progress.background_w) {
					progress_active ^= 1;
					x = 0;
				}
				if(infinite == 0) {
					if(new_percentage > -1) {
						percentage = new_percentage;
						new_percentage = -1;
						target_width = (int)(progress.background_w * (((double)percentage/100)));
						x = 0;
					} else if(percentage < last_percentage && last_percentage != 100) {
						new_percentage = percentage;
						target_width = (int)progress.background_w;
						x = 0;
					} else {
						draw_loop = 0;
					}
					last_percentage = percentage;
				}
				pthread_mutex_unlock(&progress_lock);
			}
		} else {
			if(percentage > 0 && percentage < 100) {
				struct timeval tp;
				struct timespec ts;

				gettimeofday(&tp, NULL);
				ts.tv_sec = tp.tv_sec;
				ts.tv_nsec = tp.tv_usec * 1000;
				ts.tv_sec += 1;

				n = pthread_cond_timedwait(&progress_signal, &progress_lock, &ts);
				if(n == ETIMEDOUT) {
					percentage++;
					draw_loop = 1;
				}
			} else {
				n = pthread_cond_wait(&progress_signal, &progress_lock);
			}
		}
	}
	return (void *)NULL;
}
Esempio n. 3
0
int do_draw_jpg (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
    U32 u32LogoAddr=0;
    U32 u32LogoSize=0;
    U32 JPD_InputADDR=0;
    U32 JPD_OUTADDR=0;
    char *PhotoPath=NULL;
    BltConfigParams stConfig;
    UBOOT_TRACE("IN\n");

    get_addr_from_mmap("E_MMAP_ID_JPD_READ", &JPD_InputADDR);
    get_addr_from_mmap("E_MMAP_ID_JPD_WRITE", &JPD_OUTADDR);

	if(JPD_InputADDR==0xFFFF || JPD_OUTADDR==0xFFFF)
	{
		UBOOT_ERROR("Get Mmap for JPD Fail Skip JPD Decode !!! \n");
		return -1;

	}
    if(argc < 6)
    {
#if (CONFIG_BINARY_RELEASE == 1)
    stConfig.u16DispX = DEFAULT_OSD_STRING_X;
    stConfig.u16DispY = DEFAULT_OSD_STRING_Y;
    stConfig.u16DispW = DEFAULT_OSD_LAYER_WIDTH;
    stConfig.u16DispH = DEFAULT_OSD_LAYER_HEIGHT; 
#else
        cmd_usage(cmdtp);
        return 1;
#endif
    }
    else
    {
        stConfig.u16DispX = simple_strtoul(argv[2], NULL, 10);
        stConfig.u16DispY = simple_strtoul(argv[3], NULL, 10);
        stConfig.u16DispW = simple_strtoul(argv[4], NULL, 10);
        stConfig.u16DispH = simple_strtoul(argv[5], NULL, 10);       
    }
    if(IsPanelReady()!=0)
    {
         UBOOT_ERROR("Panle is not ready\n");
        return -1;
    }


    UBOOT_DEBUG("u16DispX=0x%x,u16DispY=0x%x,u16DispW=0x%x,u16DispH=0x%x\n",stConfig.u16DispX,stConfig.u16DispY,stConfig.u16DispW,stConfig.u16DispH);

    if(strncmp(argv[1], "-fs", 3)==0) // jpd from filesystem
    {
        PhotoPath = argv[6];
        UBOOT_DEBUG("PhotoPath=%s\n",PhotoPath);
        u32LogoSize = LoadJpg2Dram(PhotoPath, JPD_InputADDR);
        UBOOT_DEBUG("u32LogoSize : 0x%x \n",u32LogoSize);
        if(u32LogoSize == 0)
        {
            UBOOT_ERROR("Fail: Load_Photo2Dram return size is 0 !!\n");
            return -1;
        }
    }
    else if(strncmp(argv[1], "-s", 2)==0)
    {
        mboot_raw_io_Config();
        u32LogoAddr= simple_strtoul(argv[6],NULL,16);
        u32LogoSize= simple_strtoul(argv[7],NULL,16);;
        raw_read(PA2NVA(JPD_InputADDR),u32LogoAddr,u32LogoSize);
    }
    else
    {
#if (CONFIG_BINARY_RELEASE == 1)
        PhotoPath = DEFAULT_OSD_BACKGROUND_PATH;
        UBOOT_DEBUG("PhotoPath=%s\n",PhotoPath);
        u32LogoSize = LoadJpg2Dram(PhotoPath,LOGO_JPG_DRAM_ADDR);
        UBOOT_DEBUG("u32LogoSize : 0x%x \n",u32LogoSize);
        if(u32LogoSize == 0)
        {
            UBOOT_ERROR("Fail: Load_Photo2Dram return size is 0 !!\n");
            return -1;
        }
#else
        cmd_usage(cmdtp);
        return -1;
#endif
    }    
    MsApi_JPD_Decode(JPD_InputADDR, u32LogoSize);
    draw_jpg(stConfig,JPD_OUTADDR);
    UBOOT_TRACE("OK\n");
    return 0;
}