GNU Linux-libre 4.9.317-gnu1
[releases.git] / drivers / media / platform / vsp1 / vsp1_video.h
1 /*
2  * vsp1_video.h  --  R-Car VSP1 Video Node
3  *
4  * Copyright (C) 2013-2015 Renesas Electronics Corporation
5  *
6  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  */
13 #ifndef __VSP1_VIDEO_H__
14 #define __VSP1_VIDEO_H__
15
16 #include <linux/list.h>
17 #include <linux/spinlock.h>
18
19 #include <media/videobuf2-v4l2.h>
20
21 #include "vsp1_rwpf.h"
22
23 struct vsp1_vb2_buffer {
24         struct vb2_v4l2_buffer buf;
25         struct list_head queue;
26         struct vsp1_rwpf_memory mem;
27 };
28
29 static inline struct vsp1_vb2_buffer *
30 to_vsp1_vb2_buffer(struct vb2_v4l2_buffer *vbuf)
31 {
32         return container_of(vbuf, struct vsp1_vb2_buffer, buf);
33 }
34
35 struct vsp1_video {
36         struct list_head list;
37         struct vsp1_device *vsp1;
38         struct vsp1_rwpf *rwpf;
39
40         struct video_device video;
41         enum v4l2_buf_type type;
42         struct media_pad pad;
43
44         struct mutex lock;
45
46         unsigned int pipe_index;
47
48         struct vb2_queue queue;
49         spinlock_t irqlock;
50         struct list_head irqqueue;
51 };
52
53 static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev)
54 {
55         return container_of(vdev, struct vsp1_video, video);
56 }
57
58 struct vsp1_video *vsp1_video_create(struct vsp1_device *vsp1,
59                                      struct vsp1_rwpf *rwpf);
60 void vsp1_video_cleanup(struct vsp1_video *video);
61
62 #endif /* __VSP1_VIDEO_H__ */