kernel  webcam驱动默认只支持640*360 和 1280 * 720分辨率支持

下面讲讲如何添加自己的分辨率,以添加640*960为例

static const struct uvc_format_uncompressed uvc_format_yuv = {
	.bLength		= UVC_DT_FORMAT_UNCOMPRESSED_SIZE,
	.bDescriptorType	= USB_DT_CS_INTERFACE,
	.bDescriptorSubType	= UVC_VS_FORMAT_UNCOMPRESSED,
	.bFormatIndex		= 1,
	.bNumFrameDescriptors	= 3,//这个值原本是2,代表YUV格式有两种分辨率,改为你需要的值
	.guidFormat		=
		{ 'Y',  'U',  'Y',  '2', 0x00, 0x00, 0x10, 0x00,
		 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71},
	.bBitsPerPixel		= 16,
	.bDefaultFrameIndex	= 1,
	.bAspectRatioX		= 0,
	.bAspectRatioY		= 0,
	.bmInterfaceFlags	= 0,
	.bCopyProtect		= 0,
};
static const struct UVC_FRAME_UNCOMPRESSED(3) uvc_frame_yuv_640p = {//这里的3也是帧率个数
	.bLength		= UVC_DT_FRAME_UNCOMPRESSED_SIZE(3),//这里的3代表有几个帧率支持
	.bDescriptorType	= USB_DT_CS_INTERFACE,
	.bDescriptorSubType	= UVC_VS_FRAME_UNCOMPRESSED,
	.bFrameIndex		= 2,//这是第几个分辨率,我这里把这个分辨率插到中间了,720P的改为3
	.bmCapabilities		= 0,
	.wWidth			= cpu_to_le16(640),
	.wHeight		= cpu_to_le16(960),
	.dwMinBitRate		= cpu_to_le32(49152000),//不清楚怎么计算的,
	.dwMaxBitRate		= cpu_to_le32(147456000),//不清楚怎么计算的
	.dwMaxVideoFrameBufferSize	= cpu_to_le32(1228800),//YUYV格式,size=640*960*2
	.dwDefaultFrameInterval	= cpu_to_le32(666666),//默认帧率
	.bFrameIntervalType	= 3,//代表支持几个帧率
	.dwFrameInterval[0]	= cpu_to_le32(666666),//15fps
	.dwFrameInterval[1]	= cpu_to_le32(1000000),//10fps
	.dwFrameInterval[2]	= cpu_to_le32(5000000),//2fps
};
//Full speed模式支持的格式和分辨率
static const struct uvc_descriptor_header * const uvc_fs_streaming_cls[] = {
	(const struct uvc_descriptor_header *) &uvc_input_header,
	(const struct uvc_descriptor_header *) &uvc_format_yuv,
	(const struct uvc_descriptor_header *) &uvc_frame_yuv_360p,
	(const struct uvc_descriptor_header *) &uvc_frame_yuv_640p,//新增的分辨率
	(const struct uvc_descriptor_header *) &uvc_frame_yuv_720p,
	(const struct uvc_descriptor_header *) &uvc_format_mjpg,
	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_360p,
	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_640p,//新增的分辨率
	(const struct uvc_descriptor_header *) &uvc_frame_mjpg_720p,
	(const struct uvc_descriptor_header *) &uvc_color_matching,
	NULL,
};

MJPEG 新增方法类似,hs,ss的cls同样添加一下新增的分辨率

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐