1
2
3
4
5
6
7 #include <linux/clk.h>
8 #include <linux/ktime.h>
9 #include <linux/platform_device.h>
10 #include <linux/spinlock.h>
11
12 #include <media/v4l2-ctrls.h>
13 #include <media/v4l2-device.h>
14 #include <media/v4l2-mem2mem.h>
15
16 #include <media/videobuf2-dma-contig.h>
17
18 #define BDISP_NAME "bdisp"
19
20
21
22
23
24 #define MAX_OUTPUT_PLANES 2
25 #define MAX_VERTICAL_STRIDES 2
26 #define MAX_NB_NODE (MAX_OUTPUT_PLANES * MAX_VERTICAL_STRIDES)
27
28
29
30
31
32 struct bdisp_ctrls {
33 struct v4l2_ctrl *hflip;
34 struct v4l2_ctrl *vflip;
35 };
36
37
38
39
40
41
42
43
44
45
46 struct bdisp_fmt {
47 u32 pixelformat;
48 u8 nb_planes;
49 u8 bpp;
50 u8 bpp_plane0;
51 u8 w_align;
52 u8 h_align;
53 };
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 struct bdisp_frame {
69 u32 width;
70 u32 height;
71 const struct bdisp_fmt *fmt;
72 enum v4l2_field field;
73 u32 bytesperline;
74 u32 sizeimage;
75 enum v4l2_colorspace colorspace;
76 struct v4l2_rect crop;
77 dma_addr_t paddr[4];
78 };
79
80
81
82
83
84
85
86
87
88
89 struct bdisp_request {
90 struct bdisp_frame src;
91 struct bdisp_frame dst;
92 unsigned int hflip:1;
93 unsigned int vflip:1;
94 int nb_req;
95 };
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113 struct bdisp_ctx {
114 struct bdisp_frame src;
115 struct bdisp_frame dst;
116 u32 state;
117 unsigned int hflip:1;
118 unsigned int vflip:1;
119 struct bdisp_dev *bdisp_dev;
120 struct bdisp_node *node[MAX_NB_NODE];
121 dma_addr_t node_paddr[MAX_NB_NODE];
122 struct v4l2_fh fh;
123 struct v4l2_ctrl_handler ctrl_handler;
124 struct bdisp_ctrls bdisp_ctrls;
125 bool ctrls_rdy;
126 };
127
128
129
130
131
132
133
134
135
136 struct bdisp_m2m_device {
137 struct video_device *vdev;
138 struct v4l2_m2m_dev *m2m_dev;
139 struct bdisp_ctx *ctx;
140 int refcnt;
141 };
142
143
144
145
146
147
148
149
150
151
152
153
154
155 struct bdisp_dbg {
156 struct dentry *debugfs_entry;
157 struct bdisp_node *copy_node[MAX_NB_NODE];
158 struct bdisp_request copy_request;
159 ktime_t hw_start;
160 s64 last_duration;
161 s64 min_duration;
162 s64 max_duration;
163 s64 tot_duration;
164 };
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185 struct bdisp_dev {
186 struct v4l2_device v4l2_dev;
187 struct video_device vdev;
188 struct platform_device *pdev;
189 struct device *dev;
190 spinlock_t slock;
191 struct mutex lock;
192 u16 id;
193 struct bdisp_m2m_device m2m;
194 unsigned long state;
195 struct clk *clock;
196 void __iomem *regs;
197 wait_queue_head_t irq_queue;
198 struct workqueue_struct *work_queue;
199 struct delayed_work timeout_work;
200 struct bdisp_dbg dbg;
201 };
202
203 void bdisp_hw_free_nodes(struct bdisp_ctx *ctx);
204 int bdisp_hw_alloc_nodes(struct bdisp_ctx *ctx);
205 void bdisp_hw_free_filters(struct device *dev);
206 int bdisp_hw_alloc_filters(struct device *dev);
207 int bdisp_hw_reset(struct bdisp_dev *bdisp);
208 int bdisp_hw_get_and_clear_irq(struct bdisp_dev *bdisp);
209 int bdisp_hw_update(struct bdisp_ctx *ctx);
210
211 void bdisp_debugfs_remove(struct bdisp_dev *bdisp);
212 int bdisp_debugfs_create(struct bdisp_dev *bdisp);
213 void bdisp_dbg_perf_begin(struct bdisp_dev *bdisp);
214 void bdisp_dbg_perf_end(struct bdisp_dev *bdisp);