Support data_offset and 10-bit packed raw bayer formats
PATCH v2 2/3 yavta: Update headers from upstream kernel
In reply to Sakari AilusInclude packed raw 10-bit definitions as well.
--- include/linux/v4l2-common.h | 2 + include/linux/v4l2-controls.h | 6 +++ include/linux/videodev2.h | 121 +++++++++++++++++++++++++++++++++++------- 3 files changed, 111 insertions(+), 18 deletions(-)
include/linux/v4l2-common.h +2 -0
@@ -43,6 +43,8 @@#define V4L2_SEL_TGT_CROP_DEFAULT 0x0001/* Cropping bounds */ #define V4L2_SEL_TGT_CROP_BOUNDS 0x0002 +/* Native frame size */ +#define V4L2_SEL_TGT_NATIVE_SIZE 0x0003/* Current composing area */ #define V4L2_SEL_TGT_COMPOSE 0x0100/* Default composing area */
include/linux/v4l2-controls.h +6 -0
@@ -746,6 +746,8 @@ enum v4l2_auto_focus_range { V4L2_AUTO_FOCUS_RANGE_INFINITY = 3, }; +#define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE+32) +#define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE+33)/* FM Modulator class control IDs */
@@ -865,6 +867,10 @@ enum v4l2_jpeg_chroma_subsampling {#define V4L2_CID_VBLANK (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 1)#define V4L2_CID_HBLANK (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 2)#define V4L2_CID_ANALOGUE_GAIN (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 3) +#define V4L2_CID_TEST_PATTERN_RED (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 4) +#define V4L2_CID_TEST_PATTERN_GREENR (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 5) +#define V4L2_CID_TEST_PATTERN_BLUE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 6) +#define V4L2_CID_TEST_PATTERN_GREENB (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 7)/* Image processing controls */
include/linux/videodev2.h +103 -18
196 lines not on this page · raw message
Signature · 1 line
2.1.0.231.g7484e3b
PATCH v2 1/3 yavta: Implement data_offset support for multi plane buffers
In reply to Sakari AilusSupport data_offset for multi plane buffers. Also add an option to write the data in the buffer before data offset (--buffer-prefix).
--- yavta.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
yavta.c +19 -3
@@ -80,6 +80,8 @@ struct devicevoid *pattern[VIDEO_MAX_PLANES ];unsigned int patternsize[VIDEO_MAX_PLANES ]; + +bool write_buffer_prefix; };static bool video_is_mplane (struct device *dev)
@@ -1546,13 +1548,22 @@ static void video_save_image(struct device *dev, struct v4l2_buffer *buf,for (i =0 ; i < dev->num_planes; i++) {unsigned int length; +unsigned int data_offset =0 ; -if (video_is_mplane (dev)) +if (video_is_mplane (dev)) { length = buf->m.planes[i].bytesused; -else + data_offset = buf->m.planes[i].data_offset; + }else { length = buf->bytesused; + } + +if (!dev->write_buffer_prefix) + length -= data_offset; +else + data_offset =0 ; - ret =write (fd, dev->buffers[buf->index].mem[i], length); + ret =write (fd, dev->buffers[buf->index].mem[i] + data_offset, + length);if (ret <0 ) {printf ("write error: %s (%d)\n" ,strerror (errno), errno);break ;
@@ -1717,6 +1728,7 @@ static void usage(const char *argv0)printf ("-t, --time-per-frame num/denom Set the time per frame (eg. 1/25 = 25 fps)\n" );printf ("-u, --userptr Use the user pointers streaming method\n" );printf ("-w, --set-control 'ctrl value' Set control 'ctrl' to 'value'\n" ); +printf (" --buffer-prefix Write portions of buffer before data_offset\n" );printf (" --buffer-size Buffer size in bytes\n" );printf (" --enum-formats Enumerate formats\n" );printf (" --enum-inputs Enumerate inputs\n" );
@@ -1749,10 +1761,12 @@ static void usage(const char *argv0)#define OPT_BUFFER_SIZE 268#define OPT_PREMULTIPLIED 269#define OPT_QUEUE_LATE 270 +#define OPT_BUFFER_PREFIX 271static struct option opts[] = { {"buffer-size" ,1 ,0 ,OPT_BUFFER_SIZE }, {"buffer-type" ,1 ,0 ,'B' }, + {"buffer-prefix" ,1 ,0 ,OPT_BUFFER_PREFIX }, {"capture" ,2 ,0 ,'c' }, {"check-overrun" ,0 ,0 ,'C' }, {"delay" ,1 ,0 ,'d' },
@@ -2016,6 +2030,8 @@ int main(int argc, char *argv[])case OPT_USERPTR_OFFSET : userptr_offset =atoi (optarg);break ; +case OPT_BUFFER_PREFIX : + dev.write_buffer_prefix = true;default :printf ("Invalid option -%c\n" , c);printf ("Run %s -h for help.\n" , argv[0 ]);
Signature · 1 line
2.1.0.231.g7484e3b
v2 cover Support data_offset and 10-bit packed raw bayer formats
Hi Laurent,
Compared to v1, a field remaining from the single plane data_offset support patch has been removed. Also the kernel headers have been updated with the 10-bit packed raw bayer pixel format definitions.
Signature · 2 lines
Kind regards, Sakari
PATCH v2 3/3 yavta: Add support for 10-bit packed raw bayer formats
Add support for these pixel formats:
V4L2_PIX_FMT_SBGGR10PV4L2_PIX_FMT_SGBRG10PV4L2_PIX_FMT_SGRBG10PV4L2_PIX_FMT_SRGGB10P
--- yavta.c | 4 ++++ 1 file changed, 4 insertions(+)
yavta.c +4 -0
@@ -202,6 +202,10 @@ static struct v4l2_format_info { { "SGBRG10", V4L2_PIX_FMT_SGBRG10, 1 }, { "SGRBG10", V4L2_PIX_FMT_SGRBG10, 1 }, { "SRGGB10", V4L2_PIX_FMT_SRGGB10, 1 }, + { "SBGGR10P", V4L2_PIX_FMT_SBGGR10P, 1 }, + { "SGBRG10P", V4L2_PIX_FMT_SGBRG10P, 1 }, + { "SGRBG10P", V4L2_PIX_FMT_SGRBG10P, 1 }, + { "SRGGB10P", V4L2_PIX_FMT_SRGGB10P, 1 }, { "SBGGR12", V4L2_PIX_FMT_SBGGR12, 1 }, { "SGBRG12", V4L2_PIX_FMT_SGBRG12, 1 }, { "SGRBG12", V4L2_PIX_FMT_SGRBG12, 1 },
Signature · 1 line
2.1.0.231.g7484e3b
Re: [yavta PATCH v2 2/3] yavta: Update headers from upstream kernel
In reply to Sakari AilusHi Sakari,
Thank you for the patch.
Quoted 1 line · On Monday 15 December 2014 18:26:48 Sakari Ailus wrote:
Include packed raw 10-bit definitions as well.
Could you please mention in the commit message which upstream tag or commit ID has been used to generate the headers ?
Quoted 34 lines
Signed-off-by Sakari Ailus <[email protected]>--- include/linux/v4l2-common.h | 2 + include/linux/v4l2-controls.h | 6 +++ include/linux/videodev2.h | 121 ++++++++++++++++++++++++++++++++------- 3 files changed, 111 insertions(+), 18 deletions(-)include/linux/v4l2-common.h +2
-0@@ -43,6 +43,8 @@#define V4L2_SEL_TGT_CROP_DEFAULT 0x0001/* Cropping bounds */ #define V4L2_SEL_TGT_CROP_BOUNDS 0x0002 +/* Native frame size */ +#define V4L2_SEL_TGT_NATIVE_SIZE 0x0003/* Current composing area */ #define V4L2_SEL_TGT_COMPOSE 0x0100/* Default composing area */ include/linux/v4l2-controls.h +2
-0@@ -746,6 +746,8 @@ enum v4l2_auto_focus_range { V4L2_AUTO_FOCUS_RANGE_INFINITY = 3, }; +#define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE+32) +#define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE+33)/* FM Modulator class control IDs */
include/linux/v4l2-controls.h enum v4l2_jpeg_chroma_subsampling { · line 869
Quoted 3 lines
include/linux/v4l2-controls.h +0
-0@@ -865,6 +867,10 @@ enum v4l2_jpeg_chroma_subsampling {#define V4L2_CID_VBLANK (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 1)#define V4L2_CID_HBLANK (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 2)#define V4L2_CID_ANALOGUE_GAIN (V4L2_CID_IMAGE_SOURCE_CLASS_BASE
+ 3)
include/linux/v4l2-controls.h enum v4l2_jpeg_chroma_subsampling { · line 870
Quoted 1 line
include/linux/v4l2-controls.h +1
-0+#define V4L2_CID_TEST_PATTERN_RED (V4L2_CID_IMAGE_SOURCE_CLASS_BASE +
4)
include/linux/v4l2-controls.h enum v4l2_jpeg_chroma_subsampling { · line 871
Quoted 1 line
include/linux/v4l2-controls.h +1
-0+#define V4L2_CID_TEST_PATTERN_GREENR (V4L2_CID_IMAGE_SOURCE_CLASS_BASE
+
Quoted 1 line
5) +#define
V4L2_CID_TEST_PATTERN_BLUE(V4L2_CID_IMAGE_SOURCE_CLASS_BASE
+
Quoted 1 line
6) +#define
V4L2_CID_TEST_PATTERN_GREENB
(V4L2_CID_IMAGE_SOURCE_CLASS_BASE
include/linux/videodev2.h line 79
Quoted 12 lines
+ 7)
/* Image processing controls */
include/linux/videodev2.h +0
-0@@ -77,6 +77,7 @@/* Four-character-code (FOURCC) */ #define v4l2_fourcc (a, b, c, d)\ ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) | ((__u32)(d) <<
24))
Quoted 139 lines
include/linux/videodev2.h +85
-9+#define v4l2_fourcc_be (a, b, c, d) (v4l2_fourcc(a, b, c, d) | (1 << 31))/* * E N U M S @@ -175,30 +176,103 @@ enum v4l2_memory {/* see also http://vektor.theorem.ca/graphics/ycbcr/ */ enum v4l2_colorspace { -/* ITU-R 601 -- broadcast NTSC/PAL */ +/* SMPTE 170M: used for broadcast NTSC/PAL SDTV */ V4L2_COLORSPACE_SMPTE170M =1 , -/* 1125-Line (US) HDTV */ +/* Obsolete pre-1998 SMPTE 240M HDTV standard, superseded by Rec 709 */ V4L2_COLORSPACE_SMPTE240M =2 , -/* HD and modern captures. */ +/* Rec.709: used for HDTV */ V4L2_COLORSPACE_REC709 =3 , -/* broken BT878 extents (601, luma range 16-253 instead of 16-235) */ +/* +* Deprecated, do not use. No driver will ever return this. This was +* based on a misunderstanding of the bt878 datasheet. +*/ V4L2_COLORSPACE_BT878 =4 , -/* These should be useful. Assume 601 extents. */ +/* +* NTSC 1953 colorspace. This only makes sense when dealing with +* really, really old NTSC recordings. Superseded by SMPTE 170M. +*/ V4L2_COLORSPACE_470_SYSTEM_M =5 , + +/* +* EBU Tech 3213 PAL/SECAM colorspace. This only makes sense when +* dealing with really old PAL/SECAM recordings. Superseded by +* SMPTE 170M. +*/ V4L2_COLORSPACE_470_SYSTEM_BG =6 , -/* I know there will be cameras that send this. So, this is -* unspecified chromaticities and full 0-255 on each of the -* Y'CbCr components +/* +* Effectively shorthand for V4L2_COLORSPACE_SRGB, V4L2_YCBCR_ENC_601 +* and V4L2_QUANTIZATION_FULL_RANGE. To be used for (Motion-)JPEG. */ V4L2_COLORSPACE_JPEG =7 , -/* For RGB colourspaces, this is probably a good start. */ +/* For RGB colorspaces such as produces by most webcams. */ V4L2_COLORSPACE_SRGB =8 , + +/* AdobeRGB colorspace */ +V4L2_COLORSPACE_ADOBERGB =9 , + +/* BT.2020 colorspace, used for UHDTV. */ +V4L2_COLORSPACE_BT2020 =10 , +}; + +enum v4l2_ycbcr_encoding { +/* +* Mapping of V4L2_YCBCR_ENC_DEFAULT to actual encodings for the +* various colorspaces: +* +* V4L2_COLORSPACE_SMPTE170M, V4L2_COLORSPACE_470_SYSTEM_M, +* V4L2_COLORSPACE_470_SYSTEM_BG, V4L2_COLORSPACE_ADOBERGB and +* V4L2_COLORSPACE_JPEG: V4L2_YCBCR_ENC_601 +* +* V4L2_COLORSPACE_REC709: V4L2_YCBCR_ENC_709 +* +* V4L2_COLORSPACE_SRGB: V4L2_YCBCR_ENC_SYCC +* +* V4L2_COLORSPACE_BT2020: V4L2_YCBCR_ENC_BT2020 +* +* V4L2_COLORSPACE_SMPTE240M: V4L2_YCBCR_ENC_SMPTE240M +*/ +V4L2_YCBCR_ENC_DEFAULT =0 , + +/* ITU-R 601 -- SDTV */ +V4L2_YCBCR_ENC_601 =1 , + +/* Rec. 709 -- HDTV */ +V4L2_YCBCR_ENC_709 =2 , + +/* ITU-R 601/EN 61966-2-4 Extended Gamut -- SDTV */ +V4L2_YCBCR_ENC_XV601 =3 , + +/* Rec. 709/EN 61966-2-4 Extended Gamut -- HDTV */ +V4L2_YCBCR_ENC_XV709 =4 , + +/* sYCC (Y'CbCr encoding of sRGB) */ +V4L2_YCBCR_ENC_SYCC =5 , + +/* BT.2020 Non-constant Luminance Y'CbCr */ +V4L2_YCBCR_ENC_BT2020 =6 , + +/* BT.2020 Constant Luminance Y'CbcCrc */ +V4L2_YCBCR_ENC_BT2020_CONST_LUM =7 , + +/* SMPTE 240M -- Obsolete HDTV */ +V4L2_YCBCR_ENC_SMPTE240M =8 , +}; + +enum v4l2_quantization { +/* +* The default for R'G'B' quantization is always full range. For +* Y'CbCr the quantization is always limited range, except for +* SYCC, XV601, XV709 or JPEG: those are full range. +*/ +V4L2_QUANTIZATION_DEFAULT =0 , +V4L2_QUANTIZATION_FULL_RANGE =1 , +V4L2_QUANTIZATION_LIM_RANGE =2 , };enum v4l2_priority {@@ -291,6 +365,8 @@ struct v4l2_pix_format {__u32 colorspace;/* enum v4l2_colorspace */ __u32 priv;/* private data, depends on pixelformat */ __u32 flags;/* format flags (V4L2_PIX_FMT_FLAG_*) */ +__u32 ycbcr_enc;/* enum v4l2_ycbcr_encoding */ +__u32 quantization;/* enum v4l2_quantization */ };/* Pixel format FOURCC depth Description */ @@ -305,6 +381,8 @@ struct
v4l2_pix_format{
#defineV4L2_PIX_FMT_XRGB555v4l2_fourcc('X', 'R', '1', '5')/* 16
XRGB-1-5-5-5 */ #defineV4L2_PIX_FMT_RGB565v4l2_fourcc('R', 'G', 'B',
'P') /* 16 RGB-5-6-5 */ #defineV4L2_PIX_FMT_RGB555Xv4l2_fourcc('R',
'G', 'B', 'Q') /* 16 RGB-5-5-5 BE */ +#defineV4L2_PIX_FMT_ARGB555Xv4l2_fourcc_be('A', 'R', '1', '5')/* 16 ARGB-5-5-5 BE */ +#defineV4L2_PIX_FMT_XRGB555Xv4l2_fourcc_be('X', 'R', '1', '5')/* 16 XRGB-5-5-5 BE */ #defineV4L2_PIX_FMT_RGB565Xv4l2_fourcc('R', 'G', 'B', 'R')/* 16 RGB-5-6-5 BE */ #defineV4L2_PIX_FMT_BGR666v4l2_fourcc('B', 'G', 'R',
'H') /* 18 BGR-6-6-6 */ #defineV4L2_PIX_FMT_BGR24v4l2_fourcc('B',
'G', 'R', '3') /* 24 BGR-8-8-8 */ @@ -383,10 +461,11 @@ structv4l2_pix_format{
#defineV4L2_PIX_FMT_SGBRG10v4l2_fourcc('G', 'B', '1', '0')/* 10 GBGB..
Quoted 8 lines
RGRG.. */ #define
V4L2_PIX_FMT_SGRBG10v4l2_fourcc('B', 'A', '1', '0')/* 10 GRGR.. BGBG.. */ #defineV4L2_PIX_FMT_SRGGB10v4l2_fourcc('R', 'G', '1', '0')/* 10 RGRG.. GBGB.. */ -#defineV4L2_PIX_FMT_SBGGR12v4l2_fourcc('B', 'G', '1', '2')/* 12 BGBG.. GRGR.. */ -#defineV4L2_PIX_FMT_SGBRG12v4l2_fourcc('G', 'B', '1', '2')/* 12 GBGB.. RGRG.. */ -#defineV4L2_PIX_FMT_SGRBG12v4l2_fourcc('B', 'A', '1', '2')/* 12 GRGR.. BGBG.. */ -#defineV4L2_PIX_FMT_SRGGB12v4l2_fourcc('R', 'G', '1',
'2') /* 12 RGRG.. GBGB.. */ + /* 10bit raw bayer packed, 5 bytes for
every
Quoted 28 lines
4 pixels */
include/linux/videodev2.h +5
-4+#define V4L2_PIX_FMT_SBGGR10P v4l2_fourcc('p', 'B', 'A', 'A') +#define V4L2_PIX_FMT_SGBRG10P v4l2_fourcc('p', 'G', 'A', 'A') +#define V4L2_PIX_FMT_SGRBG10P v4l2_fourcc('p', 'g', 'A', 'A') +#define V4L2_PIX_FMT_SRGGB10P v4l2_fourcc('p', 'R', 'A', 'A')/* 10bit raw bayer a-law compressed to 8 bits */ #define V4L2_PIX_FMT_SBGGR10ALAW8 v4l2_fourcc('a', 'B', 'A', '8')#define V4L2_PIX_FMT_SGBRG10ALAW8 v4l2_fourcc('a', 'G', 'A', '8')@@ -397,10 +476,10 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_SGBRG10DPCM8 v4l2_fourcc('b', 'G', 'A', '8')#define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0')#define V4L2_PIX_FMT_SRGGB10DPCM8 v4l2_fourcc('b', 'R', 'A', '8') -/* -* 10bit raw bayer, expanded to 16 bits -* xxxxrrrrrrrrrrxxxxgggggggggg xxxxggggggggggxxxxbbbbbbbbbb... -*/ +#define V4L2_PIX_FMT_SBGGR12 v4l2_fourcc('B', 'G', '1', '2')/* 12 BGBG.. GRGR.. */ +#define
V4L2_PIX_FMT_SGBRG12v4l2_fourcc('G', 'B', '1', '2')/* 12 GBGB.. RGRG.. */ +#defineV4L2_PIX_FMT_SGRBG12v4l2_fourcc('B', 'A', '1', '2')/* 12 GRGR.. BGBG.. */ +#defineV4L2_PIX_FMT_SRGGB12v4l2_fourcc('R', 'G', '1', '2')/* 12 RGRG.. GBGB.. */ #defineV4L2_PIX_FMT_SBGGR16v4l2_fourcc('B', 'Y', 'R', '2')/* 16 BGBG.. GRGR.. *//* compressed formats */
include/linux/videodev2.h +0
-0@@ -1244,6 +1323,7 @@ struct v4l2_input {#define V4L2_IN_CAP_DV_TIMINGS 0x00000002/* Supports S_DV_TIMINGS */ #define V4L2_IN_CAP_CUSTOM_TIMINGS V4L2_IN_CAP_DV_TIMINGS/* For
Quoted 1 line
compatibility */ #define
V4L2_IN_CAP_STD0x00000004/* Supports
S_STD */
Quoted 1 line
+#define
V4L2_IN_CAP_NATIVE_SIZE0x00000008/* Supports setting native
size
include/linux/videodev2.h struct v4l2_output { · line 1347
Quoted 6 lines
*/
/*
* V I D E O O U T P U T Sinclude/linux/videodev2.h +0
-0@@ -1267,6 +1347,7 @@ struct v4l2_output {#define V4L2_OUT_CAP_DV_TIMINGS 0x00000002/* Supports S_DV_TIMINGS
*/
Quoted 2 lines
include/linux/videodev2.h +0
-0#define V4L2_OUT_CAP_CUSTOM_TIMINGS V4L2_OUT_CAP_DV_TIMINGS/* For compatibility */ #define
V4L2_OUT_CAP_STD0x00000004/* SupportsS_STD
*/
Quoted 1 line
+#define
V4L2_OUT_CAP_NATIVE_SIZE0x00000008/* Supports setting native
size
Quoted 24 lines
*/
/*
* C O N T R O L Sinclude/linux/videodev2.h +5
-1@@ -1772,6 +1853,8 @@ struct v4l2_plane_pix_format {* @plane_fmt: per-plane information * @num_planes: number of planes for this format * @flags: format flags (V4L2_PIX_FMT_FLAG_*) +* @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding +* @quantization: enum v4l2_quantization, colorspace quantization */ struct v4l2_pix_format_mplane {__u32 width;@@ -1783,7 +1866,9 @@ struct v4l2_pix_format_mplane {struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES ];__u8 num_planes;__u8 flags; -__u8 reserved[10 ]; +__u8 ycbcr_enc; +__u8 quantization; +__u8 reserved[8 ]; } __attribute__ ((packed));/**
Signature · 3 lines
Regards, Laurent Pinchart
Re: [yavta PATCH v2 3/3] yavta: Add support for 10-bit packed raw bayer formats
In reply to Sakari AilusHi Sakari,
Thank you for the patch.
Quoted 8 lines · On Monday 15 December 2014 18:26:49 Sakari Ailus wrote:
Add support for these pixel formats:
V4L2_PIX_FMT_SBGGR10PV4L2_PIX_FMT_SGBRG10PV4L2_PIX_FMT_SGRBG10PV4L2_PIX_FMT_SRGGB10PSigned-off-by Sakari Ailus <[email protected]>
Quoted 19 lines
--- yavta.c | 4 ++++ 1 file changed, 4 insertions(+)yavta.c +4
-0@@ -202,6 +202,10 @@ static struct v4l2_format_info { { "SGBRG10", V4L2_PIX_FMT_SGBRG10, 1 }, { "SGRBG10", V4L2_PIX_FMT_SGRBG10, 1 }, { "SRGGB10", V4L2_PIX_FMT_SRGGB10, 1 }, + { "SBGGR10P", V4L2_PIX_FMT_SBGGR10P, 1 }, + { "SGBRG10P", V4L2_PIX_FMT_SGBRG10P, 1 }, + { "SGRBG10P", V4L2_PIX_FMT_SGRBG10P, 1 }, + { "SRGGB10P", V4L2_PIX_FMT_SRGGB10P, 1 }, { "SBGGR12", V4L2_PIX_FMT_SBGGR12, 1 }, { "SGBRG12", V4L2_PIX_FMT_SGBRG12, 1 }, { "SGRBG12", V4L2_PIX_FMT_SGRBG12, 1 },
Signature · 3 lines
Regards, Laurent Pinchart
Re: [yavta PATCH v2 1/3] yavta: Implement data_offset support for multi plane buffers
In reply to Sakari AilusHi Sakari,
Thank you for the patch.
Quoted 31 lines · On Monday 15 December 2014 18:26:47 Sakari Ailus wrote:
Support
data_offsetfor multi plane buffers. Also add an option to write the data in the buffer before data offset (--buffer-prefix).Signed-off-by Sakari Ailus <[email protected]>--- yavta.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)yavta.c +4
-1@@ -80,6 +80,8 @@ struct devicevoid *pattern[VIDEO_MAX_PLANES ];unsigned int patternsize[VIDEO_MAX_PLANES ]; + +bool write_buffer_prefix; };static bool video_is_mplane (struct device *dev)@@ -1546,13 +1548,22 @@ static void video_save_image(struct device *dev,struct v4l2_buffer *buf, for (i = 0; i < dev->num_planes; i++) {unsigned int length; +unsigned int data_offset =0 ; -if (video_is_mplane (dev)) +if (video_is_mplane (dev)) { length = buf->m.planes[i].bytesused;
yavta.c static void video_save_image(struct device *dev, · line 1564
Quoted 10 lines
yavta.c +8
-1-else + data_offset = buf->m.planes[i].data_offset; + }else { length = buf->bytesused; + } + +if (!dev->write_buffer_prefix) + length -= data_offset; +else + data_offset =0 ;
Nitpicking here, I find it a bit hard to read that you're adjusting the length here but still keep the offset to add it to the buffer address below. How about something like
void *data = dev->buffers[buf->index].mem[i];
unsigned int length;
if (video_is_mplane(dev)) {
length = buf->m.planes[i].bytesused;
if (!dev->write_buffer_prefix) {
data += buf->m.planes[i].data_offset;
length -= buf->m.planes[i].data_offset;
}
} else {
length = buf->bytesused;
}
ret = write(fd, data, length);yavta.c static void usage(const char *argv0) · line 1728
Quoted 8 lines
yavta.c +2
-1- ret =write (fd, dev->buffers[buf->index].mem[i], length); + ret =write (fd, dev->buffers[buf->index].mem[i] + data_offset, + length);if (ret <0 ) {printf ("write error: %s (%d)\n" ,strerror (errno), errno);break ;@@ -1717,6 +1728,7 @@ static void usage(const char *argv0) printf("-t, --time-per-frame num/denom Set the time per frame (eg. 1/25
=
Quoted 3 lines
25 fps)\n"); printf("-u, --userptr Use the user pointers streaming
method\n"); printf("-w, --set-control 'ctrl value' Set control 'ctrl' to
'value'\n"); + printf(" --buffer-prefix Write portions of buffer
before
Quoted 25 lines
data_offset\n");
printf(" --buffer-size Buffer size in bytes\n");yavta.c +4
-0printf (" --enum-formats Enumerate formats\n" );printf (" --enum-inputs Enumerate inputs\n" );@@ -1749,10 +1761,12 @@ static void usage(const char *argv0)#define OPT_BUFFER_SIZE 268#define OPT_PREMULTIPLIED 269#define OPT_QUEUE_LATE 270 +#define OPT_BUFFER_PREFIX 271static struct option opts[] = { {"buffer-size" ,1 ,0 ,OPT_BUFFER_SIZE }, {"buffer-type" ,1 ,0 ,'B' }, + {"buffer-prefix" ,1 ,0 ,OPT_BUFFER_PREFIX }, {"capture" ,2 ,0 ,'c' }, {"check-overrun" ,0 ,0 ,'C' }, {"delay" ,1 ,0 ,'d' },@@ -2016,6 +2030,8 @@ int main(int argc, char *argv[])case OPT_USERPTR_OFFSET : userptr_offset =atoi (optarg);break ; +case OPT_BUFFER_PREFIX : + dev.write_buffer_prefix = true;default :printf ("Invalid option -%c\n" , c);printf ("Run %s -h for help.\n" , argv[0 ]);
Signature · 3 lines
Regards, Laurent Pinchart