BUG: V4L2 fourcc GRBG not supported
In kernel 2.6.31, which ships with Ubuntu Karmic (9.10) and will be shipping with openSUSE 11.2, some web cams now report a v4l2 fourcc of "GRBG". This is effectively the same format as "GBRG" and can be processed with bayer2rgb24, but since Motion doesn't know about that, it doesn't try to use it. I have created a patch (see below) which successfully restored the old functionality.
Log from when it was failing:
[Oct 29 13:01:10] [2] v4l2_get_capability:
------------------------
cap.driver: "STV06xx"
cap.card: "Camera"
cap.bus_info: "usb-0000:00:1f.2-2"
cap.capabilities=0x05000001
------------------------
[Oct 29 13:01:10] [2] - VIDEO_CAPTURE
[Oct 29 13:01:10] [2] - READWRITE
[Oct 29 13:01:10] [2] - STREAMING
[Oct 29 13:01:10] [2] v4l2_set_pix_format: Supported palettes:
[Oct 29 13:01:10] [2] 0: GRBG (GRBG)
[Oct 29 13:01:10] [2] v4l2_set_pix_format: 0 - GRBG (compressed : 0) (0x47425247)
[Oct 29 13:01:10] [2] v4l2_set_pix_format: Unable to find a compatible palette format.
[Oct 29 13:01:10] [2] v4l_start: Using VIDEO_PALETTE_YUV420P palette
[Oct 29 13:01:10] [2] vid_v4lx_start: Using V4L1
[Oct 29 13:01:10] [2] image_ring_resize: Resizing pre_capture buffer to 1 items
[Oct 29 13:01:10] [2] http_bindsock: motion-stream testing : IPV4 addr: 0.0.0.0 port: 8082
[Oct 29 13:01:10] [2] http_bindsock: motion-stream Bound : IPV4 addr: 0.0.0.0 port: 8082
[Oct 29 13:01:10] [2] motion_init: Started motion-stream server in port 8082
[Oct 29 13:01:10] [2] v4l_next: sync error in proc 1890:
[Oct 29 13:01:11] [2] v4l_next: mcapture error in proc 1890:
[Oct 29 13:01:11] [2] motion_loop: Video device fatal error - Closing video device
[Oct 29 13:01:11] [2] vid_close: Closing video device /dev/video1
[Oct 29 13:01:20] [2] motion_loop: Retrying until successful connection with camera
Log after fix:
[Oct 29 18:26:39] [2] motion_init: Thread 2 started
[Oct 29 18:26:39] [2] v4l2_get_capability:
------------------------
cap.driver: "STV06xx"
cap.card: "Camera"
cap.bus_info: "usb-0000:00:1f.2-2"
cap.capabilities=0x05000001
------------------------
[Oct 29 18:26:39] [2] - VIDEO_CAPTURE
[Oct 29 18:26:39] [2] - READWRITE
[Oct 29 18:26:39] [2] - STREAMING
[Oct 29 18:26:39] [2] v4l2_set_pix_format: Supported palettes:
[Oct 29 18:26:39] [2] 0: GRBG (GRBG)
[Oct 29 18:26:39] [2] v4l2_set_pix_format: 0 - GRBG (compressed : 0) (0x47425247)
[Oct 29 18:26:39] [2] v4l2_set_pix_format: index_format 17 Testing palette GRBG (640x480)
[Oct 29 18:26:39] [2] v4l2_set_pix_format: Adjusting resolution from 640x480 to 324x240.
[Oct 29 18:26:39] [2] v4l2_set_pix_format: Using palette GRBG (324x240) bytesperlines 324 sizeimage 79056 colorspace 00000008
[Oct 29 18:26:39] [2] v4l2_scan_controls: found control 0x00980900, "Brightness", range 0,31
[Oct 29 18:26:39] [2] v4l2_scan_controls: "Brightness", default 3, current 3
[Oct 29 18:26:39] [2] v4l2_scan_controls: found control 0x00980901, "Contrast", range 0,15
[Oct 29 18:26:39] [2] v4l2_scan_controls: "Contrast", default 11, current 11
[Oct 29 18:26:39] [2] v4l2_scan_controls: found control 0x00980911, "Exposure", range 0,1023
[Oct 29 18:26:39] [2] v4l2_scan_controls: "Exposure", default 256, current 104
[Oct 29 18:26:39] [2] v4l2_scan_controls: found control 0x00980913, "Gain", range 0,255
[Oct 29 18:26:39] [2] v4l2_scan_controls: "Gain", default 64, current 64
[Oct 29 18:26:39] [2] v4l2_set_mmap: mmap information: frames=4
[Oct 29 18:26:39] [2] v4l2_set_mmap: 0 length=81920
[Oct 29 18:26:39] [2] v4l2_set_mmap: 1 length=81920
[Oct 29 18:26:39] [2] v4l2_set_mmap: 2 length=81920
[Oct 29 18:26:39] [2] v4l2_set_mmap: 3 length=81920
Patch:
Index: motion/video2.c
===================================================================
--- motion.orig/video2.c 2009-09-02 14:00:37.000000000 -0400
+++ motion/video2.c 2009-10-29 18:32:15.000000000 -0400
@@ -47,6 +47,7 @@
V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') YYUV per line
V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') YUVY per line
V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') 8 GBGB.. RGRG..
+ V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') 8 GRGR.. BGBG..
V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') 16 BGBG.. GRGR..
V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') compressed GBRG bayer
V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') Pixart 73xx JPEG
@@ -91,6 +92,10 @@
#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */
#endif
+#ifndef V4L2_PIX_FMT_SGRBG8
+#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */
+#endif
+
#ifndef V4L2_PIX_FMT_MJPEG
#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */
#endif
@@ -376,6 +381,7 @@
V4L2_PIX_FMT_YUYV,
V4L2_PIX_FMT_YUV422P,
V4L2_PIX_FMT_YUV420,
+ V4L2_PIX_FMT_SGRBG8,
0
};
@@ -933,6 +939,7 @@
/* FIXME: quick hack to allow work all bayer formats */
case V4L2_PIX_FMT_SBGGR16:
case V4L2_PIX_FMT_SGBRG8:
+ case V4L2_PIX_FMT_SGRBG8:
case V4L2_PIX_FMT_SPCA561:
case V4L2_PIX_FMT_SBGGR8: /* bayer */
bayer2rgb24(cnt->imgs.common_buffer, the_buffer->ptr, width, height);
Environment
Motion version: |
svn r469 (trunk) |
ffmpeg version: |
SVN-r19352-4:0.5+svn20090706-2ubuntu2 |
Shared libraries: |
ffmpeg, |
Server OS: |
Ubuntu Karmic (9.10) 2.6.31 |
--
IsaacRichter - 29 Oct 2009
Follow up
Hi Issac,
Did your patch work fine with that Bayer palette ?
I've to test it before introduce your patch to svn.
Thanks !
--
AngelCarpintero - 15 Nov 2009
Fix record
Added to svn trunk ( r473 )
--
AngelCarpintero - 24 Nov 2009