一.關(guān)于H-sync /V-Sync的知識(shí):
1. 分辨率:比如說(shuō)640x480,就會(huì)有640 個(gè)pixel &480 line,那么每個(gè)V-sync的信號(hào)時(shí)間內(nèi)就會(huì)有480個(gè)H-sync,而一個(gè)H-sync會(huì)有640個(gè)pixel。但是,每個(gè)pixel會(huì)有2 byte,所以我們會(huì)量到PCLK 在一個(gè)H-sync內(nèi)的數(shù)量會(huì)有1280個(gè)。
2. H-sync /V-Sync的極性polarity: polarity就是資料有效的準(zhǔn)備,比方說(shuō)V-sync上的H-sync有可能在V-sync的low,也有可能在high出現(xiàn)。
二. 所使用的ISP處理器簡(jiǎn)介:XXX838是一款isp(圖像信號(hào)處理器)ic,核心是一款arm7 process,提供自動(dòng)對(duì)焦,人臉識(shí)別等功能。BB通過(guò)i2c與其進(jìn)行命令類的數(shù)據(jù)通信,而sensor數(shù)據(jù)則通過(guò)CCIR總線傳輸給BB.
三. 25平臺(tái) camera處理流程學(xué)習(xí)
1. void cam_event_ind_hdlr(ilm_struct *ilm_ptr)// This function is to handle camera event indication.
在該函數(shù)中,通過(guò)camera_capture_mem_process(&capture_mem_param)命令從lcd層獲取capture數(shù)據(jù),然后通過(guò)jpeg_encode_process(&jpg_encode)命令將這些數(shù)據(jù)軟編碼成jpeg格式的數(shù)據(jù)。
2. void cam_capture_req_hdlr(ilm_struct *ilm_ptr)// This function is to handle camera capture request.
(1) 該函數(shù)首先執(zhí)行exit_camera_preview_process();命令退出preview流程;
(2) ./* copy preview data to MMI buffer */
memcpy(
(kal_uint8*) cam_context_p->frame_buffer_p,
(kal_uint8*) cam_context_p->int_frame_buffer_p,
cam_context_p->frame_buffer_size);
(3). /* release preview related memory */
cam_release_memory();
3.cam_context_p->capture_buffer_p :所需存儲(chǔ)的拍照數(shù)據(jù)指針
cam_context_p->file_size :所要存儲(chǔ)的數(shù)據(jù)大小
4. 在cam_open_image_file函數(shù)中執(zhí)行命令
cam_context_p->capture_buffer_p = (kal_uint32) med_alloc_ext_mem(buffer_size);
來(lái)分配內(nèi)存。
Capture數(shù)據(jù)存儲(chǔ)指針:capture_isp_param.target_buffer_start_address = (kal_uint32) cam_context_p->capture_buffer_p;
camera_capture_jpeg_process(&capture_isp_param);
isp_capture_jpeg_data.target_buffer_start_address=isp_data->target_buffer_start_address;
sw_jpeg_encode_config_data.jpeg_file_start_address=isp_capture_jpeg_data.target_buffer_start_address;
5. camera capture后的數(shù)據(jù)傳送流程:cam_context_p->intmem_start_address.
(1). capture_isp_param.intmem_start_address = cam_context_p->intmem_start_address =
(kal_uint32) med_alloc_int_mem(cam_capture_mem[0]);//只有45k
capture_isp_param.intmem_size = cam_context_p->intmem_size = (kal_uint32) cam_capture_mem[0];
(2). file_size = camera_capture_jpeg_process(&capture_isp_param); //jpeg編碼后的文件大小
(3).isp_capture_jpeg_data.intmem_start_address=isp_data->intmem_start_address;
isp_capture_jpeg_data.intmem_size=isp_data->intmem_size;
(4). intmem_init((kal_uint32 *) isp_capture_jpeg_data.intmem_start_address,
isp_capture_jpeg_data.intmem_size);
(5).sw_jpeg_encode_config_data.intmem_start_address=isp_capture_jpeg_data.intmem_start_address; //將所獲取的capture原始數(shù)據(jù)地址指針賦給軟編碼的起始地址
四.調(diào)試關(guān)鍵點(diǎn)
1. 首先調(diào)通I2C通訊,必須確保BB與ISP的I2C通訊正常;
2. 重新定義#define MAX_CAM_FILE_BUFFER_LEN (3150*1024) /* 2700kb for 5.0M */
3.仿照camera_capture_jpeg_process函數(shù),創(chuàng)建一個(gè)新函數(shù),在該函數(shù)中對(duì)獲取的數(shù)據(jù)直接存儲(chǔ),而不經(jīng)過(guò)jpeg編碼流程(由于XXX838傳輸過(guò)來(lái)的已經(jīng)是jpeg格式的數(shù)據(jù))。
注意:
(1) 在該函數(shù)中,要設(shè)置:
ENABLE_CAMERA_OUTPUT_TO_MEM;//ISP輸出至Memory,
SET_CAMERA_CAPTURE_MODE
/*** Capture,等待VSYNC中斷**/
(2).在capture完成后,要DISABLE_CMOS_SESNOR;//關(guān)閉sensor信號(hào)。
(3).此時(shí),獲取的capture的數(shù)據(jù)已經(jīng)存儲(chǔ)在isp_data->target_buffer_start_address中;
然后讀取這些數(shù)據(jù),通過(guò)0xff ,0xd8判斷文件頭,0xff ,0xd9判斷jpeg文件尾及其長(zhǎng)度。
(4)最后,通過(guò)kal_int32 cam_close_image_file(kal_uint32 size)保存文件