前面我们在https://mp.weixin.qq.com/s/s3uC-SHaVcXWAZK1sK6EZw?token=6568576&lang=zh_CN
《WSL2中配置支持UVC》一文中,分享了重新编译WSL2内核以支持UVC。
基于此,我们能随意修改内核重新编译加载新的内核运行,这样我们就可以方便的在PC上进行UVC相关的调试了。这一篇就来分享一个具体的案例。
我们调试的主要手段就是打开UVC代码中的dbg调试打印,通过打印信息来确认执行流,状态等。 当然现在我们可以随意修改内核代码了,那么我们就可以在关心的位置添加我们自己的打印信息方便调试。
在drivers/media/usb/uvc/uvc_driver.c中,通过以下语句定义了一个调试使能的参数
unsigned int uvc_dbg_param;
module_param_named(trace, uvc_dbg_param, uint, S_IRUGO|S_IWUSR);
最终的效果就是生成对应的文件
/sys/module/uvcvideo/parameters/trace
修改上述文件trace实际对应的就是修改变量uvc_dbg_param
类似的所有其他的参数如下
MODULE_PARM_DESC(clock, "Video buffers timestamp clock");
module_param_named(hwtimestamps, uvc_hw_timestamps_param, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(hwtimestamps, "Use hardware timestamps");
module_param_named(nodrop, uvc_no_drop_param, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(nodrop, "Don't drop incomplete frames");
module_param_named(quirks, uvc_quirks_param, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(quirks, "Forced device quirks");
module_param_named(trace, uvc_dbg_param, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(trace, "Trace level bitmask");
module_param_named(timeout, uvc_timeout_param, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(timeout, "Streaming control requests timeout");
drivers/media/usb/uvc/uvcvideo.h中
调试打印接口,调用的时dev_printk, 根据uvc_dbg_param变量的具体某一位是否置位(与UVC_DBG_##flag与)来判断是否要打印,flag是传入的分类名,比如PROBE对应的是 UVC_DBG_PROBE,bit0,如果uvc_dbg_param的bit0置位,则uvc_dbg(stream->dev, PROBE,对应的就会打印。
do { \
if (uvc_dbg_param & UVC_DBG_##flag) \
dev_printk(KERN_DEBUG, &(_dev)->udev->dev, fmt, \
##__VA_ARGS__); \
} while (0)
#define UVC_DBG_PROBE (1 << 0)
#define UVC_DBG_DESCR (1 << 1)
#define UVC_DBG_CONTROL (1 << 2)
#define UVC_DBG_FORMAT (1 << 3)
#define UVC_DBG_CAPTURE (1 << 4)
#define UVC_DBG_CALLS (1 << 5)
#define UVC_DBG_FRAME (1 << 7)
#define UVC_DBG_SUSPEND (1 << 8)
#define UVC_DBG_STATUS (1 << 9)
#define UVC_DBG_VIDEO (1 << 10)
#define UVC_DBG_STATS (1 << 11)
#define UVC_DBG_CLOCK (1 << 12)
具体操作如下
Shell中查看参数,
上述的参数对应的文件位于对于/sys/module/{模块名}/parameters/
,对于uvc模块名为uvcvideo,所以对应/sys/module/uvcvideo/parameters/
查看如下
root@lhj:/home/lhj# ls /sys/module/uvcvideo/parameters/
clock hwtimestamps nodrop quirks timeout trace
root@lhj:/home/lhj#
所以只需要按照如下操作,这里是配置 uvc_dbg_param的bit0~bit12都置位,使能所有类别的打印。
sudo su
echo 0x01FFF > /sys/module/uvcvideo/parameters/trace
cat /sys/module/uvcvideo/parameters/trace
显示8191
su qinyunti
以上使能之后就可以dmesg查看调试输出了。
我们这里以一个具体的案例来分享,UVC增加双设备支持后,在windows下可以双设备同时显示,在linux下只能单独显示,打开一个设备后再打开另一个设备导致两个设备都不能显示,关闭一个设备后另一个设备能显示。
我们找到UVC probe关键的代码增加一些打印信息,当然具体情况具体分析,一般在关键路径增加一些状态和数据的打印方便分析。
uvc_v4l2_set_streamparm
uvc_v4l2_try_format
uvc_probe_video
我这里在函数uvc_v4l2_try_format和uvc_probe_video中增加打印信息
static int uvc_v4l2_try_format(struct uvc_streaming *stream,
struct v4l2_format *fmt, struct uvc_streaming_control *probe,
struct uvc_format **uvc_format, struct uvc_frame **uvc_frame)
{
struct uvc_format *format = NULL;
struct uvc_frame *frame = NULL;
u16 rw, rh;
unsigned int d, maxd;
unsigned int i;
u32 interval;
int ret = 0;
u8 *fcc;
if (fmt->type != stream->type)
return -EINVAL;
fcc = (u8 *)&fmt->fmt.pix.pixelformat;
uvc_dbg(stream->dev, FORMAT, "Trying format 0x%08x (%c%c%c%c): %ux%u\n",
fmt->fmt.pix.pixelformat,
fcc[0], fcc[1], fcc[2], fcc[3],
fmt->fmt.pix.width, fmt->fmt.pix.height);
/* Check if the hardware supports the requested format, use the default
* format otherwise.
*/
for (i = 0; i < stream->nformats; ++i) {
format = &stream->format[i];
if (format->fcc == fmt->fmt.pix.pixelformat)
break;
}
if (i == stream->nformats) {
format = stream->def_format;
fmt->fmt.pix.pixelformat = format->fcc;
}
/* Find the closest image size. The distance between image sizes is
* the size in pixels of the non-overlapping regions between the
* requested size and the frame-specified size.
*/
rw = fmt->fmt.pix.width;
rh = fmt->fmt.pix.height;
maxd = (unsigned int)-1;
for (i = 0; i < format->nframes; ++i) {
u16 w = format->frame[i].wWidth;
u16 h = format->frame[i].wHeight;
d = min(w, rw) * min(h, rh);
d = w*h + rw*rh - 2*d;
if (d < maxd) {
maxd = d;
frame = &format->frame[i];
}
if (maxd == 0)
break;
}
if (frame == NULL) {
uvc_dbg(stream->dev, FORMAT, "Unsupported size %ux%u\n",
fmt->fmt.pix.width, fmt->fmt.pix.height);
return -EINVAL;
}
/* Use the default frame interval. */
interval = frame->dwDefaultFrameInterval;
uvc_dbg(stream->dev, FORMAT,
"Using default frame interval %u.%u us (%u.%u fps)\n",
interval / 10, interval % 10, 10000000 / interval,
(100000000 / interval) % 10);
/* Set the format index, frame index and frame interval. */
memset(probe, 0, sizeof(*probe));
probe->bmHint = 1; /* dwFrameInterval */
probe->bFormatIndex = format->index;
probe->bFrameIndex = frame->bFrameIndex;
probe->dwFrameInterval = uvc_try_frame_interval(frame, interval);
/* Some webcams stall the probe control set request when the
* dwMaxVideoFrameSize field is set to zero. The UVC specification
* clearly states that the field is read-only from the host, so this
* is a webcam bug. Set dwMaxVideoFrameSize to the value reported by
* the webcam to work around the problem.
*
* The workaround could probably be enabled for all webcams, so the
* quirk can be removed if needed. It's currently useful to detect
* webcam bugs and fix them before they hit the market (providing
* developers test their webcams with the Linux driver as well as with
* the Windows driver).
*/
mutex_lock(&stream->mutex);
if (stream->dev->quirks & UVC_QUIRK_PROBE_EXTRAFIELDS)
probe->dwMaxVideoFrameSize =
stream->ctrl.dwMaxVideoFrameSize;
/* Probe the device. */
ret = uvc_probe_video(stream, probe);
mutex_unlock(&stream->mutex);
if (ret < 0){
uvc_dbg(stream->dev, FORMAT,"%s %d %d\r\n",__FILE__,__LINE__,ret);
goto done;
}
/* After the probe, update fmt with the values returned from
* negotiation with the device. Some devices return invalid bFormatIndex
* and bFrameIndex values, in which case we can only assume they have
* accepted the requested format as-is.
*/
uvc_dbg(stream->dev, FORMAT,"%s %d stream->nformats:%d\r\n",__FILE__,__LINE__,stream->nformats);
for (i = 0; i < stream->nformats; ++i) {
if (probe->bFormatIndex == stream->format[i].index) {
format = &stream->format[i];
uvc_dbg(stream->dev, FORMAT,"%s %d match format:%d\r\n",__FILE__,__LINE__,probe->bFormatIndex);
break;
}
}
if (i == stream->nformats)
uvc_dbg(stream->dev, FORMAT,
"Unknown bFormatIndex %u, using default\n",
probe->bFormatIndex);
uvc_dbg(stream->dev, FORMAT,"%s %d format->nframes:%d\r\n",__FILE__,__LINE__,format->nframes);
for (i = 0; i < format->nframes; ++i) {
if (probe->bFrameIndex == format->frame[i].bFrameIndex) {
frame = &format->frame[i];
uvc_dbg(stream->dev, FORMAT,"%s %d match frame:%d\r\n",__FILE__,__LINE__,probe->bFrameIndex);
break;
}
}
if (i == format->nframes)
uvc_dbg(stream->dev, FORMAT,
"Unknown bFrameIndex %u, using default\n",
probe->bFrameIndex);
fmt->fmt.pix.width = frame->wWidth;
fmt->fmt.pix.height = frame->wHeight;
fmt->fmt.pix.field = V4L2_FIELD_NONE;
fmt->fmt.pix.bytesperline = uvc_v4l2_get_bytesperline(format, frame);
fmt->fmt.pix.sizeimage = probe->dwMaxVideoFrameSize;
fmt->fmt.pix.pixelformat = format->fcc;
fmt->fmt.pix.colorspace = format->colorspace;
fmt->fmt.pix.xfer_func = format->xfer_func;
fmt->fmt.pix.ycbcr_enc = format->ycbcr_enc;
uvc_dbg(stream->dev, FORMAT,"%s %d width:%d,height:%d,field:%d,bytesperline:%d,sizeimage:%d,pixelformat:%d,colorspace:%d,xfer_func:%d,ycbcr_enc:%d\r\n",__FILE__,__LINE__,
fmt->fmt.pix.width,
fmt->fmt.pix.height,
fmt->fmt.pix.field,
fmt->fmt.pix.bytesperline,
fmt->fmt.pix.sizeimage,
fmt->fmt.pix.pixelformat,
fmt->fmt.pix.colorspace,
fmt->fmt.pix.xfer_func,
fmt->fmt.pix.ycbcr_enc);
if (uvc_format != NULL){
*uvc_format = format;
uvc_dbg(stream->dev, FORMAT, "set uvc_format\r\n");
}
if (uvc_frame != NULL){
*uvc_frame = frame;
uvc_dbg(stream->dev, FORMAT, "set uvc_frame\r\n");
}
done:
return ret;
}
int uvc_probe_video(struct uvc_streaming *stream,
struct uvc_streaming_control *probe)
{
struct uvc_streaming_control probe_min, probe_max;
u16 bandwidth;
unsigned int i;
int ret;
/* Perform probing. The device should adjust the requested values
* according to its capabilities. However, some devices, namely the
* first generation UVC Logitech webcams, don't implement the Video
* Probe control properly, and just return the needed bandwidth. For
* that reason, if the needed bandwidth exceeds the maximum available
* bandwidth, try to lower the quality.
*/
ret = uvc_set_video_ctrl(stream, probe, 1);
if (ret < 0){
uvc_dbg(stream->dev, FORMAT,"%s %d %d\r\n",__FILE__,__LINE__,ret);
goto done;
}
/* Get the minimum and maximum values for compression settings. */
uvc_dbg(stream->dev, FORMAT,"%s %d stream->dev->quirks:%x\r\n",__FILE__,__LINE__,stream->dev->quirks);
if (!(stream->dev->quirks & UVC_QUIRK_PROBE_MINMAX)) {
ret = uvc_get_video_ctrl(stream, &probe_min, 1, UVC_GET_MIN);
if (ret < 0){
uvc_dbg(stream->dev, FORMAT,"%s %d %d\r\n",__FILE__,__LINE__,ret);
goto done;
}
ret = uvc_get_video_ctrl(stream, &probe_max, 1, UVC_GET_MAX);
if (ret < 0){
uvc_dbg(stream->dev, FORMAT,"%s %d %d\r\n",__FILE__,__LINE__,ret);
goto done;
}
probe->wCompQuality = probe_max.wCompQuality;
uvc_dbg(stream->dev, FORMAT,"%s %d probe->wCompQuality:%x\r\n",__FILE__,__LINE__,probe->wCompQuality);
}
for (i = 0; i < 2; ++i) {
ret = uvc_set_video_ctrl(stream, probe, 1);
if (ret < 0){
uvc_dbg(stream->dev, FORMAT,"%s %d %d\r\n",__FILE__,__LINE__,ret);
goto done;
}
ret = uvc_get_video_ctrl(stream, probe, 1, UVC_GET_CUR);
if (ret < 0){
uvc_dbg(stream->dev, FORMAT,"%s %d %d\r\n",__FILE__,__LINE__,ret);
goto done;
}
uvc_dbg(stream->dev, FORMAT,"%s %d pstream->intf->num_altsetting:%x\r\n",__FILE__,__LINE__,stream->intf->num_altsetting);
if (stream->intf->num_altsetting == 1)
break;
bandwidth = probe->dwMaxPayloadTransferSize;
uvc_dbg(stream->dev, FORMAT,"%s %d bandwidth:%x\r\n",__FILE__,__LINE__,bandwidth);
if (bandwidth <= stream->maxpsize)
break;
if (stream->dev->quirks & UVC_QUIRK_PROBE_MINMAX) {
ret = -ENOSPC;
goto done;
}
/* TODO: negotiate compression parameters */
probe->wKeyFrameRate = probe_min.wKeyFrameRate;
probe->wPFrameRate = probe_min.wPFrameRate;
probe->wCompQuality = probe_max.wCompQuality;
probe->wCompWindowSize = probe_min.wCompWindowSize;
uvc_dbg(stream->dev, FORMAT,"%s %d probe->wKeyFrameRate:%x\r\n",__FILE__,__LINE__,probe->wKeyFrameRate);
uvc_dbg(stream->dev, FORMAT,"%s %d probe->wPFrameRate:%x\r\n",__FILE__,__LINE__,probe->wPFrameRate);
uvc_dbg(stream->dev, FORMAT,"%s %d probe->wCompQuality:%x\r\n",__FILE__,__LINE__,probe->wCompQuality);
uvc_dbg(stream->dev, FORMAT,"%s %d probe->wCompWindowSize:%x\r\n",__FILE__,__LINE__,probe->wCompWindowSize);
}
done:
return ret;
}
先使能UVC的dbg信息
sudo su
echo 0x01FFF > /sys/module/uvcvideo/parameters/trace
cat /sys/module/uvcvideo/parameters/trace
su qinyunti
然后清除dmesg
sudo dmesg -c
确认清除
dmesg
usbipd bind -b 3-2
usbipd attach -w -b 3-2之后
查看dmesg
[ 93.764118] vhci_hcd vhci_hcd.0: pdev(0) rhport(0) sockfd(3)
[ 93.764805] vhci_hcd vhci_hcd.0: devid(196610) speed(3) speed_str(high-speed)
[ 93.765632] vhci_hcd vhci_hcd.0: Device attached
[ 94.120776] usb 1-1: new high-speed USB device number 2 using vhci_hcd
[ 94.270769] usb 1-1: SetAddress Request (2) to port 0
[ 94.306545] usb 1-1: New USB device found, idVendor=1993, idProduct=0101, bcdDevice= 1.01
[ 94.307540] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 94.308758] usb 1-1: Product: .UVC
[ 94.309224] usb 1-1: Manufacturer: .Technology
[ 94.312458] usb 1-1: Probing generic UVC device 1
[ 94.314366] usb 1-1: Found format NV12 little-endian (0x3231564e)
[ 94.315230] usb 1-1: - 1280x720 (39.0 fps)
[ 94.315614] usb 1-1: Found format H264 little-endian (0x34363248)
[ 94.316145] usb 1-1: - 1280x720 (39.0 fps)
[ 94.316444] usb 1-1: Found format MJPG little-endian (0x47504a4d)
[ 94.316947] usb 1-1: - 1280x720 (39.0 fps)
[ 94.317194] usb 1-1: Found UVC 1.10 device .UVC (1993:0101)
[ 94.317582] usb 1-1: Scanning UVC chain:
[ 94.317812] OT 3 <- PU 2 <- IT 1
[ 94.318047] usb 1-1: Found a valid video chain (1 -> 3)
[ 94.323796] usb 1-1: UVC device initialized
[ 94.324422] usb 1-1: Probing generic UVC device 1
[ 94.326098] usb 1-1: Found format NV12 little-endian (0x3231564e)
[ 94.326771] usb 1-1: - 1280x720 (39.0 fps)
[ 94.327083] usb 1-1: Found format H264 little-endian (0x34363248)
[ 94.327581] usb 1-1: - 1280x720 (39.0 fps)
[ 94.327998] usb 1-1: Found format MJPG little-endian (0x47504a4d)
[ 94.328650] usb 1-1: - 1280x720 (39.0 fps)
[ 94.328955] usb 1-1: Found UVC 1.10 device .UVC (1993:0101)
[ 94.329397] usb 1-1: Scanning UVC chain:
[ 94.329617] OT 6 <- PU 5 <- IT 4
[ 94.329836] usb 1-1: Found a valid video chain (4 -> 6)
[ 94.334657] usb 1-1: UVC device initialized
设备的串口打印
ITF:1 ID:0 GET CS:1 REQ:87 B:281802d0 OF:216 LEN:34
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:3,frame:1
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 GET CS:1 REQ:81 B:281802d0 OF:0 LEN:34
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
uvc set itf 3 0,active_itf:0
ITF:3 ID:0 GET CS:1 REQ:87 B:281803cc OF:216 LEN:34
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:3 ID:0 SET CS:1 REQ:1 B:281803cc OF:0 LEN:34
probe format:3,frame:1
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:3 ID:0 GET CS:1 REQ:81 B:281803cc OF:0 LEN:34
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
运行
sudo guvcview
查看dmesg
[ 201.207930] usb 1-1: uvc_v4l2_open
[ 201.210377] usb 1-1: uvc_v4l2_release
[ 201.212104] usb 1-1: uvc_v4l2_open
[ 201.213039] usb 1-1: uvc_v4l2_release
[ 201.215030] usb 1-1: uvc_v4l2_open
[ 201.216886] usb 1-1: Control 0x00980900 not found
[ 201.217702] usb 1-1: Control 0x00980901 not found
[ 201.218261] usb 1-1: Control 0x00980902 not found
[ 201.218770] usb 1-1: Control 0x00980903 not found
[ 201.219250] usb 1-1: Control 0x00980904 not found
[ 201.219726] usb 1-1: Control 0x00980905 not found
[ 201.220225] usb 1-1: Control 0x00980906 not found
[ 201.220745] usb 1-1: Control 0x00980907 not found
[ 201.221266] usb 1-1: Control 0x00980908 not found
[ 201.221701] usb 1-1: Control 0x00980909 not found
[ 201.222089] usb 1-1: Control 0x0098090a not found
[ 201.222467] usb 1-1: Control 0x0098090b not found
[ 201.222827] usb 1-1: Control 0x0098090c not found
[ 201.223221] usb 1-1: Control 0x0098090d not found
[ 201.223588] usb 1-1: Control 0x0098090e not found
[ 201.223973] usb 1-1: Control 0x0098090f not found
[ 201.224394] usb 1-1: Control 0x00980910 not found
[ 201.224778] usb 1-1: Control 0x00980911 not found
[ 201.225139] usb 1-1: Control 0x00980912 not found
[ 201.225478] usb 1-1: Control 0x00980913 not found
[ 201.225824] usb 1-1: Control 0x00980914 not found
[ 201.226177] usb 1-1: Control 0x00980915 not found
[ 201.226549] usb 1-1: Control 0x00980916 not found
[ 201.226929] usb 1-1: Control 0x00980917 not found
[ 201.227379] usb 1-1: Control 0x00980918 not found
[ 201.227785] usb 1-1: Control 0x00980919 not found
[ 201.228152] usb 1-1: Control 0x0098091a not found
[ 201.228523] usb 1-1: Control 0x0098091b not found
[ 201.229016] usb 1-1: Control 0x0098091c not found
[ 201.229670] usb 1-1: Control 0x0098091d not found
[ 201.230266] usb 1-1: Control 0x0098091e not found
[ 201.231027] usb 1-1: Control 0x0098091f not found
[ 201.231680] usb 1-1: Control 0x00980920 not found
[ 201.232314] usb 1-1: Control 0x00980921 not found
[ 201.232860] usb 1-1: Control 0x00980922 not found
[ 201.233365] usb 1-1: Control 0x00980923 not found
[ 201.234030] usb 1-1: Control 0x00980924 not found
[ 201.234480] usb 1-1: Control 0x00980925 not found
[ 201.234925] usb 1-1: Control 0x00980926 not found
[ 201.235382] usb 1-1: Control 0x00980927 not found
[ 201.235820] usb 1-1: Control 0x00980928 not found
[ 201.236251] usb 1-1: Control 0x00980929 not found
[ 201.236697] usb 1-1: Control 0x0098092a not found
[ 201.237144] usb 1-1: Control 0x009a0900 not found
[ 201.237609] usb 1-1: Control 0x009a0901 not found
[ 201.238100] usb 1-1: Control 0x009a0902 not found
[ 201.238452] usb 1-1: Control 0x009a0903 not found
[ 201.238796] usb 1-1: Control 0x009a0904 not found
[ 201.239199] usb 1-1: Control 0x009a0905 not found
[ 201.239802] usb 1-1: Control 0x009a0906 not found
[ 201.240136] usb 1-1: Control 0x009a0907 not found
[ 201.240470] usb 1-1: Control 0x009a0908 not found
[ 201.240846] usb 1-1: Control 0x009a0909 not found
[ 201.241240] usb 1-1: Control 0x009a090a not found
[ 201.241628] usb 1-1: Control 0x009a090b not found
[ 201.242255] usb 1-1: Control 0x009a090c not found
[ 201.242884] usb 1-1: Control 0x009a090d not found
[ 201.243589] usb 1-1: Control 0x009a090e not found
[ 201.244387] usb 1-1: Control 0x009a090f not found
[ 201.245005] usb 1-1: Control 0x009a0910 not found
[ 201.245797] usb 1-1: Control 0x009a0911 not found
[ 201.246278] usb 1-1: Control 0x009a0912 not found
[ 201.246899] usb 1-1: Control 0x009a0913 not found
[ 201.247883] usb 1-1: Control 0x009a0914 not found
[ 201.248643] usb 1-1: Control 0x009a0915 not found
[ 201.249343] usb 1-1: Control 0x009a0916 not found
[ 201.249885] usb 1-1: Control 0x009a0917 not found
[ 201.250389] usb 1-1: Control 0x009a0918 not found
[ 201.250938] usb 1-1: Control 0x009a0919 not found
[ 201.251443] usb 1-1: Control 0x009a091a not found
[ 201.251968] usb 1-1: Control 0x009a091b not found
[ 201.252459] usb 1-1: Control 0x009a091c not found
[ 201.252964] usb 1-1: Control 0x009a091d not found
[ 201.253356] usb 1-1: Control 0x009a091e not found
[ 201.253736] usb 1-1: Control 0x009a091f not found
[ 201.254114] usb 1-1: Control 0x08000000 not found
[ 201.277422] usb 1-1: Trying format 0x47504a4d (MJPG): 1280x720
[ 201.278244] usb 1-1: Using default frame interval 25641.0 us (39.0 fps)
[ 201.280293] usb 1-1: drivers/media/usb/uvc/uvc_video.c 404 stream->dev->quirks:0
[ 201.284240] usb 1-1: drivers/media/usb/uvc/uvc_video.c 417 probe->wCompQuality:0
[ 201.287658] usb 1-1: drivers/media/usb/uvc/uvc_video.c 431 pstream->intf->num_altsetting:2
[ 201.288450] usb 1-1: drivers/media/usb/uvc/uvc_video.c 436 bandwidth:0
[ 201.288956] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 266 stream->nformats:3
[ 201.289574] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 270 match format:3
[ 201.290880] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 280 format->nframes:1
[ 201.291957] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 284 match frame:1
[ 201.292698] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 304 width:1280,height:720,field:1,bytesperline:0,sizeimage:0,pixelformat:1196444237,colorspace:0,xfer_func:0,ycbcr_enc:0
[ 201.294226] usb 1-1: Trying format 0x47504a4d (MJPG): 1280x720
[ 201.294850] usb 1-1: Using default frame interval 25641.0 us (39.0 fps)
[ 201.296655] usb 1-1: drivers/media/usb/uvc/uvc_video.c 404 stream->dev->quirks:0
[ 201.300138] usb 1-1: drivers/media/usb/uvc/uvc_video.c 417 probe->wCompQuality:0
[ 201.303232] usb 1-1: drivers/media/usb/uvc/uvc_video.c 431 pstream->intf->num_altsetting:2
[ 201.304038] usb 1-1: drivers/media/usb/uvc/uvc_video.c 436 bandwidth:0
[ 201.304572] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 266 stream->nformats:3
[ 201.305211] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 270 match format:3
[ 201.306009] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 280 format->nframes:1
[ 201.306951] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 284 match frame:1
[ 201.307689] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 304 width:1280,height:720,field:1,bytesperline:0,sizeimage:0,pixelformat:1196444237,colorspace:0,xfer_func:0,ycbcr_enc:0
[ 201.309043] usb 1-1: set uvc_format
[ 201.309393] usb 1-1: set uvc_frame
[ 201.317452] ------------[ cut here ]------------
[ 201.318141] WARNING: CPU: 0 PID: 314 at drivers/media/common/videobuf2/videobuf2-core.c:815 vb2_core_reqbufs+0x141/0x3a0
[ 201.319212] Modules linked in:
[ 201.319551] CPU: 0 PID: 314 Comm: guvcview Not tainted 5.15.167.4-microsoft-standard-WSL2 #3
[ 201.320344] RIP: 0010:vb2_core_reqbufs+0x141/0x3a0
[ 201.320853] Code: 85 c9 0f 84 29 02 00 00 8d 51 ff 48 8d 44 24 08 48 8d 54 94 0c eb 0d 48 83 c0 04 48 39 d0 0f 84 fe 00 00 00 8b 30 85 f6 75 ed <0f> 0b 41 bf ea ff ff ff 4c 89 e7 e8 9f 0b 49 00 4c 89 e7 c7 85 c8
[ 201.322443] RSP: 0018:ffffc90005c83cb8 EFLAGS: 00010246
[ 201.322896] RAX: ffffc90005c83cc0 RBX: ffffc90005c83e48 RCX: 0000000000000001
[ 201.323721] RDX: ffffc90005c83cc4 RSI: 0000000000000000 RDI: ffff888103d38518
[ 201.324471] RBP: ffff888103d38518 R08: 0000000000000000 R09: 0000000000000000
[ 201.325168] R10: 0000000000000000 R11: ffffffff825073e0 R12: ffff888103d385c0
[ 201.325884] R13: 0000000000000001 R14: ffff888103d38580 R15: 0000000000000000
[ 201.326597] FS: 00007fdf6cbbae80(0000) GS:ffff8881dc600000(0000) knlGS:0000000000000000
[ 201.327312] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 201.327896] CR2: 00007fdf6c914000 CR3: 0000000102436000 CR4: 00000000003506b0
[ 201.328644] Call Trace:
[ 201.328941] <TASK>
[ 201.329197] ? __warn+0x80/0x100
[ 201.329498] ? vb2_core_reqbufs+0x141/0x3a0
[ 201.329784] ? report_bug+0x9e/0xc0
[ 201.330069] ? handle_bug+0x3c/0x70
[ 201.330411] ? exc_invalid_op+0x14/0x70
[ 201.330884] ? asm_exc_invalid_op+0x16/0x20
[ 201.331230] ? vb2_core_reqbufs+0x141/0x3a0
[ 201.331569] ? vb2_core_reqbufs+0x10c/0x3a0
[ 201.331970] uvc_request_buffers+0x29/0x50
[ 201.332348] uvc_ioctl_reqbufs+0x46/0xa0
[ 201.332755] ? v4l_reqbufs+0x22/0x60
[ 201.333135] __video_do_ioctl+0x3a0/0x3e0
[ 201.333470] ? srso_return_thunk+0x5/0x10
[ 201.333746] ? page_add_new_anon_rmap+0x4e/0xf0
[ 201.334123] video_usercopy+0x2e1/0x760
[ 201.334492] ? v4l_print_control+0x20/0x20
[ 201.334813] ? srso_return_thunk+0x5/0x10
[ 201.335138] v4l2_ioctl+0x49/0x50
[ 201.335458] __x64_sys_ioctl+0x8a/0xc0
[ 201.335826] do_syscall_64+0x35/0xb0
[ 201.336346] entry_SYSCALL_64_after_hwframe+0x6c/0xd6
[ 201.336913] RIP: 0033:0x7fdf75fff88d
[ 201.337319] Code: 5b 41 5c c3 66 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 73 b5 0f 00 f7 d8 64 89 01 48
[ 201.339122] RSP: 002b:00007fff1e1e6228 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[ 201.340090] RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007fdf75fff88d
[ 201.340851] RDX: 000056188e4826c0 RSI: 00000000c0145608 RDI: 0000000000000004
[ 201.341590] RBP: 00000000c0145608 R08: 0000000000000000 R09: 0000000000000000
[ 201.342302] R10: 00007fdf75edd020 R11: 0000000000000246 R12: 0000000000000004
[ 201.342997] R13: 0000000000000000 R14: 00007fdf75edd020 R15: 000056188e4826c0
[ 201.343714] TASK>
[ 201.343945] ---[ end trace ad1f2ae766fc9251 ]---
[ 201.344584] usb 1-1: Trying format 0x3231564e (NV12): 1280x720
[ 201.345253] usb 1-1: Using default frame interval 25641.0 us (39.0 fps)
[ 201.346991] usb 1-1: drivers/media/usb/uvc/uvc_video.c 404 stream->dev->quirks:0
[ 201.350002] usb 1-1: drivers/media/usb/uvc/uvc_video.c 417 probe->wCompQuality:0
[ 201.353228] usb 1-1: drivers/media/usb/uvc/uvc_video.c 431 pstream->intf->num_altsetting:2
[ 201.354172] usb 1-1: drivers/media/usb/uvc/uvc_video.c 436 bandwidth:0
[ 201.354830] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 266 stream->nformats:3
[ 201.355624] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 270 match format:1
[ 201.356352] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 280 format->nframes:1
[ 201.357123] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 284 match frame:1
[ 201.357714] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 304 width:1280,height:720,field:1,bytesperline:1280,sizeimage:1382400,pixelformat:842094158,colorspace:8,xfer_func:1,ycbcr_enc:1
[ 201.359176] usb 1-1: Trying format 0x3231564e (NV12): 1280x720
[ 201.359782] usb 1-1: Using default frame interval 25641.0 us (39.0 fps)
[ 201.361507] usb 1-1: drivers/media/usb/uvc/uvc_video.c 404 stream->dev->quirks:0
[ 201.364710] usb 1-1: drivers/media/usb/uvc/uvc_video.c 417 probe->wCompQuality:0
[ 201.368030] usb 1-1: drivers/media/usb/uvc/uvc_video.c 431 pstream->intf->num_altsetting:2
[ 201.368993] usb 1-1: drivers/media/usb/uvc/uvc_video.c 436 bandwidth:0
[ 201.369637] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 266 stream->nformats:3
[ 201.370419] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 270 match format:1
[ 201.371077] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 280 format->nframes:1
[ 201.371718] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 284 match frame:1
[ 201.372273] usb 1-1: drivers/media/usb/uvc/uvc_v4l2.c 304 width:1280,height:720,field:1,bytesperline:1280,sizeimage:1382400,pixelformat:842094158,colorspace:8,xfer_func:1,ycbcr_enc:1
[ 201.373622] usb 1-1: set uvc_format
[ 201.373912] usb 1-1: set uvc_frame
[ 201.378054] usb 1-1: uvc_v4l2_mmap
[ 201.378682] usb 1-1: uvc_v4l2_mmap
[ 201.379126] usb 1-1: uvc_v4l2_mmap
[ 201.379550] usb 1-1: uvc_v4l2_mmap
[ 201.379974] usb 1-1: Setting frame interval to 1/25 (400000)
[ 201.381805] usb 1-1: drivers/media/usb/uvc/uvc_video.c 404 stream->dev->quirks:0
[ 201.385213] usb 1-1: drivers/media/usb/uvc/uvc_video.c 417 probe->wCompQuality:0
[ 201.388137] usb 1-1: drivers/media/usb/uvc/uvc_video.c 431 pstream->intf->num_altsetting:2
[ 201.389009] usb 1-1: drivers/media/usb/uvc/uvc_video.c 436 bandwidth:0
[ 201.497158] misc dxg: dxgk: dxgkio_is_feature_enabled: Ioctl failed: -22
[ 201.500618] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -22
[ 201.501538] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -22
[ 201.502355] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -22
[ 201.503101] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -22
[ 201.503963] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -2
[ 201.670572] usb 1-1: Device requested null bandwidth, defaulting to lowest
[ 201.671624] usb 1-1: Selecting alternate setting 1 (1024 B/frame bandwidth)
[ 201.676945] usb 1-1: Allocated 5 URB buffers of 32x1024 bytes each
[ 201.678552] usb 1-1: uvc_v4l2_poll
[ 201.836093] usb 1-1: Frame complete (EOF found)
[ 201.995351] usb 1-1: frame 1 stats: 0/23/23 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 202.027253] usb 1-1: Frame complete (EOF found)
[ 202.187363] usb 1-1: frame 2 stats: 0/23/23 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 202.188630] usb 1-1: Frame complete (EOF found)
[ 202.347510] usb 1-1: frame 3 stats: 0/23/23 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 202.379318] usb 1-1: Frame complete (EOF found)
[ 202.539504] usb 1-1: frame 4 stats: 0/22/22 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 202.541300] usb 1-1: Frame complete (EOF found)
[ 202.679618] usb 1-1: uvc_v4l2_poll
[ 202.681203] vhci_hcd: unlink->seqnum 82
[ 202.682047] vhci_hcd: urb->status -104
[ 202.683629] vhci_hcd: unlink->seqnum 83
[ 202.684305] vhci_hcd: urb->status -104
[ 202.685409] vhci_hcd: unlink->seqnum 84
[ 202.686028] vhci_hcd: urb->status -104
[ 202.687147] vhci_hcd: unlink->seqnum 85
[ 202.687768] vhci_hcd: urb->status -104
[ 202.690592] vhci_hcd: unlink->seqnum 86
[ 202.691222] vhci_hcd: urb->status -104
[ 202.697097] usb 1-1: Setting frame interval to 1/39 (256410)
[ 202.699608] usb 1-1: drivers/media/usb/uvc/uvc_video.c 404 stream->dev->quirks:0
[ 202.702845] usb 1-1: drivers/media/usb/uvc/uvc_video.c 417 probe->wCompQuality:0
[ 202.706362] usb 1-1: drivers/media/usb/uvc/uvc_video.c 431 pstream->intf->num_altsetting:2
[ 202.707301] usb 1-1: drivers/media/usb/uvc/uvc_video.c 436 bandwidth:0
[ 202.707997] usb 1-1: uvc_v4l2_mmap
[ 202.708448] usb 1-1: uvc_v4l2_mmap
[ 202.708839] usb 1-1: uvc_v4l2_mmap
[ 202.709265] usb 1-1: uvc_v4l2_mmap
[ 202.710815] usb 1-1: Device requested null bandwidth, defaulting to lowest
[ 202.711466] usb 1-1: Selecting alternate setting 1 (1024 B/frame bandwidth)
[ 202.716751] usb 1-1: Allocated 5 URB buffers of 32x1024 bytes each
[ 202.717703] usb 1-1: uvc_v4l2_poll
[ 202.745431] usb 1-1: Frame complete (EOF found)
[ 202.905409] usb 1-1: frame 1 stats: 0/23/23 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 202.937378] usb 1-1: Frame complete (EOF found)
[ 203.097862] usb 1-1: frame 2 stats: 0/23/23 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 203.099538] usb 1-1: Frame complete (EOF found)
[ 203.257478] usb 1-1: frame 3 stats: 0/22/22 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 203.289444] usb 1-1: Frame complete (EOF found)
[ 203.449523] usb 1-1: frame 4 stats: 0/23/23 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 203.451155] usb 1-1: Frame complete (EOF found)
[ 203.609555] usb 1-1: frame 5 stats: 0/23/23 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 203.641387] usb 1-1: Frame complete (EOF found)
[ 203.718912] usb 1-1: uvc_v4l2_poll
[ 203.719763] usb 1-1: uvc_v4l2_poll
[ 203.801564] usb 1-1: frame 6 stats: 0/23/23 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 203.803195] usb 1-1: Frame complete (EOF found)
[ 203.961536] usb 1-1: frame 7 stats: 0/22/22 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 203.993402] usb 1-1: Frame complete (EOF found)
[ 204.153744] usb 1-1: frame 8 stats: 0/23/23 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 204.156312] usb 1-1: Frame complete (EOF found)
[ 204.313624] usb 1-1: frame 9 stats: 0/23/23 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 204.345445] usb 1-1: Frame complete (EOF found)
[ 204.505525] usb 1-1: frame 10 stats: 0/23/23 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 204.506837] usb 1-1: Frame complete (EOF found)
[ 204.665466] usb 1-1: frame 11 stats: 0/22/22 packets, 0/0/0 pts (!early !initial), 0/0 scr, last pts/stc/sof 0/0/0
[ 204.697380] usb 1-1: Frame complete (EOF found)
[ 204.720845] usb 1-1: uvc_v4l2_poll
[ 204.722161] vhci_hcd: unlink->seqnum 162
[ 204.722797] vhci_hcd: urb->status -104
[ 204.724195] vhci_hcd: unlink->seqnum 163
[ 204.724792] vhci_hcd: urb->status -104
[ 204.725940] vhci_hcd: unlink->seqnum 164
[ 204.726487] vhci_hcd: urb->status -104
[ 204.727479] vhci_hcd: unlink->seqnum 165
[ 204.728023] vhci_hcd: urb->status -104
[ 204.729319] vhci_hcd: unlink->seqnum 166
[ 204.729871] vhci_hcd: urb->status -104
[ 204.742738] usb 1-1: uvc_v4l2_release
qinyunti:~$
此时串口打印
sh>
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:3,frame:1
01 00 03 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:82 B:281802d0 OF:36 LEN:34
01 00 01 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 GET CS:1 REQ:83 B:281802d0 OF:72 LEN:34
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:3,frame:1
01 00 03 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:81 B:281802d0 OF:0 LEN:34
01 00 03 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:3,frame:1
01 00 03 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:82 B:281802d0 OF:36 LEN:34
01 00 01 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 GET CS:1 REQ:83 B:281802d0 OF:72 LEN:34
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:3,frame:1
01 00 03 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:81 B:281802d0 OF:0 LEN:34
01 00 03 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:1,frame:1
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:82 B:281802d0 OF:36 LEN:34
01 00 01 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 GET CS:1 REQ:83 B:281802d0 OF:72 LEN:34
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:1,frame:1
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:81 B:281802d0 OF:0 LEN:34
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:1,frame:1
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:82 B:281802d0 OF:36 LEN:34
01 00 01 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 GET CS:1 REQ:83 B:281802d0 OF:72 LEN:34
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:1,frame:1
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:81 B:281802d0 OF:0 LEN:34
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:1,frame:1
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 18 15 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:82 B:281802d0 OF:36 LEN:34
01 00 01 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 GET CS:1 REQ:83 B:281802d0 OF:72 LEN:34
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:1,frame:1
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 18 15 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:81 B:281802d0 OF:0 LEN:34
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 18 15 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 SET CS:2 REQ:1 B:281800d8 OF:0 LEN:34
commit format:1,frame:1
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 18 15 00 00 00 00 00 00 00 00 00 00 00 00 00
uvc set itf 1 1,active_itf:1
dev:0,itf:1,format:1,frame:1
mjpeg 0 used:8424(uS) len:22567
dev:0,itf:1,format:1,frame:1
mjpeg 0 used:8419(uS) len:22613
dev:0,itf:1,format:1,frame:1
mjpeg 0 used:8418(uS) len:22054
dev:0,itf:1,format:1,frame:1
mjpeg 0 used:8421(uS) len:23084
dev:0,itf:1,format:1,frame:1
mjpeg 0 used:8421(uS) len:22819
dev:0,itf:1,format:1,frame:1
mjpeg 0 used:8422(uS) len:22746
uvc set itf 1 0,active_itf:0
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:1,frame:1
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 18 15 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:82 B:281802d0 OF:36 LEN:34
01 00 01 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 GET CS:1 REQ:83 B:281802d0 OF:72 LEN:34
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:1,frame:1
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 18 15 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:81 B:281802d0 OF:0 LEN:34
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 18 15 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 SET CS:2 REQ:1 B:281800d8 OF:0 LEN:34
commit format:1,frame:1
01 00 01 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 18 15 00 00 00 00 00 00 00 00 00 00 00 00 00
uvc set itf 1 1,active_itf:1
dev:0,itf:1,format:1,frame:1
mjpeg 0 used:8420(uS) len:21833
dev:0,itf:1,format:1,frame:1
对照可以看到dwMaxPayloadTransferSize为0,而该值从GET_CUR
前面的ret = uvc_get_video_ctrl(stream, probe, 1, UVC_GET_CUR);获取
即设备返回的34字节的偏移22字节处的值
ctrl->dwMaxPayloadTransferSize = get_unaligned_le32(&data[22]);
从打印看HOST SET_CUR发送的值是,这部分填写0,device的逻辑是收到SET_CUR后覆盖,GET_CUR时返回的是上一次的值。
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:3,frame:1
01 00 03 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:82 B:281802d0 OF:36 LEN:34
01 00 01 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 GET CS:1 REQ:83 B:281802d0 OF:72 LEN:34
01 00 03 01 9a 19 03 00 00 00 00 00 00 00 00 00 00 00 00 c0 3f 00 ff 03 00 00 80 c3 c9 01 03 00 00 00
ITF:1 ID:0 SET CS:1 REQ:1 B:281802d0 OF:0 LEN:34
probe format:3,frame:1
01 00 03 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ITF:1 ID:0 GET CS:1 REQ:81 B:281802d0 OF:0 LEN:34
01 00 03 01 9a e9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
这里device的逻辑有问题,需要修改下,
SET时只有非零值才会生效,才会覆盖CUR值,0值不覆盖原来的CUR值。
在UVC的规格书中其实也有类似的介绍。
修改了上述问题之后,再测试看到了打印如下信息
“Dropping payload (out of sync)”
我们查找对应的代码处
可以看到如下逻辑,看到fid一直不变才会有这个打印,那么基本就确认问题了
再去看设备那边的代码,确实是多设备使用了同一个fid记录,增加设备时忘记改这里了,导致一个设备tog fid,然后另一个设备又tog fid,最终看起来是fid没变。修改就很简单,各个设备使用各自的fid记录就可以了。
以上实际也可以通过抓包查看发出的包是否FID FED正确也可以发现,分享以上,重点在于以上分析调试方法。打印相关信息会更加直观。
除了之前提的guvcview这里还推荐下qv4l2工具,在linux下进行uvc的查看。
sudo apt install v4l-utils
sudo apt install qv4l2
sudo qv4l2
这里双UVC设备显示如下
以上主要是分享基于WSL2如何修改内核UVC相关代码,增加调试信息去进行调试,问题本身不是很重要,重点是分享分析过程。而分享的案例本身的问题,一个是Probe Commit处理时对SET_CUR的处理不合理,将0值也进行了覆盖,一个是增加多设备支持时把负载头的FID共用了,没有区分开,导致一个设备发完一帧TOG了FID,下一个设备又发一帧又TOG了FID,两次TOG之后导致某一个设备的FID始终不变,windows下能够处理这种问题(这里发的是MJPEG猜测系统是根据负载头的FED位区分,或者是根据MPJEG本身头尾标志区分的),linux下则无法区分帧,解决办法是多个设备各自使用自己的FID记录。这里也可以看出windows确实兼容性是做的很好的,考虑了很多容错处理,虽然这里是设备那边的问题,但是这种不是致命的问题windows能正常显示,linux则不能。