Unknown EM2800 video grabber (card=0)

2014-03-01 Thread Jacob Korf
Hi there,

I'm trying this video capture stick from Conceptronic, the Home Video
Creator, but I'm not getting it to work with Linux. I'm using kernel
version 3.13.5 and I'm on Arch Linux. More information and specs here:
http://www.conceptronic.net/product.php?id=322linkid=294.

This is the output from lsusb -v:

Bus 001 Device 005: ID 1d19:6108 Dexatek Technology Ltd.
Couldn't open device, some information will be missing
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   2.00
  bDeviceClass  239 Miscellaneous Device
  bDeviceSubClass 2 ?
  bDeviceProtocol 1 Interface Association
  bMaxPacketSize064
  idVendor   0x1d19 Dexatek Technology Ltd.
  idProduct  0x6108
  bcdDevice   40.01
  iManufacturer   1
  iProduct2
  iSerial 3
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength  248
bNumInterfaces  6
bConfigurationValue 1
iConfiguration  4
bmAttributes 0x80
  (Bus Powered)
MaxPower  500mA
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber0
  bAlternateSetting   0
  bNumEndpoints   2
  bInterfaceClass   255 Vendor Specific Class
  bInterfaceSubClass255 Vendor Specific Subclass
  bInterfaceProtocol255 Vendor Specific Protocol
  iInterface 32
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x8e  EP 14 IN
bmAttributes3
  Transfer TypeInterrupt
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0020  1x 32 bytes
bInterval   4
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x0e  EP 14 OUT
bmAttributes3
  Transfer TypeInterrupt
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0020  1x 32 bytes
bInterval   4
Interface Association:
  bLength 8
  bDescriptorType11
  bFirstInterface 1
  bInterfaceCount 5
  bFunctionClass255 Vendor Specific Class
  bFunctionSubClass 255 Vendor Specific Subclass
  bFunctionProtocol 255 Vendor Specific Protocol
  iFunction   0
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber1
  bAlternateSetting   0
  bNumEndpoints   1
  bInterfaceClass   255 Vendor Specific Class
  bInterfaceSubClass255 Vendor Specific Subclass
  bInterfaceProtocol255 Vendor Specific Protocol
  iInterface  7
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x8f  EP 15 IN
bmAttributes3
  Transfer TypeInterrupt
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0008  1x 8 bytes
bInterval   7
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber2
  bAlternateSetting   0
  bNumEndpoints   1
  bInterfaceClass   255 Vendor Specific Class
  bInterfaceSubClass255 Vendor Specific Subclass
  bInterfaceProtocol255 Vendor Specific Protocol
  iInterface 20
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83  EP 3 IN
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   0
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber2
  bAlternateSetting   1
  bNumEndpoints   1
  bInterfaceClass   255 Vendor Specific Class
  bInterfaceSubClass255 Vendor Specific Subclass
  bInterfaceProtocol255 Vendor Specific Protocol
  iInterface 21
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83  EP 3 IN
bmAttributes5
  Transfer TypeIsochronous
  Synch Type   Asynchronous
  Usage Type   Data
wMaxPacketSize 0x001c  1x 28 bytes
bInterval   1

Re: [PATCH 0/3] media/drx39xyj: fix DJH_DEBUG path null pointer dereferences, and compile errors.

2014-03-01 Thread Mauro Carvalho Chehab
Hi Devin,

Em Fri, 28 Feb 2014 19:13:16 -0500
Devin Heitmueller dheitmuel...@kernellabs.com escreveu:

 Seems kind of strange that I wasn't on the CC for this, since I was the
 original author of all that code (in fact, DJH are my initials).
 
 Mauro, did you strip off my authorship when you pulled the patches from my
 tree?

Thanks for warning me about that!

Not sure what happened there. The original branch were added back in 2012,
with the sole reason to provide a way for Patrick Dickey to catch a few
patches I made on that time with some CodingStyle fixes:

http://git.linuxtv.org/mchehab/experimental.git/shortlog/refs/heads/drx-j

There, your name was there as an extra weird Committer tag on those 
changesets:

http://git.linuxtv.org/mchehab/experimental.git/commit/24d5ed7b19cc19f807264d7d4d56ab48e5cab230

http://git.linuxtv.org/mchehab/experimental.git/commit/0440897f72b9cf82b8f576fae292b0567ad88239

The second one also contained a Tag: tip on it. So, I suspect that
something wrong happened when I imported it (either from your tree or
from some email sent by you or by Patrick). Probably, some broken
hg-import scripting.

Anyway, I rebased my tree, fixing those issues, at:

http://git.linuxtv.org/mchehab/experimental.git/shortlog/refs/heads/drx-j-v3

I also added a credit at the first patch for Patrick's fixes that
I suspect it was merged somehow there, based on the comments he
posted at the mailing list when he sent his 25-patches series:
https://lwn.net/Articles/467301/

Please let me know if you find any other issues on it. Anyway, I'll post
the patches from my experimental branch at the ML before merging them
upstream, in order to get a proper review.

Before that happen, however, I need to fix a serious bug that is
preventing to watch TV with this frontend, that it is there since the
first patch.

To be sure that this is a driver issue, I tested the driver on
another OS using the original PCTV driver, and it worked.

However, since the first working version of this driver, it
is randomly losing MPEG TS packets.

The bug is intermittent: every time it sets up VSB reception, it loses
different MPEG TS tables. Sometimes, not a single TS packet is received,
but, most of the time, it gets ~ 1/10 of the expected number of packets.

It behaves like letting a hardware PID filtering on some random state,
inspecting the traffic using dvbv5-zap at monitor mode shows just a
small set of the MPEG TS PIDs,  but I'm starting to suspect that it
could be due to something else, like an improper ISOC setting at em28xx
or due to some clock initialized with the wrong value.

I'm even tried to compare what's the original driver is doing with the
Linux one, but the original driver provided by PCTV was compiled using a
different firmware version, so it uses a different drxj_map.h.

I would need to get in hands the drxj_map.h used by PCTV, in order to be
able to properly see what initialization is being done by the PCTV driver
and see what sequence is missing.

I won't be merging this driver upstream while this bug is not fixed.

It would help a lot if I could get the original tree you worked with, as
maybe this bug might not be present there. In such case, then the bug is
likely at em28xx side.

Do you still have a copy of your old hg tree? Do you have some contact at
PCTV that could help me either getting a binary driver using the same
version as the one you used here, or getting me the newer drxj_map.h
file?

Thanks,
Mauro

 
 The patches themselves look sane, and I will send a formal Acked-by once I
 can get in front of a real computer.
 
 Devin
 On Feb 28, 2014 4:23 PM, Shuah Khan shuah...@samsung.com wrote:
 
  This patch series fixes null pointer dereference boot failure as well as
  compile errors.
 
  Shuah Khan (3):
media/drx39xyj: fix pr_dbg undefined compile errors when DJH_DEBUG is
  defined
media/drx39xyj: remove return that prevents DJH_DEBUG code to run
media/drx39xyj: fix boot failure due to null pointer dereference
 
   drivers/media/dvb-frontends/drx39xyj/drxj.c | 31
  ++---
   1 file changed, 19 insertions(+), 12 deletions(-)
 
  --
  1.8.3.2
 
  --
  To unsubscribe from this list: send the line unsubscribe linux-media in
  the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
 


-- 

Cheers,
Mauro
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 00/10] Fix buffer timestamp documentation, add new timestamp flags

2014-03-01 Thread Sakari Ailus
Hi all,

This is the 6th and hopefully the final version of the set.

What has changed since v5.2:
- Got a patch from Hans to fix timestamp issues in vb2 (1st one). That's
  unchanged.
- Renamed the vb2_queue.timestamp_type field as timestamp_flags (patch 4).
- Add a note that on mem-to-mem devices the timestamp source may vary from
  buffer to buffer (patch 10).
- Copy timestamp source from source buffers to destination (patch 6).

Testing has been done on uvc and mem2mem_testdev.

Unless something serious is found I'll send a pull request tomorrow.

-- 
Kind regards,
Sakari


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATH v6 06/10] v4l: Handle buffer timestamp flags correctly

2014-03-01 Thread Sakari Ailus
For COPY timestamps, buffer timestamp source flags will traverse the queue
untouched.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 drivers/media/v4l2-core/videobuf2-core.c |   26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 3dda083..7afeb6b 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -488,7 +488,22 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
struct v4l2_buffer *b)
 * Clear any buffer state related flags.
 */
b-flags = ~V4L2_BUFFER_MASK_FLAGS;
-   b-flags |= q-timestamp_flags;
+   if ((q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
+   V4L2_BUF_FLAG_TIMESTAMP_COPY) {
+   /*
+* For COPY timestamps, we just set the timestamp type
+* here. The timestamp source is already in b-flags.
+*/
+   b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK;
+   } else {
+   /*
+* For non-COPY timestamps, drop timestamp source and
+* obtain the timestamp type and source from the
+* queue.
+*/
+   b-flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+   b-flags |= q-timestamp_flags;
+   }
 
switch (vb-state) {
case VB2_BUF_STATE_QUEUED:
@@ -1031,6 +1046,15 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
 
/* Zero flags that the vb2 core handles */
vb-v4l2_buf.flags = b-flags  ~V4L2_BUFFER_MASK_FLAGS;
+   if ((vb-vb2_queue-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
+   V4L2_BUF_FLAG_TIMESTAMP_COPY) {
+   /*
+* Non-COPY timestamps will get their timestamp and
+* timestamp source flags from the queue.
+*/
+   vb-v4l2_buf.flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+   }
+
if (V4L2_TYPE_IS_OUTPUT(b-type)) {
/*
 * For output buffers mask out the timecode flag:
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATH v6 01/10] vb2: fix timecode and flags handling for output buffers

2014-03-01 Thread Sakari Ailus
From: Hans Verkuil hans.verk...@cisco.com

When sending a buffer to a video output device some of the fields need
to be copied so they arrive in the driver. These are the KEY/P/BFRAME
flags and the TIMECODE flag, and, if that flag is set, the timecode field
itself.

There are a number of functions involved in this: the __fill_vb2_buffer()
is called while preparing a buffer. For output buffers the buffer contains
the video data, so any meta data associated with that (KEY/P/BFRAME and
the field information) should be stored at that point.

The timecode, timecode flag and timestamp information is not part of that,
that information will have to be set when vb2_internal_qbuf() is called to
actually queue the buffer to the driver. Usually VIDIOC_QBUF will do the
prepare as well, but you can call PREPARE_BUF first and only later VIDIOC_QBUF.
You most likely will want to set the timestamp and timecode when you actually
queue the buffer, not when you prepare it.

Finally, in buf_prepare() make sure the timestamp and sequence fields are
actually cleared so that when you do a QUERYBUF of a prepared-but-not-yet-queued
buffer you will not see stale timestamp/sequence data.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 drivers/media/v4l2-core/videobuf2-core.c |   35 --
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 5a5fb7f..edab3af 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -40,10 +40,14 @@ module_param(debug, int, 0644);
 #define call_qop(q, op, args...)   \
(((q)-ops-op) ? ((q)-ops-op(args)) : 0)
 
+/* Flags that are set by the vb2 core */
 #define V4L2_BUFFER_MASK_FLAGS (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \
 V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_ERROR | \
 V4L2_BUF_FLAG_PREPARED | \
 V4L2_BUF_FLAG_TIMESTAMP_MASK)
+/* Output buffer flags that should be passed on to the driver */
+#define V4L2_BUFFER_OUT_FLAGS  (V4L2_BUF_FLAG_PFRAME | V4L2_BUF_FLAG_BFRAME | \
+V4L2_BUF_FLAG_KEYFRAME | 
V4L2_BUF_FLAG_TIMECODE)
 
 /**
  * __vb2_buf_mem_alloc() - allocate video memory for the given buffer
@@ -1025,9 +1029,21 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
 
}
 
-   vb-v4l2_buf.field = b-field;
-   vb-v4l2_buf.timestamp = b-timestamp;
+   /* Zero flags that the vb2 core handles */
vb-v4l2_buf.flags = b-flags  ~V4L2_BUFFER_MASK_FLAGS;
+   if (V4L2_TYPE_IS_OUTPUT(b-type)) {
+   /*
+* For output buffers mask out the timecode flag:
+* this will be handled later in vb2_internal_qbuf().
+* The 'field' is valid metadata for this output buffer
+* and so that needs to be copied here.
+*/
+   vb-v4l2_buf.flags = ~V4L2_BUF_FLAG_TIMECODE;
+   vb-v4l2_buf.field = b-field;
+   } else {
+   /* Zero any output buffer flags as this is a capture buffer */
+   vb-v4l2_buf.flags = ~V4L2_BUFFER_OUT_FLAGS;
+   }
 }
 
 /**
@@ -1261,6 +1277,10 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
}
 
vb-state = VB2_BUF_STATE_PREPARING;
+   vb-v4l2_buf.timestamp.tv_sec = 0;
+   vb-v4l2_buf.timestamp.tv_usec = 0;
+   vb-v4l2_buf.sequence = 0;
+
switch (q-memory) {
case V4L2_MEMORY_MMAP:
ret = __qbuf_mmap(vb, b);
@@ -1448,6 +1468,17 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct 
v4l2_buffer *b)
 */
list_add_tail(vb-queued_entry, q-queued_list);
vb-state = VB2_BUF_STATE_QUEUED;
+   if (V4L2_TYPE_IS_OUTPUT(q-type)) {
+   /*
+* For output buffers copy the timestamp if needed,
+* and the timecode field and flag if needed.
+*/
+   if (q-timestamp_type == V4L2_BUF_FLAG_TIMESTAMP_COPY)
+   vb-v4l2_buf.timestamp = b-timestamp;
+   vb-v4l2_buf.flags |= b-flags  V4L2_BUF_FLAG_TIMECODE;
+   if (b-flags  V4L2_BUF_FLAG_TIMECODE)
+   vb-v4l2_buf.timecode = b-timecode;
+   }
 
/*
 * If already streaming, give the buffer to driver for processing.
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATH v6 04/10] v4l: Rename vb2_queue.timestamp_type as timestamp_flags

2014-03-01 Thread Sakari Ailus
The timestamp_type field used to contain only the timestamp type. Soon it
will be used for timestamp source flags as well. Rename the field
accordingly.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 drivers/media/parport/bw-qcam.c  |2 +-
 drivers/media/platform/blackfin/bfin_capture.c   |2 +-
 drivers/media/platform/coda.c|4 ++--
 drivers/media/platform/davinci/vpbe_display.c|2 +-
 drivers/media/platform/davinci/vpif_capture.c|2 +-
 drivers/media/platform/davinci/vpif_display.c|2 +-
 drivers/media/platform/exynos-gsc/gsc-m2m.c  |4 ++--
 drivers/media/platform/exynos4-is/fimc-capture.c |2 +-
 drivers/media/platform/exynos4-is/fimc-lite.c|2 +-
 drivers/media/platform/exynos4-is/fimc-m2m.c |4 ++--
 drivers/media/platform/m2m-deinterlace.c |4 ++--
 drivers/media/platform/mem2mem_testdev.c |4 ++--
 drivers/media/platform/mx2_emmaprp.c |4 ++--
 drivers/media/platform/s3c-camif/camif-capture.c |2 +-
 drivers/media/platform/s5p-g2d/g2d.c |4 ++--
 drivers/media/platform/s5p-jpeg/jpeg-core.c  |4 ++--
 drivers/media/platform/s5p-mfc/s5p_mfc.c |4 ++--
 drivers/media/platform/soc_camera/atmel-isi.c|2 +-
 drivers/media/platform/soc_camera/mx2_camera.c   |2 +-
 drivers/media/platform/soc_camera/mx3_camera.c   |2 +-
 drivers/media/platform/soc_camera/rcar_vin.c |2 +-
 drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c |2 +-
 drivers/media/platform/ti-vpe/vpe.c  |4 ++--
 drivers/media/platform/vivi.c|2 +-
 drivers/media/platform/vsp1/vsp1_video.c |2 +-
 drivers/media/usb/em28xx/em28xx-video.c  |4 ++--
 drivers/media/usb/pwc/pwc-if.c   |2 +-
 drivers/media/usb/stk1160/stk1160-v4l.c  |2 +-
 drivers/media/usb/usbtv/usbtv-video.c|2 +-
 drivers/media/usb/uvc/uvc_queue.c|2 +-
 drivers/media/v4l2-core/videobuf2-core.c |8 
 include/media/videobuf2-core.h   |2 +-
 32 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/drivers/media/parport/bw-qcam.c b/drivers/media/parport/bw-qcam.c
index d12bd33..a0a6ee6 100644
--- a/drivers/media/parport/bw-qcam.c
+++ b/drivers/media/parport/bw-qcam.c
@@ -965,7 +965,7 @@ static struct qcam *qcam_init(struct parport *port)
q-drv_priv = qcam;
q-ops = qcam_video_qops;
q-mem_ops = vb2_vmalloc_memops;
-   q-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+   q-timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
err = vb2_queue_init(q);
if (err  0) {
v4l2_err(v4l2_dev, couldn't init vb2_queue for %s.\n, 
port-name);
diff --git a/drivers/media/platform/blackfin/bfin_capture.c 
b/drivers/media/platform/blackfin/bfin_capture.c
index 2819165..200bec9 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -997,7 +997,7 @@ static int bcap_probe(struct platform_device *pdev)
q-buf_struct_size = sizeof(struct bcap_buffer);
q-ops = bcap_video_qops;
q-mem_ops = vb2_dma_contig_memops;
-   q-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+   q-timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
ret = vb2_queue_init(q);
if (ret)
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 61f3dbc..81b6f7b 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -2428,7 +2428,7 @@ static int coda_queue_init(void *priv, struct vb2_queue 
*src_vq,
src_vq-buf_struct_size = sizeof(struct v4l2_m2m_buffer);
src_vq-ops = coda_qops;
src_vq-mem_ops = vb2_dma_contig_memops;
-   src_vq-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+   src_vq-timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
 
ret = vb2_queue_init(src_vq);
if (ret)
@@ -2440,7 +2440,7 @@ static int coda_queue_init(void *priv, struct vb2_queue 
*src_vq,
dst_vq-buf_struct_size = sizeof(struct v4l2_m2m_buffer);
dst_vq-ops = coda_qops;
dst_vq-mem_ops = vb2_dma_contig_memops;
-   dst_vq-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
+   dst_vq-timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
 
return vb2_queue_init(dst_vq);
 }
diff --git a/drivers/media/platform/davinci/vpbe_display.c 
b/drivers/media/platform/davinci/vpbe_display.c
index b02aba4..e512767 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -1415,7 +1415,7 @@ static int 

[PATH v6 10/10] v4l: Document timestamp buffer flag behaviour

2014-03-01 Thread Sakari Ailus
Timestamp buffer flags are constant at the moment. Document them so that 1)
they're always valid and 2) not changed by the drivers. This leaves room to
extend the functionality later on if needed.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 Documentation/DocBook/media/v4l/io.xml |   14 ++
 1 file changed, 14 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index d44401c..1bffb1c 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -653,6 +653,20 @@ plane, are stored in struct 
structnamev4l2_plane/structname instead.
 In that case, struct structnamev4l2_buffer/structname contains an array of
 plane structures./para
 
+paraDequeued video buffers come with timestamps. The driver
+decides at which part of the frame and with which clock the
+timestamp is taken. Please see flags in the masks
+constantV4L2_BUF_FLAG_TIMESTAMP_MASK/constant and
+constantV4L2_BUF_FLAG_TSTAMP_SRC_MASK/constant in xref
+linkend=buffer-flags. These flags are always valid and constant
+across all buffers during the whole video stream. Changes in these
+flags may take place as a side effect of VIDIOC-S-INPUT; or
+VIDIOC-S-OUTPUT; however. The
+constantV4L2_BUF_FLAG_TIMESTAMP_COPY/constant timestamp type
+which is used by e.g. on mem-to-mem devices is an exception to the
+rule: the timestamp source flags are copied from the OUTPUT video
+buffer to the CAPTURE video buffer./para
+
 table frame=none pgwide=1 id=v4l2-buffer
   titlestruct structnamev4l2_buffer/structname/title
   tgroup cols=4
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATH v6 08/10] exynos-gsc, m2m-deinterlace, mx2_emmaprp: Copy v4l2_buffer data from src to dst

2014-03-01 Thread Sakari Ailus
The timestamp and timecode fields were copied from destination to source,
not the other way around as they should. Fix it.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
Acked-by: Kamil Debski k.deb...@samsung.com
---
 drivers/media/platform/exynos-gsc/gsc-m2m.c |4 ++--
 drivers/media/platform/m2m-deinterlace.c|4 ++--
 drivers/media/platform/mx2_emmaprp.c|4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 6741025..3a842ee 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -88,8 +88,8 @@ void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
dst_vb = v4l2_m2m_dst_buf_remove(ctx-m2m_ctx);
 
if (src_vb  dst_vb) {
-   src_vb-v4l2_buf.timestamp = dst_vb-v4l2_buf.timestamp;
-   src_vb-v4l2_buf.timecode = dst_vb-v4l2_buf.timecode;
+   dst_vb-v4l2_buf.timestamp = src_vb-v4l2_buf.timestamp;
+   dst_vb-v4l2_buf.timecode = src_vb-v4l2_buf.timecode;
 
v4l2_m2m_buf_done(src_vb, vb_state);
v4l2_m2m_buf_done(dst_vb, vb_state);
diff --git a/drivers/media/platform/m2m-deinterlace.c 
b/drivers/media/platform/m2m-deinterlace.c
index f3a9e24..3416131 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -207,8 +207,8 @@ static void dma_callback(void *data)
src_vb = v4l2_m2m_src_buf_remove(curr_ctx-m2m_ctx);
dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx-m2m_ctx);
 
-   src_vb-v4l2_buf.timestamp = dst_vb-v4l2_buf.timestamp;
-   src_vb-v4l2_buf.timecode = dst_vb-v4l2_buf.timecode;
+   dst_vb-v4l2_buf.timestamp = src_vb-v4l2_buf.timestamp;
+   dst_vb-v4l2_buf.timecode = src_vb-v4l2_buf.timecode;
 
v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE);
v4l2_m2m_buf_done(dst_vb, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/mx2_emmaprp.c 
b/drivers/media/platform/mx2_emmaprp.c
index af3e106..6debb02 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -377,8 +377,8 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
src_vb = v4l2_m2m_src_buf_remove(curr_ctx-m2m_ctx);
dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx-m2m_ctx);
 
-   src_vb-v4l2_buf.timestamp = dst_vb-v4l2_buf.timestamp;
-   src_vb-v4l2_buf.timecode = dst_vb-v4l2_buf.timecode;
+   dst_vb-v4l2_buf.timestamp = src_vb-v4l2_buf.timestamp;
+   dst_vb-v4l2_buf.timecode = src_vb-v4l2_buf.timecode;
 
spin_lock_irqsave(pcdev-irqlock, flags);
v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATH v6 02/10] v4l: Document timestamp behaviour to correspond to reality

2014-03-01 Thread Sakari Ailus
Document that monotonic timestamps are taken after the corresponding frame
has been received, not when the reception has begun. This corresponds to the
reality of current drivers: the timestamp is naturally taken when the
hardware triggers an interrupt to tell the driver to handle the received
frame.

Remove the note on timestamp accuracy as it is fairly subjective what is
actually an unstable timestamp.

Also remove explanation that output buffer timestamps can be used to delay
outputting a frame.

Remove the footnote saying we always use realtime clock.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/io.xml |   56 +++-
 1 file changed, 12 insertions(+), 44 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index 2c4c068..8facac4 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -339,8 +339,8 @@ returns immediately with an EAGAIN; when no buffer is 
available. The
 queues as a side effect. Since there is no notion of doing anything
 now on a multitasking system, if an application needs to synchronize
 with another event it should examine the v4l2-buffer;
-structfieldtimestamp/structfield of captured buffers, or set the
-field before enqueuing buffers for output./para
+structfieldtimestamp/structfield of captured or outputted buffers.
+/para
 
 paraDrivers implementing memory mapping I/O must
 support the constantVIDIOC_REQBUFS/constant,
@@ -457,7 +457,7 @@ queues and unlocks all buffers as a side effect. Since 
there is no
 notion of doing anything now on a multitasking system, if an
 application needs to synchronize with another event it should examine
 the v4l2-buffer; structfieldtimestamp/structfield of captured
-buffers, or set the field before enqueuing buffers for output./para
+or outputted buffers./para
 
 paraDrivers implementing user pointer I/O must
 support the constantVIDIOC_REQBUFS/constant,
@@ -620,8 +620,7 @@ returns immediately with an EAGAIN; when no buffer is 
available. The
 unlocks all buffers as a side effect. Since there is no notion of doing
 anything now on a multitasking system, if an application needs to synchronize
 with another event it should examine the v4l2-buffer;
-structfieldtimestamp/structfield of captured buffers, or set the field
-before enqueuing buffers for output./para
+structfieldtimestamp/structfield of captured or outputted buffers./para
 
 paraDrivers implementing DMABUF importing I/O must support the
 constantVIDIOC_REQBUFS/constant, constantVIDIOC_QBUF/constant,
@@ -654,38 +653,11 @@ plane, are stored in struct 
structnamev4l2_plane/structname instead.
 In that case, struct structnamev4l2_buffer/structname contains an array of
 plane structures./para
 
-  paraNominally timestamps refer to the first data byte transmitted.
-In practice however the wide range of hardware covered by the V4L2 API
-limits timestamp accuracy. Often an interrupt routine will
-sample the system clock shortly after the field or frame was stored
-completely in memory. So applications must expect a constant
-difference up to one field or frame period plus a small (few scan
-lines) random error. The delay and error can be much
-larger due to compression or transmission over an external bus when
-the frames are not properly stamped by the sender. This is frequently
-the case with USB cameras. Here timestamps refer to the instant the
-field or frame was received by the driver, not the capture time. These
-devices identify by not enumerating any video standards, see xref
-linkend=standard /./para
-
-  paraSimilar limitations apply to output timestamps. Typically
-the video hardware locks to a clock controlling the video timing, the
-horizontal and vertical synchronization pulses. At some point in the
-line sequence, possibly the vertical blanking, an interrupt routine
-samples the system clock, compares against the timestamp and programs
-the hardware to repeat the previous field or frame, or to display the
-buffer contents./para
-
-  paraApart of limitations of the video device and natural
-inaccuracies of all clocks, it should be noted system time itself is
-not perfectly stable. It can be affected by power saving cycles,
-warped to insert leap seconds, or even turned back or forth by the
-system administrator affecting long term measurements. footnote
- paraSince no other Linux multimedia
-API supports unadjusted time it would be foolish to introduce here. We
-must use a universally supported clock to synchronize different media,
-hence time of day./para
-   /footnote/para
+  paraFor timestamp types that are sampled from the system clock
+(V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC) it is guaranteed that the timestamp is
+taken after the complete frame has been received (or transmitted in
+case of video output devices). For other kinds of

[PATH v6 07/10] uvcvideo: Tell the user space we're using start-of-exposure timestamps

2014-03-01 Thread Sakari Ailus
The UVC device provided timestamps are taken from the clock once the
exposure of the frame has begun, not when the reception of the frame would
have been finished as almost anywhere else. Show this to the user space by
using V4L2_BUF_FLAG_TSTAMP_SRC_SOE buffer flag.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/usb/uvc/uvc_queue.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_queue.c 
b/drivers/media/usb/uvc/uvc_queue.c
index 7c14616..935556e 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -151,7 +151,8 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum 
v4l2_buf_type type,
queue-queue.buf_struct_size = sizeof(struct uvc_buffer);
queue-queue.ops = uvc_queue_qops;
queue-queue.mem_ops = vb2_vmalloc_memops;
-   queue-queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+   queue-queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
+   | V4L2_BUF_FLAG_TSTAMP_SRC_SOE;
ret = vb2_queue_init(queue-queue);
if (ret)
return ret;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATH v6 05/10] v4l: Add timestamp source flags, mask and document them

2014-03-01 Thread Sakari Ailus
Some devices do not produce timestamps that correspond to the end of the
frame. The user space should be informed on the matter. This patch achieves
that by adding buffer flags (and a mask) for timestamp sources since more
possible timestamping points are expected than just two.

A three-bit mask is defined (V4L2_BUF_FLAG_TSTAMP_SRC_MASK) and two of the
eight possible values is are defined V4L2_BUF_FLAG_TSTAMP_SRC_EOF for end of
frame (value zero) V4L2_BUF_FLAG_TSTAMP_SRC_SOE for start of exposure (next
value).

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
Acked-by: Kamil Debski k.deb...@samsung.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/io.xml   |   36 +-
 drivers/media/v4l2-core/videobuf2-core.c |4 +++-
 include/media/videobuf2-core.h   |2 ++
 include/uapi/linux/videodev2.h   |4 
 4 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index 46d24b3..d44401c 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -653,12 +653,6 @@ plane, are stored in struct 
structnamev4l2_plane/structname instead.
 In that case, struct structnamev4l2_buffer/structname contains an array of
 plane structures./para
 
-  paraFor timestamp types that are sampled from the system clock
-(V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC) it is guaranteed that the timestamp is
-taken after the complete frame has been received (or transmitted in
-case of video output devices). For other kinds of
-timestamps this may vary depending on the driver./para
-
 table frame=none pgwide=1 id=v4l2-buffer
   titlestruct structnamev4l2_buffer/structname/title
   tgroup cols=4
@@ -1119,6 +1113,36 @@ in which case caches have not been used./entry
entryThe CAPTURE buffer timestamp has been taken from the
corresponding OUTPUT buffer. This flag applies only to mem2mem 
devices./entry
  /row
+ row
+   entryconstantV4L2_BUF_FLAG_TSTAMP_SRC_MASK/constant/entry
+   entry0x0007/entry
+   entryMask for timestamp sources below. The timestamp source
+   defines the point of time the timestamp is taken in relation to
+   the frame. Logical and operation between the
+   structfieldflags/structfield field and
+   constantV4L2_BUF_FLAG_TSTAMP_SRC_MASK/constant produces the
+   value of the timestamp source./entry
+ /row
+ row
+   entryconstantV4L2_BUF_FLAG_TSTAMP_SRC_EOF/constant/entry
+   entry0x/entry
+   entryEnd Of Frame. The buffer timestamp has been taken
+   when the last pixel of the frame has been received or the
+   last pixel of the frame has been transmitted. In practice,
+   software generated timestamps will typically be read from
+   the clock a small amount of time after the last pixel has
+   been received or transmitten, depending on the system and
+   other activity in it./entry
+ /row
+ row
+   entryconstantV4L2_BUF_FLAG_TSTAMP_SRC_SOE/constant/entry
+   entry0x0001/entry
+   entryStart Of Exposure. The buffer timestamp has been
+   taken when the exposure of the frame has begun. This is
+   only valid for the
+   constantV4L2_BUF_TYPE_VIDEO_CAPTURE/constant buffer
+   type./entry
+ /row
/tbody
   /tgroup
 /table
diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 411429c..3dda083 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2226,7 +2226,9 @@ int vb2_queue_init(struct vb2_queue *q)
WARN_ON(!q-io_modes) ||
WARN_ON(!q-ops-queue_setup) ||
WARN_ON(!q-ops-buf_queue)   ||
-   WARN_ON(q-timestamp_flags  ~V4L2_BUF_FLAG_TIMESTAMP_MASK))
+   WARN_ON(q-timestamp_flags 
+   ~(V4L2_BUF_FLAG_TIMESTAMP_MASK |
+ V4L2_BUF_FLAG_TSTAMP_SRC_MASK)))
return -EINVAL;
 
/* Warn that the driver should choose an appropriate timestamp type */
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 3770be6..bf6859e 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -312,6 +312,8 @@ struct v4l2_fh;
  * @buf_struct_size: size of the driver-specific buffer structure;
  * 0 indicates the driver doesn't want to use a custom buffer
  * structure type, so sizeof(struct vb2_buffer) will is used
+ * @timestamp_flags: Timestamp flags; V4L2_BUF_FLAGS_TIMESTAMP_* and
+ * V4L2_BUF_FLAGS_TSTAMP_SRC_*
  * @gfp_flags: additional gfp flags used when allocating the buffers.
  * Typically this is 0, but it may be 

[PATH v6 03/10] v4l: Use full 32 bits for buffer flags

2014-03-01 Thread Sakari Ailus
The buffer flags field is 32 bits but the defined only used 16. This is
fine, but as more than 16 bits will be used in the very near future, define
them as 32-bit numbers for consistency.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/io.xml |   30 -
 include/uapi/linux/videodev2.h |   38 +++-
 2 files changed, 38 insertions(+), 30 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index 8facac4..46d24b3 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -984,7 +984,7 @@ should set this to 0./entry
tbody valign=top
  row
entryconstantV4L2_BUF_FLAG_MAPPED/constant/entry
-   entry0x0001/entry
+   entry0x0001/entry
entryThe buffer resides in device memory and has been mapped
 into the application's address space, see xref linkend=mmap / for details.
 Drivers set or clear this flag when the
@@ -994,7 +994,7 @@ Drivers set or clear this flag when the
  /row
  row
entryconstantV4L2_BUF_FLAG_QUEUED/constant/entry
-   entry0x0002/entry
+   entry0x0002/entry
  entryInternally drivers maintain two buffer queues, an
 incoming and outgoing queue. When this flag is set, the buffer is
 currently on the incoming queue. It automatically moves to the
@@ -1007,7 +1007,7 @@ cleared./entry
  /row
  row
entryconstantV4L2_BUF_FLAG_DONE/constant/entry
-   entry0x0004/entry
+   entry0x0004/entry
entryWhen this flag is set, the buffer is currently on
 the outgoing queue, ready to be dequeued from the driver. Drivers set
 or clear this flag when the constantVIDIOC_QUERYBUF/constant ioctl
@@ -1021,7 +1021,7 @@ state, in the application domain to say so./entry
  /row
  row
entryconstantV4L2_BUF_FLAG_ERROR/constant/entry
-   entry0x0040/entry
+   entry0x0040/entry
entryWhen this flag is set, the buffer has been dequeued
successfully, although the data might have been corrupted.
This is recoverable, streaming may continue as normal and
@@ -1031,7 +1031,7 @@ state, in the application domain to say so./entry
  /row
  row
entryconstantV4L2_BUF_FLAG_KEYFRAME/constant/entry
-   entry0x0008/entry
+   entry0x0008/entry
  entryDrivers set or clear this flag when calling the
 constantVIDIOC_DQBUF/constant ioctl. It may be set by video
 capture devices when the buffer contains a compressed image which is a
@@ -1039,27 +1039,27 @@ key frame (or field), ie; can be decompressed on its 
own./entry
  /row
  row
entryconstantV4L2_BUF_FLAG_PFRAME/constant/entry
-   entry0x0010/entry
+   entry0x0010/entry
entrySimilar to constantV4L2_BUF_FLAG_KEYFRAME/constant
 this flags predicted frames or fields which contain only differences to a
 previous key frame./entry
  /row
  row
entryconstantV4L2_BUF_FLAG_BFRAME/constant/entry
-   entry0x0020/entry
+   entry0x0020/entry
entrySimilar to constantV4L2_BUF_FLAG_PFRAME/constant
this is a bidirectional predicted frame or field. [ooc tbd]/entry
  /row
  row
entryconstantV4L2_BUF_FLAG_TIMECODE/constant/entry
-   entry0x0100/entry
+   entry0x0100/entry
entryThe structfieldtimecode/structfield field is valid.
 Drivers set or clear this flag when the constantVIDIOC_DQBUF/constant
 ioctl is called./entry
  /row
  row
entryconstantV4L2_BUF_FLAG_PREPARED/constant/entry
-   entry0x0400/entry
+   entry0x0400/entry
entryThe buffer has been prepared for I/O and can be queued by the
 application. Drivers set or clear this flag when the
 link linkend=vidioc-querybufVIDIOC_QUERYBUF/link, link
@@ -1069,7 +1069,7 @@ application. Drivers set or clear this flag when the
  /row
  row

entryconstantV4L2_BUF_FLAG_NO_CACHE_INVALIDATE/constant/entry
-   entry0x0800/entry
+   entry0x0800/entry
entryCaches do not have to be invalidated for this buffer.
 Typically applications shall use this flag if the data captured in the buffer
 is not going to be touched by the CPU, instead the buffer will, probably, be
@@ -1078,7 +1078,7 @@ passed on to a DMA-capable hardware unit for further 
processing or output.
  /row
  row
entryconstantV4L2_BUF_FLAG_NO_CACHE_CLEAN/constant/entry
-   entry0x1000/entry
+   entry0x1000/entry
entryCaches do not have to be cleaned for this buffer.
 Typically applications shall use this flag for output 

[PATH v6 09/10] v4l: Copy timestamp source flags to destination on m2m devices

2014-03-01 Thread Sakari Ailus
Copy the flags containing the timestamp source from source buffer flags to
the destination buffer flags on memory-to-memory devices. This is analogous
to copying the timestamp field from source to destination.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
Acked-by: Kamil Debski k.deb...@samsung.com
---
 drivers/media/platform/coda.c|3 +++
 drivers/media/platform/exynos-gsc/gsc-m2m.c  |4 
 drivers/media/platform/exynos4-is/fimc-m2m.c |3 +++
 drivers/media/platform/m2m-deinterlace.c |3 +++
 drivers/media/platform/mem2mem_testdev.c |3 +++
 drivers/media/platform/mx2_emmaprp.c |5 +
 drivers/media/platform/s5p-g2d/g2d.c |3 +++
 drivers/media/platform/s5p-jpeg/jpeg-core.c  |3 +++
 drivers/media/platform/s5p-mfc/s5p_mfc.c |5 +
 drivers/media/platform/ti-vpe/vpe.c  |2 ++
 10 files changed, 34 insertions(+)

diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 81b6f7b..3e5199e 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -2829,6 +2829,9 @@ static void coda_finish_encode(struct coda_ctx *ctx)
}
 
dst_buf-v4l2_buf.timestamp = src_buf-v4l2_buf.timestamp;
+   dst_buf-v4l2_buf.flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+   dst_buf-v4l2_buf.flags |=
+   src_buf-v4l2_buf.flags  V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
dst_buf-v4l2_buf.timecode = src_buf-v4l2_buf.timecode;
 
v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 3a842ee..d0ea94f 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -90,6 +90,10 @@ void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
if (src_vb  dst_vb) {
dst_vb-v4l2_buf.timestamp = src_vb-v4l2_buf.timestamp;
dst_vb-v4l2_buf.timecode = src_vb-v4l2_buf.timecode;
+   dst_vb-v4l2_buf.flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+   dst_vb-v4l2_buf.flags |=
+   src_vb-v4l2_buf.flags
+V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 
v4l2_m2m_buf_done(src_vb, vb_state);
v4l2_m2m_buf_done(dst_vb, vb_state);
diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c 
b/drivers/media/platform/exynos4-is/fimc-m2m.c
index bfc900d..36971d9 100644
--- a/drivers/media/platform/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
@@ -134,6 +134,9 @@ static void fimc_device_run(void *priv)
goto dma_unlock;
 
dst_vb-v4l2_buf.timestamp = src_vb-v4l2_buf.timestamp;
+   dst_vb-v4l2_buf.flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+   dst_vb-v4l2_buf.flags |=
+   src_vb-v4l2_buf.flags  V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 
/* Reconfigure hardware if the context has changed. */
if (fimc-m2m.ctx != ctx) {
diff --git a/drivers/media/platform/m2m-deinterlace.c 
b/drivers/media/platform/m2m-deinterlace.c
index 3416131..c21d14f 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -208,6 +208,9 @@ static void dma_callback(void *data)
dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx-m2m_ctx);
 
dst_vb-v4l2_buf.timestamp = src_vb-v4l2_buf.timestamp;
+   dst_vb-v4l2_buf.flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+   dst_vb-v4l2_buf.flags |=
+   src_vb-v4l2_buf.flags  V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
dst_vb-v4l2_buf.timecode = src_vb-v4l2_buf.timecode;
 
v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/mem2mem_testdev.c 
b/drivers/media/platform/mem2mem_testdev.c
index 02a40c5..4bb5e88 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -239,6 +239,9 @@ static int device_process(struct m2mtest_ctx *ctx,
memcpy(out_vb-v4l2_buf.timestamp,
in_vb-v4l2_buf.timestamp,
sizeof(struct timeval));
+   out_vb-v4l2_buf.flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+   out_vb-v4l2_buf.flags |=
+   in_vb-v4l2_buf.flags  V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 
switch (ctx-mode) {
case MEM2MEM_HFLIP | MEM2MEM_VFLIP:
diff --git a/drivers/media/platform/mx2_emmaprp.c 
b/drivers/media/platform/mx2_emmaprp.c
index 6debb02..0b7480e 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -378,6 +378,11 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx-m2m_ctx);
 
dst_vb-v4l2_buf.timestamp = src_vb-v4l2_buf.timestamp;
+   dst_vb-v4l2_buf.flags =
+   ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+   dst_vb-v4l2_buf.flags |=
+   

Re: [PATH v6 05/10] v4l: Add timestamp source flags, mask and document them

2014-03-01 Thread Hans Verkuil
Hi Sakari,

Don't worry, it's a very minor change:

On 03/01/2014 02:17 PM, Sakari Ailus wrote:
 Some devices do not produce timestamps that correspond to the end of the
 frame. The user space should be informed on the matter. This patch achieves
 that by adding buffer flags (and a mask) for timestamp sources since more
 possible timestamping points are expected than just two.
 
 A three-bit mask is defined (V4L2_BUF_FLAG_TSTAMP_SRC_MASK) and two of the
 eight possible values is are defined V4L2_BUF_FLAG_TSTAMP_SRC_EOF for end of
 frame (value zero) V4L2_BUF_FLAG_TSTAMP_SRC_SOE for start of exposure (next
 value).
 
 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 Acked-by: Kamil Debski k.deb...@samsung.com
 Acked-by: Hans Verkuil hans.verk...@cisco.com
 ---
  Documentation/DocBook/media/v4l/io.xml   |   36 
 +-
  drivers/media/v4l2-core/videobuf2-core.c |4 +++-
  include/media/videobuf2-core.h   |2 ++
  include/uapi/linux/videodev2.h   |4 
  4 files changed, 39 insertions(+), 7 deletions(-)
 
 diff --git a/Documentation/DocBook/media/v4l/io.xml 
 b/Documentation/DocBook/media/v4l/io.xml
 index 46d24b3..d44401c 100644
 --- a/Documentation/DocBook/media/v4l/io.xml
 +++ b/Documentation/DocBook/media/v4l/io.xml
 @@ -653,12 +653,6 @@ plane, are stored in struct 
 structnamev4l2_plane/structname instead.
  In that case, struct structnamev4l2_buffer/structname contains an array 
 of
  plane structures./para
  
 -  paraFor timestamp types that are sampled from the system clock
 -(V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC) it is guaranteed that the timestamp is
 -taken after the complete frame has been received (or transmitted in
 -case of video output devices). For other kinds of
 -timestamps this may vary depending on the driver./para
 -
  table frame=none pgwide=1 id=v4l2-buffer
titlestruct structnamev4l2_buffer/structname/title
tgroup cols=4
 @@ -1119,6 +1113,36 @@ in which case caches have not been used./entry
   entryThe CAPTURE buffer timestamp has been taken from the
   corresponding OUTPUT buffer. This flag applies only to mem2mem 
 devices./entry
 /row
 +   row
 + entryconstantV4L2_BUF_FLAG_TSTAMP_SRC_MASK/constant/entry
 + entry0x0007/entry
 + entryMask for timestamp sources below. The timestamp source
 + defines the point of time the timestamp is taken in relation to
 + the frame. Logical and operation between the

Rephrase to: A logical 'and' operation

I read it at first more like 'apples and oranges': 'logical and operation'.
It's unambiguous after rephrasing.

Regards,

Hans

 + structfieldflags/structfield field and
 + constantV4L2_BUF_FLAG_TSTAMP_SRC_MASK/constant produces the
 + value of the timestamp source./entry
 +   /row
 +   row
 + entryconstantV4L2_BUF_FLAG_TSTAMP_SRC_EOF/constant/entry
 + entry0x/entry
 + entryEnd Of Frame. The buffer timestamp has been taken
 + when the last pixel of the frame has been received or the
 + last pixel of the frame has been transmitted. In practice,
 + software generated timestamps will typically be read from
 + the clock a small amount of time after the last pixel has
 + been received or transmitten, depending on the system and
 + other activity in it./entry
 +   /row
 +   row
 + entryconstantV4L2_BUF_FLAG_TSTAMP_SRC_SOE/constant/entry
 + entry0x0001/entry
 + entryStart Of Exposure. The buffer timestamp has been
 + taken when the exposure of the frame has begun. This is
 + only valid for the
 + constantV4L2_BUF_TYPE_VIDEO_CAPTURE/constant buffer
 + type./entry
 +   /row
   /tbody
/tgroup
  /table
 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index 411429c..3dda083 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -2226,7 +2226,9 @@ int vb2_queue_init(struct vb2_queue *q)
   WARN_ON(!q-io_modes) ||
   WARN_ON(!q-ops-queue_setup) ||
   WARN_ON(!q-ops-buf_queue)   ||
 - WARN_ON(q-timestamp_flags  ~V4L2_BUF_FLAG_TIMESTAMP_MASK))
 + WARN_ON(q-timestamp_flags 
 + ~(V4L2_BUF_FLAG_TIMESTAMP_MASK |
 +   V4L2_BUF_FLAG_TSTAMP_SRC_MASK)))
   return -EINVAL;
  
   /* Warn that the driver should choose an appropriate timestamp type */
 diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
 index 3770be6..bf6859e 100644
 --- a/include/media/videobuf2-core.h
 +++ b/include/media/videobuf2-core.h
 @@ -312,6 +312,8 @@ struct v4l2_fh;
   * @buf_struct_size: size of the driver-specific buffer structure;
   *   0 indicates the driver doesn't want to use a custom buffer
   *   

Re: [PATH v6 10/10] v4l: Document timestamp buffer flag behaviour

2014-03-01 Thread Hans Verkuil
Acked-by: Hans Verkuil hans.verk...@cisco.com

Regards,

Hans

On 03/01/2014 02:17 PM, Sakari Ailus wrote:
 Timestamp buffer flags are constant at the moment. Document them so that 1)
 they're always valid and 2) not changed by the drivers. This leaves room to
 extend the functionality later on if needed.
 
 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 ---
  Documentation/DocBook/media/v4l/io.xml |   14 ++
  1 file changed, 14 insertions(+)
 
 diff --git a/Documentation/DocBook/media/v4l/io.xml 
 b/Documentation/DocBook/media/v4l/io.xml
 index d44401c..1bffb1c 100644
 --- a/Documentation/DocBook/media/v4l/io.xml
 +++ b/Documentation/DocBook/media/v4l/io.xml
 @@ -653,6 +653,20 @@ plane, are stored in struct 
 structnamev4l2_plane/structname instead.
  In that case, struct structnamev4l2_buffer/structname contains an array 
 of
  plane structures./para
  
 +paraDequeued video buffers come with timestamps. The driver
 +decides at which part of the frame and with which clock the
 +timestamp is taken. Please see flags in the masks
 +constantV4L2_BUF_FLAG_TIMESTAMP_MASK/constant and
 +constantV4L2_BUF_FLAG_TSTAMP_SRC_MASK/constant in xref
 +linkend=buffer-flags. These flags are always valid and constant
 +across all buffers during the whole video stream. Changes in these
 +flags may take place as a side effect of VIDIOC-S-INPUT; or
 +VIDIOC-S-OUTPUT; however. The
 +constantV4L2_BUF_FLAG_TIMESTAMP_COPY/constant timestamp type
 +which is used by e.g. on mem-to-mem devices is an exception to the
 +rule: the timestamp source flags are copied from the OUTPUT video
 +buffer to the CAPTURE video buffer./para
 +
  table frame=none pgwide=1 id=v4l2-buffer
titlestruct structnamev4l2_buffer/structname/title
tgroup cols=4
 
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATH v6 04/10] v4l: Rename vb2_queue.timestamp_type as timestamp_flags

2014-03-01 Thread Hans Verkuil
Acked-by: Hans Verkuil hans.verk...@cisco.com

Regards,

Hans

On 03/01/2014 02:17 PM, Sakari Ailus wrote:
 The timestamp_type field used to contain only the timestamp type. Soon it
 will be used for timestamp source flags as well. Rename the field
 accordingly.
 
 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 ---
  drivers/media/parport/bw-qcam.c  |2 +-
  drivers/media/platform/blackfin/bfin_capture.c   |2 +-
  drivers/media/platform/coda.c|4 ++--
  drivers/media/platform/davinci/vpbe_display.c|2 +-
  drivers/media/platform/davinci/vpif_capture.c|2 +-
  drivers/media/platform/davinci/vpif_display.c|2 +-
  drivers/media/platform/exynos-gsc/gsc-m2m.c  |4 ++--
  drivers/media/platform/exynos4-is/fimc-capture.c |2 +-
  drivers/media/platform/exynos4-is/fimc-lite.c|2 +-
  drivers/media/platform/exynos4-is/fimc-m2m.c |4 ++--
  drivers/media/platform/m2m-deinterlace.c |4 ++--
  drivers/media/platform/mem2mem_testdev.c |4 ++--
  drivers/media/platform/mx2_emmaprp.c |4 ++--
  drivers/media/platform/s3c-camif/camif-capture.c |2 +-
  drivers/media/platform/s5p-g2d/g2d.c |4 ++--
  drivers/media/platform/s5p-jpeg/jpeg-core.c  |4 ++--
  drivers/media/platform/s5p-mfc/s5p_mfc.c |4 ++--
  drivers/media/platform/soc_camera/atmel-isi.c|2 +-
  drivers/media/platform/soc_camera/mx2_camera.c   |2 +-
  drivers/media/platform/soc_camera/mx3_camera.c   |2 +-
  drivers/media/platform/soc_camera/rcar_vin.c |2 +-
  drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c |2 +-
  drivers/media/platform/ti-vpe/vpe.c  |4 ++--
  drivers/media/platform/vivi.c|2 +-
  drivers/media/platform/vsp1/vsp1_video.c |2 +-
  drivers/media/usb/em28xx/em28xx-video.c  |4 ++--
  drivers/media/usb/pwc/pwc-if.c   |2 +-
  drivers/media/usb/stk1160/stk1160-v4l.c  |2 +-
  drivers/media/usb/usbtv/usbtv-video.c|2 +-
  drivers/media/usb/uvc/uvc_queue.c|2 +-
  drivers/media/v4l2-core/videobuf2-core.c |8 
  include/media/videobuf2-core.h   |2 +-
  32 files changed, 46 insertions(+), 46 deletions(-)
 
 diff --git a/drivers/media/parport/bw-qcam.c b/drivers/media/parport/bw-qcam.c
 index d12bd33..a0a6ee6 100644
 --- a/drivers/media/parport/bw-qcam.c
 +++ b/drivers/media/parport/bw-qcam.c
 @@ -965,7 +965,7 @@ static struct qcam *qcam_init(struct parport *port)
   q-drv_priv = qcam;
   q-ops = qcam_video_qops;
   q-mem_ops = vb2_vmalloc_memops;
 - q-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 + q-timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
   err = vb2_queue_init(q);
   if (err  0) {
   v4l2_err(v4l2_dev, couldn't init vb2_queue for %s.\n, 
 port-name);
 diff --git a/drivers/media/platform/blackfin/bfin_capture.c 
 b/drivers/media/platform/blackfin/bfin_capture.c
 index 2819165..200bec9 100644
 --- a/drivers/media/platform/blackfin/bfin_capture.c
 +++ b/drivers/media/platform/blackfin/bfin_capture.c
 @@ -997,7 +997,7 @@ static int bcap_probe(struct platform_device *pdev)
   q-buf_struct_size = sizeof(struct bcap_buffer);
   q-ops = bcap_video_qops;
   q-mem_ops = vb2_dma_contig_memops;
 - q-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 + q-timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
  
   ret = vb2_queue_init(q);
   if (ret)
 diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
 index 61f3dbc..81b6f7b 100644
 --- a/drivers/media/platform/coda.c
 +++ b/drivers/media/platform/coda.c
 @@ -2428,7 +2428,7 @@ static int coda_queue_init(void *priv, struct vb2_queue 
 *src_vq,
   src_vq-buf_struct_size = sizeof(struct v4l2_m2m_buffer);
   src_vq-ops = coda_qops;
   src_vq-mem_ops = vb2_dma_contig_memops;
 - src_vq-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
 + src_vq-timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
  
   ret = vb2_queue_init(src_vq);
   if (ret)
 @@ -2440,7 +2440,7 @@ static int coda_queue_init(void *priv, struct vb2_queue 
 *src_vq,
   dst_vq-buf_struct_size = sizeof(struct v4l2_m2m_buffer);
   dst_vq-ops = coda_qops;
   dst_vq-mem_ops = vb2_dma_contig_memops;
 - dst_vq-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;
 + dst_vq-timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
  
   return vb2_queue_init(dst_vq);
  }
 diff --git a/drivers/media/platform/davinci/vpbe_display.c 
 b/drivers/media/platform/davinci/vpbe_display.c
 index b02aba4..e512767 100644
 

Re: [RFC] [PATCH 4/6] media: em28xx-input - implement em28xx_ops: suspend/resume hooks

2014-03-01 Thread Mauro Carvalho Chehab
Em Fri, 21 Feb 2014 17:50:16 -0700
Shuah Khan shuah...@samsung.com escreveu:

 Implement em28xx_ops: suspend/resume hooks. em28xx usb driver will
 invoke em28xx_ops: suspend and resume hooks for all its extensions
 from its suspend() and resume() interfaces.
 
 Signed-off-by: Shuah Khan shuah...@samsung.com
 ---
  drivers/media/usb/em28xx/em28xx-input.c | 35 
 +
  1 file changed, 35 insertions(+)
 
 diff --git a/drivers/media/usb/em28xx/em28xx-input.c 
 b/drivers/media/usb/em28xx/em28xx-input.c
 index 18f65d8..1227309 100644
 --- a/drivers/media/usb/em28xx/em28xx-input.c
 +++ b/drivers/media/usb/em28xx/em28xx-input.c
 @@ -827,11 +827,46 @@ static int em28xx_ir_fini(struct em28xx *dev)
   return 0;
  }
  
 +static int em28xx_ir_suspend(struct em28xx *dev)
 +{
 + struct em28xx_IR *ir = dev-ir;
 +
 + if (dev-is_audio_only)
 + return 0;
 +
 + em28xx_info(Suspending input extension);
 + cancel_delayed_work_sync(ir-work);
 + cancel_delayed_work_sync(dev-buttons_query_work);
 + /* is canceling delayed work sufficient or does the rc event
 +kthread needs stopping? kthread is stopped in
 +ir_raw_event_unregister() */
 + return 0;
 +}
 +
 +static int em28xx_ir_resume(struct em28xx *dev)
 +{
 + struct em28xx_IR *ir = dev-ir;
 +
 + if (dev-is_audio_only)
 + return 0;
 +
 + em28xx_info(Resuming input extension);
 + /* if suspend calls ir_raw_event_unregister(), the should call
 +ir_raw_event_register() */
 + schedule_delayed_work_sync(ir-work);

This causes a compilation breakage:

drivers/media/usb/em28xx/em28xx-input.c: In function ‘em28xx_ir_resume’:
drivers/media/usb/em28xx/em28xx-input.c:856:2: error: implicit declaration of 
function ‘schedule_delayed_work_sync’ [-Werror=implicit-function-declaration]
  schedule_delayed_work_sync(ir-work);


 + if (dev-num_button_polling_addresses)
 + schedule_delayed_work(dev-buttons_query_work,
 +msecs_to_jiffies(dev-button_polling_interval));
 + return 0;
 +}
 +
  static struct em28xx_ops rc_ops = {
   .id   = EM28XX_RC,
   .name = Em28xx Input Extension,
   .init = em28xx_ir_init,
   .fini = em28xx_ir_fini,
 + .suspend = em28xx_ir_suspend,
 + .resume = em28xx_ir_resume,
  };
  
  static int __init em28xx_rc_register(void)


-- 

Cheers,
Mauro
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch] [media] av7110_hw: fix a sanity check in av7110_fw_cmd()

2014-03-01 Thread Dan Carpenter
ARRAY_SIZE(buf) (8 elements) was intended instead of sizeof(buf) (16
bytes).  But this is just a sanity check and the callers always pass
valid values so this doesn't cause a problem.

Signed-off-by: Dan Carpenter dan.carpen...@oracle.com

diff --git a/drivers/media/pci/ttpci/av7110_hw.c 
b/drivers/media/pci/ttpci/av7110_hw.c
index 6299d5dadb82..300bd3c94738 100644
--- a/drivers/media/pci/ttpci/av7110_hw.c
+++ b/drivers/media/pci/ttpci/av7110_hw.c
@@ -501,7 +501,7 @@ int av7110_fw_cmd(struct av7110 *av7110, int type, int com, 
int num, ...)
 
 // dprintk(4, %p\n, av7110);
 
-   if (2 + num  sizeof(buf)) {
+   if (2 + num  ARRAY_SIZE(buf)) {
printk(KERN_WARNING
   %s: %s len=%d is too big!\n,
   KBUILD_MODNAME, __func__, num);
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch] [media] ddbridge: remove unneeded an NULL check

2014-03-01 Thread Dan Carpenter
Static checkers complain about the inconsistent NULL check here.

There is an unchecked dereference of intput-fe in the call to
tuner_attach_tda18271() and there is a second unchecked dereference a
couple lines later when we do:
input-fe2-tuner_priv = input-fe-tuner_priv;

But actually intput-fe can't be NULL because if demod_attach_drxk()
fails to allocate it, then we would have return an error code.

Signed-off-by: Dan Carpenter dan.carpen...@oracle.com

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 9375f30d9a81..fb52bda8d45f 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -876,10 +876,8 @@ static int dvb_input_attach(struct ddb_input *input)
return -ENODEV;
if (tuner_attach_tda18271(input)  0)
return -ENODEV;
-   if (input-fe) {
-   if (dvb_register_frontend(adap, input-fe)  0)
-   return -ENODEV;
-   }
+   if (dvb_register_frontend(adap, input-fe)  0)
+   return -ENODEV;
if (input-fe2) {
if (dvb_register_frontend(adap, input-fe2)  0)
return -ENODEV;
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATH v6 06/10] v4l: Handle buffer timestamp flags correctly

2014-03-01 Thread Hans Verkuil
Hi Sakari,

I believe this needs some more work. See comments below:

On 03/01/2014 02:17 PM, Sakari Ailus wrote:
 For COPY timestamps, buffer timestamp source flags will traverse the queue
 untouched.
 
 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 ---
  drivers/media/v4l2-core/videobuf2-core.c |   26 +-
  1 file changed, 25 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index 3dda083..7afeb6b 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -488,7 +488,22 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
 struct v4l2_buffer *b)
* Clear any buffer state related flags.
*/
   b-flags = ~V4L2_BUFFER_MASK_FLAGS;
 - b-flags |= q-timestamp_flags;
 + if ((q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
 + V4L2_BUF_FLAG_TIMESTAMP_COPY) {
 + /*
 +  * For COPY timestamps, we just set the timestamp type
 +  * here. The timestamp source is already in b-flags.
 +  */
 + b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK;
 + } else {
 + /*
 +  * For non-COPY timestamps, drop timestamp source and
 +  * obtain the timestamp type and source from the
 +  * queue.
 +  */
 + b-flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 + b-flags |= q-timestamp_flags;
 + }

It's correct, but I would do it a bit differently:

b-flags = ~V4L2_BUFFER_MASK_FLAGS;
b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK;
if ((q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
V4L2_BUF_FLAG_TIMESTAMP_COPY) {
/*
 * For non-COPY timestamps, drop timestamp source and
 * obtain the timestamp type and source from the
 * queue.
 */
b-flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
}

That way it is clearer that the timestamp type is always set and that it is
just the timestamp source that has special handling.


  
   switch (vb-state) {
   case VB2_BUF_STATE_QUEUED:
 @@ -1031,6 +1046,15 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
  
   /* Zero flags that the vb2 core handles */
   vb-v4l2_buf.flags = b-flags  ~V4L2_BUFFER_MASK_FLAGS;
 + if ((vb-vb2_queue-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
 + V4L2_BUF_FLAG_TIMESTAMP_COPY) {
 + /*
 +  * Non-COPY timestamps will get their timestamp and
 +  * timestamp source flags from the queue.
 +  */
 + vb-v4l2_buf.flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 + }

This should be:

if ((vb-vb2_queue-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b-type)) {

Capture buffers also need to clear the TSTAMP_SRC flags as they will get it
from the output queue. In other words: capture buffers never set the timestamp
source flags, only output buffers can do that if timestamps are copied.

As an aside: the more I think about it, the more I believe that we're not quite
doing the right thing when it comes to copying timestamps. The problem is that
TIMESTAMP_COPY is part of the timestamp type mask. It should be a separate bit.
That way output buffers supply both type and source, and capture buffers give
those back to the application. Right now you can't copy the timestamp type since
COPY is part of those types.

We did not really think that through.

Regards,

Hans

 +
   if (V4L2_TYPE_IS_OUTPUT(b-type)) {
   /*
* For output buffers mask out the timecode flag:
 
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATH v6 05.1/11] v4l: Timestamp flags will soon contain timestamp source, not just type

2014-03-01 Thread Sakari Ailus
Mask out other bits when comparing timestamp types.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
This change was missing from the set. The check needs to be changed as there
will be also timestamp source flags, not just timestamp type flags in the
field.

 drivers/media/v4l2-core/videobuf2-core.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 411429c..521350a 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1473,7 +1473,8 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct 
v4l2_buffer *b)
 * For output buffers copy the timestamp if needed,
 * and the timecode field and flag if needed.
 */
-   if (q-timestamp_flags == V4L2_BUF_FLAG_TIMESTAMP_COPY)
+   if ((q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
+   V4L2_BUF_FLAG_TIMESTAMP_COPY)
vb-v4l2_buf.timestamp = b-timestamp;
vb-v4l2_buf.flags |= b-flags  V4L2_BUF_FLAG_TIMECODE;
if (b-flags  V4L2_BUF_FLAG_TIMECODE)
@@ -2230,7 +2231,8 @@ int vb2_queue_init(struct vb2_queue *q)
return -EINVAL;
 
/* Warn that the driver should choose an appropriate timestamp type */
-   WARN_ON(q-timestamp_flags == V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
+   WARN_ON((q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
+   V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
 
INIT_LIST_HEAD(q-queued_list);
INIT_LIST_HEAD(q-done_list);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[yavta PATCH 9/9] Set timestamp for output buffers if the timestamp type is copy

2014-03-01 Thread Sakari Ailus
Copy timestamp type will mean the timestamp is be copied from the source to
the destination buffer on mem-to-mem devices.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 yavta.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/yavta.c b/yavta.c
index 5171024..50bc6c2 100644
--- a/yavta.c
+++ b/yavta.c
@@ -74,6 +74,7 @@ struct device
unsigned int bytesperline;
unsigned int imagesize;
uint32_t buffer_output_flags;
+   uint32_t timestamp_type;
 
void *pattern;
unsigned int patternsize;
@@ -549,6 +550,7 @@ static int video_alloc_buffers(struct device *dev, int 
nbufs,
}
}
 
+   dev-timestamp_type = buf.flags  V4L2_BUF_FLAG_TIMESTAMP_MASK;
dev-buffers = buffers;
dev-nbufs = rb.count;
return 0;
@@ -623,6 +625,13 @@ static int video_queue_buffer(struct device *dev, int 
index, enum buffer_fill_mo
buf.flags = dev-buffer_output_flags;
buf.bytesused = dev-patternsize;
memcpy(dev-buffers[buf.index].mem, dev-pattern, 
dev-patternsize);
+   if (dev-timestamp_type == V4L2_BUF_FLAG_TIMESTAMP_COPY) {
+   struct timespec ts;
+   
+   clock_gettime(CLOCK_MONOTONIC, ts);
+   buf.timestamp.tv_sec = ts.tv_sec;
+   buf.timestamp.tv_usec = ts.tv_nsec / 1000;
+   }
} else {
if (fill  BUFFER_FILL_FRAME)
memset(dev-buffers[buf.index].mem, 0x55, 
dev-buffers[index].size);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[yavta PATCH 3/9] Allow supporting mem2mem devices by adding forced OUTPUT device type

2014-03-01 Thread Sakari Ailus
The option is --output, or -o.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 yavta.c |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/yavta.c b/yavta.c
index 8e43ce5..e010252 100644
--- a/yavta.c
+++ b/yavta.c
@@ -1240,6 +1240,7 @@ static void usage(const char *argv0)
printf(-I, --fill-frames   Fill frames with check pattern 
before queuing them\n);
printf(-l, --list-controls List available controls\n);
printf(-n, --nbufs n   Set the number of video 
buffers\n);
+   printf(-o, --outputUse video node as output\n);
printf(-p, --pause Pause before starting the video 
stream\n);
printf(-q, --quality n MJPEG quality (0-100)\n);
printf(-r, --get-control ctrl  Get control 'ctrl'\n);
@@ -1282,6 +1283,7 @@ static struct option opts[] = {
{nbufs, 1, 0, 'n'},
{no-query, 0, 0, OPT_NO_QUERY},
{offset, 1, 0, OPT_USERPTR_OFFSET},
+   {output, 0, 0, 'o'},
{pause, 0, 0, 'p'},
{quality, 1, 0, 'q'},
{get-control, 1, 0, 'r'},
@@ -1304,7 +1306,7 @@ int main(int argc, char *argv[])
int ret;
 
/* Options parsings */
-   int do_file = 0, do_capture = 0, do_pause = 0;
+   int do_file = 0, do_capture = 0, do_pause = 0, do_output = 0;
int do_set_time_per_frame = 0;
int do_enum_formats = 0, do_set_format = 0;
int do_enum_inputs = 0, do_set_input = 0;
@@ -1385,6 +1387,9 @@ int main(int argc, char *argv[])
if (nbufs  V4L_BUFFERS_MAX)
nbufs = V4L_BUFFERS_MAX;
break;
+   case 'o':
+   do_output = 1;
+   break;
case 'p':
do_pause = 1;
break;
@@ -1500,6 +1505,9 @@ int main(int argc, char *argv[])
if (dev.type == (enum v4l2_buf_type)-1)
no_query = 1;
 
+   if (do_output)
+   dev.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+
dev.memtype = memtype;
 
if (do_get_control) {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[yavta PATCH 4/9] Zero dev in main()

2014-03-01 Thread Sakari Ailus
This is necessary since video_open() may not be always called soon

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 yavta.c |7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/yavta.c b/yavta.c
index e010252..870682e 100644
--- a/yavta.c
+++ b/yavta.c
@@ -182,11 +182,6 @@ static unsigned int v4l2_format_code(const char *name)
 
 static int video_open(struct device *dev, const char *devname, int no_query)
 {
-   struct v4l2_capability cap;
-   unsigned int capabilities;
-   int ret;
-
-   memset(dev, 0, sizeof *dev);
dev-fd = -1;
dev-memtype = V4L2_MEMORY_MMAP;
dev-buffers = NULL;
@@ -1302,7 +1297,7 @@ static struct option opts[] = {
 int main(int argc, char *argv[])
 {
struct sched_param sched;
-   struct device dev;
+   struct device dev = { 0 };
int ret;
 
/* Options parsings */
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[yavta PATCH 5/9] Allow passing file descriptors to yavta

2014-03-01 Thread Sakari Ailus
Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 yavta.c |   63 +++
 1 file changed, 43 insertions(+), 20 deletions(-)

diff --git a/yavta.c b/yavta.c
index 870682e..a9b192a 100644
--- a/yavta.c
+++ b/yavta.c
@@ -62,6 +62,7 @@ struct buffer
 struct device
 {
int fd;
+   int opened;
 
enum v4l2_buf_type type;
enum v4l2_memory memtype;
@@ -180,13 +181,8 @@ static unsigned int v4l2_format_code(const char *name)
return 0;
 }
 
-static int video_open(struct device *dev, const char *devname, int no_query)
+static int video_open(struct device *dev, const char *devname)
 {
-   dev-fd = -1;
-   dev-memtype = V4L2_MEMORY_MMAP;
-   dev-buffers = NULL;
-   dev-type = (enum v4l2_buf_type)-1;
-
dev-fd = open(devname, O_RDWR);
if (dev-fd  0) {
printf(Error opening device %s: %s (%d).\n, devname,
@@ -196,6 +192,16 @@ static int video_open(struct device *dev, const char 
*devname, int no_query)
 
printf(Device %s opened.\n, devname);
 
+   dev-opened = 1;
+
+   return 0;
+}
+
+static int video_querycap(struct device *dev, int no_query) {
+   struct v4l2_capability cap;
+   unsigned int capabilities;
+   int ret;
+
if (no_query) {
/* Assume capture device. */
dev-type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -215,9 +221,7 @@ static int video_open(struct device *dev, const char 
*devname, int no_query)
else if (capabilities  V4L2_CAP_VIDEO_OUTPUT)
dev-type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
else {
-   printf(Error opening device %s: neither video capture 
-   nor video output supported.\n, devname);
-   close(dev-fd);
+   printf(Device supports neither capture nor output.\n);
return -EINVAL;
}
 
@@ -231,7 +235,8 @@ static void video_close(struct device *dev)
 {
free(dev-pattern);
free(dev-buffers);
-   close(dev-fd);
+   if (dev-opened)
+   close(dev-fd);
 }
 
 static unsigned int get_control_type(struct device *dev, unsigned int id)
@@ -1246,6 +1251,7 @@ static void usage(const char *argv0)
printf(-w, --set-control 'ctrl value'  Set control 'ctrl' to 
'value'\n);
printf(--enum-formats  Enumerate formats\n);
printf(--enum-inputs   Enumerate inputs\n);
+   printf(--fdUse a numeric file descriptor 
insted of a device\n);
printf(--no-query  Don't query capabilities on 
open\n);
printf(--offsetUser pointer buffer offset from 
page start\n);
printf(--requeue-last  Requeue the last buffers before 
streamoff\n);
@@ -1262,6 +1268,7 @@ static void usage(const char *argv0)
 #define OPT_USERPTR_OFFSET 261
 #define OPT_REQUEUE_LAST   262
 #define OPT_STRIDE 263
+#define OPT_FD 264
 
 static struct option opts[] = {
{capture, 2, 0, 'c'},
@@ -1269,6 +1276,7 @@ static struct option opts[] = {
{delay, 1, 0, 'd'},
{enum-formats, 0, 0, OPT_ENUM_FORMATS},
{enum-inputs, 0, 0, OPT_ENUM_INPUTS},
+   {fd, 1, 0, OPT_FD},
{file, 2, 0, 'F'},
{fill-frames, 0, 0, 'I'},
{format, 1, 0, 'f'},
@@ -1297,7 +1305,11 @@ static struct option opts[] = {
 int main(int argc, char *argv[])
 {
struct sched_param sched;
-   struct device dev = { 0 };
+   struct device dev = {
+   .fd = -1,
+   .memtype = V4L2_MEMORY_MMAP,
+   .type = (enum v4l2_buf_type)-1,
+   };
int ret;
 
/* Options parsings */
@@ -1452,6 +1464,14 @@ int main(int argc, char *argv[])
case OPT_ENUM_INPUTS:
do_enum_inputs = 1;
break;
+   case OPT_FD:
+   dev.fd = atoi(optarg);
+   if (dev.fd  0) {
+   printf(Bad file descriptor %d\n, dev.fd);
+   return 1;
+   }
+   printf(Using file descriptor %d\n, dev.fd);
+   break;
case OPT_NO_QUERY:
no_query = 1;
break;
@@ -1482,18 +1502,21 @@ int main(int argc, char *argv[])
return 1;
}
 
-   if (optind = argc) {
-   usage(argv[0]);
-   return 1;
-   }
-
if (!do_file)
filename = NULL;
 
-   /* Open the video device. If the device type isn't recognized, set the
-* --no-query option to avoid querying V4L2 subdevs.
-*/
-   ret = video_open(dev, argv[optind], no_query);
+   if (dev.fd == -1) {
+   if (optind = argc) {
+   usage(argv[0]);
+   

[yavta PATCH 0/9] Timestamp source and mem-to-mem device support

2014-03-01 Thread Sakari Ailus
Hi,

This patchset enables using yavta for mem-to-mem devices, including
mem2mem_testdev (or soon vim2m). The timestamp will be set for output
buffers when the timestamp type is copy. An option is added to set the
timestamp source flags (eof/soe).

To use yavta for mem2mem devices, just open the device in the shell and pass
the file descriptor to yavta (--fd).

-- 
Kind regards,
Sakari

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[yavta PATCH 1/9] Update headers from upstream kernel, including timestamp source patches

2014-03-01 Thread Sakari Ailus
Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 include/linux/v4l2-controls.h |  105 -
 include/linux/videodev2.h |  250 +++--
 2 files changed, 214 insertions(+), 141 deletions(-)

diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
index f56c945..2cbe605 100644
--- a/include/linux/v4l2-controls.h
+++ b/include/linux/v4l2-controls.h
@@ -53,12 +53,13 @@
 #define V4L2_CTRL_CLASS_USER   0x0098  /* Old-style 'user' 
controls */
 #define V4L2_CTRL_CLASS_MPEG   0x0099  /* MPEG-compression 
controls */
 #define V4L2_CTRL_CLASS_CAMERA 0x009a  /* Camera class 
controls */
-#define V4L2_CTRL_CLASS_FM_TX  0x009b  /* FM Modulator control 
class */
+#define V4L2_CTRL_CLASS_FM_TX  0x009b  /* FM Modulator 
controls */
 #define V4L2_CTRL_CLASS_FLASH  0x009c  /* Camera flash 
controls */
 #define V4L2_CTRL_CLASS_JPEG   0x009d  /* JPEG-compression 
controls */
 #define V4L2_CTRL_CLASS_IMAGE_SOURCE   0x009e  /* Image source 
controls */
 #define V4L2_CTRL_CLASS_IMAGE_PROC 0x009f  /* Image processing 
controls */
 #define V4L2_CTRL_CLASS_DV 0x00a0  /* Digital Video 
controls */
+#define V4L2_CTRL_CLASS_FM_RX  0x00a1  /* FM Receiver controls 
*/
 
 /* User-class control IDs */
 
@@ -88,10 +89,6 @@
 #define V4L2_CID_HFLIP (V4L2_CID_BASE+20)
 #define V4L2_CID_VFLIP (V4L2_CID_BASE+21)
 
-/* Deprecated; use V4L2_CID_PAN_RESET and V4L2_CID_TILT_RESET */
-#define V4L2_CID_HCENTER   (V4L2_CID_BASE+22)
-#define V4L2_CID_VCENTER   (V4L2_CID_BASE+23)
-
 #define V4L2_CID_POWER_LINE_FREQUENCY  (V4L2_CID_BASE+24)
 enum v4l2_power_line_frequency {
V4L2_CID_POWER_LINE_FREQUENCY_DISABLED  = 0,
@@ -144,8 +141,36 @@ enum v4l2_colorfx {
 /* last CID + 1 */
 #define V4L2_CID_LASTP1 (V4L2_CID_BASE+43)
 
+/* USER-class private control IDs */
+
+/* The base for the meye driver controls. See linux/meye.h for the list
+ * of controls. We reserve 16 controls for this driver. */
+#define V4L2_CID_USER_MEYE_BASE(V4L2_CID_USER_BASE + 
0x1000)
+
+/* The base for the bttv driver controls.
+ * We reserve 32 controls for this driver. */
+#define V4L2_CID_USER_BTTV_BASE(V4L2_CID_USER_BASE + 
0x1010)
+
+
+/* The base for the s2255 driver controls.
+ * We reserve 16 controls for this driver. */
+#define V4L2_CID_USER_S2255_BASE   (V4L2_CID_USER_BASE + 0x1030)
+
+/* The base for the si476x driver controls. See include/media/si476x.h for the 
list
+ * of controls. Total of 16 controls is reserved for this driver */
+#define V4L2_CID_USER_SI476X_BASE  (V4L2_CID_USER_BASE + 0x1040)
+
+/* The base for the TI VPE driver controls. Total of 16 controls is reserved 
for
+ * this driver */
+#define V4L2_CID_USER_TI_VPE_BASE  (V4L2_CID_USER_BASE + 0x1050)
+
+/* The base for the saa7134 driver controls.
+ * We reserve 16 controls for this driver. */
+#define V4L2_CID_USER_SAA7134_BASE (V4L2_CID_USER_BASE + 0x1060)
 
 /* MPEG-class control IDs */
+/* The MPEG controls are applicable to all codec controls
+ * and the 'MPEG' part of the define is historical */
 
 #define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900)
 #define V4L2_CID_MPEG_CLASS(V4L2_CTRL_CLASS_MPEG | 1)
@@ -350,6 +375,7 @@ enum v4l2_mpeg_video_multi_slice_mode {
 #define V4L2_CID_MPEG_VIDEO_DEC_PTS(V4L2_CID_MPEG_BASE+223)
 #define V4L2_CID_MPEG_VIDEO_DEC_FRAME  (V4L2_CID_MPEG_BASE+224)
 #define V4L2_CID_MPEG_VIDEO_VBV_DELAY  (V4L2_CID_MPEG_BASE+225)
+#define V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER  (V4L2_CID_MPEG_BASE+226)
 
 #define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP(V4L2_CID_MPEG_BASE+300)
 #define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP(V4L2_CID_MPEG_BASE+301)
@@ -506,6 +532,38 @@ enum v4l2_mpeg_video_mpeg4_profile {
 };
 #define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE+407)
 
+/*  Control IDs for VP8 streams
+ *  Although VP8 is not part of MPEG we add these controls to the MPEG class
+ *  as that class is already handling other video compression standards
+ */
+#define V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS (V4L2_CID_MPEG_BASE+500)
+enum v4l2_vp8_num_partitions {
+   V4L2_CID_MPEG_VIDEO_VPX_1_PARTITION = 0,
+   V4L2_CID_MPEG_VIDEO_VPX_2_PARTITIONS= 1,
+   V4L2_CID_MPEG_VIDEO_VPX_4_PARTITIONS= 2,
+   V4L2_CID_MPEG_VIDEO_VPX_8_PARTITIONS= 3,
+};
+#define V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4
(V4L2_CID_MPEG_BASE+501)
+#define V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES (V4L2_CID_MPEG_BASE+502)
+enum v4l2_vp8_num_ref_frames {
+   V4L2_CID_MPEG_VIDEO_VPX_1_REF_FRAME = 0,
+   

[yavta PATCH 2/9] Print timestamp source (start-of-exposure or end-of-frame)

2014-03-01 Thread Sakari Ailus
Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 yavta.c |   16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/yavta.c b/yavta.c
index 0e1c921..8e43ce5 100644
--- a/yavta.c
+++ b/yavta.c
@@ -476,7 +476,7 @@ static int video_alloc_buffers(struct device *dev, int 
nbufs,
 
/* Map the buffers. */
for (i = 0; i  rb.count; ++i) {
-   const char *ts_type;
+   const char *ts_type, *ts_source;
memset(buf, 0, sizeof buf);
buf.index = i;
buf.type = dev-type;
@@ -497,8 +497,18 @@ static int video_alloc_buffers(struct device *dev, int 
nbufs,
default:
ts_type = invalid;
}
-   printf(length: %u offset: %u timestamp type: %s\n,
-  buf.length, buf.m.offset, ts_type);
+   switch (buf.flags  V4L2_BUF_FLAG_TSTAMP_SRC_MASK) {
+   case V4L2_BUF_FLAG_TSTAMP_SRC_EOF:
+   ts_source = EoF;
+   break;
+   case V4L2_BUF_FLAG_TSTAMP_SRC_SOE:
+   ts_source = SoE;
+   break;
+   default:
+   ts_source = invalid;
+   }
+   printf(length: %u offset: %u timestamp type/source: %s/%s\n,
+  buf.length, buf.m.offset, ts_type, ts_source);
 
switch (dev-memtype) {
case V4L2_MEMORY_MMAP:
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[yavta PATCH 6/9] Timestamp source for output buffers

2014-03-01 Thread Sakari Ailus
Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 yavta.c |   18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/yavta.c b/yavta.c
index a9b192a..71c1477 100644
--- a/yavta.c
+++ b/yavta.c
@@ -73,6 +73,7 @@ struct device
unsigned int height;
unsigned int bytesperline;
unsigned int imagesize;
+   uint32_t buffer_output_flags;
 
void *pattern;
unsigned int patternsize;
@@ -611,6 +612,7 @@ static int video_queue_buffer(struct device *dev, int 
index, enum buffer_fill_mo
buf.m.userptr = (unsigned long)dev-buffers[index].mem;
 
if (dev-type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
+   buf.flags = dev-buffer_output_flags;
buf.bytesused = dev-patternsize;
memcpy(dev-buffers[buf.index].mem, dev-pattern, 
dev-patternsize);
} else {
@@ -1255,6 +1257,7 @@ static void usage(const char *argv0)
printf(--no-query  Don't query capabilities on 
open\n);
printf(--offsetUser pointer buffer offset from 
page start\n);
printf(--requeue-last  Requeue the last buffers before 
streamoff\n);
+   printf(--timestamp-source  Set timestamp source on output 
buffers [eof, soe]\n);
printf(--skip nSkip the first n frames\n);
printf(--sleep-forever Sleep forever after configuring 
the device\n);
printf(--stride value  Line stride in bytes\n);
@@ -1269,6 +1272,7 @@ static void usage(const char *argv0)
 #define OPT_REQUEUE_LAST   262
 #define OPT_STRIDE 263
 #define OPT_FD 264
+#define OPT_TSTAMP_SRC 265
 
 static struct option opts[] = {
{capture, 2, 0, 'c'},
@@ -1298,7 +1302,8 @@ static struct option opts[] = {
{sleep-forever, 0, 0, OPT_SLEEP_FOREVER},
{stride, 1, 0, OPT_STRIDE},
{time-per-frame, 1, 0, 't'},
-   {userptr, 0, 0, 'u'},
+   {timestamp-source, 1, 0, OPT_TSTAMP_SRC},
+   {userptr, 1, 0, 'u'},
{0, 0, 0, 0}
 };
 
@@ -1487,6 +1492,17 @@ int main(int argc, char *argv[])
case OPT_STRIDE:
stride = atoi(optarg);
break;
+   case OPT_TSTAMP_SRC:
+   if (!strcmp(optarg, eof)) {
+   dev.buffer_output_flags |= 
V4L2_BUF_FLAG_TSTAMP_SRC_EOF;
+   } else if (!strcmp(optarg, soe)) {
+   dev.buffer_output_flags |= 
V4L2_BUF_FLAG_TSTAMP_SRC_SOE;
+   } else {
+   printf(Invalid timestamp source %s\n, optarg);
+   return 1;
+   }
+   printf(Using %s timestamp source\n, optarg);
+   break;
case OPT_USERPTR_OFFSET:
userptr_offset = atoi(optarg);
break;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[yavta PATCH 8/9] Support copy timestamps

2014-03-01 Thread Sakari Ailus
Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 yavta.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/yavta.c b/yavta.c
index 224405d..5171024 100644
--- a/yavta.c
+++ b/yavta.c
@@ -454,6 +454,9 @@ static void get_ts_flags(uint32_t flags, const char 
**ts_type, const char **ts_s
case V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC:
*ts_type = monotonic;
break;
+   case V4L2_BUF_FLAG_TIMESTAMP_COPY:
+   *ts_type = copy;
+   break;
default:
*ts_type = invalid;
}
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[yavta PATCH 7/9] Print timestamp type and source for dequeued buffers

2014-03-01 Thread Sakari Ailus
Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 yavta.c |   52 ++--
 1 file changed, 30 insertions(+), 22 deletions(-)

diff --git a/yavta.c b/yavta.c
index 71c1477..224405d 100644
--- a/yavta.c
+++ b/yavta.c
@@ -445,6 +445,30 @@ static int video_set_framerate(struct device *dev, struct 
v4l2_fract *time_per_f
return 0;
 }
 
+static void get_ts_flags(uint32_t flags, const char **ts_type, const char 
**ts_source)
+{
+   switch (flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) {
+   case V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN:
+   *ts_type = unknown;
+   break;
+   case V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC:
+   *ts_type = monotonic;
+   break;
+   default:
+   *ts_type = invalid;
+   }
+   switch (flags  V4L2_BUF_FLAG_TSTAMP_SRC_MASK) {
+   case V4L2_BUF_FLAG_TSTAMP_SRC_EOF:
+   *ts_source = EoF;
+   break;
+   case V4L2_BUF_FLAG_TSTAMP_SRC_SOE:
+   *ts_source = SoE;
+   break;
+   default:
+   *ts_source = invalid;
+   }
+}
+
 static int video_alloc_buffers(struct device *dev, int nbufs,
unsigned int offset, unsigned int padding)
 {
@@ -488,26 +512,7 @@ static int video_alloc_buffers(struct device *dev, int 
nbufs,
strerror(errno), errno);
return ret;
}
-   switch (buf.flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) {
-   case V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN:
-   ts_type = unknown;
-   break;
-   case V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC:
-   ts_type = monotonic;
-   break;
-   default:
-   ts_type = invalid;
-   }
-   switch (buf.flags  V4L2_BUF_FLAG_TSTAMP_SRC_MASK) {
-   case V4L2_BUF_FLAG_TSTAMP_SRC_EOF:
-   ts_source = EoF;
-   break;
-   case V4L2_BUF_FLAG_TSTAMP_SRC_SOE:
-   ts_source = SoE;
-   break;
-   default:
-   ts_source = invalid;
-   }
+   get_ts_flags(buf.flags, ts_type, ts_source);
printf(length: %u offset: %u timestamp type/source: %s/%s\n,
   buf.length, buf.m.offset, ts_type, ts_source);
 
@@ -1131,6 +1136,7 @@ static int video_do_capture(struct device *dev, unsigned 
int nframes,
last.tv_usec = start.tv_nsec / 1000;
 
for (i = 0; i  nframes; ++i) {
+   const char *ts_type, *ts_source;
/* Dequeue a buffer. */
memset(buf, 0, sizeof buf);
buf.type = dev-type;
@@ -1163,10 +1169,12 @@ static int video_do_capture(struct device *dev, 
unsigned int nframes,
fps = fps ? 100.0 / fps : 0.0;
 
clock_gettime(CLOCK_MONOTONIC, ts);
-   printf(%u (%u) [%c] %u %u bytes %ld.%06ld %ld.%06ld %.3f 
fps\n, i, buf.index,
+   get_ts_flags(buf.flags, ts_type, ts_source);
+   printf(%u (%u) [%c] %u %u bytes %ld.%06ld %ld.%06ld %.3f fps 
tstamp type/src %s/%s\n, i, buf.index,
(buf.flags  V4L2_BUF_FLAG_ERROR) ? 'E' : '-',
buf.sequence, buf.bytesused, buf.timestamp.tv_sec,
-   buf.timestamp.tv_usec, ts.tv_sec, ts.tv_nsec/1000, fps);
+   buf.timestamp.tv_usec, ts.tv_sec, ts.tv_nsec/1000, fps,
+   ts_type, ts_source);
 
last = buf.timestamp;
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATH v6 05/10] v4l: Add timestamp source flags, mask and document them

2014-03-01 Thread Sakari Ailus
Hi Hans,

Hans Verkuil wrote:
 Hi Sakari,
 
 Don't worry, it's a very minor change:

I won't; I'm always happy to get comments. ;-) Thank you again.

 On 03/01/2014 02:17 PM, Sakari Ailus wrote:
 Some devices do not produce timestamps that correspond to the end of the
 frame. The user space should be informed on the matter. This patch achieves
 that by adding buffer flags (and a mask) for timestamp sources since more
 possible timestamping points are expected than just two.

 A three-bit mask is defined (V4L2_BUF_FLAG_TSTAMP_SRC_MASK) and two of the
 eight possible values is are defined V4L2_BUF_FLAG_TSTAMP_SRC_EOF for end of
 frame (value zero) V4L2_BUF_FLAG_TSTAMP_SRC_SOE for start of exposure (next
 value).

I'll fix that soonish.

-- 
Sakari Ailus
sakari.ai...@iki.fi
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATH v6 06/10] v4l: Handle buffer timestamp flags correctly

2014-03-01 Thread Sakari Ailus
Hi Hans,

Thanks for the comments.

Hans Verkuil wrote:
 On 03/01/2014 02:17 PM, Sakari Ailus wrote:
 For COPY timestamps, buffer timestamp source flags will traverse the queue
 untouched.

 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 ---
  drivers/media/v4l2-core/videobuf2-core.c |   26 +-
  1 file changed, 25 insertions(+), 1 deletion(-)

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index 3dda083..7afeb6b 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -488,7 +488,22 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
 struct v4l2_buffer *b)
   * Clear any buffer state related flags.
   */
  b-flags = ~V4L2_BUFFER_MASK_FLAGS;
 -b-flags |= q-timestamp_flags;
 +if ((q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
 +V4L2_BUF_FLAG_TIMESTAMP_COPY) {
 +/*
 + * For COPY timestamps, we just set the timestamp type
 + * here. The timestamp source is already in b-flags.
 + */
 +b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK;
 +} else {
 +/*
 + * For non-COPY timestamps, drop timestamp source and
 + * obtain the timestamp type and source from the
 + * queue.
 + */
 +b-flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 +b-flags |= q-timestamp_flags;
 +}
 
 It's correct, but I would do it a bit differently:
 
   b-flags = ~V4L2_BUFFER_MASK_FLAGS;
   b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK;
   if ((q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
   V4L2_BUF_FLAG_TIMESTAMP_COPY) {
   /*
* For non-COPY timestamps, drop timestamp source and
* obtain the timestamp type and source from the
* queue.
*/
   b-flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
   b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
   }
 
 That way it is clearer that the timestamp type is always set and that it is
 just the timestamp source that has special handling.

I was actually pondering between the above and what ended up into the
code. ;-) I'll fix that and change the comment to say:

/*
 * For non-COPY timestamps, drop timestamp source bits
 * and obtain the timestamp source from the queue.
 */
 
  
  switch (vb-state) {
  case VB2_BUF_STATE_QUEUED:
 @@ -1031,6 +1046,15 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
  
  /* Zero flags that the vb2 core handles */
  vb-v4l2_buf.flags = b-flags  ~V4L2_BUFFER_MASK_FLAGS;
 +if ((vb-vb2_queue-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
 +V4L2_BUF_FLAG_TIMESTAMP_COPY) {
 +/*
 + * Non-COPY timestamps will get their timestamp and
 + * timestamp source flags from the queue.
 + */
 +vb-v4l2_buf.flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 +}
 
 This should be:
 
   if ((vb-vb2_queue-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
   V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b-type)) {
 
 Capture buffers also need to clear the TSTAMP_SRC flags as they will get it
 from the output queue. In other words: capture buffers never set the timestamp
 source flags, only output buffers can do that if timestamps are copied.

Good point. I'll also change the comment accordingly:

/*
 * Non-COPY timestamps and non-OUTPUT queues will get
 * their timestamp and timestamp source flags from the
 * queue.
 */

 As an aside: the more I think about it, the more I believe that we're not 
 quite
 doing the right thing when it comes to copying timestamps. The problem is that
 TIMESTAMP_COPY is part of the timestamp type mask. It should be a separate 
 bit.
 That way output buffers supply both type and source, and capture buffers give
 those back to the application. Right now you can't copy the timestamp type 
 since
 COPY is part of those types.

Is that a real problem? The timestamp types are related to clocks and in
that sense, copy is one of them: it's anything the program queueing it
to the OUTPUT queue has specified. In other words, I don't think the
combination of monotonic (or realtime) and copy would be meaningful.

 We did not really think that through.

At least I don't see a problem with how it's currently implemented. :-)

-- 
Kind regards,

Sakari Ailus
sakari.ai...@iki.fi
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATH v6.1 06/10] v4l: Handle buffer timestamp flags correctly

2014-03-01 Thread Sakari Ailus
For COPY timestamps, buffer timestamp source flags will traverse the queue
untouched.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
changes since v6:
- Clean up changes to __fill_v4l2_buffer().
- Drop timestamp source flags for non-OUTPUT buffers in __fill_vb2_buffer().
- Comments fixed accordingly.

 drivers/media/v4l2-core/videobuf2-core.c |   21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 42a8568..79eb9ba 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -488,7 +488,16 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
struct v4l2_buffer *b)
 * Clear any buffer state related flags.
 */
b-flags = ~V4L2_BUFFER_MASK_FLAGS;
-   b-flags |= q-timestamp_flags;
+   b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK;
+   if ((q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
+   V4L2_BUF_FLAG_TIMESTAMP_COPY) {
+   /*
+* For non-COPY timestamps, drop timestamp source bits
+* and obtain the timestamp source from the queue.
+*/
+   b-flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+   b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+   }
 
switch (vb-state) {
case VB2_BUF_STATE_QUEUED:
@@ -1031,6 +1040,16 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
 
/* Zero flags that the vb2 core handles */
vb-v4l2_buf.flags = b-flags  ~V4L2_BUFFER_MASK_FLAGS;
+   if ((vb-vb2_queue-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
+   V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b-type)) {
+   /*
+* Non-COPY timestamps and non-OUTPUT queues will get
+* their timestamp and timestamp source flags from the
+* queue.
+*/
+   vb-v4l2_buf.flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+   }
+
if (V4L2_TYPE_IS_OUTPUT(b-type)) {
/*
 * For output buffers mask out the timecode flag:
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] rc-main: fix missing unlock if no devno left

2014-03-01 Thread James Hogan
While playing with make coccicheck I noticed this message:
drivers/media/rc/rc-main.c:1245:3-9: preceding lock on line 1238

It was introduced by commit 587d1b06e07b ([media] rc-core: reuse device
numbers) which returns -ENOMEM after a mutex_lock without first
unlocking it when there are no more device numbers left. The added code
doesn't depend on the device lock, so move it before the lock is taken.

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Mauro Carvalho Chehab m.che...@samsung.com
Cc: linux-media@vger.kernel.org
---
 drivers/media/rc/rc-main.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 2ec60f8..79bcd41 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1228,24 +1228,24 @@ int rc_register_device(struct rc_dev *dev)
dev-input_dev-open = ir_open;
if (dev-close)
dev-input_dev-close = ir_close;
 
-   /*
-* Take the lock here, as the device sysfs node will appear
-* when device_add() is called, which may trigger an ir-keytable udev
-* rule, which will in turn call show_protocols and access
-* dev-enabled_protocols before it has been initialized.
-*/
-   mutex_lock(dev-lock);
-
do {
devno = find_first_zero_bit(ir_core_dev_number,
IRRCV_NUM_DEVICES);
/* No free device slots */
if (devno = IRRCV_NUM_DEVICES)
return -ENOMEM;
} while (test_and_set_bit(devno, ir_core_dev_number));
 
+   /*
+* Take the lock here, as the device sysfs node will appear
+* when device_add() is called, which may trigger an ir-keytable udev
+* rule, which will in turn call show_protocols and access
+* dev-enabled_protocols before it has been initialized.
+*/
+   mutex_lock(dev-lock);
+
dev-devno = devno;
dev_set_name(dev-dev, rc%ld, dev-devno);
dev_set_drvdata(dev-dev, dev);
rc = device_add(dev-dev);
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


cron job: media_tree daily build: ERRORS

2014-03-01 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Sun Mar  2 04:00:20 CET 2014
git branch: test
git hash:   a06b429df49bb50ec1e671123a45147a1d1a6186
gcc version:i686-linux-gcc (GCC) 4.8.2
sparse version: 0.4.5-rc1
host hardware:  x86_64
host os:3.12-6.slh.2-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: WARNINGS
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.31.14-i686: ERRORS
linux-2.6.32.27-i686: ERRORS
linux-2.6.33.7-i686: ERRORS
linux-2.6.34.7-i686: ERRORS
linux-2.6.35.9-i686: ERRORS
linux-2.6.36.4-i686: ERRORS
linux-2.6.37.6-i686: ERRORS
linux-2.6.38.8-i686: ERRORS
linux-2.6.39.4-i686: ERRORS
linux-3.0.60-i686: ERRORS
linux-3.1.10-i686: ERRORS
linux-3.2.37-i686: ERRORS
linux-3.3.8-i686: ERRORS
linux-3.4.27-i686: ERRORS
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12-i686: OK
linux-3.13-i686: OK
linux-3.14-rc1-i686: OK
linux-2.6.31.14-x86_64: ERRORS
linux-2.6.32.27-x86_64: ERRORS
linux-2.6.33.7-x86_64: ERRORS
linux-2.6.34.7-x86_64: ERRORS
linux-2.6.35.9-x86_64: ERRORS
linux-2.6.36.4-x86_64: ERRORS
linux-2.6.37.6-x86_64: ERRORS
linux-2.6.38.8-x86_64: ERRORS
linux-2.6.39.4-x86_64: ERRORS
linux-3.0.60-x86_64: ERRORS
linux-3.1.10-x86_64: ERRORS
linux-3.2.37-x86_64: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.27-x86_64: ERRORS
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12-x86_64: OK
linux-3.13-x86_64: OK
linux-3.14-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse version: 0.4.5-rc1
sparse: ERRORS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Sunday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Sunday.tar.bz2

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/media.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] [media] tvp5150: Fix type mismatch warning in clamp macro

2014-03-01 Thread Prabhakar Lad
Hi Philipp,

Thanks for the patch.

On Thu, Feb 27, 2014 at 10:14 PM, Philipp Zabel p.za...@pengutronix.de wrote:
 This patch fixes the following warning:

 drivers/media/i2c/tvp5150.c: In function '__tvp5150_try_crop':
 include/linux/kernel.h:762:17: warning: comparison of distinct pointer types 
 lacks a cast [enabled by default]
   (void) (__val == __min);  \
  ^
 drivers/media/i2c/tvp5150.c:886:16: note: in expansion of macro 'clamp'
   rect-width = clamp(rect-width,
 ^
 include/linux/kernel.h:763:17: warning: comparison of distinct pointer types 
 lacks a cast [enabled by default]
   (void) (__val == __max);  \
  ^
 drivers/media/i2c/tvp5150.c:886:16: note: in expansion of macro 'clamp'
   rect-width = clamp(rect-width,
 ^
 include/linux/kernel.h:762:17: warning: comparison of distinct pointer types 
 lacks a cast [enabled by default]
   (void) (__val == __min);  \
  ^
 drivers/media/i2c/tvp5150.c:904:17: note: in expansion of macro 'clamp'
   rect-height = clamp(rect-height,
  ^
 include/linux/kernel.h:763:17: warning: comparison of distinct pointer types 
 lacks a cast [enabled by default]
   (void) (__val == __max);  \
  ^
 drivers/media/i2c/tvp5150.c:904:17: note: in expansion of macro 'clamp'
   rect-height = clamp(rect-height,
  ^

 Signed-off-by: Philipp Zabel p.za...@pengutronix.de

Acked-by: Lad, Prabhakar prabhakar.cse...@gmail.com

Thanks,
--Prabhakar Lad
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] [media] tvp5150: Make debug module parameter visible in sysfs

2014-03-01 Thread Prabhakar Lad
Hi Philipp,

Thanks for the patch.

On Thu, Feb 27, 2014 at 10:14 PM, Philipp Zabel p.za...@pengutronix.de wrote:
 Set permissions on the debug module parameter to make it appear in sysfs.

 Signed-off-by: Philipp Zabel p.za...@pengutronix.de

Acked-by: Lad, Prabhakar prabhakar.cse...@gmail.com

Thanks,
--Prabhakar Lad
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATH v6.1 06/10] v4l: Handle buffer timestamp flags correctly

2014-03-01 Thread Hans Verkuil
Acked-by: Hans Verkuil hans.verk...@cisco.com

Regards,

Hans

On 03/01/2014 05:59 PM, Sakari Ailus wrote:
 For COPY timestamps, buffer timestamp source flags will traverse the queue
 untouched.
 
 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 ---
 changes since v6:
 - Clean up changes to __fill_v4l2_buffer().
 - Drop timestamp source flags for non-OUTPUT buffers in __fill_vb2_buffer().
 - Comments fixed accordingly.
 
  drivers/media/v4l2-core/videobuf2-core.c |   21 -
  1 file changed, 20 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index 42a8568..79eb9ba 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -488,7 +488,16 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
 struct v4l2_buffer *b)
* Clear any buffer state related flags.
*/
   b-flags = ~V4L2_BUFFER_MASK_FLAGS;
 - b-flags |= q-timestamp_flags;
 + b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK;
 + if ((q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
 + V4L2_BUF_FLAG_TIMESTAMP_COPY) {
 + /*
 +  * For non-COPY timestamps, drop timestamp source bits
 +  * and obtain the timestamp source from the queue.
 +  */
 + b-flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 + b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 + }
  
   switch (vb-state) {
   case VB2_BUF_STATE_QUEUED:
 @@ -1031,6 +1040,16 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
  
   /* Zero flags that the vb2 core handles */
   vb-v4l2_buf.flags = b-flags  ~V4L2_BUFFER_MASK_FLAGS;
 + if ((vb-vb2_queue-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
 + V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b-type)) {
 + /*
 +  * Non-COPY timestamps and non-OUTPUT queues will get
 +  * their timestamp and timestamp source flags from the
 +  * queue.
 +  */
 + vb-v4l2_buf.flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 + }
 +
   if (V4L2_TYPE_IS_OUTPUT(b-type)) {
   /*
* For output buffers mask out the timecode flag:
 
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATH v6 06/10] v4l: Handle buffer timestamp flags correctly

2014-03-01 Thread Hans Verkuil


On 03/01/2014 05:51 PM, Sakari Ailus wrote:
 Hi Hans,
 
 Thanks for the comments.
 
 Hans Verkuil wrote:
 On 03/01/2014 02:17 PM, Sakari Ailus wrote:
 For COPY timestamps, buffer timestamp source flags will traverse the queue
 untouched.

 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 ---
  drivers/media/v4l2-core/videobuf2-core.c |   26 +-
  1 file changed, 25 insertions(+), 1 deletion(-)

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index 3dda083..7afeb6b 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -488,7 +488,22 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
 struct v4l2_buffer *b)
  * Clear any buffer state related flags.
  */
 b-flags = ~V4L2_BUFFER_MASK_FLAGS;
 -   b-flags |= q-timestamp_flags;
 +   if ((q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
 +   V4L2_BUF_FLAG_TIMESTAMP_COPY) {
 +   /*
 +* For COPY timestamps, we just set the timestamp type
 +* here. The timestamp source is already in b-flags.
 +*/
 +   b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK;
 +   } else {
 +   /*
 +* For non-COPY timestamps, drop timestamp source and
 +* obtain the timestamp type and source from the
 +* queue.
 +*/
 +   b-flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 +   b-flags |= q-timestamp_flags;
 +   }

 It's correct, but I would do it a bit differently:

  b-flags = ~V4L2_BUFFER_MASK_FLAGS;
  b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK;
  if ((q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
  V4L2_BUF_FLAG_TIMESTAMP_COPY) {
  /*
   * For non-COPY timestamps, drop timestamp source and
   * obtain the timestamp type and source from the
   * queue.
   */
  b-flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
  b-flags |= q-timestamp_flags  V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
  }

 That way it is clearer that the timestamp type is always set and that it is
 just the timestamp source that has special handling.
 
 I was actually pondering between the above and what ended up into the
 code. ;-) I'll fix that and change the comment to say:
 
   /*
* For non-COPY timestamps, drop timestamp source bits
* and obtain the timestamp source from the queue.
*/

  
 switch (vb-state) {
 case VB2_BUF_STATE_QUEUED:
 @@ -1031,6 +1046,15 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
  
 /* Zero flags that the vb2 core handles */
 vb-v4l2_buf.flags = b-flags  ~V4L2_BUFFER_MASK_FLAGS;
 +   if ((vb-vb2_queue-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
 +   V4L2_BUF_FLAG_TIMESTAMP_COPY) {
 +   /*
 +* Non-COPY timestamps will get their timestamp and
 +* timestamp source flags from the queue.
 +*/
 +   vb-v4l2_buf.flags = ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 +   }

 This should be:

  if ((vb-vb2_queue-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
  V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b-type)) {

 Capture buffers also need to clear the TSTAMP_SRC flags as they will get it
 from the output queue. In other words: capture buffers never set the 
 timestamp
 source flags, only output buffers can do that if timestamps are copied.
 
 Good point. I'll also change the comment accordingly:
 
   /*
* Non-COPY timestamps and non-OUTPUT queues will get
* their timestamp and timestamp source flags from the
* queue.
*/
 
 As an aside: the more I think about it, the more I believe that we're not 
 quite
 doing the right thing when it comes to copying timestamps. The problem is 
 that
 TIMESTAMP_COPY is part of the timestamp type mask. It should be a separate 
 bit.
 That way output buffers supply both type and source, and capture buffers give
 those back to the application. Right now you can't copy the timestamp type 
 since
 COPY is part of those types.
 
 Is that a real problem? The timestamp types are related to clocks and in
 that sense, copy is one of them: it's anything the program queueing it
 to the OUTPUT queue has specified. In other words, I don't think the
 combination of monotonic (or realtime) and copy would be meaningful.
 
 We did not really think that through.
 
 At least I don't see a problem with how it's currently implemented. :-)

Well, the problem is that when you capture from hardware you get a timestamp
and a timestamp type (i.e. which clock did the timestamp use?). If you then
pass that captured stream through a m2m device for postprocessing you will
have lost the timestamp type on the other side of the m2m device since it
will be