📄 usbvideo_drv.c
字号:
((Usb_If_Dscr*)p_desc)->bInterfaceClass = USBVIDEO_CC_VIDEO;
((Usb_If_Dscr*)p_desc)->bInterfaceSubClass = USBVIDEO_SC_VIDEOSTREAMING;
((Usb_If_Dscr*)p_desc)->bInterfaceProtocol = USBVIDEO_PC_PROTOCOL_UNDEFINED;
((Usb_If_Dscr*)p_desc)->iInterface = USB_Get_String_Number((void *)g_USBVideo.custom_param->vs_interface_string);
kal_mem_cpy(&g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index ], p_desc, USB_IFDSC_LENGTH);
if_desc_index += USB_IFDSC_LENGTH;
free_ctrl_buffer(p_desc);
/* class specific VS interface descriptor, input header descriptor */
p_desc = get_ctrl_buffer(sizeof(USBVideo_Class_VS_If_Dscr));
((USBVideo_Class_VS_If_Dscr*)p_desc)->bLength = USBVIDEO_VS_INTERFACE_LENGTH;
((USBVideo_Class_VS_If_Dscr*)p_desc)->bDescriptorType = USBVIDEO_CS_INTERFACE;
((USBVideo_Class_VS_If_Dscr*)p_desc)->bDescriptorSubType = USBVIDEO_VS_INPUT_HEADER;
((USBVideo_Class_VS_If_Dscr*)p_desc)->bNumFormats = 0x01; /* one format descriptor for MJPEG*/
total_length = sizeof(USBVideo_Class_VS_If_Dscr)+sizeof(USBVideo_MJPEG_Format_Dscr)
+(video_size_num*sizeof(USBVideo_MJPEG_Frame_Dscr))
+USBVIDEO_VS_STILL_LENGTH + (sizeof(USBVideo_Still_Size)*still_size_num) + (sizeof(kal_uint8)*compression_num)
+sizeof(USBVideo_Color_Dscr);
((USBVideo_Class_VS_If_Dscr*)p_desc)->wTotalLength[0] = total_length&0xff;
((USBVideo_Class_VS_If_Dscr*)p_desc)->wTotalLength[1] = (total_length>>8)&0xff;
((USBVideo_Class_VS_If_Dscr*)p_desc)->bEndpointAddress = (USB_EP_DIR_IN | ep_in_id); /*InPipe*/
((USBVideo_Class_VS_If_Dscr*)p_desc)->bmInfo = 0; /* No dynamic format change support */
((USBVideo_Class_VS_If_Dscr*)p_desc)->bTerminalLink = USBVIDEO_OT_ID;
((USBVideo_Class_VS_If_Dscr*)p_desc)->bStillCaptureMethod = USBVIDEO_STILL_CAPTURE_METHOD_2;
#ifdef __USBVIDEO_DEVICE_TRIGGER_SUPPORT__
((USBVideo_Class_VS_If_Dscr*)p_desc)->bTriggerSupport = USBVIDEO_HARDWARE_TRIGGER_SUPPORT;
((USBVideo_Class_VS_If_Dscr*)p_desc)->bTriggerUsage = USBVIDEO_HARDWARE_TRIGGER_STILL;
#else
((USBVideo_Class_VS_If_Dscr*)p_desc)->bTriggerSupport = USBVIDEO_HARDWARE_TRIGGER_NOT_SUPPORT;
((USBVideo_Class_VS_If_Dscr*)p_desc)->bTriggerUsage = 0;
#endif
((USBVideo_Class_VS_If_Dscr*)p_desc)->bControlSize = 1;
((USBVideo_Class_VS_If_Dscr*)p_desc)->bmaControls = 0;
kal_mem_cpy(&g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index], p_desc, USBVIDEO_VS_INTERFACE_LENGTH);
if_desc_index +=USBVIDEO_VS_INTERFACE_LENGTH;
free_ctrl_buffer(p_desc);
/* MJPEG video format descriptor */
p_desc = get_ctrl_buffer(sizeof(USBVideo_MJPEG_Format_Dscr));
((USBVideo_MJPEG_Format_Dscr*)p_desc)->bLength = USBVIDEO_VS_MJPEG_FORMAT_LENGTH;
((USBVideo_MJPEG_Format_Dscr*)p_desc)->bDescriptorType = USBVIDEO_CS_INTERFACE;
((USBVideo_MJPEG_Format_Dscr*)p_desc)->bDescriptorSubType = USBVIDEO_VS_FORMAT_MJPEG;
((USBVideo_MJPEG_Format_Dscr*)p_desc)->bFormatIndex = 1;
((USBVideo_MJPEG_Format_Dscr*)p_desc)->bNumFrameDescriptors = video_size_num;
((USBVideo_MJPEG_Format_Dscr*)p_desc)->bmFlags = USBVIDEO_FIXED_SIZE_SAMPLES;
((USBVideo_MJPEG_Format_Dscr*)p_desc)->bDefaultFrameIndex = g_USBVideo.camera_param->usbvideo_get_default_video_index();
((USBVideo_MJPEG_Format_Dscr*)p_desc)->bAspectRatioX = 0;
((USBVideo_MJPEG_Format_Dscr*)p_desc)->bAspectRatioY = 0;
((USBVideo_MJPEG_Format_Dscr*)p_desc)->bmInterlaceFlags = 0;
((USBVideo_MJPEG_Format_Dscr*)p_desc)->bCopyProtect = 0;
kal_mem_cpy(&g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index], p_desc, USBVIDEO_VS_MJPEG_FORMAT_LENGTH);
if_desc_index += USBVIDEO_VS_MJPEG_FORMAT_LENGTH;
free_ctrl_buffer(p_desc);
/* MJPEG frame descriptor */
p_desc = get_ctrl_buffer(sizeof(USBVideo_MJPEG_Frame_Dscr)*video_size_num);
for(index = 0; index < video_size_num; index++)
{
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].bLength = USBVIDEO_VS_MJPEG_FRAME_LENGTH;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].bDescriptorType = USBVIDEO_CS_INTERFACE;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].bDescriptorSubType = USBVIDEO_VS_FRAME_MJPEG;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].bFrameIndex = p_video_size_param[index].type;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].bmCapabilities = 0;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].wWidth[0] = p_video_size_param[index].width&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].wWidth[1] = (p_video_size_param[index].width>>8)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].wHeight[0] = p_video_size_param[index].height&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].wHeight[1] = (p_video_size_param[index].height>>8)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMinBitRate[0] = p_video_size_param[index].min_bit_rate&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMinBitRate[1] = (p_video_size_param[index].min_bit_rate>>8)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMinBitRate[2] = (p_video_size_param[index].min_bit_rate>>16)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMinBitRate[3] = (p_video_size_param[index].min_bit_rate>>24)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMaxBitRate[0] = p_video_size_param[index].max_bit_rate&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMaxBitRate[1] = (p_video_size_param[index].max_bit_rate>>8)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMaxBitRate[2] = (p_video_size_param[index].max_bit_rate>>16)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMaxBitRate[3] = (p_video_size_param[index].max_bit_rate>>24)&0xff;
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
if(g_USBVideo.video_control.b_set_default_jpeg_max_size[index]==KAL_FALSE)
EXT_ASSERT(0, index, 0, 0);
max_frame_size = USBVideo_Get_Max(p_video_size_param[index].max_frame_size,
g_USBVideo.video_control.default_jpeg_max_size[index]);
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMaxVideoFrameBufferSize[0] = max_frame_size&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMaxVideoFrameBufferSize[1] = (max_frame_size>>8)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMaxVideoFrameBufferSize[2] = (max_frame_size>>16)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMaxVideoFrameBufferSize[3] = (max_frame_size>>24)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwDefaultFrameInterval[0] = p_video_size_param[index].default_frame_interval&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwDefaultFrameInterval[1] = (p_video_size_param[index].default_frame_interval>>8)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwDefaultFrameInterval[2] = (p_video_size_param[index].default_frame_interval>>16)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwDefaultFrameInterval[3] = (p_video_size_param[index].default_frame_interval>>24)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].bFrameIntervalType = 0;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMinFrameInterval[0] = p_video_size_param[index].min_frame_interval&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMinFrameInterval[1] = (p_video_size_param[index].min_frame_interval>>8)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMinFrameInterval[2] = (p_video_size_param[index].min_frame_interval>>16)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMinFrameInterval[3] = (p_video_size_param[index].min_frame_interval>>24)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMaxFrameInterval[0] = p_video_size_param[index].max_frame_interval&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMaxFrameInterval[1] = (p_video_size_param[index].max_frame_interval>>8)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMaxFrameInterval[2] = (p_video_size_param[index].max_frame_interval>>16)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwMaxFrameInterval[3] = (p_video_size_param[index].max_frame_interval>>24)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwFrameIntervalStep[0] = p_video_size_param[index].frame_interval_step&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwFrameIntervalStep[1] = (p_video_size_param[index].frame_interval_step>>8)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwFrameIntervalStep[2] = (p_video_size_param[index].frame_interval_step>>16)&0xff;
((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index].dwFrameIntervalStep[3] = (p_video_size_param[index].frame_interval_step>>24)&0xff;
kal_mem_cpy(&g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index], &((USBVideo_MJPEG_Frame_Dscr*)p_desc)[index], USBVIDEO_VS_MJPEG_FRAME_LENGTH);
if_desc_index +=USBVIDEO_VS_MJPEG_FRAME_LENGTH;
}
free_ctrl_buffer(p_desc);
/* still image frame descriptor */
p_desc = get_ctrl_buffer(sizeof(USBVideo_Still_Frame_Dscr));
((USBVideo_Still_Frame_Dscr*)p_desc)->bLength =
USBVIDEO_VS_STILL_LENGTH + (sizeof(USBVideo_Still_Size)*still_size_num) + (sizeof(kal_uint8)*compression_num);
((USBVideo_Still_Frame_Dscr*)p_desc)->bDescriptorType = USBVIDEO_CS_INTERFACE;
((USBVideo_Still_Frame_Dscr*)p_desc)->bDescriptorSubType = USBVIDEO_VS_STILL_IMAGE_FRAME;
((USBVideo_Still_Frame_Dscr*)p_desc)->bEndpointAddress = 0; /*for method 2*/
((USBVideo_Still_Frame_Dscr*)p_desc)->bNumImageSizePatterns = still_size_num;
((USBVideo_Still_Frame_Dscr*)p_desc)->bNumCompressionPattern = compression_num;
((USBVideo_Still_Frame_Dscr*)p_desc)->p_image_patterns = (USBVideo_Still_Size *)get_ctrl_buffer(sizeof(USBVideo_Still_Size)*still_size_num);
((USBVideo_Still_Frame_Dscr*)p_desc)->p_compression_patterns = (kal_uint8 *)get_ctrl_buffer(sizeof(kal_uint8)*compression_num);
for(index = 0; index < still_size_num; index++)
{
((USBVideo_Still_Frame_Dscr*)p_desc)->p_image_patterns[index].wWidth[0] = p_still_size_param[index].width&0xff;
((USBVideo_Still_Frame_Dscr*)p_desc)->p_image_patterns[index].wWidth[1] = (p_still_size_param[index].width>>8)&0xff;
((USBVideo_Still_Frame_Dscr*)p_desc)->p_image_patterns[index].wHeight[0] = p_still_size_param[index].height&0xff;
((USBVideo_Still_Frame_Dscr*)p_desc)->p_image_patterns[index].wHeight[1] = (p_still_size_param[index].height>>8)&0xff;
}
for(index = 0; index < compression_num; index++)
{
((USBVideo_Still_Frame_Dscr*)p_desc)->p_compression_patterns[index] = p_compression_param[index].compression;
}
g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index] = ((USBVideo_Still_Frame_Dscr*)p_desc)->bLength;
g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index+1] = ((USBVideo_Still_Frame_Dscr*)p_desc)->bDescriptorType;
g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index+2] = ((USBVideo_Still_Frame_Dscr*)p_desc)->bDescriptorSubType;
g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index+3] = ((USBVideo_Still_Frame_Dscr*)p_desc)->bEndpointAddress;
g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index+4] = ((USBVideo_Still_Frame_Dscr*)p_desc)->bNumImageSizePatterns;
if_desc_index+=5;
kal_mem_cpy(&g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index], ((USBVideo_Still_Frame_Dscr*)p_desc)->p_image_patterns, sizeof(USBVideo_Still_Size)*still_size_num);
if_desc_index +=(sizeof(USBVideo_Still_Size)*still_size_num);
g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index] = ((USBVideo_Still_Frame_Dscr*)p_desc)->bNumCompressionPattern;
if_desc_index+=1;
kal_mem_cpy(&g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index], ((USBVideo_Still_Frame_Dscr*)p_desc)->p_compression_patterns, sizeof(kal_uint8)*compression_num);
if_desc_index +=(sizeof(kal_uint8)*compression_num);
free_ctrl_buffer(((USBVideo_Still_Frame_Dscr*)p_desc)->p_image_patterns);
free_ctrl_buffer(((USBVideo_Still_Frame_Dscr*)p_desc)->p_compression_patterns);
free_ctrl_buffer(p_desc); /* should be freed last one */
/* color matching descriptor */
p_desc = get_ctrl_buffer(sizeof(USBVideo_Color_Dscr));
((USBVideo_Color_Dscr*)p_desc)->bLength = USBVIDEO_VS_COLOR_MATCHING_LENGTH;
((USBVideo_Color_Dscr*)p_desc)->bDescriptorType = USBVIDEO_CS_INTERFACE;
((USBVideo_Color_Dscr*)p_desc)->bDescriptorSubType = USBVIDEO_VS_COLORFORMAT;
((USBVideo_Color_Dscr*)p_desc)->bColorPrimaries = 0;
((USBVideo_Color_Dscr*)p_desc)->bTransferCharacteristics = 0;
((USBVideo_Color_Dscr*)p_desc)->bMatrixCoefficients = 0;
kal_mem_cpy(&g_USBVideo.vs_if_info->ifdscr.classif[if_desc_index], p_desc, USBVIDEO_VS_COLOR_MATCHING_LENGTH);
if_desc_index += USBVIDEO_VS_COLOR_MATCHING_LENGTH;
free_ctrl_buffer(p_desc);
/* endpoint handler */
USB_Register_Drv_Info(USB_DRV_HDLR_EP_IN, ep_in_id, NULL);
g_USBVideo.vs_ep_in_info->ep_reset = USBVideo_BulkIn_Reset;
/* endpoint descriptor */
g_USBVideo.vs_ep_in_info->epdesc.stdep.bLength = USB_EPDSC_LENGTH;
g_USBVideo.vs_ep_in_info->epdesc.stdep.bDescriptorType = USB_ENDPOINT;
g_USBVideo.vs_ep_in_info->epdesc.stdep.bEndpointAddress = (USB_EP_DIR_IN | ep_in_id); /*InPipe*/
g_USBVideo.vs_ep_in_info->epdesc.stdep.bmAttributes = USB_EP_BULK;
g_USBVideo.vs_ep_in_info->epdesc.stdep.wMaxPacketSize[0] = USB_EP_BULK_MAXP&0xff;
g_USBVideo.vs_ep_in_info->epdesc.stdep.wMaxPacketSize[1] = (USB_EP_BULK_MAXP>>8)&0xff;
g_USBVideo.vs_ep_in_info->epdesc.stdep.bInterval = 0;
g_USBVideo.vs_ep_in_info->ep_status.epin_status.byEP = ep_in_id;
g_USBVideo.vs_ep_in_info->ep_status.epin_status.nBytesLeft = USB_EP_NODATA;
USB_Get_DMA_Channel(ep_in_id);
/* construct interface size */
g_USBVideo.vs_if_info->ifdscr_size = if_desc_index;
g_USBVideo.vs_ep_in_info->epdscr_size = USB_EPDSC_LENGTH;
/* construct IAD descriptor */
g_USBVideo.iad_desc = USB_Get_IAD_Number(&iad_id);
g_USBVideo.iad_desc->bLength = USB_IAD_LENGTH;
g_USBVideo.iad_desc->bDescriptorType = USB_INTERFACE_ASSOCIATION;
g_USBVideo.iad_desc->bFirstInterface = g_USBVideo.vc_if_info->ifdscr.stdif.bInterfaceNumber;
g_USBVideo.iad_desc->bInterfaceCount = gUsbDevice.resource_interface_number;
g_USBVideo.iad_desc->bFunctionClass = USBVIDEO_CC_VIDEO;
g_USBVideo.iad_desc->bFunctionSubClass = USBVIDEO_SC_VIDEO_INTERFACE_COLLECTION;
g_USBVideo.iad_desc->bFunctionProtocol = USBVIDEO_PC_PROTOCOL_UNDEFINED;
g_USBVideo.iad_desc->iFunction = USB_Get_String_Number((void *)g_USBVideo.custom_param->iad_function_string);
/* construct video probe and control setting */
/* assign default value first, may be changed in the probe and commit flow */
index = g_USBVideo.camera_param->usbvideo_get_default_video_index();
g_USBVideo.vs_probe_control.bmHint[0] = 0;
g_USBVideo.vs_probe_control.bmHint[1] = 0;
g_USBVideo.vs_probe_control.bFormatIndex = 1; /* only one MJPEG format */
g_USBVideo.vs_probe_control.bFrameIndex = index;
g_USBVideo.vs_probe_control.dwFrameInterval[0] = p_video_size_param[index-1].default_frame_interval&0xff;
g_USBVideo.vs_probe_control.dwFrameInterval[1] = (p_video_size_param[index-1].default_frame_interval>>8)&0xff;
g_USBVideo.vs_probe_control.dwFrameInterval[2] = (p_video_size_param[index-1].default_frame_interval>>16)&0xff;
g_USBVideo.vs_probe_control.dwFrameInterval[3] = (p_video_size_param[index-1].default_frame_interval>>24)&0xff;
g_USBVideo.vs_probe_control.wKeyFrameRate[0] = 1;
g_USBVideo.vs_probe_control.wKeyFrameRate[1] = 0;
g_USBVideo.vs_probe_control.wPFrameRate[0] = 0;
g_USBVideo.vs_probe_control.wPFrameRate[1] = 0;
g_USBVideo.vs_probe_control.wCompQuality[0] = 0;
g_USBVideo.vs_probe_control.wCompQuality[1] = 0;
g_USBVideo.vs_probe_control.wCompWindowSize[0] = 0;
g_USBVideo.vs_probe_control.wCompWindowSize[1] = 0;
g_USBVideo.vs_probe_control.wDelay[0] = 0;
g_USBVideo.vs_probe_control.wDelay[1] = 0;
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
max_frame_size = USBVideo_Get_Max(p_video_size_param[index-1].max_frame_size,
g_USBVideo.video_control.default_jpeg_max_size[index-1]);
g_USBVideo.vs_probe_control.dwMaxVideoFrameSize[0] = max_frame_size&0xff;
g_USBVideo.vs_probe_control.dwMaxVideoFrameSize[1] = (max_frame_size>>8)&0xff;
g_USBVideo.vs_probe_control.dwMaxVideoFrameSize[2] = (max_frame_size>>16)&0xff;
g_USBVideo.vs_probe_control.dwMaxVideoFrameSize[3] = (max_frame_size>>24)&0xff;
g_USBVideo.vs_probe_control.dwMaxPayloadTransferSize[0] = USBVIDEO_MAX_PAYLOAD_LENGTH&0xff;
g_USBVideo.vs_probe_control.dwMaxPayloadTransferSize[1] = (USBVIDEO_MAX_PAYLOAD_LENGTH>>8)&0xff;
g_USBVideo.vs_probe_control.dwMaxPayloadTransferSize[2] = (USBVIDEO_MAX_PAYLOAD_LENGTH>>16)&0xff;
g_USBVideo.vs_probe_control.dwMaxPayloadTransferSize[3] = (USBVIDEO_MAX_PAYLOAD_LENGTH>>24)&0xff;
/* for 1.1 version */
/*
g_USBVideo.vs_probe_control.dwClockFrequency[0] = USBVIDEO_CLOCK_FREQUENCY&0xff;
g_USBVideo.vs_probe_control.dwClockFrequency[1] = (USBVIDEO_CLOCK_FREQUENCY>>8)&0xff;
g_USBVideo.vs_probe_control.dwClockFrequency[2] = (USBVIDEO_CLOCK_FREQUENCY>>16)&0xff;
g_USBVideo.vs_probe_control.dwClockFrequency[3] = (USBVIDEO_CLOCK_FREQUENCY>>24)&0xff;
g_USBVideo.vs_probe_control.bmFramingInfo = 0;
g_USBVideo.vs_probe_control.bPreferedVersion = 1;
g_USBVideo.vs_probe_control.bMinVersion = 0;
g_USBVideo.vs_probe_control.bMaxVersion = 1;
*/
/* construct still probe and control setting */
/* assign default value first, may be changed in the probe and commit flow */
index = g_USBVideo.camera_param->usbvideo_get_default_still_index();
g_USBVideo.vs_still_probe_control.bFormatIndex = 1;
g_USBVideo.vs_still_probe_control.bFrameIndex = index;
g_USBVideo.vs_still_probe_control.bCompressionIndex = g_USBVideo.camera_param->usbvideo_get_default_compression_index();
g_USBVideo.vs_still_probe_control.dwMaxVideoFrameSize[0] = p_still_size_param[index-1].max_frame_size&0xff;
g_USBVideo.vs_still_probe_control.dwMaxVideoFrameSize[1] = (p_still_size_param[index-1].max_frame_size>>8)&0xff;
g_USBVideo.vs_still_probe_control.dwMaxVideoFrameSize[2] = (p_still_size_param[index-1].max_frame_size>>16)&0xff;
g_USBVideo.vs_still_probe_control.dwMaxVideoFrameSize[3] = (p_still_size_param[index-1].max_frame_size>>24)&0xff;
g_USBVideo.vs_still_probe_control.dwMaxPayloadTransferSize[0] = USBVIDEO_MAX_PAYLOAD_LENGTH&0xff;
g_USBVideo.vs_still_probe_control.dwMaxPayloadTransferSize[1] = (USBVIDEO_MAX_PAYLOAD_LENGTH>>8)&0xff;
g_USBVideo.vs_still_probe_control.dwMaxPayloadTransferSize[2] = (USBVIDEO_MAX_PAYLOAD_LENGTH>>16)&0xff;
g_USBVideo.vs_still_probe_control.dwMaxPayloadTransferSize[3] = (USBVIDEO_MAX_PAYLOAD_LENGTH>>24)&0xff;
/* register class-specific handler for standard ep0 cmd, but clear for ep1 */
USB_Register_EP0_Class_CmdHdlr(USB_CLEAR_FEATURE, USBVideo_ClearFeature_Callback);
}
/* video streaming interface reset function, enable EP*/
void USBVideo_VS_If_Reset(void)
{
g_USBVideo.txpipe = &g_USBVideo.vs_ep_in_info->ep_status.epin_status;
/*DMA*/
USB_InEPEn(g_USBVideo.vs_ep_in_info->ep_status.epin_status.byEP, KAL_TRUE);
if(g_USBVideo.state!=USBVIDEO_STATE_STOP)
{
USBVideo_Send_Msg(USBVIDEO_MSG_USB_ABORT, 0, 0);
}
}
/************************************************************
global variable g_USBVideo initialize and release functions
*************************************************************/
/* initialize global variable g_USBVideo */
void USB_Init_Video_Status(void)
{
kal_prompt_trace(MOD_USB, "Init video\n");
/* initailize g_USBVideo */
g_USBVideo.txpipe = NULL;
g_USBVideo.intrpipe = NULL;
g_USBVideo.vs_interface_id = 0;
g_USBVideo.vc_ct_support = 0;
g_USBVideo.vc_ct_set = 0;
g_USBVideo.vc_pu_support = 0;
g_USBVideo.vc_pu_set = 0;
g_USBVideo.state = USBVIDEO_STATE_STOP;
g_USBVideo.commit_video_index = 0;
g_USBVideo.probe_state = USBVIDEO_PROBE_NONE;
g_USBVideo.commit_still_index = 0;
g_USBVideo.still_probe_state = USBVIDEO_PROBE_NONE;
g_USBVideo.video_start_state = USBVIDEO_START_NONE;
g_USBVideo.video_control.video_buffer_addr[0] = NULL;
g_USBVideo.video_control.video_buffer_read_index = 0;
g_USBVideo.video_control.video_buffer_write_index = 0;
g_USBVideo.video_control.video_buffer_full = KAL_FALSE;
g_USBVideo.video_control.send_video_msg = KAL_TRUE;
g_USBVideo.video_control.sent_video_size = 0;
g_USBVideo.video_control.video_frame_id = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -