/***************************************************************************** * FUNCTION * gdi_image_jpeg_draw_to_buffer * DESCRIPTION * draw resized jpeg * PARAMETERS * width [IN] * height [IN] * jpeg_src [IN] * size [IN] * buf [?] * buf_size [IN] * decoded_image_width [?] * oy(?) [IN] * resized_width(?) [IN] * resized_height(?) [IN] * ox(?) [IN] * RETURNS * GDI_RESULT *****************************************************************************/ GDI_RESULT gdi_image_jpeg_draw_to_buffer( S32 width, S32 height, U8 *jpeg_src, U32 size, U8 *buf, S32 buf_size, S32 *decoded_image_width) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ENTER_CRITICAL_SECTION(gdi_image_jpeg_draw_to_buffer) GDI_RETURN(gdi_image_jpeg_draw_internal( 0,0,width,height, -1,-1,-1,-1, jpeg_src,size, FALSE,TRUE,TRUE, buf,buf_size,decoded_image_width,GDI_COLOR_FORMAT_16)); GDI_EXIT_CRITICAL_SECTION(gdi_image_jpeg_draw_to_buffer) }
/***************************************************************************** * FUNCTION * gdi_image_jpeg_get_dimension_file * DESCRIPTION * get jpeg dimension, source is from file * PARAMETERS * image_name [IN] * width [OUT] * height [OUT] * RETURNS * GDI_RESULT *****************************************************************************/ GDI_RESULT gdi_image_jpeg_get_dimension_file(S8 *image_name, S32 *width, S32 *height) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ENTER_CRITICAL_SECTION(gdi_image_jpeg_get_dimension_file) GDI_RESULT ret; *width = 0; *height = 0; if (image_name == NULL || gdi_bytestream_create_file(image_name) != GDI_SUCCEED) { GDI_RETURN(GDI_FAILED); } GDI_TRY { ret = gdi_image_jpeg_get_dimension_internal(width, height); } GDI_CATCH_BEGIN { *width = 0; *height = 0; ret = GDI_IMAGE_ERR_INVALID_IMG_TYPE; } GDI_CATCH_END gdi_bytestream_free(); GDI_RETURN(ret); GDI_EXIT_CRITICAL_SECTION(gdi_image_jpeg_get_dimension_file) }
/***************************************************************************** * FUNCTION * gdi_image_jpeg_get_dimension * DESCRIPTION * get jpeg dimension, source is from memory * PARAMETERS * jpeg_src [IN] * size [IN] * width [OUT] * height [OUT] * RETURNS * GDI_RESULT *****************************************************************************/ GDI_RESULT gdi_image_jpeg_get_dimension(U8 *jpeg_src, U32 size, S32 *width, S32 *height) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ENTER_CRITICAL_SECTION(gdi_image_jpeg_get_dimension) GDI_RESULT ret; *width = 0; *height = 0; if (jpeg_src == NULL || gdi_bytestream_create((U8*) jpeg_src, size) != GDI_SUCCEED) { GDI_RETURN(GDI_IMAGE_ERR_OPEN_FILE_FAILED); } GDI_TRY { ret = gdi_image_jpeg_get_dimension_internal(width, height); } GDI_CATCH_BEGIN { *width = 0; *height = 0; ret = GDI_IMAGE_ERR_INVALID_IMG_TYPE; } GDI_CATCH_END gdi_bytestream_free(); GDI_RETURN(ret); GDI_EXIT_CRITICAL_SECTION(gdi_image_jpeg_get_dimension) }
/***************************************************************************** * FUNCTION * gdi_image_decoder_stop_all * DESCRIPTION * * PARAMETERS * void * RETURNS * *****************************************************************************/ GDI_RESULT gdi_image_decoder_stop_all(void) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ENTER_CRITICAL_SECTION(gdi_image_decoder_stop_all) S16 next_idx; /* check if anything in decoder */ if (gdi_image_decoder_item_first_idx == -1) { GDI_RETURN(GDI_SUCCEED); } /* stop current running decoder */ switch (gdi_image_decoder_item_list[gdi_image_decoder_item_first_idx].img_type) { case GDI_IMAGE_TYPE_JPG_FILE: media_img_stop(MOD_MMI); break; default: GDI_ASSERT(0); } /* close file */ /* DRM_REPLACE */ /* FS_Close(gdi_image_decoder_item_list[gdi_image_decoder_item_first_idx].file_handle); */ DRM_close_file(gdi_image_decoder_item_list[gdi_image_decoder_item_first_idx].file_handle); next_idx = gdi_image_decoder_item_first_idx; while (next_idx != -1) { /* close all opened file */ if (gdi_image_decoder_item_list[next_idx].file_handle >= 0) { /* DRM_REPLACE */ /* FS_Close(gdi_image_decoder_item_list[next_idx].file_handle); */ DRM_close_file(gdi_image_decoder_item_list[next_idx].file_handle); gdi_image_decoder_item_list[next_idx].file_handle = -1; /* gdi_image_decoder_item_list[next_idx].file_size = 0; */ } gdi_image_decoder_item_list[next_idx].is_used = FALSE; next_idx = gdi_image_decoder_item_list[next_idx].next_idx; } gdi_image_decoder_item_first_idx = -1; gdi_image_decoder_item_last_idx = -1; GDI_RETURN(GDI_SUCCEED); GDI_EXIT_CRITICAL_SECTION(gdi_image_decoder_stop_all) }
/***************************************************************************** * FUNCTION * gdi_image_jpeg_draw_file_to_buffer * DESCRIPTION * * PARAMETERS * width [IN] * height [IN] * jpeg_file [?] * buf [?] * buf_size [IN] * decoded_image_width [?] * RETURNS * *****************************************************************************/ GDI_RESULT gdi_image_jpeg_draw_file_to_buffer( S32 width, S32 height, U8 *jpeg_file, U8 *buf, S32 buf_size, S32 *decoded_image_width) { GDI_ENTER_CRITICAL_SECTION(gdi_image_jpeg_draw_to_buffer) GDI_RETURN(gdi_image_jpeg_draw_internal( 0,0,width,height, -1,-1,-1,-1, jpeg_file,0, TRUE,TRUE,TRUE, buf,buf_size,decoded_image_width,GDI_COLOR_FORMAT_16)); GDI_EXIT_CRITICAL_SECTION(gdi_image_jpeg_draw_to_buffer) }
/***************************************************************************** * FUNCTION * gdi_image_decoder_free * DESCRIPTION * * PARAMETERS * void * RETURNS * *****************************************************************************/ GDI_RESULT gdi_image_decoder_free(void) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ENTER_CRITICAL_SECTION(gdi_image_decoder_free) gdi_image_decoder_is_created = FALSE; /* clear call back function */ gdi_image_decoder_result_callback = NULL; GDI_RETURN(GDI_SUCCEED); GDI_EXIT_CRITICAL_SECTION(gdi_image_decoder_free) }
/***************************************************************************** * FUNCTION * gdi_image_decoder_stop * DESCRIPTION * * PARAMETERS * handle [IN] * RETURNS * *****************************************************************************/ GDI_RESULT gdi_image_decoder_stop(gdi_handle handle) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ENTER_CRITICAL_SECTION(gdi_image_decoder_stop) S16 this_idx; S16 prev_idx = -1; this_idx = gdi_image_decoder_item_first_idx; while (this_idx != -1) { if (handle == gdi_image_decoder_item_list[this_idx].seq_num) { /* stop jpeg decoderr driver */ if (this_idx == gdi_image_decoder_item_first_idx) { /* is the one that currently decoding - stop it */ /* handle each decoder's stop function */ switch (gdi_image_decoder_item_list[this_idx].img_type) { case GDI_IMAGE_TYPE_JPG_FILE: media_img_stop(MOD_MMI); break; default: GDI_ASSERT(0); } /* close file */ /* DRM_REPLACE */ /* FS_Close(gdi_image_decoder_item_list[this_idx].file_handle); */ DRM_close_file(gdi_image_decoder_item_list[this_idx].file_handle); gdi_image_decoder_item_list[this_idx].is_used = FALSE; gdi_image_decoder_item_first_idx = gdi_image_decoder_item_list[this_idx].next_idx; if (gdi_image_decoder_item_first_idx != -1) { gdi_image_decoder_decode_from_list(); } } else { /* not first one */ /* DRM_REPLACE */ /* FS_Close(gdi_image_decoder_item_list[this_idx].file_handle); */ DRM_close_file(gdi_image_decoder_item_list[this_idx].file_handle); /* file is successfully read into buffer, clear file handle */ gdi_image_decoder_item_list[this_idx].file_handle = -1; /* gdi_image_decoder_item_list[this_idx].file_size = 0; */ gdi_image_decoder_item_list[this_idx].is_used = FALSE; gdi_image_decoder_item_list[prev_idx].next_idx = gdi_image_decoder_item_list[this_idx].next_idx; } GDI_RETURN(GDI_SUCCEED); } prev_idx = this_idx; this_idx = gdi_image_decoder_item_list[this_idx].next_idx; } GDI_RETURN(GDI_IMAGE_DECODER_ERR_WRONG_HANDLE); GDI_EXIT_CRITICAL_SECTION(gdi_image_decoder_stop) }
/***************************************************************************** * FUNCTION * gdi_image_decoder_decode_file_with_output_clipping * DESCRIPTION * * PARAMETERS * offset_x [IN] * offset_y [IN] * width [IN] * height [IN] * output_clipx1 [IN] * output_clipy1 [IN] * output_clipx2 [IN] * output_clipy2 [IN] * is_blt [IN] * image_name [?] * handle_ptr [?] * RETURNS * *****************************************************************************/ GDI_RESULT gdi_image_decoder_decode_file_with_output_clipping( S32 offset_x, S32 offset_y, S32 width, S32 height, S32 output_clipx1, S32 output_clipy1, S32 output_clipx2, S32 output_clipy2, BOOL is_blt, S8 *image_name, gdi_handle *handle_ptr) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ENTER_CRITICAL_SECTION(gdi_image_decoder_decode_file) S16 valid_idx; S16 this_idx; U32 file_size; BOOL has_entry = FALSE; FS_HANDLE file_handle; U16 image_type; if (handle_ptr != NULL) { *handle_ptr = GDI_ERROR_HANDLE; } if (width == 0 || height == 0) { GDI_RETURN(GDI_SUCCEED); } /* check if it is a decodable file format */ image_type = gdi_image_get_type_from_file(image_name); if (image_type != GDI_IMAGE_TYPE_JPG_FILE) /* currently, we only support jpeg file */ { GDI_RETURN(GDI_IMAGE_DECODER_ERR_INVALID_IMG_TYPE); } /* find a valid entry to record this jpeg decoder */ for (valid_idx = 0; valid_idx < GDI_IMAGE_DECODER_ITEM_COUNT; valid_idx++) { if (gdi_image_decoder_item_list[valid_idx].is_used == FALSE) { has_entry = TRUE; break; } } if (has_entry == FALSE) { /* cant find entry to save jpeg decoder data */ GDI_RETURN(GDI_IMAGE_DECODER_ERR_NO_ITEM_ENTRY); } /* open file */ file_handle = DRM_open_file((U16*) image_name, FS_READ_ONLY, 0); if (file_handle >= 0) { /* check if size can fit into file buffer */ /* DRM_REPLACE */ /* FS_GetFileSize(file_handle, (kal_uint32*)&file_size); */ DRM_file_size(file_handle, (kal_uint32*) & file_size); /* check if dest size larger than intermediate frame buffer */ if (gdi_image_decoder_frame_buf_size < (U32) ((width + 16) * (height + 16))) /* +16 for jpeg's stuffing */ { /* DRM_REPLACE */ /* FS_Close(file_handle); */ DRM_close_file(file_handle); GDI_RETURN(GDI_IMAGE_DECODER_ERR_FRAME_BUF_NOT_ENOUGH); } if (gdi_image_decoder_item_first_idx == -1) { /* first in the list, re-assign first index */ gdi_image_decoder_item_first_idx = valid_idx; } else { this_idx = gdi_image_decoder_item_first_idx; /* loop to find next */ while (this_idx != -1) { if (gdi_image_decoder_item_list[this_idx].next_idx == -1) { gdi_image_decoder_item_list[this_idx].next_idx = valid_idx; break; } this_idx = gdi_image_decoder_item_list[this_idx].next_idx; } } /* find a valid seq number */ if (gdi_image_decoder_item_seq_num_idx < GDI_IMAGE_DECODER_ITEM_SEQ_NUM_LIMIT - 1) { gdi_image_decoder_item_seq_num_idx++; } else { gdi_image_decoder_item_seq_num_idx = 1; } gdi_image_decoder_item_list[valid_idx].is_used = TRUE; gdi_image_decoder_item_list[valid_idx].file_handle = file_handle; gdi_image_decoder_item_list[valid_idx].is_blt = is_blt; gdi_image_decoder_item_list[valid_idx].img_type = image_type; gdi_image_decoder_item_list[valid_idx].dest_offset_x = offset_x; gdi_image_decoder_item_list[valid_idx].dest_offset_y = offset_y; gdi_image_decoder_item_list[valid_idx].dest_width = (U16) width; gdi_image_decoder_item_list[valid_idx].dest_height = (U16) height; gdi_image_decoder_item_list[valid_idx].next_idx = -1; gdi_image_decoder_item_list[valid_idx].seq_num = gdi_image_decoder_item_seq_num_idx; gdi_image_decoder_item_list[valid_idx].layer_handle = (gdi_handle) gdi_act_layer; gdi_image_decoder_item_list[valid_idx].lcd_handle = GDI_LCD->act_handle; gdi_image_decoder_item_list[valid_idx].clipx1 = gdi_act_layer->clipx1; gdi_image_decoder_item_list[valid_idx].clipy1 = gdi_act_layer->clipy1; gdi_image_decoder_item_list[valid_idx].clipx2 = gdi_act_layer->clipx2; gdi_image_decoder_item_list[valid_idx].clipy2 = gdi_act_layer->clipy2; gdi_image_decoder_item_list[valid_idx].output_clipx1 = output_clipx1; gdi_image_decoder_item_list[valid_idx].output_clipy1 = output_clipy1; gdi_image_decoder_item_list[valid_idx].output_clipx2 = output_clipx2; gdi_image_decoder_item_list[valid_idx].output_clipy2 = output_clipy2; if (gdi_image_decoder_item_list[gdi_image_decoder_item_first_idx].next_idx == -1) { /* only one jpeg wait to decoder, call this function, if already has another jpeg is decoding, the following function will be called when the previous jpeg is decoderd */ gdi_image_decoder_decode_from_list(); } /* succeed create a jpeg decoder entry , return it's sequential no as handle */ if (handle_ptr != NULL) { *handle_ptr = gdi_image_decoder_item_seq_num_idx; } GDI_RETURN(GDI_SUCCEED); } else { /* open File error */ GDI_RETURN(GDI_IMAGE_DECODER_ERR_OPEN_FILE_FAILED); } GDI_EXIT_CRITICAL_SECTION(gdi_image_decoder_decode_file) }
/***************************************************************************** * FUNCTION * gdi_lcd_init * DESCRIPTION * Init lcd * PARAMETERS * void * RETURNS * GDI_RESULT(?) *****************************************************************************/ void gdi_lcd_init(void) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ENTER_CRITICAL_SECTION(gdi_lcd_init) S32 i = 0; memset(GDI_LCD_ARRAY, 0, sizeof(GDI_LCD_ARRAY)); GDI_LCD_ARRAY[i].act_handle = GDI_LCD_MAIN_LCD_HANDLE; GDI_LCD_ARRAY[i].act_width = GDI_LCD_WIDTH; GDI_LCD_ARRAY[i].act_height = GDI_LCD_HEIGHT; GDI_LCD_ARRAY[i].act_layer_handle = GDI_LAYER_MAIN_BASE_LAYER_HANDLE; GDI_LCD_ARRAY[i].cf = gdi_get_color_format(DRV_MAINLCD_BIT_PER_PIXEL); GDI_LCD_ARRAY[i].is_freeze = FALSE; GDI_LCD_ARRAY[i].lcd_type = GDI_LCD_TYPE_LCD; GDI_LCD_ARRAY[i].bind_handle = GDI_NULL_HANDLE; GDI_LCD_ARRAY[i].rotate_value = GDI_LCD_LAYER_ROTATE_0; GDI_LCD_ARRAY[i].rotate_by_layer = FALSE; i++; #ifdef __MMI_SUBLCD__ GDI_LCD_ARRAY[i].act_handle = GDI_LCD_SUB_LCD_HANDLE; GDI_LCD_ARRAY[i].act_width = GDI_SUBLCD_WIDTH; GDI_LCD_ARRAY[i].act_height = GDI_SUBLCD_HEIGHT; GDI_LCD_ARRAY[i].act_layer_handle = GDI_LAYER_SUB_BASE_LAYER_HANDLE; GDI_LCD_ARRAY[i].cf = gdi_get_color_format(DRV_SUBLCD_BIT_PER_PIXEL); GDI_LCD_ARRAY[i].is_freeze = FALSE; GDI_LCD_ARRAY[i].lcd_type = GDI_LCD_TYPE_LCD; GDI_LCD_ARRAY[i].bind_handle = GDI_NULL_HANDLE; GDI_LCD_ARRAY[i].rotate_value = GDI_LCD_LAYER_ROTATE_0; GDI_LCD_ARRAY[i].rotate_by_layer = FALSE; #endif /* __MMI_SUBLCD__ */ i++; #ifdef GDI_USING_TV_OUTPUT GDI_LCD_ARRAY[i].act_handle = GDI_LCD_TVOUT_HANDLE; GDI_LCD_ARRAY[i].act_width = 0; GDI_LCD_ARRAY[i].act_height = 0; GDI_LCD_ARRAY[i].act_layer_handle = 0; GDI_LCD_ARRAY[i].cf = GDI_COLOR_FORMAT_16; GDI_LCD_ARRAY[i].is_freeze = FALSE; GDI_LCD_ARRAY[i].lcd_type = GDI_LCD_TYPE_TVOUT; GDI_LCD_ARRAY[i].bind_handle = GDI_NULL_HANDLE; GDI_LCD_ARRAY[i].rotate_value = GDI_LCD_LAYER_ROTATE_0; GDI_LCD_ARRAY[i].rotate_by_layer = FALSE; #endif /* GDI_USING_TV_OUTPUT */ /* init LCD */ lcd_init(MAIN_LCD, DRV_MAINLCD_INIT_COLOR); /* sub lcd supported */ #ifdef __MMI_SUBLCD__ lcd_init(SUB_LCD, DRV_SUBLCD_INIT_COLOR); #endif /* __MMI_SUBLCD__ */ GDI_LCD = &GDI_LCD_ARRAY[0]; GDI_EXIT_CRITICAL_SECTION(gdi_lcd_init) }