Last active
August 29, 2015 13:58
-
-
Save mkassner/10134241 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 6a4b0b8..e5e63b2 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 | |
@@ -403,6 +404,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; | |
@@ -2097,6 +2102,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 | |
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c | |
index 9637e8b..2aabbc0 100644 | |
--- a/drivers/media/usb/uvc/uvc_video.c | |
+++ b/drivers/media/usb/uvc/uvc_video.c | |
@@ -119,8 +119,10 @@ 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 +151,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 f0a04b5..f6faf08 100644 | |
--- a/drivers/media/usb/uvc/uvcvideo.h | |
+++ b/drivers/media/usb/uvc/uvcvideo.h | |
@@ -150,6 +150,9 @@ | |
#define UVC_QUIRK_RESTORE_CTRLS_ON_INIT 0x00000400 | |
#define UVC_QUIRK_FORCE_Y8 0x00000800 | |
+#define UVC_QUIRK_FIX_JPEG_BANDWIDTH 0x00000040 | |
+#define UVC_QUIRK_DISABLE_URB_1024 0x00004000 | |
+ | |
/* Format flags */ | |
#define UVC_FMT_FLAG_COMPRESSED 0x00000001 | |
#define UVC_FMT_FLAG_STREAM 0x00000002 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mkassner - the file should be renamed
mjpeg_bandwidth.patch
(instead of mjepg). Additionally the wiki page for the patch would also need to be updated.