Last active
June 25, 2021 20:37
-
-
Save BrianAdams/a558717b9ede409414fa to your computer and use it in GitHub Desktop.
v4l2 driver patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c | |
index 7c8322d..f389ccb 100644 | |
--- a/drivers/media/usb/uvc/uvc_driver.c | |
+++ b/drivers/media/usb/uvc/uvc_driver.c | |
@@ -36,6 +36,7 @@ unsigned int uvc_no_drop_param; | |
static unsigned int uvc_quirks_param = -1; | |
unsigned int uvc_trace_param; | |
unsigned int uvc_timeout_param = UVC_CTRL_STREAMING_TIMEOUT; | |
+unsigned int uvc_jpeg_comp_param; | |
/* ------------------------------------------------------------------------ | |
* Video formats | |
@@ -388,6 +389,10 @@ static int uvc_parse_format(struct uvc_device *dev, | |
format->fcc = V4L2_PIX_FMT_MJPEG; | |
format->flags = UVC_FMT_FLAG_COMPRESSED; | |
format->bpp = 0; | |
+ if ((uvc_jpeg_comp_param > 0) && ( 16 >= uvc_jpeg_comp_param)) | |
+ format->bpp = uvc_jpeg_comp_param; | |
+ else | |
+ format->bpp = 4; | |
ftype = UVC_VS_FRAME_MJPEG; | |
break; | |
@@ -2071,6 +2076,8 @@ module_param_named(trace, uvc_trace_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"); | |
+module_param_named(jpg_compression, uvc_jpeg_comp_param, uint, S_IRUGO|S_IWUSR); | |
+MODULE_PARM_DESC(jpg_compression, "JPG compression ratio for bandwidth quirk"); | |
/* ------------------------------------------------------------------------ | |
* Driver initialization and cleanup | |
@@ -2553,4 +2560,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |
MODULE_DESCRIPTION(DRIVER_DESC); | |
MODULE_LICENSE("GPL"); | |
MODULE_VERSION(DRIVER_VERSION); | |
- | |
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c | |
index 9ace520..da17351 100644 | |
--- a/drivers/media/usb/uvc/uvc_video.c | |
+++ b/drivers/media/usb/uvc/uvc_video.c | |
@@ -119,8 +119,11 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream, | |
ctrl->dwMaxVideoFrameSize = | |
frame->dwMaxVideoFrameBufferSize; | |
- if (!(format->flags & UVC_FMT_FLAG_COMPRESSED) && | |
- stream->dev->quirks & UVC_QUIRK_FIX_BANDWIDTH && | |
+ | |
+ if ((!(format->flags & UVC_FMT_FLAG_COMPRESSED) || | |
+ (format->fcc == V4L2_PIX_FMT_MJPEG)) && | |
+ (stream->dev->quirks & UVC_QUIRK_FIX_BANDWIDTH || | |
+ stream->dev->quirks & UVC_QUIRK_FIX_JPEG_BANDWIDTH) && | |
stream->intf->num_altsetting > 1) { | |
u32 interval; | |
u32 bandwidth; | |
@@ -149,7 +152,8 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream, | |
* resolutions working while not preventing two simultaneous | |
* VGA streams at 15 fps. | |
*/ | |
- bandwidth = max_t(u32, bandwidth, 1024); | |
+ if(!(stream->dev->quirks & UVC_QUIRK_DISABLE_URB_1024)) | |
+ bandwidth = max_t(u32, bandwidth, 1024); | |
ctrl->dwMaxPayloadTransferSize = bandwidth; | |
} | |
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h | |
index 6f676c2..04fc55b 100644 | |
--- a/drivers/media/usb/uvc/uvcvideo.h | |
+++ b/drivers/media/usb/uvc/uvcvideo.h | |
@@ -144,10 +144,12 @@ | |
#define UVC_QUIRK_BUILTIN_ISIGHT 0x00000008 | |
#define UVC_QUIRK_STREAM_NO_FID 0x00000010 | |
#define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020 | |
+#define UVC_QUIRK_FIX_JPEG_BANDWIDTH 0x00000040 | |
#define UVC_QUIRK_FIX_BANDWIDTH 0x00000080 | |
#define UVC_QUIRK_PROBE_DEF 0x00000100 | |
#define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200 | |
#define UVC_QUIRK_RESTORE_CTRLS_ON_INIT 0x00000400 | |
+#define UVC_QUIRK_DISABLE_URB_1024 0x00004000 | |
/* Format flags */ | |
#define UVC_FMT_FLAG_COMPRESSED 0x00000001 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment