📄 usbvideo_drv.c
字号:
usbvideo_still_size_struct *still_ind;
usbvideo_still_dma_struct *still_dma;
usbvideo_result_struct *result;
ilm_struct *send_ilm;
module_type dest_mod;
#if ( (defined(__WEBCAM_CAMERA_TEST__)) || (defined(__WEBCAM_USB_TEST__)) )
dest_mod = MOD_CUSTOM1;
#else
dest_mod = MOD_MED;
#endif
if(msg_type == USBVIDEO_MSG_MED_START_SUCCESS_CNF)
{
start_cnf = (usbvideo_video_size_struct*)construct_local_para(
sizeof(usbvideo_video_size_struct), TD_CTRL);
start_cnf->video_size_type = (USBVIDEO_VIDEO_SIZE_TYPE)param1;
start_cnf->video_compression_type = (USBVIDEO_COMPRESSION_TYPE)param2;
start_cnf->result = KAL_TRUE;
DRV_BuildPrimitive(send_ilm,
MOD_USB,
dest_mod,
MSG_ID_USB_MED_START_VIDEO_CNF,
start_cnf);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_MED_START_FAIL_CNF)
{
start_cnf = (usbvideo_video_size_struct*)construct_local_para(
sizeof(usbvideo_video_size_struct), TD_CTRL);
start_cnf->video_size_type = (USBVIDEO_VIDEO_SIZE_TYPE)param1;
start_cnf->video_compression_type = (USBVIDEO_COMPRESSION_TYPE)param2;
start_cnf->result = KAL_FALSE; /* because USB cable plug out */
DRV_BuildPrimitive(send_ilm,
MOD_USB,
dest_mod,
MSG_ID_USB_MED_START_VIDEO_CNF,
start_cnf);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_MED_CHANGE_VIDEO_IND)
{
start_cnf = (usbvideo_video_size_struct*)construct_local_para(
sizeof(usbvideo_video_size_struct), TD_CTRL);
start_cnf->video_size_type = (USBVIDEO_VIDEO_SIZE_TYPE)param1;
start_cnf->video_compression_type = (USBVIDEO_COMPRESSION_TYPE)param2;
start_cnf->result = KAL_TRUE;
DRV_BuildPrimitive(send_ilm,
MOD_USB,
dest_mod,
MSG_ID_USB_MED_CHANGE_VIDEO_IND,
start_cnf);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_MED_STILL_CAPTURE_IND)
{
still_ind = (usbvideo_still_size_struct*)construct_local_para(
sizeof(usbvideo_still_size_struct), TD_CTRL);
still_ind->still_size_type = (USBVIDEO_STILL_SIZE_TYPE)param1;
still_ind->still_compression_type = (USBVIDEO_COMPRESSION_TYPE)param2;
DRV_BuildPrimitive(send_ilm,
MOD_USB,
dest_mod,
MSG_ID_USB_MED_START_STILL_IND,
still_ind);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_MED_START_IND)
{
start_cnf = (usbvideo_video_size_struct*)construct_local_para(
sizeof(usbvideo_video_size_struct), TD_CTRL);
start_cnf->video_size_type = (USBVIDEO_VIDEO_SIZE_TYPE)param1;
start_cnf->video_compression_type = (USBVIDEO_COMPRESSION_TYPE)param2;
start_cnf->result = KAL_TRUE;
DRV_BuildPrimitive(send_ilm,
MOD_USB,
dest_mod,
MSG_ID_USB_MED_START_VIDEO_IND, /* restart video after still capture */
start_cnf);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_MED_DEVICE_STILL_CNF) /* be used at HW trigger */
{
result = (usbvideo_result_struct*)construct_local_para(
sizeof(usbvideo_result_struct), TD_CTRL);
result->result = (kal_bool) param1;
DRV_BuildPrimitive(send_ilm,
MOD_USB,
dest_mod,
MSG_ID_USB_MED_DEVICE_STILL_CNF,
result);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_MED_PAUSE_CNF)
{
result = (usbvideo_result_struct*)construct_local_para(
sizeof(usbvideo_result_struct), TD_CTRL);
result->result = (kal_bool) param1;
DRV_BuildPrimitive(send_ilm,
MOD_USB,
dest_mod,
MSG_ID_USB_MED_PAUSE_CNF,
result);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_MED_RESUME_SUCCESS_CNF)
{
start_cnf = (usbvideo_video_size_struct*)construct_local_para(
sizeof(usbvideo_video_size_struct), TD_CTRL);
start_cnf->video_size_type = (USBVIDEO_VIDEO_SIZE_TYPE)param1;
start_cnf->video_compression_type = (USBVIDEO_COMPRESSION_TYPE)param2;
start_cnf->result = KAL_TRUE;
DRV_BuildPrimitive(send_ilm,
MOD_USB,
dest_mod,
MSG_ID_USB_MED_RESUME_VIDEO_CNF,
start_cnf);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_MED_RESUME_FAIL_CNF)
{
start_cnf = (usbvideo_video_size_struct*)construct_local_para(
sizeof(usbvideo_video_size_struct), TD_CTRL);
start_cnf->video_size_type = (USBVIDEO_VIDEO_SIZE_TYPE)param1;
start_cnf->video_compression_type = (USBVIDEO_COMPRESSION_TYPE)param2;
start_cnf->result = KAL_FALSE;
DRV_BuildPrimitive(send_ilm,
MOD_USB,
dest_mod,
MSG_ID_USB_MED_RESUME_VIDEO_CNF,
start_cnf);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_MED_STOP_IND) /*stop because of cable plugging out */
{
DRV_BuildPrimitive(send_ilm,
MOD_USB,
dest_mod,
MSG_ID_USB_MED_STOP_IND,
NULL);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_MED_STOP_CNF) /* stop request from media task */
{
result = (usbvideo_result_struct*)construct_local_para(
sizeof(usbvideo_result_struct), TD_CTRL);
result->result = (kal_bool) param1;
DRV_BuildPrimitive(send_ilm,
MOD_USB,
dest_mod,
MSG_ID_USB_MED_STOP_CNF,
result);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_MED_ABORT_IND) /* OS sleep then wakeup, webcam must be abort */
{
DRV_BuildPrimitive(send_ilm,
MOD_USB,
dest_mod,
MSG_ID_USB_MED_ABORT_IND,
NULL);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_USB_ENUM_DONE)
{
DRV_BuildPrimitive(send_ilm,
MOD_DRV_HISR,
MOD_USB,
MSG_ID_USB_ENUM_DONE,
NULL);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_USB_COMPLETE_VIDEO)
{
/* !!! Note that source need to modify after camera phase in*/
DRV_BuildPrimitive(send_ilm,
MOD_GPT_HISR,/* not correct */
MOD_USB,
MSG_ID_USB_VIDEO_COMPLETE,
NULL);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_USB_DMA_DONE)
{
DRV_BuildPrimitive(send_ilm,
param1,
MOD_USB,
MSG_ID_USB_VIDEO_DMA_DONE,
NULL);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_USB_CHANGE_SIZE)
{
DRV_BuildPrimitive(send_ilm,
MOD_DRV_HISR,
MOD_USB,
MSG_ID_USB_VIDEO_CHANGE_SIZE,
NULL);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_USB_STILL_CAPTURE)
{
DRV_BuildPrimitive(send_ilm,
MOD_DRV_HISR,
MOD_USB,
MSG_ID_USB_STILL_CAPTURE,
NULL);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_USB_COMPLETE_STILL)
{
/* !!! Note that source need to modify after camera phase in*/
DRV_BuildPrimitive(send_ilm,
MOD_GPT_HISR,/* not correct */
MOD_USB,
MSG_ID_USB_STILL_COMPLETE,
NULL);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_USB_STILL_DMA_DONE)
{
DRV_BuildPrimitive(send_ilm,
param1,
MOD_USB,
MSG_ID_USB_VIDEO_STILL_DMA_DONE,
NULL);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_USB_STILL_DMA_PARTIAL)
{
still_dma = (usbvideo_still_dma_struct*)construct_local_para(
sizeof(usbvideo_still_dma_struct), TD_CTRL);
still_dma->index = param1;
DRV_BuildPrimitive(send_ilm,
MOD_DRV_HISR,
MOD_USB,
MSG_ID_USB_VIDEO_STILL_DMA_PARTIAL,
still_dma);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_USB_INCALL_DMA_DONE)
{
DRV_BuildPrimitive(send_ilm,
param1,
MOD_USB,
MSG_ID_USB_VIDEO_INCALL_DMA_DONE,
NULL);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_USB_INCALL_TIMEOUT)
{
DRV_BuildPrimitive(send_ilm,
MOD_GPT_HISR,
MOD_USB,
MSG_ID_USB_VIDEO_INCALL_TIMEOUT,
NULL);
msg_send_ext_queue(send_ilm);
}
else if (msg_type == USBVIDEO_MSG_USB_INCALL_CHANGE_SIZE)
{
DRV_BuildPrimitive(send_ilm,
MOD_DRV_HISR,
MOD_USB,
MSG_ID_USB_VIDEO_INCALL_CHANGE_SIZE,
NULL);
msg_send_ext_queue(send_ilm);
}
else if(msg_type == USBVIDEO_MSG_USB_ABORT)
{
DRV_BuildPrimitive(send_ilm,
MOD_DRV_HISR,
MOD_USB,
MSG_ID_USB_VIDEO_ABORT,
NULL);
msg_send_ext_queue(send_ilm);
}
}
/************************************************************
interface initialization functions
*************************************************************/
/* video control interface create function, prepare descriptor */
void USBVideo_VC_If_Create(void *ifname)
{
kal_uint8 ep_id;
kal_uint8 if_id;
USBVideo_Attr_Value attr_value;
const USBVideo_Attr_Info* attr_info = NULL;
kal_uint8 attr_size;
kal_uint32 attr_index;
kal_uint32 map_index, map_size;
kal_uint16 ct_attr = 0;
kal_uint16 pu_attr = 0;
kal_uint32 total_size;
kal_uint8* p_desc;
kal_uint32 if_desc_index = 0;
kal_uint32 ep_desc_index = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -