📄 cam_msg_handler.c
字号:
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
#ifndef MED_NOT_PRESENT
/*==== INCLUDES =========*/
/* system includes */
#include "kal_release.h"
#include "kal_trace.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h" /* Task message communiction */
#include "syscomp_config.h"
#include "task_config.h" /* Task creation */
#include "app_buff_alloc.h" /* Declaration of buffer management API */
#include "stacklib.h" /* Basic type for dll, evshed, stacktimer */
#include "event_shed.h" /* Event scheduler */
#include "stack_timer.h" /* Stack timer */
/* global includes */
#include "l1audio.h"
#include "device.h"
#include "resource_audio.h"
#include "nvram_enums.h"
#include "nvram_struct.h"
#include "nvram_user_defs.h"
#include "nvram_data_items.h"
#include "custom_nvram_editor_data_item.h"
#include "lcd_if.h"
#include "lcd_sw_inc.h"
#include "fat_fs.h"
#include "custom_equipment.h"
#if defined(JPG_ENCODE) || defined(__SW_JPEG_CODEC_SUPPORT__)
#include "jpeg.h"
#endif
#ifdef ISP_SUPPORT
#include "isp_if.h"
#include "ae_awb.h"
#include "image_effect.h"
#include "visual_comm.h"
#include "img_comm.h"
#endif /* ISP_SUPPORT */
/* local includes */
#include "med_global.h"
#include "med_main.h"
#include "aud_defs.h"
#include "med_struct.h"
#include "med_api.h"
#include "med_context.h"
#include "med_smalloc.h"
#include "med_utility.h"
#include "cam_main.h"
#include "img_main.h"
/* XENON_FLASHLIGHT */
#if defined(XENON_FLASHLIGHT) || defined(XENON_FLASHLIGHT_ANTI_RED_EYE)
#include "uem_context.h"
#include "uem_utility.h"
#include "isp_flashlight.h"
#endif
#if defined(__MED_VID_ENC_MOD__) || defined(__MED_MJPG_ENC_MOD__)
#include "vid_main.h"
#endif
#ifdef MP4_CODEC
#include "med_c_main.h"
#include "med_c_struct.h"
#endif /* MP4_CODEC */
#ifdef __MED_TVO_MOD__
#include "tv_out.h"
#include "tvo_main.h"
#endif /* __MED_TVO_MOD__ */
#ifdef __CAM_TRACE_ON__
#include "med_trc.h"
#endif
#ifdef BARCODE_DECODER_SCANBUY
#include "sc_2dDecoder.h"
#if MT6219_SERIES
#include "dcmgr.h"
#endif
#endif
#ifdef CAMERA_MODULE
#include "ext_camera.h"
#include "cam_module.h"
#endif /* CAMERA_MODULE */
#ifdef __MED_CAM_MOD__
#if (MT6228_SERIES)
extern void set_overlay_palette(kal_uint8 palette_size, kal_uint32 *palette_addr_ptr);
#endif
#if defined(__SW_JPEG_CODEC_SUPPORT__) && !defined(WIN32)
extern kal_uint32 INT_SwitchStackToRun(void *stack_start, kal_uint32 stack_size, kal_func_ptr func, kal_uint32 argc, ...);
#endif
#define CAM_FREE_CAPTURE_BUFFER() if (cam_context_p->capture_buffer_p) \
med_free_ext_mem((void**)&cam_context_p->capture_buffer_p)
#define CAM_FREE_INT_BUFFER() if (cam_context_p->intmem_start_address) \
med_free_int_mem((void**)&cam_context_p->intmem_start_address)
#define CAM_FREE_EXT_BUFFER() if (cam_context_p->extmem_start_address) \
med_free_ext_mem((void**)&cam_context_p->extmem_start_address)
#ifdef BARCODE_SUPPORT
#define CAME_FREE_BARCODE_BUFFER() if(cam_context_p->barcode_buffer_address) \
med_free_ext_mem((void**)&cam_context_p->barcode_buffer_address)
#endif
#if defined(ISP_SUPPORT)
#if MT6219_SERIES
kal_int32 cam_capture_mem[2] = {MAX_CAM_CAP_INT_MEM_SIZE, MAX_CAM_CAP_EXT_MEM_SIZE};
kal_int32 cam_preview_mem[2] = {3840, 0};
#else /* MT6219_SERIES */
kal_int32 cam_capture_mem[2] = {MAX_CAM_CAP_INT_MEM_SIZE, MAX_CAM_CAP_EXT_MEM_SIZE};
kal_int32 cam_preview_mem[2] = {46080, 0};
#endif /* MT6219_SERIES */
/* rotate mapping for MT6219 */
kal_uint8 cam_rotate_map[CAM_NO_OF_IMAGE_ROTATE] =
{
IMAGE_NORMAL,
IMAGE_NORMAL,
IMAGE_HV_MIRROR,
IMAGE_NORMAL,
IMAGE_H_MIRROR,
IMAGE_NORMAL,
IMAGE_V_MIRROR,
IMAGE_NORMAL
};
/* wb mapping for MT6219 */
kal_uint8 cam_wb_map[CAM_NO_OF_WB] =
{
0,
DAYLIGHT,
TUNGSTEN,
FLUORESCENT,
CLOUD,
INCANDESCENCE
};
#endif /* defined(ISP_SUPPORT) */
#if defined (ISP_SUPPORT)
camera_capture_mem_struct capture_mem_param;
jpeg_encode_process_struct jpg_encode;
#ifdef BARCODE_DECODER_SCANBUY
camera_capture_barcode_struct capture_barcode_param;
#endif
#endif
#if defined(XENON_FLASHLIGHT) || defined(XENON_FLASHLIGHT_ANTI_RED_EYE)
static void cam_xenon_status_check(void *args);
kal_int32 cam_turn_on_xenonflash(void);
kal_int32 cam_turn_off_xenonflash(void);
#endif
#if (defined(CAMERA_MODULE) || defined(AIT812))
typedef enum
{
CAM_HANDLE_INDEX_DSP = 0x00,
CAM_HANDLE_INDEX_MTK,
CAM_HENDLE_INDEX_MAX
}CAM_HANDLE_INDEX_TYPE;
typedef struct
{
void (*pfunc_cam_power_up_req_hdlr)(ilm_struct * ilm_ptr);
void (*pfunc_cam_power_down_req_hdlr)(ilm_struct * ilm_ptr);
void (*pfunc_cam_preview_req_hdlr)(ilm_struct * ilm_ptr);
void (*pfunc_cam_stop_req_hdlr)(ilm_struct * ilm_ptr);
void (*pfunc_cam_capture_req_hdlr)(ilm_struct * ilm_ptr);
void (*pfunc_cam_set_param_req_hdlr)(ilm_struct * ilm_ptr);
void (*pfunc_cam_mwb_op_req_hdlr)(ilm_struct * ilm_ptr);
void (*pfunc_cam_set_overlay_palette_req_hdlr)(ilm_struct * ilm_ptr);
void (*pfunc_cam_event_ind_hdlr)(ilm_struct * ilm_ptr);
void (*pfunc_cam_preview_restart)(void);
void (*pfunc_cam_abort_to_idle)(void);
}MED_CAM_HANDLE_FUNC;
ext_camera_para_struct cam_param;
lcd_frame_update_struct lcd_param;
//extern void dump_printf(kal_char * fmt,...);
#define SIMC_CAM_PRITNF(state) //dump_printf(#state" %s, %d\r\n", __FILE__, __LINE__);
#define SIMC_CAM_PRINTFV(val) //dump_printf(#val"= %d, %s, %d\r\n", val, __FILE__, __LINE__);
#else
#define SIMC_CAM_PRITNF(state)
#define SIMC_CAM_PRINTFV(val)
#endif
#ifdef __MMI_DSM__
extern int isDsmUseCamera;
#endif
#if defined(OV2640)
extern kal_uint8 jpeg_capture_flag;
#endif
/*==== FUNCTIONS ===========*/
/*****************************************************************************
* FUNCTION
* cam_open_image_file
* DESCRIPTION
* This function is to open image file for capture.
* PARAMETERS
* file_name [?]
* buffer_size [IN]
* RETURNS
* void
*****************************************************************************/
kal_int32 cam_open_image_file(kal_wchar *file_name, kal_uint32 buffer_size)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 result;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* check if the format valid */
/* open the file */
cam_context_p->file_handle = FS_Open((kal_wchar*) file_name, FS_CREATE | FS_READ_WRITE);
if (cam_context_p->file_handle >= 0)
{
/* Check free memory space first */
if ((result = med_check_disc_space(file_name, CAPTURE_MEM_MARGIN)) != MED_RES_OK)
{
FS_Close(cam_context_p->file_handle);
FS_Delete((kal_wchar*) file_name);
return result;
}
/* to release the memory allocated in MED_MODE_BUFFER mode */
CAM_FREE_CAPTURE_BUFFER();
cam_context_p->capture_buffer_p = (kal_uint32) med_alloc_ext_mem(buffer_size);
if (cam_context_p->capture_buffer_p == NULL)
{
FS_Close(cam_context_p->file_handle);
FS_Delete((kal_wchar*) file_name);
return MED_RES_MEM_INSUFFICIENT;
}
else
{
cam_context_p->file_name_p = (kal_wchar*) file_name;
return MED_RES_OK;
}
}
else if (cam_context_p->file_handle == FS_WRITE_PROTECTION)
{
return MED_RES_WRITE_PROTECTION;
}
else if ((cam_context_p->file_handle == FS_ROOT_DIR_FULL) || (cam_context_p->file_handle == FS_DISK_FULL))
{
return MED_RES_DISC_FULL;
}
else
{
return MED_RES_OPEN_FILE_FAIL;
}
}
/*****************************************************************************
* FUNCTION
* cam_close_image_file
* DESCRIPTION
* This function is to close image file for capture.
* PARAMETERS
* size [IN]
* RETURNS
* void
*****************************************************************************/
kal_int32 cam_close_image_file(kal_uint32 size)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 result;
kal_uint32 len;
kal_int32 res = MED_RES_OK;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (size > 0)
{
result = FS_Write(cam_context_p->file_handle, (void*)cam_context_p->capture_buffer_p, size, &len);
FS_Close(cam_context_p->file_handle);
if (result != FS_NO_ERROR)
{
CAM_CLOSE_IMAGE_RESULT_TRACE(result);
FS_Delete((kal_wchar*) cam_context_p->file_name_p);
if (result == FS_DRIVE_NOT_FOUND)
{
res = MED_RES_NO_DISC;
}
else if (result == FS_DISK_FULL)
{
res = MED_RES_DISC_FULL;
}
else
{
res = MED_RES_OPEN_FILE_FAIL;
}
}
else if (size != len)
{
FS_Delete((kal_wchar*) cam_context_p->file_name_p);
res = MED_RES_DISC_FULL;
}
}
else
{
/* Close and delete the file */
FS_Close(cam_context_p->file_handle);
FS_Delete((kal_wchar*) cam_context_p->file_name_p);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -