Commit 66847ef0 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] uvcvideo: Add UVC timestamps support

UVC devices transmit a device timestamp along with video frames. Convert
the timestamp to a host timestamp and use it to fill the V4L2 buffer
timestamp field.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 25738cbd
......@@ -104,10 +104,22 @@ static void uvc_buffer_queue(struct vb2_buffer *vb)
spin_unlock_irqrestore(&queue->irqlock, flags);
}
static int uvc_buffer_finish(struct vb2_buffer *vb)
{
struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
struct uvc_streaming *stream =
container_of(queue, struct uvc_streaming, queue);
struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf);
uvc_video_clock_update(stream, &vb->v4l2_buf, buf);
return 0;
}
static struct vb2_ops uvc_queue_qops = {
.queue_setup = uvc_queue_setup,
.buf_prepare = uvc_buffer_prepare,
.buf_queue = uvc_buffer_queue,
.buf_finish = uvc_buffer_finish,
};
void uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
......
This diff is collapsed.
......@@ -329,6 +329,8 @@ struct uvc_buffer {
void *mem;
unsigned int length;
unsigned int bytesused;
u32 pts;
};
#define UVC_QUEUE_DISCONNECTED (1 << 0)
......@@ -455,6 +457,25 @@ struct uvc_streaming {
struct uvc_stats_frame frame;
struct uvc_stats_stream stream;
} stats;
/* Timestamps support. */
struct uvc_clock {
struct uvc_clock_sample {
u32 dev_stc;
u16 dev_sof;
struct timespec host_ts;
u16 host_sof;
} *samples;
unsigned int head;
unsigned int count;
unsigned int size;
u16 last_sof;
u16 sof_offset;
spinlock_t lock;
} clock;
};
enum uvc_device_state {
......@@ -527,6 +548,7 @@ struct uvc_driver {
#define UVC_TRACE_STATUS (1 << 9)
#define UVC_TRACE_VIDEO (1 << 10)
#define UVC_TRACE_STATS (1 << 11)
#define UVC_TRACE_CLOCK (1 << 12)
#define UVC_WARN_MINMAX 0
#define UVC_WARN_PROBE_DEF 1
......@@ -607,6 +629,9 @@ extern int uvc_probe_video(struct uvc_streaming *stream,
struct uvc_streaming_control *probe);
extern int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit,
__u8 intfnum, __u8 cs, void *data, __u16 size);
void uvc_video_clock_update(struct uvc_streaming *stream,
struct v4l2_buffer *v4l2_buf,
struct uvc_buffer *buf);
/* Status */
extern int uvc_status_init(struct uvc_device *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment