Skip to contentSkip to conversation

Support data_offset and 10-bit packed raw bayer

PATCH In review Sakari Ailus 2 participants 6 messages Dec 15, 2014 Media (V4L/DVB)

lore
Share & tools
lore
#5 lore raw

PATCH v3 3/3 yavta: Add support for 10-bit packed raw bayer formats

In reply to Sakari Ailus

Add support for these pixel formats:

V4L2_PIX_FMT_SBGGR10P
V4L2_PIX_FMT_SGBRG10P
V4L2_PIX_FMT_SGRBG10P
V4L2_PIX_FMT_SRGGB10P

---
 yavta.c | 4 ++++
 1 file changed, 4 insertions(+)
yavta.c +4 -0
index cf8239b..e79abd6 100644
@@ -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
#0 lore raw

v3 cover Support data_offset and 10-bit packed raw bayer

Hi Laurent,

since v2:

- Reworked patch 1,
- List media-tree and on-list patches included in the headers.

Signature · 2 lines
Kind regards,
Sakari
#1 lore raw

PATCH v3 1/3 yavta: Implement data_offset support for multi plane buffers

Support data_offset for multi plane buffers. Also add an option to write the data in the buffer before data offset (--buffer-prefix).

---
 yavta.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
yavta.c +17 -3
index 77e5a41..cf8239b 100644
@@ -80,6 +80,8 @@ struct device
 
 	void *pattern[VIDEO_MAX_PLANES];
 	unsigned int patternsize[VIDEO_MAX_PLANES];
+
+	bool write_buffer_prefix;
 };
 
 static bool video_is_mplane(struct device *dev)
@@ -1545,14 +1547,21 @@ static void video_save_image(struct device *dev, struct v4l2_buffer *buf,
 		return;
 
 	for (i = 0; i < dev->num_planes; i++) {
+		void *data = dev->buffers[buf->index].mem[i];
 		unsigned int length;
 
-		if (video_is_mplane(dev))
+		if (video_is_mplane(dev)) {
 			length = buf->m.planes[i].bytesused;
-		else
+
+			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, dev->buffers[buf->index].mem[i], length);
+		ret = write(fd, data, length);
 		if (ret < 0) {
 			printf("write error: %s (%d)\n", strerror(errno), errno);
 			break;
@@ -1717,6 +1726,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 +1759,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	271
 
 static 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 +2028,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
#3 lore raw

PATCH v3 2/3 yavta: Update headers from upstream kernel

In reply to Sakari Ailus

Include packed raw 10-bit definitions as well.

This includes patches up to and including
"[media] mn88473: One function call less in mn88473_init() after error" and the following patches (v2 sent to linux-media):

"DocBook: v4l: Fix raw bayer pixel format documentation wording", "DocBook: v4l: Rearrange raw bayer format definitions, remove bad comment" and "v4l: Add packed Bayer raw10 pixel formats".

---
 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
index 2f6f8ca..1527398 100644
@@ -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
index e946e43..661f119 100644
@@ -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
#4 lore raw

Re: [yavta PATCH v3 2/3] yavta: Update headers from upstream kernel

Hi Sakari,

Thank you for the patch.

Quoted 9 lines · On Monday 15 December 2014 21:58:39 Sakari Ailus wrote:

Include packed raw 10-bit definitions as well.

This includes patches up to and including
"[media] mn88473: One function call less in mn88473_init() after error" and the following patches (v2 sent to linux-media):

"DocBook: v4l: Fix raw bayer pixel format documentation wording", "DocBook: v4l: Rearrange raw bayer format definitions, remove bad comment" and "v4l: Add packed Bayer raw10 pixel formats".

Could you please resubmit this with the upstream commit ID when Mauro will have pulled those two patches ?

Quoted 34 lines
---
 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
index 2f6f8ca..1527398 100644
@@ -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
index e946e43..661f119 100644
@@ -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
index 87b83c3..14e2129 100644
@@ -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 {
#define V4L2_PIX_FMT_XRGB555 v4l2_fourcc('X', 'R', '1', '5') /* 16
XRGB-1-5-5-5 */ #define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B',
'P') /* 16 RGB-5-6-5 */ #define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R',
'G', 'B', 'Q') /* 16 RGB-5-5-5 BE */ +#define V4L2_PIX_FMT_ARGB555X v4l2_fourcc_be('A', 'R', '1', '5') /* 16 ARGB-5-5-5 BE */ +#define V4L2_PIX_FMT_XRGB555X v4l2_fourcc_be('X', 'R', '1', '5') /* 16 XRGB-5-5-5 BE */ #define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16 RGB-5-6-5 BE */ #define V4L2_PIX_FMT_BGR666 v4l2_fourcc('B', 'G', 'R',
'H') /* 18 BGR-6-6-6 */ #define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B',
'G', 'R', '3') /* 24 BGR-8-8-8 */ @@ -383,10 +461,11 @@ struct
v4l2_pix_format {
#define V4L2_PIX_FMT_SGBRG10 v4l2_fourcc('G', 'B', '1', '0') /* 10 GBGB..

Quoted 8 lines

RGRG.. */ #define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0') /* 10 GRGR.. BGBG.. */ #define V4L2_PIX_FMT_SRGGB10 v4l2_fourcc('R', 'G', '1', '0') /* 10 RGRG.. GBGB.. */ -#define V4L2_PIX_FMT_SBGGR12 v4l2_fourcc('B', 'G', '1', '2') /* 12 BGBG.. GRGR.. */ -#define V4L2_PIX_FMT_SGBRG12 v4l2_fourcc('G', 'B', '1', '2') /* 12 GBGB.. RGRG.. */ -#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12 GRGR.. BGBG.. */ -#define V4L2_PIX_FMT_SRGGB12 v4l2_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_SGBRG12 v4l2_fourcc('G', 'B', '1', '2') /* 12 GBGB.. RGRG.. */ +#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12 GRGR.. BGBG.. */ +#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12 RGRG.. GBGB.. */ #define V4L2_PIX_FMT_SBGGR16 v4l2_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_STD 0x00000004 /* Supports

S_STD */

Quoted 1 line

+#define V4L2_IN_CAP_NATIVE_SIZE 0x00000008 /* 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 S

include/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_STD 0x00000004 /* Supports S_STD

*/

Quoted 1 line

+#define V4L2_OUT_CAP_NATIVE_SIZE 0x00000008 /* Supports setting native

size

Quoted 24 lines

*/

/*
* C O N T R O L S

include/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
Acked-by on v3 1/3
#2 lore raw

Re: [yavta PATCH v3 1/3] yavta: Implement data_offset support for multi plane buffers

In reply to Sakari Ailus

Hi Sakari,

Thank you for the patch.

Quoted 4 lines · On Monday 15 December 2014 21:58:38 Sakari Ailus wrote:

Support data_offset for multi plane buffers. Also add an option to write the data in the buffer before data offset (--buffer-prefix).

Quoted 43 lines
---
 yavta.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
yavta.c +12 -3
index 77e5a41..cf8239b 100644
@@ -80,6 +80,8 @@ struct device
 
 	void *pattern[VIDEO_MAX_PLANES];
 	unsigned int patternsize[VIDEO_MAX_PLANES];
+
+	bool write_buffer_prefix;
 };
 
 static bool video_is_mplane(struct device *dev)
@@ -1545,14 +1547,21 @@ static void video_save_image(struct device *dev,
 struct v4l2_buffer *buf, return;
 
 	for (i = 0; i < dev->num_planes; i++) {
+		void *data = dev->buffers[buf->index].mem[i];
 		unsigned int length;
 
-		if (video_is_mplane(dev))
+		if (video_is_mplane(dev)) {
 			length = buf->m.planes[i].bytesused;
-		else
+
+			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, dev->buffers[buf->index].mem[i], length);
+		ret = write(fd, data, length);
 		if (ret < 0) {
 			printf("write error: %s (%d)\n", strerror(errno), errno);
 			break;

yavta.c static void usage(const char *argv0) · line 1726

Quoted 1 line
yavta.c +0 -0
@@ -1717,6 +1726,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 -0
 	printf("    --enum-formats		Enumerate formats\n");
 	printf("    --enum-inputs		Enumerate inputs\n");
@@ -1749,10 +1759,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	271
 
 static 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 +2028,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