USB分为USB Host和USB Device两种,PC一般是USB Host,手机等终端数码设备一般是USB Device。OTG是指设备既可以作为USB Device,又可以作为USB Host。在Linux中,USB Device设备称为Gadget。
还是从代码开始看,这次的代码来自:
这个代码是应用层的,内核将来有时间再写一篇吧。
还有一个代码是GitHub - wlhe/uvc-gadget: enhance uvc-gadget test application
比对着一起看吧,兼听则明啊。。。
从main的结构来看,主要是以下流程:
configfs_parse_uvc_function
events_init
v4l2_video_source_create
uvc_stream_new
uvc_stream_set_event_handler(stream, &events) uvc_stream_set_video_source(stream, src) uvc_stream_init_uvc(stream, fc) events_loop(&events) clean
参考:
V4l2视频输出实现流程_v4l2_type_is_output-CSDN博客
guvcview调试UVC摄像头-CSDN博客