@@ -750,11 +750,30 @@ should set this to 0.</entry>
<entry><structfield>data_offset</structfield></entry>
<entry></entry>
<entry>Offset in bytes to video data in the plane, if applicable.
+ This offset can be used to indicate that the data in the plane
+ is preceded by additional metadata, such as headers, specific to
+ the current format.
+ If app_offset != 0, this memory comes after the memory reserved
+ with app_offset and start of data = app_offset + data_offset.
+ This offset can be set by either drivers/hardware (for CAPTURE
+ buffers) or userspace (for OUTPUT types).
</entry>
</row>
<row>
<entry>__u32</entry>
- <entry><structfield>reserved[11]</structfield></entry>
+ <entry><structfield>app_offset</structfield></entry>
+ <entry></entry>
+ <entry>Offset in the plane to the beginning of memory usable by
+ the driver/hardware. Applications may use this field
+ to reserve memory at the beginning of the plane for own
+ use. Neither drivers nor hardware should ever write to
+ the plane before this offset (with the exception of
+ zeroing on allocation, if performed by kernel).
+ </entry>
+ </row>
+ <row>
+ <entry>__u32</entry>
+ <entry><structfield>reserved[10]</structfield></entry>
<entry></entry>
<entry>Reserved for future use. Should be zeroed by an
application.</entry>
@@ -307,7 +307,8 @@ struct v4l2_plane32 {
compat_long_t userptr;
} m;
__u32 data_offset;
- __u32 reserved[11];
+ __u32 app_offset;
+ __u32 reserved[10];
};
struct v4l2_buffer32 {
@@ -338,9 +339,11 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
void __user *up_pln;
compat_long_t p;
+ /* bytesused and length */
if (copy_in_user(up, up32, 2 * sizeof(__u32)) ||
+ /* data_offset and app_offset */
copy_in_user(&up->data_offset, &up32->data_offset,
- sizeof(__u32)))
+ 2 * sizeof(__u32)))
return -EFAULT;
if (memory == V4L2_MEMORY_USERPTR) {
@@ -361,9 +364,11 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
enum v4l2_memory memory)
{
+ /* bytesused and length */
if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
+ /* data_offset and app_offset */
copy_in_user(&up32->data_offset, &up->data_offset,
- sizeof(__u32)))
+ 2 * sizeof(__u32)))
return -EFAULT;
/* For MMAP, driver might've set up the offset, so copy it back.
@@ -332,10 +332,12 @@ static void dbgbuf(unsigned int cmd, struct video_device *vfd,
if (V4L2_TYPE_IS_MULTIPLANAR(p->type) && p->m.planes) {
for (i = 0; i < p->length; ++i) {
plane = &p->m.planes[i];
- dbgarg2("plane %d: bytesused=%d, data_offset=0x%08x "
- "offset/userptr=0x%08lx, length=%d\n",
- i, plane->bytesused, plane->data_offset,
- plane->m.userptr, plane->length);
+ dbgarg2("plane %d: bytesused=%d, app_offset=0x%08x, "
+ " data_offset=0x%08x, offset/userptr=0x%08lx, "
+ " length=%d\n",
+ i, plane->bytesused, plane->app_offset,
+ plane->data_offset, plane->m.userptr,
+ plane->length);
}
} else {
dbgarg2("bytesused=%d, offset/userptr=0x%08lx, length=%d\n",
@@ -575,7 +575,20 @@ struct v4l2_requestbuffers {
* @userptr: when memory is V4L2_MEMORY_USERPTR, a userspace pointer
* pointing to this plane
* @data_offset: offset in the plane to the start of data; usually 0,
- * unless there is a header in front of the data
+ * unless there is a header in front of the data;
+ * memory reserved using this offset can be filled by
+ * userspace (for OUTPUT types) or driver/hardware (for
+ * CAPTURE);
+ * if app_offset != 0, data_offset should be added to it,
+ * i.e. start of data = app_offset + data_offset and
+ * header data (reserved with data_offset) comes AFTER
+ * app-reserved data (app_offset);
+ * @app_offset: offset in the plane to the beginning of memory usable by
+ * the driver/hardware; applications may use this field
+ * to reserve memory at the beginning of the plane for own
+ * use; neither drivers nor hardware should ever write to
+ * the plane before this offset (with the exception of
+ * zeroing on allocation, if performed by kernel);
*
* Multi-planar buffers consist of one or more planes, e.g. an YCbCr buffer
* with two planes can have one plane for Y, and another for interleaved CbCr
@@ -590,7 +603,8 @@ struct v4l2_plane {
unsigned long userptr;
} m;
__u32 data_offset;
- __u32 reserved[11];
+ __u32 app_offset;
+ __u32 reserved[10];
};
/**