1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef __VSP1_VIDEO_H__
14#define __VSP1_VIDEO_H__
15
16#include <linux/list.h>
17#include <linux/spinlock.h>
18#include <linux/wait.h>
19
20#include <media/media-entity.h>
21#include <media/videobuf2-core.h>
22
23struct vsp1_video;
24
25
26
27
28
29
30
31
32
33
34
35
36
37struct vsp1_format_info {
38 u32 fourcc;
39 unsigned int mbus;
40 unsigned int hwfmt;
41 unsigned int swap;
42 unsigned int planes;
43 unsigned int bpp[3];
44 bool swap_yc;
45 bool swap_uv;
46 unsigned int hsub;
47 unsigned int vsub;
48};
49
50enum vsp1_pipeline_state {
51 VSP1_PIPELINE_STOPPED,
52 VSP1_PIPELINE_RUNNING,
53 VSP1_PIPELINE_STOPPING,
54};
55
56
57
58
59
60
61
62struct vsp1_pipeline {
63 struct media_pipeline pipe;
64
65 spinlock_t irqlock;
66 enum vsp1_pipeline_state state;
67 wait_queue_head_t wq;
68
69 struct mutex lock;
70 unsigned int use_count;
71 unsigned int stream_count;
72 unsigned int buffers_ready;
73
74 unsigned int num_video;
75 unsigned int num_inputs;
76 struct vsp1_rwpf *inputs[VPS1_MAX_RPF];
77 struct vsp1_rwpf *output;
78 struct vsp1_entity *lif;
79
80 struct list_head entities;
81};
82
83static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
84{
85 if (likely(e->pipe))
86 return container_of(e->pipe, struct vsp1_pipeline, pipe);
87 else
88 return NULL;
89}
90
91struct vsp1_video_buffer {
92 struct vsp1_video *video;
93 struct vb2_buffer buf;
94 struct list_head queue;
95
96 dma_addr_t addr[3];
97 unsigned int length[3];
98};
99
100static inline struct vsp1_video_buffer *
101to_vsp1_video_buffer(struct vb2_buffer *vb)
102{
103 return container_of(vb, struct vsp1_video_buffer, buf);
104}
105
106struct vsp1_video_operations {
107 void (*queue)(struct vsp1_video *video, struct vsp1_video_buffer *buf);
108};
109
110struct vsp1_video {
111 struct vsp1_device *vsp1;
112 struct vsp1_entity *rwpf;
113
114 const struct vsp1_video_operations *ops;
115
116 struct video_device video;
117 enum v4l2_buf_type type;
118 struct media_pad pad;
119
120 struct mutex lock;
121 struct v4l2_pix_format_mplane format;
122 const struct vsp1_format_info *fmtinfo;
123
124 struct vsp1_pipeline pipe;
125 unsigned int pipe_index;
126
127 struct vb2_queue queue;
128 void *alloc_ctx;
129 spinlock_t irqlock;
130 struct list_head irqqueue;
131 unsigned int sequence;
132};
133
134static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev)
135{
136 return container_of(vdev, struct vsp1_video, video);
137}
138
139int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf);
140void vsp1_video_cleanup(struct vsp1_video *video);
141
142void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
143
144#endif
145